public function getExtensionsAction()
 {
     $configurations = array();
     // plugins
     $pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs();
     foreach ($pluginConfigs as $config) {
         $className = $config["plugin"]["pluginClassName"];
         $updateable = false;
         $revisionFile = PIMCORE_PLUGINS_PATH . "/" . $config["plugin"]["pluginName"] . "/.pimcore_extension_revision";
         if (is_file($revisionFile)) {
             $updateable = true;
         }
         if (!empty($className)) {
             $isEnabled = Pimcore_ExtensionManager::isEnabled("plugin", $config["plugin"]["pluginName"]);
             $plugin = array("id" => $config["plugin"]["pluginName"], "type" => "plugin", "name" => $config["plugin"]["pluginNiceName"], "description" => $config["plugin"]["pluginDescription"], "installed" => $isEnabled ? $className::isInstalled() : null, "active" => $isEnabled, "configuration" => $config["plugin"]["pluginIframeSrc"], "updateable" => $updateable);
             $configurations[] = $plugin;
         }
     }
     // bricks
     $brickConfigs = Pimcore_ExtensionManager::getBrickConfigs();
     // get repo state of bricks
     foreach ($brickConfigs as $id => $config) {
         $updateable = false;
         $revisionFile = PIMCORE_WEBSITE_PATH . "/var/areas/" . $id . "/.pimcore_extension_revision";
         if (is_file($revisionFile)) {
             $updateable = true;
         }
         $isEnabled = Pimcore_ExtensionManager::isEnabled("brick", $id);
         $brick = array("id" => $id, "type" => "brick", "name" => $config->name, "description" => $config->description, "installed" => true, "active" => $isEnabled, "updateable" => $updateable);
         $configurations[] = $brick;
     }
     $this->_helper->json(array("extensions" => $configurations));
 }
 /**
  * @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;
 }
Beispiel #3
0
 /**
  * @see Document_Tag_Interface::frontend
  */
 public function frontend()
 {
     $count = 0;
     $this->setupStaticEnvironment();
     $suffixes = Zend_Registry::get("pimcore_tag_block_current");
     $suffixes[] = $this->getName();
     Zend_Registry::set("pimcore_tag_block_current", $suffixes);
     $options = $this->getOptions();
     $this->current = $count;
     // don't show disabled bricks
     if (!Pimcore_ExtensionManager::isEnabled("brick", $options["type"]) && $options['dontCheckEnabled'] != true) {
         return;
     }
     // create info object and assign it to the view
     $info = null;
     try {
         $info = new Document_Tag_Area_Info();
         $info->setId($options["type"]);
         $info->setIndex($count);
         $info->setPath(str_replace(PIMCORE_DOCUMENT_ROOT, "", Pimcore_ExtensionManager::getPathForExtension($options["type"], "brick")));
         $info->setConfig(Pimcore_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;
             $actionClassname = "Document_Tag_Area_" . ucfirst($options["type"]);
             if (Pimcore_Tool::classExists($actionClassname)) {
                 $actionObj = new $actionClassname();
                 if ($actionObj instanceof Document_Tag_Area_Abstract) {
                     $actionObj->setView($this->getView());
                     $areaConfig = new Zend_Config_Xml($areas[$options["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_' . $options["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>';
             }
         }
     }
     $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);
 }
Beispiel #4
0
 public static function initPlugins()
 {
     // add plugin include paths
     $autoloader = Zend_Loader_Autoloader::getInstance();
     try {
         $pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs();
         if (!empty($pluginConfigs)) {
             $includePaths = array(get_include_path());
             //adding plugin include paths and namespaces
             if (count($pluginConfigs) > 0) {
                 foreach ($pluginConfigs as $p) {
                     if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                         continue;
                     }
                     if (is_array($p['plugin']['pluginIncludePaths']['path'])) {
                         foreach ($p['plugin']['pluginIncludePaths']['path'] as $path) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $path;
                         }
                     } else {
                         if ($p['plugin']['pluginIncludePaths']['path'] != null) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $p['plugin']['pluginIncludePaths']['path'];
                         }
                     }
                     if (is_array($p['plugin']['pluginNamespaces']['namespace'])) {
                         foreach ($p['plugin']['pluginNamespaces']['namespace'] as $namespace) {
                             $autoloader->registerNamespace($namespace);
                         }
                     } else {
                         if ($p['plugin']['pluginNamespaces']['namespace'] != null) {
                             $autoloader->registerNamespace($p['plugin']['pluginNamespaces']['namespace']);
                         }
                     }
                 }
             }
             set_include_path(implode(PATH_SEPARATOR, $includePaths));
             $broker = Pimcore_API_Plugin_Broker::getInstance();
             //registering plugins
             foreach ($pluginConfigs as $p) {
                 if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                     continue;
                 }
                 $jsPaths = array();
                 if (is_array($p['plugin']['pluginJsPaths']['path'])) {
                     $jsPaths = $p['plugin']['pluginJsPaths']['path'];
                 } else {
                     if ($p['plugin']['pluginJsPaths']['path'] != null) {
                         $jsPaths[0] = $p['plugin']['pluginJsPaths']['path'];
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($jsPaths) and count($jsPaths) > 0) {
                     for ($i = 0; $i < count($jsPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) {
                             $jsPaths[$i] = "/plugins" . $jsPaths[$i];
                         }
                     }
                 }
                 $cssPaths = array();
                 if (is_array($p['plugin']['pluginCssPaths']['path'])) {
                     $cssPaths = $p['plugin']['pluginCssPaths']['path'];
                 } else {
                     if ($p['plugin']['pluginCssPaths']['path'] != null) {
                         $cssPaths[0] = $p['plugin']['pluginCssPaths']['path'];
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($cssPaths) and count($cssPaths) > 0) {
                     for ($i = 0; $i < count($cssPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) {
                             $cssPaths[$i] = "/plugins" . $cssPaths[$i];
                         }
                     }
                 }
                 try {
                     $className = $p['plugin']['pluginClassName'];
                     if (!empty($className) && Pimcore_Tool::classExists($className)) {
                         $plugin = new $className($jsPaths, $cssPaths);
                         if ($plugin instanceof Pimcore_API_Plugin_Abstract) {
                             $broker->registerPlugin($plugin);
                         }
                     }
                 } catch (Exeption $e) {
                     Logger::err("Could not instantiate and register plugin [" . $p['plugin']['pluginClassName'] . "]");
                 }
             }
             Zend_Registry::set("Pimcore_API_Plugin_Broker", $broker);
         }
     } catch (Exception $e) {
         Logger::alert("there is a problem with the plugin configuration");
         Logger::alert($e);
     }
 }