/** * @see Document_Tag_Interface::frontend */ public function frontend() { $count = 0; $this->start(); $options = $this->getOptions(); foreach ($this->indices as $index) { $this->current = $count; // don't show disabled bricks if (!Pimcore_ExtensionManager::isEnabled("brick", $index["type"]) && $options['dontCheckEnabled'] != true) { $count++; continue; } if ($count > 0) { $this->blockEnd(); } // create info object and assign it to the view $info = null; try { $info = new Document_Tag_Area_Info(); $info->setId($index["type"]); $info->setIndex($count); $info->setPath(str_replace(PIMCORE_DOCUMENT_ROOT, "", Pimcore_ExtensionManager::getPathForExtension($index["type"], "brick"))); $info->setConfig(Pimcore_ExtensionManager::getBrickConfig($index["type"])); } catch (Exception $e) { $info = null; } $this->blockStart(); if ($this->getView() instanceof Zend_View) { $this->getView()->brick = $info; $areas = $this->getAreaDirs(); $view = $areas[$index["type"]] . "/view.php"; $action = $areas[$index["type"]] . "/action.php"; $edit = $areas[$index["type"]] . "/edit.php"; $options = $this->getOptions(); $params = array(); if (is_array($options["params"]) && array_key_exists($index["type"], $options["params"])) { if (is_array($options["params"][$index["type"]])) { $params = $options["params"][$index["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; $actionClassname = "Document_Tag_Area_" . ucfirst($index["type"]); if (class_exists($actionClassname)) { $actionObj = new $actionClassname(); if ($actionObj instanceof Document_Tag_Area_Abstract) { $actionObj->setView($this->getView()); $areaConfig = new Zend_Config_Xml($areas[$index["type"]] . "/area.xml"); $actionObj->setConfig($areaConfig); // params $params = array_merge($this->view->getAllParams(), $params); $actionObj->setParams($params); if ($info) { $actionObj->setBrick($info); } if (method_exists($actionObj, "action")) { $actionObj->action(); } } } } if (is_file($view)) { $editmode = $this->getView()->editmode; echo '<div class="pimcore_area_' . $index["type"] . ' pimcore_area_content">'; if (is_file($edit) && $editmode) { echo '<div class="pimcore_area_edit_button"></div>'; $this->getView()->editmode = false; } $this->getView()->template($view); if (is_file($edit) && $editmode) { $this->getView()->editmode = true; echo '<div class="pimcore_area_editmode">'; $this->getView()->template($edit); echo '</div>'; } echo '</div>'; } } $count++; } if (count($this->indices) > 0) { $this->blockEnd(); } $this->end(); }
/** * @param array $options * @return void */ public function setOptions($options) { // read available types $areaConfigs = $this->getBrickConfigs(); $availableAreas = array(); $availableAreasSort = array(); if (!is_array($options["allowed"])) { $options["allowed"] = array(); } foreach ($areaConfigs as $areaName => $areaConfig) { // don't show disabled bricks if (!$options['dontCheckEnabled']) { if (!Pimcore_ExtensionManager::isEnabled("brick", $areaName)) { continue; } } if (empty($options["allowed"]) || in_array($areaName, $options["allowed"])) { $n = (string) $areaConfig->name; $d = (string) $areaConfig->description; $icon = (string) $areaConfig->icon; if (empty($icon)) { $path = Pimcore_ExtensionManager::getPathForExtension($areaName, "brick"); $iconPath = $path . "/icon.png"; if (file_exists($iconPath)) { $icon = str_replace(PIMCORE_DOCUMENT_ROOT, "", $iconPath); } } if ($this->view) { $n = $this->view->translateAdmin((string) $areaConfig->name); $d = $this->view->translateAdmin((string) $areaConfig->description); } $availableAreas[] = array("name" => $n, "description" => $d, "type" => $areaName, "icon" => $icon); } } // sort with translated names usort($availableAreas, function ($a, $b) { if ($a["name"] == $b["name"]) { return 0; } return $a["name"] < $b["name"] ? -1 : 1; }); $options["types"] = $availableAreas; if (is_array($options["group"])) { $groupingareas = array(); foreach ($availableAreas as $area) { $groupingareas[$area["type"]] = $area["type"]; } $groups = array(); foreach ($options["group"] as $name => $areas) { $n = $name; if ($this->view) { $n = $this->view->translateAdmin($name); } $groups[$n] = $areas; foreach ($areas as $area) { unset($groupingareas[$area]); } } if (count($groupingareas) > 0) { $uncatAreas = array(); foreach ($groupingareas as $area) { $uncatAreas[] = $area; } $n = "uncategorized"; if ($this->view) { $n = $this->view->translateAdmin($n); } $groups[$n] = $uncatAreas; } $options["group"] = $groups; } if (empty($options["limit"])) { $options["limit"] = 1000000; } $this->options = $options; }
public function startUploadAction() { $client = Pimcore_Tool::getHttpClient(); $client->setParameterPost("data", base64_encode(Pimcore_Tool_Serialize::serialize(array("id" => $this->_getParam("id"), "type" => $this->_getParam("type"), "token" => Pimcore_Liveconnect::getToken())))); $client->setUri("http://extensions.pimcore.org/share/startUpload.php"); $response = $client->request(Zend_Http_Client::POST); // call share.php inside the extension $extensionDir = Pimcore_ExtensionManager::getPathForExtension($this->_getParam("id"), $this->_getParam("type")); $shareScript = $extensionDir . "/share.php"; if (is_file($shareScript)) { include $shareScript; } $this->_helper->json(array("success" => true)); }