Esempio n. 1
0
 function tabAction($title, $message, $selected, $query = '', $checkEdit = false)
 {
     $classes = array();
     if ($selected) {
         $classes[] = 'selected';
     }
     if ($checkEdit && $title->getArticleId() == 0) {
         $classes[] = 'new';
         // WERELATE: removed action=edit
         //			$query = 'action=edit';
     }
     $text = wfMsg($message);
     if ($text == "<{$message}>") {
         global $wgContLang;
         $text = $wgContLang->getNsText(Namespac::getSubject($title->getNamespace()));
     }
     // WERELATE: added title attribute
     return array('class' => implode(' ', $classes), 'text' => $text, 'title' => $this->getMsgOrEmpty($message . 'tip'), 'href' => $title->getLocalUrl($query));
 }
Esempio n. 2
0
 public static function getWatchlistSummary($title, $text)
 {
     $mainNS = Namespac::getSubject($title->getNamespace());
     if ($mainNS == NS_PERSON) {
         $xml = StructuredData::getXml('person', $text);
         $summary = Person::getSummary($xml, $title);
     } else {
         if ($mainNS == NS_FAMILY) {
             $xml = StructuredData::getXml('family', $text);
             $summary = Family::getSummary($xml, $title);
         } else {
             $summary = '';
         }
     }
     return $summary;
 }
Esempio n. 3
0
 /**
  * Get a title object associated with the subject page of this
  * talk page
  *
  * @return Title the object for the subject page
  * @access public
  */
 function getSubjectPage()
 {
     return Title::makeTitle(Namespac::getSubject($this->getNamespace()), $this->getDBkey());
 }
Esempio n. 4
0
/**
 * Get index contents for specified page_id's
 *
 * @param unknown_type $args page_id=id,id,id,... (up to IAF_MAX_COUNT_CONTENTS)|index=1 to return watchers (defaults to 0)
 * @return IAF_SUCCESS, IAF_INVALID_ARG
 */
function wfGetPageIndexContents($args)
{
    global $wgAjaxCachePolicy;
    // set cache policy
    $wgAjaxCachePolicy->setPolicy(0);
    // validate input arguments
    $status = IAF_SUCCESS;
    $result = array();
    $args = iafGetArgs($args);
    $pageidString = iafGetArg($args, 'page_id', null);
    $index = iafGetArg($args, 'index', false);
    $pageids = explode(',', $pageidString);
    if (!$pageidString || count($pageids) > IAF_MAX_COUNT_CONTENTS) {
        $status = IAF_INVALID_ARG;
    } else {
        $db =& wfGetDB(DB_SLAVE);
        $db->ignoreErrors(true);
        foreach ($pageids as $pageid) {
            $ns = 0;
            $fullTitle = '';
            $timestamp = '';
            $revid = '';
            $text = '';
            $popularity = '';
            $users = array();
            $trees = array();
            $revision = Revision::loadFromPageId($db, $pageid);
            $errno = $db->lastErrno();
            if ($errno != 0) {
                $status = IAF_DB_ERROR;
                break;
            }
            if ($revision) {
                $ns = $revision->getTitle()->getNamespace();
                $fullTitle = $revision->getTitle()->getPrefixedText();
                $timestamp = $revision->getTimestamp();
                $revid = $revision->getId();
                $text =& $revision->getText();
                $errno = $db->lastErrno();
                if ($errno != 0) {
                    $status = IAF_DB_ERROR;
                    break;
                }
                if ($index) {
                    $watcherCount = 0;
                    $dbkey = $revision->getTitle()->getDBkey();
                    $rows = $db->select(array('watchlist', 'user'), array('user_name'), array('wl_user=user_id', 'wl_namespace' => $ns, 'wl_title' => $dbkey));
                    $errno = $db->lastErrno();
                    if ($errno != 0) {
                        $status = IAF_DB_ERROR;
                        break;
                    }
                    while ($row = $db->fetchObject($rows)) {
                        $users[] = '<user>' . StructuredData::escapeXml($row->user_name) . '</user>';
                        $watcherCount++;
                    }
                    $db->freeResult($rows);
                    $rows = $db->select(array('familytree_page', 'familytree'), array('ft_user', 'ft_name'), array('fp_tree_id=ft_tree_id', 'fp_namespace' => $ns, 'fp_title' => $dbkey));
                    $errno = $db->lastErrno();
                    if ($errno != 0) {
                        $status = IAF_DB_ERROR;
                        break;
                    }
                    while ($row = $db->fetchObject($rows)) {
                        $temp = $row->ft_user . '/' . $row->ft_name;
                        $trees[] = '<tree>' . StructuredData::escapeXml($temp) . '</tree>';
                    }
                    $db->freeResult($rows);
                    $wlhCount = 0;
                    $sns = Namespac::getSubject($ns);
                    if ($sns == NS_MAIN || $sns == NS_IMAGE || $sns == NS_CATEGORY || $sns == NS_PROJECT || $sns == NS_USER || $sns == NS_HELP || $sns == NS_SOURCE || $sns == NS_REPOSITORY || $sns == NS_PORTAL || $sns == NS_PLACE || $sns == NS_TRANSCRIPT) {
                        if (($ns == NS_SOURCE || $ns == NS_REPOSITORY) && ($dbkey == 'Family_History_Library' || $dbkey == 'Family_History_Center')) {
                            $wlhCount = 100000;
                        } else {
                            if ($ns == NS_IMAGE) {
                                $wlhCount = $db->selectField('imagelinks', 'count(*)', array('il_to' => $dbkey));
                            } else {
                                $wlhCount = $db->selectField('pagelinks', 'count(*)', array('pl_namespace' => $ns, 'pl_title' => $dbkey));
                            }
                        }
                        if ($ns == NS_PLACE || $ns == NS_USER || $ns == NS_CATEGORY) {
                            // discount links to place/user pages
                            $wlhCount = $wlhCount / 128;
                        }
                    }
                    $popularity = $watcherCount + $wlhCount > 0 ? max(20, min(384, floor(128 * log10($watcherCount * 4 + $wlhCount)))) : 0;
                }
            }
            $result[] = '<page page_id="' . $pageid . '" namespace="' . $ns . '" title="' . StructuredData::escapeXml($fullTitle) . '" rev_id="' . $revid . '" rev_timestamp="' . $timestamp . '" popularity="' . $popularity . '">' . '<contents>' . StructuredData::escapeXml($text) . '</contents>' . join("\n", $users) . join("\n", $trees) . '</page>';
        }
    }
    // return status
    return "<result status=\"{$status}\">" . join("\n", $result) . '</result>';
}