Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
+44
-27
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Theme\Dev;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -45,9 +45,9 @@ class _Theme extends \IPS\Theme
|
||||
public function getRawTemplates( $app=array(), $location=array(), $group=array(), $returnType=null, $returnThisSetOnly=false )
|
||||
{
|
||||
$returnType = ( $returnType === null ) ? self::RETURN_ALL : $returnType;
|
||||
$app = ( is_string( $app ) AND $app != '' ) ? array( $app ) : $app;
|
||||
$location = ( is_string( $location ) AND $location != '' ) ? array( $location ) : $location;
|
||||
$group = ( is_string( $group ) AND $group != '' ) ? array( $group ) : $group;
|
||||
$app = ( \is_string( $app ) AND $app != '' ) ? array( $app ) : $app;
|
||||
$location = ( \is_string( $location ) AND $location != '' ) ? array( $location ) : $location;
|
||||
$group = ( \is_string( $group ) AND $group != '' ) ? array( $group ) : $group;
|
||||
$where = array();
|
||||
$templates = array();
|
||||
|
||||
@@ -61,17 +61,17 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
foreach( \IPS\Application::applications() as $appDir => $application )
|
||||
{
|
||||
if ( $app === NULL or ( in_array( $appDir, $app ) ) )
|
||||
if ( $app === NULL or ( \in_array( $appDir, $app ) ) )
|
||||
{
|
||||
foreach( $fixedLocations as $_location )
|
||||
{
|
||||
if ( $location === NULL or ( in_array( $_location, $location ) ) ) # location?
|
||||
if ( $location === NULL or ( \in_array( $_location, $location ) ) ) # location?
|
||||
{
|
||||
foreach( new \DirectoryIterator( static::_getHtmlPath( $appDir, $_location ) ) as $file )
|
||||
{
|
||||
if ( $file->isDir() AND mb_substr( $file->getFilename(), 0, 1 ) !== '.' )
|
||||
{
|
||||
if ( $group === NULL or ( in_array( $file->getFilename(), $group ) ) )
|
||||
if ( $group === NULL or ( \in_array( $file->getFilename(), $group ) ) )
|
||||
{
|
||||
foreach( new \DirectoryIterator( static::_getHtmlPath( $appDir, $_location, $file->getFilename() ) ) as $template )
|
||||
{
|
||||
@@ -132,7 +132,16 @@ class _Theme extends \IPS\Theme
|
||||
if( file_exists( \IPS\ROOT_PATH . '/' . $data['file'] ) )
|
||||
{
|
||||
$contents = "namespace " . rtrim( static::_getTemplateNamespace(), '\\' ) . ";\n\n" . str_replace( '_HOOK_CLASS_', $class, file_get_contents( \IPS\ROOT_PATH . '/' . $data['file'] ) );
|
||||
eval( $contents );
|
||||
|
||||
if ( \IPS\DEBUG_TEMPLATES )
|
||||
{
|
||||
static::runDebugTemplate( str_replace( '/', '_', $data['file'] ), $contents );
|
||||
}
|
||||
else
|
||||
{
|
||||
eval( $contents );
|
||||
}
|
||||
|
||||
$class = $data['class'];
|
||||
}
|
||||
}
|
||||
@@ -166,7 +175,7 @@ class _Theme extends \IPS\Theme
|
||||
$path = static::_getCssPath($app, $location, $file);
|
||||
}
|
||||
|
||||
if ( isset( self::$buildGrouping['css'][ $app ][ $location ] ) AND is_array( self::$buildGrouping['css'][ $app ][ $location ] ) )
|
||||
if ( isset( self::$buildGrouping['css'][ $app ][ $location ] ) AND \is_array( self::$buildGrouping['css'][ $app ][ $location ] ) )
|
||||
{
|
||||
foreach( self::$buildGrouping['css'][ $app ][ $location ] as $buildPath )
|
||||
{
|
||||
@@ -202,7 +211,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
sort( $csses );
|
||||
|
||||
if ( count( $csses ) )
|
||||
if ( \count( $csses ) )
|
||||
{
|
||||
if( \IPS\DEV_DEBUG_CSS )
|
||||
{
|
||||
@@ -312,6 +321,7 @@ class _Theme extends \IPS\Theme
|
||||
* @param string $path Path to resource
|
||||
* @param string|null $app Application key
|
||||
* @param string|null $location Location
|
||||
* @param bool $noProtocol Return URL without a protocol (protocol-relative)
|
||||
* @return \IPS\Http\Url|NULL URL to resource
|
||||
*/
|
||||
public function resource( $path, $app=NULL, $location=NULL, $noProtocol=FALSE )
|
||||
@@ -367,7 +377,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
if ( $location->isDir() )
|
||||
{
|
||||
if ( ! in_array( $location->getFilename(), $themeLocations ) )
|
||||
if ( ! \in_array( $location->getFilename(), $themeLocations ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -465,7 +475,6 @@ class _Theme extends \IPS\Theme
|
||||
*
|
||||
* @param string $app Application Key
|
||||
* @param int $id Theme Set Id (0 if IN_DEV and not in advanced theming mode)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function importDevCss( $app, $id )
|
||||
@@ -507,7 +516,7 @@ class _Theme extends \IPS\Theme
|
||||
*
|
||||
* @param string $app Application Key
|
||||
* @param int $id Theme set ID
|
||||
* @param array $master Master CSS bits
|
||||
* @param array $currentCss Master CSS bits
|
||||
* @param string $location Location Folder Name
|
||||
* @param string $path Path
|
||||
* @return void
|
||||
@@ -541,7 +550,7 @@ class _Theme extends \IPS\Theme
|
||||
preg_match( '#^/\*<ips:css([^>]+?)>\*/\n#', $css, $params );
|
||||
|
||||
/* Strip it */
|
||||
if ( count( $params ) AND ! empty( $params[0] ) )
|
||||
if ( \count( $params ) AND ! empty( $params[0] ) )
|
||||
{
|
||||
$css = str_replace( $params[0], '', $css );
|
||||
}
|
||||
@@ -552,7 +561,7 @@ class _Theme extends \IPS\Theme
|
||||
$cssHidden = 0;
|
||||
|
||||
/* Tidy params */
|
||||
if ( count( $params ) AND ! empty( $params[1] ) )
|
||||
if ( \count( $params ) AND ! empty( $params[1] ) )
|
||||
{
|
||||
preg_match_all( '#([\d\w]+?)=\"([^"]+?)"#i', $params[1], $items, PREG_SET_ORDER );
|
||||
|
||||
@@ -567,10 +576,10 @@ class _Theme extends \IPS\Theme
|
||||
$cssApp = trim( $attr[2] );
|
||||
break;
|
||||
case 'position':
|
||||
$cssPos = intval( $attr[2] );
|
||||
$cssPos = \intval( $attr[2] );
|
||||
break;
|
||||
case 'hidden':
|
||||
$cssHidden = intval( $attr[2] );
|
||||
$cssHidden = \intval( $attr[2] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -631,9 +640,9 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
/**
|
||||
* Build Resourcess ready for non IN_DEV use
|
||||
*
|
||||
* @param string|array $app App (e.g. core, forum)
|
||||
* @param int $id Theme Set Id (0 if IN_DEV and not in advanced theming mode)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function importDevResources( $app=NULL, $id )
|
||||
@@ -647,7 +656,11 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
if ( $app === null OR $app == $dir->getFilename() )
|
||||
{
|
||||
\IPS\Theme::deleteCompiledResources( $dir->getFilename(), null, null, null, ( $id === 0 ? \IPS\DEFAULT_THEME_ID : $id ) );
|
||||
/* When we are building, removeResources() has already taken care of this */
|
||||
if( $id !== 0 )
|
||||
{
|
||||
\IPS\Theme::deleteCompiledResources( $dir->getFilename(), null, null, null, $id );
|
||||
}
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
@@ -688,7 +701,6 @@ class _Theme extends \IPS\Theme
|
||||
* @param int $id Theme Set Id
|
||||
* @param string $location Location Folder Name
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function _importDevResources( $app, $id, $location, $path='/' )
|
||||
@@ -735,9 +747,9 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
$custom = 0;
|
||||
$name = self::makeBuiltTemplateLookupHash($app, $location, $path) . '_' . $file->getFilename();
|
||||
$fileName = (string) \IPS\File::create( 'core_Theme', $name, $content, 'set_resources_' . ( $id == 0 ? \IPS\DEFAULT_THEME_ID : $id ) );
|
||||
$fileName = (string) \IPS\File::create( 'core_Theme', $name, $content, 'set_resources_' . ( $id == 0 ? \IPS\DEFAULT_THEME_ID : $id ), TRUE );
|
||||
|
||||
if ( ! isset( $master[ $file->getFilename() ] ) or !\IPS\Login::compareHashes( md5( $content ), $master[ $file->getFilename() ] ) )
|
||||
if ( $id !== 0 AND ( !isset( $master[ $file->getFilename() ] ) or !\IPS\Login::compareHashes( md5( $content ), $master[ $file->getFilename() ] ) ) )
|
||||
{
|
||||
$custom = 1;
|
||||
}
|
||||
@@ -813,9 +825,10 @@ class _Theme extends \IPS\Theme
|
||||
/**
|
||||
* Writes the /application/{app}/dev/{container}/{path} directory
|
||||
*
|
||||
* @param string $app Application Directory
|
||||
* @param string $container Path to create (e.g. admin, front)
|
||||
* @return string Path created
|
||||
* @param string $app Application Directory
|
||||
* @param string $container Location of path to create (e.g. admin, front)
|
||||
* @param string $path Path to create
|
||||
* @return string Path created
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected static function _writeThemePathDirectory( $app, $container, $path )
|
||||
@@ -990,7 +1003,7 @@ class _Theme extends \IPS\Theme
|
||||
$params[] = 'hidden="1"';
|
||||
}
|
||||
|
||||
if ( count( $params ) )
|
||||
if ( \count( $params ) )
|
||||
{
|
||||
$write .= '/*<ips:css ' . implode( ' ', $params ) . ' />*/' . "\n";
|
||||
}
|
||||
@@ -1104,7 +1117,7 @@ class _Theme extends \IPS\Theme
|
||||
{
|
||||
$file = \IPS\ROOT_PATH . "/applications/{$app}/data/themesettings.json";
|
||||
|
||||
if( @\file_put_contents( $file, version_compare( PHP_VERSION, '5.4.0' ) >= 0 ? json_encode( $json, JSON_PRETTY_PRINT ) : json_encode( $json ) ) === FALSE )
|
||||
if( @\file_put_contents( $file, json_encode( $json, JSON_PRETTY_PRINT ) ) === FALSE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'dev_could_not_write_data', '1C103/4', 403, '' );
|
||||
}
|
||||
@@ -1144,6 +1157,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
/**
|
||||
* Returns the namespace for the template class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _getTemplateNamespace()
|
||||
@@ -1153,6 +1167,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
/**
|
||||
* Returns the path for the IN_DEV .phtml files
|
||||
*
|
||||
* @param string $app Application Key
|
||||
* @param string|null $location Location
|
||||
* @param string|null $path Path or Filename
|
||||
@@ -1165,6 +1180,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
/**
|
||||
* Returns the path for the IN_DEV CSS file
|
||||
*
|
||||
* @param string $app Application Key
|
||||
* @param string|null $location Location
|
||||
* @param string|null $path Path or Filename
|
||||
@@ -1177,6 +1193,7 @@ class _Theme extends \IPS\Theme
|
||||
|
||||
/**
|
||||
* Returns the path for the IN_DEV resource files
|
||||
*
|
||||
* @param string $app Application Key
|
||||
* @param string|null $location Location
|
||||
* @param string|null $path Path or Filename
|
||||
|
||||
Reference in new issue
Block a user