/**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest;
     // Set page title and other stuff
     $this->setHeaders();
     # Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # If user is blocked, s/he doesn't need to access this page
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     $title = $wgRequest->getVal('wpTitle');
     $category = $wgRequest->getVal('wpCategory');
     if (empty($title) || empty($category)) {
         return;
     }
     $oTitle = Title::newFromText($title);
     if (!is_object($oTitle)) {
         return;
     }
     $oArticle = new Article($oTitle);
     if ($oTitle->exists()) {
         $text = $oArticle->getContent();
     } else {
         $text = self::getCreateplate($category);
     }
     $text .= "\n[[Category:" . $category . ']]';
     $oArticle->doEdit($text, wfMsgForContent('createincategory-comment', $category));
     $wgOut->redirect($oTitle->getFullUrl());
 }
 /**
  * Run a dtImport job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn(__METHOD__);
     if (is_null($this->title)) {
         $this->error = "dtImport: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     $article = new Article($this->title);
     if (!$article) {
         $this->error = 'dtImport: Article not found "' . $this->title->getPrefixedDBkey() . '"';
         wfProfileOut(__METHOD__);
         return false;
     }
     $for_pages_that_exist = $this->params['for_pages_that_exist'];
     if ($for_pages_that_exist == 'skip' && $this->title->exists()) {
         return true;
     }
     // change global $wgUser variable to the one specified by
     // the job only for the extent of this import
     global $wgUser;
     $actual_user = $wgUser;
     $wgUser = User::newFromId($this->params['user_id']);
     $text = $this->params['text'];
     if ($for_pages_that_exist == 'append' && $this->title->exists()) {
         $text = $article->getContent() . "\n" . $text;
     }
     $edit_summary = $this->params['edit_summary'];
     $article->doEdit($text, $edit_summary);
     $wgUser = $actual_user;
     wfProfileOut(__METHOD__);
     return true;
 }
Example #3
0
 /**
  * Run a refreshLinks job
  * @return boolean success
  */
 function run()
 {
     global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
     $wgTitle = $this->title;
     // FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
     $wgUser = User::newFromName('WeRelate agent');
     // set the user
     $treeId = $this->params['tree_id'];
     $treeName = $this->params['name'];
     $treeUser = $this->params['user'];
     $filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
     $ge = new GedcomExporter();
     $error = $ge->exportGedcom($treeId, $filename);
     if ($error) {
         $this->error = $error;
         return false;
     }
     // leave a message for the tree requester
     $userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
     $article = new Article($userTalkTitle, 0);
     if ($article->getID() != 0) {
         $text = $article->getContent();
     } else {
         $text = '';
     }
     $title = Title::makeTitle(NS_SPECIAL, 'Trees');
     $msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
     $text .= "\n\n" . $msg;
     $success = $article->doEdit($text, 'GEDCOM export ready');
     if (!$success) {
         $this->error = 'Unable to edit user talk page: ' . $treeUser;
         return false;
     }
     return true;
 }
Example #4
0
 protected function initialize()
 {
     global $wgParser;
     $article = new Article($this->mOriginTitle);
     $content = $article->getContent();
     $this->parse($content);
 }
Example #5
0
/**
 * adding the flag table to the comments form
 *
 * @global SFFormPrinter $sfgFormPrinter from SMW
 * @global Article $wgArticle
 * @param String $sHtml
 * @return boolean
 */
function onAddCommentsFormDiv(&$sHtml)
{
    global $sfgFormPrinter, $wgArticle, $webplatformSectionCommentsSMW;
    $sHtml .= '<a id="comments-flag-link">' . wfMessage('comments-flag-link')->text() . '</a>';
    $sHtml .= '<div id="comment-flags">';
    $sFormName = $webplatformSectionCommentsSMW['form'];
    //$sPageName = 'Comments';
    $oTitle = Title::newFromText($sFormName, SF_NS_FORM);
    $oArticle = new Article($oTitle, 0);
    $sFormDefinition = $oArticle->getContent();
    $sFormDefinition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $sFormDefinition);
    $aHtml = $sfgFormPrinter->formHTML($sFormDefinition, false, true, $oTitle->getArticleID(), $wgArticle->fetchContent());
    //, $wgArticle->getTitle()->getArticleID(), $wgArticle->fetchContent(), $wgArticle->getTitle()->getText(), null );
    $aMatches = array();
    preg_match_all('#<table.*?</table>#is', $aHtml[0], $aMatches);
    $index = null;
    foreach ($aMatches[0] as $key => $value) {
        $bPos = strrpos($value, $webplatformSectionCommentsSMW['template'] . '[');
        if ($bPos !== false) {
            $index = $key;
            break;
        }
    }
    $sHtml .= $aMatches[0][$index];
    $sHtml .= '</div>';
    return true;
}
 public function assertArticle(Article $article, $hash, $title, $author, $publicationDate, $content)
 {
     $this->assertEquals($article->getHash(), $hash);
     $this->assertEquals($article->getTitle(), $title);
     $this->assertEquals($article->getAuthor(), $author);
     $this->assertEquals($article->getPublicationDate(), $publicationDate);
     $this->assertEquals($article->getContent(), $content);
 }
	/**
	 * Fetches the content of a defined MediaWiki message.
	 *
	 * @param $name String: name of the MediaWiki message
	 * @return string or nothing
	 */
	static function getParam( $name ) {
		$nameTitle = Title::newFromText( $name, NS_MEDIAWIKI );
		if ( $nameTitle->exists() ) {
			$article = new Article( $nameTitle );
			return $article->getContent();
		} else {
			return '';
		}
	}
Example #8
0
 public function isArticleAnswered()
 {
     global $wgContLang;
     if (!self::isQuestion()) {
         return false;
     }
     $article = new Article($this->title);
     $content = $article->getContent();
     return self::isContentAnswered($content);
 }
 function getTextById($id)
 {
     $title = $this->getTitleObject('id', $id);
     if ($title == '') {
         return '';
     }
     $rev = new Article($title, 0);
     $text = $rev->getContent();
     return $text;
 }
Example #10
0
 public function addArticle($month, $day, $year, $page)
 {
     $lines = array();
     $temp = "";
     $head = array();
     $article = new Article(Title::newFromText($page));
     if (!$article->exists()) {
         return "";
     }
     $redirectCount = 0;
     if ($article->isRedirect() && $this->setting('disableredirects')) {
         return '';
     }
     while ($article->isRedirect() && $redirectCount < 10) {
         $redirectedArticleTitle = Title::newFromRedirect($article->getContent());
         $article = new Article($redirectedArticleTitle);
         $redirectCount += 1;
     }
     $body = $article->fetchContent(0, false, false);
     if (strlen(trim($body)) == 0) {
         return "";
     }
     $lines = split("\n", $body);
     $cntLines = count($lines);
     // dont use section events... only line 1 of the page
     if ($this->setting('disablesectionevents')) {
         $key = $lines[0];
         //initalize the key
         $head[$key] = "";
         $cntLines = 0;
     }
     for ($i = 0; $i < $cntLines; $i++) {
         $line = $lines[$i];
         if (substr($line, 0, 2) == '==') {
             $arr = split("==", $line);
             $key = $arr[1];
             $head[$key] = "";
             $temp = "";
         } else {
             if ($i == 0) {
                 // $i=0  means this is a one event page no (==event==) data
                 $key = $line;
                 //initalize the key
                 $head[$key] = "";
             } else {
                 $temp .= "{$line}\n";
                 $head[$key] = Common::cleanWiki($temp);
             }
         }
     }
     while (list($event, $body) = each($head)) {
         $this->buildEvent($month, $day, $year, trim($event), $page, $body);
     }
 }
Example #11
0
function efCondTemplateLoadPage($p)
{
    $title = Title::newFromText($p);
    if ($title->getArticleID() == 0) {
        $text = "<b>[[" . $p . ']]</b>';
    } else {
        $article = new Article($title);
        $text = $article->getContent();
    }
    return $text;
}
Example #12
0
 /**
  * Returns the contents of the specified wiki page, at either the
  * specified revision (if there is one) or the latest revision
  * (otherwise).
  */
 public static function getPageText($title, $revisionID = null)
 {
     if (method_exists('Revision', 'getContent')) {
         // MW >= 1.21
         $revision = Revision::newFromTitle($title, $revisionID);
         return $revision->getContent()->getNativeData();
     } else {
         $article = new Article($title, $revisionID);
         return $article->getContent();
     }
 }
 function setup()
 {
     global $wgParser, $wgHooks, $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions, $wgSecurityExtraActions, $wgSecurityExtraGroups, $wgRestrictionTypes, $wgRestrictionLevels, $wgGroupPermissions, $wgSecurityRenderInfo, $wgSecurityAllowUnreadableLinks, $wgSecurityGroupsArticle;
     # Add our hooks
     $wgHooks['UserGetRights'][] = $this;
     $wgHooks['ImgAuthBeforeStream'][] = $this;
     $wgParser->setFunctionHook('ifusercan', array($this, 'ifUserCan'));
     $wgParser->setFunctionHook('ifgroup', array($this, 'ifGroup'));
     if ($wgSecurityRenderInfo) {
         $wgHooks['OutputPageBeforeHTML'][] = $this;
     }
     if ($wgSecurityAllowUnreadableLinks) {
         $wgHooks['BeforePageDisplay'][] = $this;
     }
     # Add a new log type
     $wgLogTypes[] = 'security';
     $wgLogNames['security'] = 'securitylogpage';
     $wgLogHeaders['security'] = 'securitylogpagetext';
     $wgLogActions['security/deny'] = 'securitylogentry';
     # Each extra action is also a restriction type
     foreach ($wgSecurityExtraActions as $k => $v) {
         $wgRestrictionTypes[] = $k;
     }
     # Add extra available groups if $wgSecurityGroupsArticle is set
     if ($wgSecurityGroupsArticle) {
         $groups = new Article(Title::newFromText($wgSecurityGroupsArticle, NS_MEDIAWIKI));
         if (preg_match_all("/^\\*?\\s*(.+?)\\s*(\\|\\s*(.+))?\$/m", $groups->getContent(), $match)) {
             foreach ($match[1] as $i => $k) {
                 $v = $match[3][$i];
                 if ($v) {
                     $wgSecurityExtraGroups[strtolower($k)] = $v;
                 } else {
                     $wgSecurityExtraGroups[strtolower($k)] = '';
                 }
             }
         }
     }
     # Ensure the new groups show up in rights management
     # - note that 1.13 does a strange check in the ProtectionForm::buildSelector
     #   $wgUser->isAllowed($key) where $key is an item from $wgRestrictionLevels
     #   this requires that we treat the extra groups as an action and make sure its allowed by the user
     foreach ($wgSecurityExtraGroups as $k => $v) {
         if (is_numeric($k)) {
             $k = strtolower($v);
         }
         $wgRestrictionLevels[] = $k;
         $wgGroupPermissions[$k][$k] = true;
         # members of $k must be allowed to perform $k
         $wgGroupPermissions['sysop'][$k] = true;
         # sysops must be allowed to perform $k as well
     }
 }
Example #14
0
 public function update(Article $article)
 {
     $id = $article->getId();
     $content = mysqli_real_escape_string($article->getContent());
     $id_author = $article->getUser()->getId();
     $query = "UPDATE article SET content='" . $content . "', id_user='******' WHERE id='" . $id . "'";
     $res = mysqli_query($this->db, $query);
     if ($res) {
         return $this->findById($id);
     } else {
         return "Internal Server Error";
     }
 }
Example #15
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgParser, $wgTitle, $wgUser;
     $year = isset($_GET['year']) ? $_REQUEST['year'] : null;
     $month = isset($_GET['month']) ? $_REQUEST['month'] : null;
     $day = isset($_GET['day']) ? $_REQUEST['day'] : null;
     if ($year == "") {
         $year = date("Y");
     }
     if ($month == "") {
         $month = date("m");
     }
     # Don't show the navigation if we're including the page
     if (!$this->mIncluding) {
         $this->setHeaders();
         $wgOut->addWikiText(wfMsg('events-header'));
     }
     if ($day == "") {
         $wgOut->AddWikiText('<calendar>upcoming=off</calendar>');
         $day = "__";
     }
     //build the SQL query
     $dbr =& wfGetDB(DB_SLAVE);
     $sPageTable = $dbr->tableName('page');
     $categorylinks = $dbr->tableName('categorylinks');
     $sSqlSelect = "SELECT page_namespace, page_title, page_id, clike1.cl_to catlike1 ";
     $sSqlSelectFrom = "FROM {$sPageTable} INNER JOIN {$categorylinks} AS c1 ON page_id = c1.cl_from AND c1.cl_to='Events' INNER JOIN {$categorylinks} " . "AS clike1 ON page_id = clike1.cl_from AND clike1.cl_to LIKE '{$year}/{$month}/{$day}'";
     $sSqlWhere = ' WHERE page_is_redirect = 0 ';
     $sSqlOrderby = ' ORDER BY catlike1 ASC';
     //DEBUG: output SQL query
     //$wgOut->addHTML('[' . $sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby . ']');
     $res = $dbr->query($sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby);
     $sk =& $wgUser->getSkin();
     while ($row = $dbr->fetchObject($res)) {
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $wgOut->addHTML('<div class="eventsblock">');
         $title_text = $title->getSubpageText();
         $wgOut->addHTML('<b>' . $sk->makeKnownLinkObj($title, $title_text) . '</b><br>');
         $wl_article = new Article($title);
         $wl = $wl_article->getContent();
         $parserOptions = ParserOptions::newFromUser($wgUser);
         $parserOptions->setEditSection(false);
         $parserOptions->setTidy(true);
         $parserOutput = $wgParser->parse($wl, $title, $parserOptions);
         $previewHTML = $parserOutput->getText();
         $wgOut->addHTML($previewHTML);
         $wgOut->addHTML('</div>');
     }
 }
Example #16
0
function wfSpecialListFeed($par)
{
    global $wgUser, $wgOut;
    $fname = "wfSpecialListFeed";
    $sk = $wgUser->getSkin();
    $feeds = FeaturedArticles::getFeaturedArticles(11);
    $wgOut->addHTML("<ul>");
    foreach ($feeds as $item) {
        $feed = $item[0];
        $x = str_replace("http://wiki.ehow.com/", "", $feed);
        $x = str_replace("http://www.wikihow.com/", "", $feed);
        $t = Title::newFromDBKey($x);
        $summary = "";
        $a = null;
        if ($t->getArticleID() > 0) {
            $a = new Article(&$t);
            $summary = Article::getSection($a->getContent(false), 0);
            $summary = ereg_replace("<.*>", "", $summary);
            $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary);
            $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
            $summary = trim($summary);
            $tags = getTechnoratiTags($a->getContent(false));
        }
        $wgOut->addHTML("<div style='width:400px; border: 1px #ccc solid; margin-bottom:20px; padding: 10px; '>");
        $wgOut->addHTML("<img height=16 src='http://wiki.ehow.com/skins/common/images/check.jpg'><a href='{$feed}'>How to " . $t->getText() . "</a><br/><br/>");
        $wgOut->addHTML($summary);
        $wgOut->addHTML("<br/><a href='{$feed}'><i>Read more...</i></a><br/><br/><font size=-2>Posted " . $item[1] . " - (<a href='{$feed}'>Permalink</a>)");
        if ($tags != null) {
            $wgOut->addHTML(" (Technorati Tags: " . trim($tags) . ")");
        }
        $wgOut->addHTML("</font>");
        $wgOut->addHTML("</div>");
    }
    $wgOut->addHTML("</ul>");
    $wgOut->addHTML('<script type="text/javascript" src="http://embed.technorati.com/embed/unj3heqw9.js"></script>');
}
 /**
  * Hook callback for `FileUpload`
  *
  * @param Image $file
  */
 public static function upload($file, $reupload, $hasDescription)
 {
     # If we create the description page with the upload, there will be
     # a SearchUpdate when the page is created.
     # Otherwise, if the page exists there won't be a search index update,
     # so we have to trigger one ourselves
     if ($hasDescription) {
         global $wgDeferredUpdateList;
         $title = $file->getTitle();
         $article = new Article($title);
         $update = new SearchUpdate($title->getArticleId(), $title->getPrefixedText(), $article->getContent());
         array_push($wgDeferredUpdateList, $update);
     }
     return true;
 }
 /**
  * updatePages
  * updates infoboxes on all census enabled pages
  */
 public function updatePages()
 {
     wfProfileIn(__METHOD__);
     //get all pages from category
     $aReturn = ApiService::call(array('action' => 'query', 'list' => 'categorymembers', 'cmtitle' => CensusDataRetrieval::getFlagCategoryTitle()->getPrefixedDBkey(), 'cmnamespace' => '0'));
     //perform update foreach page from category
     foreach ($aReturn['query']['categorymembers'] as $cm) {
         $oTitle = Title::newFromText($cm['title']);
         $oArticle = new Article($oTitle);
         $newText = $this->getUpdatedContent($oArticle->getContent(), $oTitle);
         //save updated content
         $oArticle->doEdit($newText, 'Updating infobox with data from Sony DB', EDIT_UPDATE);
     }
     wfProfileOut(__METHOD__);
 }
Example #19
0
 /**
  * @desc Get list of albums (or song sections from Artist article)
  *
  * @param Article $article
  * @param string $artistName
  * @return array - Albums and song sections
  */
 public function getAlbums(Article $article, $artistName)
 {
     $albums = [];
     $text = $article->getContent();
     $sections = $this->getSections($text);
     foreach ($sections as $section) {
         if (preg_match('#==(.*?)==#mu', $section, $matches)) {
             $albumData = $this->getAlbumData($matches[1]);
             $albumData['image'] = $this->getAlbumPic($section, $artistName);
             $albumData['songs'] = $this->getAlbumSongs($section);
             $albums[] = $albumData;
         }
     }
     return $albums;
 }
Example #20
0
 /**
  * Fulfil the request; shows the form or reverts the file,
  * pending authentication, confirmation, etc.
  */
 public function execute()
 {
     global $wgOut, $wgRequest, $wgUser, $wgLang;
     $this->setHeaders();
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     } elseif (!$wgUser->isLoggedIn()) {
         $wgOut->showErrorPage('uploadnologin', 'uploadnologintext');
         return;
     } elseif (!$this->title->userCan('edit') || !$this->title->userCan('upload')) {
         // The standard read-only thing doesn't make a whole lot of sense
         // here; surely it should show the image or something? -- RC
         $article = new Article($this->title);
         $wgOut->readOnlyPage($article->getContent(), true);
         return;
     } elseif ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     $this->archiveName = $wgRequest->getText('oldimage');
     $token = $wgRequest->getText('wpEditToken');
     if (!$this->isValidOldSpec()) {
         $wgOut->showUnexpectedValueError('oldimage', htmlspecialchars($this->archiveName));
         return;
     }
     if (!$this->haveOldVersion()) {
         $wgOut->addHTML(wfMsgExt('filerevert-badversion', 'parse'));
         $wgOut->returnToMain(false, $this->title);
         return;
     }
     // Perform the reversion if appropriate
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($token, $this->archiveName)) {
         $source = $this->file->getArchiveVirtualUrl($this->archiveName);
         $comment = $wgRequest->getText('wpComment');
         // TODO: Preserve file properties from database instead of reloading from file
         $status = $this->file->upload($source, $comment, $comment);
         if ($status->isGood()) {
             $wgOut->addHTML(wfMsgExt('filerevert-success', 'parse', $this->title->getText(), $wgLang->date($this->getTimestamp(), true), $wgLang->time($this->getTimestamp(), true), wfExpandUrl($this->file->getArchiveUrl($this->archiveName))));
             $wgOut->returnToMain(false, $this->title);
         } else {
             $wgOut->addWikiText($status->getWikiText());
         }
         return;
     }
     // Show the form
     $this->showForm();
 }
 /**
 		Gets the 'raw' content from an article page.
 */
 public function getRawPage(&$obj)
 {
     if (!isset($obj) || empty($obj)) {
         return null;
     }
     if (!is_a($obj, 'Title')) {
         $title = self::getTitle($obj);
     } else {
         $title = $obj;
     }
     $article = new Article($title);
     if ($article->getID() == 0) {
         return null;
     }
     return $article->getContent();
 }
function efDisplayMessageDocumentation($editPage)
{
    global $wgTitle;
    if ($wgTitle->getNamespace() != NS_MEDIAWIKI) {
        return true;
    }
    $docTitle = Title::newFromText($wgTitle->getBaseText() . '/qqq', NS_MEDIAWIKI);
    $docArticle = new Article($docTitle);
    $wikitext = $docArticle->getContent();
    if (!empty($wikitext)) {
        $editPage->editFormTextBeforeContent .= Xml::openElement('div', array('class' => 'i18ndoc'));
        $editPage->editFormTextBeforeContent .= htmlspecialchars($wikitext);
        $editPage->editFormTextBeforeContent .= Xml::closeElement('div');
    }
    return true;
}
 /**
  * Constructor. Creates a new Parser. Does not automatically parse
  * the text. Call parseText afterwards.
  * @param t Text (String) or EditPage object to be parsed.
  * @param enc Encryption-object to use for encryption and decryption.
  */
 function ProtectionParser($t, &$enc)
 {
     $this->mEnc = $enc;
     if (strtolower(get_class($t)) == "editpage") {
         $text = $t->mArticle->getContent();
         $section = $this->getSection();
         if ($section > 0) {
             $art = new Article($t->mTitle);
             $art->getContent();
             $text = $art->mContent;
         }
         $this->mText = $text;
     } else {
         $this->mText = $t;
     }
 }
 /**
  * Our special overridden addPage.  Adds the H1 of the article content, 
  * instead of the title itself.
  *
  * @param $title Title the Title obj which represents the article.
  * @param $sortkey string What key are we sorted on.
  * @param $pageLength integer Ignored in our implementation.
  *
  */
 function addPage($title, $sortkey, $pageLength, $isRedirect = false)
 {
     global $wgContLang;
     $this->articleCount++;
     $textForm = $title->getText();
     if ($isRedirect) {
         // In rare chances where the title will conflict with another, make
         // all article elements sub-arrays
         if (!is_array($this->articles[strtoupper($textForm[0])])) {
             $this->articles[strtoupper($textForm[0])] = array();
         }
         $this->articles[strtoupper($textForm[0])] = '<span class="redirect-in-category">' . $this->getSkin()->makeKnownLinkObj($title) . '</span>';
     } else {
         // Not a redirect, a regular article.  Let's grab the h1, if
         // available.
         // Make sure we run the ArticleFromTitle hook...
         $article = null;
         wfRunHooks('ArticleFromTitle', array(&$title, &$article));
         if (!$article) {
             $article = new Article($title);
         }
         $article->LoadContent();
         preg_match('/^\\s*=(.*)=.*\\n?/', $article->getContent(), $matches);
         if (isset($matches[1])) {
             // We found a header in the content, use that as our h1
             $h1 = trim($matches[1]);
             if (strlen($h1) == 0) {
                 $h1 = trim($textForm);
             }
         } else {
             // Could not find a header, use the text form of our title
             $h1 = trim($textForm);
         }
         // Let's get the namespace, if any.
         $nsText = $title->getNsText();
         if ($nsText) {
             // Not in default namespace, add in parenthesis.
             $h1 .= " ({$nsText})";
         }
         // In rare chances where the title will conflict with another, make
         // all article elements sub-arrays
         if (!(isset($this->articles[strtoupper($h1[0])]) && is_array($this->articles[strtoupper($h1[0])]))) {
             $this->articles[strtoupper($h1[0])] = array();
         }
         $this->articles[strtoupper($h1[0])][] = $this->getSkin()->makeKnownLinkObj($title, htmlentities($h1));
     }
 }
function checkForEmpty($t)
{
    $deleteComment = "Deleting unused profile box page";
    if ($t) {
        $a = new Article($t);
        if ($a->exists()) {
            $content = $a->getContent();
            if ($content == "") {
                if ($a->doDeleteArticle($deleteComment)) {
                    echo $deleteComment . " " . $t->getText() . "\n";
                    return true;
                }
            }
        }
    }
    return false;
}
Example #26
0
 /**
  * Gets the text contents of a page with the passed-in Title object.
  */
 public static function getPageText($title)
 {
     if (method_exists('WikiPage', 'getContent')) {
         // MW 1.21+
         $wikiPage = new WikiPage($title);
         $content = $wikiPage->getContent();
         if ($content !== null) {
             return $content->getNativeData();
         } else {
             return null;
         }
     } else {
         // MW <= 1.20
         $article = new Article($title);
         return $article->getContent();
     }
 }
Example #27
0
 /**
  * Get the wikitext output from a form.
  * @param $form Mixed: Title object of the form to use, or a String form definition.
  * @param $data Array: Associative array as would be POSTed to the form.
  * @return Wikitext
  */
 public static function getWikitext($form, $data = array())
 {
     $printer = new SFFormPrinter();
     if ($form instanceof Title) {
         $article = new Article($form);
         $form = $article->getContent();
     }
     global $wgRequest;
     // Process into arrays and what not
     $data = self::convertFlatToArray($data);
     $oldRequest = $wgRequest;
     $wgRequest = new FauxRequest($data);
     $output = $printer->formHTML($form, count($data) > 0, false);
     list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $output;
     $wgRequest = $oldRequest;
     return $data_text;
 }
Example #28
0
 function setContent()
 {
     // Get the page content for later use
     $this->pageContent = $this->getContent();
     // If its a redirect, in order to get the *real* content for later use,
     // we have to load the text for the real page
     // Note: If $this->getContent is called anywhere before parent::view,
     // the real article text won't get loaded on the page
     if ($this->isRedirect($this->pageContent)) {
         wfDebugLog('LinkFilter', __METHOD__ . "\n");
         $target = $this->followRedirect();
         $rarticle = new Article($target);
         $this->pageContent = $rarticle->getContent();
         // if we don't clear, the page content will be [[redirect-blah]],
         // and not actual page
         $this->clear();
     }
 }
Example #29
0
 public function hUnknownAction($action, &$article)
 {
     // check if request 'action=formsubmit'
     if ($action != 'formsubmit') {
         return true;
     }
     // continue hook-chain.
     $article->loadContent();
     // follow redirects
     if ($article->mIsRedirect == true) {
         $title = Title::newFromRedirect($article->getContent());
         $article = new Article($title);
         $article->loadContent();
     }
     // Extract the code
     // Use our runphpClass helper
     $runphp = new runphpClass();
     $runphp->initFromContent($article->getContent());
     // Execute Code
     $code = $runphp->getCode(true);
     if (!empty($code)) {
         $callback = eval($code);
     }
     // we might implement functionality around a callback method in the future
     // Was there an expected class defined?
     $name = $article->mTitle->getDBkey();
     // the page name might actually be a sub-page; extract the basename without the full path.
     $pn = explode('/', $name);
     if (!empty($pn)) {
         $rn = array_reverse($pn);
         $name = $rn[0];
     }
     $name .= 'Class';
     if (class_exists($name)) {
         $class = new $name();
         if (is_object($class)) {
             if (method_exists($class, 'submit')) {
                 $class->submit();
             }
         }
     }
     // ... then it was a page built from ground up; nothing more to do here.
     return false;
 }
Example #30
0
 public function executeMain(&$text, $lang, $lines, $source = null)
 {
     switch ($source) {
         case 'page':
             $title = Title::newFromText($text);
             $article = new Article($title);
             $text = $article->getContent();
             break;
         case 'file':
             $text = $this->getFileText($text, $result);
             if (!$result) {
                 return $text;
             }
             break;
         default:
             // the text passed as argument.
             break;
     }
     return $this->highlight($text, $lang, $lines);
 }