当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::newFromDBkey方法代码示例

本文整理汇总了PHP中Title::newFromDBkey方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::newFromDBkey方法的具体用法?PHP Title::newFromDBkey怎么用?PHP Title::newFromDBkey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Title的用法示例。


在下文中一共展示了Title::newFromDBkey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute special page.  Only available to wikihow staff.
  */
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     # don't stop execution
     set_time_limit(0);
     print "querying database...<br>\n";
     $dbr = wfGetDB(DB_SLAVE);
     $titles = array();
     $sql = 'SELECT page_title FROM page WHERE page_namespace=' . NS_MAIN . ' AND page_is_redirect=0';
     $res = $dbr->query($sql);
     while ($obj = $res->fetchObject()) {
         $titles[] = Title::newFromDBkey($obj->page_title);
     }
     $wgOut->clearHTML();
     $file = '/tmp/out.csv';
     print "writing output to {$file}...<br>\n";
     $fp = fopen($file, 'w');
     fputs($fp, "url,new,new-format,old\n");
     foreach ($titles as $title) {
         $tt = TitleTests::newFromTitle($title);
         if (!$tt) {
             continue;
         }
         list($new, $format) = $tt->getTitle();
         list($old, ) = $tt->getOldTitle();
         $url = 'http://www.wikihow.com/' . $title->getPartialURL();
         $out = array($url, $new, $format, $old);
         fputcsv($fp, $out);
     }
     fclose($fp);
     print "done.<br>\n";
     exit;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:36,代码来源:GenTitleExtraInfo.body.php

示例2: execute

 /**
  * Show the special page
  *
  * @param $params Mixed: parameter(s) passed to the page or null
  */
 public function execute($params)
 {
     global $wgOut, $wgUser;
     // Check permissions
     if (!in_array('staff', $wgUser->getEffectiveGroups())) {
         throw new ErrorPageError('error', 'badaccess');
     }
     // Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     // If user is blocked, they don't need to access this page
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select('page', array('page_title'), array('page_namespace' => NS_USER), __METHOD__);
     $count = 0;
     // To avoid an annoying PHP notice
     foreach ($res as $row) {
         $user_name_title = Title::newFromDBkey($row->page_title);
         $user_name = $user_name_title->getText();
         $user_id = User::idFromName($user_name);
         if ($user_id > 0) {
             $s = $dbw->selectRow('user_profile', array('up_user_id'), array('up_user_id' => $user_id), __METHOD__);
             if ($s === false) {
                 $dbw->insert('user_profile', array('up_user_id' => $user_id, 'up_type' => 0), __METHOD__);
                 $count++;
             }
         }
     }
     $wgOut->addHTML(wfMsgExt('populate-user-profile-done', 'parsemag', $count));
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:40,代码来源:SpecialPopulateExistingUsersProfiles.php

示例3: NotifyOnSubPageChange

 /**
  * Adds users to watchlist if:
  * - User is watching parent page
  * - User has 'watchlistsubpages' turned on
  *
  * @param $watchers array of user ID
  * @param $title Title object
  * @param $editor User object
  * @param $notificationTimeoutSql string timeout to the watchlist
  *
  * @author Jakub Kurcek <jakub@wikia-inc.com>
  */
 public static function NotifyOnSubPageChange($watchers, $title, $editor, $notificationTimeoutSql)
 {
     wfProfileIn(__METHOD__);
     // Gets parent data
     $arrTitle = explode('/', $title->getDBkey());
     if (empty($arrTitle)) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // make Title
     $t = reset($arrTitle);
     $newTitle = Title::newFromDBkey($t);
     if (!$newTitle instanceof Title) {
         return true;
     }
     $dbw = wfGetDB(DB_MASTER);
     /** @var $dbw Database */
     $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_title' => $newTitle->getDBkey(), 'wl_namespace' => $newTitle->getNamespace(), 'wl_user != ' . intval($editor->getID()), $notificationTimeoutSql), __METHOD__);
     // Gets user settings
     $parentpageWatchers = array();
     while ($row = $dbw->fetchObject($res)) {
         $userId = intval($row->wl_user);
         $tmpUser = User::newFromId($userId);
         if ($tmpUser->getBoolOption(self::PREFERENCES_ENTRY)) {
             $parentpageWatchers[] = $userId;
         }
         unset($tmpUser);
     }
     // Updates parent watchlist timestamp for $parentOnlyWatchers.
     $parentOnlyWatchers = array_diff($parentpageWatchers, $watchers);
     $wl = WatchedItem::fromUserTitle($editor, $newTitle);
     $wl->updateWatch($parentOnlyWatchers);
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:47,代码来源:WatchSubPagesHelper.class.php

示例4: reprocessAllArticles

 /**
  * Add meta descriptions for all pages on site.  Convert all to the
  * given style.
  *
  * Commenting out this function because it's dangerous.  It could delete
  * all user-generated descriptions from the table.
  *
  */
 public static function reprocessAllArticles($style)
 {
     // pull all pages from DB
     $dbw = wfGetDB(DB_MASTER);
     $rows = $dbw->select('page', 'page_title', array('page_is_redirect' => 0, 'page_namespace' => NS_MAIN), __METHOD__);
     //array('LIMIT' => 100));
     $pages = array();
     foreach ($rows as $obj) {
         $pages[] = $obj->page_title;
     }
     // delete all existing meta descriptions not of the chosen style
     //$dbw->delete('article_meta_info', '*', __METHOD__);
     //$dbw->update('article_meta_info',
     //  array('ami_desc_style = ' . $style,
     //      "ami_desc = ''"),
     //  array('ami_desc_style <> ' . $style),
     //  __METHOD__);
     // process all pages, adding then chosen style description to them
     foreach ($pages as $page) {
         $title = Title::newFromDBkey($page);
         if ($title) {
             $ami = new ArticleMetaInfo($title, true);
             $ami->refreshMetaData($style);
             if (@$count++ % 10000 == 0 && $count > 0) {
                 print date('r') . " done {$count}\n";
             }
             sleep(2);
             // roll out slowly to prevent overwhelming servers with new image requests
         } else {
             print "title not found: {$page}\n";
         }
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:41,代码来源:reprocessMetaDescs.php

示例5: wfSajaxSearch

function wfSajaxSearch($term)
{
    global $wgContLang, $wgOut;
    $limit = 16;
    $l = new Linker();
    $term = str_replace(' ', '_', $wgContLang->ucfirst($wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)))));
    if (strlen(str_replace('_', '', $term)) < 3) {
        return;
    }
    $db =& wfGetDB(DB_SLAVE);
    $res = $db->select('page', 'page_title', array('page_namespace' => 0, "page_title LIKE '" . $db->strencode($term) . "%'"), "wfSajaxSearch", array('LIMIT' => $limit + 1));
    $r = "";
    $i = 0;
    while (($row = $db->fetchObject($res)) && ++$i <= $limit) {
        $nt = Title::newFromDBkey($row->page_title);
        $r .= '<li>' . $l->makeKnownLinkObj($nt) . "</li>\n";
    }
    if ($i > $limit) {
        $more = '<i>' . $l->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsg('moredotdotdot'), "namespace=0&from=" . wfUrlEncode($term)) . '</i>';
    } else {
        $more = '';
    }
    $subtitlemsg = Title::newFromText($term) ? 'searchsubtitle' : 'searchsubtitleinvalid';
    $subtitle = $wgOut->parse(wfMsg($subtitlemsg, wfEscapeWikiText($term)));
    #FIXME: parser is missing mTitle !
    $term = htmlspecialchars($term);
    $html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">' . wfMsg('hideresults') . '</a></div>' . '<h1 class="firstHeading">' . wfMsg('search') . '</h1><div id="contentSub">' . $subtitle . '</div><ul><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchcontaining', $term), "search={$term}&fulltext=Search") . '</li><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchnamed', $term), "search={$term}&go=Go") . "</li></ul><h2>" . wfMsg('articletitles', $term) . "</h2>" . '<ul>' . $r . '</ul>' . $more;
    $response = new AjaxResponse($html);
    $response->setCacheDuration(30 * 60);
    return $response;
}
开发者ID:negabaro,项目名称:alfresco,代码行数:31,代码来源:AjaxFunctions.php

示例6: checkDupImage

 /**
  * Check to see if an image was already uploaded for wikiphoto
  */
 public static function checkDupImage($filename)
 {
     $dbr = self::getDB('read');
     $contents = @file_get_contents($filename);
     if ($contents) {
         $sha1 = sha1($contents);
         $db_title = $dbr->selectField('images_sha1', 'is_page_title', array('is_sha1' => $sha1), __METHOD__);
         if ($db_title) {
             $title = Title::newFromDBkey('Image:' . $db_title);
             if ($title && $title->exists()) {
                 $file = wfFindFile($title);
                 if ($file) {
                     $path = $file->getPath();
                     if ($path && @file_exists($path)) {
                         $contents = @file_get_contents($path);
                         if ($contents) {
                             $sha1_orig = sha1($contents);
                             if ($sha1_orig == $sha1) {
                                 return $title->getText();
                             }
                         }
                     }
                 }
             }
         }
     }
     return '';
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:DupImage.class.php

示例7: getSelection

 public static function getSelection($maxUrls, $minImages)
 {
     $output = array();
     $dbr = wfGetDB(DB_SLAVE);
     $sql = 'SELECT pr_title FROM page_randomizer';
     $rows = parent::loadRows($dbr, $sql, '', __METHOD__);
     shuffle($rows);
     foreach ($rows as $row) {
         $wikitext = '';
         $steps = '';
         $titleDBkey = $row['pr_title'];
         $title = Title::newFromDBkey($titleDBkey);
         if ($title) {
             $wikitext = parent::getWikitext($dbr, $title);
         }
         if ($wikitext) {
             list($steps, ) = Wikitext::getStepsSection($wikitext);
         }
         if ($steps) {
             $images = parent::getNumStepsImages($steps);
             if ($images >= $minImages) {
                 $output[] = $title->getPartialURL();
                 if (count($output) >= $maxUrls) {
                     break;
                 }
             }
         }
     }
     return $output;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:30,代码来源:selectImagesRandomizerArticles.php

示例8: addAll404Redirects

function addAll404Redirects()
{
    $rows = DatabaseHelper::batchSelect('page', array('page_title', 'page_id'), array('page_namespace' => NS_MAIN, 'page_is_redirect' => 0), __METHOD__);
    foreach ($rows as $row) {
        $title = Title::newFromDBkey($row->page_title);
        if ($title) {
            Misc::modify404Redirect($row->page_id, $title);
        }
    }
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:10,代码来源:populate404Redirects.php

示例9: setUser2

 function setUser2($username)
 {
     $title1 = Title::newFromDBkey($username);
     $this->challenge_username2 = $title1->getText();
     $dbr =& wfGetDB(DB_SLAVE);
     $s = $dbr->selectRow('user', array('user_id'), array('user_name' => $this->challenge_username2), $fname);
     if ($s === false) {
         $this->challenge_user_id_2 = 0;
     } else {
         $this->challenge_user_id_2 = $s->user_id;
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:12,代码来源:ChallengeUser.php

示例10: __construct

	/**
	 * Constructor
	 *
	 * @param $username String: username (usually $wgUser's username)
	 * @param $filter String: passed to setFilter(); can be either 'user',
	 *                        'friends', 'foes' or 'all', depending on what
	 *                        kind of information is wanted
	 * @param $item_max Integer: maximum amount of items to display in the feed
	 */
	public function __construct( $username, $filter, $item_max ) {
		if ( $username ) {
			$title1 = Title::newFromDBkey( $username );
			$this->user_name = $title1->getText();
			$this->user_id = User::idFromName( $this->user_name );
		}
		$this->setFilter( $filter );
		$this->item_max = $item_max;
		$this->now = time();
		$this->three_days_ago = $this->now - ( 60 * 60 * 24 * 3 );
		$this->items_grouped = array();
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:UserActivityClass.php

示例11: searchHTML

 private static function searchHTML($terms)
 {
     $html = '';
     $html .= '<style>tr:nth-child(even) {background: #EEE}</style>';
     $html .= '<table>';
     $dbr = wfGetDB(DB_SLAVE);
     $terms = trim(strip_tags($terms));
     $terms = '%' . join('%', preg_split('@\\s+@', $terms)) . '%';
     $res = $dbr->select('page', array('page_title', 'page_is_redirect', 'page_id'), array('page_namespace' => NS_MAIN, 'LOWER(page_title) LIKE ' . $dbr->addQuotes($terms)), __METHOD__);
     foreach ($res as $row) {
         $id = $row->page_id;
         $title = Title::newFromDBkey($row->page_title);
         $html .= "<tr id='row_{$id}'>";
         $html .= '<td><a href="' . htmlspecialchars($title->getFullURL('redirect=no')) . '" target="_new">' . htmlspecialchars($title->getText()) . '</a>' . ($row->page_is_redirect ? ' <i>redirect</i>' : '') . '</td>';
         $html .= '<td><a href="#" class="delete" id="rm_' . $id . '">delete</a></td>';
         $html .= "</tr>\n";
     }
     $html .= "</table>";
     return $html;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:20,代码来源:AdminAnomalies.body.php

示例12: computeLatestAll

    /**
     * Compute the latest good revisions table for all articles.
     */
    public static function computeLatestAll()
    {
        $dbw = wfGetDB(DB_MASTER);
        $one_week_ago = wfTimestamp(TS_MW, time() - 7 * 24 * 60 * 60);
        $corrected = array();
        $updateRevFunc = function ($page_id, $page_title, $rev_id) {
            $title = Title::newFromDBkey($page_title);
            $goodRev = GoodRevision::newFromTitle($title, $page_id);
            if ($goodRev) {
                return $goodRev->updateRev($rev_id, true);
            } else {
                return false;
            }
        };
        // Clear from good_revision table all the deleted articles,
        // articles moved to other namespaces and articles
        // turned into redirects.
        $sql = 'DELETE good_revision FROM good_revision
				LEFT JOIN page ON gr_page = page_id
				WHERE page_is_redirect <> 0 OR
					page_namespace <> 0 OR
					page_title IS NULL';
        $dbw->query($sql, __METHOD__);
        $count = $dbw->affectedRows();
        print __METHOD__ . ": removed " . $dbw->affectedRows() . " non-article rows from good_revision table\n";
        // List all articles patrolled over the last week and
        // compute good_rev on them
        $sql = 'SELECT page_title, page_id, MAX(rc_id) AS rc_id
				FROM page, recentchanges 
				WHERE page_id = rc_cur_id AND
					page_namespace = 0 AND
					page_is_redirect = 0 AND
					rc_patrolled = 1 AND
					page_touched >= ' . $dbw->addQuotes($one_week_ago) . '
				GROUP BY rc_cur_id';
        $patrolled = array();
        $res = $dbw->query($sql, __METHOD__);
        foreach ($res as $obj) {
            $patrolled[$obj->page_id] = (array) $obj;
        }
        // Store recently patrolled articles with their patrolled revision
        foreach ($patrolled as $row) {
            $rev_id = GoodRevision::getRevFromRC($row['page_id'], $row['rc_id']);
            $updated = $updateRevFunc($row['page_id'], $row['page_title'], $rev_id);
            if ($updated) {
                $corrected[] = $row['page_id'];
            }
        }
        $count = count($corrected);
        print __METHOD__ . ": updated {$count} recently patrolled articles in good_revision table\n";
        // List all articles that haven't been touched in the last week
        // and correct their good revision if need
        $sql = 'SELECT page_title, page_id, page_latest
				FROM page
				WHERE page_namespace = 0 AND
					page_is_redirect = 0 AND
					page_touched < ' . $dbw->addQuotes($one_week_ago);
        $rows = array();
        $res = $dbw->query($sql, __METHOD__);
        foreach ($res as $obj) {
            $rows[] = (array) $obj;
        }
        // Store latest revision of all articles not edited in the last week
        foreach ($rows as $row) {
            if (!isset($patrolled[$row['page_id']])) {
                $updated = $updateRevFunc($row['page_id'], $row['page_title'], $row['page_latest']);
                if ($updated) {
                    $corrected[] = $row['page_id'];
                }
            }
        }
        print __METHOD__ . ": updated " . (count($corrected) - $count) . " older articles in good_revision table\n";
        // Call out to DailyEdits to let Titus and others know what should be recomputed
        foreach ($corrected as $aid) {
            DailyEdits::onGoodRevisionFixed($aid);
        }
    }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:80,代码来源:goodRevisionComputeAll.php

示例13: execute

	/**
	 * Show the special page
	 *
	 * @param $params Mixed: parameter(s) passed to the page or null
	 */
	public function execute( $params ) {
		global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts;

		// Can't use $this->setHeaders(); here because then it'll set the page
		// title to <removerelationship> and we don't want that, we'll be
		// messing with the page title later on in the code
		$wgOut->setArticleRelated( false );
		$wgOut->setRobotPolicy( 'noindex,nofollow' );

		$wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );

		$usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) );
		if ( !$usertitle ) {
			$wgOut->setPageTitle( wfMsgHtml( 'ur-error-title' ) );
			$wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) );
			return false;
		}

		$this->user_name_to = $usertitle->getText();
		$this->user_id_to = User::idFromName( $this->user_name_to );
		$this->relationship_type = UserRelationship::getUserRelationshipByID(
			$this->user_id_to,
			$wgUser->getID()
		);

		if ( $this->relationship_type == 1 ) {
			$confirmTitle = wfMsg( 'ur-remove-relationship-title-confirm-friend', $this->user_name_to );
			$confirmMsg = wfMsg( 'ur-remove-relationship-message-confirm-friend', $this->user_name_to );
			$error = wfMsg( 'ur-remove-error-not-loggedin-friend' );
			$pending = wfMsg( 'ur-remove-error-message-pending-friend-request', $this->user_name_to );
		} else {
			$confirmTitle = wfMsg( 'ur-remove-relationship-title-confirm-foe', $this->user_name_to );
			$confirmMsg = wfMsg( 'ur-remove-relationship-message-confirm-foe', $this->user_name_to );
			$error = wfMsg( 'ur-remove-error-not-loggedin-foe' );
			$pending = wfMsg( 'ur-remove-error-message-pending-foe-request', $this->user_name_to );
		}

		$out = '';
		if ( $wgUser->getID() == $this->user_id_to ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
			$out .= '<div class="relationship-error-message">' .
				wfMsg( 'ur-remove-error-message-remove-yourself' ) .
			'</div>
			<div>
				<input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
			if ( $wgUser->isLoggedIn() ) {
				$out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
			}
			$out .= '</div>';

			$wgOut->addHTML( $out );
		} elseif ( $this->relationship_type == false ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
			$out .= '<div class="relationship-error-message">' .
				wfMsg( 'ur-remove-error-message-no-relationship', $this->user_name_to ) .
			'</div>
			<div>
				<input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
			if ( $wgUser->isLoggedIn() ) {
				$out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
			}
			$out .= '</div>';

			$wgOut->addHTML( $out );
		} elseif ( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
			$out .= '<div class="relationship-error-message">' .
				$pending .
				'</div>
			<div>
				<input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
			if ( $wgUser->isLoggedIn() ) {
				$out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
			}
			$out .= '</div>';

			$wgOut->addHTML( $out );
		} elseif ( $wgUser->getID() == 0 ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
			$out .= '<div class="relationship-error-message">' .
				$error .
			'</div>
			<div>
				<input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
			if ( $wgUser->isLoggedIn() ) {
				$out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
			}
			$out .= '</div>';

			$wgOut->addHTML( $out );
		} else {
			$rel = new UserRelationship( $wgUser->getName() );
	 		if ( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
				$_SESSION['alreadysubmitted'] = true;
				$rel->removeRelationshipByUserID(
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SpecialRemoveRelationship.php

示例14: findDataItemForExpElement

 /**
  * Try to find an SMWDataItem that the given SMWExpElement might
  * represent. Returns null if this attempt failed.
  *
  * @param SMWExpElement $expElement
  * @return SMWDataItem or null
  */
 public static function findDataItemForExpElement(SMWExpElement $expElement)
 {
     global $wgContLang;
     $dataItem = null;
     if ($expElement instanceof SMWExpResource) {
         $uri = $expElement->getUri();
         $wikiNamespace = self::getNamespaceUri('wiki');
         if (strpos($uri, $wikiNamespace) === 0) {
             $localName = substr($uri, strlen($wikiNamespace));
             $dbKey = urldecode(self::decodeURI($localName));
             $parts = explode('-23', $dbKey, 2);
             if (count($parts) == 2) {
                 $subobjectname = $parts[1];
             } else {
                 $subobjectname = '';
             }
             $parts = explode(':', $dbKey, 2);
             if (count($parts) == 1) {
                 $dataItem = new SMWDIWikiPage($dbKey, NS_MAIN, '', $subobjectname);
             } else {
                 // try the by far most common cases directly before using Title
                 $namespaceName = str_replace('_', ' ', $parts[0]);
                 $namespaceId = -1;
                 foreach (array(SMW_NS_PROPERTY, NS_CATEGORY, NS_USER, NS_HELP) as $nsId) {
                     if ($namespaceName == $wgContLang->getNsText($nsId)) {
                         $namespaceId = $nsId;
                         break;
                     }
                 }
                 if ($namespaceId != -1) {
                     $dataItem = new SMWDIWikiPage($parts[1], $namespaceId, '', $subobjectname);
                 } else {
                     $title = Title::newFromDBkey($dbKey);
                     if (!is_null($title)) {
                         $dataItem = new SMWDIWikiPage($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), $subobjectname);
                     }
                 }
             }
         }
         // else: not in wiki namespace -- TODO: this could be an imported URI
     } else {
         // TODO (currently not needed, but will be useful for displaying external SPARQL results)
     }
     return $dataItem;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_Exporter.php

示例15: toggle

 public static function toggle($pagename)
 {
     global $wgUser;
     $title = Title::newFromDBkey($pagename);
     if (!$title) {
         return self::returnMsg(self::TITLE_INVALID, $protectState);
     }
     $aid = $title->getArticleID();
     // title must exist!
     if ($aid == 0) {
         return self::returnMsg(self::TITLE_INVALID, $protectState);
     }
     // user must have the required clearance
     if (!$wgUser->isAllowed('protect')) {
         return self::returnMsg(self::USER_INSUFFICIENT_RIGHT, $protectState);
     }
     $protectState = $title->isProtected('edit');
     // format the restriction
     //  whilst inverting the state...
     $group = $protectState ? '' : 'sysop';
     $restriction = array('edit' => $group);
     // update!
     $article = new Article($title);
     $code = $article->updateRestrictions($restriction);
     $msg = $code ? self::SUCCESS : self::FAILURE;
     // update protection status
     $protectState = $code ? !$protectState : $protectState;
     return self::returnMsg($msg, $protectState);
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:29,代码来源:QuickEditProtect.php


注:本文中的Title::newFromDBkey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。