/** * Get a message, with optional parameters * Parameters from user input must be escaped for HTML *before* passing to this function * * @access public * @param integer Message ID * @return string */ public function msg() { $args = func_get_args(); $errorId = array_shift($args); $errorLevel = floor($errorId / 1000); $errorMessageId = $errorId % 1000; if (\DynamicPageListHooks::getDebugLevel() >= $errorLevel) { if (\DynamicPageListHooks::isLikeIntersection()) { if ($errorId == \DynamicPageListHooks::FATAL_TOOMANYCATS) { $text = wfMessage('intersection_toomanycats', $args)->text(); } elseif ($errorId == \DynamicPageListHooks::FATAL_TOOFEWCATS) { $text = wfMessage('intersection_toofewcats', $args)->text(); } elseif ($errorId == \DynamicPageListHooks::WARN_NORESULTS) { $text = wfMessage('intersection_noresults', $args)->text(); } elseif ($errorId == \DynamicPageListHooks::FATAL_NOSELECTION) { $text = wfMessage('intersection_noincludecats', $args)->text(); } } if (empty($text)) { $text = wfMessage('dpl_log_' . $errorMessageId, $args)->text(); } $this->buffer[] = '<p>Extension:DynamicPageList (DPL), version ' . DPL_VERSION . ': ' . $text . '</p>'; } return false; }
/** * Main Constructor * * @access public * @return void */ public function __construct() { $this->setRichness(Config::getSetting('functionalRichness')); if (\DynamicPageListHooks::isLikeIntersection()) { $this->data['ordermethod'] = ['default' => 'categoryadd', 'values' => ['categoryadd', 'lastedit', 'none']]; $this->data['order'] = ['default' => 'descending', 'values' => ['ascending', 'descending']]; $this->data['mode'] = ['default' => 'unordered', 'values' => ['none', 'ordered', 'unordered']]; $this->data['userdateformat'] = ['default' => 'Y-m-d: ']; $this->data['allowcachedresults']['default'] = 'true'; } }
/** * Set the footer text. * * @access private * @param string Footer Text * @return void */ private function setFooter($footer) { if (\DynamicPageListHooks::getDebugLevel() == 5) { $footer .= '</nowiki></pre>'; } $this->footer = $this->replaceVariables($footer); }
/** * Clean and test 'fixcategory' parameter. * * @access public * @param string Options passed to parameter. * @return boolean Success */ public function _fixcategory($option) { \DynamicPageListHooks::fixCategory($option); return true; }
/** * Set SQL for 'ordermethod' parameter. * * @access private * @param mixed Parameter Option * @return void */ private function _ordermethod($option) { global $wgContLang; if ($this->parameters->getParameter('goal') == 'categories') { //No order methods for returning categories. return true; } $namespaces = $wgContLang->getNamespaces(); //$aStrictNs = array_slice((array) Config::getSetting('allowedNamespaces'), 1, count(Config::getSetting('allowedNamespaces')), true); $namespaces = array_slice($namespaces, 3, count($namespaces), true); $_namespaceIdToText = "CASE {$this->tableNames['page']}.page_namespace"; foreach ($namespaces as $id => $name) { $_namespaceIdToText .= ' WHEN ' . intval($id) . " THEN " . $this->DB->addQuotes($name . ':'); } $_namespaceIdToText .= ' END'; $revisionAuxWhereAdded = false; foreach ($option as $orderMethod) { switch ($orderMethod) { case 'category': $this->addOrderBy('cl_head.cl_to'); $this->addSelect(['cl_head.cl_to']); //Gives category headings in the result. if (is_array($this->parameters->getParameter('catheadings')) && in_array('', $this->parameters->getParameter('catheadings')) || is_array($this->parameters->getParameter('catnotheadings')) && in_array('', $this->parameters->getParameter('catnotheadings'))) { $_clTableName = 'dpl_clview'; $_clTableAlias = $_clTableName; } else { $_clTableName = 'categorylinks'; $_clTableAlias = 'cl_head'; } $this->addTable($_clTableName, $_clTableAlias); $this->addTable('revision', 'rev'); $this->addJoin($_clTableAlias, ["LEFT OUTER JOIN", "page_id = cl_head.cl_from"]); if (is_array($this->parameters->getParameter('catheadings')) && count($this->parameters->getParameter('catheadings'))) { $this->addWhere(["cl_head.cl_to" => $this->parameters->getParameter('catheadings')]); } if (is_array($this->parameters->getParameter('catnotheadings')) && count($this->parameters->getParameter('catnotheadings'))) { $this->addNotWhere(['cl_head.cl_to' => $this->parameters->getParameter('catnotheadings')]); } break; case 'categoryadd': //@TODO: See TODO in __addfirstcategorydate(). $this->addOrderBy('cl1.cl_timestamp'); break; case 'counter': if (class_exists("\\HitCounters\\Hooks")) { //If the "addpagecounter" parameter was not used the table and join need to be added now. if (!array_key_exists('hit_counter', $this->tables)) { $this->addTable('hit_counter', 'hit_counter'); if (!isset($this->join['hit_counter'])) { $this->addJoin('hit_counter', ["LEFT JOIN", "hit_counter.page_id = " . $this->tableNames['page'] . '.page_id']); } } $this->addOrderBy('hit_counter.page_counter'); } break; case 'firstedit': $this->addOrderBy('rev.rev_timestamp'); $this->setOrderDir('ASC'); $this->addTable('revision', 'rev'); $this->addSelect(['rev.rev_timestamp']); if (!$revisionAuxWhereAdded) { $this->addWhere(["{$this->tableNames['page']}.page_id = rev.rev_page", "rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page=rev.rev_page)"]); } $revisionAuxWhereAdded = true; break; case 'lastedit': if (\DynamicPageListHooks::isLikeIntersection()) { $this->addOrderBy('page_touched'); $this->addSelect(["page_touched" => "{$this->tableNames['page']}.page_touched"]); } else { $this->addOrderBy('rev.rev_timestamp'); $this->addTable('revision', 'rev'); $this->addSelect(['rev.rev_timestamp']); if (!$revisionAuxWhereAdded) { $this->addWhere(["{$this->tableNames['page']}.page_id = rev.rev_page", "rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page = rev.rev_page)"]); } $revisionAuxWhereAdded = true; } break; case 'pagesel': $this->addOrderBy('sortkey'); $this->addSelect(['sortkey' => 'CONCAT(pl.pl_namespace, pl.pl_title) ' . $this->getCollateSQL()]); break; case 'pagetouched': $this->addOrderBy('page_touched'); $this->addSelect(["page_touched" => "{$this->tableNames['page']}.page_touched"]); break; case 'size': $this->addOrderBy('page_len'); break; case 'sortkey': $this->addOrderBy('sortkey'); // If cl_sortkey is null (uncategorized page), generate a sortkey in the usual way (full page name, underscores replaced with spaces). // UTF-8 created problems with non-utf-8 MySQL databases $replaceConcat = "REPLACE(CONCAT({$_namespaceIdToText}, " . $this->tableNames['page'] . ".page_title), '_', ' ')"; if (count($this->parameters->getParameter('category')) + count($this->parameters->getParameter('notcategory')) > 0) { if (in_array('category', $this->parameters->getParameter('ordermethod'))) { $this->addSelect(['sortkey' => "IFNULL(cl_head.cl_sortkey, {$replaceConcat}) " . $this->getCollateSQL()]); } else { //This runs on the assumption that at least one category parameter was used and that numbering starts at 1. $this->addSelect(['sortkey' => "IFNULL(cl1.cl_sortkey, {$replaceConcat}) " . $this->getCollateSQL()]); } } else { $this->addSelect(['sortkey' => $replaceConcat . $collation]); } break; case 'titlewithoutnamespace': if ($this->parameters->getParameter('openreferences')) { $this->addOrderBy("pl_title"); } else { $this->addOrderBy("page_title"); } $this->addSelect(['sortkey' => "{$this->tableNames['page']}.page_title " . $this->getCollateSQL()]); break; case 'title': $this->addOrderBy('sortkey'); if ($this->parameters->getParameter('openreferences')) { $this->addSelect(['sortkey' => "REPLACE(CONCAT(IF(pl_namespace =0, '', CONCAT(" . $_namespaceIdToText . ", ':')), pl_title), '_', ' ') " . $this->getCollateSQL()]); } else { //Generate sortkey like for category links. UTF-8 created problems with non-utf-8 MySQL databases. $this->addSelect(['sortkey' => "REPLACE(CONCAT(IF(" . $this->tableNames['page'] . ".page_namespace = 0, '', CONCAT(" . $_namespaceIdToText . ", ':')), " . $this->tableNames['page'] . ".page_title), '_', ' ') " . $this->getCollateSQL()]); } break; case 'user': $this->addOrderBy('rev.rev_user_text'); $this->addTable('revision', 'rev'); $this->_adduser(null, 'rev'); break; case 'none': break; } } }
public static function endReset(&$parser, $text) { if (!self::$createdLinks['resetdone']) { self::$createdLinks['resetdone'] = true; foreach ($parser->mOutput->mCategories as $key => $val) { if (array_key_exists($key, self::$fixedCategories)) { self::$fixedCategories[$key] = $val; } } // $text .= self::dumpParsedRefs($parser,"before final reset"); if (self::$createdLinks['resetLinks']) { $parser->mOutput->mLinks = []; } if (self::$createdLinks['resetCategories']) { $parser->mOutput->mCategories = self::$fixedCategories; } if (self::$createdLinks['resetTemplates']) { $parser->mOutput->mTemplates = []; } if (self::$createdLinks['resetImages']) { $parser->mOutput->mImages = []; } // $text .= self::dumpParsedRefs($parser,"after final reset"); self::$fixedCategories = []; } return true; }