';
}
$installer = $this->get_config('installer'); // Can't use method return value in write context in '' with substr(), get_config() and isset()
$parts = explode(':', $this->checkUpdateVersion[0]); // this is ckeditor only
$s .= PLUGIN_EVENT_CKEDITOR_REVISION_TITLE;
$s .= "\n
\n";
// hook this as a scalar value into this plugins lang files (would be needed by adding this to a constant)
foreach( $this->revisionPackage AS $revision ) {
$s .= '
' . $revision . "
\n";
}
$s .= "
\n\n";
if (!empty($installer)) {
switch ($installer[0]) {
case '4': // this won't happen, since case 2 is true - just a fake
$s .= '
Check Plugin Update Message: NO CONFIG SET OR NO MATCH -> config_set: "last_'.$parts[0].'_version:'. $parts[1].'"
';
break;
case '3':
$s .= '
Installer Update Message: Check Update found false, no unpack needed. Plugin upgrade successfully done or has been triggered to be checked by an other Spartacus Plugin update!
';
break;
case '2':
$s .= '
Installer Message: Extracting the zip to ' . $this->cke_path . ' directory done!
';
break;
case '1':
$s .= '
Installer Error[1]: Extracting the zip to ' . $this->cke_path . ' directory failed! Please extract ' . $this->cke_zipfile . ' by hand.
';
break;
case '0':
$s .= '
Installer Error[0]: Due to a writing permission error, extracting the zip to ' . $this->cke_path . ' directory failed! 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 remove(!) this plugin from your plugin list and install it again.
';
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
$s .= PLUGIN_EVENT_CKEDITOR_INSTALL;
$s .= PLUGIN_EVENT_CKEDITOR_CONFIG;
$s .= PLUGIN_EVENT_CKEDITOR_SCAYT;
return $s;
}
/**
* Downgrade of version to keep plugin version track with CKE versioning for upcoming next major upgrades!
* This method is temporary only!
* @see updateConfig()
* @see checkUpdate()
*/
private function temporaryDowngrade($newVersion, $oldVersion)
{
global $serendipity;
$thisclass = serendipity_db_escape_string('serendipity_event_ckeditor');
$row = serendipity_db_query("SELECT version FROM {$serendipity['dbPrefix']}pluginlist
WHERE plugin_class = '" . $thisclass . "'
AND pluginlocation = 'local'
LIMIT 1", true, 'assoc');
$versions = array($oldVersion, $newVersion); // keep prior and current versions false check
if (in_array($row['version'], $versions)) {
return false;
}
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}pluginlist
SET version = '" . serendipity_db_escape_string($oldVersion) . "'
WHERE plugin_class = '" . $thisclass . "'
AND pluginlocation = 'local'");
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}pluginlist
SET upgrade_version = '" . serendipity_db_escape_string($newVersion) . "'
WHERE plugin_class = '" . $thisclass . "'
AND pluginlocation = 'local'");
}
/**
* Set config database table to keep track to zip update versions
* @access private
*/
private function updateConfig()
{
#$this->temporaryDowngrade('4.5.10.3', '4.5.10.2'); // was temporary used for the harmonization of plugin and lib versions
foreach(array_values($this->checkUpdateVersion) AS $package) {
$match = explode(':', $package);
$this->set_config('last_'.$match[0].'_version', $match[1]);
}
}
/**
* Check update versions to perform unzip and create config values
* @access private
* @return boolean
*/
private function checkUpdate()
{
#$this->temporaryDowngrade('4.5.10.3', '4.5.10.2'); // was temporary used for the harmonization of plugin and lib versions
$doupdate = false;
foreach(array_values($this->checkUpdateVersion) AS $package) {
$match = explode(':', $package);
// always set and extract if not match
if ($this->get_config('last_'.$match[0].'_version') == $match[1]) {
$doupdate = false;
} else {
$doupdate = true;
break; // this is probably needed to force install upgrade routines
}
}
return $doupdate;
}
/**
* empty a directory using the Standard PHP Library (SPL) iterator
* @access private
* @param string directory
*/
private function empty_dir($dir)
{
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);
foreach ($iterator AS $file) {
if ($file->isFile()) {
@unlink($file->__toString());
} else {
@rmdir($file->__toString());
}
}
@rmdir(dir);
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_header':
$headcss = true;
case 'frontend_footer':
// set prettify.css and prettify.js in frontend footer by plugin option (too much overhead to split this into head css and food js!)
if (serendipity_db_bool($this->get_config('codebutton', false))) {
$plugingpath = function_exists('serendipity_specialchars') ? serendipity_specialchars($this->get_config('plugpath')) : htmlspecialchars($this->get_config('plugpath'), ENT_COMPAT, LANG_CHARSET);
if ($headcss) {
?>
get_config('prettify', false))) {
if ($headcss) {
?>
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);
$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
$uats_on = $serendipity['use_autosave'] ? 'true' : 'false'; // dito
$toolbar = $this->get_config('toolbar', 'Standard');
$time = $this->get_config('timestamp', time());
$slang = (isset($flocale) && !empty($flocale[0]) ? $flocale[0] : WYSIWYG_LANG); // set scayt locales 4-letter POSIX lang or fall back
$lang = $slang ? $slang : 'en_US'; // use new WYSIWYG_LANG, or the workaround locale, or fall back to default
$lang = str_replace('_', '-', $lang); // change to IETF standard unicode language tag, using a dash
/*
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
*/
?>
get_config('ibn_off', 'true')) ) {
?>
get_config('codebutton', false))) {
/* moved to highlight.css to prepend streamed css first (keep note!)
CKEDITOR CODESNIPPET PLUGIN
pre {
word-wrap: inherit; fixes chrome issue
}
pre code {
white-space: pre;
overflow-x: auto;
}
.hljs {
border-left: 5px solid #DDD;
}
*/
if (serendipity_db_bool($this->get_config('prettify', false))) {
ob_start();
?>
/* CKEDITOR PLUGIN PBCKCODE PRETTY PRINT */
.prettyprint {
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.prettyprint.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
.content ol {
margin: 0px 0px 1em 2em;
}
.serendipity_entry ol.linenums {
padding-left: 40px;
}
ol.linenums li {
padding-left: 1em;
color: #bebec5;
line-height: 1.6;
text-shadow: 0 1px 0 #fff;
}
install()) {
header('Location: ' . $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]='.urlencode($this->instance));
} else {
header('Location: ' . $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]='.urlencode($this->instance));
}
}
break;
case 'backend_plugins_update':
if ($eventData == 'serendipity_event_ckeditor' && !$serendipity['ajax']) {
// @TODO: This is is really messed up. Probably much better to perform a HTTP_Request to perform an action. Text below needs to be reworked, that all makes no sense to me.
// Make sure a Spartacus update really falls down into this plugins config.
// In case of using the UPDATE ALL 1-click ajax-upgrader, this redirection is disabled and you have to force the extraction yourself in the config.
// 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');
// This runtime breakage will reset all other plugins waiting to UPGRADE back to their current version in table pluginlist.
// After this, the updater has to wait for a new read of the xml file(s) and to set pending plugins with setPluginInfo() method for versions and timestamp again.
// This is not what we want here! So we nuke the blog-servers xml file in templates_c to later on continue with pending plugin updates.
// Spartacus has to be prepared to set this global var. All other users probably have to wait up to 12h+.
//#@unlink($serendipity['spartacus_cachedXMLfile']);
//#die(); // now exit the runtime UPGRADE task executor, which forces to really halt into this->install() check redirector!
}
break;
case 'backend_media_path_exclude_directories':
$eventData[".thumbs"] = true;
break;
case 'backend_wysiwyg':
$eventData['skip'] = true; // this skips htmlarea drop-in
if (preg_match('@^nugget@i', $eventData['item'])) {
// switch to finisher, in case of nuggets
$this->event_hook('backend_wysiwyg_finish', $bag, $eventData);
} else {
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
$bid = array();
if (isset($eventData['buttons']) && (is_array($eventData['buttons']) && !empty($eventData['buttons']))) foreach ($eventData['buttons'] AS $bt) { $bid[] = $bt['id']; }
$addB = implode(",", $bid);
$addB = str_replace(',','","',$addB);
}
// this builds both textareas of entry forms only
if (isset($eventData['item']) && !empty($eventData['item'])) {
$jebtnarr = (isset($eventData['buttons']) && (is_array($eventData['buttons']) && !empty($eventData['buttons']))) ? json_encode($eventData['buttons']) : 'null';
?>