public function reverseMap($object)
 {
     parent::reverseMap($object);
     $object->childs = null;
     $object->elements = array();
     if (is_array($this->elements)) {
         foreach ($this->elements as $element) {
             $tag = Document_Tag::factory($element->type, $element->name, $this->id);
             $tag->getFromWebserviceImport($element);
             $object->elements[$element->name] = $tag;
         }
     }
 }
Example #2
0
 /**
  * @param $type
  * @param $name
  * @param array $options
  * @return Tag
  */
 public function tag($type, $name, $options = array())
 {
     $type = strtolower($type);
     try {
         // @todo add document-id to registry key | for example for embeded snippets
         // set suffixes if the tag is inside a block
         try {
             $blocks = Zend_Registry::get("pimcore_tag_block_current");
             $numeration = Zend_Registry::get("pimcore_tag_block_numeration");
             if (is_array($blocks) and count($blocks) > 0) {
                 if ($type == "block") {
                     $tmpBlocks = $blocks;
                     $tmpNumeration = $numeration;
                     array_pop($tmpBlocks);
                     array_pop($tmpNumeration);
                     $tmpName = $name;
                     if (is_array($tmpBlocks)) {
                         $tmpName = $name . implode("_", $tmpBlocks) . implode("_", $tmpNumeration);
                     }
                     if ($blocks[count($blocks) - 1] == $tmpName) {
                         array_pop($blocks);
                         array_pop($numeration);
                     }
                 }
                 $name = $name . implode("_", $blocks) . implode("_", $numeration);
             }
         } catch (Exception $e) {
         }
         $document = $this->document;
         if ($document instanceof Document) {
             $tag = $document->getElement($name);
             if ($tag instanceof Document_Tag && $tag->getType() == $type) {
                 // call the load() method if it exists to reinitialize the data (eg. from serializing, ...)
                 if (method_exists($tag, "load")) {
                     $tag->load();
                 }
                 // set view & controller, editmode
                 $tag->setController($this->controller);
                 $tag->setView($this);
                 $tag->setEditmode($this->editmode);
                 $tag->setOptions($options);
             } else {
                 $tag = Document_Tag::factory($type, $name, $document->getId(), $options, $this->controller, $this, $this->editmode);
                 $document->setElement($name, $tag);
             }
         }
         return $tag;
     } catch (Exception $e) {
         Logger::warning($e);
     }
 }
Example #3
0
 /**
  * @return bool
  */
 public function sanityCheck()
 {
     $sane = true;
     if ($this->data["internal"]) {
         if ($this->data["internalType"] == "document") {
             $doc = Document::getById($this->data["internalId"]);
             if (!$doc) {
                 $sane = false;
                 Logger::notice("Detected insane relation, removing reference to non existent document with id [" . $this->getDocumentId() . "]");
                 $new = Document_Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                 $this->data = $new->getData();
             }
         } else {
             if ($this->data["internalType"] == "asset") {
                 $asset = Asset::getById($this->data["internalId"]);
                 if (!$asset) {
                     $sane = false;
                     Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->getDocumentId() . "]");
                     $new = Document_Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                     $this->data = $new->getData();
                 }
             }
         }
     }
     return $sane;
 }