Exemplo n.º 1
0
 /**
  * Install templates
  *
  * @return void
  */
 public function install_templates()
 {
     ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_templates'), 'core');
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     if (is_file(IPS_ROOT_PATH . 'setup/sql/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_install.php')) {
         require_once IPS_ROOT_PATH . 'setup/sql/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_install.php';
         /*noLibHook*/
         $extra_install = new install_extra($this->registry);
     }
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']);
     /* Got any skin sets? */
     $count = $this->DB->buildAndFetch(array('select' => 'count(*) as count', 'from' => 'skin_collections'));
     if (!$count['count']) {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "Добавление шаблонов";
         require_once IPS_KERNEL_PATH . 'classXML.php';
         /*noLibHook*/
         $xml = new classXML(IPSSetUp::charSet);
         //-----------------------------------------
         // Adjust the table?
         //-----------------------------------------
         if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
             $q = $extra_install->before_inserts_run('skinset');
         }
         /* Skin Set Data */
         $xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml');
         foreach ($xml->fetchElements('set') as $xmlelement) {
             $data = $xml->fetchElementsFromRecord($xmlelement);
             $this->DB->insert('skin_collections', $data);
         }
         //-----------------------------------------
         // Adjust the table?
         //-----------------------------------------
         if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
             $q = $extra_install->after_inserts_run('skinset');
         }
     }
     /* Load skin classes */
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php';
     /*noLibHook*/
     $skinFunctions = new skinImportExport($this->registry);
     /* Grab skin data */
     $this->DB->build(array('select' => '*', 'from' => 'skin_collections'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         /* Bit of jiggery pokery... */
         if ($row['set_key'] == 'default') {
             $row['set_key'] = 'root';
             $row['set_id'] = 0;
         }
         $skinSets[$row['set_key']] = $row;
     }
     //-----------------------------------------
     // InstallTemplates
     //-----------------------------------------
     if ($next['key']) {
         foreach ($skinSets as $skinKey => $skinData) {
             $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
             $output[] = $next['title'] . ": Обновление шаблонов {$skinData['set_name']}";
             if (is_file($_PATH . $next['key'] . '_' . $skinKey . '_templates.xml')) {
                 //-----------------------------------------
                 // Install
                 //-----------------------------------------
                 $return = $skinFunctions->importTemplateAppXML($next['key'], $skinKey, $skinData['set_id'], TRUE);
                 $output[] = $next['title'] . ": " . intval($return['insertCount']) . " шаблонов добавлено";
             }
             if (is_file($_PATH . $next['key'] . '_' . $skinKey . '_css.xml')) {
                 //-----------------------------------------
                 // Install
                 //-----------------------------------------
                 $return = $skinFunctions->importCSSAppXML($next['key'], $skinKey, $skinData['set_id']);
                 $output[] = $next['title'] . ": " . intval($return['insertCount']) . " {$skinData['set_name']} CSS файлов добавлено";
             }
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Обновление: Шаблоны", 'upgrade&do=templates&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Recache templates
         //-----------------------------------------
         $output[] = "Кеширование шаблонов";
         foreach ($skinSets as $skinKey => $skinData) {
             /* Replacements */
             if (is_file(IPS_ROOT_PATH . 'setup/xml/skins/replacements_' . $skinKey . '.xml')) {
                 $skinFunctions->importReplacementsXMLArchive(file_get_contents(IPS_ROOT_PATH . 'setup/xml/skins/replacements_' . $skinKey . '.xml'), $skinKey);
             }
         }
         $skinFunctions->rebuildMobileSkinUserAgentsFromSetDataXml();
         $skinFunctions->rebuildSkinSetsCache();
         $output[] = "Все шаблоны обновлены";
         $this->_finishStep($output, "Обновление: Шаблоны", 'upgrade&do=tasks');
     }
 }