本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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();
}