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


PHP PageManager::getTemplate方法代码示例

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


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

示例1: __form

 public function __form()
 {
     $this->setPageType('form');
     $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
     $this->Form->setAttribute('class', 'columns');
     $filename = $this->_existing_file;
     // Handle unknown context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         Administration::instance()->errorPageNotFound();
     }
     // Edit Utility context
     if ($this->_context[0] == 'edit') {
         $file_abs = UTILITIES . '/' . $this->_existing_file;
         if (!is_file($file_abs)) {
             redirect(SYMPHONY_URL . '/blueprints/utilities/new/');
         }
         $fields['name'] = $filename;
         $fields['body'] = @file_get_contents($file_abs);
         $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/utilities/edit/' . $this->_context[1] . '/');
     } else {
         $fields['body'] = file_get_contents(PageManager::getTemplate('blueprints.utility'));
     }
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
     }
     // These alerts are only valid if the form doesn't have errors
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Utility updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Utility created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS);
                 break;
         }
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %3$s', array($filename, __('Utilities'), __('Symphony'))));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $filename);
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Utilities'), SYMPHONY_URL . '/blueprints/utilities/')));
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     }
     $fields['body'] = htmlentities($fields['body'], ENT_COMPAT, 'UTF-8');
     $fields['name'] = isset($fields['name']) ? $fields['name'] : null;
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'primary column');
     $label = Widget::Label(__('Name'));
     $label->appendChild(Widget::Input('fields[name]', $fields['name']));
     $fieldset->appendChild(isset($this->_errors['name']) ? Widget::Error($label, $this->_errors['name']) : $label);
     $label = Widget::Label(__('Body'));
     $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
     $fieldset->appendChild(isset($this->_errors['body']) ? Widget::Error($label, $this->_errors['body']) : $label);
     $this->Form->appendChild($fieldset);
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     if (is_array($utilities) && !empty($utilities)) {
         $this->Form->setAttribute('class', 'two columns');
         $div = new XMLElement('div');
         $div->setAttribute('class', 'secondary column');
         $p = new XMLElement('p', __('Utilities'));
         $p->setAttribute('class', 'label');
         $div->appendChild($p);
         $frame = new XMLElement('div', null, array('class' => 'frame'));
         $ul = new XMLElement('ul');
         $ul->setAttribute('id', 'utilities');
         foreach ($utilities as $util) {
             $li = new XMLElement('li');
             $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
             $ul->appendChild($li);
         }
         $frame->appendChild($ul);
         $div->appendChild($frame);
         $this->Form->appendChild($div);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit') {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this utility'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this Utility?')));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
 }
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:85,代码来源:content.blueprintsutilities.php


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