Inheritance: extends Pimcore\Model\AbstractModel, implements Pimcore\Model\Document\Tag\TagInterface
示例#1
0
 /**
  * @param $type
  * @param $realName
  * @param array $options
  * @return Model\Document\Tag
  */
 public function tag($type, $realName, $options = array())
 {
     $type = strtolower($type);
     $document = $this->document;
     $name = Model\Document\Tag::buildTagName($type, $realName, $document);
     try {
         if ($document instanceof Model\Document\PageSnippet) {
             $tag = $document->getElement($name);
             if ($tag instanceof Model\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 = Model\Document\Tag::factory($type, $name, $document->getId(), $options, $this->controller, $this, $this->editmode);
                 $document->setElement($name, $tag);
             }
             // set the real name of this editable, without the prefixes and suffixes from blocks and areablocks
             $tag->setRealName($realName);
         }
         return $tag;
     } catch (\Exception $e) {
         \Logger::warning($e);
     }
 }
示例#2
0
 /**
  * @see Document\Tag\TagInterface::admin
  * @return string
  */
 public function admin()
 {
     $html = parent::admin();
     // get frontendcode for preview
     // put the video code inside the generic code
     $html = str_replace("</div>", $this->frontend() . "</div>", $html);
     return $html;
 }
 /**
  * @param $object
  * @param bool $disableMappingExceptions
  * @param null $idMapper
  * @throws \Exception
  */
 public function reverseMap($object, $disableMappingExceptions = false, $idMapper = null)
 {
     parent::reverseMap($object, $disableMappingExceptions, $idMapper);
     $object->childs = null;
     $object->elements = array();
     if (is_array($this->elements)) {
         foreach ($this->elements as $element) {
             $tag = Model\Document\Tag::factory($element->type, $element->name, $this->id);
             $tag->getFromWebserviceImport($element, $idMapper);
             $object->elements[$element->name] = $tag;
         }
     }
 }
示例#4
0
 public function getEditmode()
 {
     return parent::getEditmode();
     // TODO: Change the autogenerated stub
 }
示例#5
0
 /**
  * @return array
  */
 public function __sleep()
 {
     $finalVars = array();
     $parentVars = parent::__sleep();
     $blockedVars = array("o");
     foreach ($parentVars as $key) {
         if (!in_array($key, $blockedVars)) {
             $finalVars[] = $key;
         }
     }
     return $finalVars;
 }
示例#6
0
 /**
  * Returns the current tag's data for web service export
  *
  * @abstract
  * @return array
  */
 public function getForWebserviceExport()
 {
     $el = parent::getForWebserviceExport();
     if ($this->data["internal"]) {
         if (intval($this->data["internalId"]) > 0) {
             if ($this->data["internalType"] == "document") {
                 $referencedDocument = Document::getById($this->data["internalId"]);
                 if (!$referencedDocument instanceof Document) {
                     //detected broken link
                     $document = Document::getById($this->getDocumentId());
                 }
             } elseif ($this->data["internalType"] == "asset") {
                 $referencedAsset = Asset::getById($this->data["internalId"]);
                 if (!$referencedAsset instanceof Asset) {
                     //detected broken link
                     $document = Document::getById($this->getDocumentId());
                 }
             }
         }
     }
     $el->data = $this->data;
     return $el;
 }