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


PHP Place::placeAbbrevsDelete方法代码示例

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


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

示例1: propagateMoveDeleteUndelete

 /**
  * Propagate move, delete, or undelete to other articles if necessary
  *
  * @param String $newTitleString null in case of delete; same as this title string in case of undelete
  * @param String $text text of article
  * @param bool $textChanged we never change the text, so this is never set to true
  * @return bool true if success
  */
 protected function propagateMoveDeleteUndelete($newTitleString, $newNs, &$text, &$textChanged)
 {
     $result = true;
     // move: maintain place abbrevs and add place redirect job
     if ($newTitleString && $newTitleString != $this->titleString) {
         Place::placeAbbrevsDelete($this->titleString);
         Place::placeAbbrevsDelete($newTitleString);
         Place::placeAbbrevsAdd($newTitleString, $this->xml);
         // edit wlh pages to point to the target title
         $newTitle = Title::newFromText($newTitleString, NS_PLACE);
         $job = new PlaceRedirectJob(array('old_title' => $this->titleString, 'new_title' => $newTitle->getText()));
         $job->insert();
     } else {
         if (!$newTitleString) {
             Place::placeAbbrevsDelete($this->titleString);
         }
     }
     // determine parents and type and lat and lng
     list($alsoLocatedIn, $type, $lat, $lng, $fromYear, $toYear) = Place::getPropagatedData($this->xml);
     // get new name pieces
     $newName = Place::getPrefNameLocatedIn($newTitleString);
     // follow redirects
     $t = (string) $this->locatedIn ? Title::newFromText((string) $this->locatedIn, NS_PLACE) : null;
     if ($t) {
         $t = StructuredData::getRedirectToTitle($t);
     }
     $oldLocatedIn = $t ? $t->getText() : (string) $this->locatedIn;
     $t = $newName[1] ? Title::newFromText($newName[1], NS_PLACE) : null;
     if ($t) {
         $t = StructuredData::getRedirectToTitle($t);
     }
     $newLocatedIn = $t ? $t->getText() : $newName[1];
     foreach ($alsoLocatedIn as $ali) {
         $t = $ali['place'] ? Title::newFromText($ali['place'], NS_PLACE) : null;
         if ($t) {
             $t = StructuredData::getRedirectToTitle($t);
         }
         if ($t) {
             $ali['place'] = $t->getText();
         }
     }
     // if current located-in place is not also an also-located-in place
     if (StructuredData::mapArraySearch($oldLocatedIn, $alsoLocatedIn, 'place') === false) {
         if ($oldLocatedIn == $newLocatedIn) {
             // update title in located-in place
             $article = StructuredData::getArticle(Title::newFromText($oldLocatedIn, NS_PLACE), true);
             if ($article) {
                 $content =& $article->fetchContent();
                 $updatedContent =& $this->updateContainedPlace($newTitleString, $type, $lat, $lng, $fromYear, $toYear, $content);
                 if ($updatedContent) {
                     $updateResult = $article->doEdit($updatedContent, self::PROPAGATE_MESSAGE . ' [[' . $this->title->getPrefixedText() . ']]', PROPAGATE_EDIT_FLAGS);
                     $result = $result && $updateResult;
                 }
             }
         } else {
             // remove from current parent
             $parentArticle = StructuredData::getArticle(Title::newFromText($oldLocatedIn, NS_PLACE), true);
             if ($parentArticle) {
                 $content =& $parentArticle->fetchContent();
                 $updatedContent =& $this->updateContainedPlace(null, null, null, null, null, null, $content);
                 if ($updatedContent) {
                     $updateResult = $parentArticle->doEdit($updatedContent, self::PROPAGATE_MESSAGE . ' [[' . $this->title->getPrefixedText() . ']]', PROPAGATE_EDIT_FLAGS);
                     $result = $result && $updateResult;
                 }
             }
         }
     }
     // add to new parent if necessary
     if ($oldLocatedIn != $newLocatedIn && StructuredData::mapArraySearch($newLocatedIn, $alsoLocatedIn, 'place') === false) {
         $article = StructuredData::getArticle(Title::newFromText($newLocatedIn, NS_PLACE), true);
         if ($article) {
             $content =& $article->fetchContent();
             $updatedContent =& $this->updateContainedPlace($newTitleString, $type, $lat, $lng, $fromYear, $toYear, $content);
             if ($updatedContent) {
                 $updateResult = $article->doEdit($updatedContent, self::PROPAGATE_MESSAGE . ' [[' . $this->title->getPrefixedText() . ']]', PROPAGATE_EDIT_FLAGS);
                 $result = $result && $updateResult;
             }
         }
     }
     // update title in also-located-in places
     foreach ($alsoLocatedIn as $pli) {
         $article = StructuredData::getArticle(Title::newFromText((string) $pli['place'], NS_PLACE), true);
         if ($article) {
             $content =& $article->fetchContent();
             $updatedContent =& $this->updateContainedPlace($newTitleString, $type, $lat, $lng, (string) $pli['from_year'], (string) $pli['to_year'], $content);
             if ($updatedContent) {
                 $updateResult = $article->doEdit($updatedContent, self::PROPAGATE_MESSAGE . ' [[' . $this->title->getPrefixedText() . ']]', PROPAGATE_EDIT_FLAGS);
                 $result = $result && $updateResult;
             }
         }
     }
     if (!$result) {
//.........这里部分代码省略.........
开发者ID:k-hasan-19,项目名称:wiki,代码行数:101,代码来源:Place.php


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