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


PHP LinkBatch::setArray方法代码示例

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


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

示例1: formatCategoryLinks

 private function formatCategoryLinks($links)
 {
     $result = array();
     if (!$links) {
         return $result;
     }
     // Fetch hiddencat property
     $lb = new LinkBatch();
     $lb->setArray(array(NS_CATEGORY => $links));
     $db = $this->getDB();
     $res = $db->select(array('page', 'page_props'), array('page_title', 'pp_propname'), $lb->constructSet('page', $db), __METHOD__, array(), array('page_props' => array('LEFT JOIN', array('pp_propname' => 'hiddencat', 'pp_page = page_id'))));
     $hiddencats = array();
     foreach ($res as $row) {
         $hiddencats[$row->page_title] = isset($row->pp_propname);
     }
     foreach ($links as $link => $sortkey) {
         $entry = array();
         $entry['sortkey'] = $sortkey;
         ApiResult::setContentValue($entry, 'category', $link);
         if (!isset($hiddencats[$link])) {
             $entry['missing'] = true;
         } elseif ($hiddencats[$link]) {
             $entry['hidden'] = true;
         }
         $result[] = $entry;
     }
     return $result;
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:28,代码来源:ApiParse.php

示例2: addCategoryLinks

 /**
  * Add an array of categories, with names in the keys
  *
  * @param array $categories Mapping category name => sort key
  */
 public function addCategoryLinks(array $categories)
 {
     global $wgContLang;
     if (!is_array($categories) || count($categories) == 0) {
         return;
     }
     # Add the links to a LinkBatch
     $arr = array(NS_CATEGORY => $categories);
     $lb = new LinkBatch();
     $lb->setArray($arr);
     # Fetch existence plus the hiddencat property
     $dbr = wfGetDB(DB_SLAVE);
     $fields = array('page_id', 'page_namespace', 'page_title', 'page_len', 'page_is_redirect', 'page_latest', 'pp_value');
     if ($this->getConfig()->get('ContentHandlerUseDB')) {
         $fields[] = 'page_content_model';
     }
     $res = $dbr->select(array('page', 'page_props'), $fields, $lb->constructSet('page', $dbr), __METHOD__, array(), array('page_props' => array('LEFT JOIN', array('pp_propname' => 'hiddencat', 'pp_page = page_id'))));
     # Add the results to the link cache
     $lb->addResultToCache(LinkCache::singleton(), $res);
     # Set all the values to 'normal'.
     $categories = array_fill_keys(array_keys($categories), 'normal');
     # Mark hidden categories
     foreach ($res as $row) {
         if (isset($row->pp_value)) {
             $categories[$row->page_title] = 'hidden';
         }
     }
     # Add the remaining categories to the skin
     if (Hooks::run('OutputPageMakeCategoryLinks', array(&$this, $categories, &$this->mCategoryLinks))) {
         foreach ($categories as $category => $type) {
             $origcategory = $category;
             $title = Title::makeTitleSafe(NS_CATEGORY, $category);
             if (!$title) {
                 continue;
             }
             $wgContLang->findVariantLink($category, $title, true);
             if ($category != $origcategory && array_key_exists($category, $categories)) {
                 continue;
             }
             $text = $wgContLang->convertHtml($title->getText());
             $this->mCategories[] = $title->getText();
             $this->mCategoryLinks[$type][] = Linker::link($title, $text);
         }
     }
 }
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:50,代码来源:OutputPage.php

示例3: formatCategoryLinks

 private function formatCategoryLinks($links)
 {
     $result = [];
     if (!$links) {
         return $result;
     }
     // Fetch hiddencat property
     $lb = new LinkBatch();
     $lb->setArray([NS_CATEGORY => $links]);
     $db = $this->getDB();
     $res = $db->select(['page', 'page_props'], ['page_title', 'pp_propname'], $lb->constructSet('page', $db), __METHOD__, [], ['page_props' => ['LEFT JOIN', ['pp_propname' => 'hiddencat', 'pp_page = page_id']]]);
     $hiddencats = [];
     foreach ($res as $row) {
         $hiddencats[$row->page_title] = isset($row->pp_propname);
     }
     $linkCache = LinkCache::singleton();
     foreach ($links as $link => $sortkey) {
         $entry = [];
         $entry['sortkey'] = $sortkey;
         // array keys will cast numeric category names to ints, so cast back to string
         ApiResult::setContentValue($entry, 'category', (string) $link);
         if (!isset($hiddencats[$link])) {
             $entry['missing'] = true;
             // We already know the link doesn't exist in the database, so
             // tell LinkCache that before calling $title->isKnown().
             $title = Title::makeTitle(NS_CATEGORY, $link);
             $linkCache->addBadLinkObj($title);
             if ($title->isKnown()) {
                 $entry['known'] = true;
             }
         } elseif ($hiddencats[$link]) {
             $entry['hidden'] = true;
         }
         $result[] = $entry;
     }
     return $result;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:37,代码来源:ApiParse.php

示例4: addCategoryLinks

 /**
  * Add an array of categories, with names in the keys
  */
 public function addCategoryLinks($categories)
 {
     global $wgUser, $wgContLang;
     if (!is_array($categories) || count($categories) == 0) {
         return;
     }
     # Add the links to a LinkBatch
     $arr = array(NS_CATEGORY => $categories);
     $lb = new LinkBatch();
     $lb->setArray($arr);
     # Fetch existence plus the hiddencat property
     $dbr = wfGetDB(DB_SLAVE);
     $pageTable = $dbr->tableName('page');
     $where = $lb->constructSet('page', $dbr);
     $propsTable = $dbr->tableName('page_props');
     $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, pp_value\n\t\t\tFROM {$pageTable} LEFT JOIN {$propsTable} ON pp_propname='hiddencat' AND pp_page=page_id WHERE {$where}";
     $res = $dbr->query($sql, __METHOD__);
     # Add the results to the link cache
     $lb->addResultToCache(LinkCache::singleton(), $res);
     # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
     $categories = array_combine(array_keys($categories), array_fill(0, count($categories), 'normal'));
     # Mark hidden categories
     foreach ($res as $row) {
         if (isset($row->pp_value)) {
             $categories[$row->page_title] = 'hidden';
         }
     }
     # Add the remaining categories to the skin
     if (wfRunHooks('OutputPageMakeCategoryLinks', array(&$this, $categories, &$this->mCategoryLinks))) {
         $sk = $wgUser->getSkin();
         foreach ($categories as $category => $type) {
             $title = Title::makeTitleSafe(NS_CATEGORY, $category);
             $text = $wgContLang->convertHtml($title->getText());
             $this->mCategoryLinks[$type][] = $sk->makeLinkObj($title, $text);
         }
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:40,代码来源:OutputPage.php

示例5: LinkBatch

 /**
  * Make a WHERE clause from a 2-d NS/dbkey array
  *
  * @param array $arr 2-d array indexed by namespace and DB key
  * @param string $prefix Field name prefix, without the underscore
  */
 function makeWhereFrom2d(&$arr, $prefix)
 {
     $lb = new LinkBatch();
     $lb->setArray($arr);
     return $lb->constructSet($prefix, $this->mDb);
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:12,代码来源:LinksUpdate.php

示例6: addCategoryLinks

 /**
  * Add an array of categories, with names in the keys
  */
 function addCategoryLinks($categories)
 {
     global $wgUser, $wgContLang;
     if (!is_array($categories)) {
         return;
     }
     # Add the links to the link cache in a batch
     $arr = array(NS_CATEGORY => $categories);
     $lb = new LinkBatch();
     $lb->setArray($arr);
     $lb->execute();
     $sk =& $wgUser->getSkin();
     foreach ($categories as $category => $arbitrary) {
         $title = Title::makeTitleSafe(NS_CATEGORY, $category);
         $text = $wgContLang->convertHtml($title->getText());
         $this->mCategoryLinks[] = $sk->makeLinkObj($title, $text);
     }
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:21,代码来源:OutputPage.php

示例7: addCategoryLinks

 /**
  * Add an array of categories, with names in the keys
  *
  * @param array $categories Mapping category name => sort key
  */
 public function addCategoryLinks(array $categories)
 {
     global $wgContLang;
     if (!is_array($categories) || count($categories) == 0) {
         return;
     }
     # Add the links to a LinkBatch
     $arr = [NS_CATEGORY => $categories];
     $lb = new LinkBatch();
     $lb->setArray($arr);
     # Fetch existence plus the hiddencat property
     $dbr = wfGetDB(DB_REPLICA);
     $fields = array_merge(LinkCache::getSelectFields(), ['page_namespace', 'page_title', 'pp_value']);
     $res = $dbr->select(['page', 'page_props'], $fields, $lb->constructSet('page', $dbr), __METHOD__, [], ['page_props' => ['LEFT JOIN', ['pp_propname' => 'hiddencat', 'pp_page = page_id']]]);
     # Add the results to the link cache
     $lb->addResultToCache(LinkCache::singleton(), $res);
     # Set all the values to 'normal'.
     $categories = array_fill_keys(array_keys($categories), 'normal');
     # Mark hidden categories
     foreach ($res as $row) {
         if (isset($row->pp_value)) {
             $categories[$row->page_title] = 'hidden';
         }
     }
     # Add the remaining categories to the skin
     if (Hooks::run('OutputPageMakeCategoryLinks', [&$this, $categories, &$this->mCategoryLinks])) {
         foreach ($categories as $category => $type) {
             // array keys will cast numeric category names to ints, so cast back to string
             $category = (string) $category;
             $origcategory = $category;
             $title = Title::makeTitleSafe(NS_CATEGORY, $category);
             if (!$title) {
                 continue;
             }
             $wgContLang->findVariantLink($category, $title, true);
             if ($category != $origcategory && array_key_exists($category, $categories)) {
                 continue;
             }
             $text = $wgContLang->convertHtml($title->getText());
             $this->mCategories[] = $title->getText();
             $this->mCategoryLinks[$type][] = Linker::link($title, $text);
         }
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:49,代码来源:OutputPage.php

示例8: makeWhereFrom2d

 protected static function makeWhereFrom2d(&$arr, $db)
 {
     $lb = new LinkBatch();
     $lb->setArray($arr);
     return $lb->constructSet('ftr', $db);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:6,代码来源:FRDependencyUpdate.php

示例9: formatCategoryLinks

 private function formatCategoryLinks($links)
 {
     $result = [];
     if (!$links) {
         return $result;
     }
     // Fetch hiddencat property
     $lb = new LinkBatch();
     $lb->setArray([NS_CATEGORY => $links]);
     $db = $this->getDB();
     $res = $db->select(['page', 'page_props'], ['page_title', 'pp_propname'], $lb->constructSet('page', $db), __METHOD__, [], ['page_props' => ['LEFT JOIN', ['pp_propname' => 'hiddencat', 'pp_page = page_id']]]);
     $hiddencats = [];
     foreach ($res as $row) {
         $hiddencats[$row->page_title] = isset($row->pp_propname);
     }
     foreach ($links as $link => $sortkey) {
         $entry = [];
         $entry['sortkey'] = $sortkey;
         // array keys will cast numeric category names to ints, so cast back to string
         ApiResult::setContentValue($entry, 'category', (string) $link);
         if (!isset($hiddencats[$link])) {
             $entry['missing'] = true;
         } elseif ($hiddencats[$link]) {
             $entry['hidden'] = true;
         }
         $result[] = $entry;
     }
     return $result;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:ApiParse.php


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