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


PHP BaseElementModel类代码示例

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


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

示例1: getTableAttributeHtml

 /**
  * Returns the table view HTML for a given attribute.
  *
  * @param BaseElementModel $element
  * @param string $attribute
  * @return string
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'mode':
             return ucwords($element->mode);
         case 'planAmount':
             if ($element->planType == 'recurring') {
                 return $element->formatPlanName();
             } else {
                 return $element->formatPlanAmount();
             }
         case 'customerName':
             return $element->customerName . ' <a href="mailto:' . $element->customerEmail . '">' . $element->customerEmail . '</a>';
         case 'cardLast4':
             return '<span class="cardType type' . $element->cardType . '"></span> ' . $element->formatCard();
         case 'planType':
             if ($element->planType == 'recurring') {
                 return ucwords($element->planType);
             } else {
                 return 'One-time';
             }
         case 'timestamp':
             if ($element->timestamp) {
                 return $element->timestamp->localeDate();
             } else {
                 return '';
             }
     }
 }
开发者ID:jamiepittock,项目名称:WhereForArt,代码行数:36,代码来源:ChargeElementType.php

示例2: prepElementContentForSave

 /**
  * Prepares an element's content for being saved to the database.
  *
  * @param BaseElementModel $element
  * @param FieldLayoutModel $fieldLayout
  * @param bool             $validate
  * @return ContentModel
  */
 public function prepElementContentForSave(BaseElementModel $element, FieldLayoutModel $fieldLayout, $validate = true)
 {
     $elementTypeClass = $element->getElementType();
     $elementType = craft()->elements->getElementType($elementTypeClass);
     $content = $element->getContent();
     if ($validate) {
         // Set the required fields from the layout
         $requiredFields = array();
         if ($elementType->hasTitles()) {
             $requiredFields[] = 'title';
         }
         foreach ($fieldLayout->getFields() as $field) {
             if ($field->required) {
                 $requiredFields[] = $field->fieldId;
             }
         }
         if ($requiredFields) {
             $content->setRequiredFields($requiredFields);
         }
     }
     // Give the fieldtypes a chance to clean up the post data
     foreach (craft()->fields->getAllFields() as $field) {
         $fieldType = craft()->fields->populateFieldType($field);
         if ($fieldType) {
             $fieldType->element = $element;
             $handle = $field->handle;
             $content->{$handle} = $fieldType->prepValueFromPost($content->{$handle});
         }
     }
     return $content;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:39,代码来源:ContentService.php

示例3: getElementOptionsHtml

 public function getElementOptionsHtml(BaseElementModel $element)
 {
     $isNew = $element->id === null;
     $locales = array_keys($element->getLocales());
     $settings = craft()->plugins->getPlugin('localeSync')->getSettings();
     if ($isNew || count($locales) < 2) {
         return;
     }
     return craft()->templates->render('localesync/_cp/entriesEditRightPane', ['settings' => $settings, 'localeId' => $element->locale]);
 }
开发者ID:timkelty,项目名称:craft-localesync,代码行数:10,代码来源:LocaleSyncService.php

示例4: getTableAttributeHtml

 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'data':
             $data = $element->_normalizeDataForElementsTable();
             return $element->data;
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
开发者ID:nealstammers,项目名称:FormBuilder-Craft-CMS,代码行数:12,代码来源:FormBuilderElementType.php

示例5: getTableAttributeHtml

 /**
  * Get Tablet Attribute HTML
  *
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'submission':
             $data = $element->viewEntryLinkOnElementsTable();
             return $element->submission;
             break;
         case 'files':
             $files = $element->normalizeFilesForElementsTable();
             return $element->files;
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
开发者ID:daituzhang,项目名称:craft-starter,代码行数:20,代码来源:FormBuilder2ElementType.php

示例6: getTableAttributeHtml

 /**
  * Return table attribute html.
  *
  * @param BaseElementModel $element
  * @param string           $attribute
  *
  * @return string
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     // First give plugins a chance to set this
     $pluginAttributeHtml = craft()->plugins->callFirst('getAuditLogTableAttributeHtml', array($element, $attribute), true);
     // Check if that had a valid result
     if ($pluginAttributeHtml) {
         return $pluginAttributeHtml;
     }
     // Modify custom attributes
     switch ($attribute) {
         // Format dates
         case 'dateCreated':
         case 'dateUpdated':
             return craft()->dateFormatter->formatDateTime($element->{$attribute});
             // Return clickable user link
         // Return clickable user link
         case 'user':
             $user = $element->getUser();
             return $user ? '<a href="' . $user->getCpEditUrl() . '">' . $user . '</a>' : Craft::t('Guest');
             // Return clickable event origin
         // Return clickable event origin
         case 'origin':
             return '<a href="' . preg_replace('/' . craft()->config->get('cpTrigger') . '\\//', '', UrlHelper::getUrl($element->origin), 1) . '">' . $element->origin . '</a>';
             // Return view changes button
         // Return view changes button
         case 'changes':
             return '<a class="btn" href="' . UrlHelper::getCpUrl('auditlog/' . $element->id) . '">' . Craft::t('View') . '</a>';
             // Default behavior
         // Default behavior
         default:
             return $element->{$attribute};
     }
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:41,代码来源:AuditLogElementType.php

示例7: indexElementAttributes

 /**
  * Indexes the attributes of a given element defined by its element type.
  *
  * @param BaseElementModel $element
  * @param string|null      $localeId
  * @return bool Whether the indexing was a success.
  */
 public function indexElementAttributes(BaseElementModel $element, $localeId = null)
 {
     // Get the element type
     $elementTypeClass = $element->getElementType();
     $elementType = craft()->elements->getElementType($elementTypeClass);
     // Does it have any searchable attributes?
     $searchableAttributes = $elementType->defineSearchableAttributes();
     if ($elementType->hasTitles()) {
         $searchableAttributes[] = 'title';
     }
     foreach ($searchableAttributes as $attribute) {
         $value = $element->{$attribute};
         $value = StringHelper::arrayToString($value);
         $this->_indexElementKeywords($element->id, $attribute, '0', $localeId, $value);
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:24,代码来源:SearchService.php

示例8: process

 /**
  * Upload and process the result.
  *
  * @param BaseElementModel $element
  * @param AssetFileModel   $asset
  * @param string           $handle
  *
  * @return bool
  */
 public function process(BaseElementModel $element, AssetFileModel $asset, $handle)
 {
     // Check if we have this asset already or upload to YouTube
     if (!($youTubeId = $this->exists($asset))) {
         try {
             $youTubeId = $this->assemble($asset);
         } catch (Exception $e) {
             return $e->getMessage();
         }
     }
     // Get current video's
     $content = $element->getContent()->getAttribute($handle);
     // Make sure content's an array
     $content = is_array($content) ? $content : array();
     // Remove this asset's id from the content
     unset($content[array_search($asset->id, $content)]);
     // Add video to (existing) content
     $element->getContent()->{$handle} = array_merge($content, array($youTubeId));
     // Save the content without validation
     craft()->content->saveContent($element, false);
     // All went well
     return true;
 }
开发者ID:boboldehampsink,项目名称:youtube,代码行数:32,代码来源:YouTubeService.php

示例9: prepForElementModel

 /**
  * Prepare reserved ElementModel values.
  *
  * @param array            &$fields
  * @param BaseElementModel $element
  *
  * @return BaseElementModel
  */
 public function prepForElementModel(array &$fields, BaseElementModel $element)
 {
     // Set slug
     $slug = Import_ElementModel::HandleSlug;
     if (isset($fields[$slug])) {
         $element->{$slug} = ElementHelper::createSlug($fields[$slug]);
         unset($fields[$slug]);
     }
     // Set title
     $title = Import_ElementModel::HandleTitle;
     if (isset($fields[$title])) {
         $element->getContent()->{$title} = $fields[$title];
         unset($fields[$title]);
     }
     // Return element
     return $element;
 }
开发者ID:radarseven,项目名称:import,代码行数:25,代码来源:Import_CategoryService.php

示例10: onAfterMoveElementInStructure

 /**
  * @inheritDoc IElementType::onAfterMoveElementInStructure()
  *
  * @param BaseElementModel $element
  * @param int              $structureId
  *
  * @return null|void
  */
 public function onAfterMoveElementInStructure(BaseElementModel $element, $structureId)
 {
     // Was the entry moved within its section's structure?
     $section = $element->getSection();
     if ($section->type == SectionType::Structure && $section->structureId == $structureId) {
         craft()->elements->updateElementSlugAndUri($element, true, true, true);
     }
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:16,代码来源:EntryElementType.php

示例11: getEditorHtml

 /**
  * @inheritDoc IElementType::getEditorHtml()
  *
  * @param BaseElementModel $element
  *
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     return sprintf('<div class="pane"><a class="btn submit" href="%s" target="_blank">%s</a></div>', $element->getCpEditUrl(), Craft::t('Edit form'));
 }
开发者ID:am-impact,项目名称:amforms,代码行数:11,代码来源:AmForms_FormElementType.php

示例12: defineAttributes

 /**
  * @access protected
  * @return array
  */
 protected function defineAttributes()
 {
     // Craft email settings
     $settings = craft()->email->getSettings();
     $systemEmail = !empty($settings['emailAddress']) ? $settings['emailAddress'] : '';
     $systemName = !empty($settings['senderName']) ? $settings['senderName'] : '';
     return array_merge(parent::defineAttributes(), array('id' => AttributeType::Number, 'fieldLayoutId' => AttributeType::Number, 'redirectEntryId' => AttributeType::Number, 'name' => AttributeType::String, 'handle' => AttributeType::String, 'titleFormat' => array(AttributeType::String, 'default' => "{dateCreated|date('D, d M Y H:i:s')}"), 'submitAction' => AttributeType::String, 'submitButton' => AttributeType::String, 'afterSubmitText' => AttributeType::Mixed, 'submissionEnabled' => array(AttributeType::Bool, 'default' => true), 'sendCopy' => array(AttributeType::Bool, 'default' => false), 'sendCopyTo' => AttributeType::String, 'notificationEnabled' => array(AttributeType::Bool, 'default' => true), 'notificationFilesEnabled' => array(AttributeType::Bool, 'default' => false), 'notificationRecipients' => array(AttributeType::String, 'default' => $systemEmail), 'notificationSubject' => array(AttributeType::String, 'default' => Craft::t('{formName} form was submitted')), 'notificationSenderName' => array(AttributeType::String, 'default' => $systemName), 'notificationSenderEmail' => array(AttributeType::String, 'default' => $systemEmail), 'notificationReplyToEmail' => array(AttributeType::String, 'default' => $systemEmail), 'formTemplate' => AttributeType::String, 'tabTemplate' => AttributeType::String, 'fieldTemplate' => AttributeType::String, 'notificationTemplate' => AttributeType::String));
 }
开发者ID:webremote,项目名称:amforms,代码行数:12,代码来源:AmForms_FormModel.php

示例13: isFresh

 /**
  * Returns whether this is the first time the element's content has been edited.
  *
  * @return bool
  */
 protected function isFresh()
 {
     // If this is for a Matrix block, we're more interested in its owner
     if (isset($this->element) && $this->element->getElementType() == ElementType::MatrixBlock) {
         $element = $this->element->getOwner();
     } else {
         $element = $this->element;
     }
     return !$element || empty($element->getContent()->id) && !$element->hasErrors();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:15,代码来源:BaseFieldType.php

示例14: isFresh

 /**
  * Returns whether this is the first time the element's content has been edited.
  *
  * @return bool
  */
 protected function isFresh()
 {
     if (!isset($this->_isFresh)) {
         if (isset($this->element)) {
             $this->_isFresh = $this->element->getHasFreshContent();
         } else {
             $this->_isFresh = true;
         }
     }
     return $this->_isFresh;
 }
开发者ID:vescoyez,项目名称:portfolio_v2,代码行数:16,代码来源:BaseFieldType.php

示例15: getStatus

 /**
  * Returns the element's status.
  *
  * @return string|null
  */
 public function getStatus()
 {
     $status = parent::getStatus();
     if ($status == static::ENABLED && $this->postDate) {
         $currentTime = DateTimeHelper::currentTimeStamp();
         $postDate = $this->postDate->getTimestamp();
         $expiryDate = $this->expiryDate ? $this->expiryDate->getTimestamp() : null;
         if ($postDate <= $currentTime && (!$expiryDate || $expiryDate > $currentTime)) {
             return static::LIVE;
         } else {
             if ($postDate > $currentTime) {
                 return static::PENDING;
             } else {
                 return static::EXPIRED;
             }
         }
     }
     return $status;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:24,代码来源:EntryModel.php


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