Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+91
-12
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Hook Model
|
||||
* @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 5 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -102,8 +102,28 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
$classname = is_int( $appOrPluginId ) ? "hook{$hook->id}" : "{$appOrPluginId}_hook_{$hook->filename}";
|
||||
\file_put_contents( $hookDir . "/{$hook->filename}.php", "//<?php\n\n{$abstract}class {$classname} extends _HOOK_CLASS_\n{\n\n\n}" );
|
||||
|
||||
/* Work out the contents */
|
||||
$contents = str_replace(
|
||||
array(
|
||||
'{abstract}',
|
||||
'{classname}',
|
||||
),
|
||||
array(
|
||||
$abstract,
|
||||
$classname,
|
||||
),
|
||||
\file_get_contents( \IPS\ROOT_PATH . '/applications/core/data/defaults/Hook.txt' )
|
||||
);
|
||||
|
||||
\file_put_contents( $hookDir . "/{$hook->filename}.php", $contents );
|
||||
static::writeDataFile();
|
||||
|
||||
/* Write application json file automatically */
|
||||
if( $hook->app )
|
||||
{
|
||||
\IPS\Application::load( $hook->app )->buildHooks();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
@@ -116,7 +136,15 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
try
|
||||
{
|
||||
$hook = static::load( \IPS\Request::i()->hook )->delete();
|
||||
$hook = static::load( \IPS\Request::i()->hook );
|
||||
$hook->delete();
|
||||
|
||||
/* Write application json file automatically */
|
||||
if( $hook->app )
|
||||
{
|
||||
\IPS\Application::load( $hook->app )->buildHooks();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -127,9 +155,17 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
/* Table */
|
||||
default:
|
||||
$table = new \IPS\Helpers\Table\Db( static::$databaseTable, $url, ( is_string( $appOrPluginId ) ? array( 'app=?', $appOrPluginId ) : array( 'plugin=?', $appOrPluginId ) ) );
|
||||
$table->include = array( 'class' );
|
||||
$table->include = array( 'filename', 'class' );
|
||||
$table->langPrefix = 'plugin_hook_';
|
||||
$table->sortBy = $table->sortBy ?: 'class';
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'filename' => function( $val, $row )
|
||||
{
|
||||
return $val . '.php';
|
||||
}
|
||||
);
|
||||
|
||||
$table->rootButtons = array(
|
||||
'add' => array(
|
||||
@@ -207,6 +243,15 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
\file_put_contents( \IPS\ROOT_PATH . '/plugins/hooks.php', "<?php\nreturn " . var_export( $hooks, TRUE ) . ';' );
|
||||
|
||||
/* Clear zend opcache if enabled */
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/plugins/hooks.php' );
|
||||
}
|
||||
|
||||
/* IPS Cloud Sync */
|
||||
\IPS\IPS::resyncIPSCloud();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,13 +281,14 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
public function editForm( $url )
|
||||
{
|
||||
$url = $url->setQueryString( 'tab', NULL )->setQueryString( 'hook', $this->id );
|
||||
|
||||
|
||||
if( !\IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/plugins.css' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'controllers/system' ) );
|
||||
\IPS\Output::i()->title = $this->class;
|
||||
\IPS\Output::i()->breadcrumb[] = array( $url, \IPS\Member::loggedIn()->language()->addToStack('plugin_hooks') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $this->filename . '.php' );
|
||||
}
|
||||
|
||||
/* Code Hooks */
|
||||
@@ -256,7 +302,20 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\file_put_contents( $this->getFilename(), $values['code'] );
|
||||
|
||||
/* Write application json file automatically */
|
||||
if( $this->app )
|
||||
{
|
||||
\IPS\Application::load( $this->app )->buildHooks();
|
||||
}
|
||||
|
||||
static::writeDataFile();
|
||||
|
||||
if( isset( \IPS\Request::i()->save_and_reload ) AND !\IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url(), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
@@ -278,7 +337,11 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
$parameters = array();
|
||||
foreach ( $method->getParameters() as $parameter )
|
||||
{
|
||||
$parameters[] = ( $parameter->getClass() ? ( '\\' . $parameter->getClass()->getName() . ' ' ) : '' ) . ( $parameter->isPassedByReference() ? '&' : '' ) . '$' . $parameter->name . ( $parameter->isOptional() ? ( '=' . var_export( $parameter->getDefaultValue(), TRUE ) ) : '' );
|
||||
try
|
||||
{
|
||||
$parameters[] = ( $parameter->getClass() ? ( '\\' . $parameter->getClass()->getName() . ' ' ) : '' ) . ( $parameter->isPassedByReference() ? '&' : '' ) . '$' . $parameter->name . ( $parameter->isOptional() ? ( '=' . var_export( $parameter->getDefaultValue(), TRUE ) ) : '' );
|
||||
}
|
||||
catch ( \ReflectionException $e ) {}
|
||||
}
|
||||
|
||||
$method->signature = json_encode( 'function ' . $method->name . '\(' );
|
||||
@@ -288,6 +351,8 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
$form->addSidebar( \IPS\Theme::i()->getTemplate( 'applications' )->codeHookSidebar( $data ) );
|
||||
|
||||
$form->canSaveAndReload = true;
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'applications' ), 'codeHookEditor' ) );
|
||||
@@ -356,7 +421,8 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->attributes['data-controller'] = 'core.admin.system.themeHook';
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'plugin_theme_hook_selector', ( $current ? $current['selector'] : NULL ), TRUE, array( 'placeholder' => '#element' ), NULL, NULL, "<a href='#' data-ipsDialog data-ipsDialog-fixed data-ipsDialog-url='" . \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins&do=templateTree&class=' . urlencode( $this->class ) . "&template=" . urlencode( \IPS\Request::i()->template ) ) . "' data-ipsDialog-title='". \IPS\Member::loggedIn()->language()->addToStack('plugin_theme_hook_select') ."' class='ipsButton ipsButton_light ipsButton_small ipsHide' data-action='showTemplate'>" . \IPS\Member::loggedIn()->language()->addToStack('plugin_theme_hook_select') . "</a>", 'plugin_theme_hook_selector' . $_idSuffix ) );
|
||||
$dialogUrl = \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins&do=templateTree' )->setQueryString( array( 'class' => $this->class, 'template' => \IPS\Request::i()->template ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'plugin_theme_hook_selector', ( $current ? $current['selector'] : NULL ), TRUE, array( 'placeholder' => '#element' ), NULL, NULL, "<a href='#' data-ipsDialog data-ipsDialog-fixed data-ipsDialog-url='" . $dialogUrl . "' data-ipsDialog-title='". \IPS\Member::loggedIn()->language()->addToStack('plugin_theme_hook_select') ."' class='ipsButton ipsButton_light ipsButton_small ipsHide' data-action='showTemplate'>" . \IPS\Member::loggedIn()->language()->addToStack('plugin_theme_hook_select') . "</a>", 'plugin_theme_hook_selector' . $_idSuffix ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'plugin_theme_hook_type', ( $current ? $current['type'] : NULL ), TRUE, array(
|
||||
'options' => array(
|
||||
'add_before' => 'plugin_theme_hook_type_add_before',
|
||||
@@ -436,9 +502,15 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
/* Write */
|
||||
$this->_writeThemeHookData( $hookData );
|
||||
|
||||
/* Write application json file automatically */
|
||||
if( $this->app )
|
||||
{
|
||||
\IPS\Application::load( $this->app )->buildHooks();
|
||||
}
|
||||
|
||||
/* Boink */
|
||||
\IPS\Output::i()->redirect( $url->setQueryString( 'template', $template )->setQueryString( 'do', 'editHook' ) );
|
||||
\IPS\Output::i()->redirect( $url->setQueryString( array( 'hookApp' => $this->app, 'hookFilename' => $this->filename, 'template' => $template, 'do' => 'editHook' ) ) );
|
||||
}
|
||||
|
||||
/* Construct tab interface */
|
||||
@@ -471,11 +543,11 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
/* Build */
|
||||
if( !count( $hookData ) )
|
||||
{
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\n\n/* End Hook Data */\n\n";
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\n\n/* End Hook Data */";
|
||||
}
|
||||
else
|
||||
{
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\npublic static function hookData() {\n return array_merge_recursive( " . var_export( $hookData, TRUE ) . ", parent::hookData() );\n}\n/* End Hook Data */\n\n";
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\npublic static function hookData() {\n return array_merge_recursive( " . var_export( $hookData, TRUE ) . ", parent::hookData() );\n}\n/* End Hook Data */";
|
||||
}
|
||||
|
||||
/* Write */
|
||||
@@ -502,7 +574,14 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function validate( $val )
|
||||
{
|
||||
if ( eval( str_replace( 'extends _HOOK_CLASS_', '', $val ) ) === FALSE )
|
||||
try
|
||||
{
|
||||
if ( eval( str_replace( 'extends _HOOK_CLASS_', '', $val ) ) === FALSE )
|
||||
{
|
||||
throw new \DomainException( 'plugin_hook_code_err_parse' );
|
||||
}
|
||||
}
|
||||
catch ( \ParseError $e )
|
||||
{
|
||||
throw new \DomainException( 'plugin_hook_code_err_parse' );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user