예제 #1
0
파일: Areablock.php 프로젝트: sfie/pimcore
 /**
  *
  */
 public function content()
 {
     // create info object and assign it to the view
     $info = new Area\Info();
     try {
         $info->setTag($this);
         $info->setName($this->getName());
         $info->setId($this->currentIndex["type"]);
         $info->setIndex($this->current);
         $info->setPath(str_replace(PIMCORE_DOCUMENT_ROOT, "", $this->getPathForBrick($this->currentIndex["type"])));
         $info->setConfig($this->getBrickConfig($this->currentIndex["type"]));
     } catch (\Exception $e) {
         \Logger::err($e);
     }
     if ($this->getView() instanceof \Zend_View) {
         $this->getView()->brick = $info;
         $areas = $this->getAreaDirs();
         $view = $areas[$this->currentIndex["type"]] . "/view.php";
         $action = $areas[$this->currentIndex["type"]] . "/action.php";
         $edit = $areas[$this->currentIndex["type"]] . "/edit.php";
         $options = $this->getOptions();
         $params = array();
         if (is_array($options["params"]) && array_key_exists($this->currentIndex["type"], $options["params"])) {
             if (is_array($options["params"][$this->currentIndex["type"]])) {
                 $params = $options["params"][$this->currentIndex["type"]];
             }
         }
         // assign parameters to view
         foreach ($params as $key => $value) {
             $this->getView()->assign($key, $value);
         }
         // check for action file
         if (is_file($action)) {
             include_once $action;
             $actionClassFound = true;
             $actionClassname = "\\Pimcore\\Model\\Document\\Tag\\Area\\" . ucfirst($this->currentIndex["type"]);
             if (!class_exists($actionClassname, false)) {
                 // also check the legacy prefixed class name, as this is used by some plugins
                 $actionClassname = "\\Document_Tag_Area_" . ucfirst($this->currentIndex["type"]);
                 if (!class_exists($actionClassname, false)) {
                     $actionClassFound = false;
                 }
             }
             if ($actionClassFound) {
                 $actionObject = new $actionClassname();
                 if ($actionObject instanceof Area\AbstractArea) {
                     $actionObject->setView($this->getView());
                     $areaConfig = new \Zend_Config_Xml($areas[$this->currentIndex["type"]] . "/area.xml");
                     $actionObject->setConfig($areaConfig);
                     // params
                     $params = array_merge($this->view->getAllParams(), $params);
                     $actionObject->setParams($params);
                     if ($info) {
                         $actionObject->setBrick($info);
                     }
                     if (method_exists($actionObject, "action")) {
                         $actionObject->action();
                     }
                     $this->getView()->assign('actionObject', $actionObject);
                 }
             } else {
                 $this->getView()->assign('actionObject', null);
             }
         }
         if (is_file($view)) {
             $editmode = $this->getView()->editmode;
             if (method_exists($actionObject, "getBrickHtmlTagOpen")) {
                 echo $actionObject->getBrickHtmlTagOpen($this);
             } else {
                 $dataComponentAttribute = "";
                 if (\Pimcore\View::addComponentIds()) {
                     $dataComponentId = 'document:' . $this->getDocumentId() . '.type:tag-areablock.name:' . $this->getName() . "--" . ($this->getCurrentIndex() ? $this->getCurrentIndex() : "0") . "--" . $this->currentIndex["type"];
                     $crc = \Pimcore\Tool\Frontend::getCurrentRequestUrlCrc32();
                     if ($crc) {
                         $dataComponentId = "uri:" . $crc . "." . $dataComponentId;
                     }
                     $dataComponentAttribute = 'data-component-id="' . $dataComponentId . '"';
                 }
                 echo '<div class="pimcore_area_' . $this->currentIndex["type"] . ' pimcore_area_content" ' . $dataComponentAttribute . '>';
             }
             if (is_file($edit) && $editmode) {
                 echo '<div class="pimcore_area_edit_button_' . $this->getName() . ' pimcore_area_edit_button"></div>';
                 // forces the editmode in view.php independent if there's an edit.php or not
                 if (!array_key_exists("forceEditInView", $params) || !$params["forceEditInView"]) {
                     $this->getView()->editmode = false;
                 }
             }
             $this->getView()->template($view);
             if (is_file($edit) && $editmode) {
                 $this->getView()->editmode = true;
                 echo '<div class="pimcore_area_editmode_' . $this->getName() . ' pimcore_area_editmode pimcore_area_editmode_hidden">';
                 $this->getView()->template($edit);
                 echo '</div>';
             }
             if (method_exists($actionObject, "getBrickHtmlTagClose")) {
                 echo $actionObject->getBrickHtmlTagClose($this);
             } else {
                 echo '</div>';
             }
             if (is_object($actionObject) && method_exists($actionObject, "postRenderAction")) {
                 $actionObject->postRenderAction();
             }
         }
     }
     $this->current++;
 }
예제 #2
0
파일: Area.php 프로젝트: pokleh/pimcore
 /**
  * @see Model\Document\Tag\TagInterface::frontend
  */
 public function frontend()
 {
     $count = 0;
     $options = $this->getOptions();
     // don't show disabled bricks
     if (!ExtensionManager::isEnabled("brick", $options["type"]) && $options['dontCheckEnabled'] != true) {
         return;
     }
     $this->setupStaticEnvironment();
     $suffixes = \Zend_Registry::get("pimcore_tag_block_current");
     $suffixes[] = $this->getName();
     \Zend_Registry::set("pimcore_tag_block_current", $suffixes);
     $this->current = $count;
     // create info object and assign it to the view
     $info = null;
     try {
         $info = new Area\Info();
         $info->setTag($this);
         $info->setId($options["type"]);
         $info->setIndex($count);
         $info->setPath(str_replace(PIMCORE_DOCUMENT_ROOT, "", ExtensionManager::getPathForExtension($options["type"], "brick")));
         $info->setConfig(ExtensionManager::getBrickConfig($options["type"]));
     } catch (\Exception $e) {
         $info = null;
     }
     $suffixes = \Zend_Registry::get("pimcore_tag_block_numeration");
     $suffixes[] = 1;
     \Zend_Registry::set("pimcore_tag_block_numeration", $suffixes);
     if ($this->getView() instanceof \Zend_View) {
         $this->getView()->brick = $info;
         $areas = $this->getAreaDirs();
         $view = $areas[$options["type"]] . "/view.php";
         $action = $areas[$options["type"]] . "/action.php";
         $edit = $areas[$options["type"]] . "/edit.php";
         $options = $this->getOptions();
         $params = array();
         if (is_array($options["params"]) && array_key_exists($options["type"], $options["params"])) {
             if (is_array($options["params"][$options["type"]])) {
                 $params = $options["params"][$options["type"]];
             }
         }
         // assign parameters to view
         foreach ($params as $key => $value) {
             $this->getView()->assign($key, $value);
         }
         // check for action file
         if (is_file($action)) {
             include_once $action;
             $actionClassFound = true;
             $actionClassname = "\\Pimcore\\Model\\Document\\Tag\\Area\\" . ucfirst($options["type"]);
             if (!Tool::classExists($actionClassname, false)) {
                 // also check the legacy prefixed class name, as this is used by some plugins
                 $actionClassname = "\\Document_Tag_Area_" . ucfirst($options["type"]);
                 if (!Tool::classExists($actionClassname, false)) {
                     $actionClassFound = false;
                 }
             }
             if ($actionClassFound) {
                 $actionObject = new $actionClassname();
                 if ($actionObject instanceof Area\AbstractArea) {
                     $actionObject->setView($this->getView());
                     $areaConfig = new \Zend_Config_Xml($areas[$options["type"]] . "/area.xml");
                     $actionObject->setConfig($areaConfig);
                     // params
                     $params = array_merge($this->view->getAllParams(), $params);
                     $actionObject->setParams($params);
                     if ($info) {
                         $actionObject->setBrick($info);
                     }
                     if (method_exists($actionObject, "action")) {
                         $actionObject->action();
                     }
                     $this->getView()->assign('actionObject', $actionObject);
                 }
             }
         }
         if (is_file($view)) {
             $editmode = $this->getView()->editmode;
             if (method_exists($actionObject, "getBrickHtmlTagOpen")) {
                 echo $actionObject->getBrickHtmlTagOpen($this);
             } else {
                 echo '<div class="pimcore_area_' . $options["type"] . ' pimcore_area_content">';
             }
             if (is_file($edit) && $editmode) {
                 echo '<div class="pimcore_area_edit_button"></div>';
                 // forces the editmode in view.php independent if there's an edit.php or not
                 if (!array_key_exists("forceEditInView", $params) || !$params["forceEditInView"]) {
                     $this->getView()->editmode = false;
                 }
             }
             $this->getView()->template($view);
             if (is_file($edit) && $editmode) {
                 $this->getView()->editmode = true;
                 echo '<div class="pimcore_area_editmode pimcore_area_editmode_hidden">';
                 $this->getView()->template($edit);
                 echo '</div>';
             }
             if (method_exists($actionObject, "getBrickHtmlTagClose")) {
                 echo $actionObject->getBrickHtmlTagClose($this);
             } else {
                 echo '</div>';
             }
             if (is_object($actionObject) && method_exists($actionObject, "postRenderAction")) {
                 $actionObject->postRenderAction();
             }
         }
     }
     $suffixes = \Zend_Registry::get("pimcore_tag_block_numeration");
     array_pop($suffixes);
     \Zend_Registry::set("pimcore_tag_block_numeration", $suffixes);
     $suffixes = \Zend_Registry::get("pimcore_tag_block_current");
     array_pop($suffixes);
     \Zend_Registry::set("pimcore_tag_block_current", $suffixes);
 }
예제 #3
0
 /**
  *
  */
 public function content()
 {
     // create info object and assign it to the view
     $info = new Area\Info();
     try {
         $info->setTag($this);
         $info->setName($this->getName());
         $info->setId($this->currentIndex["type"]);
         $info->setIndex($this->current);
         $info->setPath(str_replace(PIMCORE_DOCUMENT_ROOT, "", $this->getPathForBrick($this->currentIndex["type"])));
         $info->setConfig($this->getBrickConfig($this->currentIndex["type"]));
     } catch (\Exception $e) {
         Logger::err($e);
     }
     if ($this->getView() instanceof \Zend_View) {
         $this->getView()->brick = $info;
         $areas = $this->getAreaDirs();
         $view = $areas[$this->currentIndex["type"]] . "/view.php";
         $action = $areas[$this->currentIndex["type"]] . "/action.php";
         $edit = $areas[$this->currentIndex["type"]] . "/edit.php";
         $options = $this->getOptions();
         $params = [];
         if (isset($options["params"]) && is_array($options["params"]) && array_key_exists($this->currentIndex["type"], $options["params"])) {
             if (is_array($options["params"][$this->currentIndex["type"]])) {
                 $params = $options["params"][$this->currentIndex["type"]];
             }
         }
         // assign parameters to view
         foreach ($params as $key => $value) {
             $this->getView()->assign($key, $value);
         }
         // check for action file
         $actionObject = null;
         if (is_file($action)) {
             include_once $action;
             $actionClassFound = true;
             $actionClass = preg_replace_callback("/[\\-_][a-z]/", function ($matches) {
                 $replacement = str_replace(["-", "_"], "", $matches[0]);
                 return strtoupper($replacement);
             }, ucfirst($this->currentIndex["type"]));
             $actionClassname = "\\Pimcore\\Model\\Document\\Tag\\Area\\" . $actionClass;
             if (!class_exists($actionClassname, false)) {
                 // also check the legacy prefixed class name, as this is used by some plugins
                 $actionClassname = "\\Document_Tag_Area_" . ucfirst($this->currentIndex["type"]);
                 if (!class_exists($actionClassname, false)) {
                     $actionClassFound = false;
                 }
             }
             if ($actionClassFound) {
                 $actionObject = new $actionClassname();
                 if ($actionObject instanceof Area\AbstractArea) {
                     $actionObject->setView($this->getView());
                     $areaConfig = new \Zend_Config_Xml($areas[$this->currentIndex["type"]] . "/area.xml");
                     $actionObject->setConfig($areaConfig);
                     // params
                     $params = array_merge($this->view->getAllParams(), $params);
                     $actionObject->setParams($params);
                     if ($info) {
                         $actionObject->setBrick($info);
                     }
                     if (method_exists($actionObject, "action")) {
                         $actionObject->action();
                     }
                     $this->getView()->assign('actionObject', $actionObject);
                 }
             } else {
                 $this->getView()->assign('actionObject', null);
             }
         }
         if (is_file($view)) {
             $editmode = $this->getView()->editmode;
             if ($actionObject && method_exists($actionObject, "getBrickHtmlTagOpen")) {
                 echo $actionObject->getBrickHtmlTagOpen($this);
             } else {
                 echo '<div class="pimcore_area_' . $this->currentIndex["type"] . ' pimcore_area_content">';
             }
             if (is_file($edit) && $editmode) {
                 echo '<div class="pimcore_area_edit_button_' . $this->getName() . ' pimcore_area_edit_button"></div>';
                 // forces the editmode in view.php independent if there's an edit.php or not
                 if (!array_key_exists("forceEditInView", $params) || !$params["forceEditInView"]) {
                     $this->getView()->editmode = false;
                 }
             }
             $this->getView()->template($view);
             if (is_file($edit) && $editmode) {
                 $this->getView()->editmode = true;
                 echo '<div class="pimcore_area_editmode_' . $this->getName() . ' pimcore_area_editmode pimcore_area_editmode_hidden">';
                 $this->getView()->template($edit);
                 echo '</div>';
             }
             if ($actionObject && method_exists($actionObject, "getBrickHtmlTagClose")) {
                 echo $actionObject->getBrickHtmlTagClose($this);
             } else {
                 echo '</div>';
             }
             if ($actionObject && method_exists($actionObject, "postRenderAction")) {
                 $actionObject->postRenderAction();
             }
         }
     }
     $this->current++;
 }