本文整理汇总了PHP中BaseElementModel类的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel类的具体用法?PHP BaseElementModel怎么用?PHP BaseElementModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseElementModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: updateDescendantSlugsAndUris
/**
* Updates an element’s descendants’ slugs and URIs.
*
* @param BaseElementModel $element The element whose descendants should be updated.
* @param bool $updateOtherLocales Whether the element’s other locales should also be updated.
* @param bool $asTask Whether the descendants’ slugs and URIs should be updated via a background task.
*
* @return null
*/
public function updateDescendantSlugsAndUris(BaseElementModel $element, $updateOtherLocales = true, $asTask = false)
{
$criteria = $this->getCriteria($element->getElementType());
$criteria->descendantOf = $element;
$criteria->descendantDist = 1;
$criteria->status = null;
$criteria->localeEnabled = null;
$criteria->locale = $element->locale;
if ($asTask) {
$childIds = $criteria->ids();
if ($childIds) {
craft()->tasks->createTask('UpdateElementSlugsAndUris', null, array('elementId' => $childIds, 'elementType' => $element->getElementType(), 'locale' => $element->locale, 'updateOtherLocales' => $updateOtherLocales, 'updateDescendants' => true));
}
} else {
$children = $criteria->find();
foreach ($children as $child) {
$this->updateElementSlugAndUri($child, $updateOtherLocales, true, false);
}
}
}
开发者ID:harish94,项目名称:Craft-Release,代码行数:29,代码来源:ElementsService.php
示例13: routeRequestForMatchedElement
/**
* Routes the request when the URI matches an element.
*
* @param BaseElementModel
* @return mixed Can be false if no special action should be taken,
* a string if it should route to a template path,
* or an array that can specify a controller action path, params, etc.
*/
public function routeRequestForMatchedElement(BaseElementModel $element)
{
// Make sure that the entry is actually live
if ($element->getStatus() == EntryModel::LIVE) {
$section = $element->getSection();
// Make sure the section is set to have URLs and is enabled for this locale
if ($section->hasUrls && array_key_exists(craft()->language, $section->getLocales())) {
return array('action' => 'templates/render', 'params' => array('template' => $section->template, 'variables' => array('entry' => $element)));
}
}
return false;
}
开发者ID:kentonquatman,项目名称:portfolio,代码行数:20,代码来源:EntryElementType.php
示例14: getEditorHtml
/**
* @inheritDoc IElementType::getEditorHtml()
*
* @param BaseElementModel $element
*
* @return string
*/
public function getEditorHtml(BaseElementModel $element)
{
$html = craft()->templates->renderMacro('_includes/forms', 'textField', array(array('label' => Craft::t('Filename'), 'id' => 'filename', 'name' => 'filename', 'value' => $element->filename, 'errors' => $element->getErrors('filename'), 'first' => true, 'required' => true)));
$html .= craft()->templates->renderMacro('_includes/forms', 'textField', array(array('label' => Craft::t('Title'), 'locale' => $element->locale, 'id' => 'title', 'name' => 'title', 'value' => $element->title, 'errors' => $element->getErrors('title'), 'required' => true)));
$html .= parent::getEditorHtml($element);
return $html;
}
开发者ID:kant312,项目名称:sop,代码行数:14,代码来源:AssetElementType.php
示例15: 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 'owner':
if ($element->ownerType == 'guest') {
return Craft::t('Guest');
} else {
$user = craft()->users->getUserById($element->ownerId);
if ($user == null) {
return Craft::t('[Deleted User]');
} else {
$url = UrlHelper::getCpUrl('users/' . $user->id);
return "<a href='" . $url . "'>" . $user->getFriendlyName() . "</a>";
}
}
case 'itemCount':
return count($element->items());
case 'itemList':
$items = $element->items();
$str = array();
$i = 0;
foreach ($items as $item) {
if ($i < $this->listInlineViewLimit) {
$parent = craft()->entries->getEntryById($item->elementId);
$url = UrlHelper::getCpUrl('shortlist/list/' . $element->id . '#' . $item->elementId);
$str[] = '<a href="' . $url . '">' . $parent->title . '</a>';
}
$i++;
}
$ret = implode(', ', $str);
if (count($items) > $this->listInlineViewLimit) {
$hidden = count($items) - $this->listInlineViewLimit;
$moreUrl = UrlHelper::getCpUrl('shortlist/list/' . $element->id . '#items');
$ret .= " .. <a href='" . $moreUrl . "'>+" . $hidden . " more</a>";
}
return $ret;
default:
return $element->{$attribute};
}
}
开发者ID:jamiepittock,项目名称:WhereForArt,代码行数:47,代码来源:Shortlist_ListElementType.php
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: _getDimension
/**
* Return a dimension of the image.
*
* @param $dimension 'height' or 'width'
* @param $transform
*
* @return null|float|mixed
*/
private function _getDimension($dimension, $transform)
{
if ($this->kind != 'image') {
return null;
}
if ($transform === null && isset($this->_transform)) {
$transform = $this->_transform;
}
if (!$transform) {
return parent::getAttribute($dimension);
}
$transform = craft()->assetTransforms->normalizeTransform($transform);
$dimensions = array('width' => $transform->width, 'height' => $transform->height);
if (!$transform->width || !$transform->height) {
// Fill in the blank
$dimensionArray = ImageHelper::calculateMissingDimension($dimensions['width'], $dimensions['height'], $this->_getWidth(), $this->_getHeight());
$dimensions['width'] = (int) $dimensionArray[0];
$dimensions['height'] = (int) $dimensionArray[1];
}
// Special case for 'fit' since that's the only one whose dimensions vary from the transform dimensions
if ($transform->mode == 'fit') {
$factor = max($this->_getWidth() / $dimensions['width'], $this->_getHeight() / $dimensions['height']);
$dimensions['width'] = (int) round($this->_getWidth() / $factor);
$dimensions['height'] = (int) round($this->_getHeight() / $factor);
}
return $dimensions[$dimension];
}
开发者ID:amite,项目名称:arc-va,代码行数:35,代码来源:AssetFileModel.php
注:本文中的BaseElementModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论