• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CMSForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Form

 public function Form()
 {
     $form = new CMSForm($this, 'Form', new FieldList(new EmailField('Email'), new TextField('SomeRequiredField'), new CheckboxSetField('Boxes', null, array('1' => 'one', '2' => 'two'))), new FieldList(new FormAction('doSubmit'), new FormAction('doSubmitValidationExempt')), new RequiredFields('Email', 'SomeRequiredField'));
     $form->setValidationExemptActions(array('doSubmitValidationExempt'));
     $form->setResponseNegotiator('foo');
     // We aren't testing AJAX responses, so just set anything
     $form->disableSecurityToken();
     // Disable CSRF protection for easier form submission handling
     return $form;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:10,代码来源:CMSFormTest.php


示例2: getEditForm

 /**
  * Gets the form used for viewing a time log
  */
 public function getEditForm($id = null, $fields = null)
 {
     $record = $this->currentPage();
     if ($this->action == 'view' && $record) {
         $fields = new FieldList(new HeaderField('LogHeader', _t('KapostBridgeLogViewer.VIEWING_ENTRY', '_Viewing Log Entry: {datetime}', array('datetime' => $record->dbObject('Created')->FormatFromSettings())), 3), new ReadonlyField('UserAgent', _t('KapostBridgeLogViewer.USER_AGENT', '_Requestor User Agent')), new ReadonlyField('Method', _t('KapostBridgeLogViewer.METHOD', '_Method')), ToggleCompositeField::create('RequestData', _t('KapostBridgeLogViewer.KAPOST_REQUEST', '_Kapost Request'), new FieldList(ReadonlyField::create('RequestFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3), ToggleCompositeField::create('ResponseData', _t('KapostBridgeLogViewer.SILVERSTRIPE_RESPONSE', '_SilverStripe Response'), new FieldList(ReadonlyField::create('ResponseFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3));
         $refObj = $record->ReferenceObject;
         if (!empty($refObj) && $refObj !== false && $refObj->exists()) {
             if (method_exists($refObj, 'CMSEditLink')) {
                 $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObj->CMSEditLink(), _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData');
             } else {
                 if ($refObj instanceof File) {
                     $refObjLink = Controller::join_links(LeftAndMain::config()->url_base, AssetAdmin::config()->url_segment, 'EditForm/field/File/item', $refObj->ID, 'edit');
                     $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObjLink, _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData');
                 }
             }
         }
     } else {
         $fields = new FieldList();
     }
     $form = new CMSForm($this, 'EditForm', $fields, new FieldList());
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form center');
     $form->setAttribute('data-layout-type', 'border');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->setHTMLID('Form_EditForm');
     if ($record) {
         $form->loadDataFrom($record);
     }
     return $form;
 }
开发者ID:webbuilders-group,项目名称:silverstripe-kapost-bridge-logger,代码行数:34,代码来源:KapostBridgeLogViewer.php


示例3: getEditForm

 /**
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $config = CodeBankConfig::CurrentConfig();
     $fields = $config->getCMSFields();
     $actions = new FieldList(FormAction::create('doSave', _t('CodeBank.SAVE', '_Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'), FormAction::create('doExportToClient', _t('CodeBank.EXPORT_TO_CLIENT', '_Export To Desktop Client'))->setAttribute('data-exporturl', Director::absoluteURL('code-bank-api/export-to-client'))->setAttribute('data-icon', 'export'));
     if (Permission::check('ADMIN')) {
         $actions->push(FormAction::create('doImportFromClient', _t('CodeBank.IMPORT_FROM_CLIENT', '_Import From Desktop Client'))->setAttribute('data-icon', 'import')->setAttribute('data-importurl', $this->Link('import-from-client')));
     }
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->addExtraClass('root-form');
     $form->addExtraClass('cms-edit-form center');
     // don't add data-pjax-fragment=CurrentForm, its added in the content template instead
     $form->setHTMLID('Form_EditForm');
     $form->loadDataFrom($config);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Use <button> to allow full jQuery UI styling
     $actions = $actions->dataFields();
     if ($actions) {
         foreach ($actions as $action) {
             $action->setUseButtonTag(true);
         }
     }
     $this->extend('updateEditForm', $form);
     //Display message telling user to run dev/build because the version numbers are out of sync
     if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
         $form->setMessage(_t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')), 'error');
     } else {
         if ($this->hasOldTables()) {
             $form->setMessage(_t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')), 'warning');
         }
     }
     $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
     return $form;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:37,代码来源:CodeBankSettings.php


示例4: getEditForm

 /**
  * Gets the form used for agreeing or disagreeing to the ip agreement
  * @param {int} $id ID of the record to fetch
  * @param {FieldList} $fields Fields to use
  * @return {Form} Form to be used
  */
 public function getEditForm($id = null, $fields = null)
 {
     $defaultPanel = Config::inst()->get('AdminRootController', 'default_panel');
     if ($defaultPanel == 'CodeBank') {
         $defaultPanel = 'SecurityAdmin';
         $sng = singleton($defaultPanel);
     }
     $fields = new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('IPMessageTitle', _t('CodeBank.IP_MESSAGE_TITLE', '_You must agree to the following terms before using Code Bank'), 2), new LiteralField('IPMessage', '<div class="ipMessage"><div class="middleColumn">' . CodeBankConfig::CurrentConfig()->dbObject('IPMessage')->forTemplate() . '</div></div>'), new HiddenField('RedirectLink', 'RedirectLink', $sng->Link()))));
     if (Session::get('CodeBankIPAgreed') === true) {
         $fields->addFieldToTab('Root.Main', new HiddenField('AgreementAgreed', 'AgreementAgreed', Session::get('CodeBankIPAgreed')));
     }
     $actions = new FieldList(FormAction::create('doDisagree', _t('CodeBankIPAgreement.DISAGREE', '_Disagree'))->addExtraClass('ss-ui-action-destructive'), FormAction::create('doAgree', _t('CodeBankIPAgreement.AGREE', '_Agree'))->addExtraClass('ss-ui-action-constructive'));
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->disableDefaultAction();
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->addExtraClass('center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     //Display message telling user to run dev/build because the version numbers are out of sync
     if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
         $form->setMessage(_t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')), 'error');
     } else {
         if ($this->hasOldTables()) {
             $form->setMessage(_t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')), 'warning');
         }
     }
     $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
     Requirements::javascript(CB_DIR . '/javascript/CodeBank.IPMessage.js');
     return $form;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:36,代码来源:CodeBankIPAgreement.php


示例5: getEditForm

 /**
  * @return Form
  * @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
  */
 public function getEditForm($id = null, $fields = null)
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $folder = $this->currentPage();
     $uploadField = UploadField::create('AssetUploadField', '');
     $uploadField->setConfig('previewMaxWidth', 40);
     $uploadField->setConfig('previewMaxHeight', 30);
     $uploadField->setConfig('changeDetection', false);
     $uploadField->addExtraClass('ss-assetuploadfield');
     $uploadField->removeExtraClass('ss-uploadfield');
     $uploadField->setTemplate('AssetUploadField');
     if ($folder->exists() && $folder->getFilename()) {
         // The Upload class expects a folder relative *within* assets/
         $path = preg_replace('/^' . ASSETS_DIR . '\\//', '', $folder->getFilename());
         $uploadField->setFolderName($path);
     } else {
         $uploadField->setFolderName('/');
         // root of the assets
     }
     $exts = $uploadField->getValidator()->getAllowedExtensions();
     asort($exts);
     $uploadField->Extensions = implode(', ', $exts);
     $form = CMSForm::create($this, 'EditForm', new FieldList($uploadField, new HiddenField('ID')), new FieldList())->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
     // Don't use AssetAdmin_EditForm, as it assumes a different panel structure
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->Fields()->push(new LiteralField('BackLink', sprintf('<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>', Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0), _t('AssetAdmin.BackToFolder', 'Back to folder'))));
     $form->loadDataFrom($folder);
     return $form;
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:36,代码来源:CMSFileAddController.php


示例6: getEditForm

 /**
  * @param null $id Not used.
  * @param null $fields Not used.
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $siteConfig = SiteConfig::current_site_config();
     $fields = $siteConfig->getCMSFields();
     $actions = $siteConfig->getCMSActions();
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-content center cms-edit-form');
     // don't add data-pjax-fragment=CurrentForm, its added in the content template instead
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setHTMLID('Form_EditForm');
     $form->loadDataFrom($siteConfig);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Use <button> to allow full jQuery UI styling
     $actions = $actions->dataFields();
     if ($actions) {
         foreach ($actions as $action) {
             $action->setUseButtonTag(true);
         }
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:i-lateral,项目名称:silverstripe-siteconfig,代码行数:30,代码来源:AdminSettingsController.php


示例7: getEditForm

 /**
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $siteConfig = SiteConfig::current_site_config();
     $fields = $siteConfig->getCMSFields();
     // Tell the CMS what URL the preview should show
     $fields->push(new HiddenField('PreviewURL', 'Preview URL', RootURLController::get_homepage_link()));
     // Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
     $fields->push($navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator()));
     $navField->setAllowHTML(true);
     $actions = $siteConfig->getCMSActions();
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-content center cms-edit-form');
     // don't add data-pjax-fragment=CurrentForm, its added in the content template instead
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setHTMLID('Form_EditForm');
     $form->loadDataFrom($siteConfig);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Use <button> to allow full jQuery UI styling
     $actions = $actions->dataFields();
     if ($actions) {
         foreach ($actions as $action) {
             $action->setUseButtonTag(true);
         }
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:33,代码来源:CMSSettingsController.php


示例8: updateEditForm

 public function updateEditForm(CMSForm &$form)
 {
     $fields = $form->Fields();
     $class = $this->owner->modelClass;
     $o = singleton($class);
     $gf = $form->Fields()->dataFieldByName($class);
     $config = $gf->getConfig();
     // If we have the bulk manager, enable by default
     if (class_exists('GridFieldBulkManager')) {
         if ($o->hasMethod('bulkManagerDisable') && $o->bulkManagerDisable) {
         } else {
             $config->addComponent($bulkManager = new GridFieldBulkManager());
             if ($o->hasMethod('bulkManagerAdd')) {
                 $actions = $o->bulkManagerAdd();
                 foreach ($actions as $key => $action) {
                     $bulkHandler = isset($action['Handler']) ? $action['Handler'] : null;
                     $bulkConfig = isset($action['Config']) ? $action['Config'] : null;
                     $bulkManager->addBulkAction($action['Name'], $action['Label'], $bulkHandler, $bulkConfig);
                 }
             }
         }
     }
     // If we have the export all button (form-extras module), enable
     if (class_exists('GridFieldExportAllButton')) {
         $config->addComponent(new GridFieldExportAllButton('before'));
     }
     if (!Director::isDev() || !Permission::check('ADMIN')) {
         return;
     }
     // Add buttons
     $config->addComponent(new GridFieldButtonRow('after'));
     $config->addComponent($btnEmpty = new DevToolkitEmptyButton('buttons-after-left'));
     if ($o->hasMethod('provideFake')) {
         $config->addComponent($btnAddFake = new DevToolkitAddFakeButton('buttons-after-left'));
     }
     if ($o->hasExtension('GeoExtension')) {
         $config->addComponent($btnAddFake = new DevToolkitFakeLocationsButton('buttons-after-left'));
     }
     $config->addComponent($btnDump = new DevToolkitDumpButton('buttons-after-left'));
     // Show session message
     $message = self::SessionMessage();
     if ($message) {
         $fields->insertBefore(new LiteralField("dev_message", "<div class='message {$message->Type}'>{$message->Content}</div>"), $gf->getName());
     }
 }
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:45,代码来源:DevToolkitAdminExtension.php


示例9: AddForm

 /**
  * Generates the form used for adding snippets
  * @return {Form} Form used to add snippets
  */
 public function AddForm()
 {
     $sng = singleton('Snippet');
     $fields = $sng->getCMSFields();
     $validator = $sng->getCMSValidator();
     $actions = new FieldList(FormAction::create('doAdd', _t('CodeBank.CREATE', '_Create'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $form = CMSForm::create($this, 'AddForm', $fields, $actions)->setHTMLID('Form_AddForm');
     $form->setValidator($validator);
     $form->disableDefaultAction();
     $form->addExtraClass('cms-add-form cms-edit-form');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->addExtraClass('center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     //Handle Language id in url
     if ($this->request->getVar('LanguageID')) {
         $langField = $form->Fields()->dataFieldByName('LanguageID');
         if ($langField && $langField->Value() == '') {
             $langField->setValue(intval(str_replace('language-', '', $this->request->getVar('LanguageID'))));
         }
     }
     //Handle folder id in url (or post)
     if ($this->request->getVar('FolderID')) {
         $folder = SnippetFolder::get()->byID(intval($this->request->getVar('FolderID')));
         if (!empty($folder) && $folder !== false && $folder->ID != 0) {
             $langField = $form->Fields()->dataFieldByName('LanguageID')->setValue($folder->ParentID);
             $form->Fields()->replaceField('LanguageID', $langField->performReadonlyTransformation());
             $form->Fields()->push(new HiddenField('FolderID', 'FolderID', $folder->ID));
         }
     } else {
         if ($this->request->postVar('FolderID')) {
             $folder = SnippetFolder::get()->byID(intval($this->request->postVar('FolderID')));
             if (!empty($folder) && $folder !== false && $folder->ID != 0) {
                 $langField = $form->Fields()->dataFieldByName('LanguageID')->setValue($folder->ParentID);
                 $form->Fields()->replaceField('LanguageID', $langField->performReadonlyTransformation());
                 $form->Fields()->push(new HiddenField('FolderID', 'FolderID', $folder->ID));
             }
         }
     }
     $this->extend('updateAddForm', $form);
     //Display message telling user to run dev/build because the version numbers are out of sync
     if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
         $form->insertBefore(new LiteralField('<p class="message error">' . _t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')) . '</p>'), 'LanguageID');
     } else {
         if ($this->hasOldTables()) {
             $form->insertBefore(new LiteralField('<p class="message warning">' . _t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')) . '</p>'), 'LanguageID');
         }
     }
     $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
     Requirements::javascript(CB_DIR . '/javascript/CodeBank.EditForm.js');
     return $form;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:56,代码来源:CodeBankAddSnippet.php


示例10: clear

 public function clear($data, CMSForm $form)
 {
     if (isset($data['ToClear'])) {
         $cleared = array();
         foreach ($data['ToClear'] as $name) {
             $cache = $this->getCache($name);
             if ($cache) {
                 if (isset($data['Key']) && strlen($data['Key'])) {
                     $cache->delete($data['Key']);
                 } else {
                     $cache->clear();
                 }
                 $cleared[] = $name;
             }
         }
         $cleared = implode(',', $cleared);
         $form->sessionMessage("Cleared {$cleared}", 'good');
     } else {
         $form->sessionMessage("No caches cleared", 'good');
     }
     return $form->getResponseNegotiator()->respond($this->getRequest());
 }
开发者ID:nyeholt,项目名称:silverstripe-simplecache,代码行数:22,代码来源:SimpleCacheAdmin.php


示例11: getEditForm

 /**
  * 
  * @param int $id
  * @param FieldList $fields
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $fields = new FieldList();
     $notifications = TimelineEvent::get_all(Member::currentUser());
     $gridField = new GridField('TimelineEvents', 'Timeline', $notifications, new TimelineConfig());
     $fields->add($gridField);
     $form = CMSForm::create($this, "EditForm", $fields, new FieldList())->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     return $form;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-timeline,代码行数:19,代码来源:Timeline.php


示例12: buildForm

 protected function buildForm(FieldList $fields, FieldList $actions)
 {
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Tab nav in CMS is rendered through separate template
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     return $form;
 }
开发者ID:webfox,项目名称:silverstripe-global-content,代码行数:14,代码来源:GlobalContentAdmin.php


示例13: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     $list = $this->getList();
     $listField = GridField::create($this->sanitiseClassName($this->modelClass), false, $list, $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length'))->removeComponentsByType('GridFieldFilterHeader')->removeComponentsByType('GridFieldDetailForm')->removeComponentsByType('GridFieldDeleteAction')->addComponents(new ExternalDataGridFieldDetailForm())->addComponents(new ExternalDataGridFieldDeleteAction()));
     // Validation
     if (singleton($this->modelClass)->hasMethod('getCMSValidator')) {
         $detailValidator = singleton($this->modelClass)->getCMSValidator();
         $listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator);
     }
     $form = CMSForm::create($this, 'EditForm', new FieldList($listField), new FieldList())->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form cms-panel-padded center');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm');
     $form->setFormAction($editFormAction);
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-externaldata,代码行数:19,代码来源:ExternalDataAdmin.php


示例14: getEditForm

 /**
  * @inheritdoc
  */
 public function getEditForm($id = null, $fields = null)
 {
     $model = singleton($this->modelClass);
     if ($model->has_extension('CatalogPageExtension') || $model->has_extension('CatalogDataObjectExtension')) {
         $list = $this->getList()->setDataQueryParam(array('Versioned.stage' => 'Stage'));
         $listField = GridField::create($this->sanitiseClassName($this->modelClass), false, $list, $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length'))->removeComponentsByType('GridFieldFilterHeader')->removeComponentsByType('GridFieldDeleteAction')->addComponent(new GridfieldPagePublishAction()));
         $form = CMSForm::create($this, 'EditForm', new FieldList($listField), new FieldList())->setHTMLID('Form_EditForm');
         // Validation
         if (singleton($this->modelClass)->hasMethod('getCMSValidator')) {
             $detailValidator = singleton($this->modelClass)->getCMSValidator();
             $listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator);
         }
         if ($gridField = $listField->getConfig()->getComponentByType('GridFieldDetailForm')) {
             $gridField->setItemRequestClass('CatalogPageGridFieldDetailForm_ItemRequest');
         }
         $form->setResponseNegotiator($this->getResponseNegotiator());
         $form->addExtraClass('cms-edit-form cms-panel-padded center');
         $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
         $editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm');
         $form->setFormAction($editFormAction);
         $form->setAttribute('data-pjax-fragment', 'CurrentForm');
         /** add sorting if we have a field for... */
         if (class_exists('GridFieldSortableRows') && ($sortField = $model->getSortFieldname())) {
             $fieldConfig->addComponent(new GridFieldSortableRows($sortField));
         }
     } else {
         if (method_exists($model, 'getAdminListField')) {
             $form = CMSForm::create($this, 'EditForm', new FieldList($model->getAdminListField()), new FieldList(FormAction::create('doSave', 'Save')))->setHTMLID('Form_EditForm');
             $form->setResponseNegotiator($this->getResponseNegotiator());
             $form->addExtraClass('cms-edit-form cms-panel-padded center');
             $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
             $editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm');
             $form->setFormAction($editFormAction);
             $form->setAttribute('data-pjax-fragment', 'CurrentForm');
         } else {
             $form = parent::getEditForm();
         }
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:dospuntocero,项目名称:silverstripe-catalogmanager,代码行数:44,代码来源:CatalogPageAdmin.php


示例15: AddForm

 /**
  * @return Form
  */
 public function AddForm()
 {
     $pageTypes = array();
     foreach ($this->PageTypes() as $type) {
         $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description'));
         $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLText', $html);
     }
     // Ensure generic page type shows on top
     if (isset($pageTypes['Page'])) {
         $pageTitle = $pageTypes['Page'];
         $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes);
     }
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';
     $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
     $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
     $fields = new FieldList(new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array(new SelectionGroup_Item("top", null, $topTitle), new SelectionGroup_Item('child', $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'), $childTitle))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page'), new LiteralField('RestrictedNote', sprintf('<p class="message notice message-restricted">%s</p>', _t('CMSMain.AddPageRestriction', 'Note: Some page types are not allowed for this selection'))));
     $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) {
         return DataObject::get($sourceObject, sprintf("\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", Convert::raw2sql($search), Convert::raw2sql($search)));
     });
     // TODO Re-enable search once it allows for HTML title display,
     // see http://open.silverstripe.org/ticket/7455
     // $parentField->setShowSearch(true);
     $parentModeField->addExtraClass('parent-mode');
     // CMSMain->currentPageID() automatically sets the homepage,
     // which we need to counteract in the default selection (which should default to root, ID=0)
     if ($parentID = $this->getRequest()->getVar('ParentID')) {
         $parentModeField->setValue('child');
         $parentField->setValue((int) $parentID);
     } else {
         $parentModeField->setValue('top');
     }
     $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create("doCancel", _t('CMSMain.Cancel', "Cancel"))->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel')->setUseButtonTag(true));
     $this->extend('updatePageOptions', $fields);
     $form = CMSForm::create($this, "AddForm", $fields, $actions)->setHTMLID('Form_AddForm');
     $form->setAttribute('data-hints', $this->SiteTreeHints());
     $form->setAttribute('data-childfilter', $this->Link('childfilter'));
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     return $form;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:44,代码来源:CMSPageAddController.php


示例16: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     // get the cmsfields from ModuleManager DataObject
     $moduleManager = ModuleManager::current_module_manager();
     $fields = $moduleManager->getCMSFields();
     // what pages is this module active on
     $modulesGridField = GridField::create("Modules_Gridfield", "Modules", Module::get(), $modulesGridFieldConfig = GridFieldConfig_RecordEditor::create());
     // add multiclass dropdown for modules
     $modulesGridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     $modulesGridFieldConfig->addComponent(new GridFieldAddNewMultiClass());
     // add the fields
     $fields->addFieldToTab('Root.Modules', $modulesGridField);
     // module positions tab
     $positionsHtml = '<h2>Module positions</h2>';
     $positionsHtml .= '<p class="message info">To change these you need to edit the positions specified in the <code>_config.php</code> file. These are your currently configured positions available:</p>';
     foreach (ModuleManager::config()->positions as $position) {
         $positionsHtml .= '<p>&bull;&nbsp; <strong>' . $position . '</strong><br />&nbsp; &nbsp; Use in your template with <code>$ModulePosition("' . $position . '");</code></p>';
     }
     $positionsHtml .= '</ul>';
     $fields->addFieldToTab('Root.Positions', LiteralField::create('html', $positionsHtml));
     // actions
     $actions = $moduleManager->getCMSActions();
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-content center cms-edit-form');
     // don't add data-pjax-fragment=CurrentForm, its added in the content template instead
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setHTMLID('Form_EditForm');
     $form->loadDataFrom($moduleManager);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Use <button> to allow full jQuery UI styling
     $actions = $actions->dataFields();
     if ($actions) {
         foreach ($actions as $action) {
             $action->setUseButtonTag(true);
         }
     }
     return $form;
 }
开发者ID:jaedb,项目名称:modulemanager,代码行数:41,代码来源:ModuleManagerController.php


示例17: getEditForm

 /**
  * @param null $id Not used.
  * @param null $fields Not used.
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $objectClass = $this->config()->get('tree_class');
     $object = $objectClass::get()->first();
     if (!$object || !$object->exists()) {
         $currentStage = Versioned::current_stage();
         Versioned::reading_stage('Stage');
         $object = $objectClass::create();
         $object->write();
         if ($objectClass::has_extension('Versioned')) {
             $object->doPublish();
         }
         Versioned::reading_stage($currentStage);
     }
     $fields = $object->getCMSFields();
     $fields->push(HiddenField::create('ID', 'ID', $object->ID));
     $fields->push($navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator()));
     $navField->setAllowHTML(true);
     $actions = new FieldList();
     $actions->push(FormAction::create('doSave', 'Save')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-content center cms-edit-form');
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setHTMLID('Form_EditForm');
     $form->loadDataFrom($object);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Use <button> to allow full jQuery UI styling
     $actions = $actions->dataFields();
     if ($actions) {
         foreach ($actions as $action) {
             $action->setUseButtonTag(true);
         }
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:littlegiant,项目名称:silverstripe-singleobjectadmin,代码行数:44,代码来源:SingleObjectAdmin.php


示例18: getEditForm

 /**
  * @param null $id Not used.
  * @param null $fields Not used.
  * @return Form
  * @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
  */
 public function getEditForm($id = null, $fields = null)
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $uploadField = CloudinaryUploadField::create('AssetUploadField', '');
     $uploadField->setConfig('previewMaxWidth', 40);
     $uploadField->setConfig('previewMaxHeight', 30);
     $uploadField->setConfig('changeDetection', false);
     $uploadField->addExtraClass('ss-assetuploadfield');
     $uploadField->removeExtraClass('ss-uploadfield');
     $uploadField->setTemplate('AssetUploadField');
     $exts = $uploadField->getValidator()->getAllowedExtensions();
     asort($exts);
     $uploadField->Extensions = implode(', ', $exts);
     $form = CMSForm::create($this, 'EditForm', new FieldList($uploadField), new FieldList())->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
     // Don't use AssetAdmin_EditForm, as it assumes a different panel structure
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->Fields()->push(new LiteralField('BackLink', sprintf('<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>', singleton('CloudinaryAdmin')->Link('show'), 'Back to files')));
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:29,代码来源:CloudinaryFileAddController.php


示例19: getEditForm

 /**
  * @param null $id Not used.
  * @param null $fields Not used.
  *
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $siteConfig = SiteConfig::current_site_config();
     $fields = $siteConfig->getCMSFields();
     // Tell the CMS what URL the preview should show
     $home = Director::absoluteBaseURL();
     $fields->push(new HiddenField('P 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CMSHomeControl类代码示例发布时间:2022-05-23
下一篇:
PHP CMSCategory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap