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


PHP Director::get_current_page方法代码示例

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


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

示例1: submitFeedback

 function submitFeedback(array $data, Form $form)
 {
     // TRUE if the submission contains a link. Crude spam mitigation.
     $ContainsLink = strpos($data['Content'], "http://") !== false;
     if ($data['Content'] != NULL && !$ContainsLink) {
         $FeedbackSubmission = new FeedbackSubmission();
         $form->saveInto($FeedbackSubmission);
         // Tie the URL of the current page to the feedback submission
         $page = Director::get_current_page();
         $FeedbackSubmission->Page = $page->Link();
         //$FeedbackSubmission->write();
         //Send email alert about submission
         $Subject = "New Website Feedback Submission";
         $email = EmailFactory::getInstance()->buildEmail(FEEDBACK_FORM_FROM_EMAIL, FEEDBACK_FORM_TO_EMAIL, $Subject);
         $email->setTemplate("FeedbackSubmissionEmail");
         $email->populateTemplate($FeedbackSubmission);
         $email->send();
         // Redirect back to the page with a success message
         $form->controller->setMessage('Success', 'Thanks for providing feedback to improve the OpenStack website!');
         $form->controller->redirectBack();
     } else {
         $form->controller->setMessage('Error', "Oops! It doesn't look like you provided any feedback. Please check the form and try again.");
         $form->controller->redirectBack();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:25,代码来源:FeedbackForm.php

示例2: Menu

 public function Menu($level = 1)
 {
     if ($level == 1) {
         $root_elements = new ArrayList($this->get_root_elements());
         $result = $root_elements->filter(array("ShowInMenus" => 1));
     } else {
         $dataID = Director::get_current_page()->ID;
         $site_map = $this->get_site_map();
         if (isset($site_map[$dataID])) {
             $parent = $site_map[$dataID];
             $stack = array($parent);
             if ($parent) {
                 while ($parent = $parent->getParent()) {
                     array_unshift($stack, $parent);
                 }
             }
             if (isset($stack[$level - 2])) {
                 $elements = new ArrayList($stack[$level - 2]->getAllChildren());
                 $result = $elements->filter(array("ShowInMenus" => 1));
             }
         }
     }
     $visible = array();
     // Remove all entries the can not be viewed by the current user
     // We might need to create a show in menu permission
     if (isset($result)) {
         foreach ($result as $page) {
             if ($page->canView()) {
                 $visible[] = $page;
             }
         }
     }
     return new ArrayList($visible);
 }
开发者ID:helpfulrobot,项目名称:deviateltd-silverstripe-cacheable,代码行数:34,代码来源:CachedNavigation.php

示例3: get_navbar_html

 public static function get_navbar_html($page = null)
 {
     // remove the protocol from the URL, otherwise we run into https/http issues
     $url = self::remove_protocol_from_url(self::get_toolbar_hostname());
     $static = true;
     if (!$page instanceof SiteTree) {
         $page = Director::get_current_page();
         $static = false;
     }
     // In some cases, controllers are bound to "mock" pages, like Security. In that case,
     // throw the "default section" as the current controller.
     if (!$page instanceof SiteTree || !$page->isInDB()) {
         $controller = ModelAsController::controller_for($page = SiteTree::get_by_link(Config::inst()->get('GlobalNav', 'default_section')));
     } else {
         // Use controller_for to negotiate sub controllers, e.g. /showcase/listing/slug
         // (Controller::curr() would return the nested RequestHandler)
         $controller = ModelAsController::controller_for($page);
     }
     // Ensure staging links are not exported to the nav
     $origStage = Versioned::current_stage();
     Versioned::reading_stage('Live');
     $html = ViewableData::create()->customise(array('ToolbarHostname' => $url, 'Scope' => $controller, 'ActivePage' => $page, 'ActiveParent' => $page instanceof SiteTree && $page->Parent()->exists() ? $page->Parent() : $page, 'StaticRender' => $static, 'GoogleCustomSearchId' => Config::inst()->get('GlobalNav', 'google_search_id')))->renderWith('GlobalNavbar');
     Versioned::reading_stage($origStage);
     return $html;
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:25,代码来源:GlobalNavSiteTreeExtension.php

示例4: __construct

 function __construct($controller, $name, $poll)
 {
     if (!$poll) {
         user_error("The poll doesn't exist.", E_USER_ERROR);
     }
     $this->poll = $poll;
     $data = array();
     foreach ($poll->Choices() as $choice) {
         $data[$choice->ID] = $choice->Title;
     }
     if ($poll->MultiChoice) {
         $choiceField = new CheckboxSetField('PollChoices', '', $data);
     } else {
         $choiceField = new OptionsetField('PollChoices', '', $data);
     }
     $fields = new FieldList($choiceField);
     if (PollForm::$show_results_link) {
         $showResultsURL = Director::get_current_page()->Link() . '?poll_results';
         $showResultsLink = new LiteralField('ShowPollLink', '<a class="show-results" href="' . $showResultsURL . '">Show results</a>');
         $fields->push($showResultsLink);
     }
     $actions = new FieldList(new FormAction('submitPoll', 'Submit', null, null, 'button'));
     $validator = new PollForm_Validator('PollChoices');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
开发者ID:helpfulrobot,项目名称:mateusz-silverstripe-polls,代码行数:25,代码来源:PollForm.php

示例5: Dates

 function Dates()
 {
     Requirements::themedCSS('archivewidget');
     $results = new DataObjectSet();
     $container = BlogTree::current();
     $ids = $container->BlogHolderIDs();
     $stage = Versioned::current_stage();
     $suffix = !$stage || $stage == 'Stage' ? "" : "_{$stage}";
     $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
     $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
     $sqlResults = DB::query("\n\t\t\tSELECT DISTINCT CAST({$monthclause} AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", {$yearclause} AS \"Year\"\n\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\tORDER BY \"Year\" DESC, \"Month\" DESC;");
     if ($this->ShowLastYears == 0) {
         $cutOffYear = 0;
     } else {
         $cutOffYear = (int) date("Y") - $this->ShowLastYears;
     }
     $years = array();
     if (Director::get_current_page()->ClassName == 'BlogHolder') {
         $urlParams = Director::urlParams();
         $yearParam = $urlParams['ID'];
         $monthParam = $urlParams['OtherID'];
     } else {
         $date = new DateTime(Director::get_current_page()->Date);
         $yearParam = $date->format("Y");
         $monthParam = $date->format("m");
     }
     if ($sqlResults) {
         foreach ($sqlResults as $sqlResult) {
             $isMonthDisplay = true;
             $year = $sqlResult['Year'] ? (int) $sqlResult['Year'] : date('Y');
             $isMonthDisplay = $year > $cutOffYear;
             // $dateFormat = 'Month'; else $dateFormat = 'Year';
             $monthVal = isset($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
             $month = $isMonthDisplay ? $monthVal : 1;
             $date = DBField::create('Date', array('Day' => 1, 'Month' => $month, 'Year' => $year));
             if ($isMonthDisplay) {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
             } else {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'];
             }
             if ($isMonthDisplay || !$isMonthDisplay && !in_array($year, $years)) {
                 $years[] = $year;
                 $current = false;
                 $children = new DataObjectSet();
                 $LinkingMode = "link";
                 if ($isMonthDisplay && $yearParam == $year && $monthParam == $month || !$isMonthDisplay && $yearParam == $year) {
                     $LinkingMode = "current";
                     $current = true;
                     if ($this->ShowChildren && $isMonthDisplay) {
                         $filter = $yearclause . ' = ' . $year . ' AND ' . $monthclause . ' = ' . $month;
                         $children = DataObject::get('BlogEntry', $filter, "Date DESC");
                     }
                 }
                 $results->push(new ArrayData(array('Date' => $date, 'Year' => $year, 'Link' => $link, 'NoMonth' => !$isMonthDisplay, 'LinkingMode' => $LinkingMode, 'Children' => $children)));
                 unset($children);
             }
         }
     }
     return $results;
 }
开发者ID:helpfulrobot,项目名称:exadium-blogarchivemenuwidget,代码行数:60,代码来源:BlogArchiveMenuWidget.php

示例6: provideGridListFilters

 /**
  * Return the current pages default filter
  *
  * @return array
  */
 public function provideGridListFilters()
 {
     $page = \Director::get_current_page();
     if ($page instanceof \CMSMain) {
         $page = $page->currentPage();
     }
     return $page->DefaultFilter();
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:13,代码来源:DefaultFilter.php

示例7: provideGridListItems

 /**
  * Return children of the current page
  * @return \DataList
  */
 public function provideGridListItems()
 {
     if ($this()->{static::SingleFieldName}) {
         if ($page = \Director::get_current_page()) {
             return $page->Children();
         }
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:12,代码来源:ChildPages.php

示例8: Link

 /**
  * @param string $action
  * @return string
  */
 public function Link($action = null)
 {
     $id = $this->block ? $this->block->ID : null;
     $segment = Controller::join_links('block', $id, $action);
     if ($page = Director::get_current_page()) {
         return $page->Link($segment);
     }
     return Controller::curr()->Link($segment);
 }
开发者ID:sekjal,项目名称:silverstripe-blocks,代码行数:13,代码来源:Block_Controller.php

示例9: Layout

 public function Layout()
 {
     $page = Director::get_current_page();
     $member = Member::currentUser();
     $access = Permission::checkMember($member, 'CMS_ACCESS');
     $sectionType = get_called_class();
     if ($this->Public || $access) {
         return $page->renderWith($this->Render());
     }
 }
开发者ID:helpfulrobot,项目名称:coreiho-silverstripe-sections,代码行数:10,代码来源:MainSection.php

示例10: InSectionID

 public function InSectionID($sectionNameID)
 {
     $page = Director::get_current_page();
     while ($page) {
         if ($sectionNameID == $page->ID) {
             return true;
         }
         $page = $page->Parent;
     }
     return false;
 }
开发者ID:neilcreagh,项目名称:FuelCMS,代码行数:11,代码来源:Page.php

示例11: get_navbar_html

 public static function get_navbar_html($page = null)
 {
     // remove the protocol from the URL, otherwise we run into https/http issues
     $url = self::remove_protocol_from_url(self::get_toolbar_hostname());
     $static = true;
     if (!$page instanceof SiteTree) {
         $page = Director::get_current_page();
         $static = false;
     }
     return ViewableData::create()->customise(array('ToolbarHostname' => $url, 'Pages' => SiteTree::get()->filter(array('ParentID' => 0, 'ShowInGlobalNav' => true)), 'ActivePage' => $page, 'ActiveParent' => $page instanceof SiteTree && $page->Parent()->exists() ? $page->Parent() : $page, 'StaticRender' => $static, 'GoogleCustomSearchId' => Config::inst()->get('GlobalNav', 'google_search_id')))->renderWith('GlobalNavbar');
 }
开发者ID:edlinklater,项目名称:silverstripe-globaltoolbar,代码行数:11,代码来源:GlobalNavSiteTreeExtension.php

示例12: LoginForm

 function LoginForm()
 {
     if (self::$BadLoginURL) {
         $page = self::$BadLoginURL;
     } else {
         $page = Director::get_current_page()->URLSegment;
     }
     Session::set("BadLoginURL", Director::absoluteURL($page, true));
     $controller = new UsernameOrEmailLoginWidget_Controller($this);
     $form = $controller->LoginForm();
     $this->extend('updateLoginForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-auth-username,代码行数:13,代码来源:UsernameOrEmailLoginWidget.php

示例13: provideGridListFilters

 /**
  * Return the current pages config.gridlist_custom_filters if set or empty array.
  * @return array
  */
 public function provideGridListFilters()
 {
     $page = \Director::get_current_page();
     if ($page instanceof \CMSMain) {
         $page = $page->currentPage();
     }
     $filters = new \ArrayList();
     if ($customFilters = $page->config()->get('gridlist_custom_filters') ?: []) {
         foreach ($customFilters as $filter => $title) {
             $filters->push(new GridListFilter([Title::SingleFieldName => $title, GridListFilter::TagFieldName => $filter]));
         }
     }
     return $filters;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:18,代码来源:CustomFilters.php

示例14: setobj

 public function setobj()
 {
     $page = Director::get_current_page();
     $fields = ['FirstName', 'LastName', 'Greeting'];
     foreach ($fields as $item) {
         $data = $_POST[$item];
         if (!isset($data)) {
             continue;
         }
         $page->{$item} = $data;
     }
     $page->write();
     return $this->getobj();
 }
开发者ID:stephenjcorwin,项目名称:silverstripe-demo,代码行数:14,代码来源:DP_ControllerActionsPage.php

示例15: constrainGridListFilters

 /**
  * Make sure only the custom filters are provided. This needs to go after other filter providers.
  *
  * @param $filters
  */
 public function constrainGridListFilters(&$filters, &$parameters = [])
 {
     $page = \Director::get_current_page();
     if ($page instanceof \CMSMain) {
         $page = $page->currentPage();
     }
     if ($customFilters = $page->config()->get('gridlist_custom_filters') ?: []) {
         $filters = new \ArrayList();
         foreach ($customFilters as $tag => $title) {
             if (!($filter = GridListFilter::get()->filter(['ModelTag' => $tag])->first())) {
                 $filter = new GridListFilter([Title::SingleFieldName => $title, GridListFilter::TagFieldName => $tag]);
             }
             $filters->push($filter);
         }
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:21,代码来源:OnlyCustom.php


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