當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HtmlEditorConfig::get_active_identifier方法代碼示例

本文整理匯總了PHP中HtmlEditorConfig::get_active_identifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP HtmlEditorConfig::get_active_identifier方法的具體用法?PHP HtmlEditorConfig::get_active_identifier怎麽用?PHP HtmlEditorConfig::get_active_identifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HtmlEditorConfig的用法示例。


在下文中一共展示了HtmlEditorConfig::get_active_identifier方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Creates a new HTMLEditorField.
  * @see TextareaField::__construct()
  *
  * @param string $name The internal field name, passed to forms.
  * @param string $title The human-readable field label.
  * @param mixed $value The value of the field.
  * @param string $config HTMLEditorConfig identifier to be used. Default to the active one.
  */
 public function __construct($name, $title = null, $value = '', $config = null)
 {
     parent::__construct($name, $title, $value);
     $this->editorConfig = $config ? $config : HtmlEditorConfig::get_active_identifier();
 }
開發者ID:ivoba,項目名稱:silverstripe-framework,代碼行數:14,代碼來源:HtmlEditorField.php

示例2: prepareForRender

 /**
  * Prepares everything just before rendering the field
  */
 protected function prepareForRender()
 {
     if (!$this->preparedForRender) {
         $this->preparedForRender = true;
         if (!$this->isReadonly() && $this->depth == 1) {
             // NOTE(Jake): jQuery.ondemand is required to allow FormField classes to add their own
             //             Requirements::javascript on-the-fly.
             //Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/jquery/jquery.js");
             Requirements::css(MULTIRECORDEDITOR_DIR . '/css/MultiRecordField.css');
             if (is_subclass_of(Controller::curr(), 'LeftAndMain')) {
                 // NOTE(Jake): Only include in CMS to fix margin issues. Not in the main CSS file
                 //             so that the frontend CSS is less in the way.
                 Requirements::css(MULTIRECORDEDITOR_DIR . '/css/MultiRecordFieldCMS.css');
             }
             Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
             Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
             Requirements::javascript(FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js');
             Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
             Requirements::javascript(MULTIRECORDEDITOR_DIR . '/javascript/MultiRecordField.js');
             // If config is set to 'default' but 'default' isn't configured, fallback to 'cms'.
             // NOTE(Jake): In SS 3.2, 'default' is the default active config but its not configured.
             $availableConfigs = HtmlEditorConfig::get_available_configs_map();
             $activeIdentifier = HtmlEditorConfig::get_active_identifier();
             if ($activeIdentifier === 'default' && !isset($availableConfigs[$activeIdentifier])) {
                 HtmlEditorConfig::set_active('cms');
             }
         }
         //
         // Setup actions
         //
         $actions = $this->Actions();
         if ($actions && $actions->count()) {
             $modelClasses = $this->getModelClassesOrThrowExceptionIfEmpty();
             $modelFirstClass = key($modelClasses);
             $inlineAddButton = $actions->dataFieldByName('action_AddInlineRecord');
             if ($inlineAddButton) {
                 // Setup default inline field data attributes
                 //$inlineAddButton->setAttribute('data-name', $this->getName());
                 $inlineAddButton->setAttribute('data-action', $this->getName());
                 $inlineAddButton->setAttribute('data-class', $modelFirstClass);
                 $inlineAddButton->setAttribute('data-depth', $this->depth);
                 // Automatically apply all data attributes on this element, to the inline button.
                 foreach ($this->getAttributes() as $name => $value) {
                     if (substr($name, 0, 5) === 'data-') {
                         $inlineAddButton->setAttribute($name, $value);
                     }
                 }
                 if (count($modelClasses) == 1) {
                     $name = singleton($modelFirstClass)->i18n_singular_name();
                     $inlineAddButton->setTitle('Add ' . $name);
                 }
             }
             $classField = $actions->dataFieldByName('ClassName');
             if ($classField) {
                 if (count($modelClasses) > 1) {
                     if ($inlineAddButton) {
                         $inlineAddButton->setDisabled(true);
                     }
                     $classField->setSource($modelClasses);
                 } else {
                     $actions->removeByName('ClassName');
                 }
             }
             // Allow outside sources to influences the disable state class-wise
             if ($inlineAddButton && $inlineAddButton->isDisabled()) {
                 $inlineAddButton->addExtraClass('is-disabled');
             }
             //
             foreach ($actions as $actionField) {
                 // Expand out names
                 $actionField->setName($this->getName() . '_' . $actionField->getName());
             }
         }
         // Get existing records to add fields for
         $recordArray = array();
         if ($this->list && !$this->list instanceof UnsavedRelationList) {
             foreach ($this->list->toArray() as $record) {
                 $recordArray[$record->ID] = $record;
             }
         }
         //
         // If the user validation failed, Value() will be populated with some records
         // that have 'new_' IDs, so handle them.
         //
         $value = $this->Value();
         if ($value && is_array($value)) {
             foreach ($value as $class => $recordDatas) {
                 foreach ($recordDatas as $new_id => $fieldData) {
                     if (substr($new_id, 0, 4) === 'new_') {
                         $record = $class::create();
                         $record->MultiRecordField_NewID = $new_id;
                         $recordArray[$new_id] = $record;
                     } else {
                         if ($new_id == (string) (int) $new_id) {
                             // NOTE(Jake): "o-multirecordediting-1-id" == 0 // evaluates true in PHP 5.5.12,
                             //             So we need to make it a string again to avoid that dumb case.
                             $new_id = (int) $new_id;
//.........這裏部分代碼省略.........
開發者ID:silbinarywolf,項目名稱:multirecordfield,代碼行數:101,代碼來源:MultiRecordField.php


注:本文中的HtmlEditorConfig::get_active_identifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。