public function setField($field) { $this->field = $field; $this->__set('fieldId', $field->getId()); $this->__set('fieldName', $field->getName()); $this->__set('fieldValue', \Acd\Model\ValueFormater::encode($field->getValue(), $field->getType(), \Acd\Model\ValueFormater::FORMAT_EDITOR)); // Antes $field->getValue()); //$ref = $field->getRef(); $ref = $field->getValue(); //d($field->getValue()); if ($field->getType() === 'content' && $ref) { //d($field->getType()); $id = $field->getRef()['ref']; //d($id,$field->getValue()->get($id)->getTitle(), $field->getRef()); } //$ref = is_string($ref) ? $ref : ''; $this->__set('fieldRef', $ref); //d($ref); $this->__set('fieldStructureRef', $field->getStructureRef()); /* switch ($field->getType()) { case 'content': d($field->getValue()); $this->__set('fieldValue', $field->getValue()); break; default: $this->__set('fieldValue', $field->getValue()); break; } */ }
public function setContent($content) { $this->__set('content', $content); $this->__set('contentTitle', \Acd\Model\ValueFormater::encode($content->getTitle(), \Acd\Model\ValueFormater::TYPE_TEXT_SIMPLE, \Acd\Model\ValueFormater::FORMAT_EDITOR)); $this->__set('aliasId', \Acd\Model\ValueFormater::encode($content->getAliasId(), \Acd\Model\ValueFormater::TYPE_TEXT_SIMPLE, \Acd\Model\ValueFormater::FORMAT_EDITOR)); $this->__set('contentTags', \Acd\Model\ValueFormater::encode($content->getTags(), \Acd\Model\ValueFormater::TYPE_TAGS, \Acd\Model\ValueFormater::FORMAT_EDITOR)); }
<?php namespace Acd; require '../autoload.php'; $accion = strtolower($_POST['a']); $id = $_POST['id']; if ($accion == 'save' && $id == '') { $accion = 'new'; } $idStructure = $_POST['ids']; $title = isset($_POST['title']) ? $_POST['title'] : null; $periodOfValidity = array(\Acd\Model\ContentDo::PERIOD_OF_VALIDITY_START => isset($_POST['validityPeriod']['start']) ? $_POST['validityPeriod']['start'] : null, \Acd\Model\ContentDo::PERIOD_OF_VALIDITY_END => isset($_POST['validityPeriod']['end']) ? $_POST['validityPeriod']['end'] : null); $periodOfValidity = \Acd\Model\ValueFormater::decode($periodOfValidity, \Acd\Model\ValueFormater::TYPE_DATE_TIME_RANGE, \Acd\Model\ValueFormater::FORMAT_EDITOR); $aliasId = isset($_POST['aliasId']) ? $_POST['aliasId'] : null; $tags = isset($_POST['tags']) ? \Acd\Model\ValueFormater::decode($_POST['tags'], \Acd\Model\ValueFormater::TYPE_TAGS, \Acd\Model\ValueFormater::FORMAT_EDITOR) : array(); $fields = isset($_POST['field']) ? $_POST['field'] : array(); $contentLoader = new \ACD\Model\ContentLoader(); $contentLoader->setId($idStructure); //$contents = $contentLoader->loadContents('id', $id); $content = $contentLoader->loadContents('id', $id); //TODO Resolver mejor try { //if (is_null($contents) || $contents->length() === 0) { if (is_null($content)) { $structureFound = false; $structure = new Model\StructureDo(); $structure->setId($idStructure); $structure->loadFromFile(); $modified_content = new Model\ContentDo(); $modified_content->buildSkeleton($structure);