Version 5.0.0 beta 8
This commit is contained in:
1 parent
54d5dcd0a0
commit
214f649f1d
483 files changed
+35354
-33568
No files matched your search
@@ -213,6 +213,117 @@ class Theme extends SystemTheme
|
||||
return $seen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import database templates from the dev directory
|
||||
*
|
||||
* @param string $directoryName
|
||||
* @param string $templateType
|
||||
* @return void
|
||||
*/
|
||||
public static function importDatabaseTemplate( string $directoryName, string $templateType ) : void
|
||||
{
|
||||
$directory = ROOT_PATH . "/applications/cms/dev/html/database/" . $directoryName;
|
||||
if( !file_exists( $directory ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Clear out any existing versions */
|
||||
Db::i()->delete( 'cms_templates', [ 'template_master=? and template_group=? and template_location=? and template_original_group=?', 0, $directoryName, 'database', $templateType ] );
|
||||
|
||||
foreach( new DirectoryIterator( $directory ) as $file )
|
||||
{
|
||||
if( $file->isDot() or $file->isDir() or $file->getFilename() == 'index.html' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$html = file_get_contents( $directory . '/' . $file->getFilename() );
|
||||
|
||||
/* Parse the header tag */
|
||||
preg_match( '/^<ips:template parameters="(.+?)?"([^>]+?)>(\r\n?|\n)/', $html, $params );
|
||||
|
||||
/* Strip it */
|
||||
$html = ( isset($params[0]) ) ? str_replace( $params[0], '', $html ) : $html;
|
||||
$title = str_replace( '.phtml', '', $file->getFilename() );
|
||||
|
||||
/* remove compiled version */
|
||||
$key = strtolower( 'template_cms_' .static::makeBuiltTemplateLookupHash( 'cms', 'database', $directoryName ) . '_' . static::cleanGroupName( $directoryName ) );
|
||||
|
||||
if ( isset( Store::i()->$key ) )
|
||||
{
|
||||
unset(Store::i()->$key);
|
||||
}
|
||||
|
||||
Db::i()->insert( 'cms_templates', array(
|
||||
'template_key' => str_replace( ' ', '_', 'database_' . $directoryName . '_' . $title ),
|
||||
'template_title' => $title,
|
||||
'template_desc' => '',
|
||||
'template_content' => $html,
|
||||
'template_location' => 'database',
|
||||
'template_group' => $directoryName,
|
||||
'template_original_group' => $templateType,
|
||||
'template_container' => 0,
|
||||
'template_params' => ( isset($params[1]) ) ? $params[1] : '',
|
||||
'template_master' => 0,
|
||||
'template_user_created' => 0,
|
||||
'template_type' => 'template'
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a custom page wrapper
|
||||
*
|
||||
* @param string $wrapperName
|
||||
* @return void
|
||||
*/
|
||||
public static function importPageWrapper( string $wrapperName ) : void
|
||||
{
|
||||
$file = ROOT_PATH . "/applications/cms/dev/html/page/custom_wrappers/" . $wrapperName;
|
||||
if( !file_exists( $file ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$wrapperName = str_replace( '.phtml', '', $wrapperName );
|
||||
|
||||
/* Delete the original */
|
||||
Db::i()->delete( 'cms_templates', [ 'template_location=? and template_title=? and template_group=? and template_master=?', 'page', $wrapperName, 'custom_wrappers', 0 ] );
|
||||
|
||||
$html = file_get_contents( $file );
|
||||
|
||||
/* Parse the header tag */
|
||||
preg_match( '/^<ips:template parameters="(.+?)?"([^>]+?)>(\r\n?|\n)/', $html, $params );
|
||||
|
||||
/* Strip it */
|
||||
$html = ( isset($params[0]) ) ? str_replace( $params[0], '', $html ) : $html;
|
||||
|
||||
/* remove compiled version */
|
||||
$key = strtolower( 'template_cms_' .static::makeBuiltTemplateLookupHash( 'cms', 'page', 'custom_wrappers' ) . '_' . static::cleanGroupName( $wrapperName ) );
|
||||
|
||||
if ( isset( Store::i()->$key ) )
|
||||
{
|
||||
unset(Store::i()->$key);
|
||||
}
|
||||
|
||||
Db::i()->insert( 'cms_templates', array(
|
||||
'template_key' => 'page_custom_wrappers_' . $wrapperName,
|
||||
'template_title' => $wrapperName,
|
||||
'template_desc' => '',
|
||||
'template_content' => $html,
|
||||
'template_location' => 'page',
|
||||
'template_group' => 'custom_wrappers',
|
||||
'template_original_group' => null,
|
||||
'template_container' => 0,
|
||||
'template_params' => ( isset($params[1]) ) ? $params[1] : '',
|
||||
'template_master' => 0,
|
||||
'template_user_created' => 0,
|
||||
'template_type' => 'template'
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a template to disk
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user