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


PHP LiteralField::createTag方法代码示例

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


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

示例1: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder->ID));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(15), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $gridField = new GridField('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Name'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'Date->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if ($folder->canCreate()) {
         $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID), _t('Folder.UploadFilesButton', 'Upload')));
     } else {
         $uploadBtn = null;
     }
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>', Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID), _t('Folder.AddFolderButton', 'Add folder')));
     } else {
         $addFolderBtn = '';
     }
     if ($folder->canEdit()) {
         $syncButton = new LiteralField('SyncButton', sprintf('<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" data-icon="arrow-circle-double" title="%s" href="%s">%s</a>', _t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'), $this->Link('doSync'), _t('FILESYSTEMSYNC', 'Sync files')));
     } else {
         $syncButton = null;
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview");
         $tabTree->addExtraClass("content-treeview");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create(CompositeField::create($uploadBtn, $addFolderBtn, $syncButton)->addExtraClass('cms-actions-row'))->addExtraClass('cms-content-toolbar field'), $gridField));
     $treeField = new LiteralField('Tree', '');
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', $treeField->createTag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $actions->removeByName('action_save');
         $actions->removeByName('action_delete');
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:70,代码来源:AssetAdmin.php


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