Esempio n. 1
0
 /**
  * Update theme info in the [OW_DB_PREFIX]_base_theme table according to the theme.xml file and force theme rebuilding if necessary
  * @param $name
  * @param bool $processTheme
  */
 public function updateThemeInfo($name, $processTheme = false)
 {
     $xmlInfo = $this->getThemeXmlInfoForKey($name);
     if (empty($xmlInfo)) {
         return;
     }
     $themeDto = $this->findThemeByKey($name);
     if (empty($themeDto)) {
         return;
     }
     $themeDto->setKey($xmlInfo["key"]);
     $themeDto->setTitle($xmlInfo["name"]);
     $themeDto->setDescription(json_encode($xmlInfo));
     $themeDto->setSidebarPosition($xmlInfo["sidebarPosition"]);
     $themeDto->setDeveloperKey($xmlInfo["developerKey"]);
     if ($themeDto->getBuild() < $xmlInfo["build"]) {
         $themeDto->setBuild($xmlInfo["build"]);
         $themeDto->setUpdate(self::THEME_STATUS_UP_TO_DATE);
         $processTheme = true;
     }
     $this->themeDao->save($themeDto);
     if ($processTheme) {
         $this->processTheme($themeDto->getId());
     }
 }
Esempio n. 2
0
 /**
  * Update theme info in the [OW_DB_PREFIX]_base_theme table according to the theme.xml file and force theme rebuilding if necessary
  * @param $name
  * @param bool $processTheme
  */
 public function updateThemeInfo($name, $processTheme = false)
 {
     $path = OW_DIR_THEME . $name;
     $xmlFiles = UTIL_File::findFiles($path, array('xml'), 1);
     $themeXml = $xmlFiles[0];
     if (basename($themeXml) === self::MANIFEST_FILE) {
         $xml = simplexml_load_file($themeXml);
         $title = (string) $xml->name;
         $build = (int) $xml->build;
         $developerKey = (string) $xml->developerKey;
         $sidebarPosition = (string) $xml->sidebarPosition;
         if (!in_array(trim($sidebarPosition), array('left', 'right', 'none'))) {
             $sidebarPosition = 'none';
         }
         $xmlArray = (array) $xml;
         unset($xmlArray['masterPages']);
         $description = json_encode($xmlArray);
         if (!trim($title)) {
             $title = $name;
         }
         $theme = $this->findThemeByName($name);
         if (empty($theme)) {
             return;
         }
         $theme->setName($name);
         $theme->setTitle($title);
         $theme->setDescription($description);
         $theme->setSidebarPosition($sidebarPosition);
         $theme->setDeveloperKey($developerKey);
         $this->themeDao->save($theme);
         if ($processTheme) {
             $this->processTheme($theme->getId());
         }
     }
 }
Esempio n. 3
0
 /**
  * Cron function.
  */
 public function checkUpdates()
 {
     if (defined('OW_PLUGIN_XP')) {
         return;
     }
     $pluginsRequestArray = array(array('key' => 'core', 'developerKey' => 'ow', 'build' => OW::getConfig()->getValue('base', 'soft_build')));
     $plugins = $this->pluginDao->findRegularPlugins();
     /* @var $plugin BOL_Plugin */
     foreach ($plugins as $plugin) {
         $pluginsRequestArray[] = array('key' => $plugin->getKey(), 'developerKey' => $plugin->getDeveloperKey(), 'build' => $plugin->getBuild());
     }
     $themesRequestArray = array();
     $themes = $this->themeDao->findAll();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesRequestArray[] = array('key' => $theme->getName(), 'developerKey' => $theme->getDeveloperKey(), 'build' => $theme->getBuild());
     }
     $event = new OW_Event('base.on_plugin_info_update');
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (empty($data)) {
         $data = array();
     }
     $requestUrl = OW::getRequest()->buildUrlQueryString(self::UPDATE_SERVER . 'get-items-update-info/');
     $postParams = array_merge(array('plugins' => urlencode(json_encode($pluginsRequestArray)), 'themes' => urlencode(json_encode($themesRequestArray))));
     $postdata = http_build_query($postParams);
     $options = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
     $context = stream_context_create($options);
     $resultArray = json_decode(file_get_contents($requestUrl, false, $context), true);
     if (empty($resultArray) || !is_array($resultArray)) {
         return;
     }
     if (!empty($resultArray['plugins']) && is_array($resultArray['plugins'])) {
         foreach ($plugins as $plugin) {
             if (in_array($plugin->getKey(), $resultArray['plugins']) && (int) $plugin->getUpdate() === 0) {
                 $plugin->setUpdate(1);
                 $this->pluginDao->save($plugin);
             }
         }
         if (in_array('core', $resultArray['plugins'])) {
             OW::getConfig()->saveConfig('base', 'update_soft', 1);
         }
     }
     if (!empty($resultArray['themes']) && is_array($resultArray['themes'])) {
         foreach ($themes as $theme) {
             if (in_array($theme->getName(), $resultArray['themes']) && (int) $theme->getUpdate() === 0) {
                 $theme->setUpdate(1);
                 $this->themeDao->save($theme);
             }
         }
     }
 }