/** * Install templates * * @return @e void */ public function templates() { /* INIT */ $vars = $this->getVars(); $output = array(); $errors = array(); 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); $skinCaching = new skinCaching($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; } foreach ($skinSets as $skinKey => $skinData) { /* Skin files first */ if (is_file($this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_templates.xml')) { $return = $skinFunctions->importTemplateAppXML($vars['app_directory'], $skinKey, $skinData['set_id'], TRUE); $output[] = sprintf($this->lang->words['redir__templates'], $return['insertCount'], $return['updateCount'], $skinData['set_name']); } /* Then CSS files */ if (is_file($this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_css.xml')) { //----------------------------------------- // Install //----------------------------------------- $return = $skinFunctions->importCSSAppXML($vars['app_directory'], $skinKey, $skinData['set_id']); $output[] = sprintf($this->lang->words['redir__cssfiles'], $return['insertCount'], $return['updateCount'], $skinData['set_name']); } /* And we can support replacements for good measure */ if (is_file($this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml')) { //----------------------------------------- // Install //----------------------------------------- $return = $skinFunctions->importReplacementsXMLArchive(file_get_contents($this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml'), $skinKey); $output[] = $this->lang->words['redir__replacements']; } } /* Recache */ //$skinCaching->rebuildPHPTemplates( 0 ); //$skinCaching->rebuildCSS( 0 ); //$skinCaching->rebuildReplacementsCache( 0 ); /* No templates? Give some sort of feedback */ if (!count($output)) { $output[] = $this->lang->words['redir__no_templates']; } /* Show redirect... */ $this->showRedirectScreen($vars['app_directory'], $output, $errors, $this->getNextURL('languages', $vars)); }
/** * Install Caches * * @return void */ public function install_caches() { //----------------------------------------- // INIT //----------------------------------------- $this->settings['base_url'] = IPSSetUp::getSavedData('install_url'); $this->settings['ipb_reg_number'] = IPSSetUp::getSavedData('lkey'); $previous = $_REQUEST['previous']; //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']); /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Install SYSTEM Templates on first cycle //----------------------------------------- if (!$previous) { //----------------------------------------- // Global caches... //----------------------------------------- # Grab cache master file require_once IPS_ROOT_PATH . 'extensions/coreVariables.php'; /*noLibHook*/ /* Add handle */ $_tmp = new coreVariables(); $_cache = $_tmp->fetchCaches(); $CACHE = $_cache['caches']; //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('caches'); } //----------------------------------------- // Continue //----------------------------------------- if (is_array($CACHE)) { foreach ($CACHE as $cs_key => $cs_data) { $output[] = "Обновление {$cs_key}..."; ipsRegistry::cache()->rebuildCache($cs_key, 'global'); } } //------------------------------------------------------------- // Systemvars //------------------------------------------------------------- $output[] = "Обновление кеша системных переменных"; $cache = array('mail_queue' => 0, 'task_next_run' => time() + 3600); ipsRegistry::cache()->setCache('systemvars', $cache, array('array' => 1)); //------------------------------------------------------------- // Stats //------------------------------------------------------------- $output[] = "Обновление кеша статистики"; $cache = array('total_replies' => 0, 'total_topics' => 1, 'mem_count' => 1, 'last_mem_name' => IPSSetUp::getSavedData('admin_user'), 'last_mem_id' => 1); ipsRegistry::cache()->setCache('stats', $cache, array('array' => 1)); //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('caches'); } $output[] = "Все кеши обновлены"; //----------------------------------------- // Recache skins: Moved here so they are // build after hooks are added //----------------------------------------- /* 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; } foreach ($skinSets as $skinKey => $skinData) { /* Bit of jiggery pokery... */ if ($skinData['set_key'] == 'root') { $skinData['set_key'] = 'default'; $skinData['set_id'] = 1; $skinKey = 'default'; } $skinFunctions->rebuildPHPTemplates($skinData['set_id']); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildCSS($skinData['set_id']); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildReplacementsCache($skinData['set_id']); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } } $skinFunctions->rebuildSkinSetsCache(); $output[] = "Кеш стиля обновлен"; /* Rebuild FURL & GLOBAL caches */ try { IPSLib::cacheFurlTemplates(); IPSLib::cacheGlobalCaches(); } catch (Exception $error) { } } //----------------------------------------- // Now install other caches //----------------------------------------- if ($next['key']) { $_PATH = IPSLib::getAppDir($next['key']) . '/extensions/'; if (is_file($_PATH . 'coreVariables.php')) { //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('caches'); } # Grab cache master file require_once $_PATH . 'coreVariables.php'; /*noLibHook*/ if (is_array($CACHE)) { foreach ($CACHE as $cs_key => $cs_data) { $output[] = $next['title'] . ": Обновление {$cs_key}..."; ipsRegistry::cache()->rebuildCache($cs_key, $next['key']); } } else { $output[] = $next['title'] . ": Нет кешей для обновления..."; } //----------------------------------------- // Adjust the table? //----------------------------------------- if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('caches'); } } else { $output[] = $next['title'] . ": Нет кешей для обновления..."; } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $this->_finishStep($output, "Установка: кеш", 'install&do=caches&previous=' . $next['key']); } else { $this->_finishStep($output, "Установка: кеш", 'done'); } }
/** * Install Tenplate Caches * * @return void */ public function install_template_caches() { //----------------------------------------- // INIT //----------------------------------------- $this->settings['base_url'] = IPSSetUp::getSavedData('install_url'); $previous = $_REQUEST['previous']; //----------------------------------------- // Fetch next 'un //----------------------------------------- $skinId = intval($this->request['skinId']); $skinData = array(); $output = array(); //----------------------------------------- // Recache skins: Moved here so they are // build after hooks are added //----------------------------------------- /* 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 */ $skinData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => 'set_id > ' . $skinId . ' AND set_parent_id=0', 'order' => 'set_id ASC', 'limit' => array(0, 1))); if ($skinData['set_id']) { $skinFunctions->rebuildPHPTemplates($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildCSS($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildReplacementsCache($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $output[] = "Обновлен кеш стиля " . $skinData['set_name'] . "..."; /* Go for the next */ $this->_finishStep($output, "Обновление: Кеш стилей", 'upgrade&do=templatecache&skinId=' . $skinData['set_id']); } else { /* All diddly done */ $output[] = "Кеш стилей обновлен"; $skinFunctions->rebuildSkinSetsCache(); /* Rebuild FURL & GLOBAL caches */ try { IPSLib::cacheFurlTemplates(); IPSLib::cacheGlobalCaches(); } catch (Exception $error) { } /* Clear out minify files */ try { if (is_dir(DOC_IPS_ROOT_PATH . 'cache/tmp')) { foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'cache/tmp') as $cache) { if ($cache->getMTime() < time() - 60 * 60 * 24 * 7 and $cache->getFilename() != 'index.html') { @unlink($cache->getPathname()); } } } } catch (Exception $e) { } /* Show message and go */ $this->_finishStep($output, "Upgrade: Skin Caches", 'done'); } }
/** * Install Tenplate Caches * * @return void */ public function install_template_caches() { //----------------------------------------- // INIT //----------------------------------------- $this->settings['base_url'] = IPSSetUp::getSavedData('install_url'); $previous = $_REQUEST['previous']; //----------------------------------------- // Fetch next 'un //----------------------------------------- $skinId = intval($this->request['skinId']); $skinData = array(); $output = array(); //----------------------------------------- // Recache skins: Moved here so they are // build after hooks are added //----------------------------------------- /* Load skin classes */ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; require_once IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php'; $skinFunctions = new skinImportExport($this->registry); /* Grab skin data */ $skinData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => 'set_id > ' . $skinId . ' AND set_parent_id=0', 'order' => 'set_id ASC', 'limit' => array(0, 1))); if ($skinData['set_id']) { $skinFunctions->rebuildPHPTemplates($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildCSS($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $skinFunctions->rebuildReplacementsCache($skinData['set_id']); $output = array_merge($output, $skinFunctions->fetchMessages(TRUE)); if ($skinFunctions->fetchErrorMessages() !== FALSE) { $this->registry->output->addWarning(implode("<br />", $skinFunctions->fetchErrorMessages())); } $output[] = "Recached skin " . $skinData['set_name'] . "..."; /* Go for the next */ $this->_finishStep($output, "Upgrade: Skin Caches", 'upgrade&do=templatecache&skinId=' . $skinData['set_id']); } else { /* All diddly done */ $output[] = "All skins recached"; $skinFunctions->rebuildSkinSetsCache(); /* Rebuild FURL cache */ try { IPSLib::cacheFurlTemplates(); } catch (Exception $error) { } $this->_finishStep($output, "Upgrade: Skin Caches", 'done'); } }