/**
  * @inheritDoc BaseModel::defineAttributes()
  *
  * @return array
  */
 protected function defineAttributes()
 {
     $attributes = array('ancestorDist' => AttributeType::Number, 'ancestorOf' => AttributeType::Mixed, 'archived' => AttributeType::Bool, 'dateCreated' => AttributeType::Mixed, 'dateUpdated' => AttributeType::Mixed, 'descendantDist' => AttributeType::Number, 'descendantOf' => AttributeType::Mixed, 'fixedOrder' => AttributeType::Bool, 'id' => AttributeType::Number, 'indexBy' => AttributeType::String, 'level' => AttributeType::Number, 'limit' => array(AttributeType::Number, 'default' => 100), 'locale' => AttributeType::Locale, 'localeEnabled' => array(AttributeType::Bool, 'default' => true), 'nextSiblingOf' => AttributeType::Mixed, 'offset' => array(AttributeType::Number, 'default' => 0), 'order' => array(AttributeType::String, 'default' => 'elements.dateCreated desc'), 'positionedAfter' => AttributeType::Mixed, 'positionedBefore' => AttributeType::Mixed, 'prevSiblingOf' => AttributeType::Mixed, 'relatedTo' => AttributeType::Mixed, 'ref' => AttributeType::String, 'search' => AttributeType::String, 'siblingOf' => AttributeType::Mixed, 'slug' => AttributeType::String, 'status' => array(AttributeType::String, 'default' => BaseElementModel::ENABLED), 'title' => AttributeType::String, 'uri' => AttributeType::String, 'kind' => AttributeType::Mixed, 'childField' => AttributeType::String, 'childOf' => AttributeType::Mixed, 'depth' => AttributeType::Number, 'parentField' => AttributeType::String, 'parentOf' => AttributeType::Mixed);
     // Mix in any custom attributes defined by the element type
     $elementTypeAttributes = $this->_elementType->defineCriteriaAttributes();
     $attributes = array_merge($attributes, $elementTypeAttributes);
     return $attributes;
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'data':
             $data = $element->_normalizeDataForElementsTable();
             return $element->data;
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
 /**
  * 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;
     }
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     $value = $element->{$attribute};
     if ($value instanceof MultiOptionsFieldData) {
         $options = $value->getOptions();
         $summary = array();
         for ($j = 0; $j < count($options); ++$j) {
             $option = $options[$j];
             if ($option->selected) {
                 $summary[] = $option->label;
             }
         }
         return implode($summary, ', ');
     } else {
         return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 /**
  * @return array
  */
 protected function defineAttributes()
 {
     $attributes = array('ancestorDist' => AttributeType::Number, 'ancestorOf' => AttributeType::Mixed, 'archived' => AttributeType::Bool, 'dateCreated' => AttributeType::Mixed, 'dateUpdated' => AttributeType::Mixed, 'descendantDist' => AttributeType::Number, 'descendantOf' => AttributeType::Mixed, 'fixedOrder' => AttributeType::Bool, 'id' => AttributeType::Number, 'indexBy' => AttributeType::String, 'level' => AttributeType::Number, 'limit' => array(AttributeType::Number, 'default' => 100), 'locale' => AttributeType::Locale, 'localeEnabled' => array(AttributeType::Bool, 'default' => true), 'nextSiblingOf' => AttributeType::Mixed, 'offset' => array(AttributeType::Number, 'default' => 0), 'order' => array(AttributeType::String, 'default' => 'elements.dateCreated desc'), 'positionedAfter' => AttributeType::Mixed, 'positionedBefore' => AttributeType::Mixed, 'prevSiblingOf' => AttributeType::Mixed, 'relatedTo' => AttributeType::Mixed, 'ref' => AttributeType::String, 'search' => AttributeType::String, 'siblingOf' => AttributeType::Mixed, 'slug' => AttributeType::String, 'status' => array(AttributeType::String, 'default' => BaseElementModel::ENABLED), 'title' => AttributeType::String, 'uri' => AttributeType::String, 'kind' => AttributeType::Mixed, 'childField' => AttributeType::String, 'childOf' => AttributeType::Mixed, 'depth' => AttributeType::Number, 'parentField' => AttributeType::String, 'parentOf' => AttributeType::Mixed);
     // Mix in any custom attributes defined by the element type
     $elementTypeAttributes = $this->_elementType->defineCriteriaAttributes();
     $attributes = array_merge($attributes, $elementTypeAttributes);
     // Mix in the custom fields
     $this->_supportedFieldHandles = array();
     foreach (craft()->fields->getAllFields() as $field) {
         // Make sure the handle doesn't conflict with an existing attribute
         if (!isset($attributes[$field->handle])) {
             $this->_supportedFieldHandles[] = $field->handle;
             $attributes[$field->handle] = array(AttributeType::Mixed);
         }
     }
     return $attributes;
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'publisher':
         case 'editor':
             if ($element->{$attribute}) {
                 return "<a href='" . $element->{$attribute}->cpEditUrl . "'>" . $element->{$attribute} . "</a>";
             }
         case 'dateApproved':
         case 'dateRejected':
             if (!$element->{$attribute}) {
                 return "-";
             }
         default:
             return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     if ($attribute == 'action') {
         return '<a class="delete icon" role="button" title="Delete"></a>';
     } else {
         $value = $element->{$attribute};
         if ($value instanceof MultiOptionsFieldData) {
             $options = $value->getOptions();
             $summary = array();
             for ($j = 0; $j < count($options); ++$j) {
                 $option = $options[$j];
                 if ($option->selected) {
                     $summary[] = $option->label;
                 }
             }
             return implode($summary, ', ');
         } else {
             return parent::getTableAttributeHtml($element, $attribute);
         }
     }
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'user':
             $user = craft()->users->getUserById($element->userId);
             if ($user == null) {
                 return $element->name;
             } else {
                 $url = UrlHelper::getCpUrl('users/' . $user->id);
                 return "<a href='" . $url . "'>" . $user->getFriendlyName() . "</a>";
             }
         case 'element':
             $element = craft()->elements->getElementById($element->elementId);
             if ($element == null) {
                 return Craft::t('[Deleted element]');
             } else {
                 return "<a href='" . $element->cpEditUrl . "'>" . $element->title . "</a>";
             }
         case 'status':
             return '<span class="status ' . $element->status . '"></span>';
         case 'comment':
             $user = craft()->users->getUserById($element->userId);
             if ($user == null) {
                 $userName = $element->name;
             } else {
                 $url = UrlHelper::getCpUrl('users/' . $user->id);
                 $userName = $user->getFriendlyName();
             }
             $html = '<div class="comment-block">';
             $html .= '<a href="' . $element->getCpEditUrl() . '">';
             $html .= '<span class="username">' . $userName . '</span>';
             $html .= '<small>' . $element->getExcerpt(0, 150) . '</small></a>';
             $html .= '</div>';
             return $html;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 /**
  * @inheritDoc BaseElementType::getTableAttributesForSource()
  *
  * @param string $sourceKey
  *
  * @return array
  */
 protected function getTableAttributesForSource($sourceKey)
 {
     // Make sure it's a folder
     if (strncmp($sourceKey, 'folder:', 7) === 0) {
         $folder = craft()->assets->getFolderById(substr($sourceKey, 7));
         // Is it a nested folder?
         if ($folder && $folder->parentId) {
             // Get the root folder in that source
             $rootFolder = craft()->assets->getRootFolderBySourceId($folder->sourceId);
             if ($rootFolder) {
                 // Use the root folder's source key
                 $sourceKey = 'folder:' . $rootFolder->id;
             }
         }
     }
     return parent::getTableAttributesForSource($sourceKey);
 }
 /**
  * Returns the HTML for an editor HUD for the given element.
  *
  * @param BaseElementModel $element
  *
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     if ($element->getType()->hasTitleField) {
         $html = craft()->templates->render('entries/_titlefield', array('entry' => $element));
     } else {
         $html = '';
     }
     $html .= parent::getEditorHtml($element);
     return $html;
 }
 /**
  * Preps the element criteria for a given table attribute
  *
  * @param ElementCriteriaModel $criteria
  * @param string               $attribute
  *
  * @return void
  */
 protected function prepElementCriteriaForTableAttribute(ElementCriteriaModel $criteria, $attribute)
 {
     if ($attribute == 'author') {
         $with = $criteria->with ?: array();
         $with[] = 'author';
         $criteria->with = $with;
     } else {
         parent::prepElementCriteriaForTableAttribute($criteria, $attribute);
     }
 }
 /**
  * Eager-loads additional elements onto a given set of elements.
  *
  * @param BaseElementType    $elementType The root element type
  * @param BaseElementModel[] $elements    The root element models that should be updated with the eager-loaded elements
  * @param string|array       $with        Dot-delimited paths of the elements that should be eager-loaded into the root elements
  *
  * @return void
  */
 public function eagerLoadElements(BaseElementType $elementType, $elements, $with)
 {
     // Bail if there aren't even any elements
     if (!$elements) {
         return;
     }
     // Normalize the paths and find any custom path criterias
     $with = ArrayHelper::stringToArray($with);
     $paths = array();
     $pathCriterias = array();
     foreach ($with as $path) {
         // Using the array syntax?
         // ['foo.bar'] or ['foo.bar', criteria]
         if (is_array($path)) {
             if (!empty($path[1])) {
                 $pathCriterias['__root__.' . $path[0]] = $path[1];
             }
             $paths[] = $path[0];
         } else {
             $paths[] = $path;
         }
     }
     // Load 'em up!
     $elementsByPath = array('__root__' => $elements);
     $elementTypesByPath = array('__root__' => $elementType->getClassHandle());
     foreach ($paths as $path) {
         $pathSegments = explode('.', $path);
         $sourcePath = '__root__';
         foreach ($pathSegments as $segment) {
             $targetPath = $sourcePath . '.' . $segment;
             // Figure out the path mapping wants a custom order
             $useCustomOrder = !empty($pathCriterias[$targetPath]['order']);
             // Make sure we haven't already eager-loaded this target path
             if (!isset($elementsByPath[$targetPath])) {
                 // Guilty until proven innocent
                 $elementsByPath[$targetPath] = $targetElements = $targetElementsById = $targetElementIdsBySourceIds = false;
                 // Get the eager-loading map from the source element type
                 $sourceElementType = $this->getElementType($elementTypesByPath[$sourcePath]);
                 $map = $sourceElementType->getEagerLoadingMap($elementsByPath[$sourcePath], $segment);
                 if ($map && !empty($map['map'])) {
                     // Remember the element type in case there are more segments after this
                     $elementTypesByPath[$targetPath] = $map['elementType'];
                     // Loop through the map to find:
                     // - unique target element IDs
                     // - target element IDs indexed by source element IDs
                     $uniqueTargetElementIds = array();
                     $targetElementIdsBySourceIds = array();
                     foreach ($map['map'] as $mapping) {
                         if (!in_array($mapping['target'], $uniqueTargetElementIds)) {
                             $uniqueTargetElementIds[] = $mapping['target'];
                         }
                         $targetElementIdsBySourceIds[$mapping['source']][] = $mapping['target'];
                     }
                     // Get the target elements
                     $customParams = array_merge(array('order' => null, 'limit' => null), isset($map['criteria']) ? $map['criteria'] : array(), isset($pathCriterias[$targetPath]) ? $pathCriterias[$targetPath] : array());
                     $criteria = $this->getCriteria($map['elementType'], $customParams);
                     $criteria->id = $uniqueTargetElementIds;
                     $targetElements = $this->findElements($criteria);
                     if ($targetElements) {
                         // Success! Store those elements on $elementsByPath FFR
                         $elementsByPath[$targetPath] = $targetElements;
                         // Index the target elements by their IDs if we are using the map-defined order
                         if (!$useCustomOrder) {
                             $targetElementsById = array();
                             foreach ($targetElements as $targetElement) {
                                 $targetElementsById[$targetElement->id] = $targetElement;
                             }
                         }
                     }
                 }
                 // Tell the source elements about their eager-loaded elements (or lack thereof, as the case may be)
                 foreach ($elementsByPath[$sourcePath] as $sourceElement) {
                     $sourceElementId = $sourceElement->id;
                     $targetElementsForSource = array();
                     if (isset($targetElementIdsBySourceIds[$sourceElementId])) {
                         if ($useCustomOrder) {
                             // Assign the elements in the order they were returned from the query
                             foreach ($targetElements as $targetElement) {
                                 if (in_array($targetElement->id, $targetElementIdsBySourceIds[$sourceElementId])) {
                                     $targetElementsForSource[] = $targetElement;
                                 }
                             }
                         } else {
                             // Assign the elements in the order defined by the map
                             foreach ($targetElementIdsBySourceIds[$sourceElementId] as $targetElementId) {
                                 if (isset($targetElementsById[$targetElementId])) {
                                     $targetElementsForSource[] = $targetElementsById[$targetElementId];
                                 }
                             }
                         }
                     }
                     $sourceElement->setEagerLoadedElements($segment, $targetElementsForSource);
                 }
             }
             if (!$elementsByPath[$targetPath]) {
                 // Dead end - stop wasting time on this path
                 break;
             }
             // Update the source path
             $sourcePath = $targetPath;
         }
     }
 }
 /**
  * Returns the HTML for an editor HUD for the given element.
  *
  * @param BaseElementModel $element
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     $linkedElements[] = craft()->entries->getEntryById($element->linkedEntryId);
     $selectElement = craft()->elements->getElementType('Entry');
     // Start/End Dates
     $html = craft()->templates->render('menus/_editor', array('element' => $element, 'linkedElements' => $linkedElements, 'selectElement' => $selectElement));
     // Everything else
     $html .= parent::getEditorHtml($element);
     return $html;
 }
 /**
  * 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 'email':
             $email = $element->email;
             if ($email) {
                 return '<a href="mailto:' . $email . '">' . $email . '</a>';
             } else {
                 return '';
             }
         case 'lastLoginDate':
             $date = $element->{$attribute};
             if ($date) {
                 return $date->localeDate();
             } else {
                 return '';
             }
         default:
             return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 /**
  * Get 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('getTaskManagerTableAttributeHtml', array($element, $attribute), true);
     if ($pluginAttributeHtml !== null) {
         return $pluginAttributeHtml;
     }
     // Or format default
     return parent::getTableAttributeHtml($element, $attribute);
 }
 /**
  * Set sortable attributes.
  *
  * @return array
  */
 public function defineSortableAttributes()
 {
     // Set modified first
     $attributes = array('dateUpdated' => Craft::t('Modified'));
     // Get table attributes
     $attributes = array_merge($attributes, parent::defineSortableAttributes());
     // Unset unsortable attributes
     unset($attributes['user'], $attributes['changes']);
     // Allow plugins to modify the attributes
     craft()->plugins->call('modifyAuditLogSortableAttributes', array(&$attributes));
     // Return attributes
     return $attributes;
 }
 /**
  * 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 'body':
             return strlen($element->{$attribute}) > 50 ? substr($element->{$attribute}, 0, 50) . '...' : $element->{$attribute};
             break;
         case 'command':
             $app = $element->getApp();
             foreach ($app->commands as $command) {
                 if ($command['param'] == $element->{$attribute}) {
                     return $command['name'];
                 }
             }
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
 /**
  * @inheritDoc IElementType::getEditorHtml()
  *
  * @param BaseElementModel $element
  *
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     $html = craft()->templates->render('users/_accountfields', array('account' => $element, 'isNewAccount' => false));
     $html .= parent::getEditorHtml($element);
     return $html;
 }
    /**
     * @inheritDoc IElementType::getEditorHtml()
     *
     * @param BaseElementModel $element
     *
     * @return string
     */
    public function getEditorHtml(BaseElementModel $element)
    {
        $html = '';
        // Show the Entry Type field?
        if (!$element->id) {
            $entryTypes = $element->getSection()->getEntryTypes();
            if (count($entryTypes) > 1) {
                $entryTypeOptions = array();
                foreach ($entryTypes as $entryType) {
                    $entryTypeOptions[] = array('label' => Craft::t($entryType->name), 'value' => Craft::t($entryType->id));
                }
                $html .= craft()->templates->renderMacro('_includes/forms', 'selectField', array(array('label' => Craft::t('Entry Type'), 'id' => 'entryType', 'value' => $element->typeId, 'options' => $entryTypeOptions)));
                $typeInputId = craft()->templates->namespaceInputId('entryType');
                $js = <<<EOD
\$('#{$typeInputId}').on('change', function(ev) {
\tvar \$typeInput = \$(this),
\t\teditor = \$typeInput.closest('.hud').data('elementEditor');
\tif (editor) {
\t\teditor.setElementAttribute('typeId', \$typeInput.val());
\t\teditor.loadHud();
\t}
});
EOD;
                craft()->templates->includeJs($js);
            }
        }
        if ($element->getType()->hasTitleField) {
            $html .= craft()->templates->render('entries/_titlefield', array('entry' => $element));
        }
        $html .= parent::getEditorHtml($element);
        return $html;
    }
 /**
  * Returns elements based on a given query.
  *
  * @access private
  * @param BaseElementType $elementType
  * @param DbCommand       $subquery
  * @param bool            $ordered
  * @return array
  */
 private function _getElementsFromQuery(BaseElementType $elementType, DbCommand $subquery, $ordered = false)
 {
     if ($ordered) {
         $subquery->addSelect('relations.sortOrder');
     }
     // Only get the unique elements (no locale duplicates)
     $query = craft()->db->createCommand()->select('*')->from('(' . $subquery->getText() . ') AS ' . craft()->db->quoteTableName('r'))->group('r.id');
     $query->params = $subquery->params;
     if ($ordered) {
         $query->order('sortOrder');
     }
     $result = $query->queryAll();
     $elements = array();
     foreach ($result as $row) {
         // The locale column might be null since the element_i18n table was left-joined into the query,
         // In that case it should be removed from the $row array so that the default value can be used.
         if (!$row['locale']) {
             unset($row['locale']);
         }
         $elements[] = $elementType->populateElementModel($row);
     }
     return $elements;
 }
 /**
  * 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 'title':
             return $element->{$attribute};
         case 'metaPath':
             return $element->{$attribute};
         default:
             return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 /**
  * Returns the HTML for an editor HUD for the given element.
  *
  * @param BaseElementModel $element
  *
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     $methodOptions = sproutSeo()->redirects->getMethods();
     // get template
     $html = craft()->templates->render('sproutseo/redirect/_editor', array('redirect' => $element, 'methodOptions' => $methodOptions));
     // Everything else
     $html .= parent::getEditorHtml($element);
     return $html;
 }
 /**
  * @inheritDoc IElementType::getTableAttributeHtml()
  *
  * @param BaseElementModel $element
  * @param string           $attribute
  *
  * @return string
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'notes':
             $notes = craft()->db->createCommand()->select('COUNT(*)')->from('amforms_notes')->where('submissionId=:submissionId', array(':submissionId' => $element->id))->queryScalar();
             return sprintf('<a href="%s">%d</a>', $element->getCpEditUrl() . '/notes', $notes);
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
 /**
  * @inheritDoc IElementType::getEagerLoadingMap()
  *
  * @param BaseElementModel[]  $sourceElements
  * @param string $handle
  *
  * @return array|false
  */
 public function getEagerLoadingMap($sourceElements, $handle)
 {
     // $handle *must* be set as "blockTypeHandle:fieldHandle" so we know _which_ myRelationalField to resolve to
     $handleParts = explode(':', $handle);
     if (count($handleParts) != 2) {
         return false;
     }
     list($blockTypeHandle, $fieldHandle) = $handleParts;
     // Get the block type
     $matrixFieldId = $sourceElements[0]->fieldId;
     $blockTypes = craft()->matrix->getBlockTypesByFieldId($matrixFieldId, 'handle');
     if (!isset($blockTypes[$blockTypeHandle])) {
         // Not a valid block type handle (assuming all $sourceElements are blocks from the same Matrix field)
         return false;
     }
     $blockType = $blockTypes[$blockTypeHandle];
     // Set the field context
     $contentService = craft()->content;
     $originalFieldContext = $contentService->fieldContext;
     $contentService->fieldContext = 'matrixBlockType:' . $blockType->id;
     $map = parent::getEagerLoadingMap($sourceElements, $fieldHandle);
     $contentService->fieldContext = $originalFieldContext;
     return $map;
 }
Beispiel #25
0
 /**
  * @inheritDoc IElementType::saveElement()
  *
  * @param BaseElementModel $element
  * @param array            $params
  *
  * @return bool
  */
 public function saveElement(BaseElementModel $element, $params)
 {
     // Is the filename changing?
     if (!empty($params['filename']) && $params['filename'] != $element->filename) {
         // Validate the content before we do anything drastic
         if (!craft()->content->validateContent($element)) {
             return false;
         }
         $oldFilename = $element->filename;
         $newFilename = $params['filename'];
         // Rename the file
         $response = craft()->assets->renameFile($element, $newFilename);
         // Did it work?
         if ($response->isConflict()) {
             $element->addError('filename', $response->getDataItem('prompt')->message);
             return false;
         }
         if ($response->isError()) {
             $element->addError('filename', $response->errorMessage);
             return false;
         }
     } else {
         $newFilename = null;
     }
     $success = parent::saveElement($element, $params);
     if (!$success && $newFilename) {
         // Better rename it back
         craft()->assets->renameFile($element, $oldFilename);
     }
     return $success;
 }
 public function getEagerLoadingMap($sourceElements, $handle)
 {
     $superTableFieldId = $sourceElements[0]->fieldId;
     $blockTypes = craft()->superTable->getBlockTypesByFieldId($superTableFieldId);
     if (!isset($blockTypes[0])) {
         return false;
     }
     $blockType = $blockTypes[0];
     // Set the field context
     $contentService = craft()->content;
     $originalFieldContext = $contentService->fieldContext;
     $contentService->fieldContext = 'superTableBlockType:' . $blockType->id;
     $map = parent::getEagerLoadingMap($sourceElements, $handle);
     $contentService->fieldContext = $originalFieldContext;
     return $map;
 }
 /**
  * @inheritDoc IElementType::getTableAttributeHtml()
  *
  * @param BaseElementModel $element
  * @param string           $attribute
  *
  * @return string
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'handle':
             return '<code>' . $element->handle . '</code>';
             break;
         case 'numberOfFields':
             $totalFields = craft()->db->createCommand()->select('COUNT(*)')->from('fieldlayoutfields')->where('layoutId=:layoutId', array(':layoutId' => $element->fieldLayoutId))->queryScalar();
             return $totalFields;
             break;
         case 'totalSubmissions':
             $totalSubmissions = craft()->db->createCommand()->select('COUNT(*)')->from('amforms_submissions')->where('formId=:formId', array(':formId' => $element->id))->queryScalar();
             return $totalSubmissions;
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
 /**
  * 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 'platform':
             switch ($element->{$attribute}) {
                 case PushNotifications_AppModel::PLATFORM_IOS:
                     return Craft::t('iOS');
                     break;
                 case PushNotifications_AppModel::PLATFORM_ANDROID:
                     return Craft::t('Android');
                     break;
             }
             break;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
             break;
     }
 }
 /**
  * Returns the HTML for an editor HUD for the given element.
  *
  * @param BaseElementModel $element
  * @return string
  */
 public function getEditorHtml(BaseElementModel $element)
 {
     // Start/End Dates
     $html = craft()->templates->render('events/_edit', array('element' => $element));
     // Everything else
     $html .= parent::getEditorHtml($element);
     return $html;
 }
 /**
  * @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('Title'), 'locale' => $element->locale, 'id' => 'title', 'name' => 'title', 'value' => $element->getContent()->title, 'errors' => $element->getErrors('title'), 'first' => true, 'autofocus' => true, 'required' => true)));
     $html .= craft()->templates->renderMacro('_includes/forms', 'textField', array(array('label' => Craft::t('Slug'), 'locale' => $element->locale, 'id' => 'slug', 'name' => 'slug', 'value' => $element->slug, 'errors' => $element->getErrors('slug'), 'required' => true)));
     $html .= parent::getEditorHtml($element);
     return $html;
 }