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


PHP BlockType::getInstance方法代碼示例

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


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

示例1: render

 /** 
  * Renders a particular view for a block or a block type
  * @param Block | BlockType $obj
  * @param string $view
  * @param array $args
  */
 public function render($obj, $view = 'view', $args = array())
 {
     if ($this->hasRendered) {
         return false;
     }
     $this->blockObj = $obj;
     $customAreaTemplates = array();
     if ($obj instanceof BlockType) {
         $bt = $obj;
         $base = $obj->getBlockTypePath();
     } else {
         $bFilename = $obj->getBlockFilename();
         $b = $obj;
         $base = $b->getBlockPath();
         $this->block = $b;
         $this->c = $b->getBlockCollectionObject();
         if ($bFilename == '' && is_object($this->area)) {
             $customAreaTemplates = $this->area->getCustomTemplates();
             $btHandle = $b->getBlockTypeHandle();
             if (isset($customAreaTemplates[$btHandle])) {
                 $bFilename = $customAreaTemplates[$btHandle];
             }
         }
     }
     $btHandle = $obj->getBlockTypeHandle();
     if (!isset($this->controller)) {
         if ($obj instanceof Block) {
             $this->controller = $obj->getInstance();
             $this->controller->setBlockObject($obj);
         } else {
             $this->controller = Loader::controller($obj);
         }
     }
     if (in_array($view, array('view', 'add', 'edit', 'composer'))) {
         $_action = $view;
     } else {
         $_action = 'view';
     }
     $u = new User();
     $outputContent = false;
     $useCache = false;
     $page = Page::getCurrentPage();
     if ($view == 'view') {
         if (ENABLE_BLOCK_CACHE && $this->controller->cacheBlockOutput() && $obj instanceof Block) {
             if ((!$u->isRegistered() || $this->controller->cacheBlockOutputForRegisteredUsers()) && ($_SERVER['REQUEST_METHOD'] != 'POST' || $this->controller->cacheBlockOutputOnPost() == true)) {
                 $useCache = true;
             }
             if ($useCache) {
                 $outputContent = $obj->getBlockCachedOutput($this->area);
             }
         }
     }
     if ($outputContent == false) {
         $this->controller->setupAndRun($_action);
     }
     extract($this->controller->getSets());
     extract($this->controller->getHelperObjects());
     $headerItems = $this->controller->headerItems;
     extract($args);
     if ($this->controller->getRenderOverride() != '') {
         $_filename = $this->controller->getRenderOverride() . '.php';
     }
     if ($view == 'scrapbook') {
         $template = $this->getBlockPath(FILENAME_BLOCK_VIEW_SCRAPBOOK) . '/' . FILENAME_BLOCK_VIEW_SCRAPBOOK;
         if (!file_exists($template)) {
             $view = 'view';
         }
     }
     if (!in_array($view, array('composer', 'view', 'add', 'edit', 'scrapbook'))) {
         // then we're trying to render a custom view file, which we'll pass to the bottom functions as $_filename
         $_filename = $view . '.php';
         $view = 'view';
     }
     switch ($view) {
         case 'scrapbook':
             $header = DIR_FILES_ELEMENTS_CORE . '/block_header_view.php';
             $footer = DIR_FILES_ELEMENTS_CORE . '/block_footer_view.php';
             break;
         case 'composer':
         case 'view':
             if (!$outputContent) {
                 if (!isset($_filename)) {
                     $_filename = FILENAME_BLOCK_VIEW;
                 }
                 $bvt = new BlockViewTemplate($obj);
                 if ($bFilename) {
                     $bvt->setBlockCustomTemplate($bFilename);
                     // this is PROBABLY already set by the method above, but in the case that it's passed by area we have to set it here
                 } else {
                     if ($_filename != FILENAME_BLOCK_VIEW) {
                         $bvt->setBlockCustomRender($_filename);
                     }
                 }
                 $template = $bvt->getTemplate();
//.........這裏部分代碼省略.........
開發者ID:ojalehto,項目名稱:concrete5-legacy,代碼行數:101,代碼來源:block_view.php


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