function getParameter($name, $default = null) { // {handler}.{method}:{parameters} if (preg_match("/^(\\w+(?:\\.\\w+)?):(\\w+)\$/", $name, $aux)) { if ($aux[2] == 'handler_file') { $res = $this->__h_include("{$aux[1]}.main"); return $res[0]; } $value = null; // load in cascade ... $hc = explode('_', $aux[1]); $origin = null; $ct = count($hc); for ($i = $ct; $i > 0; $i--) { $hc_c = implode('_', $hc); // ... from cache if (isset($GLOBALS['tt780'][$this->id]['parameters'][$hc_c]) && isset($GLOBALS['tt780'][$this->id]['parameters'][$hc_c][$aux[2]])) { $value = $GLOBALS['tt780'][$this->id]['parameters'][$hc_c][$aux[2]]; break; } // ... from configuration if (isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]) && is_array($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]) && isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters']) && isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters'][$aux[2]])) { $origin = true; $value = $GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters'][$aux[2]]; break; } array_pop($hc); } if ($value) { $pre = array(); $pre[$aux[2]] = $value; $pre2 = new Parameters(); if ($origin) { $pre2->origin('configuration_file'); } $pre2->concat($GLOBALS['tt780'][$this->id]['globals']); // por si necesita valores de contexto $pre2->concat($pre); $res = $pre2->getParameter($aux[2], $default); return $res; } } // ??? $cursor = count($this->cursor); if ($cursor > 0 && isset($this->cursor[$cursor - 1]) && isset($this->cursor[$cursor - 1][$name])) { return $this->cursor[$cursor - 1][$name]; } return $GLOBALS['tt780'][$this->id]['globals']->getParameter($name, $default); }
/** * Initialize a new instance from a database row. * * @access public * @param array Database Row * @param object \DPL\Parameters Object * @param object Mediawiki Title Object * @param integer Page Namespace ID * @param string Page Title as Selected from Query * @return object \DPL\Article Object */ public static function newFromRow($row, Parameters $parameters, \Title $title, $pageNamespace, $pageTitle) { global $wgLang, $wgContLang; $article = new Article($title, $pageNamespace); $titleText = $title->getText(); if ($parameters->getParameter('shownamespace') === true) { $titleText = $title->getPrefixedText(); } if ($parameters->getParameter('replaceintitle') !== null) { $titleText = preg_replace($parameters->getParameter('replaceintitle')[0], $parameters->getParameter('replaceintitle')[1], $titleText); } //Chop off title if longer than the 'titlemaxlen' parameter. if ($parameters->getParameter('titlemaxlen') !== null && strlen($titleText) > $parameters->getParameter('titlemaxlen')) { $titleText = substr($titleText, 0, $parameters->getParameter('titlemaxlen')) . '...'; } if ($parameters->getParameter('showcurid') === true && isset($row['page_id'])) { $articleLink = '[' . $title->getLinkURL(['curid' => $row['page_id']]) . ' ' . htmlspecialchars($titleText) . ']'; } else { $articleLink = '[[' . ($parameters->getParameter('escapelinks') && ($pageNamespace == NS_CATEGORY || $pageNamespace == NS_FILE) ? ':' : '') . $title->getFullText() . '|' . htmlspecialchars($titleText) . ']]'; } $article->mLink = $articleLink; //get first char used for category-style output if (isset($row['sortkey'])) { $article->mStartChar = $wgContLang->convert($wgContLang->firstChar($row['sortkey'])); } else { $article->mStartChar = $wgContLang->convert($wgContLang->firstChar($pageTitle)); } $article->mID = intval($row['page_id']); //External link if (isset($row['el_to'])) { $article->mExternalLink = $row['el_to']; } //SHOW PAGE_COUNTER if (isset($row['page_counter'])) { $article->mCounter = $row['page_counter']; } //SHOW PAGE_SIZE if (isset($row['page_len'])) { $article->mSize = $row['page_len']; } //STORE initially selected PAGE if (count($parameters->getParameter('linksto')) || count($parameters->getParameter('linksfrom'))) { if (!isset($row['sel_title'])) { $article->mSelTitle = 'unknown page'; $article->mSelNamespace = 0; } else { $article->mSelTitle = $row['sel_title']; $article->mSelNamespace = $row['sel_ns']; } } //STORE selected image if (count($parameters->getParameter('imageused')) > 0) { if (!isset($row['image_sel_title'])) { $article->mImageSelTitle = 'unknown image'; } else { $article->mImageSelTitle = $row['image_sel_title']; } } if ($parameters->getParameter('goal') != 'categories') { //REVISION SPECIFIED if ($parameters->getParameter('lastrevisionbefore') || $parameters->getParameter('allrevisionsbefore') || $parameters->getParameter('firstrevisionsince') || $parameters->getParameter('allrevisionssince')) { $article->mRevision = $row['rev_id']; $article->mUser = $row['rev_user_text']; $article->mDate = $row['rev_timestamp']; $article->mComment = $row['rev_comment']; } //SHOW "PAGE_TOUCHED" DATE, "FIRSTCATEGORYDATE" OR (FIRST/LAST) EDIT DATE if ($parameters->getParameter('addpagetoucheddate')) { $article->mDate = $row['page_touched']; } elseif ($parameters->getParameter('addfirstcategorydate')) { $article->mDate = $row['cl_timestamp']; } elseif ($parameters->getParameter('addeditdate') && isset($row['rev_timestamp'])) { $article->mDate = $row['rev_timestamp']; } elseif ($parameters->getParameter('addeditdate') && isset($row['page_touched'])) { $article->mDate = $row['page_touched']; } //Time zone adjustment if ($article->mDate) { $article->mDate = $wgLang->userAdjust($article->mDate); } if ($article->mDate && $parameters->getParameter('userdateformat')) { //Apply the userdateformat $article->myDate = gmdate($parameters->getParameter('userdateformat'), wfTimeStamp(TS_UNIX, $article->mDate)); } // CONTRIBUTION, CONTRIBUTOR if ($parameters->getParameter('addcontribution')) { $article->mContribution = $row['contribution']; $article->mContributor = $row['contributor']; $article->mContrib = substr('*****************', 0, round(log($row['contribution']))); } //USER/AUTHOR(S) // because we are going to do a recursive parse at the end of the output phase // we have to generate wiki syntax for linking to a userĀ“s homepage if ($parameters->getParameter('adduser') || $parameters->getParameter('addauthor') || $parameters->getParameter('addlasteditor')) { $article->mUserLink = '[[User:'******'rev_user_text'] . '|' . $row['rev_user_text'] . ']]'; $article->mUser = $row['rev_user_text']; } //CATEGORY LINKS FROM CURRENT PAGE if ($parameters->getParameter('addcategories') && $row['cats']) { $artCatNames = explode(' | ', $row['cats']); foreach ($artCatNames as $artCatName) { $article->mCategoryLinks[] = '[[:Category:' . $artCatName . '|' . str_replace('_', ' ', $artCatName) . ']]'; $article->mCategoryTexts[] = str_replace('_', ' ', $artCatName); } } // PARENT HEADING (category of the page, editor (user) of the page, etc. Depends on ordermethod param) if ($parameters->getParameter('headingmode') != 'none') { switch ($parameters->getParameter('ordermethod')[0]) { case 'category': //Count one more page in this heading self::$headings[$row['cl_to']] = isset(self::$headings[$row['cl_to']]) ? self::$headings[$row['cl_to']] + 1 : 1; if ($row['cl_to'] == '') { //uncategorized page (used if ordermethod=category,...) $article->mParentHLink = '[[:Special:Uncategorizedpages|' . wfMsg('uncategorizedpages') . ']]'; } else { $article->mParentHLink = '[[:Category:' . $row['cl_to'] . '|' . str_replace('_', ' ', $row['cl_to']) . ']]'; } break; case 'user': self::$headings[$row['rev_user_text']] = isset(self::$headings[$row['rev_user_text']]) ? self::$headings[$row['rev_user_text']] + 1 : 1; if ($row['rev_user'] == 0) { //anonymous user $article->mParentHLink = '[[User:'******'rev_user_text'] . '|' . $row['rev_user_text'] . ']]'; } else { $article->mParentHLink = '[[User:'******'rev_user_text'] . '|' . $row['rev_user_text'] . ']]'; } break; } } } return $article; }