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


PHP Versioned::get_by_stage方法代码示例

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


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

示例1: deleteVersionedObjects

 protected function deleteVersionedObjects($tags, $obj, $stage, $pageID)
 {
     $tagsArray = array();
     $tagsTempArray = array();
     if ($tags) {
         foreach ($tags as $tag) {
             array_push($tagsArray, $tag->ID);
         }
         $versionedTags = Versioned::get_by_stage($obj, $stage)->filter(array('FaqPageID' => $pageID));
         foreach ($versionedTags as $versionedTag) {
             array_push($tagsTempArray, $versionedTag->ID);
         }
         $tagsArrayDiff = array_diff($tagsTempArray, $tagsArray);
         if ($tagsArrayDiff) {
             foreach ($tagsArrayDiff as $key => $val) {
                 $thisTag = Versioned::get_by_stage($obj, $stage)->byID($val);
                 if ($thisTag) {
                     $thisTag->deleteFromStage($stage);
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:nadzweb-advancedfaq,代码行数:25,代码来源:FaqPage.php

示例2: republish

 function republish($original)
 {
     if (self::$disable_realtime) {
         return;
     }
     $urls = array();
     if ($this->owner->hasMethod('pagesAffectedByChanges')) {
         $urls = $this->owner->pagesAffectedByChanges($original);
     } else {
         $pages = Versioned::get_by_stage('SiteTree', 'Live', '', '', '', 10);
         if ($pages) {
             foreach ($pages as $page) {
                 $urls[] = $page->AbsoluteLink();
             }
         }
     }
     // Note: Similiar to RebuildStaticCacheTask->rebuildCache()
     foreach ($urls as $i => $url) {
         if (!is_string($url)) {
             user_error("Bad URL: " . var_export($url, true), E_USER_WARNING);
             continue;
         }
         // Remove leading slashes from all URLs (apart from the homepage)
         if (substr($url, -1) == '/' && $url != '/') {
             $url = substr($url, 0, -1);
         }
         $urls[$i] = $url;
     }
     $urls = array_unique($urls);
     $this->publishPages($urls);
 }
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:31,代码来源:StaticPublisher.php

示例3: onAfterWrite

 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if (in_array('Searchable', class_implements($this->owner->class))) {
         if ($this->owner->IncludeInSearch()) {
             if ($this->owner->hasExtension('Versioned')) {
                 $filterID = array('ID' => $this->owner->ID);
                 $filter = $filterID + $this->owner->getSearchFilter();
                 $do = Versioned::get_by_stage($this->owner->class, 'Live')->filter($filter)->first();
             } else {
                 $filterID = "`{$this->owner->class}`.`ID`={$this->owner->ID}";
                 $do = DataObject::get($this->owner->class, $filterID, false)->filter($this->owner->getSearchFilter())->first();
             }
             if ($do) {
                 PopulateSearch::insert($do);
             } else {
                 $this->deleteDo($this->owner);
             }
         } else {
             $this->deleteDo($this->owner);
         }
     } else {
         if ($this->owner instanceof SiteTree) {
             if ($this->owner->ShowInSearch) {
                 PopulateSearch::insertPage($this->owner);
             } else {
                 $this->deleteDo($this->owner);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:zirak-searchable-dataobjects,代码行数:31,代码来源:SearchableDataObject.php

示例4: multipleNewsHolderPages

 /**
  * If there are multiple @link NewsHolderPage available, add the field for multiples.
  * This includes translation options
  */
 private function multipleNewsHolderPages()
 {
     $enabled = false;
     // If we have translations, disable translation filter to get all pages.
     if (class_exists('Translatable')) {
         $enabled = Translatable::disable_locale_filter();
     }
     $pages = Versioned::get_by_stage('NewsHolderPage', 'Live');
     // Only add the page-selection if there are multiple. Otherwise handled by onBeforeWrite();
     if ($pages->count() > 1) {
         $pagelist = array();
         if (class_exists('Translatable')) {
             foreach ($pages as $page) {
                 $pagelist['Root.Main'][$page->ID] = $page->Title . ' ' . $page->Locale;
             }
         } else {
             $pagelist = $pages->map('ID', 'Title')->toArray();
         }
         $this->field_list['Root.Main'][1] = ListboxField::create('NewsHolderPages', $this->owner->fieldLabel('NewsHolderPages'), $pagelist);
         $this->field_list['Root.Main'][1]->setMultiple(true);
     }
     if ($enabled) {
         Translatable::enable_locale_filter();
     }
 }
开发者ID:MilesSummers,项目名称:silverstripe-newsmodule,代码行数:29,代码来源:NewsCMSExtension.php

示例5: getBy

 /**
  * @param int $summit_id
  * @return SummitConfirmSpeakerPage
  */
 public static function getBy($summit_id)
 {
     $page = Versioned::get_by_stage('SummitConfirmSpeakerPage', 'Live')->filter('SummitID', $summit_id)->first();
     if (is_null($page)) {
         $page = Versioned::get_by_stage('SummitConfirmSpeakerPage', 'Stage')->filter('SummitID', $summit_id)->first();
     }
     return $page;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:12,代码来源:SummitConfirmSpeakerPage.php

示例6: getBy

 /**
  * @param ISummit $summit
  * @return SummitAppSchedPage
  */
 public static function getBy(ISummit $summit)
 {
     $page = Versioned::get_by_stage('SummitAppSchedPage', 'Live')->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($page)) {
         $page = Versioned::get_by_stage('SummitAppSchedPage', 'Stage')->filter('SummitID', $summit->getIdentifier())->first();
     }
     return $page;
 }
开发者ID:hogepodge,项目名称:openstack-org,代码行数:12,代码来源:SummitAppSchedPage.php

示例7: sourceRecords

 public function sourceRecords($params = null)
 {
     $classes = ClassInfo::subclassesFor('RedirectorPage');
     $classParams = DB::placeholders($classes);
     $classFilter = array("\"ClassName\" IN ({$classParams}) AND \"HasBrokenLink\" = 1" => $classes);
     $stage = isset($params['OnLive']) ? 'Live' : 'Stage';
     return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:8,代码来源:BrokenRedirectorPagesReport.php

示例8: doDeleteFromStage

 /**
  * Unpublishing Versioning support
  *
  * When unpublishing the field it has to remove all options attached
  *
  * @return void
  */
 public function doDeleteFromStage($stage)
 {
     // Remove options
     $options = Versioned::get_by_stage('EditableOption', $stage)->filter('ParentID', $this->ID);
     foreach ($options as $option) {
         $option->deleteFromStage($stage);
     }
     parent::doDeleteFromStage($stage);
 }
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:16,代码来源:EditableMultipleOptionField.php

示例9: assertDataObjectsOnStage

	protected function assertDataObjectsOnStage($class, $number, $stage = 'Live') {
		$objects = Versioned::get_by_stage($class, $stage);
		if (!$number) {
			$this->assertEmpty($objects);
		} else {
			$this->assertInstanceOf('DataObjectSet', $objects);
			$this->assertEquals($number, $objects->TotalItems());
		}
	}
开发者ID:redema,项目名称:silverstripe-handyman,代码行数:9,代码来源:DataObjectOnVersioningDecoratorTest.php

示例10: sourceRecords

 public function sourceRecords($params = null)
 {
     $classNames = "'" . join("','", ClassInfo::subclassesFor('RedirectorPage')) . "'";
     if (isset($_REQUEST['OnLive'])) {
         $ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ({$classNames}) AND \"HasBrokenLink\" = 1");
     } else {
         $ret = DataObject::get('SiteTree', "\"ClassName\" IN ({$classNames}) AND \"HasBrokenLink\" = 1");
     }
     return $ret;
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:10,代码来源:BrokenRedirectorPagesReport.php

示例11: currentPage

 /**
  * Custom currentPage() method to handle opening the 'root' folder
  *
  * @return
  */
 public function currentPage()
 {
     $id = $this->currentPageID();
     if ($id && is_numeric($id) && $id > 0) {
         return Versioned::get_by_stage('SiteTree', 'Stage', sprintf('ID = %s', (int) $id))->first();
     } else {
         // ID is either '0' or 'root'
         return singleton('SiteTree');
     }
 }
开发者ID:benmanu,项目名称:silverstripe-dms,代码行数:15,代码来源:DMSDocumentAddController.php

示例12: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gfConfig = GridFieldConfig_relationEditor::create();
     $gfConfig->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldDetailForm')->addComponents(new VersionedGridFieldDetailForm());
     $articles = Versioned::get_by_stage('NewsArticle', 'Stage');
     $fields->insertAfter(Tab::create('Articles'), 'Main');
     $fields->addFieldToTab('Root.Articles', GridField::create('Children', 'Articles', $articles, $gfConfig));
     return $fields;
 }
开发者ID:nyeholt,项目名称:silverstripe-newsly,代码行数:10,代码来源:NewsHolder.php

示例13: Items

 public function Items()
 {
     $filter = '';
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     if (self::$use_show_in_search) {
         $filter = "{$bt}ShowInSearch{$bt} = 1";
     }
     $this->Pages = Versioned::get_by_stage('SiteTree', 'Live', $filter);
     $newPages = new DataObjectSet();
     if ($this->Pages) {
         foreach ($this->Pages as $page) {
             // Only include pages from this host and pages which are not an instance of ErrorPage
             // We prefix $_SERVER['HTTP_HOST'] with 'http://' so that parse_url to help parse_url identify the host name component; we could use another protocol (like
             // 'ftp://' as the prefix and the code would work the same.
             if (parse_url($page->AbsoluteLink(), PHP_URL_HOST) == parse_url('http://' . $_SERVER['HTTP_HOST'], PHP_URL_HOST) && !$page instanceof ErrorPage) {
                 // If the page has been set to 0 priority, we set a flag so it won't be included
                 if ($page->canView() && (!isset($page->Priority) || $page->Priority > 0)) {
                     // The one field that isn't easy to deal with in the template is
                     // Change frequency, so we set that here.
                     $properties = $page->toMap();
                     $created = new SS_Datetime();
                     $created->value = $properties['Created'];
                     $now = new SS_Datetime();
                     $now->value = date('Y-m-d H:i:s');
                     $versions = $properties['Version'];
                     $timediff = $now->format('U') - $created->format('U');
                     // Check how many revisions have been made over the lifetime of the
                     // Page for a rough estimate of it's changing frequency.
                     $period = $timediff / ($versions + 1);
                     if ($period > 60 * 60 * 24 * 365) {
                         // > 1 year
                         $page->ChangeFreq = 'yearly';
                     } elseif ($period > 60 * 60 * 24 * 30) {
                         // > ~1 month
                         $page->ChangeFreq = 'monthly';
                     } elseif ($period > 60 * 60 * 24 * 7) {
                         // > 1 week
                         $page->ChangeFreq = 'weekly';
                     } elseif ($period > 60 * 60 * 24) {
                         // > 1 day
                         $page->ChangeFreq = 'daily';
                     } elseif ($period > 60 * 60) {
                         // > 1 hour
                         $page->ChangeFreq = 'hourly';
                     } else {
                         // < 1 hour
                         $page->ChangeFreq = 'always';
                     }
                     $newPages->push($page);
                 }
             }
         }
         return $newPages;
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:55,代码来源:GoogleSitemap.php

示例14: Items

 public function Items()
 {
     $this->Pages = Versioned::get_by_stage('SiteTree', 'Live');
     $newPages = new DataObjectSet();
     foreach ($this->Pages as $page) {
         // Only include pages from this host
         if (parse_url($page->AbsoluteLink(), PHP_URL_HOST) == $_SERVER['HTTP_HOST']) {
             // If the page has been set to 0 priority, we set a flag so it won't be included
             if (isset($page->Priority) && $page->Priority <= 0) {
                 $page->Include = false;
             } else {
                 $page->Include = true;
             }
             // The one field that isn't easy to deal with in the template is
             // Change frequency, so we set that here.
             $properties = $page->toMap();
             $created = new Datetime($properties['Created']);
             $now = new Datetime();
             $versions = $properties['Version'];
             $timediff = $now->format('U') - $created->format('U');
             // Check how many revisions have been made over the lifetime of the
             // Page for a rough estimate of it's changing frequency.
             $period = $timediff / ($versions + 1);
             if ($period > 60 * 60 * 24 * 365) {
                 // > 1 year
                 $page->ChangeFreq = 'yearly';
             } else {
                 if ($period > 60 * 60 * 24 * 30) {
                     // > ~1 month
                     $page->ChangeFreq = 'monthly';
                 } else {
                     if ($period > 60 * 60 * 24 * 7) {
                         // > 1 week
                         $page->ChangeFreq = 'weekly';
                     } else {
                         if ($period > 60 * 60 * 24) {
                             // > 1 day
                             $page->ChangeFreq = 'daily';
                         } else {
                             if ($period > 60 * 60) {
                                 // > 1 hour
                                 $page->ChangeFreq = 'hourly';
                             } else {
                                 // < 1 hour
                                 $page->ChangeFreq = 'always';
                             }
                         }
                     }
                 }
             }
             $newPages->push($page);
         }
     }
     return $newPages;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:55,代码来源:GoogleSitemap.php

示例15: sourceRecords

 public function sourceRecords($params = null)
 {
     // Get class names for page types that are not virtual pages or redirector pages
     $classes = array_diff(ClassInfo::subclassesFor('SiteTree'), ClassInfo::subclassesFor('VirtualPage'), ClassInfo::subclassesFor('RedirectorPage'));
     $classNames = "'" . join("','", $classes) . "'";
     if (isset($_REQUEST['OnLive'])) {
         $ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ({$classNames}) AND \"HasBrokenFile\" = 1");
     } else {
         $ret = DataObject::get('SiteTree', "\"ClassName\" IN ({$classNames}) AND \"HasBrokenFile\" = 1");
     }
     return $ret;
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:12,代码来源:BrokenFilesReport.php


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