public function loadAudioTagsCms($nothing, $nothing, Node $node) { if ($node->getNodePartials()->getOutPartials() != "") { $tagDefs = $node->getNodeRef()->getElement()->Schema->getTagDefs(); foreach ($tagDefs as $k => $tagDef) { if ($tagDef->Partial->TagAspect == 'audio') { $node->getNodePartials()->increaseOutPartials('#' . $tagDef->Partial->TagRole . '.#original.#url'); } } } }
public function loadMediaTagsOriginalsCms($nothing, $nothing, Node $node) { return; if ($node->getNodePartials()->getOutPartials() != "") { $tagDefs = $node->getNodeRef()->getElement()->Schema->getTagDefs(); foreach ($tagDefs as $k => $tagDef) { if ($tagDef->Partial->TagAspect == 'media') { $node->getNodePartials()->increaseOutPartials('#' . $tagDef->Partial->TagRole . '.#original.#url,#' . $tagDef->Partial->TagRole . '.#original.#height,#' . $tagDef->Partial->TagRole . '.#original.#width'); } } } }
public function loadImageTagsThumbnailsCms($nothing, $nothing, Node $node) { return; if ($node->getNodePartials()->getOutPartials() != "") { $tagDefs = $node->getNodeRef()->getElement()->Schema->getTagDefs(); foreach ($tagDefs as $k => $tagDef) { if ($tagDef->Partial->TagAspect == 'images') { $node->getNodePartials()->increaseOutPartials('#' . $tagDef->Partial->TagRole . '.#thumbnails.#url,#' . $tagDef->Partial->TagRole . '.#thumbnails.#width,#' . $tagDef->Partial->TagRole . '.#thumbnails.#height'); } } } }
public function requirePrimaryImage(Errors &$errors, NodeRef $nodeRef, Node &$node) { $element = $nodeRef->getElement(); $schema = $element->getSchema(); if (!PartialUtils::isTagRoleInOutTagsScope($schema, $node->getNodePartials(), '#primary-image')) { // this should only occur during bulk cms actions return; } if ($schema->hasTagDef('#primary-image')) { $primaryImageTag = $node->getOutTag('#primary-image'); $errors->rejectIfEmpty('#primary-image', 'tag', 'Primary Image', $primaryImageTag); } }
protected function editInternal(Node $node) { $existingNode = $this->NodeLookupDAO->getByNodeRef($node->getNodeRef()); $this->Logger->debug('Editing node [' . $node->getNodeRef() . '] with partials [' . $node->getNodePartials() . ']'); // update the record $primaryKey = $this->NodeDBMeta->getPrimaryKey($node->getNodeRef()); $id = $existingNode->getID(); $node->{$primaryKey} = $id; $node->ID = $id; $db = $this->getConnectionForWrite($node->getNodeRef()); $oldArray = $this->NodeMapper->nodeToPersistentArray($existingNode); $newArray = $this->NodeMapper->nodeToPersistentArray($node); // save meta $changedMeta = $this->NodeMetaDAO->saveMeta($db, $node->getNodeRef(), $id, $node->getNodePartials()->getMetaPartials(), $node->getMetas(), $node->getNodePartials()->getRestrictedMetaPartials()); // save the tags $changedOut = $this->NodeTagsDAO->saveOutTags($db, $node->getNodeRef(), $id, $node->getNodePartials()->getOutPartials(), $node->getOutTags(), $node->getNodePartials()->getRestrictedOutPartials()); $changedIn = $this->NodeTagsDAO->saveInTags($db, $node->getNodeRef(), $id, $node->getNodePartials()->getInPartials(), $node->getInTags(), $node->getNodePartials()->getRestrictedInPartials()); if (array_intersect_key($oldArray, $newArray) != $newArray) { $newArray['ModifiedDate'] = $this->DateFactory->newStorageDate(); $node->ModifiedDate = $newArray['ModifiedDate']; $db->updateRecord($db->quoteIdentifier($this->NodeDBMeta->getTableName($node->getNodeRef())), $newArray, "{$primaryKey} = {$db->quote($id)}"); } }
protected function validateMetas(Node $node, Node $obj, NodeSchema $schema, $mode) { $processed_metas = array(); $metas = $obj->getMetas(); // Check all metas passed against the meta defs. foreach ($metas as $meta) { // Ensure the meta has a meta_def $meta_def = $schema->getMetaDef($meta->getMetaName()); $this->getErrors()->rejectIfInvalid($this->resolveField($node->getNodeRef(), $meta->getMetaName(), $obj instanceof Section ? $obj : null), 'meta', $meta_def->Title, $meta->getValue(), $meta_def->Validation); $processed_metas[] = $meta->getMetaName(); } $meta_defs = $schema->getMetaDefs(); // Check all meta defs that haven't been processed // These meta defs must only match partials that we have. $meta_partials = PartialUtils::unserializeMetaPartials($node->getNodePartials()->getMetaPartials()); $re_meta_partials = PartialUtils::unserializeMetaPartials($node->getNodePartials()->getRestrictedMetaPartials()); foreach ($meta_defs as $meta_def) { if (in_array($meta_def->Id, $processed_metas)) { continue; } if ($mode == 'edit' && !$this->metaInScope($schema, new Meta($meta_def->Id, ''), $meta_partials, $re_meta_partials)) { continue; } // Validate the meta def with a null value $this->getErrors()->rejectIfInvalid($this->resolveField($node->getNodeRef(), $meta_def->Id, $obj instanceof Section ? $obj : null), 'meta', $meta_def->Title, null, $meta_def->Validation); $processed_metas[] = $meta_def->Id; } }
protected function fireBindEvents($action, Node &$node, Errors &$errors, array $fields, array $rawFields) { if (isset($fields['OutTags_partials'])) { foreach (StringUtils::smartSplit($fields['OutTags_partials'], ',', '"', '\\"') as $partial) { $node->getNodePartials()->increaseOutPartials($partial); } } if (isset($fields['InTags_partials'])) { foreach (StringUtils::smartSplit($fields['InTags_partials'], ',', '"', '\\"') as $partial) { $node->getNodePartials()->increaseInPartials($partial); } } foreach ((array) $node->getNodeRef()->getElement()->getAspects() as $aspect) { $this->Events->trigger('Node.@' . $aspect->Slug . '.bind', $action, $node, $errors, $fields, $rawFields); $schema = $aspect->getSchema(); foreach ($schema->getMetaDefs() as $metaDef) { $bound = $this->Events->trigger('Node.@' . $aspect->Slug . '.meta.#' . $metaDef->Id . '.bind', $action, $node, $errors, $fields, $rawFields); if (!$bound) { $this->bindMeta($node, $errors, $fields, $rawFields, $metaDef->Id); } } foreach ($schema->getTagDefs() as $tagDef) { if ($tagDef->Direction == 'in') { $bound = $this->Events->trigger('Node.@' . $aspect->Slug . '.intags.#' . $tagDef->Id . '.bind', $action, $node, $errors, $fields, $rawFields); if (!$bound && $tagDef->isFieldlike()) { $this->bindInTags($node, $errors, $fields, $rawFields, $tagDef->Id); } } else { $bound = $this->Events->trigger('Node.@' . $aspect->Slug . '.outtags.#' . $tagDef->Id . '.bind', $action, $node, $errors, $fields, $rawFields); if (!$bound && $tagDef->isFieldlike()) { $this->bindOutTags($node, $errors, $fields, $rawFields, $tagDef->Id); } } } } $errors->throwOnError(); }