protected function setup($par)
 {
     global $wgEnableNewpagesUserFilter;
     // Options
     $opts = new FormOptions();
     $this->opts = $opts;
     // bind
     $opts->add('hideliu', false);
     $opts->add('hidepatrolled', $this->getUser()->getBoolOption('newpageshidepatrolled'));
     $opts->add('hidebots', false);
     $opts->add('hideredirs', true);
     $opts->add('limit', $this->getUser()->getIntOption('rclimit'));
     $opts->add('offset', '');
     $opts->add('namespace', '0');
     $opts->add('username', '');
     $opts->add('feed', '');
     $opts->add('tagfilter', '');
     $opts->add('invert', false);
     $this->customFilters = array();
     wfRunHooks('SpecialNewPagesFilters', array($this, &$this->customFilters));
     foreach ($this->customFilters as $key => $params) {
         $opts->add($key, $params['default']);
     }
     // Set values
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par) {
         $this->parseParams($par);
     }
     // Validate
     $opts->validateIntBounds('limit', 0, 5000);
     if (!$wgEnableNewpagesUserFilter) {
         $opts->setValue('username', '');
     }
 }
 function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('namespace', '', FormOptions::INTNULL);
     $opts->add('limit', 50);
     $opts->add('from', 0);
     $opts->add('back', 0);
     $opts->add('hideredirs', false);
     $opts->add('hidetrans', false);
     $opts->add('hidelinks', false);
     $opts->add('hideimages', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $opts->validateIntBounds('limit', 0, 5000);
     // Give precedence to subpage syntax
     if (isset($par)) {
         $opts->setValue('target', $par);
     }
     // Bind to member variable
     $this->opts = $opts;
     $this->target = Title::newFromURL($opts->getValue('target'));
     if (!$this->target) {
         $out->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->getSkin()->setRelevantTitle($this->target);
     $this->selfTitle = $this->getTitle($this->target->getPrefixedDBkey());
     $out->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
     $out->setSubtitle(wfMsg('whatlinkshere-backlink', Linker::link($this->target, $this->target->getPrefixedText(), array(), array('redirect' => 'no'))));
     $this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
 }
 protected function setup($par)
 {
     global $wgRequest, $wgUser, $wgEnableNewpagesUserFilter;
     // Options
     $opts = new FormOptions();
     $this->opts = $opts;
     // bind
     $opts->add('hideliu', false);
     $opts->add('hidepatrolled', false);
     $opts->add('hidebots', false);
     $opts->add('hideredirs', true);
     $opts->add('limit', (int) $wgUser->getOption('rclimit'));
     $opts->add('offset', '');
     $opts->add('namespace', '0');
     $opts->add('username', '');
     $opts->add('feed', '');
     // Set values
     $opts->fetchValuesFromRequest($wgRequest);
     if ($par) {
         $this->parseParams($par);
     }
     // Validate
     $opts->validateIntBounds('limit', 0, 5000);
     if (!$wgEnableNewpagesUserFilter) {
         $opts->setValue('username', '');
     }
     // Store some objects
     $this->skin = $wgUser->getSkin();
 }
 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $this->addHelpLink('Help:New images');
     $opts = new FormOptions();
     $opts->add('like', '');
     $opts->add('showbots', false);
     $opts->add('hidepatrolled', false);
     $opts->add('limit', 50);
     $opts->add('offset', '');
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par !== null) {
         $opts->setValue(is_numeric($par) ? 'limit' : 'like', $par);
     }
     $opts->validateIntBounds('limit', 0, 500);
     $this->opts = $opts;
     if (!$this->including()) {
         $this->setTopText();
         $this->buildForm();
     }
     $pager = new NewFilesPager($this->getContext(), $opts);
     $out->addHTML($pager->getBody());
     if (!$this->including()) {
         $out->addHTML($pager->getNavigationBar());
     }
 }
Exemple #5
0
 public function setup()
 {
     global $wgRequest;
     $opts = new FormOptions();
     // Bind to the member variable
     $this->opts = $opts;
     $opts->add('mode', self::MODE_STATS);
     $opts->add('image', APCImages::IMG_NONE);
     $opts->add('clearcache', false);
     $opts->add('limit', 20);
     $opts->add('offset', 0);
     $opts->add('display', '');
     $opts->add('delete', '');
     $opts->add('sort', 'hits');
     $opts->add('sortdir', 0);
     $opts->add('scope', 'active');
     $opts->add('searchi', '');
     // MediaWiki captures search, ARGH!
     $opts->fetchValuesFromRequest($wgRequest);
     $opts->validateIntBounds('limit', 0, 5000);
     $opts->validateIntBounds('sortdir', 0, 1);
     $this->opts->consumeValues(array('display', 'clearcache', 'image'));
 }
 function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $this->addHelpLink('Help:What links here');
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('namespace', '', FormOptions::INTNULL);
     $opts->add('limit', $this->getConfig()->get('QueryPageDefaultLimit'));
     $opts->add('from', 0);
     $opts->add('back', 0);
     $opts->add('hideredirs', false);
     $opts->add('hidetrans', false);
     $opts->add('hidelinks', false);
     $opts->add('hideimages', false);
     $opts->add('invert', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $opts->validateIntBounds('limit', 0, 5000);
     // Give precedence to subpage syntax
     if ($par !== null) {
         $opts->setValue('target', $par);
     }
     // Bind to member variable
     $this->opts = $opts;
     $this->target = Title::newFromText($opts->getValue('target'));
     if (!$this->target) {
         if (!$this->including()) {
             $out->addHTML($this->whatlinkshereForm());
         }
         return;
     }
     $this->getSkin()->setRelevantTitle($this->target);
     $this->selfTitle = $this->getPageTitle($this->target->getPrefixedDBkey());
     $out->setPageTitle($this->msg('whatlinkshere-title', $this->target->getPrefixedText()));
     $out->addBacklinkSubtitle($this->target);
     $this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
 }
 public function validateOptions(FormOptions $opts)
 {
     $opts->validateIntBounds('limit', 0, 5000);
     parent::validateOptions($opts);
 }
	public function execute( $par ) {
		global $wgOut, $wgRequest;

		$opts = new FormOptions();
		$opts->add( 'graphit', false );
		$opts->add( 'preview', false );
		$opts->add( 'language', '' );
		$opts->add( 'count', 'edits' );
		$opts->add( 'scale', 'days' );
		$opts->add( 'days', 30 );
		$opts->add( 'width', 600 );
		$opts->add( 'height', 400 );
		$opts->add( 'group', '' );
		$opts->add( 'uselang', '' );
		$opts->add( 'start', '' );
		$opts->fetchValuesFromRequest( $wgRequest );

		$pars = explode( ';', $par );

		foreach ( $pars as $item ) {
			if ( strpos( $item, '=' ) === false ) {
				continue;
			}

			list( $key, $value ) = array_map( 'trim', explode( '=', $item, 2 ) );
			if ( isset( $opts[$key] ) ) {
				$opts[$key] = $value;
			}
		}

		$opts->validateIntBounds( 'days', 1, 10000 );
		$opts->validateIntBounds( 'width', 200, 1000 );
		$opts->validateIntBounds( 'height', 200, 1000 );
		if ( $opts['start'] !== '' ) {
			$opts['start'] = strval( wfTimestamp( TS_MW, $opts['start'] ) );
		}

		$validScales = array( 'months', 'weeks', 'days', 'hours' );
		if ( !in_array( $opts['scale'], $validScales ) ) {
			$opts['scale'] = 'days';
		}

		if ( $opts['scale'] === 'hours' ) {
			$opts->validateIntBounds( 'days', 1, 4 );
		}

		$validCounts = array( 'edits', 'users', 'registrations' );
		if ( !in_array( $opts['count'], $validCounts ) ) {
			$opts['count'] = 'edits';
		}

		foreach ( array( 'group', 'language' ) as $t ) {
			$values = array_map( 'trim', explode( ',', $opts[$t] ) );
			$values = array_splice( $values, 0, 4 );
			if ( $t === 'group' ) {
				// BC for old syntax which replaced _ to | which was not allowed
				$values = preg_replace( '~^page_~', 'page-', $values );
			}
			$opts[$t] = implode( ',', $values );
		}

		if ( $this->including() ) {
			$wgOut->addHTML( $this->image( $opts ) );
		} elseif ( $opts['graphit'] ) {

			if ( !class_exists( 'PHPlot' ) ) {
				header( "HTTP/1.0 500 Multi fail" );
				echo "PHPlot not found";
			}

			if ( !$wgRequest->getBool( 'debug' ) ) {
				$wgOut->disable();
				header( 'Content-Type: image/png' );
				header( 'Cache-Control: private, max-age=3600' );
				header( 'Expires: ' . wfTimestamp( TS_RFC2822, time() + 3600 ) );
			}
			$this->draw( $opts );


		} else {
			$this->form( $opts );
		}
	}
 public function validateOptions(FormOptions $opts)
 {
     global $wgFeedLimit;
     $opts->validateIntBounds('limit', 0, $this->feedFormat ? $wgFeedLimit : 5000);
     parent::validateOptions($opts);
 }
 public function execute($par)
 {
     global $wgOut, $wgRequest;
     $opts = new FormOptions();
     $opts->add('graphit', false);
     $opts->add('preview', false);
     $opts->add('language', '');
     $opts->add('count', 'edits');
     $opts->add('scale', 'days');
     $opts->add('days', 30);
     // now
     $endday = time();
     $opts->add('endday', date('j', $endday));
     $opts->add('endmonth', (int) date('n', $endday));
     $opts->add('endyear', date('Y', $endday));
     // enddate - 30 days
     $startday = $endday - 2592000;
     $opts->add('startday', date('j', $startday));
     $opts->add('startmonth', (int) date('n', $startday));
     $opts->add('startyear', date('Y', $startday));
     $opts->add('width', 600);
     $opts->add('height', 400);
     $opts->add('group', '');
     $opts->add('uselang', '');
     $opts->fetchValuesFromRequest($wgRequest);
     $pars = explode(';', $par);
     foreach ($pars as $item) {
         if (strpos($item, '=') === false) {
             continue;
         }
         list($key, $value) = array_map('trim', explode('=', $item, 2));
         if (isset($opts[$key])) {
             $opts[$key] = $value;
         }
     }
     $opts->validateIntBounds('days', 1, 10000);
     $opts->validateIntBounds('width', 200, 1000);
     $opts->validateIntBounds('height', 200, 1000);
     $validScales = array('months', 'weeks', 'days', 'hours');
     if (!in_array($opts['scale'], $validScales)) {
         $opts['scale'] = 'days';
     }
     if ($opts['scale'] === 'hours') {
         $opts->validateIntBounds('days', 1, 4);
     }
     $validCounts = array('edits', 'users', 'registrations');
     if (!in_array($opts['count'], $validCounts)) {
         $opts['count'] = 'edits';
     }
     foreach (array('group', 'language') as $t) {
         $values = array_map('trim', explode(',', $opts[$t]));
         $values = array_splice($values, 0, 4);
         if ($t === 'group') {
             $values = preg_replace('~^page_~', 'page|', $values);
         }
         $opts[$t] = implode(',', $values);
     }
     $validRange = $this->checkDates($opts);
     if ($this->including()) {
         if ($validRange) {
             $wgOut->addHTML($this->image($opts));
         }
     } elseif ($opts['graphit']) {
         if (!class_exists('PHPlot')) {
             header("HTTP/1.0 500 Multi fail");
             echo "PHPlot not found";
         }
         if (!$validRange) {
             header("HTTP/1.0 500 Multi fail");
             echo "Invalid date range";
         }
         if (!$wgRequest->getBool('debug')) {
             $wgOut->disable();
             header('Content-Type: image/png');
             header('Cache-Control: private, max-age=3600');
             header('Expires: ' . wfTimestamp(TS_RFC2822, time() + 3600));
         }
         $this->draw($opts);
     } else {
         if (!$validRange) {
             $wgOut->addHTML('<p>' . wfMsg('translationstats-invalid-range') . '</p>');
         }
         $this->form($opts);
         /* check if form has been posted */
         if ($validRange && $wgRequest->getVal('preview')) {
             $this->table($opts);
         }
     }
 }