コード例 #1
0
 /**
  * Generate a component.yml for one theme available on the system
  * 
  * @param \Cx\Core\View\Model\Entity\Theme $theme
  */
 public function convertThemeToComponent(\Cx\Core\View\Model\Entity\Theme $theme)
 {
     if ($theme->getComponentData()) {
         return;
     }
     $themePath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername();
     $infoFile = null;
     $themeInformation = array('DlcInfo' => array());
     if (file_exists($themePath . '/info.xml')) {
         try {
             // check for old info file
             $infoFile = new \Cx\Lib\FileSystem\File($themePath . '/info.xml');
             $this->xmlParseFile($infoFile);
             $themeInformation['DlcInfo'] = array('name' => $theme->getThemesname(), 'description' => $this->xmlDocument['THEME']['DESCRIPTION']['cdata'], 'type' => 'template', 'publisher' => $this->xmlDocument['THEME']['AUTHORS']['AUTHOR']['USER']['cdata'], 'subtype' => null, 'versions' => array('state' => 'stable', 'number' => $this->xmlDocument['THEME']['VERSION']['cdata'], 'releaseDate' => ''));
             unset($this->xmlDocument);
         } catch (\Exception $e) {
             // not critical, ignore
         }
     } else {
         // create new data for new component.yml file
         $themeInformation['DlcInfo'] = array('name' => $theme->getThemesname(), 'description' => '', 'type' => 'template', 'publisher' => 'Cloudrexx AG', 'subtype' => null, 'versions' => array('state' => 'stable', 'number' => '1.0.0', 'releaseDate' => ''));
     }
     // Add default dependencies
     $themeInformation['DlcInfo']['dependencies'] = array(array('name' => 'jquery', 'type' => 'lib', 'minimumVersionNumber' => '1.6.1', 'maximumVersionNumber' => '1.6.1'));
     // write components yaml
     $theme->setComponentData($themeInformation['DlcInfo']);
     try {
         $this->saveComponentData($theme);
     } catch (\Exception $e) {
         // could not write new component.yml file, try next time
         throw new $e();
     }
     if ($infoFile) {
         try {
             // delete existing info.xml file
             $infoFile->delete();
         } catch (\Exception $e) {
             // not critical, ignore
         }
     }
 }
コード例 #2
0
ファイル: ViewManager.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Insert the skin into database
  *
  * @param \Cx\Core\View\Model\Entity\Theme $theme the template object
  * 
  * @return  mixed integer on success | false on error
  */
 private function insertSkinIntoDb(\Cx\Core\View\Model\Entity\Theme $theme)
 {
     global $_ARRAYLANG, $objDatabase;
     $objResult = $objDatabase->Execute('INSERT INTO 
                                           `' . DBPREFIX . 'skins` 
                                         SET
                                             `themesname` = "' . contrexx_raw2db($theme->getThemesname()) . '",
                                             `foldername` = "' . contrexx_raw2db($theme->getFoldername()) . '",
                                             `expert`     = 1');
     if ($objResult) {
         return $objDatabase->Insert_ID();
     } else {
         \Message::add($_ARRAYLANG['TXT_THEME_ERROR_IN_INSERT_THEME'], \Message::CLASS_ERROR);
         return false;
     }
 }