Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Skin Caching Functions
|
||||
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-09-16 15:32:18 -0400 (Fri, 16 Sep 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: mmecham $
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th July 2008
|
||||
* @version $Revision: 6975 $
|
||||
* @version $Revision: 9503 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ if ( ! defined( 'IN_IPB' ) )
|
||||
*/
|
||||
if ( ! class_exists( 'skinFunctions' ) )
|
||||
{
|
||||
require_once( dirname( __FILE__ ) . '/skinFunctions.php' );
|
||||
require_once( dirname( __FILE__ ) . '/skinFunctions.php' );/*noLibHook*/
|
||||
}
|
||||
|
||||
class skinCaching extends skinFunctions
|
||||
@@ -47,7 +47,9 @@ class skinCaching extends skinFunctions
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -58,12 +60,30 @@ class skinCaching extends skinFunctions
|
||||
*/
|
||||
protected $_cssNeedToRebuildArray = array();
|
||||
|
||||
/**
|
||||
* Ignore children when recaching ...
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_ignoreChildrenWhenRecaching = false;
|
||||
|
||||
/**
|
||||
* Recache skin sets on shutdown
|
||||
* @var bool
|
||||
*/
|
||||
protected $_recacheSkinsCache = false;
|
||||
|
||||
/**
|
||||
* Remember which skins we've already flagged for recache
|
||||
* @var array
|
||||
*/
|
||||
protected $_flaggedForRecache = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -71,6 +91,24 @@ class skinCaching extends skinFunctions
|
||||
parent::__construct( $registry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ignore children when recaching
|
||||
* @param boolean $val
|
||||
*/
|
||||
public function setIgnoreChildrenWhenRecaching( $val )
|
||||
{
|
||||
$this->_ignoreChildrenWhenRecaching = ( ! empty( $val ) ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ignore children when recaching
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIgnoreChildrenWhenRecaching()
|
||||
{
|
||||
return $this->_ignoreChildrenWhenRecaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild Replacements cache
|
||||
*
|
||||
@@ -121,6 +159,17 @@ class skinCaching extends skinFunctions
|
||||
$_setID = $setID;
|
||||
}
|
||||
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$__replacements = $this->fetchReplacements( $_setID );
|
||||
$_replacements = array();
|
||||
|
||||
@@ -155,7 +204,7 @@ class skinCaching extends skinFunctions
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
$skinSetData['set_image_dir'] = ( $skinSetData['set_image_dir'] ) ? $skinSetData['set_image_dir'] : 'master';
|
||||
@@ -182,6 +231,17 @@ class skinCaching extends skinFunctions
|
||||
|
||||
foreach( $skinSetData['_childTree'] as $_setID )
|
||||
{
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get template set titles
|
||||
//-----------------------------------------
|
||||
@@ -390,6 +450,11 @@ EOF;
|
||||
|
||||
foreach( $phpKeep as $_setID => $data )
|
||||
{
|
||||
if ( ( $_setID != $setID ) && $this->getIgnoreChildrenWhenRecaching() === true )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_path = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $_setID;
|
||||
|
||||
if ( is_dir( $_path ) )
|
||||
@@ -512,6 +577,11 @@ EOF;
|
||||
|
||||
foreach( $cssKeep as $_setID => $data )
|
||||
{
|
||||
if ( ( $_setID != $setID ) && $this->getIgnoreChildrenWhenRecaching() === true )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_path = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $_setID;
|
||||
|
||||
if ( is_dir( $_path ) )
|
||||
@@ -563,7 +633,7 @@ EOF;
|
||||
* @access public
|
||||
* @param int [Optional Skin set id to rebuild. If no value given, all skin sets are rebuilt]
|
||||
* @param boolean Force rebuild regardless of if it requires it
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function rebuildCSS( $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
@@ -590,7 +660,7 @@ EOF;
|
||||
*/
|
||||
public function rebuildCSSFlatFiles( $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
$this->_resetErrorHandle();
|
||||
$this->_resetMessageHandle();
|
||||
@@ -649,16 +719,26 @@ EOF;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
IPSDebug::addLogMessage( "Attempting to write CSS " . $_setID . ", " . $_group . ".css", 'css' );
|
||||
|
||||
$this->_writeCSSFile( $_setID, $_group, $_css );
|
||||
|
||||
//-----------------------------------------
|
||||
// Got any error messages?
|
||||
//-----------------------------------------
|
||||
|
||||
/* Any problems? */
|
||||
if ( $this->fetchErrorMessages() !== FALSE )
|
||||
{
|
||||
/* Flag as using inline */
|
||||
$this->flagSetAsNonCachedCSS( $_setID );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -717,6 +797,17 @@ EOF;
|
||||
$_css = $this->fetchCSS( $_setID );
|
||||
$_skinSetData = $this->fetchSkinData( $_setID );
|
||||
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach( $_css as $name => $css )
|
||||
{
|
||||
if ( ! in_array( $name, array_keys( $needToRebuild[ $_setID ] ) ) )
|
||||
@@ -783,7 +874,7 @@ EOF;
|
||||
//-----------------------------------------
|
||||
// Update skin sets
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ( count( $cssSkinCollections ) )
|
||||
{
|
||||
foreach( $cssSkinCollections as $setID => $data )
|
||||
@@ -800,6 +891,26 @@ EOF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as not able to serve cached CSS
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetAsNonCachedCSS( $setId=null )
|
||||
{
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_css_inline' => 1 ), 'set_id=' . intval( $setId ) );
|
||||
}
|
||||
|
||||
/* Build cache */
|
||||
$this->rebuildSkinSetsCache();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild master replacements from cache/skin_cache/master_skin/_replacements.inc
|
||||
*
|
||||
@@ -817,7 +928,7 @@ EOF;
|
||||
// Master file exists?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( $dir . '/_replacements.inc' ) )
|
||||
if ( ! is_file( $dir . '/_replacements.inc' ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -830,28 +941,47 @@ EOF;
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_master_key='" . $setId . "'" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_set_id='" . intval($setId) . "'" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab file
|
||||
//-----------------------------------------
|
||||
|
||||
$replacements = array();
|
||||
require( $dir . '/_replacements.inc' );
|
||||
include( $dir . '/_replacements.inc' );/*noLibHook*/
|
||||
|
||||
if ( !is_array($replacements) || !count($replacements) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Insert... */
|
||||
//-----------------------------------------
|
||||
// Get proper set key/id
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $replacements as $k => $v )
|
||||
{
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $k;
|
||||
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
|
||||
'replacement_content' => $v,
|
||||
'replacement_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'replacement_set_id' => 0,
|
||||
'replacement_master_key' => $set_key,
|
||||
'replacement_set_id' => $set_id,
|
||||
'replacement_added_to' => 0 ) );
|
||||
}
|
||||
|
||||
@@ -874,7 +1004,7 @@ EOF;
|
||||
{
|
||||
/* Set directory */
|
||||
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
|
||||
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $this->remapData['css'][ $setId ];
|
||||
$cssDir = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $this->remapData['css'][ $setId ];
|
||||
$messages = array();
|
||||
$css = array();
|
||||
|
||||
@@ -910,6 +1040,18 @@ EOF;
|
||||
$css = $this->fetchCSS( $setId );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set key and ID
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Recurse over the directory
|
||||
//-----------------------------------------
|
||||
@@ -923,36 +1065,36 @@ EOF;
|
||||
|
||||
if ( substr( $_name, -4 ) == '.css' )
|
||||
{
|
||||
$cssName = substr( $_name, 0, -4 );
|
||||
$cssContent = @file_get_contents( $cssDir . '/' . $_name );
|
||||
$_css_added_to = 0;
|
||||
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
|
||||
$cssName = substr( $_name, 0, -4 );
|
||||
$cssContent = @file_get_contents( $cssDir . '/' . $_name );
|
||||
$_css_added_to = 0;
|
||||
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
|
||||
|
||||
/* Encode */
|
||||
$cssContent = IPSText::encodeForXml( $cssContent );
|
||||
$cssContent = IPSText::encodeForXml( $cssContent );
|
||||
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
|
||||
/* 'Master' bit? */
|
||||
if ( ! $css[ $cssName ] )
|
||||
{
|
||||
$_css_added_to = $setId;
|
||||
$_css_added_to = $set_id;
|
||||
}
|
||||
|
||||
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
|
||||
'css_set_id' => ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId ),
|
||||
'css_added_to' => ( is_numeric( $_css_added_to ) ) ? $_css_added_to : $this->fetchSetIdByKey( $_css_added_to ),
|
||||
'css_app' => $cssData['css_app'],
|
||||
'css_app_hide' => intval( $cssData['css_app_hide'] ),
|
||||
'css_modules' => trim( $cssData['css_modules'] ),
|
||||
'css_position' => intval( $cssData['css_position'] ),
|
||||
'css_attributes' => $cssData['css_attributes'],
|
||||
'css_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'css_group' => $cssName,
|
||||
'css_content' => $cssContent ) );
|
||||
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
|
||||
'css_set_id' => $set_id,
|
||||
'css_added_to' => $_css_added_to,
|
||||
'css_app' => $cssData['css_app'],
|
||||
'css_app_hide' => intval( $cssData['css_app_hide'] ),
|
||||
'css_modules' => trim( $cssData['css_modules'] ),
|
||||
'css_position' => intval( $cssData['css_position'] ),
|
||||
'css_attributes' => $cssData['css_attributes'],
|
||||
'css_master_key' => $set_key,
|
||||
'css_group' => $cssName,
|
||||
'css_content' => $cssContent ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1029,6 +1171,18 @@ EOF;
|
||||
$templates = $this->fetchTemplates( $setId, 'allTemplates' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set key and ID
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
/* Loop through the directory */
|
||||
try
|
||||
{
|
||||
@@ -1058,10 +1212,10 @@ EOF;
|
||||
continue;
|
||||
}
|
||||
|
||||
$farray = explode( "\n", $fdata );
|
||||
$functions = array();
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
$farray = explode( "\n", $fdata );
|
||||
$functions = array();
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
|
||||
foreach( $farray as $f )
|
||||
{
|
||||
@@ -1156,22 +1310,25 @@ EOF;
|
||||
$content = IPSText::encodeForXml( $content );
|
||||
|
||||
/* Build array */
|
||||
$array = array( 'template_set_id' => $setId,
|
||||
$array = array( 'template_set_id' => $set_id,
|
||||
'template_group' => $name,
|
||||
'template_content' => $content,
|
||||
'template_name' => $fname,
|
||||
'template_data' => trim($config[$fname]),
|
||||
'template_updated' => time(),
|
||||
'template_removable' => ( is_numeric( $setId ) AND $setId ) ? 1 : 0,
|
||||
'template_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'template_added_to' => ( is_numeric( $setId ) ) ? intval( $setId ) : $this->fetchSetIdByKey( $setId ) );
|
||||
'template_master_key' => $set_key,
|
||||
'template_added_to' => $set_id );
|
||||
|
||||
if ( ! $setId OR ! $templates[ $name ][ strtolower( $fname ) ] )
|
||||
if ( ! $setId )
|
||||
{
|
||||
$added++;
|
||||
|
||||
/* All new bits go to 'master' skin */
|
||||
$array['template_set_id'] = 0;
|
||||
$array['template_added_to'] = 0;
|
||||
$array['template_set_id'] = 0;
|
||||
$array['template_added_to'] = 0;
|
||||
$array['template_master_key'] = 'root';
|
||||
|
||||
$this->DB->insert( 'skin_templates', $array );
|
||||
}
|
||||
else
|
||||
@@ -1192,6 +1349,7 @@ EOF;
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {}
|
||||
|
||||
/* Recache */
|
||||
if ( is_numeric( $setId ) AND $setId )
|
||||
{
|
||||
@@ -1201,19 +1359,63 @@ EOF;
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
|
||||
}
|
||||
|
||||
if ( $set_key == 'mobile' )
|
||||
{
|
||||
$this->rebuildMobileSkinUserAgentsFromSetDataXml();
|
||||
}
|
||||
|
||||
/* Return */
|
||||
$messages[] = $this->lang->words['cpltrebuildfromcaches'];
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as needing recache
|
||||
*
|
||||
* @param int Set ID
|
||||
* @param bool Skip rebuild skin sets cache
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetForRecache( $setId=null, $skipRebuild=false )
|
||||
{
|
||||
/* If we're already flagged, just return
|
||||
@link http://community.invisionpower.com/tracker/issue-31472-skin-recaching-optimizations */
|
||||
$_key = md5( $setId . $skipRebuild );
|
||||
|
||||
if( isset($this->_flaggedForRecache[ $_key ]) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->_flaggedForRecache[ $_key ] = 1;
|
||||
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -2 ), 'set_id=' . intval( $setId ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -2 ) );
|
||||
}
|
||||
|
||||
/* Build cache */
|
||||
if( !$skipRebuild )
|
||||
{
|
||||
$this->rebuildSkinSetsCache();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as needing recache
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetForRecache( $setId=null )
|
||||
public function flagSetAsRecaching( $setId=null )
|
||||
{
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
@@ -1231,14 +1433,33 @@ EOF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* We set a flag to rebuild the skin sets cache on shutdown. We do it this way to ensure we only rebuild the cache once per page load.
|
||||
*
|
||||
* @link http://community.invisionpower.com/tracker/issue-31472-skin-recaching-optimizations
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function rebuildSkinSetsCache()
|
||||
{
|
||||
if( !$this->_recacheSkinsCache )
|
||||
{
|
||||
$this->_recacheSkinsCache = true;
|
||||
|
||||
register_shutdown_function( array( $this, '__rebuildSkinSetsCache' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild skinsets cache in the cache_store table
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function rebuildSkinSetsCache()
|
||||
public function __rebuildSkinSetsCache()
|
||||
{
|
||||
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
@@ -1325,7 +1546,7 @@ EOF;
|
||||
{
|
||||
/* Set directory */
|
||||
$css = array();
|
||||
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
|
||||
$cssDir = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $dir;
|
||||
$messages = array();
|
||||
|
||||
if ( ! file_exists( $cssDir ) )
|
||||
@@ -1409,7 +1630,7 @@ EOF;
|
||||
|
||||
$setData = $this->fetchSkinData( $id );
|
||||
|
||||
$path = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
|
||||
$path = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $dir;
|
||||
$msgs = array();
|
||||
|
||||
if ( ! isset( $setData['set_id'] ) )
|
||||
@@ -1597,7 +1818,7 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
@chmod( $path . '/' . $_file, 0777 );
|
||||
@chmod( $path . '/' . $_file, IPS_FILE_PERMISSION );
|
||||
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/' . $_file;
|
||||
}
|
||||
}
|
||||
@@ -1613,11 +1834,11 @@ EOF;
|
||||
/**
|
||||
* Creates CSS master block
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Array of CSS data from the DB
|
||||
* @return string
|
||||
*/
|
||||
private function _masterWrite_createCssBlock( $data )
|
||||
protected function _masterWrite_createCssBlock( $data )
|
||||
{
|
||||
$block = array();
|
||||
|
||||
@@ -1663,11 +1884,11 @@ EOF;
|
||||
/**
|
||||
* Wrap content for a master skin function
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Template bit data
|
||||
* @param string Content
|
||||
*/
|
||||
private function _masterWrite_format( $data )
|
||||
protected function _masterWrite_format( $data )
|
||||
{
|
||||
$_open = '<<<EOF';
|
||||
$_close = 'EOF';
|
||||
@@ -1693,11 +1914,11 @@ EOF;
|
||||
/**
|
||||
* Wrap content for a master skin class
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param string Content
|
||||
* @param string Content
|
||||
*/
|
||||
private function _masterWrite_wrap( $content )
|
||||
protected function _masterWrite_wrap( $content )
|
||||
{
|
||||
$_date = gmdate( 'r' );
|
||||
$return = <<<EOF
|
||||
@@ -1721,7 +1942,7 @@ EOF;
|
||||
* @param int Skin set ID
|
||||
* @param string Group Name
|
||||
* @param string CSS content
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _writeCSSFile( $setID, $css_group, $css_content )
|
||||
{
|
||||
@@ -1744,7 +1965,7 @@ EOF;
|
||||
|
||||
if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) )
|
||||
{
|
||||
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, 0777 ) )
|
||||
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, IPS_FOLDER_PERMISSION ) )
|
||||
{
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['couldnotcreatecssdir'], $setID ) );
|
||||
return $this->_errorMsgs;
|
||||
@@ -1752,7 +1973,7 @@ EOF;
|
||||
else
|
||||
{
|
||||
@file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, IPS_FOLDER_PERMISSION );
|
||||
$good_to_go = 1;
|
||||
}
|
||||
}
|
||||
@@ -1763,7 +1984,7 @@ EOF;
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['cssdirnotwritaaaable'], $setID ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
else if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
else if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
{
|
||||
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
|
||||
{
|
||||
@@ -1803,7 +2024,7 @@ EOF;
|
||||
{
|
||||
fwrite( $FH, $css_content, strlen($css_content) );
|
||||
fclose( $FH );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 0777 );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', IPS_FILE_PERMISSION );
|
||||
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre']. "skin_cache/css_{$setID}/{$css_group}.css" );
|
||||
}
|
||||
@@ -1842,7 +2063,7 @@ EOF;
|
||||
|
||||
if ( ! is_dir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID ) )
|
||||
{
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 ) )
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, IPS_FOLDER_PERMISSION ) )
|
||||
{
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplatew'], $setID ) );
|
||||
return;
|
||||
@@ -1850,13 +2071,13 @@ EOF;
|
||||
else
|
||||
{
|
||||
@file_put_contents( IPS_CACHE_PATH.'cache/skin_cache/cacheid_' . $setID . '/index.html', '' );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, IPS_FOLDER_PERMISSION );
|
||||
$good_to_go = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( file_exists( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) )
|
||||
if ( is_file( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) )
|
||||
{
|
||||
if ( IPSLib::isWritable( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) !== TRUE )
|
||||
{
|
||||
@@ -1890,7 +2111,7 @@ EOF;
|
||||
{
|
||||
fwrite( $FH, $content, strlen($content) );
|
||||
fclose( $FH );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', 0777 );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', IPS_FILE_PERMISSION );
|
||||
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php" );
|
||||
}
|
||||
@@ -2009,6 +2230,9 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/* remove phpdoc style comments */
|
||||
$cssContent = preg_replace( '#/\*\*(\s+?)(.+?)\n(\s+?)?\*/#s', '', $cssContent );
|
||||
|
||||
$cssContent = preg_replace( '#url\((\"|\')?.+?style_images/([\d\w]+?)/#i', "url(\\1{style_images_url}/", $cssContent );
|
||||
$cssContent = preg_replace( '#url\((\"|\')?/style_images/([\d\w]+?)#i' , "url(\\1{style_images_url}/", $cssContent );
|
||||
|
||||
@@ -2066,13 +2290,13 @@ EOF;
|
||||
/**
|
||||
* Determine which CSS files need rebuilding
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Array of child skins (including current setID)
|
||||
* @param int Set ID we're recaching
|
||||
* @param boolean Force all css sets to recache
|
||||
* @return array Array of items to rebuild
|
||||
*/
|
||||
private function _CSSNeedToRebuild( $childTree, $setID, $forceRebuild=FALSE )
|
||||
protected function _CSSNeedToRebuild( $childTree, $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Already been 'ere?
|
||||
@@ -2088,9 +2312,28 @@ EOF;
|
||||
$needToRebuild = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch cached CSS data
|
||||
// Fetch cached CSS data - need to add parent tree and select parent css first
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
/* Do we need a parent? */
|
||||
$setData = $this->fetchSkinData( $setID );
|
||||
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
/* Allow parent data to be overwritten by child data */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ',', $setData['_parentTree'] ) . ')' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch() )
|
||||
{
|
||||
$row['cache_content'] = md5( $row['cache_content'] );
|
||||
$cachedCSS[ $row['cache_set_id'] ][ $row['cache_value_1'] ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ',', $childTree ) . ')' ) );
|
||||
@@ -2120,6 +2363,12 @@ EOF;
|
||||
$thisCSS[ $row['css_set_id'] ][ $row['css_group'] ] = $row;
|
||||
}
|
||||
|
||||
/* Add in parent skins */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
$childTree = array_merge( $childTree, $setData['_parentTree'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// First off, any caches missing?
|
||||
//-----------------------------------------
|
||||
@@ -2198,10 +2447,34 @@ EOF;
|
||||
/* This CSS inherits our skin set, so recache */
|
||||
$needToRebuild[ $_setID ][ $group ] = 1;
|
||||
}
|
||||
|
||||
/* Now lets see if there are any parent CSS that need to be added */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
foreach( $setData['_parentTree'] as $id )
|
||||
{
|
||||
if ( $cacheData['cache_key_3'] == 'setBy' && $cacheData['cache_value_3'] == $id )
|
||||
{
|
||||
/* Add to current set id */
|
||||
$needToRebuild[ $setID ][ $group ] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally, we don't want to recache parents so remove them */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
foreach( $setData['_parentTree'] as $id )
|
||||
{
|
||||
if ( is_array( $needToRebuild[ $id ] ) )
|
||||
{
|
||||
unset( $needToRebuild[ $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_cssNeedToRebuildArray[ $setID ] = $needToRebuild;
|
||||
|
||||
|
||||
Reference in new issue
Block a user