Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+27
-18
@@ -90,7 +90,7 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
$hook->type = $values['plugin_hook_type'];
|
||||
$hook->class = ( $values['plugin_hook_type'] == 'C' ) ? ( '\IPS\\' . $values['plugin_hook_class'] ) : ( '\IPS\Theme\class_' . $values['plugin_hook_group'] );
|
||||
$hook->filename = $values['plugin_hook_location'] ?: md5( uniqid() );
|
||||
$hook->filename = $values['plugin_hook_location'] ?: md5( mt_rand() );
|
||||
$hook->save();
|
||||
|
||||
$abstract = '';
|
||||
@@ -116,6 +116,12 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
);
|
||||
|
||||
\file_put_contents( $hookDir . "/{$hook->filename}.php", $contents );
|
||||
|
||||
if ( $values['plugin_hook_type'] != 'C' )
|
||||
{
|
||||
$hook->writeThemeHookData( array() );
|
||||
}
|
||||
|
||||
static::writeDataFile();
|
||||
|
||||
/* Write application json file automatically */
|
||||
@@ -209,6 +215,7 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
$hooks = array();
|
||||
$seen = array();
|
||||
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
'core_hooks.*, core_plugins.*, core_applications.*',
|
||||
@@ -225,20 +232,22 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
foreach ( $stmt as $row )
|
||||
{
|
||||
if ( $row['plugin'] )
|
||||
$overloadedClass = trim( $row['class'] );
|
||||
$file = ( $row['plugin'] ) ? "plugins/{$row['plugin_location']}/hooks/{$row['filename']}.php" : "applications/{$row['app']}/hooks/{$row['filename']}.php";
|
||||
$class = ( $row['plugin'] ) ? "hook{$row['id']}" : $row['app'] . '_hook_' . $row['filename'];
|
||||
|
||||
/* Duplicate rows cause WSOD as class is created twice by monkey patching */
|
||||
if ( isset( $seen[ $overloadedClass ][ $file ][ $class ] ) )
|
||||
{
|
||||
$hooks[ trim( $row['class'] ) ][ $row['id'] ] = array(
|
||||
'file' => "plugins/{$row['plugin_location']}/hooks/{$row['filename']}.php",
|
||||
'class' => "hook{$row['id']}",
|
||||
);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hooks[ trim( $row['class'] ) ][ $row['id'] ] = array(
|
||||
'file' => "applications/{$row['app']}/hooks/{$row['filename']}.php",
|
||||
'class' => $row['app'] . '_hook_' . $row['filename'],
|
||||
);
|
||||
}
|
||||
|
||||
$seen[ $overloadedClass ][ $file ][ $class ] = true;
|
||||
|
||||
$hooks[ $overloadedClass ][ $row['id'] ] = array(
|
||||
'file' => $file,
|
||||
'class' => $class,
|
||||
);
|
||||
}
|
||||
|
||||
\file_put_contents( \IPS\ROOT_PATH . '/plugins/hooks.php', "<?php\nreturn " . var_export( $hooks, TRUE ) . ';' );
|
||||
@@ -344,7 +353,7 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
$method->signature = json_encode( 'function ' . $method->name . '\(' );
|
||||
$method->codeToInject = json_encode( "\n\t{$method->getDocComment()}\n\t" . ( $method->isFinal() ? 'final ' : '' ) . ( $method->isAbstract() ? 'abstract ' : '' ) . ( $method->isStatic() ? 'static ' : '' ) . ( $method->isPublic() ? 'public ' : 'protected ' ) . "function {$method->name}(" . ( empty( $parameters ) ? '' : ( ' ' . implode(', ', $parameters ) . ' ' ) ) . ")\n\t{\n\t\treturn call_user_func_array( 'parent::{$method->name}', func_get_args() );\n\t}\n" );
|
||||
$method->codeToInject = json_encode( "\n\t{$method->getDocComment()}\n\t" . ( $method->isFinal() ? 'final ' : '' ) . ( $method->isAbstract() ? 'abstract ' : '' ) . ( $method->isStatic() ? 'static ' : '' ) . ( $method->isPublic() ? 'public ' : 'protected ' ) . "function {$method->name}(" . ( empty( $parameters ) ? '' : ( ' ' . implode( ', ', $parameters ) . ' ' ) ) . ")\n\t{\n\t\treturn parent::{$method->name}(" . ( empty( $parameters ) ? '' : ( ' ' . implode( ', ', array_map( function( $param ){ return str_replace( '&', '', $param ); }, $parameters ) ) . ' ' ) ) . ");\n\t}\n" );
|
||||
|
||||
$data[ $method->getDeclaringClass()->getName() ]['methods'][ $method->getName() ] = $method;
|
||||
}
|
||||
@@ -386,7 +395,7 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
unset( $hookData[ \IPS\Request::i()->template ] );
|
||||
}
|
||||
|
||||
$this->_writeThemeHookData( $hookData );
|
||||
$this->writeThemeHookData( $hookData );
|
||||
|
||||
/* Boink */
|
||||
\IPS\Output::i()->redirect( $url->setQueryString( 'template', \IPS\Request::i()->template )->setQueryString( 'do', 'editHook' )->stripQueryString( 'delete' ) );
|
||||
@@ -501,7 +510,7 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Write */
|
||||
$this->_writeThemeHookData( $hookData );
|
||||
$this->writeThemeHookData( $hookData );
|
||||
|
||||
/* Write application json file automatically */
|
||||
if( $this->app )
|
||||
@@ -538,12 +547,12 @@ class _Hook extends \IPS\Patterns\ActiveRecord
|
||||
* @param array $hookData Hook data
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeThemeHookData( $hookData )
|
||||
public function writeThemeHookData( $hookData )
|
||||
{
|
||||
/* Build */
|
||||
if( !count( $hookData ) )
|
||||
{
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\n\n/* End Hook Data */";
|
||||
$hookData = "/* !Hook Data - DO NOT REMOVE */\npublic static function hookData() {\n return parent::hookData();\n}\n/* End Hook Data */";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user