2013-12-10 15:25:54 +01:00
< ? php
2013-05-30 10:33:00 +02:00
if ( IN_serendipity !== true ) {
die ( " Don't hack! " );
}
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname ( __FILE__ ) . '/' . $serendipity [ 'charset' ] . 'lang_' . $serendipity [ 'lang' ] . '.inc.php' ;
if ( file_exists ( $probelang )) {
include $probelang ;
}
2013-12-12 13:14:28 +01:00
include_once dirname ( __FILE__ ) . '/lang_en.inc.php' ;
2013-05-30 10:33:00 +02:00
2013-12-12 13:14:28 +01:00
/**
* Class member instance attribute values
* Members must be initialized with a constant expression ( like a string constant , numeric literal , etc ), not a dynamic expression !
**/
2013-05-30 10:33:00 +02:00
if ( ! defined ( 'CKEDITOR_DIRNAME_PLUGIN_PATH' )) define ( 'CKEDITOR_DIRNAME_PLUGIN_PATH' , dirname ( __FILE__ ));
if ( ! defined ( 'CKEDITOR_DIRNAME_CKEDITOR_PATH' )) define ( 'CKEDITOR_DIRNAME_CKEDITOR_PATH' , dirname ( __FILE__ ) . '/ckeditor' );
class serendipity_event_ckeditor extends serendipity_event
{
/**
* Access property title
* Since already used in class serendipity_event extends serendipity_plugin this needs to be public
* @ access public
* @ var string
*/
2014-09-07 10:52:45 +02:00
public $title = PLUGIN_EVENT_CKEDITOR_NAME ;
2013-05-30 10:33:00 +02:00
/**
* Access property cke_path
* @ access protected
* @ var string
*/
2013-08-08 19:12:02 +02:00
protected $cke_path = CKEDITOR_DIRNAME_PLUGIN_PATH ;
2013-05-30 10:33:00 +02:00
/**
* Access property cke_dir
* @ access protected
* @ var string
*/
2013-08-08 19:12:02 +02:00
protected $cke_dir = CKEDITOR_DIRNAME_CKEDITOR_PATH ;
2013-05-30 10:33:00 +02:00
2013-12-10 15:25:54 +01:00
/**
* Access property forceZipInstall
* @ access protected
* @ var bool
*/
protected $forceZipInstall = false ;
2013-05-30 10:33:00 +02:00
/**
* Access property cke_zipfile
* @ access protected
* @ var string
*/
2015-07-05 18:37:26 +02:00
protected $cke_zipfile = 'ckeditor_4.4.8.0-plus.zip' ;
2013-05-30 10:33:00 +02:00
/**
* Access property checkUpdateVersion
* Verify release package versions - do update on upgrades !
2013-05-30 11:06:30 +02:00
* @ var array
2013-05-30 10:33:00 +02:00
*/
2015-07-05 18:37:26 +02:00
protected $checkUpdateVersion = array ( 'ckeditor:4.4.8.0' );
2013-05-30 10:33:00 +02:00
2013-08-02 12:31:57 +02:00
/**
* Access property revisionPackage
2014-09-07 10:52:45 +02:00
* Note revisions of ckeditor and plugin additions to lang files
2013-08-02 12:31:57 +02:00
* @ var array
*/
2015-07-05 18:37:26 +02:00
protected $revisionPackage = array ( 'CKEditor 4.4.8 (revision ccd0038, full package, 2015-07-01)' ,
2013-11-20 18:14:30 +01:00
'CKEditor-Plugin: mediaembed, v. 0.5+ (https://github.com/frozeman/MediaEmbed, 2013-09-12)' ,
2015-07-05 18:37:26 +02:00
'CKEditor-Plugin: manually added codesnippet, fakeobjects, lineutils and widget plugins, 2015-07-01)' ,
2014-10-13 19:46:57 +02:00
'CKEditor-Plugin: procurator, v. 1.5 (Serendipity placeholder Plugin, 2014-10-10)' ,
'CKEditor-Plugin: cheatsheet, v. 1.2 (Serendipity CKE-Cheatsheet Plugin, 2014-09-02)' ,
2015-01-28 12:55:41 +01:00
'CKEditor-S9yCustomConfig, cke_config.js, v. 2.3, 2015-01-28' ,
'CKEditor-S9yCustomPlugins, cke_plugin.js, v. 1.9, 2015-01-01' ,
2015-07-05 18:37:26 +02:00
'CKEditor-S9yAddOn, fresh highlight.pack.js file v.8.6 and github styles in highlight.css, (https://highlightjs.org/) 2015-07-05' ,
2013-12-12 13:14:28 +01:00
'Prettify: JS & CSS files, v. "current", (http://code.google.com/p/google-code-prettify/, 2013-03-04)' );
2013-08-02 12:31:57 +02:00
2013-05-30 10:33:00 +02:00
2013-12-10 15:25:54 +01:00
function install () {
2013-05-30 10:33:00 +02:00
global $serendipity ;
if ( ! $serendipity [ 'serendipityUserlevel' ] >= USERLEVEL_ADMIN ) {
return false ;
}
// do we already have it?
2013-12-10 15:25:54 +01:00
if ( ! $this -> forceZipInstall && is_dir ( $this -> cke_dir ) && is_file ( $this -> cke_dir . '/ckeditor.js' )) {
2013-05-30 10:33:00 +02:00
// this is running while getting a new Plugin version
2013-06-12 17:51:53 +02:00
if ( $this -> checkUpdate ()) {
2013-05-30 10:33:00 +02:00
$this -> set_config ( 'installer' , '4-' . date ( 'Ymd-H:i:s' )); // this is a faked debug notice, since falldown is extract true with case 0, 1 or 2
} else {
$this -> set_config ( 'installer' , '3-' . date ( 'Ymd-H:i:s' )); // this will happen, if no further extract is necessary in case of an update
2013-09-05 11:44:27 +02:00
return ;
2013-05-30 10:33:00 +02:00
}
}
2013-11-20 18:14:30 +01:00
if ( ! extension_loaded ( 'zip' )) {
trigger_error ( ' ZIP extension has not been compiled or loaded in php.' , E_USER_WARNING );
return ;
}
2013-05-30 10:33:00 +02:00
if ( is_writable ( $this -> cke_path )) {
$zip = new ZipArchive ;
if ( $zip -> open ( $this -> cke_path . '/' . $this -> cke_zipfile ) === true ) {
$zip -> extractTo ( $this -> cke_path );
$zip -> close ();
$this -> set_config ( 'installer' , '2-' . date ( 'Ymd-H:i:s' )); // returned by string[0], which is better than substr in this case
2014-10-13 19:46:57 +02:00
// Check to remove every old ckeditor_(*)-plus.zip files
2013-08-08 19:12:02 +02:00
foreach ( glob ( $this -> cke_path . '/*.zip' ) as $filename ) {
if ( $this -> cke_path . '/' . $this -> cke_zipfile != $filename ) {
@ unlink ( $filename );
2013-11-20 18:14:30 +01:00
$is_update = true ;
2013-08-08 19:12:02 +02:00
}
}
2013-11-20 18:14:30 +01:00
if ( $is_update ) {
// purge removed files for upgraders to ckeditor v. 4.2 only
@ unlink ( $this -> cke_path . '/ckeditor/build_config.js' );
@ unlink ( $this -> cke_path . '/ckeditor/skins/moono/images/mini.png' );
2014-10-13 19:46:57 +02:00
// purge removed files for upgraders to ckeditor >= v. 4.4.4 only
@ unlink ( $this -> cke_path . '/UTF-8/documentation_cz.html' );
@ unlink ( $this -> cke_path . '/UTF-8/lang_en.inc.php' );
@ unlink ( $this -> cke_path . '/UTF-8/documentation_cs.html' );
}
2014-11-28 16:26:41 +01:00
// remove widget/dev samples directory
if ( is_file ( dirname ( __FILE__ ) . '/ckeditor/plugins/widget/dev/console.js' )) {
$this -> empty_dir ( dirname ( __FILE__ ) . '/ckeditor/widget/dev' );
@ rmdir ( dirname ( __FILE__ ) . '/ckeditor/widget/dev' );
}
// remove lineutils/dev samples directory
if ( is_file ( dirname ( __FILE__ ) . '/ckeditor/plugins/lineutils/dev/dnd.html' )) {
$this -> empty_dir ( dirname ( __FILE__ ) . '/ckeditor/lineutils/dev' );
@ rmdir ( dirname ( __FILE__ ) . '/ckeditor/lineutils/dev' );
}
2014-10-13 19:46:57 +02:00
// remove usused placeholder plugin
if ( is_file ( dirname ( __FILE__ ) . '/ckeditor/plugins/placeholder/plugin.js' )) {
$this -> empty_dir ( dirname ( __FILE__ ) . '/ckeditor/plugins/placeholder' );
@ rmdir ( dirname ( __FILE__ ) . '/ckeditor/plugins/placeholder' );
}
// remove code button plugin pbckcode
if ( is_file ( dirname ( __FILE__ ) . '/ckeditor/plugins/pbckcode/plugin.js' )) {
$this -> empty_dir ( dirname ( __FILE__ ) . '/ckeditor/plugins/pbckcode' );
@ rmdir ( dirname ( __FILE__ ) . '/ckeditor/plugins/pbckcode' );
}
// remove kcfinder instance
if ( is_file ( dirname ( __FILE__ ) . '/kcfinder/config.php' )) {
$this -> empty_dir ( dirname ( __FILE__ ) . '/kcfinder' );
@ rmdir ( dirname ( __FILE__ ) . '/kcfinder' );
unset ( $_COOKIE [ 'KCFINDER_uploadurl' ]);
unset ( $_COOKIE [ 'KCFINDER_displaySettings' ]);
unset ( $_COOKIE [ 'KCFINDER_showname' ]);
unset ( $_COOKIE [ 'KCFINDER_showsize' ]);
unset ( $_COOKIE [ 'KCFINDER_showtime' ]);
unset ( $_COOKIE [ 'KCFINDER_order' ]);
unset ( $_COOKIE [ 'KCFINDER_orderDesc' ]);
unset ( $_COOKIE [ 'KCFINDER_view' ]);
2013-11-20 18:14:30 +01:00
}
2013-05-30 10:33:00 +02:00
} else {
$this -> set_config ( 'installer' , '1-' . date ( 'Ymd-H:i:s' ));
return false ;
}
} else {
$this -> set_config ( 'installer' , '0-' . date ( 'Ymd-H:i:s' )); // do it again, Sam
return false ;
}
2014-09-07 10:52:45 +02:00
// make sure the new versions are set to last_ckeditor_version
2013-12-10 15:25:54 +01:00
$this -> updateTableZip ();
2013-05-30 10:33:00 +02:00
return true ;
}
2013-12-10 15:25:54 +01:00
function uninstall ( & $propbag ) {
// todo? uninstall old instances which may be in there, caused by a duplicating bug using installer fallback without right instance in 2.3.2 for one day online
2013-12-09 14:23:03 +01:00
}
2013-05-30 10:33:00 +02:00
function introspect ( & $propbag )
{
global $serendipity ;
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_NAME );
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_DESC );
$propbag -> add ( 'stackable' , false );
$propbag -> add ( 'author' , 'Rustam Abdullaev, Ian' );
2015-07-05 18:37:26 +02:00
$propbag -> add ( 'version' , '4.8.0' ); // is CKEDITOR Series 4 (hidden) - revision .4.8 - and appended plugin revision .0
2013-06-27 10:48:02 +02:00
$propbag -> add ( 'copyright' , 'GPL or LGPL License' );
2013-05-30 10:33:00 +02:00
$propbag -> add ( 'requirements' , array (
'serendipity' => '1.7' ,
'smarty' => '3.1.13' ,
'php' => '5.2.6'
));
$propbag -> add ( 'event_hooks' , array (
2014-11-28 16:26:41 +01:00
'frontend_header' => true ,
2013-11-20 18:14:30 +01:00
'frontend_footer' => true ,
2013-06-05 11:25:25 +02:00
'backend_header' => true ,
2014-10-13 19:46:57 +02:00
'css' => true ,
2013-06-05 11:25:25 +02:00
'css_backend' => true ,
2013-12-08 20:26:24 +01:00
'external_plugin' => true ,
2013-08-02 08:07:19 +02:00
'backend_plugins_update' => true ,
2013-06-05 11:25:25 +02:00
'backend_media_path_exclude_directories' => true ,
'backend_wysiwyg' => true ,
'backend_wysiwyg_finish' => true
2013-05-30 10:33:00 +02:00
));
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'configuration' , array ( 'path' , 'plugpath' , 'codebutton' , 'prettify' , 'acf_off' , 'toolbar' , 'ibn_off' , 'toolbar_break' , 'force_install' , 'timestamp' ));
2013-05-30 10:33:00 +02:00
$propbag -> add ( 'groups' , array ( 'BACKEND_EDITOR' ));
}
function introspect_config_item ( $name , & $propbag )
{
global $serendipity ;
switch ( $name ) {
case 'path' :
$propbag -> add ( 'type' , 'string' );
$propbag -> add ( 'name' , INSTALL_RELPATH );
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_OPTION_DESC . '"plugins/serendipity_event_ckeditor/ckeditor/"' );
2013-05-30 10:33:00 +02:00
$propbag -> add ( 'default' , 'plugins/serendipity_event_ckeditor/ckeditor/' );
break ;
case 'plugpath' :
$propbag -> add ( 'type' , 'string' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_INSTALL_PLUGPATH );
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_OPTION_DESC . '"' . $serendipity [ 'serendipityHTTPPath' ] . 'plugins/"' );
2013-05-30 10:33:00 +02:00
$propbag -> add ( 'default' , $serendipity [ 'serendipityHTTPPath' ] . 'plugins/' );
break ;
2013-11-20 18:14:30 +01:00
case 'codebutton' :
$propbag -> add ( 'type' , 'boolean' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_CODEBUTTON_OPTION );
$propbag -> add ( 'description' , '' );
$propbag -> add ( 'default' , 'false' );
break ;
case 'prettify' :
$propbag -> add ( 'type' , 'boolean' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_PRETTIFY_OPTION );
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_PRETTIFY_OPTION_DESC );
2013-11-20 18:14:30 +01:00
$propbag -> add ( 'default' , 'false' );
break ;
2013-06-11 17:15:52 +02:00
case 'acf_off' :
$propbag -> add ( 'type' , 'boolean' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_CKEACF_OPTION );
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_CKEACF_OPTION_DESC );
2013-06-11 17:15:52 +02:00
$propbag -> add ( 'default' , 'false' );
break ;
2014-10-13 19:46:57 +02:00
case 'toolbar' :
$select = array ();
$select [ " Standard " ] = 'STANDARD' ;
$select [ " Basic " ] = 'BASIC' ;
$select [ " Full " ] = 'FULL' ;
$propbag -> add ( 'type' , 'select' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_SETTOOLBAR_OPTION );
$propbag -> add ( 'description' , '' );
$propbag -> add ( 'select_values' , $select );
$propbag -> add ( 'default' , 'Standard' );
break ;
2015-01-28 12:55:41 +01:00
case 'ibn_off' :
$propbag -> add ( 'type' , 'boolean' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_CKEIBN_OPTION );
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_CKEIBN_OPTION_DESC );
$propbag -> add ( 'default' , 'true' );
break ;
2013-05-30 10:33:00 +02:00
case 'toolbar_break' :
$propbag -> add ( 'type' , 'boolean' );
2013-12-12 13:14:28 +01:00
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_TOOLBAR_OPTION );
2013-05-30 10:33:00 +02:00
$propbag -> add ( 'description' , '' );
$propbag -> add ( 'default' , 'true' );
break ;
2013-12-08 20:26:24 +01:00
case 'force_install' :
$propbag -> add ( 'type' , 'boolean' );
$propbag -> add ( 'name' , PLUGIN_EVENT_CKEDITOR_FORCEINSTALL_OPTION );
2015-01-28 12:55:41 +01:00
$propbag -> add ( 'description' , PLUGIN_EVENT_CKEDITOR_FORCEINSTALL_OPTION_DESC . $this -> cke_zipfile );
2013-12-08 20:26:24 +01:00
$propbag -> add ( 'default' , 'false' );
break ;
2014-11-28 16:26:41 +01:00
case 'timestamp' :
$propbag -> add ( 'type' , 'hidden' );
$propbag -> add ( 'value' , time ());
break ;
2013-05-30 10:33:00 +02:00
default :
return false ;
}
return true ;
}
function generate_content ( & $title ) {
$title = $this -> title ;
}
function example () {
2014-03-05 13:48:15 +01:00
$s = '' ;
2013-12-08 20:26:24 +01:00
if ( serendipity_db_bool ( $this -> get_config ( 'force_install' ))) {
2013-12-10 15:25:54 +01:00
$this -> forceZipInstall = true ;
$this -> install ();
$this -> forceZipInstall = false ;
2013-12-08 20:26:24 +01:00
$this -> set_config ( 'force_install' , 'false' );
2013-12-10 15:25:54 +01:00
// forceZipInstall forces to surround the checkUpdate function, thus we set config database table to keep track
$this -> updateTableZip ();
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_success"><span class="icon-ok"></span><strong>Force deflate done:</strong> Please reload this page <a href="' . $serendipity [ 'baseURL' ] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . urlencode ( $this -> instance ) . '" target="_self">here</a>!</p>' ;
2013-12-04 12:30:51 +01:00
}
2013-05-30 10:33:00 +02:00
$installer = $this -> get_config ( 'installer' ); // Can't use method return value in write context in '' with substr(), get_config() and isset()
2013-05-30 11:00:23 +02:00
$parts = explode ( ':' , $this -> checkUpdateVersion [ 0 ]); // this is ckeditor only
2013-05-30 10:33:00 +02:00
2014-03-05 13:48:15 +01:00
$s .= PLUGIN_EVENT_CKEDITOR_REVISION_TITLE ;
$s .= " \n <ul> \n " ;
2013-08-08 19:12:02 +02:00
// hook this as a scalar value into this plugins lang files (would be needed by adding this to a constant)
2013-08-02 12:45:23 +02:00
foreach ( $this -> revisionPackage AS $revision ) {
2014-03-05 13:48:15 +01:00
$s .= ' <li>' . $revision . " </li> \n " ;
2013-08-02 12:45:23 +02:00
}
2014-03-05 13:48:15 +01:00
$s .= " </ul> \n \n " ;
2013-08-02 12:31:57 +02:00
2013-05-30 10:33:00 +02:00
if ( isset ( $installer ) && ! empty ( $installer ) ) {
switch ( $installer [ 0 ]) {
case '4' : // this won't happen, since case 2 is true - just a fake
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_notice"><span class="icon-attention"></span> <strong>Check Plugin Update Message:</strong> NO CONFIG SET OR NO MATCH -> config_set: "last_' . $parts [ 0 ] . '_version:' . $parts [ 1 ] . '"</p>' ;
2013-05-30 10:33:00 +02:00
break ;
case '3' :
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_success"><span class="icon-ok"></span> <strong>Installer Update Message:</strong> Check Update found false, no unpack needed. Plugin upgrade successfully done <strong>or</strong> has been triggered to be checked by an other Spartacus Plugin update!</p>' ;
2013-05-30 10:33:00 +02:00
break ;
case '2' :
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_success"><span class="icon-ok"></span> <strong>Installer Message:</strong> Extracting the zip to ' . $this -> cke_path . ' directory done!</p>' ;
2013-05-30 10:33:00 +02:00
break ;
case '1' :
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_error"><span class="icon-error"></span> <strong>Installer Error[1]:</strong> Extracting the zip to ' . $this -> cke_path . ' directory failed!<br>Please extract ' . $this -> cke_zipfile . ' by hand.</p>' ;
2013-05-30 10:33:00 +02:00
break ;
case '0' :
2014-03-05 13:48:15 +01:00
$s .= '<p class="msg_error"><span class="icon-error"></span> <strong>Installer Error[0]:</strong> Due to a writing permission error, extracting the zip to ' . $this -> cke_path . ' directory failed!<br>Please set "/plugins" or "/plugins/serendipity_event_ckeditor" directory and files correct writing permissions and extract ' . $this -> cke_zipfile . ' by hand or try again and <u>remove(!)</u> this plugin from your plugin list and install it again.</p>' ;
2013-05-30 10:33:00 +02:00
break ;
}
$this -> set_config ( 'installer' , '' ); // can't use serendipity_plugin_api::remove_plugin_value($this->instance, array('installer')); here, since it delivers the wrong instance
}
#echo $installer[0] . ' - ' . $this->instance; // this debug message on the other hand will do well, if all went through w/o install() returning false
2014-03-05 13:48:15 +01:00
$s .= PLUGIN_EVENT_CKEDITOR_INSTALL ;
$s .= PLUGIN_EVENT_CKEDITOR_CONFIG ;
return $s ;
2013-05-30 10:33:00 +02:00
}
2013-12-10 15:25:54 +01:00
/**
* Set config database table to keep track to zip updates
* @ access private
*/
private function updateTableZip () {
foreach ( array_values ( $this -> checkUpdateVersion ) AS $package ) {
$match = explode ( ':' , $package );
$this -> set_config ( 'last_' . $match [ 0 ] . '_version' , $match [ 1 ]);
}
}
2013-05-30 10:33:00 +02:00
/**
2013-06-12 17:51:53 +02:00
* Check update versions to perform unzip and create config values
2013-05-30 10:33:00 +02:00
* @ access private
2013-05-30 11:00:23 +02:00
* @ return boolean
2013-05-30 10:33:00 +02:00
*/
2013-06-12 17:51:53 +02:00
private function checkUpdate () {
2013-05-30 10:33:00 +02:00
$doupdate = false ;
foreach ( array_values ( $this -> checkUpdateVersion ) AS $package ) {
2013-06-12 17:51:53 +02:00
$match = explode ( ':' , $package );
2013-05-30 10:33:00 +02:00
// always set and extract if not match
2013-06-12 17:51:53 +02:00
if ( $this -> get_config ( 'last_' . $match [ 0 ] . '_version' ) == $match [ 1 ]) {
$doupdate = false ;
} else {
2013-12-10 15:25:54 +01:00
$this -> set_config ( 'last_' . $match [ 0 ] . '_version' , $match [ 1 ]); // redundant, since now done for both in updateTableZip, but leave here until new is proofed
2013-06-12 17:51:53 +02:00
$doupdate = true ;
break ; // this is possibly needed to force install upgrade routines
2013-05-30 10:33:00 +02:00
}
}
return $doupdate ? true : false ;
}
/**
* empty a directory using the Standard PHP Library ( SPL ) iterator
2013-12-10 15:25:54 +01:00
* @ access private
2013-05-30 10:33:00 +02:00
* @ param string directory
*/
2013-12-10 15:25:54 +01:00
private function empty_dir ( $dir ) {
2014-10-13 19:46:57 +02:00
if ( ! is_dir ( $dir )) return ;
try {
$_dir = new RecursiveDirectoryIterator ( $dir );
// NOTE: UnexpectedValueException thrown for PHP >= 5.3
} catch ( Exception $e ) {
return ;
}
$iterator = new RecursiveIteratorIterator ( $_dir , RecursiveIteratorIterator :: CHILD_FIRST );
//$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
2013-05-30 10:33:00 +02:00
foreach ( $iterator as $file ) {
if ( $file -> isFile ()) {
@ unlink ( $file -> __toString ());
} else {
@ rmdir ( $file -> __toString ());
}
}
2014-10-13 19:46:57 +02:00
@ rmdir ( dir );
2013-05-30 10:33:00 +02:00
}
function event_hook ( $event , & $bag , & $eventData , $addData = null ) {
global $serendipity ;
$hooks = & $bag -> get ( 'event_hooks' );
if ( isset ( $hooks [ $event ])) {
switch ( $event ) {
2013-12-12 13:14:28 +01:00
2014-11-28 16:26:41 +01:00
case 'frontend_header' :
$headcss = true ;
2013-11-20 18:14:30 +01:00
case 'frontend_footer' :
2013-12-12 13:14:28 +01:00
// set prettify.css and prettify.js in frontend footer by plugin option (too much overhead to split this into head css and food js!)
2014-10-13 19:46:57 +02:00
if ( serendipity_db_bool ( $this -> get_config ( 'codebutton' , false ))) {
2014-11-28 16:26:41 +01:00
$plugingpath = function_exists ( 'serendipity_specialchars' ) ? serendipity_specialchars ( $this -> get_config ( 'plugpath' )) : htmlspecialchars ( $this -> get_config ( 'plugpath' ), ENT_COMPAT , LANG_CHARSET );
if ( $headcss ) {
2014-10-13 19:46:57 +02:00
?>
< link rel = " stylesheet " href = " <?php echo $plugingpath . 'serendipity_event_ckeditor/highlight.css'; ?> " />
2014-11-28 16:26:41 +01:00
< ? php
} else {
?>
2014-10-13 19:46:57 +02:00
< script src = " <?php echo $plugingpath . 'serendipity_event_ckeditor/highlight.pack.js'; ?> " ></ script >
< script >
jQuery ( function ( $ ){
// launch the codesnippet highlight
hljs . initHighlightingOnLoad ();
});
</ script >
< ? php
2014-11-28 16:26:41 +01:00
}
2014-10-13 19:46:57 +02:00
if ( serendipity_db_bool ( $this -> get_config ( 'prettify' , false ))) {
2014-11-28 16:26:41 +01:00
if ( $headcss ) {
2013-11-20 18:14:30 +01:00
?>
2013-12-12 13:14:28 +01:00
< link rel = " stylesheet " type = " text/css " href = " <?php echo $plugingpath . 'serendipity_event_ckeditor/prettify.css'; ?> " />
2014-11-28 16:26:41 +01:00
< ? php
} else {
?>
2014-06-09 19:01:43 +02:00
< script type = " text/javascript " src = " <?php echo $plugingpath . 'serendipity_event_ckeditor/prettify.js'; ?> " ></ script >
2013-11-20 18:14:30 +01:00
< script >
jQuery ( function ( $ ){
2013-12-12 13:14:28 +01:00
// launch the prettify code
2013-11-20 18:14:30 +01:00
prettyPrint ();
});
</ script >
< ? php
2014-11-28 16:26:41 +01:00
}
2014-10-13 19:46:57 +02:00
}
2013-11-20 18:14:30 +01:00
}
break ;
2013-05-30 10:33:00 +02:00
case 'backend_header' :
2015-01-28 12:55:41 +01:00
if ( isset ( $serendipity [ 'wysiwyg' ]) && $serendipity [ 'wysiwyg' ] && isset ( $eventData ) && ! isset ( $_GET [ 'serendipity' ][ 'iframe_mode' ])) {
2014-11-28 16:26:41 +01:00
$relpath = function_exists ( 'serendipity_specialchars' ) ? serendipity_specialchars ( $this -> get_config ( 'path' )) : htmlspecialchars ( $this -> get_config ( 'path' ), ENT_COMPAT , LANG_CHARSET );
$plgpath = function_exists ( 'serendipity_specialchars' ) ? serendipity_specialchars ( $this -> get_config ( 'plugpath' )) : htmlspecialchars ( $this -> get_config ( 'plugpath' ), ENT_COMPAT , LANG_CHARSET );
2015-01-28 12:55:41 +01:00
$acf_off = serendipity_db_bool ( $this -> get_config ( 'acf_off' , 'false' )) ? 'true' : 'false' ; // need this, to be passed correctly as boolean true/false to custom cke_config.js
$code_on = serendipity_db_bool ( $this -> get_config ( 'codebutton' , 'false' )) ? 'true' : 'false' ; // same here for cke_plugins.js
2014-10-13 19:46:57 +02:00
$toolbar = $this -> get_config ( 'toolbar' , 'Standard' );
2015-01-28 12:55:41 +01:00
$time = $this -> get_config ( 'timestamp' , time ());
2014-11-28 16:26:41 +01:00
/*
Define some global CKEDITOR plugin startup vars
Include the ckeditor
Build dynamic plugins and set the custom config ( cke_config . js )
Sadly this can not hook into js_backend hook in 2.0 , since that is cached to lazyload
*/
2013-05-30 10:33:00 +02:00
?>
< script type = " text/javascript " >
2014-11-28 16:26:41 +01:00
CKEDITOR_BASEPATH = '<?php echo $relpath; ?>' ;
CKEDITOR_PLUGPATH = '<?php echo $plgpath; ?>' ;
S9Y_VERSION_NEW = < ? php echo $serendipity [ 'version' ][ 0 ] < 2 ? 'false' : 'true' ; ?> ;
CKECONFIG_ACF_OFF = < ? php echo $acf_off ; ?> ;
CKECONFIG_CODE_ON = < ? php echo $code_on ; ?> ;
CKECONFIG_LANG = '<?php echo WYSIWYG_LANG; ?>' ;
CKECONFIG_TOOLBAR = '<?php echo $toolbar; ?>' ;
2015-01-28 12:55:41 +01:00
CKECONFIG_TOOLBAR_BREAK = < ? php echo serendipity_db_bool ( $this -> get_config ( 'toolbar_break' , 'false' )) ? " '/' " : " '' " ; ?> ;
2014-11-28 16:26:41 +01:00
CKECONFIG_FORCE_LOAD = < ? php echo $time ; ?> ;
2013-05-30 10:33:00 +02:00
</ script >
2014-06-09 19:01:43 +02:00
< script type = " text/javascript " src = " <?php echo $serendipity['serendipityHTTPPath'] . $relpath ; ?>ckeditor.js " ></ script >
< script type = " text/javascript " src = " <?php echo $plgpath . 'serendipity_event_ckeditor/'; ?>cke_plugin.js " ></ script >
2013-05-30 10:33:00 +02:00
< ? php
2015-01-28 12:55:41 +01:00
// sadly this can't be pushed into streamed css, since that is cached to lazyload.
2015-01-28 13:45:25 +01:00
if ( $toolbar == 'Basic' ) {
2014-11-28 17:19:13 +01:00
if ( $serendipity [ 'version' ][ 0 ] < 2 ) {
2014-11-28 16:26:41 +01:00
?>
2014-11-28 17:19:13 +01:00
< link rel = " stylesheet " href = " <?php echo $plgpath . 'serendipity_event_ckeditor/'; ?>basic_toolbar1.css " />
2014-11-28 16:26:41 +01:00
< ? php
2014-11-28 17:19:13 +01:00
} else {
?>
< link rel = " stylesheet " href = " <?php echo $plgpath . 'serendipity_event_ckeditor/'; ?>basic_toolbar2.css " />
2015-01-28 13:45:25 +01:00
< ? php
}
} else { // case other toolbars
if ( false === serendipity_db_bool ( $this -> get_config ( 'ibn_off' , 'true' )) ) {
?>
< link rel = " stylesheet " href = " <?php echo $plgpath . 'serendipity_event_ckeditor/'; ?>cke_ibn.css " />
2014-11-28 17:19:13 +01:00
< ? php
}
2014-11-28 16:26:41 +01:00
}
}
2013-05-30 10:33:00 +02:00
break ;
2013-11-20 18:14:30 +01:00
2014-10-13 19:46:57 +02:00
case 'css' :
if ( serendipity_db_bool ( $this -> get_config ( 'codebutton' , false ))) {
2014-11-28 16:26:41 +01:00
/* moved to highlight . css to prepend streamed css first ( keep note ! )
CKEDITOR CODESNIPPET PLUGIN
pre {
word - wrap : inherit ; fixes chrome issue
}
2014-10-13 19:46:57 +02:00
pre code {
white - space : pre ;
overflow - x : auto ;
}
. hljs {
border - left : 5 px solid #DDD;
}
2014-11-28 16:26:41 +01:00
*/
2014-10-13 19:46:57 +02:00
if ( serendipity_db_bool ( $this -> get_config ( 'prettify' , false ))) {
2014-11-28 16:26:41 +01:00
2014-10-13 19:46:57 +02:00
?>
2014-11-28 16:26:41 +01:00
2014-10-13 19:46:57 +02:00
/* CKEDITOR PLUGIN PBCKCODE PRETTY PRINT */
. prettyprint {
padding : 8 px ;
background - color : #f7f7f9;
border : 1 px solid #e1e1e8;
}
. prettyprint . linenums {
- webkit - box - shadow : inset 40 px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
- moz - box - shadow : inset 40 px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box - shadow : inset 40 px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
. content ol {
margin : 0 px 0 px 1 em 2 em ;
}
< ? php
if ( $serendipity [ 'template' ] == 'bulletproof' ) {
?>
. serendipity_entry ol . linenums {
padding - left : 40 px ;
}
< ? php
}
?>
ol . linenums li {
padding - left : 1 em ;
color : #bebec5;
line - height : 1.6 ;
text - shadow : 0 1 px 0 #fff;
}
< ? php
}
}
break ;
2014-02-28 20:00:26 +01:00
case 'css_backend' :
2013-05-30 10:33:00 +02:00
?>
2014-02-28 20:00:26 +01:00
/* CKE styles start ----------------------------------------------------------------- */
2013-05-30 10:33:00 +02:00
2013-12-09 15:28:37 +01:00
< ? php
2014-02-28 20:00:26 +01:00
// do not use in 2.0 versions
2014-10-14 15:51:29 +02:00
if ( $serendipity [ 'version' ][ 0 ] < 2 ) {
2014-02-28 20:00:26 +01:00
echo file_get_contents ( dirname ( __FILE__ ) . '/cke_olds9y.css' );
}
if ( ! strpos ( $eventData , '.cke_config_block' )) {
echo file_get_contents ( dirname ( __FILE__ ) . '/cke_backend.css' );
2013-12-09 15:28:37 +01:00
}
2014-02-28 20:00:26 +01:00
?>
/* CKE styles end ----------------------------------------------------------------- */
2013-12-09 15:28:37 +01:00
2013-05-30 10:33:00 +02:00
< ? php
break ;
2013-11-20 18:14:30 +01:00
2013-12-08 20:26:24 +01:00
case 'external_plugin' :
switch ( $eventData ) {
case 'triggerckeinstall' :
if ( $this -> install ()) {
2013-12-09 14:23:03 +01:00
header ( 'Location: ' . $serendipity [ 'baseURL' ] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . urlencode ( $this -> instance ));
2013-12-08 20:26:24 +01:00
} else {
header ( 'Location: ' . $serendipity [ 'baseURL' ] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[type]=event' );
}
}
break ;
2013-08-02 08:07:19 +02:00
case 'backend_plugins_update' :
2013-12-09 14:23:03 +01:00
// Make sure a Spartacus update really falls down to plugins config, for the need to deflate the zip, if necessary.
// This needs a *real* new HTTP request! Using plugin_to_conf:instance (see above) would not do here!!
// A request to ...&serendipity[install_plugin]=serendipity_event_ckeditor would force a deflate, but would install another plugin instance!
header ( 'Location: ' . $serendipity [ 'baseURL' ] . ( $serendipity [ 'rewrite' ] == 'none' ? $serendipity [ 'indexFile' ] . '?/' : '' ) . 'plugin/triggerckeinstall' );
2013-12-08 20:26:24 +01:00
break ;
2013-08-02 08:07:19 +02:00
2013-11-20 18:14:30 +01:00
2013-06-05 11:25:25 +02:00
case 'backend_media_path_exclude_directories' :
$eventData [ " .thumbs " ] = true ;
return true ;
break ;
2013-11-20 18:14:30 +01:00
2013-05-30 10:33:00 +02:00
case 'backend_wysiwyg' :
$eventData [ 'skip' ] = true ; // this skips htmlarea drop-in
if ( preg_match ( '@^nugget@i' , $eventData [ 'item' ])) {
2013-08-08 19:12:02 +02:00
// switch to finisher, in case of nuggets
2013-05-30 10:33:00 +02:00
$this -> event_hook ( 'backend_wysiwyg_finish' , $bag , $eventData );
} else {
2014-10-13 19:46:57 +02:00
if ( serendipity_db_bool ( $this -> get_config ( 'codebutton' ))) {
// for case using customized toolbars, else it falls back to toolbar Group where 'others' is automatically added
2014-10-13 20:19:40 +02:00
$bid = array ();
if ( isset ( $eventData [ 'buttons' ]) && ( is_array ( $eventData [ 'buttons' ]) && ! empty ( $eventData [ 'buttons' ]))) foreach ( $eventData [ 'buttons' ] AS $bt ) { $bid [] = $bt [ 'id' ]; }
2014-10-13 19:46:57 +02:00
$addB = implode ( " , " , $bid );
$addB = str_replace ( ',' , '","' , $addB );
}
2013-08-08 19:12:02 +02:00
// this builds both textareas of entry forms only
2013-11-20 18:14:30 +01:00
if ( isset ( $eventData [ 'item' ]) && ! empty ( $eventData [ 'item' ])) {
2014-02-09 18:43:28 +01:00
$jebtnarr = ( isset ( $eventData [ 'buttons' ]) && ( is_array ( $eventData [ 'buttons' ]) && ! empty ( $eventData [ 'buttons' ]))) ? json_encode ( $eventData [ 'buttons' ]) : 'null' ;
2013-05-30 10:33:00 +02:00
?>
2013-11-20 18:14:30 +01:00
< script type = " text/javascript " >
2014-10-13 19:46:57 +02:00
s9ypluginbuttons . push ( " <?php echo $addB ; ?> " );
2014-02-09 18:43:28 +01:00
if ( window . Spawnnuggets ) Spawnnuggets ( '<?php echo $eventData[' item ']; ?>' , 'entryforms<?php echo $eventData[' jsname ']; ?>' , < ? php echo $jebtnarr ; ?> );
2013-11-20 18:14:30 +01:00
</ script >
2013-05-30 10:33:00 +02:00
< ? php
2014-02-09 18:43:28 +01:00
}
2013-05-30 10:33:00 +02:00
}
return true ;
break ;
2013-11-20 18:14:30 +01:00
2013-05-30 10:33:00 +02:00
case 'backend_wysiwyg_finish' :
2013-08-08 19:12:02 +02:00
// Run once only, save ressources
2013-11-20 18:14:30 +01:00
// This should better move into a future(!) 'backend_footer' hook, to not happen for every of any multiple textareas!
2014-10-14 16:25:17 +02:00
// but there $eventData['item'] isn't available yet...
2013-08-08 19:12:02 +02:00
if ( isset ( $eventData [ 'item' ]) && ! empty ( $eventData [ 'item' ])) {
2013-12-12 13:14:28 +01:00
if ( isset ( $eventData [ 'buttons' ]) && ( is_array ( $eventData [ 'buttons' ]) && ! empty ( $eventData [ 'buttons' ]))) {
2014-10-13 19:46:57 +02:00
// send eventData as json encoded array into the javascript stream, which can be pulled by 'backend_header' hooks global Spawnnuggets() nugget function
2013-05-30 10:33:00 +02:00
?>
< script type = " text/javascript " >
2013-09-05 11:44:27 +02:00
jsEventData = < ? php echo json_encode ( $eventData [ 'buttons' ]); ?> ;
2013-05-30 10:33:00 +02:00
</ script >
2013-09-05 11:44:27 +02:00
< ? php
2013-12-12 13:14:28 +01:00
}
2013-08-12 18:55:00 +02:00
} // end isset $eventData['item']
2013-05-30 10:33:00 +02:00
return true ;
break ;
2013-11-20 18:14:30 +01:00
2013-05-30 10:33:00 +02:00
default :
return false ;
}
} else {
return false ;
}
}
}
?>