/** * Restore IPB default skin as default * * @return @e void */ public function setDefaultSkin() { /* Get skin functions library */ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ $skinFunctions = new skinCaching($this->registry); /* Update members to use default skin */ $this->DB->update('members', array('skin' => 0)); /* Update forums to use default skin */ $this->DB->update('forums', array('skin_id' => 0)); /* Reset any default skin(s) */ $this->DB->update('skin_collections', array('set_is_default' => 0)); /* Set IPB default skin as default */ $this->DB->update('skin_collections', array('set_is_default' => 1), "set_key='default'"); /* Verify we have a skin set as default */ $_check = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_collections', 'where' => 'set_is_default=1')); if ($_check['total'] < 1) { $this->DB->build(array('update' => 'skin_collections', 'set' => 'set_is_default=1', 'where' => "set_output_format='html'", 'limit' => array(0, 1))); $this->DB->execute(); } /* Check for any modifications in IPB default skin */ $_master = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => "set_key='default'")); $_master['set_id'] = intval($_master['set_id']); $_modifiedTemplates = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_templates', 'where' => "template_set_id={$_master['set_id']} AND template_removable=1 OR template_user_edited=1")); $_modifiedCSS = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'skin_css', 'where' => "css_set_id={$_master['set_id']} AND css_master_key=''")); if ($_modifiedTemplates['total'] or $_modifiedCSS['total']) { /* Create a new skin with IPB default as parent */ $curPos = $skinFunctions->fetchHighestSetPosition(); $_master['set_key'] = 'default_modified'; $_master['set_parent_id'] = $_master['set_id']; $_master['set_is_default'] = 0; $_master['set_name'] = $_master['set_name'] . ' (Pre 3.2)'; $_master['set_order'] = (int) $curPos++; unset($_master['set_id']); $this->DB->insert('skin_collections', $_master); $set_id = $this->DB->getInsertId(); $this->DB->update('skin_templates', array('template_set_id' => $set_id), "template_set_id={$_master['set_parent_id']} AND template_removable=1 OR template_user_edited=1"); $this->DB->update('skin_css', array('css_set_id' => $set_id), "css_set_id={$_master['set_parent_id']} AND css_master_key=''"); $skinFunctions->rebuildSkinSetsCache(); $skinFunctions->rebuildTreeInformation($set_id); //$skinFunctions->flushSkinData(); $skinFunctions->rebuildCSS($set_id); $skinFunctions->rebuildPHPTemplates($set_id); $skinFunctions->rebuildReplacementsCache($set_id); } /* Message */ $this->registry->output->addMessage("Восстановлен новый базовый стиль...."); /* Next Page */ $this->request['workact'] = 'hooks'; }
/** * Construct * * @access public * @param object ipsRegistry reference * @param bool Whether to init or not * @return @e void */ public function __construct(ipsRegistry $registry, $initialize = FALSE) { /* Make object */ $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->lang = $this->registry->getClass('class_localization'); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); /* Safe mode skins... */ $this->_usingSafeModeSkins = ($this->settings['safe_mode_skins'] == 0 and $this->settings['safe_mode'] == 0 or IN_DEV) ? FALSE : TRUE; if ($initialize === TRUE) { //----------------------------------------- // INIT //----------------------------------------- $_outputFormat = 'html'; $_outputClassName = 'htmlOutput'; $this->allSkins = $this->_fetchAllSkins(); $skinSetID = $this->_fetchUserSkin(); $this->skin = $this->allSkins[$skinSetID]; /* Does it need a recache? */ if ($this->skin['set_updated'] == -2) { /* Flag skins for recache */ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ $skinCaching = new skinCaching($this->registry); /* Set it as caching */ $skinCaching->flagSetAsRecaching($skinSetID); /* Just recache this one skin set */ $skinCaching->setIgnoreChildrenWhenRecaching(true); $skinCaching->rebuildPHPTemplates($skinSetID); $skinCaching->rebuildCSS($skinSetID); $skinCaching->rebuildReplacementsCache($skinSetID); IPSDebug::addMessage("Recached skin set: " . $skinSetID); } //----------------------------------------- // Get the skin caches //----------------------------------------- $skinCaches = $this->cache->getWithCacheLib('Skin_Store_' . $skinSetID); if (!is_array($skinCaches) or !count($skinCaches)) { $_grab = "'css', 'replacements'"; $this->DB->build(array('select' => '*', 'from' => 'skin_cache', 'where' => "cache_set_id=" . intval($skinSetID) . " AND cache_type IN (" . $_grab . ")")); $this->DB->execute(); while ($row = $this->DB->fetch()) { $skinCaches[$row['cache_value_2'] . '.' . $row['cache_id']] = $row; } /* Put skin cache back if needed */ $this->cache->putWithCacheLib('Skin_Store_' . $skinSetID, $skinCaches, 86400); } /* Avoid SQL filesort */ ksort($skinCaches); /* Loop and build */ foreach ($skinCaches as $row) { switch ($row['cache_type']) { default: break; case 'css': $appDir = ''; $appHide = 0; if (strstr($row['cache_value_4'], '-')) { list($appDir, $appHide) = explode('-', $row['cache_value_4']); if ($appDir and $appDir != IPS_APP_COMPONENT and $appHide) { continue; } else { if ($appDir and !IPSLib::appIsInstalled($appDir)) { continue; } } } /* Tied to specific modules within the app? */ if ($row['cache_value_6'] and $this->request['module']) { if (!in_array($this->request['module'], explode(',', str_replace(' ', '', $row['cache_value_6'])))) { continue; } } $skinCaches['css'][$row['cache_value_1']] = array('content' => $row['cache_content'], 'attributes' => $row['cache_value_5']); break; case 'replacements': $skinCaches['replacements'] = $row['cache_content']; break; } } $this->skin['_css'] = is_array($skinCaches['css']) ? $skinCaches['css'] : array(); $this->skin['_replacements'] = unserialize($skinCaches['replacements']); $this->skin['_skincacheid'] = $this->skin['set_id']; $this->skin['_csscacheid'] = 'css_' . $this->skin['set_id']; // Set a hash we can use to prevent client caching of CSS/JS $this->antiCacheHash = md5(IPB_VERSION . $this->settings['board_url'] . md5($this->settings['sql_tbl_prefix'] . $this->settings['sql_pass']) . $this->skin['set_updated']); /* IN_DEV Stuff */ if (IN_DEV) { $this->skin['_css'] = array(); if (is_file(IPS_CACHE_PATH . 'cache/skin_cache/masterMap.php')) { $REMAP = $this->buildRemapData(); $_setId = intval($REMAP['inDevDefault']); $_dir = $REMAP['templates'][$REMAP['inDevDefault']]; $_cdir = $REMAP['css'][$REMAP['inDevDefault']]; /* Reset master dir */ $this->skin['set_image_dir'] = $REMAP['images'][$REMAP['inDevDefault']]; $this->skin['set_key'] = $REMAP['inDevDefault']; } else { $_setId = 0; $_dir = 'master_skin'; $_cdir = 'master_css'; } /* Using a custom master skin */ if ($_setId) { $this->skin = $this->allSkins[$_setId]; $this->skin['_replacements'] = unserialize($skinCaches['replacements']); } /* Sort out CSS */ if (!isset($this->_skinFunctions) || !is_object($this->_skinFunctions)) { require_once IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php'; /*noLibHook*/ $this->_skinFunctions = new skinCaching($this->registry); } $css = $this->_skinFunctions->fetchDirectoryCSS($_cdir); $tmp = array(); $ord = array(); foreach ($css as $name => $data) { /* Tied to app? */ if ($data['css_app'] and $data['css_app'] != IPS_APP_COMPONENT and $data['css_app_hide']) { continue; } /* Tied to specific modules within the app? */ if ($data['css_modules'] and !in_array($this->request['module'], explode(',', str_replace(' ', '', $data['css_modules'])))) { continue; } $tmp[$data['css_position'] . '.' . $data['css_group']][$name] = array('content' => $data['css_content'], 'attributes' => $data['css_attributes']); } ksort($tmp); foreach ($tmp as $blah => $data) { foreach ($data as $name => $data) { $ord[$blah] = array('css_group' => $name, 'css_position' => 1); $this->skin['_css'][$name] = $data; } } /* Other data */ $this->skin['_cssGroupsArray'] = $ord; $this->skin['_skincacheid'] = is_dir(IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir) ? $_setId : $this->skin['set_id']; $this->skin['_csscacheid'] = $_cdir; $this->skin['set_css_inline'] = is_dir(IPS_PUBLIC_PATH . 'style_css/' . $_cdir) ? 1 : 0; if (is_file(IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir . '/_replacements.inc')) { $replacements = array(); include_once IPS_CACHE_PATH . 'cache/skin_cache/' . $_dir . '/_replacements.inc'; /*noLibHook*/ $this->skin['_replacements'] = $replacements; } } /* Is this a mobile skin? */ if ($this->skin['set_key'] == 'mobile') { $this->setAsMobileSkin(true); } //----------------------------------------- // Which output engine? //----------------------------------------- if ($this->skin['set_output_format']) { if (file_exists(IPS_ROOT_PATH . 'sources/classes/output/formats/' . $this->skin['set_output_format'])) { $_outputFormat = $this->skin['set_output_format']; $_outputClassName = $this->skin['set_output_format'] . 'Output'; } } require_once IPS_ROOT_PATH . 'sources/classes/output/formats/coreOutput.php'; /*noLibHook*/ $outputClassToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/output/formats/' . $_outputFormat . '/' . $_outputClassName . '.php', $_outputClassName); $this->outputFormatClass = new $outputClassToLoad($this); /* Build URLs */ $this->_buildUrls(); /* Special set up for mobile skin */ if ($this->getAsMobileSkin() === true) { $this->_mobileSkinSetUp(); } } }