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


PHP Widget::generate方法代码示例

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


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

示例1: generateForm

 public static function generateForm(\Widget $objWidget, $hideLabel = false)
 {
     if (in_array($objWidget->type, static::$arrSkipTypes)) {
         return $objWidget->generate();
     }
     $strClass = $GLOBALS['TL_FFL_BOOTSTRAPPER']['legacy'];
     if (isset($GLOBALS['TL_FFL_BOOTSTRAPPER'][$objWidget->type])) {
         $strClass = $GLOBALS['TL_FFL_BOOTSTRAPPER'][$objWidget->type];
     }
     if (!class_exists($strClass)) {
         return $objWidget->generate();
     }
     $objField = new $strClass($objWidget);
     if (!$objField instanceof BootstrapperFormField) {
         return $objWidget->generate();
     }
     $objField->hideLabel = $hideLabel;
     return $objField->generate();
 }
开发者ID:heimrichhannot,项目名称:contao-bootstrapper,代码行数:19,代码来源:Bootstrapper.php

示例2: buildByWidget

 /**
  * Build the element by the widget.
  *
  * If the widget has a GeneratesAnElement event the widget generate method will be used instead of recreating the
  * elements.
  *
  * @param CreateElementEvent $event  The subscribed event.
  * @param \Widget            $widget The form widget.
  *
  * @return bool
  */
 private function buildByWidget(CreateElementEvent $event, $widget)
 {
     if ($widget instanceof GeneratesAnElement) {
         $element = $widget->generate();
         $event->setElement($element);
         return true;
     }
     return false;
 }
开发者ID:netzmacht,项目名称:contao-form-helper,代码行数:20,代码来源:CreateElementSubscriber.php

示例3: buildElement

 /**
  * Build the element.
  *
  * @param \Widget $widget The form widget.
  * @param View    $view   The view instance.
  *
  * @return \Netzmacht\Html\Element|\Netzmacht\Html\Element\StaticHtml
  */
 private function buildElement(\Widget $widget, View $view)
 {
     // build the element
     $event = new CreateElementEvent($view);
     $this->eventDispatcher->dispatch(Events::CREATE_ELEMENT, $event);
     $element = $event->getElement();
     // no element given by build event. generate form widget instead
     if (!$element) {
         $element = new StaticHtml($widget->generate());
     }
     return $element;
 }
开发者ID:netzmacht,项目名称:contao-form-helper,代码行数:20,代码来源:Helper.php

示例4: generate

 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     // create new include template
     $objTemplate = new \BackendTemplate('be_include');
     // get the active record
     $activeRecord = $this->arrConfiguration['activeRecord'];
     // get the type
     $type = $activeRecord->type;
     // get the table
     $table = $this->arrConfiguration['strTable'];
     // depending on type
     if ($type == 'alias') {
         // get the element
         $objElement = \ContentModel::findByPk($activeRecord->cteAlias);
         if ($objElement === null) {
             return '';
         }
         // get the parent article
         $objArticle = \ArticleModel::findByPk($objElement->pid);
         if ($objArticle === null) {
             return parent::generate();
         }
         // get the parent pages
         $objPages = \PageModel::findParentsById($objArticle->pid);
         if ($objPages === null) {
             return parent::generate();
         }
         // get the page titles
         $arrPageTitles = array_reverse($objPages->fetchEach('title'));
         // set breadcrumb to original element
         $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN));
         // get include breadcrumbs
         $includes = \IncludeInfoHelper::getIncludes('cteAlias', $activeRecord->cteAlias, $activeRecord->id);
         // set include breadcrumbs
         if (count($includes) > 1) {
             $objTemplate->includes = $includes;
         }
     } elseif ($type == 'article') {
         // get the article
         $objArticle = \ArticleModel::findByPk($activeRecord->articleAlias);
         if ($objArticle === null) {
             return parent::generate();
         }
         // get the parent pages
         $objPages = \PageModel::findParentsById($objArticle->pid);
         if ($objPages === null) {
             return parent::generate();
         }
         // get the page titles
         $arrPageTitles = array_reverse($objPages->fetchEach('title'));
         // set breadcrumb to original element
         $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN));
         // get include breadcrumbs
         $includes = \IncludeInfoHelper::getIncludes('articleAlias', $activeRecord->articleAlias, $activeRecord->id);
         // set include breadcrumbs
         if (count($includes) > 1) {
             $objTemplate->includes = $includes;
         }
     } elseif ($table == 'tl_content') {
         // get include breadcrumbs that reference this content element
         $includes = \IncludeInfoHelper::getIncludes(array("cteAlias = ? AND type = 'alias'"), array($activeRecord->id));
         // set include breadcrumbs
         if (count($includes) > 0) {
             $objTemplate->includes = $includes;
         }
     } elseif ($table == 'tl_article') {
         // get include breadcrumbs that reference this article
         $includes = \IncludeInfoHelper::getIncludes(array("articleAlias = ? AND type = 'article'"), array($activeRecord->id));
         // set include breadcrumbs
         if (count($includes) > 0) {
             $objTemplate->includes = $includes;
         }
     } elseif ($table == 'tl_module') {
         // get include breadcrumbs that reference this module
         $includes = \IncludeInfoHelper::getIncludes(array("module = ? AND type = 'module'"), array($activeRecord->id));
         // set include breadcrumbs
         if (count($includes) > 0) {
             $objTemplate->includes = $includes;
         }
     }
     // check for includes and add CSS
     if ($objTemplate->includes) {
         $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS;
     }
     // return template
     return $objTemplate->parse();
 }
开发者ID:fritzmg,项目名称:contao-be-include-info,代码行数:91,代码来源:IncludeInfoField.php


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