Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1 +1,10 @@
|
||||
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Skin Caching Functions
|
||||
* Last Updated: $Date: 2009-10-01 10:02:08 -0400 (Thu, 01 Oct 2009) $
|
||||
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: bfarber $
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since 9th July 2008
|
||||
* @version $Revision: 5190 $
|
||||
* @version $Revision: 6975 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -91,7 +93,14 @@ class skinCaching extends skinFunctions
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift( $skinSetData['_childTree'], 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove current caches
|
||||
@@ -105,6 +114,13 @@ class skinCaching extends skinFunctions
|
||||
|
||||
foreach( $skinSetData['_childTree'] as $_setID )
|
||||
{
|
||||
/* Bit of a fiddle here... */
|
||||
if ( ! is_numeric( $setID ) AND $_setID == 0 )
|
||||
{
|
||||
/* We mean a master set, then */
|
||||
$_setID = $setID;
|
||||
}
|
||||
|
||||
$__replacements = $this->fetchReplacements( $_setID );
|
||||
$_replacements = array();
|
||||
|
||||
@@ -119,6 +135,8 @@ class skinCaching extends skinFunctions
|
||||
'cache_set_id' => $_setID,
|
||||
'cache_type' => 'replacements',
|
||||
'cache_content' => serialize( $_replacements ) ) );
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -140,6 +158,12 @@ class skinCaching extends skinFunctions
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
$skinSetData['set_image_dir'] = ( $skinSetData['set_image_dir'] ) ? $skinSetData['set_image_dir'] : 'master';
|
||||
|
||||
/* These are not always set up correctly */
|
||||
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinSetData['set_image_dir'];
|
||||
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
|
||||
|
||||
/* Remove dead template caches */
|
||||
$this->removeDeadPHPCaches( $setID );
|
||||
|
||||
@@ -165,8 +189,15 @@ class skinCaching extends skinFunctions
|
||||
$groupTitles = $this->fetchTemplates( $_setID, 'groupNames' );
|
||||
$allHooks = $this->fetchSkinHooks();
|
||||
|
||||
/* Update DB row */
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => time() ), 'set_id=' . intval( $_setID ) );
|
||||
|
||||
foreach ( $groupTitles as $name => $group )
|
||||
{
|
||||
/* Separated $out into two variables, needed to build the sections independently to fix bug #21574 */
|
||||
$fileHead = '';
|
||||
$fileBody = '';
|
||||
|
||||
//-----------------------------------------
|
||||
// Skip if we're only updating one group..
|
||||
//-----------------------------------------
|
||||
@@ -179,8 +210,8 @@ class skinCaching extends skinFunctions
|
||||
}
|
||||
}
|
||||
|
||||
$out = "class {$group['template_group']}_{$_setID} {\n\n";
|
||||
$out .= <<<EOF
|
||||
$fileHead = "class {$group['template_group']}_{$_setID} {\n\n";
|
||||
$fileHead .= <<<EOF
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
@@ -196,21 +227,37 @@ function __construct( ipsRegistry \$registry )
|
||||
\$this->memberData =& \$this->registry->member()->fetchMemberData();
|
||||
\$this->cache = \$this->registry->cache();
|
||||
\$this->caches =& \$this->registry->cache()->fetchCaches();
|
||||
}
|
||||
|
||||
EOF;
|
||||
|
||||
$templates = $this->fetchTemplates( $_setID, 'groupTemplates', $group['template_group'] );
|
||||
|
||||
|
||||
foreach ($templates as $func_name => $data )
|
||||
{
|
||||
$this->registry->templateEngine->setWorkingGroup( $group['template_group'] );
|
||||
|
||||
$out .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
|
||||
$fileBody .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
|
||||
}
|
||||
|
||||
$out .= "\n\n}";
|
||||
//-----------------------------------------
|
||||
// Function Hooks
|
||||
//------------------------------------------
|
||||
$funcHooks = '$this->_funcHooks = array();' . "\n";
|
||||
|
||||
if( is_array( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] ) )
|
||||
{
|
||||
foreach( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] as $func_name => $hookIds )
|
||||
{
|
||||
if( is_array( $hookIds ) && count( $hookIds ) )
|
||||
{
|
||||
$funcHooks .= "\$this->_funcHooks['{$func_name}'] = array(".implode( ',', $hookIds ).");\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fileHead .= "\n\n{$funcHooks}\n\n}\n\n";
|
||||
$out = $fileHead . $fileBody . "\n}\n";
|
||||
|
||||
/* This would be better off within the templateEngine really cos $out now contains the entire class */
|
||||
$out = $this->stripUnneededHooks( $out, $allHooks[ $group['template_group'] ] );
|
||||
|
||||
@@ -226,6 +273,7 @@ EOF;
|
||||
'cache_key_1' => 'group',
|
||||
'cache_value_1' => $group['template_group'],
|
||||
'cache_content' => $out ) );
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Write to the flatfile
|
||||
@@ -235,7 +283,7 @@ EOF;
|
||||
$start .= "/*--------------------------------------------------*/\n";
|
||||
$start .= "/* FILE GENERATED BY INVISION POWER BOARD 3 */\n";
|
||||
$start .= "/* CACHE FILE: Skin set id: {$_setID} */\n";
|
||||
$start .= "/* CACHE FILE: Generated: ".gmdate( "D, d M Y H:i:s \G\M\T" )." */\n";
|
||||
$start .= "/* CACHE FILE: Generated: ".gmdate( 'D, d M Y H:i:s \G\M\T' )." */\n";
|
||||
$start .= "/* DO NOT EDIT DIRECTLY - THE CHANGES WILL NOT BE */\n";
|
||||
$start .= "/* WRITTEN TO THE DATABASE AUTOMATICALLY */\n";
|
||||
$start .= "/*--------------------------------------------------*/\n\n";
|
||||
@@ -249,11 +297,16 @@ EOF;
|
||||
{
|
||||
$this->_writePHPTemplate( $_setID, $group['template_group'], $start.$out.$end );
|
||||
}
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
|
||||
}
|
||||
|
||||
$this->_addMessage( "HTML шаблоны обновлены... (Стиль: $_setID)" );
|
||||
$this->_addMessage( sprintf( $this->lang->words['finishedcachinghtml'], $_setID ) );
|
||||
}
|
||||
|
||||
/* Rebuild skin cache */
|
||||
$this->rebuildSkinSetsCache();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -273,7 +326,7 @@ EOF;
|
||||
$phpKeep = array();
|
||||
$phpThrow = array();
|
||||
$phpUnlink = array();
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Get skin set data
|
||||
//-----------------------------------------
|
||||
@@ -310,8 +363,7 @@ EOF;
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => 'cache_type=\'phptemplate\'',
|
||||
'order' => 'cache_set_id ASC' ) );
|
||||
'where' => "cache_type='phptemplate' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
@@ -338,7 +390,7 @@ EOF;
|
||||
|
||||
foreach( $phpKeep as $_setID => $data )
|
||||
{
|
||||
$_path = IPS_CACHE_PATH.'cache/skin_cache/cacheid_' . $_setID;
|
||||
$_path = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $_setID;
|
||||
|
||||
if ( is_dir( $_path ) )
|
||||
{
|
||||
@@ -433,8 +485,7 @@ EOF;
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => 'cache_type=\'css\'',
|
||||
'order' => 'cache_set_id ASC' ) );
|
||||
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
@@ -486,6 +537,8 @@ EOF;
|
||||
}
|
||||
} catch ( Exception $e ) {}
|
||||
}
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -546,7 +599,10 @@ EOF;
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch CSS that needs to be rebuilt
|
||||
@@ -639,7 +695,10 @@ EOF;
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_childTree'], $setID );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch CSS that needs to be rebuilt
|
||||
@@ -655,7 +714,8 @@ EOF;
|
||||
|
||||
foreach( array_keys( $needToRebuild ) as $_setID )
|
||||
{
|
||||
$_css = $this->fetchCSS( $_setID );
|
||||
$_css = $this->fetchCSS( $_setID );
|
||||
$_skinSetData = $this->fetchSkinData( $_setID );
|
||||
|
||||
foreach( $_css as $name => $css )
|
||||
{
|
||||
@@ -685,8 +745,12 @@ EOF;
|
||||
'cache_value_5' => $css['css_attributes'],
|
||||
'cache_key_6' => 'modules',
|
||||
'cache_value_6' => $css['css_modules'],
|
||||
'cache_content' => $this->_CSS_fromDBtoFile( $css['css_content'], $skinSetData ) ) );
|
||||
'cache_content' => $this->_CSS_fromDBtoFile( $css['css_content'], $_skinSetData )
|
||||
//'cache_content' => $css['css_content']
|
||||
) ) ;
|
||||
}
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -725,6 +789,8 @@ EOF;
|
||||
foreach( $cssSkinCollections as $setID => $data )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_css_groups' => serialize( $cssSkinCollections[ $setID ] ) ), 'set_id='. $setID );
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setID, array(), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -740,13 +806,18 @@ EOF;
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function rebuildMasterReplacements()
|
||||
public function rebuildMasterReplacements( $setId=0 )
|
||||
{
|
||||
/* Set directory */
|
||||
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
|
||||
$dir = IPS_CACHE_PATH . 'cache/skin_cache/' . $this->remapData['templates'][ $setId ];
|
||||
$messages = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Master file exists?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' ) )
|
||||
if ( ! file_exists( $dir . '/_replacements.inc' ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -755,15 +826,19 @@ EOF;
|
||||
// Remove current CSS
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->delete( 'skin_replacements', "replacement_set_id=0" );
|
||||
if ( ! is_numeric( $setId ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_master_key='" . $setId . "'" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab file
|
||||
//-----------------------------------------
|
||||
|
||||
require( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' );
|
||||
$replacements = array();
|
||||
require( $dir . '/_replacements.inc' );
|
||||
|
||||
if ( ! count( $replacements ) )
|
||||
if ( !is_array($replacements) || !count($replacements) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -771,13 +846,18 @@ EOF;
|
||||
/* Insert... */
|
||||
foreach( $replacements as $k => $v )
|
||||
{
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
|
||||
'replacement_content' => $v,
|
||||
'replacement_set_id' => 0,
|
||||
'replacement_added_to' => 0 ) );
|
||||
$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_added_to' => 0 ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -793,6 +873,7 @@ EOF;
|
||||
public function rebuildMasterCSS( $setId=0 )
|
||||
{
|
||||
/* Set directory */
|
||||
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
|
||||
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $this->remapData['css'][ $setId ];
|
||||
$messages = array();
|
||||
$css = array();
|
||||
@@ -813,18 +894,22 @@ EOF;
|
||||
throw new Exception( "CANNOT_READ" );
|
||||
}
|
||||
|
||||
/* Fetch all CSS bits. NOW */
|
||||
if ( $setId > 0 )
|
||||
/* Remove current CSS... */
|
||||
if ( is_numeric( $setId ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_css', 'css_set_id=' . $setId );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->delete( 'skin_css', 'css_master_key=\'' . $setId . '\'' );
|
||||
}
|
||||
|
||||
/* Fetch all template bits. NOW */
|
||||
if ( is_numeric( $setId ) AND $setId > 0 )
|
||||
{
|
||||
$css = $this->fetchCSS( $setId );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove current CSS
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->delete( 'skin_css', "css_set_id=" . $setId );
|
||||
|
||||
//-----------------------------------------
|
||||
// Recurse over the directory
|
||||
//-----------------------------------------
|
||||
@@ -845,8 +930,8 @@ EOF;
|
||||
|
||||
/* Encode */
|
||||
$cssContent = IPSText::encodeForXml( $cssContent );
|
||||
|
||||
$messages[] = "Imported " . $cssName;
|
||||
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
@@ -858,13 +943,14 @@ EOF;
|
||||
}
|
||||
|
||||
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
|
||||
'css_set_id' => $setId,
|
||||
'css_added_to' => $_css_added_to,
|
||||
'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 ) );
|
||||
}
|
||||
@@ -873,10 +959,12 @@ EOF;
|
||||
} catch ( Exception $e ) {}
|
||||
|
||||
/* Recache */
|
||||
if ( $setId )
|
||||
if ( is_numeric( $setId ) AND $setId )
|
||||
{
|
||||
$this->rebuildCSS( $setId );
|
||||
$this->removeDeadCSSCaches( $setId );
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
|
||||
}
|
||||
|
||||
return $messages;
|
||||
@@ -901,7 +989,7 @@ EOF;
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$setId = intval( $setId );
|
||||
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
|
||||
$script_token = 0;
|
||||
$script_jump = 0;
|
||||
$skin_dir = IPS_CACHE_PATH . "cache/skin_cache/" . $this->remapData['templates'][ $setId ];
|
||||
@@ -926,10 +1014,17 @@ EOF;
|
||||
}
|
||||
|
||||
/* Remove current templates... */
|
||||
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
|
||||
if ( is_numeric( $setId ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->delete( 'skin_templates', 'template_master_key=\'' . $setId . '\'' );
|
||||
}
|
||||
|
||||
/* Fetch all template bits. NOW */
|
||||
if ( $setId > 0 )
|
||||
if ( is_numeric( $setId ) AND $setId > 0 )
|
||||
{
|
||||
$templates = $this->fetchTemplates( $setId, 'allTemplates' );
|
||||
}
|
||||
@@ -937,7 +1032,7 @@ EOF;
|
||||
/* Loop through the directory */
|
||||
try
|
||||
{
|
||||
foreach( new DirectoryIterator( $skin_dir ) as $file )
|
||||
foreach( new DirectoryIterator( $skin_dir ) as $file )
|
||||
{
|
||||
if ( ! $file->isDot() AND ! $file->isDir() )
|
||||
{
|
||||
@@ -950,7 +1045,7 @@ EOF;
|
||||
|
||||
if ( ! $fdata )
|
||||
{
|
||||
$messages[] = "Не удалось открыть файл $_name, пропускаем...";
|
||||
$messages[] = sprintf( $this->lang->words['couldnotopenfile'], $_name );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -959,7 +1054,7 @@ EOF;
|
||||
|
||||
if ( ! preg_match( "/\n/", $fdata ) )
|
||||
{
|
||||
$messages[] = "Не удалось найти содержимое в файле $_name, пропускаем...";
|
||||
$messages[] = sprintf( $this->lang->words['couldnotfindlineeol'], $_name );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -992,7 +1087,7 @@ EOF;
|
||||
|
||||
if ( $script_token AND $script_jump == 0 )
|
||||
{
|
||||
if ( preg_match( "#<if test=[\'\"]#", $f ) )
|
||||
if ( preg_match( '#<if test=[\'\"]#', $f ) )
|
||||
{
|
||||
$script_jump = 1;
|
||||
$script_token = 0;
|
||||
@@ -1014,7 +1109,7 @@ EOF;
|
||||
|
||||
if ( ! $script_token )
|
||||
{
|
||||
if ( preg_match( "/^function\s*([\w\_]+)\s*\((.*)\)/i", $f, $matches ) )
|
||||
if ( preg_match( '/^function\s*([\w\_]+)\s*\((.*)\)/i', $f, $matches ) )
|
||||
{
|
||||
$functions[ $matches[1] ] = '';
|
||||
$config[ $matches[1] ] = $matches[2];
|
||||
@@ -1028,9 +1123,9 @@ EOF;
|
||||
else
|
||||
{
|
||||
# Make JS safe (UBE - Ugly, but effective)
|
||||
$f = preg_replace( "#if\s+?\(#is" , "i~f~(~" , $f );
|
||||
$f = str_ireplace( "else" , "e~lse~" , $f );
|
||||
$f = preg_replace( "#else\s+?if#is", "e~lse~i~f", $f );
|
||||
$f = preg_replace( '#if\s+?\(#is' , "i~f~(~" , $f );
|
||||
$f = str_ireplace( 'else' , "e~lse~" , $f );
|
||||
$f = preg_replace( '#else\s+?if#is', "e~lse~i~f", $f );
|
||||
}
|
||||
|
||||
if ( $flag )
|
||||
@@ -1061,14 +1156,15 @@ EOF;
|
||||
$content = IPSText::encodeForXml( $content );
|
||||
|
||||
/* Build array */
|
||||
$array = array( 'template_set_id' => $setId,
|
||||
'template_group' => $name,
|
||||
'template_content' => $content,
|
||||
'template_name' => $fname,
|
||||
'template_data' => trim($config[$fname]),
|
||||
'template_updated' => time(),
|
||||
'template_removable' => ( $setId ) ? 1 : 0,
|
||||
'template_added_to' => $setId );
|
||||
$array = array( 'template_set_id' => $setId,
|
||||
'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 ) );
|
||||
|
||||
if ( ! $setId OR ! $templates[ $name ][ strtolower( $fname ) ] )
|
||||
{
|
||||
@@ -1090,25 +1186,51 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
$messages[] = "$name добавлен (Шаблонов добавлено " . $added . "; обновлено " . $updated . ")";
|
||||
$messages[] = sprintf( $this->lang->words['tplbitimported'], $name, $added, $updated );
|
||||
$functions = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {}
|
||||
/* Recache */
|
||||
if ( $setId )
|
||||
if ( is_numeric( $setId ) AND $setId )
|
||||
{
|
||||
$this->rebuildPHPTemplates( $setId );
|
||||
$this->removeDeadPHPCaches( $setId );
|
||||
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
$messages[] = "Завершено обновление шаблонов из PHP кеша.";
|
||||
$messages[] = $this->lang->words['cpltrebuildfromcaches'];
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as needing recache
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetForRecache( $setId=null )
|
||||
{
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ), 'set_id=' . intval( $setId ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ) );
|
||||
}
|
||||
|
||||
/* Build cache */
|
||||
$this->rebuildSkinSetsCache();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild skinsets cache in the cache_store table
|
||||
*
|
||||
@@ -1129,7 +1251,7 @@ EOF;
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'order' => 'set_parent_id, set_id' ) );
|
||||
'order' => 'set_order' ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch() )
|
||||
@@ -1235,7 +1357,7 @@ EOF;
|
||||
|
||||
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
|
||||
|
||||
$messages[] = "Импортирован " . $cssName;
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
@@ -1280,6 +1402,11 @@ EOF;
|
||||
throw new Exception( 'IN_DEV_OFF' );
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $id ) )
|
||||
{
|
||||
$id = $this->fetchSetIdByKey( $id );
|
||||
}
|
||||
|
||||
$setData = $this->fetchSkinData( $id );
|
||||
|
||||
$path = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
|
||||
@@ -1312,11 +1439,11 @@ EOF;
|
||||
|
||||
if ( @file_put_contents( $path . '/' . $data['css_group'] . '.css', $_block . $this->_CSS_fromDBtoFile( $data['css_content'], $setData ) ) )
|
||||
{
|
||||
$msgs[] = "Записан: " . $data['css_group'] . '.css';
|
||||
$msgs[] = $this->lang->words['basicwrittenpre'] . $data['css_group'] . '.css';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msgs[] = "Ошибка: Не удалось записать " . $data['css_group'] . '.css';
|
||||
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $data['css_group'] . '.css';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1324,6 +1451,81 @@ EOF;
|
||||
return $msgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out replacements in the master format
|
||||
* IN_DEV tool, currently.
|
||||
*
|
||||
* @access public
|
||||
* @param int Skin ID to write out
|
||||
* @param string Directory to write into. Directory must be in /public/style_css/
|
||||
* @return array Array of messages
|
||||
* Exception Codes:
|
||||
* IN_DEV_OFF IN_DEV constant is not enabled
|
||||
* NO_SUCH_SKIN_SET Skin set of $id does not exist
|
||||
* DIR_DOES_NOT_EXIST Directory does not exist in /cache/skin_cache
|
||||
* CANNOT_WRITE_DIR Directory cannot be written into
|
||||
*/
|
||||
public function writeMasterSkinReplacements( $id, $dir )
|
||||
{
|
||||
/* Checkin' */
|
||||
if ( ! IN_DEV )
|
||||
{
|
||||
throw new Exception( 'IN_DEV_OFF' );
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $id ) )
|
||||
{
|
||||
$id = $this->fetchSetIdByKey( $id );
|
||||
}
|
||||
|
||||
$setData = $this->fetchSkinData( $id );
|
||||
|
||||
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
|
||||
$msgs = array();
|
||||
|
||||
if ( ! isset( $setData['set_id'] ) )
|
||||
{
|
||||
throw new Exception( 'NO_SUCH_SKIN_SET' );
|
||||
}
|
||||
|
||||
if ( ! is_dir( $path ) )
|
||||
{
|
||||
throw new Exception( 'DIR_DOES_NOT_EXIST' );
|
||||
}
|
||||
|
||||
if ( ! is_writeable( $path ) )
|
||||
{
|
||||
throw new Exception( 'CANNOT_WRITE_DIR' );
|
||||
}
|
||||
|
||||
/* Fetch Replacements */
|
||||
$replacements = $this->fetchReplacements( $id );
|
||||
|
||||
/* Write it.. */
|
||||
if ( is_array( $replacements ) )
|
||||
{
|
||||
$content = "<" . "?php\n\n\$replacements = array(\n\n";
|
||||
|
||||
foreach( $replacements as $k => $data )
|
||||
{
|
||||
$content .= "\n'" . $k . "' => \"" . str_replace( '"', '\\"', $data['replacement_content'] ) . '",';
|
||||
}
|
||||
|
||||
$content .= "\n);\n\n?>";
|
||||
|
||||
if ( @file_put_contents( $path . '/_replacements.inc', $content ) )
|
||||
{
|
||||
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/_replacements.inc';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/_replacements.inc';
|
||||
}
|
||||
}
|
||||
|
||||
return $msgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out skin templates in the master format
|
||||
* IN_DEV tool, currently.
|
||||
@@ -1346,6 +1548,11 @@ EOF;
|
||||
throw new Exception( 'IN_DEV_OFF' );
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $id ) )
|
||||
{
|
||||
$id = $this->fetchSetIdByKey( $id );
|
||||
}
|
||||
|
||||
$setData = $this->fetchSkinData( $id );
|
||||
|
||||
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
|
||||
@@ -1386,17 +1593,17 @@ EOF;
|
||||
|
||||
if ( ! @file_put_contents( $path . '/' . $_file, $_content ) )
|
||||
{
|
||||
$msgs[] = "Ошибка: Не удалось записать: " . $path . '/' . $_file;
|
||||
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/' . $_file;
|
||||
}
|
||||
else
|
||||
{
|
||||
@chmod( $path . '/' . $_file, 0777 );
|
||||
$msgs[] = "Записан: " . $path . '/' . $_file;
|
||||
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/' . $_file;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$msgs[] = "Ошибка: нечего записывать в файл " . $path . '/' . $_file;
|
||||
$msgs[] = $this->lang->words['basicnothingtowritepre'] . $path . '/' . $_file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1424,6 +1631,11 @@ EOF;
|
||||
$block[] = "<css_app>" . $data['css_app'] . "</css_app>";
|
||||
}
|
||||
|
||||
if ( isset( $data['css_modules'] ) )
|
||||
{
|
||||
$block[] = "<css_modules>" . $data['css_modules'] . "</css_modules>";
|
||||
}
|
||||
|
||||
if ( isset( $data['css_app_hide'] ) )
|
||||
{
|
||||
$block[] = "<css_app_hide>" . $data['css_app_hide'] . "</css_app_hide>";
|
||||
@@ -1526,36 +1738,36 @@ EOF;
|
||||
{
|
||||
$good_to_go = 1;
|
||||
|
||||
if ( is_writeable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
|
||||
if ( is_writeable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
|
||||
{
|
||||
$good_to_go = 1;
|
||||
|
||||
if ( ! is_dir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) )
|
||||
if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) )
|
||||
{
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 ) )
|
||||
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, 0777 ) )
|
||||
{
|
||||
$this->_addErrorMessage( "Ошибка! не удалось создать: public/style_css/css_{$setID}/" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['couldnotcreatecssdir'], $setID ) );
|
||||
return $this->_errorMsgs;
|
||||
}
|
||||
else
|
||||
{
|
||||
@file_put_contents( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
|
||||
@chmod( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
|
||||
@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 );
|
||||
$good_to_go = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) !== TRUE )
|
||||
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) !== TRUE )
|
||||
{
|
||||
$this->_addErrorMessage( "public/style_css/css_{$setID}/ not writeable" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['cssdirnotwritaaaable'], $setID ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
else if ( file_exists( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
else if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
{
|
||||
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
|
||||
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
|
||||
{
|
||||
$this->_addErrorMessage( "public/style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
else
|
||||
@@ -1571,13 +1783,13 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . PUBLIC_DIRECTORY . "/style_css нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotwreite'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_addErrorMessage( "Безопасный режим: Пропускаем создание CSS кешей" );
|
||||
$this->_addErrorMessage( $this->lang->words['safemodeenablednow'] );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
|
||||
@@ -1587,17 +1799,17 @@ EOF;
|
||||
|
||||
if ( $good_to_go )
|
||||
{
|
||||
if ( $FH = @fopen( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
|
||||
if ( $FH = @fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
|
||||
{
|
||||
fwrite( $FH, $css_content, strlen($css_content) );
|
||||
fclose( $FH );
|
||||
@chmod( IPS_CACHE_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', 0777 );
|
||||
|
||||
$this->_addMessage( "Записан skin_cache/css_{$setID}/{$css_group}.css" );
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre']. "skin_cache/css_{$setID}/{$css_group}.css" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_addErrorMessage( "style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1632,7 +1844,7 @@ EOF;
|
||||
{
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 ) )
|
||||
{
|
||||
$this->_addErrorMessage( "Ошибка! не удалось создать: cache/skin_cache/cacheid_{$setID}/" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplatew'], $setID ) );
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -1648,7 +1860,7 @@ EOF;
|
||||
{
|
||||
if ( IPSLib::isWritable( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) !== TRUE )
|
||||
{
|
||||
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
else
|
||||
@@ -1664,7 +1876,7 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . "cache/skin_cache нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplsafe'], IPS_CACHE_PATH ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1680,11 +1892,11 @@ EOF;
|
||||
fclose( $FH );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', 0777 );
|
||||
|
||||
$this->_addMessage( "Записан skin_cache/cacheid_{$setID}/{$groupName}.php" );
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1711,7 +1923,7 @@ EOF;
|
||||
}
|
||||
|
||||
/* Remove all hooks */
|
||||
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
|
||||
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
|
||||
|
||||
/* Restore saved hooks */
|
||||
foreach( $hooks as $hook )
|
||||
@@ -1725,7 +1937,7 @@ EOF;
|
||||
else
|
||||
{
|
||||
/* No hooks, so remove all */
|
||||
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
|
||||
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
|
||||
}
|
||||
|
||||
return $html;
|
||||
@@ -1752,7 +1964,7 @@ EOF;
|
||||
/* Fetch the data block */
|
||||
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
|
||||
{
|
||||
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
|
||||
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
|
||||
|
||||
if ( $match[0] )
|
||||
{
|
||||
@@ -1788,7 +2000,7 @@ EOF;
|
||||
/* Fetch the data block */
|
||||
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
|
||||
{
|
||||
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
|
||||
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
|
||||
|
||||
if ( $match[0] )
|
||||
{
|
||||
@@ -1797,8 +2009,8 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
$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 );
|
||||
$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 );
|
||||
|
||||
return $cssContent;
|
||||
}
|
||||
@@ -1814,6 +2026,10 @@ EOF;
|
||||
{
|
||||
$skinData['set_image_dir'] = ( $skinData['set_image_dir'] ) ? $skinData['set_image_dir'] : 'master';
|
||||
|
||||
/* These are not always set up correctly */
|
||||
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinData['set_image_dir'];
|
||||
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up style images stuff
|
||||
//-----------------------------------------
|
||||
@@ -1832,7 +2048,7 @@ EOF;
|
||||
$this->settings['ipb_img_url'] .= '/';
|
||||
}
|
||||
|
||||
$cssContent = preg_replace( "#url\(('|\")?\.\./\.\./style_images/#", "url(\\1{$this->settings['ipb_img_url']}/style_images/", $cssContent );
|
||||
$cssContent = preg_replace( '#url\((\'|\")?\.\./\.\./style_images/#', "url(\\1" . $this->settings['ipb_img_url'] . "/style_images/", $cssContent );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1867,7 +2083,9 @@ EOF;
|
||||
return $this->_cssNeedToRebuildArray[ $setID ];
|
||||
}
|
||||
|
||||
$needToRebuild = array();
|
||||
$cachedCSS = array();
|
||||
$thisCSS = array();
|
||||
$needToRebuild = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch cached CSS data
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2009-12-07 21:57:46 -0500 (Mon, 07 Dec 2009) $
|
||||
* Last Updated: $Date: 2010-10-13 14:43:52 -0400 (Wed, 13 Oct 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: bfarber $
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 5529 $
|
||||
* @version $Revision: 6972 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -81,6 +83,12 @@ class skinFunctions
|
||||
*/
|
||||
public $remapData = array();
|
||||
|
||||
/**
|
||||
* Set cache
|
||||
* @var private
|
||||
*/
|
||||
private $_seenSet = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -102,6 +110,9 @@ class skinFunctions
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->caches =& $this->registry->cache()->fetchCaches();
|
||||
$this->lang = $this->registry->class_localization;
|
||||
|
||||
$this->registry->class_localization->loadLanguageFile( array( 'admin_templates' ), 'core' );
|
||||
|
||||
//-----------------------------------------
|
||||
// IN_DEV on?
|
||||
@@ -137,6 +148,111 @@ class skinFunctions
|
||||
return $this->recursiveTiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch highest order
|
||||
*
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function fetchHighestSetPosition()
|
||||
{
|
||||
$bill = $this->DB->buildAndFetch( array( 'select' => 'MAX(set_order) as and_ted',
|
||||
'from' => 'skin_collections' ) );
|
||||
|
||||
|
||||
/* Excellent! (guitar solo) */
|
||||
return intval( $bill['and_ted'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use the merge system?
|
||||
*
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function canUseMergeSystem()
|
||||
{
|
||||
$c = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as ount',
|
||||
'from' => 'skin_templates_previous' ) );
|
||||
|
||||
return ( $c['ount'] ) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch master template keys
|
||||
*
|
||||
* @access public
|
||||
* @return arraya
|
||||
*/
|
||||
public function fetchMasterKeys()
|
||||
{
|
||||
if ( is_array( $this->remapData ) AND is_array( $this->remapData['masterKeys'] ) )
|
||||
{
|
||||
return $this->remapData['masterKeys'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$REMAP = array();
|
||||
require( DOC_IPS_ROOT_PATH . 'cache/skin_cache/masterMap.php' );
|
||||
|
||||
if ( is_array($REMAP) && count($REMAP) )
|
||||
{
|
||||
$this->remapData = array( 'masterKeys' => $REMAP['masterKeys'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->remapData['masterKeys'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a skin set ID based on a key
|
||||
* @param string $key
|
||||
*/
|
||||
public function fetchSetIdByKey( $key )
|
||||
{
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
if ( in_array( $key, $masterKeys ) )
|
||||
{
|
||||
/* Default master keys are always 0 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( ! $this->_seenSet[ 'k-' . $key ] )
|
||||
{
|
||||
$this->_seenSet[ 'k-' . $key ] = $this->DB->buildAndFetch( array( 'select' => 'set_id',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_key=\'' . addslashes( $key ) . '\'' ) );
|
||||
}
|
||||
|
||||
return ( $this->_seenSet[ 'k-' . $key ]['set_id'] ) ? $this->_seenSet[ 'k-' . $key ]['set_id'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a skin set key based on a id
|
||||
* @param string $key
|
||||
*/
|
||||
public function fetchSetKeyById( $id )
|
||||
{
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
if ( $id == 0 )
|
||||
{
|
||||
/* Default master keys are always 0 */
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! $this->_seenSet[ 'i-' . $id ] )
|
||||
{
|
||||
$this->_seenSet[ 'i-' . $id ] = $this->DB->buildAndFetch( array( 'select' => 'set_key',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_id=' . intval( $id ) ) );
|
||||
}
|
||||
|
||||
return ( $this->_seenSet[ 'i-' . $id ]['set_key'] ) ? $this->_seenSet[ 'i-' . $id ]['set_key'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search template bits
|
||||
*
|
||||
@@ -201,7 +317,9 @@ class skinFunctions
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
$_templateCount = 0;
|
||||
|
||||
/* You may continue... */
|
||||
foreach( $_templates as $_group => $_gdata )
|
||||
{
|
||||
@@ -380,7 +498,9 @@ class skinFunctions
|
||||
$this->remapData = $this->registry->output->buildRemapData();
|
||||
}
|
||||
|
||||
$_dir = $this->remapData['templates'][ $id ];
|
||||
$_id = ( $id == 0 ) ? $this->remapData['inDevDefault'] : $id;
|
||||
|
||||
$_dir = $this->remapData['templates'][ $_id ];
|
||||
|
||||
if( ! file_exists(IPS_CACHE_PATH."cache/skin_cache/" . $_dir . "/".$name.".php") )
|
||||
{
|
||||
@@ -440,7 +560,7 @@ class skinFunctions
|
||||
}
|
||||
|
||||
/* Root skin? */
|
||||
if ( in_array( $setID, array_values( $this->remapData['export'] ) ) )
|
||||
if ( in_array( $setID, $this->remapData['masterKeys'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -492,18 +612,36 @@ class skinFunctions
|
||||
$this->DB->delete( 'skin_url_mapping', 'map_skin_set_id=' . $setID );
|
||||
|
||||
/* Delete CSS Files */
|
||||
$this->registry->adminFunctions->removeDirectory( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
|
||||
$this->registry->adminFunctions->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
|
||||
|
||||
/* Delete PHP Cache Files */
|
||||
$this->registry->adminFunctions->removeDirectory( IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID );
|
||||
|
||||
|
||||
/* Delete any diff/merge sessions */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_merge_session',
|
||||
'where' => 'merge_set_id=' . $setID ) );
|
||||
|
||||
$o = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $o ) )
|
||||
{
|
||||
/* Delete 'em */
|
||||
$this->DB->delete('skin_merge_session', 'merge_id=' . $row['merge_id'] );
|
||||
$this->DB->delete('skin_merge_changes', 'change_session_id=' . $row['merge_id'] );
|
||||
}
|
||||
|
||||
/* Rebuild Tree Information */
|
||||
$this->rebuildTreeInformation();
|
||||
|
||||
/* Rebuild Skin Set Caches */
|
||||
$this->rebuildSkinSetsCache();
|
||||
$this->rebuildURLMapCache();
|
||||
|
||||
if ( class_exists( 'skinCaching' ) )
|
||||
{
|
||||
$this->rebuildSkinSetsCache();
|
||||
$this->rebuildURLMapCache();
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setID, array(), 1 );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -540,10 +678,47 @@ class skinFunctions
|
||||
{
|
||||
$_parents = $this->recursiveTiers->fetchItemParents( $row['set_id'] );
|
||||
$_children = $this->recursiveTiers->fetchItemChildren( $row['set_id'] );
|
||||
|
||||
|
||||
$this->DB->update( 'skin_collections', array( 'set_parent_array' => serialize( ( is_array( $_parents ) ) ? $_parents : array() ),
|
||||
'set_child_array' => serialize( ( is_array( $_children ) ) ? $_children : array() ) ), 'set_id=' . $row['set_id'] );
|
||||
|
||||
|
||||
/* Reset master key - parents */
|
||||
if( count($_parents) AND $row['set_id'] )
|
||||
{
|
||||
$_p = $_parents;
|
||||
$_id = array_pop( $_p );
|
||||
$rootParent = $this->fetchSkinData( $_id, true );
|
||||
|
||||
/* If no parent, we must be a parent, then */
|
||||
if ( ! $rootParent['set_id'] )
|
||||
{
|
||||
$rootParent = $this->fetchSkinData( $setID, true );
|
||||
}
|
||||
|
||||
$this->DB->update( 'skin_collections', array( 'set_master_key' => ( $rootParent['set_master_key'] ) ? $rootParent['set_master_key'] : 'root' ), 'set_id IN (' . implode( ',', $_parents ) . ')' );
|
||||
}
|
||||
|
||||
/* Reset master key - children */
|
||||
if( count($_children) AND $row['set_id'] )
|
||||
{
|
||||
if ( ! is_array( $rootParent ) )
|
||||
{
|
||||
$_p = $_parents;
|
||||
$_id = array_pop( $_p );
|
||||
$rootParent = $this->fetchSkinData( $_id, true );
|
||||
|
||||
/* If no parent, we must be a parent, then */
|
||||
if ( ! $rootParent['set_id'] )
|
||||
{
|
||||
$rootParent = $this->fetchSkinData( $setID, true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->DB->update( 'skin_collections', array( 'set_master_key' => ( $rootParent['set_master_key'] ) ? $rootParent['set_master_key'] : 'root' ), 'set_id IN (' . implode( ',', $_children ) . ')' );
|
||||
}
|
||||
|
||||
if( count($_parents) AND $setID )
|
||||
{
|
||||
foreach( $_parents as $parent )
|
||||
@@ -552,7 +727,7 @@ class skinFunctions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -576,13 +751,35 @@ class skinFunctions
|
||||
*/
|
||||
public function fetchReplacements( $setID )
|
||||
{
|
||||
$replacements = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Try and get the skin from the cache
|
||||
//-----------------------------------------
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$replacements = array();
|
||||
|
||||
|
||||
/* Did we pass a master key? - all root skins are 0 */
|
||||
if ( ! is_numeric( $setID ) )
|
||||
{
|
||||
$skinSetData = array( 'set_id' => 0,
|
||||
'set_master_key' => $setID,
|
||||
'set_key' => $setID,
|
||||
'_isMaster' => 1,
|
||||
'_parentTree' => array(),
|
||||
'_childTree' => array(),
|
||||
'_userAgents' => array(),
|
||||
'_cssGroupsArray' => array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
}
|
||||
|
||||
/* Did we get a skin set? */
|
||||
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Push root ID onto the END of the parent array
|
||||
//-----------------------------------------
|
||||
@@ -593,8 +790,29 @@ class skinFunctions
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
}
|
||||
|
||||
/* We want to capture only this set's master bits */
|
||||
$where = ' AND ( ( replacement_set_id > 0 AND ( replacement_master_key=\'\' OR replacement_master_key IS NULL ) ) OR ( replacement_set_id=0 AND replacement_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
|
||||
|
||||
//-----------------------------------------
|
||||
// Push root ID onto the END of the parent array
|
||||
//-----------------------------------------
|
||||
|
||||
array_push( $skinSetData['_parentTree'], 0 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Geddit
|
||||
//-----------------------------------------
|
||||
@@ -603,7 +821,7 @@ class skinFunctions
|
||||
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
|
||||
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'replacement_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => "replacement_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
|
||||
'where' => "replacement_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
|
||||
'order' => 'replacement_key ASC, theorder DESC' ) );
|
||||
|
||||
$i = $this->DB->execute();
|
||||
@@ -809,7 +1027,7 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$replacementID = intval( $replacementID );
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch replacement data
|
||||
//-----------------------------------------
|
||||
@@ -887,14 +1105,33 @@ class skinFunctions
|
||||
*/
|
||||
public function fetchCSS( $setID, $parse=TRUE, $skipRemoved=TRUE )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Try and get the skin from the cache
|
||||
//-----------------------------------------
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$css = array();
|
||||
$skip = array();
|
||||
|
||||
$where = '';
|
||||
|
||||
/* Did we pass a master key? - all root skins are 0 */
|
||||
if ( ! is_numeric( $setID ) )
|
||||
{
|
||||
$skinSetData = array( 'set_id' => 0,
|
||||
'set_master_key' => $setID,
|
||||
'set_key' => $setID,
|
||||
'_isMaster' => 1,
|
||||
'_parentTree' => array(),
|
||||
'_childTree' => array(),
|
||||
'_userAgents' => array(),
|
||||
'_cssGroupsArray' => array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
}
|
||||
|
||||
/* Did we get a skin set? */
|
||||
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Push root ID onto the END of the parent array
|
||||
//-----------------------------------------
|
||||
@@ -905,7 +1142,13 @@ class skinFunctions
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
}
|
||||
|
||||
/* We want to capture only this set's master bits */
|
||||
$where = ' AND ( ( css_set_id > 0 AND ( css_master_key=\'\' OR css_master_key IS NULL ) ) OR ( css_set_id=0 AND css_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
|
||||
|
||||
//-----------------------------------------
|
||||
// Geddit
|
||||
@@ -915,7 +1158,7 @@ class skinFunctions
|
||||
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
|
||||
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'css_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
|
||||
'from' => 'skin_css',
|
||||
'where' => "css_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
|
||||
'where' => "css_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
|
||||
'order' => 'css_group, theorder DESC' ) );
|
||||
|
||||
$i = $this->DB->execute();
|
||||
@@ -943,7 +1186,7 @@ class skinFunctions
|
||||
|
||||
$css[ $row['css_group'] ] = $row;
|
||||
}
|
||||
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
@@ -992,6 +1235,7 @@ class skinFunctions
|
||||
|
||||
$css['_actualSetID'] = $css['css_set_id'];
|
||||
$css['_belongsSetID'] = $setID;
|
||||
$css['_isMaster'] = ( $css['css_master_key'] ) ? true : false;
|
||||
//$css['_css_content'] = $css['css_content'];
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1340,7 +1584,7 @@ class skinFunctions
|
||||
* Fetch Templates from the tree
|
||||
*
|
||||
* @access public
|
||||
* @param int Skin set ID
|
||||
* @param mixed Skin key or Skin set ID
|
||||
* @param string Type of data to return: 'allTemplates' will return the data [template_group][template_name], 'allNoContent' the same as 'allTemplates' minus the actual template content, 'groupNames'; [template_group] or groupTemplates, just that groups templates [template_name], groupTemplatesNoContent is the same as groupTemplates but template_content is removed
|
||||
* @param string Which group to use
|
||||
* @return array Array of data depending on the params
|
||||
@@ -1352,6 +1596,8 @@ class skinFunctions
|
||||
* $templates = $skinFunctions->fetchTemplates( 1, 'groupTemplates', 'skin_global' );
|
||||
* # To return all templates in all groups
|
||||
* $templates = $skinFunctions->fetchTemplates( 1, 'allTemplates');
|
||||
* # To return all master templates for the mobile skin
|
||||
* $templates = $skinFunctions->fetchTemplates( 'mobile', 'allTemplates' );
|
||||
* </code>
|
||||
*/
|
||||
public function fetchTemplates( $setID, $type='allTemplates', $group='')
|
||||
@@ -1361,13 +1607,31 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$templates = array();
|
||||
$where = '';
|
||||
|
||||
/* Did we pass a master key? - all root skins are 0 */
|
||||
if ( ! is_numeric( $setID ) )
|
||||
{
|
||||
$skinSetData = array( 'set_id' => 0,
|
||||
'set_master_key' => $setID,
|
||||
'set_key' => $setID,
|
||||
'_isMaster' => 1,
|
||||
'_parentTree' => array(),
|
||||
'_childTree' => array(),
|
||||
'_userAgents' => array(),
|
||||
'_cssGroupsArray' => array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
}
|
||||
|
||||
/* Did we get a skin set? */
|
||||
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Try and get the skin from the cache
|
||||
//-----------------------------------------
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
//-----------------------------------------
|
||||
// Push root ID onto the END of the parent array
|
||||
//-----------------------------------------
|
||||
@@ -1377,9 +1641,63 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
// Push the current skin set ID onto the beginnging
|
||||
//-----------------------------------------
|
||||
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
|
||||
|
||||
if ( is_numeric( $setID ) )
|
||||
{
|
||||
array_unshift( $skinSetData['_parentTree'], $setID );
|
||||
}
|
||||
|
||||
/* We want to capture only this set's master bits */
|
||||
$where = ' AND ( ( template_set_id > 0 AND ( template_master_key=\'\' OR template_master_key IS NULL ) ) OR ( template_set_id=0 AND template_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
|
||||
|
||||
/* First off, load 'root' skin as we tend to develop this the most and there is always a small chance other master skins won't
|
||||
contain all the template bits. We'll just load the group / name and leave the content blank to prevent parse errors, etc */
|
||||
if ( $setID != 'root' )
|
||||
{
|
||||
if ( ( $type == 'groupTemplates' OR $type == 'groupTemplatesNoContent' ) and $group != '' )
|
||||
{
|
||||
$_w = " AND template_group='{$group}'";
|
||||
}
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_templates',
|
||||
'where' => "template_master_key='root'" . $_w,
|
||||
'order' => 'template_group' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['template_content'] = '<!--no data in this master skin-->';
|
||||
|
||||
if ( $type == 'groupNames' )
|
||||
{
|
||||
$templates[ $r['template_group'] ] = $r;
|
||||
}
|
||||
else if ( $type == 'groupTemplates' OR $type == 'groupTemplatesNoContent' )
|
||||
{
|
||||
$r['_templateSize'] = IPSLib::sizeFormat( IPSLib::strlenToBytes( strlen( $r['template_content'] ) ) );
|
||||
|
||||
if ( $type == 'groupTemplatesNoContent' )
|
||||
{
|
||||
unset( $r['template_data'] );
|
||||
unset( $r['template_content'] );
|
||||
}
|
||||
|
||||
$templates[ strtolower($r['template_name']) ] = $r;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $type == 'allNoContent' )
|
||||
{
|
||||
unset( $r['template_content'] );
|
||||
}
|
||||
|
||||
$templates[ $r['template_group'] ][ strtolower($r['template_name']) ] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Ok, what to return?
|
||||
//-----------------------------------------
|
||||
@@ -1391,7 +1709,7 @@ class skinFunctions
|
||||
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
|
||||
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
|
||||
'from' => 'skin_templates',
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) ." )",
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) ." )" . $where,
|
||||
'order' => 'template_group, theorder DESC'
|
||||
) );
|
||||
$newq = $this->DB->execute();
|
||||
@@ -1403,7 +1721,7 @@ class skinFunctions
|
||||
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
|
||||
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
|
||||
'from' => 'skin_templates',
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) . ") AND template_group='{$group}'",
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) . ") AND template_group='{$group}'" . $where,
|
||||
'order' => 'template_name, theorder DESC'
|
||||
) );
|
||||
$newq = $this->DB->execute();
|
||||
@@ -1415,7 +1733,7 @@ class skinFunctions
|
||||
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
|
||||
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
|
||||
'from' => 'skin_templates',
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
|
||||
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
|
||||
'order' => 'template_group, template_name, theorder DESC'
|
||||
) );
|
||||
$newq = $this->DB->execute();
|
||||
@@ -1471,6 +1789,14 @@ class skinFunctions
|
||||
}
|
||||
|
||||
ksort($templates);
|
||||
|
||||
foreach( $templates as $k => $v )
|
||||
{
|
||||
if( is_array($v) )
|
||||
{
|
||||
ksort($templates[ $k ]);
|
||||
}
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
@@ -1500,8 +1826,8 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$template = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_templates',
|
||||
'where' => 'template_id=' . $templateID ) );
|
||||
'from' => 'skin_templates',
|
||||
'where' => 'template_id=' . $templateID ) );
|
||||
|
||||
if ( ! $template['template_id'] )
|
||||
{
|
||||
@@ -1522,6 +1848,7 @@ class skinFunctions
|
||||
$template['_belongsSetID'] = $setID;
|
||||
$template['_template_content'] = $template['template_content'];
|
||||
$template['_template_data'] = $template['template_data'];
|
||||
$template['_isMaster'] = ( $template['template_master_key'] ) ? true : false;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update content for editing
|
||||
@@ -1712,7 +2039,7 @@ class skinFunctions
|
||||
// Test it..
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->testTemplateBitSyntax( $template['template_name'], $template_data, $template_content ) !== TRUE )
|
||||
if ( $this->testTemplateBitSyntax( $template_name, $template_data, $template_content ) !== TRUE )
|
||||
{
|
||||
throw new Exception( "SYNTAX_INCORRECT" );
|
||||
}
|
||||
@@ -2034,9 +2361,10 @@ class skinFunctions
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$config = array();
|
||||
require( $path . '/' . $_name . '/conf.php' );
|
||||
|
||||
|
||||
$formats[ $_name ] = $config;
|
||||
}
|
||||
}
|
||||
@@ -2060,7 +2388,7 @@ class skinFunctions
|
||||
/* Fetch groups? */
|
||||
if ( ! count( $groups ) )
|
||||
{
|
||||
$groups = array_keys( $this->fetchTemplates( 1, 'groupNames' ) );
|
||||
$groups = array_keys( $this->fetchTemplates( 'root', 'groupNames' ) );
|
||||
}
|
||||
|
||||
/* Got a hooks cache? */
|
||||
@@ -2074,21 +2402,21 @@ class skinFunctions
|
||||
|
||||
if( is_array( $hooksCache['templateHooks'] ) AND count( $hooksCache['templateHooks'] ) )
|
||||
{
|
||||
foreach( $hooksCache['templateHooks'] as $hook )
|
||||
foreach( $hooksCache['templateHooks'] as $skinGroup => $hooks )
|
||||
{
|
||||
foreach( $hook as $tplHook )
|
||||
/* Check to see if the group is loaded */
|
||||
if( ! in_array( $skinGroup, $groups ) )
|
||||
{
|
||||
/* Check to see if the group is loaded */
|
||||
if( ! in_array( $tplHook['skinGroup'], $groups ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach( $hooks as $tplHook )
|
||||
{
|
||||
/* Check for hook file */
|
||||
if( file_exists( DOC_IPS_ROOT_PATH . 'hooks/' . $tplHook['filename'] ) )
|
||||
{
|
||||
$tplHook['_commentTag'] = $tplHook['type'] . '.' . $tplHook['skinGroup'] . '.' . $tplHook['skinFunction'] . '.' . $tplHook['id'] . '.' . $tplHook['position'];
|
||||
$myHooks[ $tplHook['skinGroup'] ][] = $tplHook;
|
||||
$tplHook['_commentTag'] = $tplHook['type'] . '.' . $skinGroup . '.' . $tplHook['skinFunction'] . '.' . $tplHook['id'] . '.' . $tplHook['position'];
|
||||
$myHooks[ $skinGroup ][] = $tplHook;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2123,9 +2451,10 @@ class skinFunctions
|
||||
*
|
||||
* @access public
|
||||
* @param int Skin set ID
|
||||
* @param bool Force load from DB
|
||||
* @return array
|
||||
*/
|
||||
public function fetchSkinData( $setID )
|
||||
public function fetchSkinData( $setID, $forceLoadDB=false )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Skin ID #0?
|
||||
@@ -2135,7 +2464,8 @@ class skinFunctions
|
||||
{
|
||||
/* This is a master skin, so lets fake it */
|
||||
$skinSetData['set_id'] = 0;
|
||||
$skinSetData['set_key'] = 'root';
|
||||
$skinSetData['set_key'] = is_numeric( $setID ) ? 'root' : $setID;
|
||||
$skinSetData['set_master_key'] = is_numeric( $setID ) ? 'root' : $setID;
|
||||
$skinSetData['_isMaster'] = 1;
|
||||
$skinSetData['_parentTree'] = array();
|
||||
$skinSetData['_childTree'] = array();
|
||||
@@ -2174,7 +2504,7 @@ class skinFunctions
|
||||
// Got nothing?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $setID > 0 AND ! is_array( $skinSetData ) )
|
||||
if ( $forceLoadDB OR ( $setID > 0 AND ! $skinSetData['set_id'] ) )
|
||||
{
|
||||
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
@@ -2199,6 +2529,9 @@ class skinFunctions
|
||||
$skinSetData['_cssGroupsArray'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail safe */
|
||||
$skinSetData['set_master_key'] = ( $skinSetData['set_master_key'] ) ? $skinSetData['set_master_key'] : 'root';
|
||||
|
||||
return $skinSetData;
|
||||
}
|
||||
@@ -2306,8 +2639,10 @@ class skinFunctions
|
||||
// Test...
|
||||
//-----------------------------------------
|
||||
|
||||
$eval = $this->registry->templateEngine->convertHtmlToPhp( 'test__' . $name, $data, $content );
|
||||
|
||||
ob_start();
|
||||
eval( $this->registry->templateEngine->convertHtmlToPhp( 'test__' . $name, $data, $content ) );
|
||||
eval( $eval );
|
||||
$return = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
@@ -2418,7 +2753,7 @@ class skinFunctions
|
||||
$templates = $this->fetchTemplates( 0, 'groupTemplatesNoContent', $_group );
|
||||
|
||||
/* Clean out any template bits no longer part of this group */
|
||||
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND LOWER(template_name) NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
|
||||
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND " . $this->DB->buildLower('template_name') . " NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
|
||||
|
||||
$affected += intval( $this->DB->getAffectedRows() );
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2009-09-28 18:04:38 -0400 (Mon, 28 Sep 2009) $
|
||||
* Last Updated: $Date: 2010-09-13 05:53:37 -0400 (Mon, 13 Sep 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: josh $
|
||||
* @author $Author: terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 5170 $
|
||||
* @version $Revision: 6854 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -68,13 +70,23 @@ class skinImportExport extends skinCaching
|
||||
//-----------------------------------------
|
||||
|
||||
$addedCount = 0;
|
||||
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
$skinMasterKey = '';
|
||||
|
||||
//-----------------------------------------
|
||||
// Got anything?
|
||||
//-----------------------------------------
|
||||
|
||||
$replacements = $this->parseReplacementsXML( $content );
|
||||
$where = ( is_numeric( $setID ) ) ? 'replacement_set_id=' . $setID : 'replacement_master_key=\'' . $setID . '\'';
|
||||
|
||||
/* If this is a 'master' skin, then reset master key */
|
||||
if ( in_array( $setID, $masterKeys ) )
|
||||
{
|
||||
$skinMasterKey = $setID;
|
||||
$setID = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Replacements...
|
||||
//-----------------------------------------
|
||||
@@ -82,7 +94,7 @@ class skinImportExport extends skinCaching
|
||||
if ( is_array( $replacements ) )
|
||||
{
|
||||
/* Get all the keys for this set id */
|
||||
$this->DB->build( array( 'select' => 'replacement_key', 'from' => 'skin_replacements', 'where' => "replacement_set_id={$setID}" ) );
|
||||
$this->DB->build( array( 'select' => 'replacement_key', 'from' => 'skin_replacements', 'where' => $where ) );
|
||||
$this->DB->execute();
|
||||
|
||||
$repKeyCache = array();
|
||||
@@ -100,21 +112,16 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if( in_array( $replacement['replacement_key'], $repKeyCache ) )
|
||||
{
|
||||
$this->DB->update( 'skin_replacements', array(
|
||||
'replacement_content' => $replacement['replacement_content']
|
||||
),
|
||||
"replacement_key='{$replacement['replacement_key']}' AND replacement_set_id={$setID}"
|
||||
);
|
||||
$this->DB->update( 'skin_replacements', array( 'replacement_content' => $replacement['replacement_content'] ), "replacement_key='{$replacement['replacement_key']}' AND " . $where );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->insert( 'skin_replacements', array(
|
||||
'replacement_key' => $replacement['replacement_key'],
|
||||
'replacement_content' => $replacement['replacement_content'],
|
||||
'replacement_set_id' => $setID,
|
||||
'replacement_added_to' => $setID
|
||||
)
|
||||
);
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
|
||||
'replacement_content' => $replacement['replacement_content'],
|
||||
'replacement_set_id' => $setID,
|
||||
'replacement_added_to' => $setID,
|
||||
'replacement_master_key' => $skinMasterKey
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +156,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! strstr( $content, "<xmlarchive" ) )
|
||||
{
|
||||
$this->_addErrorMessage( "Содержимое не является XMLArchive" );
|
||||
$this->_addErrorMessage( $this->lang->words['invalidxmlarchivei'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -164,7 +171,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! $xmlArchive->countFileArray() )
|
||||
{
|
||||
$this->_addErrorMessage( "XMLArchive пуст" );
|
||||
$this->_addErrorMessage( $this->lang->words['emptyxmlarchivei'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -177,13 +184,13 @@ class skinImportExport extends skinCaching
|
||||
if ( $this->checkImageDirectoryExists( $imageSetName ) === TRUE )
|
||||
{
|
||||
/* Already exists... */
|
||||
$this->_addErrorMessage( "Директория public/style_images/{$imageSetName} уже существует" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['imagediralreadyexists'], $imageSetName ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( $this->createNewImageDirectory( $imageSetName ) !== TRUE )
|
||||
{
|
||||
$this->_addErrorMessage( "Не удалось создать public/style_images/{$imageSetName}. Проверьте права доступа и повторите попытку снова." );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['imagedircannotcreate'], $imageSetName ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -201,7 +208,7 @@ class skinImportExport extends skinCaching
|
||||
/* Write it */
|
||||
if ( $xmlArchive->write( $content, $this->fetchImageDirectoryPath( $imageSetName ) ) === FALSE )
|
||||
{
|
||||
$this->_addErrorMessage( "Не удалось записать файлы изображений" );
|
||||
$this->_addErrorMessage( $this->lang->words['cannotwriteimageset'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -245,21 +252,23 @@ class skinImportExport extends skinCaching
|
||||
* @param int [ Skin set parent. If omitted, it will be made a root skin ]
|
||||
* @param string [ Images directory to use. If omitted, default skin's image dir is used ]
|
||||
* @param string [ Name of skin to create. If omitted, name from skin set is used ]
|
||||
* @param bool [ Whether or not we are attempting to upgrade an existing skin ]
|
||||
* @return mixed bool, or number of items added
|
||||
*/
|
||||
public function importSetXMLArchive( $content, $parentID=0, $imageDir='', $setName='' )
|
||||
public function importSetXMLArchive( $content, $parentID=0, $imageDir='', $setName='', $upgrading=FALSE )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$templates = array();
|
||||
$csss = array();
|
||||
$groups = array();
|
||||
$defaultSkin = array();
|
||||
$return = array( 'replacements' => 0,
|
||||
'css' => 0,
|
||||
'templates' => 0 );
|
||||
$templates = array();
|
||||
$csss = array();
|
||||
$groups = array();
|
||||
$defaultSkin = array();
|
||||
$return = array( 'replacements' => 0,
|
||||
'css' => 0,
|
||||
'templates' => 0,
|
||||
'upgrade' => FALSE );
|
||||
|
||||
//-----------------------------------------
|
||||
// Got anything?
|
||||
@@ -267,7 +276,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! strstr( $content, "<xmlarchive" ) )
|
||||
{
|
||||
$this->_addErrorMessage( "Содержимое не является XMLArchive" );
|
||||
$this->_addErrorMessage( $this->lang->words['invalidxmlarchivei'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -294,7 +303,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! $xmlArchive->countFileArray() )
|
||||
{
|
||||
$this->_addErrorMessage( "XMLArchive пуст" );
|
||||
$this->_addErrorMessage( $this->lang->words['emptyxmlarchivei'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -307,12 +316,34 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if( !$infoXml )
|
||||
{
|
||||
$this->_addErrorMessage( "Файл info.xml пуст или отсутствует" );
|
||||
$this->_addErrorMessage( $this->lang->words['noinfoxml'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$info = $this->parseInfoXML( $infoXml );
|
||||
|
||||
|
||||
/* Are we attempting to upgrade? */
|
||||
$setID = 0;
|
||||
$doUpgrade = FALSE;
|
||||
$new_items = array( 'replacements' => array(),
|
||||
'css' => array(),
|
||||
'templates' => array(),
|
||||
);
|
||||
|
||||
if ( $info['set_key'] && $upgrading )
|
||||
{
|
||||
foreach ( $this->caches['skinsets'] as $set_id => $set_data )
|
||||
{
|
||||
if ( $set_data['set_key'] == $info['set_key'] )
|
||||
{
|
||||
$setID = $set_id;
|
||||
$doUpgrade = TRUE;
|
||||
$return['upgrade'] = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Replacements */
|
||||
$replacements = $this->parseReplacementsXML( $xmlArchive->getFile( 'replacements.xml' ) );
|
||||
|
||||
@@ -336,7 +367,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $info ) )
|
||||
{
|
||||
$this->_addErrorMessage( "XMLArchive не содержит файл info.xml" );
|
||||
$this->_addErrorMessage( $this->lang->words['noinfoxml'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -355,12 +386,22 @@ class skinImportExport extends skinCaching
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure key in unique */
|
||||
$test = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_key=\'' . $this->DB->addSlashes( $info['set_key'] ) . '\' AND set_id != ' . intval( $setID ) ) );
|
||||
|
||||
if ( $test['set_id'] )
|
||||
{
|
||||
$info['set_key'] .= '_' . time();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build Set Array
|
||||
//-----------------------------------------
|
||||
|
||||
$newSet = array('set_name' => ( $setName ) ? $setName : $info['set_name'] . ' (Import)',
|
||||
'set_key' => '',
|
||||
'set_key' => $info['set_key'],
|
||||
'set_parent_id' => $parentID,
|
||||
'set_permissions' => implode( ",", $groups ),
|
||||
'set_is_default' => 0,
|
||||
@@ -372,15 +413,31 @@ class skinImportExport extends skinCaching
|
||||
'set_output_format' => $info['set_output_format'],
|
||||
'set_css_groups' => '',
|
||||
'set_hide_from_list' => 1, // Per Rikki :P
|
||||
'set_order' => intval( $this->fetchHighestSetPosition() ) + 1,
|
||||
'set_master_key' => ( isset( $info['set_master_key'] ) ) ? $info['set_master_key'] : 'root',
|
||||
'set_updated' => time() );
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->insert( 'skin_collections', $newSet );
|
||||
|
||||
$setID = $this->DB->getInsertId();
|
||||
if ( $setID )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Update...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->update( 'skin_collections', array( 'set_author_name' => $info['set_author_name'],
|
||||
'set_author_url' => $info['set_author_url'],
|
||||
'set_updated' => time(),
|
||||
), 'set_id=' . $setID );
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Insert...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->insert( 'skin_collections', $newSet );
|
||||
|
||||
$setID = $this->DB->getInsertId();
|
||||
}
|
||||
|
||||
/* Rebuild trees */
|
||||
$this->rebuildTreeInformation( $setID );
|
||||
@@ -409,11 +466,31 @@ class skinImportExport extends skinCaching
|
||||
if ( $replacement['replacement_key'] )
|
||||
{
|
||||
$return['replacements']++;
|
||||
$existing_id = 0;
|
||||
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
|
||||
'replacement_content' => $replacement['replacement_content'],
|
||||
'replacement_set_id' => $setID,
|
||||
'replacement_added_to' => $setID ) );
|
||||
/* Check if we need to update or insert */
|
||||
if ( $doUpgrade )
|
||||
{
|
||||
$exists = $this->DB->buildAndFetch( array( 'select' => 'replacement_id',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => "replacement_key='{$replacement['replacement_key']}' AND replacement_set_id={$setID} AND replacement_added_to={$setID}" ) );
|
||||
|
||||
|
||||
$existing_id = $exists['replacement_id'];
|
||||
}
|
||||
|
||||
if ( $existing_id )
|
||||
{
|
||||
$new_items['replacements'][] = $existing_id;
|
||||
$this->DB->update( 'skin_replacements', array( 'replacement_content' => $replacement['replacement_content'] ), "replacement_id=".$existing_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
|
||||
'replacement_content' => $replacement['replacement_content'],
|
||||
'replacement_set_id' => $setID,
|
||||
'replacement_added_to' => $setID ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,17 +513,42 @@ class skinImportExport extends skinCaching
|
||||
if ( $css['css_group'] )
|
||||
{
|
||||
$return['css']++;
|
||||
|
||||
$this->DB->insert( 'skin_css', array( 'css_group' => $css['css_group'],
|
||||
'css_content' => $css['css_content'],
|
||||
'css_position' => $css['css_position'],
|
||||
'css_attributes' => $css['css_attributes'],
|
||||
'css_app' => $css['css_app'],
|
||||
'css_app_hide' => $css['css_app_hide'],
|
||||
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
|
||||
'css_updated' => time(),
|
||||
'css_set_id' => $setID,
|
||||
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ) );
|
||||
$existing_id = 0;
|
||||
|
||||
/* Check if we need to update or insert */
|
||||
if ( $doUpgrade )
|
||||
{
|
||||
$exists = $this->DB->buildAndFetch( array( 'select' => 'css_id',
|
||||
'from' => 'skin_css',
|
||||
'where' => "css_group='{$css['css_group']}' AND css_app='{$css['css_app']}' AND css_set_id={$setID}" ) );
|
||||
|
||||
$existing_id = $exists['css_id'];
|
||||
}
|
||||
|
||||
if ( $existing_id )
|
||||
{
|
||||
$new_items['css'][] = $existing_id;
|
||||
$this->DB->update( 'skin_css', array( 'css_content' => $css['css_content'],
|
||||
'css_position' => $css['css_position'],
|
||||
'css_attributes' => $css['css_attributes'],
|
||||
'css_app_hide' => $css['css_app_hide'],
|
||||
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
|
||||
'css_updated' => time(),
|
||||
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ), "css_id=".$existing_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->insert( 'skin_css', array( 'css_group' => $css['css_group'],
|
||||
'css_content' => $css['css_content'],
|
||||
'css_position' => $css['css_position'],
|
||||
'css_attributes' => $css['css_attributes'],
|
||||
'css_app' => $css['css_app'],
|
||||
'css_app_hide' => $css['css_app_hide'],
|
||||
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
|
||||
'css_updated' => time(),
|
||||
'css_set_id' => $setID,
|
||||
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,23 +576,70 @@ class skinImportExport extends skinCaching
|
||||
$isAdded = ( is_array( $_MASTER[ $template['template_group'] ][ strtolower( $template['template_name'] ) ] ) AND ! $_MASTER[ $template['template_group'] ][ strtolower( $template['template_name'] ) ]['template_user_added'] ) ? 0 : 1;
|
||||
|
||||
$return['templates']++;
|
||||
|
||||
$this->DB->insert( 'skin_templates', array( 'template_set_id' => $setID,
|
||||
'template_group' => $template['template_group'],
|
||||
'template_content' => $template['template_content'],
|
||||
'template_name' => $template['template_name'],
|
||||
'template_data' => $template['template_data'],
|
||||
'template_updated' => $template['template_updated'],
|
||||
'template_removable' => 1,
|
||||
'template_user_edited' => 1,
|
||||
'template_user_added' => $isAdded,
|
||||
'template_added_to' => $setID ) );
|
||||
$existing_id = 0;
|
||||
|
||||
/* Check if we need to update or insert */
|
||||
if ( $doUpgrade )
|
||||
{
|
||||
$exists = $this->DB->buildAndFetch( array( 'select' => 'template_id',
|
||||
'from' => 'skin_templates',
|
||||
'where' => "template_set_id={$setID} AND template_group='{$template['template_group']}' AND template_name='{$template['template_name']}'" ) );
|
||||
|
||||
$existing_id = $exists['template_id'];
|
||||
}
|
||||
|
||||
if ( $existing_id )
|
||||
{
|
||||
$new_items['templates'][] = $existing_id;
|
||||
$this->DB->update( 'skin_templates', array( 'template_content' => $template['template_content'],
|
||||
'template_data' => $template['template_data'],
|
||||
'template_updated' => $template['template_updated'],
|
||||
'template_removable' => 1,
|
||||
'template_user_edited' => 1,
|
||||
'template_user_added' => $isAdded,
|
||||
'template_added_to' => $setID ), "template_id=".$existing_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->insert( 'skin_templates', array( 'template_set_id' => $setID,
|
||||
'template_group' => $template['template_group'],
|
||||
'template_content' => $template['template_content'],
|
||||
'template_name' => $template['template_name'],
|
||||
'template_data' => $template['template_data'],
|
||||
'template_updated' => $template['template_updated'],
|
||||
'template_removable' => 1,
|
||||
'template_user_edited' => 1,
|
||||
'template_user_added' => $isAdded,
|
||||
'template_added_to' => $setID ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// If upgrading, and there are items from an old
|
||||
// skin not in the new one, delete the old elements
|
||||
// This probably won't ever come up, but I'm anal retentive :P
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $doUpgrade )
|
||||
{
|
||||
if ( count( $new_items['replacements'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_set_id={$setID} AND replacement_id NOT IN (" . implode( ',', $new_items['replacements']) . ")" );
|
||||
}
|
||||
if ( count( $new_items['css'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_css', "css_set_id={$setID} AND css_id NOT IN (" . implode( ',', $new_items['css']) . ")" );
|
||||
}
|
||||
if ( count( $new_items['templates'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_templates', "template_set_id={$setID} AND template_id NOT IN (" . implode( ',', $new_items['templates']) . ")" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Re-cache
|
||||
//-----------------------------------------
|
||||
@@ -677,7 +826,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( $this->checkImageDirectoryExists( $imgDir ) !== TRUE )
|
||||
{
|
||||
$this->_addErrorMessage( "Директории изображений $imgDir не существует" );
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['imagedirnotexists'], $imgDir ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -757,16 +906,16 @@ class skinImportExport extends skinCaching
|
||||
|
||||
foreach( $templates as $app_dir => $templateXML )
|
||||
{
|
||||
IPSDebug::addLogMessage( "Template Export: $app_dir\n".$templateXML, 'admin-setExport' );
|
||||
IPSDebug::addLogMessage( "Template Export: $app_dir\n".$templateXML, 'admin-setExport', false, true, true );
|
||||
}
|
||||
|
||||
foreach( $csss as $app_dir => $cssXML )
|
||||
{
|
||||
IPSDebug::addLogMessage( "CSS Export: $app_dir\n".$cssXML, 'admin-setExport' );
|
||||
IPSDebug::addLogMessage( "CSS Export: $app_dir\n".$cssXML, 'admin-setExport', false, true );
|
||||
}
|
||||
|
||||
IPSDebug::addLogMessage( "Replacements Export:\n".$replacements, 'admin-setExport' );
|
||||
IPSDebug::addLogMessage( "Info Export:\n".$info, 'admin-setExport' );
|
||||
IPSDebug::addLogMessage( "Replacements Export:\n".$replacements, 'admin-setExport', false, true );
|
||||
IPSDebug::addLogMessage( "Info Export:\n".$info, 'admin-setExport', false, true );
|
||||
|
||||
//-----------------------------------------
|
||||
// Create new XML archive...
|
||||
@@ -775,6 +924,10 @@ class skinImportExport extends skinCaching
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
|
||||
$xmlArchive = new classXMLArchive();
|
||||
|
||||
/* Add in version numbers */
|
||||
$version = IPSLib::fetchVersionNumber();
|
||||
$xmlArchive->addRootTagValues( array( 'ipbLongVersion' => $version['long'], 'ipbHumanVersion' => $version['human'] ) );
|
||||
|
||||
# Templates
|
||||
foreach( $templates as $app_dir => $templateXML )
|
||||
{
|
||||
@@ -813,18 +966,30 @@ class skinImportExport extends skinCaching
|
||||
$this->_resetErrorHandle();
|
||||
$this->_resetMessageHandle();
|
||||
|
||||
if ( $setID == 0 )
|
||||
{
|
||||
/* This is which skins we want to export for default installations */
|
||||
$skinIDs = array_values( $this->remapData['export'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinIDs = array( $setID );
|
||||
}
|
||||
|
||||
foreach( $skinIDs as $setID )
|
||||
{
|
||||
foreach( ipsRegistry::$applications as $app_dir => $app_data )
|
||||
{
|
||||
if ( ! file_exists( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
|
||||
{
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не существует" );
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirmissing'] );
|
||||
continue;
|
||||
}
|
||||
else if ( ! is_writable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
|
||||
{
|
||||
if ( ! @chmod( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) )
|
||||
{
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не имеет прав на запись" );
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirnotwrite'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -832,6 +997,7 @@ class skinImportExport extends skinCaching
|
||||
$this->exportTemplateAppXML( $app_dir, $setID, $setOnly );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all Apps CSS
|
||||
@@ -849,20 +1015,32 @@ class skinImportExport extends skinCaching
|
||||
$this->_resetErrorHandle();
|
||||
$this->_resetMessageHandle();
|
||||
|
||||
if ( $setID == 0 )
|
||||
{
|
||||
/* This is which skins we want to export for default installations */
|
||||
$skinIDs = array_values( $this->remapData['export'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinIDs = array( $setID );
|
||||
}
|
||||
|
||||
foreach( $skinIDs as $setID )
|
||||
{
|
||||
foreach( ipsRegistry::$applications as $app_dir => $app_data )
|
||||
{
|
||||
$file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_css.xml';
|
||||
|
||||
if ( ! file_exists( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
|
||||
{
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не существует" );
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirmissing'] );
|
||||
continue;
|
||||
}
|
||||
else if ( ! is_writable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
|
||||
{
|
||||
if ( ! @chmod( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) )
|
||||
{
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не имеет прав на запись" );
|
||||
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirnotwrite'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -870,6 +1048,7 @@ class skinImportExport extends skinCaching
|
||||
$this->exportCSSAppXML( $app_dir, $setID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import all Apps skin files
|
||||
@@ -893,13 +1072,13 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! file_exists( $file ) )
|
||||
{
|
||||
$this->_addMessage( $app_dir . ': нечего импортировать' );
|
||||
$this->_addMessage( $app_dir . $this->lang->words['importnothingtoimport'] );
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = $this->importTemplateAppXML( $app_dir, 0 );
|
||||
$this->_addMessage( $app_dir . ': ' . $return['updateCount'] . ' добавлено, ' . $return['insertCount'] . ' обновлено' );
|
||||
$this->_addMessage( sprintf( $this->lang->words['importaddupdate'], $app_dir, $return['updateCount'], $return['insertCount'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -917,11 +1096,25 @@ class skinImportExport extends skinCaching
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$skins = array();
|
||||
$setid = 1;
|
||||
|
||||
$skins = array();
|
||||
$setid = 1;
|
||||
$exports = array_values( $this->remapData['export'] );
|
||||
$remap = array( 'mobile' => array( 'set_id' => 2,
|
||||
'set_name' => 'IP.Board Mobile',
|
||||
'set_key' => 'mobile',
|
||||
'set_master_key' => 'mobile',
|
||||
'set_output_format' => 'html',
|
||||
'set_image_dir' => 'mobile',
|
||||
'set_locked_uagent' => 'a:2:{s:6:"groups";a:0:{}s:7:"uagents";a:10:{s:10:"blackberry";s:0:"";s:6:"iphone";s:0:"";s:9:"ipodtouch";s:0:"";s:12:"sonyericsson";s:0:"";s:5:"nokia";s:0:"";s:8:"motorola";s:0:"";s:7:"samsung";s:0:"";s:3:"htc";s:0:"";s:2:"lg";s:0:"";s:4:"palm";s:0:"";}}' ),
|
||||
'xmlskin' => array( 'set_id' => 3,
|
||||
'set_name' => 'IP.Board XML',
|
||||
'set_key' => 'xmlskin',
|
||||
'set_master_key' => 'xmlskin',
|
||||
'set_output_format' => 'xml',
|
||||
'set_image_dir' => 'master' ) );
|
||||
|
||||
/* Figure out ID 0 */
|
||||
if ( in_array( 0, $skinIDs ) )
|
||||
if ( in_array( 0, $skinIDs ) OR in_array( 'root', $skinIDs ) )
|
||||
{
|
||||
$cssSkinCollections = array();
|
||||
$_css = $this->fetchCSS( 0 );
|
||||
@@ -943,7 +1136,7 @@ class skinImportExport extends skinCaching
|
||||
'set_permissions' => '*',
|
||||
'set_is_default' => 1,
|
||||
'set_author_name' => 'Invision Power Services, Inc',
|
||||
'set_author_url' => '',
|
||||
'set_author_url' => 'http://www.bestcms.ws',
|
||||
'set_image_dir' => 'master',
|
||||
'set_emo_dir' => 'default',
|
||||
'set_css_inline' => 1,
|
||||
@@ -952,27 +1145,70 @@ class skinImportExport extends skinCaching
|
||||
'set_updated' => time(),
|
||||
'set_output_format' => 'html',
|
||||
'set_locked_uagent' => '',
|
||||
'set_hide_from_list' => 0 );
|
||||
'set_hide_from_list' => 0,
|
||||
'set_master_key' => 'root' );
|
||||
}
|
||||
|
||||
/* Grab the rest */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_id IN (' . implode( ",", $skinIDs ) . ')' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch() )
|
||||
foreach( $exports as $_id )
|
||||
{
|
||||
/* Ensure settings */
|
||||
$row['set_id'] = $setid;
|
||||
$row['set_permissions'] = '*';
|
||||
$row['set_hide_from_list'] = 0;
|
||||
$row['set_css_inline'] = 1;
|
||||
if ( $_id != 'root' AND in_array( $_id, $skinIDs ) )
|
||||
{
|
||||
$cssSkinCollections = array();
|
||||
$_css = $this->fetchCSS( $_id );
|
||||
|
||||
foreach( $_css as $name => $css )
|
||||
{
|
||||
/* Build skin set row*/
|
||||
$cssSkinCollections[ $css['css_position'] . '.' . $css['css_id'] ] = array( 'css_group' => $css['css_group'], 'css_position' => $css['css_position'] );
|
||||
}
|
||||
|
||||
$setid++;
|
||||
|
||||
$skins[ $remap[ $_id ]['set_id'] ] = array( 'set_id' => $remap[ $_id ]['set_id'],
|
||||
'set_name' => $remap[ $_id ]['set_name'],
|
||||
'set_key' => $remap[ $_id ]['set_key'],
|
||||
'set_parent_id' => 0,
|
||||
'set_parent_array' => serialize( array() ),
|
||||
'set_child_array' => serialize( array() ),
|
||||
'set_permissions' => '*',
|
||||
'set_is_default' => 1,
|
||||
'set_author_name' => 'Invision Power Services, Inc',
|
||||
'set_author_url' => 'http://www.bestcms.ws',
|
||||
'set_image_dir' => $remap[ $_id ]['set_image_dir'],
|
||||
'set_emo_dir' => 'default',
|
||||
'set_css_inline' => 1,
|
||||
'set_css_groups' => serialize( $cssSkinCollections ),
|
||||
'set_added' => time(),
|
||||
'set_updated' => time(),
|
||||
'set_output_format' => $remap[ $_id ]['set_output_format'],
|
||||
'set_locked_uagent' => ( isset( $remap[ $_id ]['set_locked_uagent'] ) ) ? $remap[ $_id ]['set_locked_uagent'] : '',
|
||||
'set_hide_from_list' => 0,
|
||||
'set_master_key' => $remap[ $_id ]['set_master_key'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( count( $skins ) != count( $skinIDs ) )
|
||||
{
|
||||
/* Grab the rest */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_id IN (' . implode( ",", $skinIDs ) . ')' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
$skins[ $row['set_id'] ] = $row;
|
||||
|
||||
$setid++;
|
||||
while( $row = $this->DB->fetch() )
|
||||
{
|
||||
/* Ensure settings */
|
||||
$row['set_id'] = $setid;
|
||||
$row['set_permissions'] = '*';
|
||||
$row['set_hide_from_list'] = 0;
|
||||
$row['set_css_inline'] = 1;
|
||||
|
||||
$skins[ $row['set_id'] ] = $row;
|
||||
|
||||
$setid++;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1019,9 +1255,11 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( $setOnly === TRUE )
|
||||
{
|
||||
$where = ( is_numeric( $setID ) ) ? 'replacement_set_id=' . $setID : 'replacement_master_key=\'' . $setID . '\'';
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_set_id=' . $setID ) );
|
||||
'where' => $where ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
@@ -1037,7 +1275,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $replacements ) OR ! count( $replacements ) )
|
||||
{
|
||||
$this->_addMessage( "Нет макросов для экспортирования" );
|
||||
$this->_addMessage( $this->lang->words['noreplacementstoexport'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1128,7 +1366,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $css ) OR ! count( $css ) )
|
||||
{
|
||||
$this->_addMessage( "Нет CSS для экспортирования в " . $app_dir );
|
||||
$this->_addMessage( $this->lang->words['nocsstoexport'] . $app_dir );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1168,7 +1406,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! $gotSomething )
|
||||
{
|
||||
$this->_addMessage( "Нет CSS для экспортирования в " . $app_dir );
|
||||
$this->_addMessage( $this->lang->words['nocsstoexport'] . $app_dir );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1200,7 +1438,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! file_exists( $infoXML ) )
|
||||
{
|
||||
$this->_addErrorMessage( "Не удалось найти: " . $infoXML );
|
||||
$this->_addErrorMessage( $this->lang->words['couldnotlocate'] . $infoXML );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1226,13 +1464,14 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $templateGroups ) OR ! count( $templateGroups ) )
|
||||
{
|
||||
$this->_addMessage( "Нечего экспортировать для приложения " . $app . ": Не установлены группы в information.xml" );
|
||||
$this->_addMessage( sprintf( $this->lang->words['nothingtoexportforapp'], $app ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch templates
|
||||
//-----------------------------------------
|
||||
$templates = array();
|
||||
|
||||
if ( $setOnly === TRUE AND $setID > 0 )
|
||||
{
|
||||
@@ -1283,7 +1522,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $templates ) OR ! count( $templates ) )
|
||||
{
|
||||
$this->_addMessage( "Нечего экспортировать для приложения " . $app . ": Нет шаблонов" );
|
||||
$this->_addMessage( sprintf( $this->lang->words['nogroupsforexportapp'], $app ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1308,9 +1547,21 @@ class skinImportExport extends skinCaching
|
||||
$_okToGo = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If this is the core app, allow any custom bits also */
|
||||
if ( $app == 'core' )
|
||||
{
|
||||
$_data = $data;
|
||||
$test = array_shift( $_data );
|
||||
|
||||
if ( $test['template_user_added'] )
|
||||
{
|
||||
$_okToGo = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $_okToGo === TRUE )
|
||||
{
|
||||
{
|
||||
$xml->addElement( 'templategroup', 'templates', array( 'group' => $group ) );
|
||||
|
||||
foreach( $data as $name => $templateData )
|
||||
@@ -1328,7 +1579,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! $added )
|
||||
{
|
||||
$this->_addMessage( "Нечего экспортировать для " . $app );
|
||||
$this->_addMessage( $this->lang->words['nothingtoexportfor'] . $app );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1350,7 +1601,8 @@ class skinImportExport extends skinCaching
|
||||
|
||||
$data = array();
|
||||
$setData = $this->fetchSkinData( $setID );
|
||||
|
||||
$version = IPSLib::fetchVersionNumber();
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab the XML parser
|
||||
//-----------------------------------------
|
||||
@@ -1366,9 +1618,13 @@ class skinImportExport extends skinCaching
|
||||
$xml->addElement( 'info' );
|
||||
|
||||
$xml->addElementAsRecord( 'info', 'data', array( 'set_name' => $setData['set_name'],
|
||||
'set_key' => $setData['set_key'],
|
||||
'set_author_name' => $setData['set_author_name'],
|
||||
'set_author_url' => $setData['set_author_url'],
|
||||
'set_output_format' => $setData['set_output_format'],
|
||||
'set_master_key' => $setData['set_master_key'],
|
||||
'ipb_human_version' => $version['human'],
|
||||
'ipb_long_version' => $version['long'],
|
||||
'ipb_major_version' => '3' ) );
|
||||
|
||||
return $xml->fetchDocument();
|
||||
@@ -1391,6 +1647,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
$fileXML = IPSLib::getAppDir( $app ) . '/xml/' . $app . '_' . $skinKey . '_css.xml';
|
||||
$return = array( 'updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array() );
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
//-----------------------------------------
|
||||
// File exists
|
||||
@@ -1401,23 +1658,31 @@ class skinImportExport extends skinCaching
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! $setID and $skinKey != 'root' )
|
||||
if ( ! $setID and ! in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
/* Figure out correct set ID based on key */
|
||||
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'where' => "set_key='" . $skinKey . "'" ) );
|
||||
|
||||
$setID = $skinSetData['set_id'];
|
||||
$setID = $skinSetData['set_id'];
|
||||
$skinMasterKey = $skinSetData['set_master_key'];
|
||||
}
|
||||
|
||||
/* If this is a 'master' skin, then reset master key */
|
||||
if ( in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
$skinMasterKey = $skinKey;
|
||||
$setID = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Delete all CSS if this is set ID 0
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $setID )
|
||||
if ( in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_css', 'css_set_id=0 AND css_app=\''. addslashes( $app ) . '\'' );
|
||||
$this->DB->delete( 'skin_css', 'css_set_id=0 AND css_master_key=\'' . $skinMasterKey . '\' AND css_app=\''. addslashes( $app ) . '\'' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1447,6 +1712,7 @@ class skinImportExport extends skinCaching
|
||||
'css_app_hide' => $_css['css_app_hide'],
|
||||
'css_attributes' => $_css['css_attributes'],
|
||||
'css_modules' => $_css['css_modules'],
|
||||
'css_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
|
||||
'css_set_id' => $setID,
|
||||
'css_added_to' => $setID ) );
|
||||
}
|
||||
@@ -1487,17 +1753,13 @@ class skinImportExport extends skinCaching
|
||||
{
|
||||
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
{
|
||||
$this->_addErrorMessage( $file . ' нет прав на запись' );
|
||||
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
file_put_contents( $file, $xml );
|
||||
|
||||
$this->_addMessage( "CSS для " . $app_dir . ' - ' . $setData['set_key'] . " создан" );
|
||||
}
|
||||
else
|
||||
{
|
||||
//$this->_addMessage( "CSS XML for " . $app_dir . ' - ' . $setData['set_key'] . " could not be generated" );
|
||||
$this->_addMessage( sprintf( $this->lang->words['csscreatedmsg'], $app_dir, $setData['set_key'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,17 +1795,13 @@ class skinImportExport extends skinCaching
|
||||
{
|
||||
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
{
|
||||
$this->_addErrorMessage( $file . ' нет прав на запись' );
|
||||
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
file_put_contents( $file, $xml );
|
||||
|
||||
$this->_addMessage( "Шаблоны для " . $app_dir . ' - ' . $setData['set_key'] . " созданы" );
|
||||
}
|
||||
else
|
||||
{
|
||||
//$this->_addMessage( "XML for " . $app_dir . ' - ' . $setData['set_key'] . " could not be generated" );
|
||||
$this->_addMessage( sprintf( $this->lang->words['templatescreatedmsg'], $app_dir, $setData['set_key'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1568,28 +1826,37 @@ class skinImportExport extends skinCaching
|
||||
$fileXML = IPSLib::getAppDir( $app ) . '/xml/' . $app . '_' . $skinKey . '_templates.xml';
|
||||
$infoXML = IPSLib::getAppDir( $app ) . '/xml/information.xml';
|
||||
$return = array( 'updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array() );
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
if( ! file_exists($fileXML) )
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
|
||||
if ( ! $setID and $skinKey != 'root' )
|
||||
if ( ! $setID and ! in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
/* Figure out correct set ID based on key */
|
||||
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_collections',
|
||||
'where' => "set_key='" . $skinKey . "'" ) );
|
||||
|
||||
$setID = $skinSetData['set_id'];
|
||||
$setID = $skinSetData['set_id'];
|
||||
$skinMasterKey = $skinSetData['set_master_key'];
|
||||
}
|
||||
|
||||
/* Set ignore flag correctly */
|
||||
if ( ! empty( $skinKey ) AND in_array( $skinKey, array( 'root', 'lofi', 'xmlskin' ) ) )
|
||||
if ( ! empty( $skinKey ) AND in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
$ignoreAddedEditedFlag = true;
|
||||
}
|
||||
|
||||
/* If this is a 'master' skin, then reset master key */
|
||||
if ( in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
$skinMasterKey = $skinKey;
|
||||
$setID = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
@@ -1616,7 +1883,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( ! is_array( $templateGroups ) OR ! count( $templateGroups ) )
|
||||
{
|
||||
$this->_addMessage( "Нечего экспортировать для приложения " . $app );
|
||||
$this->_addMessage( $this->lang->words['nothingtoexportfor'] . $app );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1624,8 +1891,8 @@ class skinImportExport extends skinCaching
|
||||
// Fetch templates
|
||||
//-----------------------------------------
|
||||
|
||||
$_templates = $this->fetchTemplates( $setID, 'allNoContent' );
|
||||
$_MASTER = $this->fetchTemplates( 0, 'allNoContent' );
|
||||
$_templates = $this->fetchTemplates( $setID , 'allNoContent' );
|
||||
$_MASTER = $this->fetchTemplates( $skinMasterKey, 'allNoContent' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through...
|
||||
@@ -1664,9 +1931,9 @@ class skinImportExport extends skinCaching
|
||||
// Wipe the master skins
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $setID == 0 )
|
||||
if ( in_array( $skinKey, $masterKeys ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_templates', "template_set_id=0 AND template_group IN ('" . implode( "','", array_keys( $templates ) ) . "') AND template_user_added=0 AND template_added_to=0" );
|
||||
$this->DB->delete( 'skin_templates', "template_master_key='" . $skinKey . "' AND template_group IN ('" . implode( "','", array_keys( $templates ) ) . "') AND template_user_added=0 AND template_added_to=0" );
|
||||
|
||||
/* Now wipe the array so we enforce creation */
|
||||
unset( $templates );
|
||||
@@ -1703,6 +1970,7 @@ class skinImportExport extends skinCaching
|
||||
'template_data' => $data['template_data'],
|
||||
'template_user_edited' => $isEdited,
|
||||
'template_user_added' => $isAdded,
|
||||
'template_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
|
||||
'template_updated' => time() ), 'template_set_id=' . $setID . " AND template_group='" . $data['template_group'] . "' AND template_name='" . $data['template_name'] . "'" );
|
||||
}
|
||||
else
|
||||
@@ -1719,6 +1987,7 @@ class skinImportExport extends skinCaching
|
||||
'template_added_to' => $setID,
|
||||
'template_user_edited' => $isEdited,
|
||||
'template_user_added' => $isAdded,
|
||||
'template_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
|
||||
'template_updated' => time() ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user