當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Page::onBeforeWrite方法代碼示例

本文整理匯總了PHP中Page::onBeforeWrite方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page::onBeforeWrite方法的具體用法?PHP Page::onBeforeWrite怎麽用?PHP Page::onBeforeWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Page的用法示例。


在下文中一共展示了Page::onBeforeWrite方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Content) {
         $this->Content = '<p>$List</p>';
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-australia-frontend-objects,代碼行數:7,代碼來源:ItemListPage.php

示例2: onBeforeWrite

 /**
  * Iterate through all the modules and add their content to the parent page, so it can be found in searches.
  */
 public function onBeforeWrite()
 {
     $pageClass = get_called_class();
     // Behaviour can be disabled via the config
     $writeContent = Config::inst()->get($pageClass, 'write_content');
     // If a custom config doesn't exist, check ModularPage
     if (is_null($writeContent)) {
         $writeContent = Config::inst()->get('ModularPage', 'write_content');
     }
     if ($writeContent) {
         $classes = ClassInfo::subclassesFor(__CLASS__);
         // Only run this code if we're on a valid instance of this class.
         // Fixes bug when changaing page type via the CMS (e.g. ModularPage -> Page)
         if (in_array($this->ClassName, $classes)) {
             if ($this->Modules()->Count()) {
                 $searchBody = '';
                 foreach ($this->Modules() as $module) {
                     $searchBody .= $module->getSearchBody() . PHP_EOL;
                 }
                 $this->Content = $searchBody;
             }
         }
     }
     parent::onBeforeWrite();
 }
開發者ID:touchcast,項目名稱:modulator,代碼行數:28,代碼來源:ModularPage.php

示例3: onBeforeWrite

 /**
  * If no publish date is set, set the date to now.
  **/
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->PublishDate) {
         $this->setCastedField("PublishDate", time());
     }
 }
開發者ID:helpfulrobot,項目名稱:micmania1-silverstripe-blog,代碼行數:10,代碼來源:BlogPost.php

示例4: onBeforeWrite

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($this->ID) {
         $this->RootFolder()->Title = $this->Title;
     }
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:7,代碼來源:ImageGalleryPage.php

示例5: onBeforeWrite

 public function onBeforeWrite()
 {
     if (!$this->ID) {
         $this->isInsert = true;
     }
     parent::onBeforeWrite();
 }
開發者ID:helpfulrobot,項目名稱:phpboyscout-silverstripe-scouts,代碼行數:7,代碼來源:ScoutGroup.php

示例6: onBeforeWrite

 /**
  * Overwrites default behaviour onBeforeWrite
  *
  * This method sets the page name based on the selected MovieTitle. If no movie title exists,
  * it will retain the existing page title (and navigation labels).
  * It clears the URL Segment variable as the SiteTree::onBeforeWrite will determine a new url-segment
  * based on the new page tile (which is the movie title).
  */
 protected function onBeforeWrite()
 {
     if ($this->MovieTitle) {
         $this->Title = $this->MovieTitle;
         $this->URLSegment = '';
     }
     parent::onBeforeWrite();
 }
開發者ID:helpfulrobot,項目名稱:fb3rasp-moviepages,代碼行數:16,代碼來源:MoviePage.php

示例7: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $parent = $this->Parent();
     if ($parent && $parent instanceof SummitPage && $parent->SummitID > 0) {
         $this->SummitID = $parent->SummitID;
     }
 }
開發者ID:OpenStackweb,項目名稱:openstack-org,代碼行數:8,代碼來源:SummitPage.php

示例8: onBeforeWrite

 function onBeforeWrite()
 {
     // Move to Photo Gallery Holder if created under something else
     if ($this->Parent()->ClassName != "PhotoGalleryHolder" && PhotoGalleryHolder::get()->count() > 0) {
         $this->ParentID = PhotoGalleryHolder::get()->first()->ID;
     }
     parent::onBeforeWrite();
 }
開發者ID:helpfulrobot,項目名稱:purplespider-basic-galleries,代碼行數:8,代碼來源:PhotoGalleryPage.php

示例9: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // set the filing mode, now that it's being obsolete
     if ($this->AutoFiling && !$this->FilingMode) {
         $this->FilingMode = 'day';
         $this->AutoFiling = false;
     }
 }
開發者ID:nyeholt,項目名稱:silverstripe-news,代碼行數:9,代碼來源:NewsHolder.php

示例10: onBeforeWrite

 /**
  * Set firstWrite flag if this is the first time this Product is written.
  * 
  * @see SiteTree::onBeforeWrite()
  * @see Product::onAfterWrite()
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->ID) {
         $this->firstWrite = true;
     }
     //Save in base currency
     $shopConfig = ShopConfig::current_shop_config();
     $this->Currency = $shopConfig->BaseCurrency;
 }
開發者ID:vinstah,項目名稱:body,代碼行數:16,代碼來源:Product.php

示例11: onBeforeWrite

 /**
  * Creates a report template instance if one does not exist.
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) {
         $template = Object::create($this->ReportType);
         $template->Title = $this->Title;
         $template->write();
         $this->ReportTemplateID = $template->ID;
     }
 }
開發者ID:helpfulrobot,項目名稱:maldicore-advancedreports,代碼行數:13,代碼來源:ReportPage.php

示例12: onBeforeWrite

 /**
  * When saving, check to see whether we should delete the
  * listing source ID
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->ID) {
         $this->Content = '$Listing';
     }
     if ($this->ClearSource) {
         $this->ClearSource = false;
         $this->ListingSourceID = 0;
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-listingpage,代碼行數:15,代碼來源:ListingPage.php

示例13: onBeforeWrite

 /**
  * Make sure Geonetwork url ends with an /.
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $geoUrl = $this->GeonetworkBaseURL;
     if (strlen($geoUrl) > 1) {
         $geoUrlLen = strlen($geoUrl) - 1;
         if ($geoUrl[$geoUrlLen] != '/') {
             $this->GeonetworkBaseURL .= '/';
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-geocatalogue,代碼行數:14,代碼來源:RegisterDataPage.php

示例14: onBeforeWrite

 /**
  * The "default" structure used for this report when auto generating etc
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) {
         $template = Object::create($this->ReportType);
         // create the template first. This is what all actual reports are based on when they're generated, either
         // automatically or by the 'generate' button
         $template->Title = $this->Title . ' Preview';
         $template->write();
         $this->ReportTemplateID = $template->ID;
     }
 }
開發者ID:rodneyway,項目名稱:silverstripe-advancedreports,代碼行數:15,代碼來源:ReportPage.php

示例15: onBeforeWrite

 /** 
  * We have to change it to copy all the content from the original page first.
  */
 function onBeforeWrite()
 {
     // Don't do this stuff when we're publishing
     if (!$this->extension_instances['Versioned']->migratingVersion) {
         if (isset($this->changed['CopyContentFromID']) && $this->changed['CopyContentFromID'] && $this->CopyContentFromID != 0 && $this instanceof VirtualPage) {
             $source = DataObject::get_one("SiteTree", sprintf('`SiteTree`.`ID` = %d', $this->CopyContentFromID));
             $this->copyFrom($source);
             $this->URLSegment = $source->URLSegment . '-' . $this->ID;
         }
     }
     parent::onBeforeWrite();
 }
開發者ID:racontemoi,項目名稱:shibuichi,代碼行數:15,代碼來源:VirtualPage.php


注:本文中的Page::onBeforeWrite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。