Exemple #1
0
 public static function sortPlugins(BOL_Plugin $a, BOL_Plugin $b)
 {
     if ($a->getId() == $b->getId()) {
         return 0;
     }
     return $a->getId() > $b->getId();
 }
 /**
  * @param BOL_Plugin $dto
  * @return OW_Plugin
  */
 public function getPluginObject(BOL_Plugin $dto)
 {
     return $dto->isSystem ? new OW_SystemPlugin(array('dir_name' => $dto->getModule(), 'key' => $dto->getKey(), 'active' => $dto->isActive(), 'dto' => $dto)) : new OW_Plugin(array('dir_name' => $dto->getModule(), 'key' => $dto->getKey(), 'active' => $dto->isActive(), 'dto' => $dto));
 }
Exemple #3
0
 public static function sortPlugins(BOL_Plugin $a, BOL_Plugin $b)
 {
     $aChar = substr($a->getTitle(), 0, 1);
     $bChar = substr($b->getTitle(), 0, 1);
     if ($aChar == $bChar) {
         return 0;
     }
     return $aChar > $bChar;
 }
Exemple #4
0
 /**
  * Installs plugins.
  *
  * @param string $key
  */
 public function install($key)
 {
     $availablePlugins = $this->getAvailablePluginsList();
     if (empty($key) || !array_key_exists($key, $availablePlugins)) {
         throw new LogicException('Invalid plugin key - `' . $key . '` provided!');
     }
     $pluginInfo = $availablePlugins[$key];
     $dirArray = explode(DS, $pluginInfo['path']);
     $moduleName = array_pop($dirArray);
     // add DB entry
     $pluginDto = new BOL_Plugin();
     $pluginDto->setTitle(!empty($pluginInfo['title']) ? trim($pluginInfo['title']) : 'No Title');
     $pluginDto->setDescription(!empty($pluginInfo['description']) ? trim($pluginInfo['description']) : 'No Description');
     $pluginDto->setKey(trim($pluginInfo['key']));
     $pluginDto->setModule($moduleName);
     $pluginDto->setIsActive(true);
     $pluginDto->setIsSystem(false);
     $pluginDto->setBuild((int) $pluginInfo['build']);
     if (!empty($pluginInfo['developerKey'])) {
         $pluginDto->setDeveloperKey(trim($pluginInfo['developerKey']));
     }
     $this->pluginDao->save($pluginDto);
     $this->readPluginsList();
     OW::getPluginManager()->readPluginsList();
     // copy static dir
     $pluginStaticDir = OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'static' . DS;
     if (!defined('OW_PLUGIN_XP') && file_exists($pluginStaticDir)) {
         $staticDir = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule() . DS;
         if (!file_exists($staticDir)) {
             mkdir($staticDir);
             chmod($staticDir, 0777);
         }
         UTIL_File::copyDir($pluginStaticDir, $staticDir);
     }
     // create dir in pluginfiles
     $pluginfilesDir = OW_DIR_PLUGINFILES . $pluginDto->getModule();
     if (!file_exists($pluginfilesDir)) {
         mkdir($pluginfilesDir);
         chmod($pluginfilesDir, 0777);
     }
     // create dir in userfiles
     $userfilesDir = OW_DIR_PLUGIN_USERFILES . $pluginDto->getModule();
     if (!file_exists($userfilesDir)) {
         mkdir($userfilesDir);
         chmod($userfilesDir, 0777);
     }
     include_once OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'install.php';
     include_once OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'activate.php';
     BOL_LanguageService::getInstance()->generateCacheForAllActiveLanguages();
     // trigger event
     $event = new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_INSTALL, array('pluginKey' => $pluginDto->getKey()));
     OW::getEventManager()->trigger($event);
     return $pluginDto;
 }
Exemple #5
0
 /**
  * Installs plugins.
  *
  * @param string $key
  */
 public function install($key, $generateCache = true)
 {
     $availablePlugins = $this->getAvailablePluginsList();
     if (empty($key) || !array_key_exists($key, $availablePlugins)) {
         throw new LogicException("Invalid plugin key - `{$key}` provided for install!");
     }
     $pluginInfo = $availablePlugins[$key];
     $dirArray = explode(DS, $pluginInfo["path"]);
     $moduleName = array_pop($dirArray);
     // add DB entry
     $pluginDto = new BOL_Plugin();
     $pluginDto->setTitle(!empty($pluginInfo["title"]) ? trim($pluginInfo["title"]) : "No Title");
     $pluginDto->setDescription(!empty($pluginInfo["description"]) ? trim($pluginInfo["description"]) : "No Description");
     $pluginDto->setKey(trim($pluginInfo["key"]));
     $pluginDto->setModule($moduleName);
     $pluginDto->setIsActive(true);
     $pluginDto->setIsSystem(false);
     $pluginDto->setBuild((int) $pluginInfo["build"]);
     if (!empty($pluginInfo["developerKey"])) {
         $pluginDto->setDeveloperKey(trim($pluginInfo["developerKey"]));
     }
     $this->pluginDao->save($pluginDto);
     $this->updatePluginListCache();
     $this->addPluginDirs($pluginDto);
     $plugin = new OW_Plugin($pluginDto);
     $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_INSTALL);
     $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_ACTIVATE);
     $pluginDto = $this->findPluginByKey($pluginDto->getKey());
     if ($generateCache) {
         BOL_LanguageService::getInstance()->generateCacheForAllActiveLanguages();
     }
     // trigger event
     OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_INSTALL, array("pluginKey" => $pluginDto->getKey())));
     return $pluginDto;
 }
Exemple #6
0
 public function getRootDir()
 {
     return ($this->dto->isSystem() ? OW_DIR_SYSTEM_PLUGIN : OW_DIR_PLUGIN) . $this->getDirName() . DS;
 }