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


PHP Page::get方法代码示例

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


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

示例1: numChildren

 /**
  * Return number of children, optionally with conditions
  *
  * Use this over $page->numChildren property when you want to specify a selector or when you want the result to
  * include only visible children. See the options for the $selector argument. 
  *
  * @param Page $page
  * @param bool|string|int $selector 
  *	When not specified, result includes all children without conditions, same as $page->numChildren property.
  *	When a string, a selector string is assumed and quantity will be counted based on selector.
  * 	When boolean true, number includes only visible children (excludes unpublished, hidden, no-access, etc.)
  *	When boolean false, number includes all children without conditions, including unpublished, hidden, no-access, etc.
  * 	When integer 1 number includes viewable children (as opposed to visible, viewable includes hidden pages + it also includes unpublished pages if user has page-edit permission).
  * @return int Number of children
  *
  */
 public function numChildren(Page $page, $selector = null)
 {
     if (is_bool($selector)) {
         // onlyVisible takes the place of selector
         $onlyVisible = $selector;
         if (!$onlyVisible) {
             return $page->get('numChildren');
         }
         return $page->wire('pages')->count("parent_id={$page->id}");
     } else {
         if ($selector === 1) {
             // viewable pages only
             $numChildren = $page->get('numChildren');
             if (!$numChildren) {
                 return 0;
             }
             if ($page->wire('user')->isSuperuser()) {
                 return $numChildren;
             }
             if ($page->wire('user')->hasPermission('page-edit')) {
                 return $page->wire('pages')->count("parent_id={$page->id}, include=unpublished");
             }
             return $page->wire('pages')->count("parent_id={$page->id}, include=hidden");
         } else {
             if (empty($selector) || !is_string($selector)) {
                 return $page->get('numChildren');
             } else {
                 return $page->wire('pages')->count("parent_id={$page->id}, {$selector}");
             }
         }
     }
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:48,代码来源:PageTraversal.php

示例2: getPage

 function getPage()
 {
     $data = array();
     // if there is no path, load the index
     if (empty($this->data['path'])) {
         $page = new Page(1);
     } else {
         $page = new Page();
         $page->get_page_from_path($this->data['path']);
     }
     // see if we have found a page
     if ($page->get('id')) {
         // store the information of the page
         /*
         $data['id'] = $this->data['id'] = $page->get('id');
         $data['title'] = stripslashes( $page->get('title') );
         $data['content'] = stripslashes( $page->get('content') );
         $data['tags'] = stripslashes( $page->get('tags') );
         $data['date'] = strtotime( stripslashes( $page->get('date') ) );
         */
         $data = $page->getAll();
         // check if the page has been classified as a category
         $this->category = strpos($data['tags'], "category") > -1 ? true : false;
         $data['path'] = $this->data['path'];
         //$data['view'] = getPath('views/main/body.php');
         $this->data['body'][] = $data;
         // FIX #38: copy data of "static" pages in a separate array for easy access
         $this->data['_page'] = $data;
         $this->data['template'] = stripslashes($page->get('template'));
         return true;
     } else {
         return false;
     }
 }
开发者ID:makesites,项目名称:kisscms,代码行数:34,代码来源:page_controller.php

示例3: loaded

 /**
  * Ensure that every user loaded has at least the 'guest' role
  *
  */
 protected function loaded(Page $page)
 {
     static $guestID = null;
     if (is_null($guestID)) {
         $guestID = $this->wire('config')->guestUserRolePageID;
     }
     $roles = $page->get('roles');
     if (!$roles->has("id={$guestID}")) {
         $page->get('roles')->add($this->wire('roles')->getGuestRole());
     }
 }
开发者ID:Rizsti,项目名称:Processwire_Compatibility,代码行数:15,代码来源:Users.php

示例4: testGet

 /**
  * @test
  */
 public function testGet()
 {
     $page = Page::get("hello");
     $page2 = Page::get(2);
     $this->assertEquals(2, $page2->identifier());
     $this->assertEquals("hello", $page->title);
 }
开发者ID:bsamel,项目名称:best_lyon,代码行数:10,代码来源:PageTest.php

示例5: removeInitialPages

 public function removeInitialPages()
 {
     if ($aboutus = Page::get()->filter(['Title' => "About us"])->first()) {
         $contactus = Page::get()->filter(['Title' => "Contact us"])->first();
         $this->deleteAll([$aboutus, $contactus]);
     }
 }
开发者ID:4j5,项目名称:Helixnexus-Silverstripe,代码行数:7,代码来源:siteStructure.php

示例6: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root', 'Pages');
     $fields->removeFieldsFromTab('Root.Main', array('SortOrder', 'showBlockbyClass', 'shownInClass', 'MemberVisibility'));
     $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Published: ' . $this->Published()), 'Title');
     $memberGroups = Group::get();
     $sourcemap = $memberGroups->map('Code', 'Title');
     $source = array('anonymous' => 'Anonymous visitors');
     foreach ($sourcemap as $mapping => $key) {
         $source[$mapping] = $key;
     }
     $memberVisibility = new CheckboxSetField($name = "MemberVisibility", $title = "Show block for specific groups", $source);
     $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
     $availabelClasses = $this->availableClasses();
     $inClass = new CheckboxSetField($name = "shownInClass", $title = "Show block for specific content types", $availabelClasses);
     $filterSelector = OptionsetField::create('showBlockbyClass', 'Choose filter set', array('0' => 'by page', '1' => 'by page/data type'))->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
     $availablePages = Page::get()->exclude('ClassName', array('ErrorPage', 'RedirectorPage', 'VirtualPage'));
     $pageSelector = new CheckboxSetField($name = "Pages", $title = "Show on Page(s)", $availablePages->map('ID', 'Title'));
     if ($this->canConfigPageAndType(Member::currentUser())) {
         $fields->addFieldsToTab('Root.VisibilitySettings', array($filterSelector, $pageSelector, $inClass));
     }
     if ($this->canConfigMemberVisibility(Member::currentUser())) {
         $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
     }
     if (!$fields->fieldByName('Options')) {
         $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
     }
     $fields->addFieldsToTab('Options', array(CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')));
     return $fields;
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:31,代码来源:Block.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     Translatable::disable_locale_filter();
     //Publish all english pages
     $pages = Page::get()->filter('Locale', 'en_US');
     foreach ($pages as $page) {
         $page->publish('Stage', 'Live');
     }
     //Rewrite the french translation groups and publish french pages
     $pagesFR = Page::get()->filter('Locale', 'fr_FR');
     foreach ($pagesFR as $index => $page) {
         $page->addTranslationGroup($pages->offsetGet($index)->ID, true);
         $page->publish('Stage', 'Live');
     }
     Translatable::enable_locale_filter();
     $this->origLocaleRoutingEnabled = Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL');
     Config::inst()->update('MultilingualRootURLController', 'UseLocaleURL', false);
     $this->origDashLocaleEnabled = Config::inst()->get('MultilingualRootURLController', 'UseDashLocale');
     Config::inst()->update('MultilingualRootURLController', 'UseDashLocale', false);
     $this->origAcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.5';
     $this->origCookieLocale = Cookie::get('language');
     Cookie::force_expiry('language');
     Cookie::set('language', 'en');
     $this->origCurrentLocale = Translatable::get_current_locale();
     Translatable::set_current_locale('en_US');
     $this->origLocale = Translatable::default_locale();
     Translatable::set_default_locale('en_US');
     $this->origi18nLocale = i18n::get_locale();
     i18n::set_locale('en_US');
     $this->origAllowedLocales = Translatable::get_allowed_locales();
     Translatable::set_allowed_locales(array('en_US', 'fr_FR'));
     MultilingualRootURLController::reset();
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-translatablerouting,代码行数:35,代码来源:MultilingualModelAsControllerTest.php

示例8: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if ($this->config()->get("auto_include")) {
         $check = TemplateOverviewPage::get()->First();
         if (!$check) {
             $page = new TemplateOverviewPage();
             $page->ShowInMenus = 0;
             $page->ShowInSearch = 0;
             $page->Title = "Templates overview";
             $page->PageTitle = "Templates overview";
             $page->Sort = 99998;
             $page->URLSegment = "templates";
             $parent = Page::get()->filter(array("URLSegment" => $this->config()->get("parent_url_segment")))->First();
             if ($parent) {
                 $page->ParentID = $parent->ID;
             }
             $page->writeToStage('Stage');
             $page->publish('Stage', 'Live');
             $page->URLSegment = "templates";
             $page->writeToStage('Stage');
             $page->publish('Stage', 'Live');
             DB::alteration_message("TemplateOverviewPage", "created");
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-templateoverview,代码行数:26,代码来源:TemplateOverviewPage.php

示例9: run

 /**
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     /** =========================================
          * @var Page $page
         ===========================================*/
     if (class_exists('Page')) {
         if (Page::has_extension('TwitterCardMeta')) {
             // Should we overwrite?
             $overwrite = $request->getVar('overwrite') ? true : false;
             echo sprintf('Overwrite is %s', $overwrite ? 'enabled' : 'disabled') . $this->eol . $this->eol;
             $pages = Page::get();
             foreach ($pages as $page) {
                 $id = $page->ID;
                 echo $this->hr;
                 echo 'Updating page: ' . $page->Title . $this->eol;
                 foreach ($this->fields_to_update as $fieldName) {
                     $oldData = DB::query("SELECT {$fieldName} FROM Page WHERE ID = {$id}")->column($fieldName);
                     $newData = DB::query("SELECT {$fieldName} FROM SiteTree WHERE ID = {$id}")->column($fieldName);
                     if (!empty($oldData)) {
                         // If new data has been saved and we don't want to overwrite, exit the loop
                         if (!empty($newData) && $overwrite === false) {
                             continue;
                         }
                         DB::query("UPDATE SiteTree SET {$fieldName} = '{$oldData[0]}' WHERE ID = {$id}");
                     } else {
                         echo 'Field "' . $fieldName . '" empty.' . $this->eol;
                     }
                 }
             }
         }
     }
 }
开发者ID:toastnz,项目名称:twitter-card-meta,代码行数:35,代码来源:MigrateSiteTreeMetaTask.php

示例10: Siblings

 function Siblings()
 {
     if (!$this->ParentID) {
         $this->ParentID = 0;
     }
     return Page::get()->filter(array("ShowInMenus" => 1, "ParentID" => $this->ParentID));
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-mysite-ssu-flava,代码行数:7,代码来源:Page.php

示例11: __construct

 public function __construct($name, $title = null, $value = null, $form = null)
 {
     // Create a callable function that returns an array of options for the DependentDropdownField.
     // When the value of the field it depends on changes, this function is called passing the
     // updated value as the first parameter ($val)
     $getanchors = function ($page_id) {
         // Copied from HtmlEditorField_Toolbar::getanchors()
         if (($page = Page::get()->byID($page_id)) && !empty($page)) {
             //			if (!$page->canView()) { /* ERROR? */ }
             // Similar to the regex found in HtmlEditorField.js / getAnchors method.
             if (preg_match_all("/\\s(name|id)=\"([^\"]+?)\"|\\s(name|id)='([^']+?)'/im", $page->Content, $matches)) {
                 //					var_dump(array_filter(array_merge($matches[2], $matches[4])));
                 $anchors = array_filter(array_merge($matches[2], $matches[4]));
                 return array_combine($anchors, $anchors);
             }
         }
     };
     // naming with underscores to prevent values from actually being saved somewhere
     $this->fieldCustomURL = new TextField("{$name}[CustomURL]", '', '', 300, $form);
     $this->fieldShortcode = new TextField("{$name}[Shortcode]", '', '', 300, $form);
     $this->fieldPageID = new TreeDropdownField("{$name}[PageID]", '', 'SiteTree', 'ID', 'MenuTitle');
     $this->fieldPageID->setForm($form);
     //		$this->fieldPageAnchor = new DropdownField("{$name}[PageAnchor]", 'Anchor:',array(), '', $form);
     // The DependentDropdownField, setting the source as the callable function
     // and setting the field it depends on to the appropriate field
     $this->fieldPageAnchor = DependentDropdownField::create("{$name}[PageAnchor]", 'Text-anchor:', $getanchors, $form)->setEmptyString('Page anchor: (none)')->setDepends($this->fieldPageID);
     $this->fieldFileID = new TreeDropdownField("{$name}[FileID]", '', 'File', 'ID', 'Name');
     $this->fieldFileID->addExtraClass('filetree');
     $this->fieldFileID->setForm($form);
     $this->fieldTitle = new TextField("{$name}[Title]", 'Title: ', '', 300, $form);
     $this->fieldLinkmode = new DropdownField("{$name}[Linkmode]", 'Type: ', array('Page' => 'Page', 'URL' => 'URL', 'File' => 'File', 'Email' => 'Email', 'Shortcode' => 'Shortcode'), '', $form);
     $this->fieldLinkmode->addExtraClass('LinkModePicker');
     parent::__construct($name, $title, $value, $form);
 }
开发者ID:micschk,项目名称:silverstripe-namedlinkfield,代码行数:34,代码来源:NamedLinkFormField.php

示例12: run

 function run($request)
 {
     $data = (require_once __DIR__ . '/../../../BlockFiller.php');
     if ($data) {
         foreach (Block::get() as $block) {
             $block->delete();
         }
     }
     //Loop through all blocks, defined in root/BlockFiller.php
     foreach ($data as $key => $blockData) {
         $block = Block::create($blockData);
         //Find page by classname, so it can link block to page
         $page = Page::get()->filter(['ClassName' => $blockData['ClassName']])->first();
         //If page is found, write block
         if (isset($page->ID)) {
             $block->PageID = $page->ID;
             $block->write();
             //Loop through all blocks translations, which are defined in block section under 'trans'
             foreach ($blockData['trans'] as $key => $translation) {
                 $blockTrans = BlockTranslation::create($translation);
                 $blockTrans->BlockID = $block->ID;
                 $blockTrans->write();
             }
             var_dump($block->Title);
         }
     }
 }
开发者ID:kendu,项目名称:silverstripe-content-blocks,代码行数:27,代码来源:InsertBlocks.php

示例13: numChildren

 /**
  * Return number of children, optionally with conditions
  *
  * Use this over $page->numChildren property when you want to specify a selector or when you want the result to
  * include only visible children. See the options for the $selector argument. 
  *
  * @param Page $page
  * @param bool|string $selector 
  *	When not specified, result includes all children without conditions, same as $page->numChildren property.
  *	When a string, a selector string is assumed and quantity will be counted based on selector.
  * 	When boolean true, number includes only visible children (excludes unpublished, hidden, no-access, etc.)
  *	When boolean false, number includes all children without conditions, including unpublished, hidden, no-access, etc.
  * @return int Number of children
  *
  */
 public function numChildren(Page $page, $selector = null)
 {
     if (is_bool($selector)) {
         // onlyVisible takes the place of selector
         $onlyVisible = $selector;
         if (!$onlyVisible) {
             return $page->get('numChildren');
         }
         return $page->children('limit=2')->getTotal();
     } else {
         if (empty($selector) || !is_string($selector)) {
             return $page->get('numChildren');
         } else {
             return wire('pages')->count("parent_id={$page->id}, {$selector}");
         }
     }
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:32,代码来源:PageTraversal.php

示例14: initFormField

 protected function initFormField()
 {
     if ($this->getSetting('PageTypeName')) {
         $pages = Page::get($this->getSetting('PageTypeName'))->map('ID', 'Title');
         return new DropdownField($this->Name, $this->Title, $pages);
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:satrun77-editablefield,代码行数:8,代码来源:EditableFieldPageTypeList.php

示例15: syncCommentsAction

 function syncCommentsAction()
 {
     $id = (int) $_REQUEST['ID'];
     $page = Page::get()->byID($id);
     DisqusSync::sync($page->disqusIdentifier());
     $this->owner->response->addHeader('X-Status', sprintf('Synced successfuly'));
     return;
 }
开发者ID:helpfulrobot,项目名称:silverstripesk-silverstripe-disqus,代码行数:8,代码来源:DisqusCMSActionExtension.php


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