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


PHP SiteTree::get_by_id方法代码示例

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


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

示例1: SetCaseStudy

 function SetCaseStudy()
 {
     if (isset($_GET['ID']) && is_numeric($_GET['ID'])) {
         $UserStory = $_GET['ID'];
     } else {
         die;
     }
     $setCaseStudy = $_GET['Set'] == 1 ? 1 : 0;
     $story = SiteTree::get_by_id("UserStory", $UserStory);
     $story->ShowCaseStudy = $setCaseStudy;
     $story->write();
     $story->publish("Live", "Stage");
     $this->owner->setMessage('Success', 'Case Study updated for <b>' . $story->Title . '</b>');
     Controller::curr()->redirectBack();
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:15,代码来源:SangriaPageSurveyDetailsExtension.php

示例2: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     if (!$this->exists()) {
         // The new module state
         Requirements::css(MODULATOR_PATH . '/css/PageModule.css');
         Requirements::javascript(MODULATOR_PATH . '/javascript/PageModule.js');
         $allowedModules = array();
         // Determine the type of the parent page
         $currentPageID = Session::get('CMSMain.currentPage');
         if ($currentPageID) {
             $currentPage = SiteTree::get_by_id('SiteTree', $currentPageID);
             if ($currentPage) {
                 $currentPageClass = $currentPage->ClassName;
                 // Get the list of allowed modules for this page type
                 if (class_exists($currentPageClass) && method_exists($currentPageClass, 'getAllowedModules')) {
                     $allowedModules = $currentPageClass::getAllowedModules();
                 }
             }
         }
         $classList = array();
         foreach ($allowedModules as $class) {
             $instance = new $class();
             $classList[$class] = '<img src="' . $instance::$icon . '"><strong>' . $class::$label . '</strong><p>' . $class::$description . '</p>';
         }
         $fields = new FieldList();
         if (!count($allowedModules)) {
             $typeField = new LiteralField('Type', '<span class="message required">There are no module types defined, please create some.</span>');
             $fields->push($typeField);
         } else {
             $labelField = new TextField('Title', 'Label');
             $labelField->setDescription('A reference name for this block, not displayed on the website');
             $fields->push($labelField);
             $typeField = new OptionSetField('NewClassName', 'Type', $classList);
             $typeField->setDescription('The type of module determines what content and functionality it will provide');
             $fields->push($typeField);
         }
         $this->extend('updateCMSFields', $fields);
     } else {
         // Existing module state
         $fields = parent::getCMSFields();
         // Don't expose Order to the CMS
         $fields->removeFieldFromTab('Root.Main', 'Order');
         $fields->removeFieldFromTab('Root.Main', 'PageID');
         // Helps us keep track of preview focus
         $fields->addFieldToTab('Root.Main', new HiddenField('ModulatorID', 'ModulatorID', $this->ID));
     }
     return $fields;
 }
开发者ID:touchcast,项目名称:modulator,代码行数:51,代码来源:PageModule.php

示例3: SetAdminSS

 function SetAdminSS()
 {
     if (isset($_GET['ID']) && is_numeric($_GET['ID'])) {
         $UserStory = $_GET['ID'];
     } else {
         die;
     }
     $showinAdmin = isset($_GET['Set']) && intval($_GET['Set']) === 1 ? 1 : 0;
     $story = SiteTree::get_by_id("UserStory", $UserStory);
     $parent = UserStoryHolder::get()->first();
     if (!$parent) {
         $this->owner->setMessage('Error', 'could not publish user story bc there is not any available parent page(UserStoryHolder).');
         Controller::curr()->redirectBack();
     }
     $story->ShowInAdmin = $showinAdmin;
     $story->setParent($parent);
     // Should set the ID once the Holder is created...
     $story->write();
     $story->publish("Live", "Stage");
     $this->owner->setMessage('Success', '<b>' . $story->Title . '</b> updated.');
     $this->owner->redirectBack();
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:22,代码来源:SangriaPageViewCurrentStoriesExtension.php

示例4: MetaTags

 public function MetaTags(&$tags)
 {
     $page = $this->getOwner();
     $config = SiteConfig::current_site_config();
     while ($page && !$page->has_extension('GeoTagsExtension')) {
         if ($parent = $page->ParentID) {
             $page = SiteTree::get_by_id('SiteTree', $parent);
         } else {
             $page = false;
         }
     }
     if ($page) {
         $data = $page;
     } else {
         if ($config->has_extension('GeoTagsExtension')) {
             $data = $config;
         }
     }
     if ($data) {
         $region = '';
         if (strlen($data->GeoCountry)) {
             $region = $data->GeoCountry;
             if (strlen($data->GeoRegion)) {
                 $region .= '-' . $data->GeoRegion;
             }
         }
         if ($region) {
             $tags .= '<meta name="geo.region" content="' . $region . '" />';
         }
         if (strlen($data->GeoPlacename)) {
             $tags .= '<meta name="geo.placename" content="' . $data->GeoPlacename . '" />';
         }
         if (strlen($data->GeoLatitude) && strlen($data->GeoLongitude)) {
             $tags .= '<meta name="geo.position" content="' . $data->GeoLatitude . ';' . $data->GeoLongitude . '" />';
             $tags .= '<meta name="ICBM" content="' . $data->GeoLatitude . ', ' . $data->GeoLongitude . '" />';
         }
     }
     return $tags;
 }
开发者ID:helpfulrobot,项目名称:zucchi-geotags,代码行数:39,代码来源:GeoTagsControllerExtension.php

示例5: retrieveStaged

 /**
  *	Return the appropriate staged JSON/XML output for the corresponding page.
  *
  *	@parameter <{PAGE_ID}> integer
  *	@parameter <{OUTPUT_TYPE}> string
  *	@URLparameter s <{STAGE_OR_LIVE}> string
  *	@return JSON/XML
  */
 public function retrieveStaged($page, $output)
 {
     // Bypass any staging preview restrictions where required.
     $request = Controller::curr()->getRequest();
     $stage = $request->getVar('s') ? $request->getVar('s') : $request->getVar('stage');
     $output = strtoupper($output);
     if (($stage === 'Stage' || $stage === 'Live') && ($output === 'JSON' || $output === 'XML')) {
         // Set the appropriate staging mode.
         Versioned::reading_stage($stage);
         // Compose the appropriate JSON/XML.
         $function = "retrieve{$output}";
         $temporary = array(0 => SiteTree::get_by_id('SiteTree', $page)->toMap());
         return $this->{$function}($temporary, false, true);
     }
     // The current request was not valid.
     return array();
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:25,代码来源:APIwesomeService.php

示例6: getRedirectPage

 /**
  *	Retrieve the page associated with this link mapping redirection.
  *
  *	@return site tree
  */
 public function getRedirectPage()
 {
     return ClassInfo::exists('SiteTree') && $this->RedirectPageID ? SiteTree::get_by_id('SiteTree', $this->RedirectPageID) : null;
 }
开发者ID:nyeholt,项目名称:silverstripe-misdirection,代码行数:9,代码来源:LinkMapping.php

示例7: newpageselected

 public function newpageselected(SS_HTTPRequest $request)
 {
     $sitetree_id = $request->param('ID');
     $page = SiteTree::get_by_id($sitetree_id);
     $result = array();
     if ($page) {
         $result['Title'] = $page->Title;
     }
     return json_encode($result);
 }
开发者ID:gordonbanderson,项目名称:Slider,代码行数:10,代码来源:SlidePage.php

示例8: import

 static function import($page)
 {
     include_once '../googledocspage/libs/simplehtmldom/simple_html_dom.php';
     //if import url is set, use that, else fall back on google doc id
     if (strlen($page->ImportURL) > 1) {
         $url = $page->ImportURL;
     } else {
         $url = GoogleDocsPage::$gdoc_pub_urlbase . $page->GoogleDocID;
     }
     //echo $url;
     $html = file_get_html($url);
     //$contents = $html->find('div[id="contents"]', 0)->innertext;
     $contents = $html->find('div[id="contents"]', 0);
     // remove h1
     //var_dump($contents->find('h1'));
     if (isset($contents)) {
         foreach ($contents->find('h1') as $e) {
             $e->outertext = '';
         }
     } else {
         return "Error retrieving document. <br /> Try visiting this URL: <br /><br /><a href=\"{$url}\">{$url}</a>";
     }
     // save style
     $style = "";
     foreach ($contents->find('style') as $e) {
         $style = $e->innertext;
     }
     $e->outertext = '';
     //changing img path
     $i = 1;
     foreach ($html->find('img') as $e) {
         if ($i < 99) {
             //echo $e->src . "<br />";
             //$e->outertext = '';
             $e->src = "http://docs.google.com/document/" . $e->src;
             //var_dump($page->PageID);
             $folderPath = 'import/' . $page->ID;
             //var_dump($folderPath);
             $folder = Folder::findOrMake($folderPath);
             //$tempFileName = $i . ".png";
             $tempFileName = $i;
             $filepath = "assets/" . $folderPath . "/" . $tempFileName;
             $src = str_replace("amp;", "", $e->src);
             $img = file_get_contents($src);
             //$size = getimagesize($img);
             //var_dump($img);
             $file = File::find($filepath);
             if (!$file) {
                 $file = new File();
                 $file->Filename = $filepath;
             }
             file_put_contents(Director::baseFolder() . "/" . $filepath, $img);
             //$file->Name = $a["FileName"];
             //$file->setName($tempFileName);
             $file->write();
             $file->setName($i);
             $file->setParentID($folder->ID);
             //$file->setName($filepath);
             $file->ClassName = "Image";
             $file->write();
             $e->src = "/" . $filepath;
         }
         $i = $i + 1;
     }
     //echo '<style>.c2 { font-weight:bold;}</style>';
     //echo $contents->innertext;
     //echo "importing";
     $import = new GoogleDocsPage_Import();
     //$import->Imported = date("Y-m-d H:i:s");
     $import->Content = $contents->innertext;
     $import->Css = $style;
     $import->CssParsed = GoogleDocsPage_Import::parsecss($style);
     $import->PageID = $page->ID;
     $import->write();
     //this is not neccessary, as it is done already be referencing the PageID
     //$pageimports = $page->Imports();
     //$pageimports->add($import);
     //writing content to the page
     //making sure the "real" page object is being used
     $page = SiteTree::get_by_id("Page", $page->ID);
     $page->Content = $import->Content;
     $page->writeToStage('Stage');
     $page->Publish('Stage', 'Live');
     $page->Status = "Published";
     $page->flushCache();
     return "import successful";
     //return $import;
 }
开发者ID:helpfulrobot,项目名称:titledk-silverstripe-googledocspage,代码行数:88,代码来源:GoogleDocsPage.php


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