Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Javascript Handler
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 12 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -157,8 +157,8 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
$key = md5( $this->app . ';' . $this->location . ';' . $this->path . ';' . $this->name );
|
||||
\file_put_contents( $path . '/' . $this->name, $this->content );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->replace( 'core_javascript', array(
|
||||
|
||||
\IPS\Db::i()->insert( 'core_javascript', array(
|
||||
'javascript_app' => $this->app,
|
||||
'javascript_location' => $this->location,
|
||||
'javascript_plugin' => $this->plugin,
|
||||
@@ -169,9 +169,6 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
'javascript_version' => $this->version,
|
||||
'javascript_position' => ( $this->position ) ? $this->position : 2000000,
|
||||
'javascript_key' => $key
|
||||
),
|
||||
array(
|
||||
'javascript_app', 'javascript_location', 'javascript_path', 'javascript_name'
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -212,16 +209,18 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
$where = array( 'javascript_app=?', 'javascript_location=?', 'javascript_path=?', 'javascript_name=?' );
|
||||
$bindings = array( $this->app, $this->location, $this->path, $this->name );
|
||||
$_where = "javascript_app=? AND javascript_location=? AND javascript_path=? AND javascript_name=?";
|
||||
$where = array( $this->app, $this->location, $this->path, $this->name );
|
||||
|
||||
if ( $this->location == 'plugins' )
|
||||
{
|
||||
$where[] = 'javascript_plugin=?';
|
||||
$bindings[] = $this->plugin;
|
||||
$_where .= " AND javascript_plugin=?";
|
||||
$where = array_merge( $where, array( $this->plugin ) );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_javascript', array( implode( ' AND ', $where ), $bindings ) );
|
||||
|
||||
array_unshift( $where, $_where );
|
||||
|
||||
\IPS\Db::i()->delete( 'core_javascript', $where );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +251,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
$xml->endAttribute();
|
||||
|
||||
/* Loop */
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_javascript', ( $app === 'core' ) ? \IPS\Db::i()->in( 'javascript_app', array('core', 'global') ) : array( 'javascript_app=?', $app ), 'javascript_path, javascript_name' ) as $js )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_javascript', ( $app === 'core' ) ? \IPS\Db::i()->in( 'javascript_app', array('core', 'global') ) : array( 'javascript_app=?', $app ), 'javascript_path, javascript_location, javascript_name' ) as $js )
|
||||
{
|
||||
/* Initiate the <template> tag */
|
||||
$xml->startElement('file');
|
||||
@@ -333,13 +332,18 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
if( $maxExecution = @ini_get( 'max_execution_time' ) )
|
||||
{
|
||||
/* If max_execution_time is set to "no limit" we should add a hard limit to prevent browser timeouts */
|
||||
if ( $maxExecution == -1 )
|
||||
{
|
||||
$maxExecution = 30;
|
||||
}
|
||||
|
||||
$cutOff = time() + ( $maxExecution * .5 );
|
||||
}
|
||||
|
||||
/* Open XML file */
|
||||
$xml = new \XMLReader;
|
||||
$xml = new \IPS\Xml\XMLReader;
|
||||
$xml->open( $file );
|
||||
|
||||
$xml->read();
|
||||
|
||||
$app = $xml->getAttribute('app');
|
||||
@@ -466,9 +470,8 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
/* Open XML file */
|
||||
if( file_exists( \IPS\ROOT_PATH . '/applications/' . $app . '/data/javascript.xml' ) )
|
||||
{
|
||||
$xml = new \XMLReader;
|
||||
$xml->open( \IPS\ROOT_PATH . '/applications/' . $app . '/data/javascript.xml' );
|
||||
|
||||
$xml = new \IPS\Xml\XMLReader;
|
||||
$xml->open( \IPS\ROOT_PATH . '/applications/' . $app . '/data/javascript.xml' );
|
||||
$xml->read();
|
||||
|
||||
while( $xml->read() )
|
||||
@@ -696,20 +699,15 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
public static function compile( $app, $location=null, $file=null )
|
||||
{
|
||||
$flagKey = 'js_compiling_' . md5( $app . ',' . $location . ',' . $file );
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->$flagKey ) and ! empty( \IPS\Data\Store::i()->$flagKey ) )
|
||||
if ( \IPS\Theme::checkLock( $flagKey ) )
|
||||
{
|
||||
/* We're currently rebuilding */
|
||||
if ( time() - \IPS\Data\Store::i()->$flagKey < 30 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
\IPS\Theme::lock( $flagKey );
|
||||
|
||||
\IPS\Data\Store::i()->$flagKey = time();
|
||||
|
||||
$map = ( isset( \IPS\Data\Store::i()->javascript_map ) ) ? \IPS\Data\Store::i()->javascript_map : array();
|
||||
$files = ( isset( \IPS\Data\Store::i()->javascript_file_map ) ) ? \IPS\Data\Store::i()->javascript_file_map : array();
|
||||
$map = ( isset( \IPS\Data\Store::i()->javascript_map ) and is_array( \IPS\Data\Store::i()->javascript_map ) ) ? \IPS\Data\Store::i()->javascript_map : array();
|
||||
$files = ( isset( \IPS\Data\Store::i()->javascript_file_map ) and is_array( \IPS\Data\Store::i()->javascript_file_map ) ) ? \IPS\Data\Store::i()->javascript_file_map : array();
|
||||
|
||||
if ( $location === null and $file === null )
|
||||
{
|
||||
@@ -882,7 +880,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->javascript_map = $map;
|
||||
unset( \IPS\Data\Store::i()->$flagKey );
|
||||
\IPS\Theme::unlock( $flagKey );
|
||||
|
||||
/* As the filename has changed, rebuild the JS map */
|
||||
if ( ( $app !== 'global' and ( $location === NULL or in_array( $location, array( 'admin', 'front', 'global' ) ) ) ) )
|
||||
@@ -904,8 +902,8 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
protected static function _writeJavascriptFromResultset( $files, $fileName, $app, $location )
|
||||
{
|
||||
$content = '';
|
||||
$jsMap = ( isset( \IPS\Data\Store::i()->javascript_map ) ) ? \IPS\Data\Store::i()->javascript_map : array();
|
||||
$content = array();
|
||||
$jsMap = ( isset( \IPS\Data\Store::i()->javascript_map ) and is_array( \IPS\Data\Store::i()->javascript_map ) ) ? \IPS\Data\Store::i()->javascript_map : array();
|
||||
|
||||
/* Try and remove any existing files */
|
||||
try
|
||||
@@ -969,7 +967,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Get javascript language as a script
|
||||
*
|
||||
* @param int $lang ID of language to fetch
|
||||
* @param int $langId ID of language to fetch
|
||||
* @return string
|
||||
*/
|
||||
public static function getJavascriptLanguage( $langId )
|
||||
@@ -993,9 +991,9 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
foreach ( \IPS\Plugin::plugins() as $plugin )
|
||||
{
|
||||
if ( file_exists( \IPS\ROOT_PATH . "/plugins/{$plugin->location}/dev/lang.php" ) )
|
||||
if ( file_exists( \IPS\ROOT_PATH . "/plugins/{$plugin->location}/dev/jslang.php" ) )
|
||||
{
|
||||
require \IPS\ROOT_PATH . "/plugins/{$plugin->location}/dev/lang.php";
|
||||
require \IPS\ROOT_PATH . "/plugins/{$plugin->location}/dev/jslang.php";
|
||||
$_lang = array_merge( $_lang, $lang );
|
||||
}
|
||||
}
|
||||
@@ -1096,7 +1094,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
if ( mb_substr( $file, 0, 8 ) === 'js_lang_' )
|
||||
{
|
||||
return array( \IPS\Settings::i()->base_url . "/applications/core/interface/js/jslang.php?langId=" . intval( mb_substr( $file, 8, -3 ) ) );
|
||||
return array( \IPS\Http\Url::baseUrl() . "/applications/core/interface/js/jslang.php?langId=" . intval( mb_substr( $file, 8, -3 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,7 +1145,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( str_replace( \IPS\ROOT_PATH, \IPS\Settings::i()->base_url, $path ) );
|
||||
return array( str_replace( \IPS\ROOT_PATH, \IPS\Http\Url::baseUrl(), $path ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,7 +1184,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[ $app ][ $location . '_' . $controllerDir ] = str_replace( \IPS\ROOT_PATH, trim( \IPS\Settings::i()->base_url, '/' ), $controllerPath ) . '/' . $file->getFileName();
|
||||
$files[ $app ][ $location . '_' . $controllerDir ] = str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ), '/' ), $controllerPath ) . '/' . $file->getFileName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1206,7 +1204,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
protected static function _urlToComponents( $url )
|
||||
{
|
||||
$url = ltrim( str_replace( \IPS\Settings::i()->base_url . 'applications', '', $url ), '/' );
|
||||
$url = ltrim( str_replace( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ) . 'applications', '', $url ), '/' );
|
||||
$bits = explode( "/", $url );
|
||||
|
||||
$app = array_shift( $bits );
|
||||
@@ -1225,7 +1223,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Gets app specific Javascript
|
||||
*
|
||||
* @param string $key Application
|
||||
* @param string $app Application
|
||||
* @param string $location Location (front, global, etc)
|
||||
* @return void
|
||||
*/
|
||||
@@ -1276,7 +1274,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
else if ( \file_exists( $templatesDir . '/ips.templates.' . $key . '.js' ) )
|
||||
{
|
||||
$templates = array( str_replace( \IPS\ROOT_PATH, trim( \IPS\Settings::i()->base_url, '/' ), $templatesDir . '/ips.templates.' . $key . '.js' ) );
|
||||
$templates = array( str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ), '/' ), $templatesDir . '/ips.templates.' . $key . '.js' ) );
|
||||
}
|
||||
|
||||
return array_merge( $templates, $controllers );
|
||||
@@ -1307,7 +1305,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
else if ( mb_substr( $file->getFileName(), -3 ) === '.js' )
|
||||
{
|
||||
$contents[] = str_replace( \IPS\ROOT_PATH, trim( \IPS\Settings::i()->base_url, '/' ), $path ) . '/' . $file->getFileName();
|
||||
$contents[] = str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ), '/' ), $path ) . '/' . $file->getFileName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,7 +1349,7 @@ class _Javascript extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mb_substr( str_replace( \IPS\Settings::i()->base_url . ltrim( str_replace( \IPS\ROOT_PATH, '', $path ), '/' ), '', $url ), 1, (mb_strlen( $item ) ) ) == $item )
|
||||
if ( mb_substr( str_replace( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ) . ltrim( str_replace( \IPS\ROOT_PATH, '', $path ), '/' ), '', $url ), 1, (mb_strlen( $item ) ) ) == $item )
|
||||
{
|
||||
$reordered[] = $url;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user