Special:Log: Convert to HTMLForm
[lhc/web/wiklou.git] / includes / specials / SpecialLog.php
index 6a11bf4..359eede 100644 (file)
@@ -46,11 +46,13 @@ class SpecialLog extends SpecialPage {
                $opts->add( 'pattern', false );
                $opts->add( 'year', null, FormOptions::INTNULL );
                $opts->add( 'month', null, FormOptions::INTNULL );
+               $opts->add( 'day', null, FormOptions::INTNULL );
                $opts->add( 'tagfilter', '' );
                $opts->add( 'offset', '' );
                $opts->add( 'dir', '' );
                $opts->add( 'offender', '' );
                $opts->add( 'subtype', '' );
+               $opts->add( 'logid', '' );
 
                // Set values
                $opts->fetchValuesFromRequest( $this->getRequest() );
@@ -58,6 +60,17 @@ class SpecialLog extends SpecialPage {
                        $this->parseParams( $opts, (string)$par );
                }
 
+               // Set date values
+               $dateString = $this->getRequest()->getVal( 'wpdate' );
+               if ( !empty( $dateString ) ) {
+                       $dateStamp = MWTimestamp::getInstance( $dateString . ' 00:00:00' );
+                       $dateStamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) );
+
+                       $opts->setValue( 'year', (int)$dateStamp->format( 'Y' ) );
+                       $opts->setValue( 'month', (int)$dateStamp->format( 'm' ) );
+                       $opts->setValue( 'day', (int)$dateStamp->format( 'd' ) );
+               }
+
                # Don't let the user get stuck with a certain date
                if ( $opts->getValue( 'offset' ) || $opts->getValue( 'dir' ) == 'prev' ) {
                        $opts->setValue( 'year', '' );
@@ -169,6 +182,16 @@ class SpecialLog extends SpecialPage {
                return $subpages;
        }
 
+       /**
+        * Set options based on the subpage title parts:
+        * - One part that is a valid log type: Special:Log/logtype
+        * - Two parts: Special:Log/logtype/username
+        * - Otherwise, assume the whole subpage is a username.
+        *
+        * @param FormOptions $opts
+        * @param $par
+        * @throws ConfigException
+        */
        private function parseParams( FormOptions $opts, $par ) {
                # Get parameters
                $par = $par !== null ? $par : '';
@@ -203,8 +226,10 @@ class SpecialLog extends SpecialPage {
                        $extraConds,
                        $opts->getValue( 'year' ),
                        $opts->getValue( 'month' ),
+                       $opts->getValue( 'day' ),
                        $opts->getValue( 'tagfilter' ),
-                       $opts->getValue( 'subtype' )
+                       $opts->getValue( 'subtype' ),
+                       $opts->getValue( 'logid' )
                );
 
                $this->addHeader( $opts->getValue( 'type' ) );
@@ -223,6 +248,7 @@ class SpecialLog extends SpecialPage {
                        $pager->getPattern(),
                        $pager->getYear(),
                        $pager->getMonth(),
+                       $pager->getDay(),
                        $pager->getFilterParams(),
                        $pager->getTagFilter(),
                        $pager->getAction()