/** * Get entry attributes. * * @param array $map * @param BaseElementModel $element * * @return array */ public function getAttributes(array $map, BaseElementModel $element) { $attributes = array(); // Try to parse checked fields through prepValue foreach ($map as $handle => $data) { if ($data['checked'] && !strstr($handle, ExportModel::HandleTitle)) { try { $attributes[$handle] = $element->{$handle}; } catch (\Exception $e) { $attributes[$handle] = null; } } } // Title placeholder for all element types foreach (craft()->sections->getEntryTypesBySectionId($element->sectionId) as $entrytype) { // Set title $attributes[ExportModel::HandleTitle . '_' . $entrytype->id] = $entrytype->id == $element->typeId ? $element->{ExportModel::HandleTitle} : ''; } // Get parent for structures if (array_key_exists(ExportModel::HandleParent, $map)) { $attributes[ExportModel::HandleParent] = $element->getAncestors() ? $element->getAncestors(1)->first() : ''; } // Get ancestors for structures if (array_key_exists(ExportModel::HandleAncestors, $map)) { $attributes[ExportModel::HandleAncestors] = $element->getAncestors() ? implode('/', $element->getAncestors()->find()) : ''; } // Call hook allowing 3rd-party plugins to modify attributes craft()->plugins->call('modifyExportAttributes', array(&$attributes, $element)); return $attributes; }
/** * Returns the block's ancestors. * * @param int|null $dist * @return ElementCriteriaModel */ public function getAncestors($dist = null) { // If the request is in Live Preview mode, use the Neo-extended criteria model, which supports Live Preview mode if (craft()->neo->isPreviewMode()) { if (!isset($this->_liveCriteria['ancestors'])) { $criteria = craft()->neo->getCriteria(); $criteria->setAllElements($this->_allElements); $criteria->ancestorOf = $this; $this->_liveCriteria['ancestors'] = $criteria; } if ($dist) { return $this->_liveCriteria['ancestors']->ancestorDist($dist); } return $this->_liveCriteria['ancestors']; } return parent::getAncestors($dist); }
/** * Get category attributes. * * @param array $map * @param BaseElementModel $element * * @return array */ public function getAttributes(array $map, BaseElementModel $element) { $attributes = array(); // Try to parse checked fields through prepValue foreach ($map as $handle => $data) { if ($data['checked']) { try { $attributes[$handle] = $element->{$handle}; } catch (\Exception $e) { $attributes[$handle] = null; } } } // Get parent for categories if (array_key_exists(ExportModel::HandleParent, $map)) { $attributes[ExportModel::HandleParent] = $element->getAncestors() ? $element->getAncestors(1)->first() : ''; } // Get ancestors for categories if (array_key_exists(ExportModel::HandleAncestors, $map)) { $attributes[ExportModel::HandleAncestors] = $element->getAncestors() ? implode('/', $element->getAncestors()->find()) : ''; } // Call hook allowing 3rd-party plugins to modify attributes craft()->plugins->call('modifyExportAttributes', array(&$attributes, $element)); return $attributes; }
/** * Get category attributes. * * @param array $map * @param BaseElementModel $element * * @return array */ public function getAttributes(array $map, BaseElementModel $element) { $attributes = array(); // Try to parse checked fields through prepValue foreach ($map as $handle => $data) { if ($data['checked']) { $attributes[$handle] = $element->{$handle}; } } // Get parent for categories if (array_key_exists(ExportModel::HandleParent, $map)) { if ($element->getAncestors()) { $attributes[ExportModel::HandleParent] = $element->getAncestors(1)->first(); } } // Get ancestors for categories if (array_key_exists(ExportModel::HandleAncestors, $map)) { if ($element->getAncestors()) { $attributes[ExportModel::HandleAncestors] = implode('/', $element->getAncestors()->find()); } } return $attributes; }