예제 #1
0
 function addCKEDITORHeaderStyles()
 {
     jckimport('ckeditor.stylesheet.writer.inlinestyles');
     $writer = new JCKInlineStyles();
     $writer->addStyleDeclaration("table.admintable", "width: 100%;");
     $writer->addToHead();
 }
예제 #2
0
 static function check()
 {
     $mainframe = JFactory::getApplication();
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('authenticate');
     JCKPluginsHelper::importPlugin('authenticate');
     return $mainframe->triggerEvent('authorise');
 }
예제 #3
0
파일: user.php 프로젝트: fur81/zofaxiopeu
 static function getSession()
 {
     static $instance;
     if ($instance) {
         return $instance;
     }
     jckimport('ckeditor.session.session');
     $instance = JCKSession::getSessionInstance();
     return $instance;
 }
예제 #4
0
 static function check()
 {
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('authenticate');
     JCKPluginsHelper::importPlugin('authenticate');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('authorise');
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i]) {
             return true;
         }
     }
     return false;
 }
예제 #5
0
 public function import()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $model = $this->getModel('import');
     if ($model->import()) {
         $cache = JFactory::getCache('mod_menu');
         $cache->clean();
     }
     //now updated editor
     jckimport('event.observable.editor');
     $obs = new JCKEditorObservable('cpanel');
     $handle = $obs->getEventHandler();
     $handle->onSync();
     $this->display();
 }
예제 #6
0
/**
 * This function must check the user session to be sure that he/she is
 * authorized to upload and access files in the File Browser.
 *
 * @return boolean
 */
function CheckAuthentication()
{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...
    //
    // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
    //
    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
    // user logs in your system.
    // %REMOVE_START%
    // Attention: In the development version (SVN) the PHP connector is enabled by default.
    //return true;
    // %REMOVE_END%
    jckimport('ckeditor.authenticate');
    return JCKAuthenticate::check();
}
예제 #7
0
 function beforeSetFilePath(&$params)
 {
     $plugin = JPluginHelper::getPlugin('content', 'jw_allvideos');
     if (!isset($plugin->params)) {
         return;
     }
     $avParams = new JParameter($plugin->params);
     $avBasePath = $avParams->get('afolder', 'images/stories/audio');
     jckimport('ckeditor.user.user');
     $user =& JCKUser::getInstance();
     $mediatype = $user->mediatype;
     if ($mediatype == 'video') {
         $avBasePath = $avParams->get('vfolder', 'images/stories/video');
     }
     //now set filepath
     $params->set('filePath', $avBasePath);
 }
예제 #8
0
 function &getSelectedToolbarList()
 {
     $rows = array();
     jckimport('helper');
     $toolbars = JCKHelper::getEditorToolbars();
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $db = JFactory::getDBO();
     $query = 'SELECT title FROM #__jckplugins' . ' WHERE id = ' . $cid[0];
     $db->setQuery($query);
     $pluginname = $db->loadResult();
     if (!!$pluginname && !is_string($pluginname)) {
         JError::raiseError(500, $db->getErrorMsg());
     }
     jckimport('helper');
     $toolbarnames = JCKHelper::getEditorToolbars();
     if (!empty($toolbarnames)) {
         require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
         $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
         foreach ($toolbarnames as $toolbarname) {
             $tmpfilename = $CKfolder . DS . $toolbarname . '.php';
             require $tmpfilename;
             $classname = 'JCK' . ucfirst($toolbarname);
             $toolbar = new $classname();
             $pluginTitle = str_replace(' ', '', $pluginname);
             //$pluginTitle = ucfirst($pluginTitle); leave it to plugin XML to captialize title
             if (!isset($toolbar->{$pluginTitle})) {
                 continue;
             }
             $row = new stdclass();
             $row->text = $toolbarname;
             $row->value = $toolbarname;
             $rows[] = $row;
         }
     }
     return $rows;
 }
예제 #9
0
jimport('joomla.environment.request');
jimport('joomla.environment.response');
jimport('joomla.language.language');
jimport('joomla.user.user');
jimport('joomla.application.component.model');
jimport('joomla.database.table');
jimport('joomla.html.parameter');
jimport('joomla.plugin.helper');
jimport('joomla.event.dispatcher');
/* load JCK loader class*/
require_once CKEDITOR_INCLUDES_DIR . '/loader.php';
//lets set DB configuration
$config = new JConfig();
// Get the global configuration object
$registry =& JFactory::getConfig();
// Load the configuration values into the registry
$registry->loadObject($config);
//set session
jckimport('ckeditor.user.user');
$session =& JCKUser::getSession();
// system events trigger events
jckimport('ckeditor.plugins.helper');
//load CK System plugins
JCKPluginsHelper::storePlugins('default');
$dispatcher =& JDispatcher::getInstance();
$plugin =& JPluginHelper::getPlugin('editors', 'jckeditor');
$params = new JParameter($plugin->params);
//import System plugin first
JCKPluginsHelper::importPlugin('default');
$dispatcher->trigger('intialize', array(&$params));
$plugin->params = $params->toString();
예제 #10
0
function JCKRegisterAllEventlisetners()
{
    $files = JFolder::files(JPATH_COMPONENT . DS . 'event');
    foreach ($files as $file) {
        jckimport('event.' . str_replace('.php', '', $file));
    }
}
예제 #11
0
 /**
  * ckeditor Lite WYSIWYG Editor - display the editor
  *
  * @param string The name of the editor area
  * @param string The content of the field
  * @param string The name of the form field
  * @param string The width of the editor area
  * @param string The height of the editor area
  * @param int The number of columns for the editor area
  * @param int The number of rows for the editor area
  * @param mixed Can be boolean or array.
  */
 function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true)
 {
     // Load modal popup behavior
     JHTML::_('behavior.modal', 'a.modal-button');
     // initialise $error varable
     $errors = '';
     /* Generate the Output */
     $this->params->set('editorname', $name);
     $javascript =& JCKJavascriptHelper::getHeadJavascript($this->params, $errors, $return_script);
     $javascript->addToHead();
     if (!$return_script) {
         return;
     }
     //Here we will use JFCKJavascript output to screen //html element as well
     jckimport('ckeditor.htmlwriter.helper');
     return $errors . JCKHtmlwriterHelper::EditorTextArea($name, $content, $buttons);
 }
예제 #12
0
    public function onSync()
    {
        $mainframe = JFactory::getApplication();
        jimport('joomla.filesystem.file');
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'pluginoverrides.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'pluginoverrides.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move pluginoverrides JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'acl.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'acl.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move ACL JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'components.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbar' . DS . 'components.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move components JCK toolbar plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move base plugins file to JCK library!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'scayt.xml';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . 'scayt' . DS . 'scayt.xml';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move scayt JCK plugin!'));
        }
        //Lets try and restore  broken or removed plugins from backup
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'helpers' . DS . 'restorer.php';
        $restorer = JCKRestorer::getInstance();
        $srcBase = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS;
        $destBase = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS;
        $folders = JFolder::folders($srcBase);
        foreach ($folders as $folder) {
            $src = $srcBase . $folder;
            if (!$restorer->install($src)) {
                $mainframe->enqueueMessage(JText::_('Unable to restore ' . $folder . ' JCK plugin!'), 'error');
            } else {
                $mainframe->enqueueMessage(JText::_('Sucessfully restored ' . $folder . ' JCK plugin!'));
            }
        }
        //check whether plugin is not a core plugin
        //if its not iterate through and see if there are files missing
        //then delete the plugin if there are
        $db = JFactory::getDBO();
        $query = 'SELECT p.id, p.name FROM `#__jckplugins` p WHERE p.iscore = 0';
        $db->setQuery($query);
        $results = $db->loadObjectList();
        if (!empty($results)) {
            for ($i = 0; $i < count($results); $i++) {
                if (!JFolder::exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name)) {
                    $query = 'DELETE FROM #__jcktoolbarplugins
								WHERE pluginid =' . $results[$i]->id;
                    $db->setQuery($query);
                    $db->query();
                    $query = 'DELETE FROM #__jckplugins
								WHERE id =' . $results[$i]->id;
                    $db->setQuery($query);
                    $db->query();
                }
            }
            //end for loop
        }
        //check for plugins that have not been added to layout -- legacy check
        $query = 'SELECT id,name FROM `#__jcktoolbars`';
        $db->setQuery($query);
        $toolbars = $db->loadObjectList();
        $JCKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
        $values = array();
        if (!empty($toolbars)) {
            require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
            //update core plugins layout if needed
            foreach ($toolbars as $row) {
                // get the total number of core plugin records
                $query = 'SELECT COUNT(*)' . ' FROM #__jcktoolbarplugins tp' . ' JOIN #__jckplugins p ON tp.pluginid = p.id' . ' WHERE tp.toolbarid =' . (int) $row->id . ' AND p.iscore = 1';
                $db->setQuery($query);
                $totalRows = $db->loadResult();
                if (!$totalRows) {
                    $filename = $JCKfolder . DS . $row->name . '.php';
                    require_once $filename;
                    $classname = 'JCK' . ucfirst($row->name);
                    $toolbar = new $classname();
                    $query = 'SELECT p.id, p.title' . ' FROM #__jckplugins p' . ' LEFT JOIN #__jckplugins parent on parent.id = p.parentid' . ' AND parent.published = 1' . ' WHERE p.title != ""' . ' AND p.published = 1' . ' AND p.iscore = 1' . ' AND(p.parentid IS NULL OR parent.published = 1)';
                    $db->setQuery($query);
                    $allplugins = $db->loadObjectList();
                    $values = array();
                    //fix toolbar values or they will get wiped out
                    $l = 1;
                    $n = 1;
                    $j = 1;
                    foreach (get_object_vars($toolbar) as $k => $v) {
                        if ($v) {
                            $n = $n > $v ? $n : $v;
                        }
                        if ($l < $n) {
                            $l = $n;
                            $j = 1;
                        }
                        for ($m = 0; $m < count($allplugins); $m++) {
                            if ($k == $allplugins[$m]->title) {
                                $values[] = '(' . (int) $row->id . ',' . (int) $allplugins[$m]->id . ',' . $n . ',' . $j . ',1)';
                                break;
                            }
                            if (strpos($k, 'brk_') !== false) {
                                $id = preg_match('/[0-9]+$/', $k);
                                $id = $id * -1;
                                $values[] = '(' . (int) $row->id . ',' . $id . ',' . $n . ',' . $j . ',1)';
                                $n++;
                                break;
                            }
                        }
                        $j++;
                    }
                    if (!empty($values)) {
                        $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values);
                        $db->setQuery($query);
                        if (!$db->query()) {
                            JError::raiseWarning(500, $db->getErrorMsg());
                        }
                    }
                }
            }
            //update non core plugins layout
            $values = array();
            foreach ($toolbars as $row) {
                $query = 'SELECT id,title FROM `#__jckplugins` p WHERE p.title != "" AND p.iscore = 0  AND p.published = 1' . ' AND NOT EXISTS(SELECT 1 FROM  #__jcktoolbarplugins tp WHERE tp.pluginid = p.id AND tp.toolbarid = ' . $row->id . ')';
                $db->setQuery($query);
                $plugins = $db->loadObjectList();
                $tmpfilename = $JCKfolder . DS . $row->name . '.php';
                if (!file_exists($tmpfilename)) {
                    continue;
                }
                //skip
                require_once $tmpfilename;
                $classname = 'JCK' . ucfirst($row->name);
                $toolbar = new $classname();
                $rowDetail = JCKHelper::getNextLayoutRow($row->id);
                foreach (get_object_vars($toolbar) as $k => $v) {
                    foreach ($plugins as $plugin) {
                        if ($plugin->title == $k) {
                            $values[] = '(' . $row->id . ',' . $plugin->id . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering . ',1)';
                            $rowDetail->rowordering++;
                        }
                    }
                }
            }
        }
        //Now add plugins to layouts
        if (!empty($values)) {
            $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values) . ' ON DUPLICATE KEY UPDATE toolbarid = VALUES(toolbarid),pluginid = VALUES(pluginid)';
            $db->setQuery($query);
            if (!$db->query()) {
                JError::raiseWarning(100, $db->getErrorMsg());
            }
        }
        //Reload Toolbar if editor is re-installed
        jckimport('event.observable.editor');
        $obs = new JCKEditorObservable('toolbars');
        $handle = $obs->getEventHandler();
        $query = 'SELECT * FROM `#__jcktoolbars` t WHERE exists(SELECT 1 FROM  #__jcktoolbarplugins tp WHERE tp.toolbarid  = t.id)';
        $db->setQuery($query);
        $rowresults = $db->loadObjectList();
        foreach ($rowresults as $row) {
            $id = $row->id;
            $name = $row->name;
            $title = $row->title;
            switch ($name) {
                case 'publisher':
                case 'full':
                case 'basic':
                case 'blog':
                case 'image':
                    $isNew = false;
                    break;
                default:
                    $isNew = true;
                    break;
            }
            //end switch
            $handle->onSave($id, $name, $name, $title, $isNew);
        }
        //end forloop
        //restore state of published/unpublished plugins
        $obs = new JCKEditorObservable('list');
        $handle = $obs->getEventHandler();
        $where = array();
        $where[] = ' WHERE p.published = 1';
        $where[] = ' WHERE p.published = 0';
        $state = array(1, 0);
        $count = count($where);
        for ($i = 0; $i < $count; $i++) {
            $db = JFactory::getDBO();
            $query = 'SELECT id FROM `#__jckplugins` p' . $where[$i] . ' AND p.iscore = 1 AND type="plugin"';
            $db->setQuery($query);
            $results = $db->loadResultArray();
            $handle->onPublish($results, $state[$i]);
        }
        //end for loop
        $mainframe->enqueueMessage(JText::_('Editor has been synchronized'));
    }
예제 #13
0
<?php

/*------------------------------------------------------------------------
# Copyright (C) 2005-2012 WebxSolution Ltd. All Rights Reserved.
# @license - GPLv2.0
# Author: WebxSolution Ltd
# Websites:  http://www.webxsolution.com
# Terms of Use: An extension that is derived from the JoomlaCK editor will only be allowed under the following conditions: http://joomlackeditor.com/terms-of-use
# ------------------------------------------------------------------------*/
// no direct access
defined('_JEXEC') or die;
jckimport('event.observable.editor');
class JCKController extends JControllerLegacy
{
    /**
     * Custom Constructor
     */
    private $editor_obervable;
    protected $event_args;
    public function __construct($default = array())
    {
        parent::__construct($default);
        $app = JFactory::getApplication();
        $this->_event_args = null;
        $name = $app->input->get('controller', '');
        if (!$name) {
            $name = $app->input->get('view', $this->getName());
        }
        $eventListenerFile = JPATH_COMPONENT . DS . 'event' . DS . $name . '.php';
        jimport('joomla.filesystem.file');
        if (JFile::exists($eventListenerFile)) {
예제 #14
0
<?php

include '../../../includes.php';
jimport('joomla.filesystem.file');
//Needed for 1.6
define('JDEBUG', false);
if (!jckimport('ckeditor.authenticate')) {
    die(false);
}
abstract class JTreeLinkHelper
{
    public static function ListExtensions(&$extensions)
    {
        $root = JURI::root() . '../../';
        $base = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins';
        $db = JFactory::getDBO();
        $query = '	SELECT ext.name FROM #__jckplugins ext
					INNER JOIN #__jckplugins parent on parent.id = ext.parentid
					WHERE parent.name = "jtreelink"
					AND parent.published = 1
					AND  ext.published = 1';
        $db->setQuery($query);
        $results = $db->loadResultArray();
        if (empty($results)) {
            return;
        }
        foreach ($results as $extension) {
            $path = $base . DS . $extension . DS . 'images' . DS . 'icon.gif';
            $url = $root . $extension . '/images/icon.gif';
            $icon = array('_open', '_closed');
            //We default to default icon if no custom icon has been supplied by plugin.
예제 #15
0
파일: helper.php 프로젝트: bizanto/Hooked
 static function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe = JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance = JBrowser::getInstance();
     $language = JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $toolbar = $params->def('toolbar', 'Full');
     $toolbar_ft = $params->def('toolbar_ft', 'Full');
     $skin = $params->def('skin', 'office2007');
     $hheight = $params->def('hheight', 480);
     $wwidth = $params->def('wwidth', '100%');
     $lang_mode = $params->def('lang_mode', 0);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 0);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     $textalign = $params->get('textalign', 0);
     $entities = $params->get('entities', 0);
     $formatsource = $params->get('formatsource', 1);
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             $lang = "";
             break;
     }
     $stylesheet =& JCKStylesheet::getInstance($path_root);
     $content_css = $stylesheet->getPath($params, $errors);
     $stylesheetJSO = $stylesheet->getJSObject();
     /*
      $jsloadJSO = 'var ckstyles_template;
      
      			window.addDomReadyEvent.add(function()
     			{
     				CKEDITOR.on("instanceReady",function(evt)
     				{
     					ckstyles_template = '.$stylesheetJSO .';
     				});
     			});';	
     $javascript->addScriptDeclaration($jsloadJSO);
     */
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     if ($textalign) {
         $textalign = "text-align:{$textalign};";
     } else {
         $textalign = "";
     }
     if (!$formatsource) {
         $formatsource = "\r\n\t\t\t\tvar format = [];\r\n\t\t\t\tformat['indent'] = false;\r\n\t\t\t\tformat['breakBeforeOpen'] = false; \r\n\t\t\t\tformat['breakAfterOpen'] =  false;\r\n\t\t\t\tformat['breakBeforeClose'] = false;\r\n\t\t\t\tformat['breakAfterClose'] = false;\r\n\t\t\t\tvar dtd = CKEDITOR.dtd;\r\n\t\t\t\tfor ( var e in CKEDITOR.tools.extend( {}, dtd.\$nonBodyContent, dtd.\$block, dtd.\$listItem, dtd.\$tableContent ) ) {\r\n\t\t\t\t\t\teditor.dataProcessor.writer.setRules( e, format); \r\n\t\t\t\t} \r\n\t\t\r\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\r\n\t\t\t\t{\r\n\t\t\t\t\tindent: false\r\n\t\t\t\t}); \r\n\t\t\t";
     } else {
         $formatsource = '';
     }
     $javascript->addScriptDeclaration("\r\n\t\r\n\t\t\tif (typeof JCKEvent == 'undefined') {\r\n\t\t\t\r\n\t\t\tvar JCKEvent = {};\r\n\t\t\t\r\n\t\t\tJCKEvent.domReady = {\r\n\t\t\t  add: function(fn) {\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (JCKEvent.domReady.loaded) return fn();\r\n\t\t\t\t\r\n\t\t\r\n\t\t\t\tvar observers = JCKEvent.domReady.observers;\r\n\t\t\t\tif (!observers) observers = JCKEvent.domReady.observers = [];\r\n\t\t\t\tobservers[observers.length] = fn;\r\n\t\t\r\n\t\t\t\tif (typeof JCKEvent.domReady.callback != 'undefined') return;\r\n\t\t\r\n\t\t\t\tJCKEvent.domReady.callback = function() {\r\n\t\t\t\t  if (JCKEvent.domReady.loaded) return;\r\n\t\t\t\t  \r\n\t\t\t\t  JCKEvent.domReady.loaded = true;\r\n\t\t\t\t  if (JCKEvent.domReady.timer) {\r\n\t\t\t\t\tclearInterval(JCKEvent.domReady.timer);\r\n\t\t\t\t\tJCKEvent.domReady.timer = null;\r\n\t\t\t\t  }\r\n\t\t\t\t \r\n\t\t\t\t  var observers = JCKEvent.domReady.observers;\r\n\t\t\t\t  for (var i = 0, length = observers.length; i < length; i++) {\r\n\t\t\t\t\tvar fn = observers[i];\r\n\t\t\t\t\tobservers[i] = null;\r\n\t\t\t\t\tfn(); // make 'this' as window\r\n\t\t\t\t  }\r\n\t\t\t\t  JCKEvent.domReady.callback = JCKEvent.domReady.observers = null;\r\n\t\t\t\t};\r\n\t\t\r\n\t\t\t\r\n\t\t\t\tvar ie = !!(window.attachEvent && !window.opera);\r\n\t\t\t\tvar webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1;\r\n\t\t\t\t\r\n\t\t\t\tif (document.readyState && webkit) {\r\n\t\t\t\t  \r\n\t\t\t\t  // Apple WebKit (Safari, OmniWeb, ...)\r\n\t\t\t\t  JCKEvent.domReady.timer = setInterval(function() {\r\n\t\t\t\t\tvar state = document.readyState;\r\n\t\t\t\t\tif (state == 'loaded' || state == 'complete') {\r\n\t\t\t\t\t  JCKEvent.domReady.callback();\r\n\t\t\t\t\t}\r\n\t\t\t\t  }, 50);\r\n\t\t\t\t  \r\n\t\t\t\t} else if (document.readyState && ie) {\r\n\t\t\t\t  \r\n\t\t\t\t  // Windows IE \r\n\t\t\t\t  var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)';\r\n\t\t\t\t  document.write(\r\n\t\t\t\t\t'<script type=\"text/javascript\" defer=\"defer\" src=\"' + src + '\" ' + \r\n\t\t\t\t\t'onreadystatechange=\"if (this.readyState == \\'complete\\') JCKEvent.domReady.callback();\"' + \r\n\t\t\t\t\t'><\\/script>');\r\n\t\t\t\t  \r\n\t\t\t\t} else {\r\n\t\t\t\t  \r\n\t\t\t\t  if (window.addEventListener) {\r\n\t\t\t\t\t// for Mozilla browsers, Opera 9\r\n\t\t\t\t\tdocument.addEventListener(\"DOMContentLoaded\", JCKEvent.domReady.callback, false);\r\n\t\t\t\t\t// Fail safe \r\n\t\t\t\t\twindow.addEventListener(\"load\", JCKEvent.domReady.callback, false);\r\n\t\t\t\t  } else if (window.attachEvent) {\r\n\t\t\t\t\twindow.attachEvent('onload', JCKEvent.domReady.callback);\r\n\t\t\t\t  } else {\r\n\t\t\t\t\t// Legacy browsers (e.g. Mac IE 5)\r\n\t\t\t\t\tvar fn = window.onload;\r\n\t\t\t\t\twindow.onload = function() {\r\n\t\t\t\t\t  JCKEvent.domReady.callback();\r\n\t\t\t\t\t  if (fn) fn();\r\n\t\t\t\t\t}\r\n\t\t\t\t  }\r\n\t\t\t\t  \r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t  }\r\n\t\t\t}\r\n\t\t\r\n\t\t\twindow.addDomReadyEvent = {};\r\n\t\t\tif(typeof window.addDomReadyEvent.add == 'undefined')\r\n\t\t\t\twindow.addDomReadyEvent.add = JCKEvent.domReady.add;\r\n\t\t}\r\n\t\t\r\n\t\twindow.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\t\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\r\n\t\t\t\t\t\t\t\t\t\t\t}, true );\r\n\t\r\n\t\t\t\t });\t \r\n\t\t\t\t \r\n\t\t\t\t //addCustom CSS\r\n\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none;" . $textalign . "}' );\r\n\t\t\t \r\n\t\t\t});\r\n\t\t\t\t\t\t\t\t\r\n\t\t});");
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('core');
     JCKPluginsHelper::importPlugin('core');
     $results = $mainframe->triggerEvent('intialize', array(&$params));
     $_GET['client'] = $mainframe->getClientId();
     /*		$session =& JFactory::getSession();
     		//clear stored jckplugins
     		$session->clear('jckplugins');		
     */
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array(&$params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array(&$params));
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\r\n\t\t\t" . (!empty($results) ? implode(chr(13), $results) : '') . "\t\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\r\n\t\r\n\t\t\t\t });\r\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\r\n\t\t\t\t\t \r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t {$formatsource}\r\n\t\t\t\t \t\t\t\t \r\n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\t//destroy editor instance if one already exist \r\n\t\t\t\t\tif ( oEditor )\r\n\t\t\t\t\t\toEditor.destroy();\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$lang}',\r\n\t\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}',\r\n\t\t\t\t\t\t entities : " . (int) $entities . "\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $editorname = JCKOutput::fixId($editorname);
     $javascript->addScriptDeclaration("\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\t\r\n\t\twindow.addDomReadyEvent.add(function() \r\n\t\t{\r\n \t\t\tCKEDITOR.tools.addHashFunction(function(div)\r\n\t\t\t{\r\n\t\t\t\t//create editor instance\r\n\t\t\t\tvar oEditor = CKEDITOR.replace(div,\r\n\t\t\t\t{ \r\n\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t language : '{$lang}',\r\n\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \r\n\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t height: '{$hheight}',\r\n\t\t\t\t\t entities : " . (int) $entities . "\r\n\t\t\t\t});\r\n\t\t\t},'" . $editorname . "');\r\n\t\t});");
     $handlerjs = "\r\n\t\t\r\n\t\tfunction editor_onDoubleClick( ev )\r\n\t\t{\r\n\t\t\t// Get the element which fired the event. This is not necessarily the\r\n\t\t\t// element to which the event has been attached.\r\n\t\t\tvar element = ev.target || ev.srcElement;\r\n\t\t\t// Find out the divtext container that holds this element.\r\n\t\t\t\r\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\r\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\r\n\t\t\t\telement = element.parentNode;\r\n\t\t\t\r\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\r\n\t\t\t{\r\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\r\n\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\t\tReplaceTextContainer( element,true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\r\n\t\t\t\t\tReplaceTextContainer( element,false);}\r\n\t\t\t}\t\t\r\n\t\t}\r\n\r\n\t\tvar editor_implementOnInstanceReady = function() \r\n\t\t{\r\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\r\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar editor = evt.editor;\r\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\r\n\t\t\t\t\tif(imgElement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\r\n\t\t\t\t\t}\t\t\r\n\t\t\t\t\t//add double click\r\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\r\n\t\t\t\t\t},null,{editor : editor});\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\r\n\t\t\t});\r\n\t\t\t\r\n\t\t}\t\t\r\n\t\tif ( window.addEventListener )\r\n\t\t{\r\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\r\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\r\n\t\t}\r\n\t\telse if ( window.attachEvent )\r\n\t\t{\r\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\r\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\r\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     return $javascript;
 }
예제 #16
0
    /**
     * ckeditor Lite WYSIWYG Editor - display the editor
     *
     * @param string The name of the editor area
     * @param string The content of the field
     * @param string The name of the form field
     * @param string The width of the editor area
     * @param string The height of the editor area
     * @param int The number of columns for the editor area
     * @param int The number of rows for the editor area
     * @param mixed Can be boolean or array.
     */
    function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null)
    {
        // Load modal popup behavior
        JHTML::_('behavior.modal', 'a.modal-button');
        // initialise $error varable
        $errors = '';
        static $loaded;
        if (empty($id)) {
            $id = $name;
        }
        if (!$width) {
            $width = "100%";
        }
        if (!$height) {
            $height = "350px";
        }
        $skin = $this->params->get('skin');
        if ($skin == 'kama' && $width == '100%') {
            $width = '99%';
        }
        $arributes = array("rows" => $row, 'cols' => $col, "style" => "width:{$width};height:{$height}");
        if (!$loaded) {
            /* Generate the Output */
            $this->params->set('editorname', $id);
            if (!$this->params->get('hheight', '')) {
                $this->params->set('hheight', $height);
            }
            if (!$this->params->get('wwidth', '')) {
                $this->params->set('wwidth', $width);
            }
            $javascript = JCKJavascriptHelper::getHeadJavascript($this->params, $errors, $return_script);
            $javascript->addToHead();
            $loaded = JCKOutput::fixId($id);
            if (!$return_script) {
                return;
            }
            //Here we will use JFCKJavascript output to screen //html element as well
            jckimport('ckeditor.htmlwriter.helper');
            return $errors . JCKHtmlwriterHelper::EditorTextArea($id, $name, $content, $buttons, $this, $arributes, $asset, $author);
        }
        //end if
        return JCKHtmlwriter::TextArea($id, $name, $content, $arributes) . '<script>window.addDomReadyEvent.add( function(){ 
			 
			CKEDITOR.on("instanceReady",function(evt)
			{
							
					
				if(evt.editor.name == "' . $loaded . '")
				{
								 
					var editor = CKEDITOR.replace( "' . JCKOutput::fixId($id) . '", CKEDITOR.instances["' . $loaded . '"].config ); 
										
					
					var xtdbuttons = CKEDITOR.document.getById("editor-xtd-buttons");
					if(xtdbuttons)
					{                                                               
						buttonsHtml = xtdbuttons.getOuterHtml().replace(/' . $loaded . '/g,"' . JCKOutput::fixId($id) . '");
						var buttonsElement = CKEDITOR.dom.element.createFromHtml(buttonsHtml); 
						editor.container.getParent().append(buttonsElement);
											
						var elements = buttonsElement.getElementsByTag("a");
													
						for(i= 0; i < elements.count();i++)
						{
							//override mootools model click event
							if(elements.getItem(i).hasClass("modal-button"))
							{
								(function()
								{
									var el = $(elements.getItem(i).$);
									el.addEvent("click", function(e) 
									{
										new Event(e).stop();
										SqueezeBox.fromElement(el,	{
																		parse: "rel"
																	});
									});
								})();
							}		
						}				
					}
				}	
				 
			})         
		});</script>';
    }
예제 #17
0
 function &getToolbarList()
 {
     $rows = array();
     jckimport('helper');
     $toolbars =& JCKHelper::getEditorToolbars();
     if (!empty($toolbars)) {
         foreach ($toolbars as $toolbar) {
             $row = new stdclass();
             $row->text = $toolbar;
             $row->value = $toolbar;
             $rows[] = $row;
         }
     }
     return $rows;
 }
예제 #18
0
파일: list.php 프로젝트: enjoy2000/714water
 function onPublish($cid, $value)
 {
     if (!$this->canDo->get('core.edit.state')) {
         $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_PUB'), 'error');
         return false;
     }
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $cids = implode(',', $cid);
     $query = 'SELECT name FROM #__jckplugins' . ' WHERE id IN ( ' . $cids . ' )' . ' AND ( checked_out = 0 OR ( checked_out = ' . (int) $user->get('id') . ' ))';
     $db->setQuery($query);
     $pluginnames = $db->loadColumn();
     if (!$pluginnames) {
         JCKHelper::error($db->getErrorMsg());
     }
     jckimport('helper');
     $config = JCKHelper::getEditorPluginConfig();
     foreach ($pluginnames as $pname) {
         $config->set($pname, $value);
     }
     $cfgFile = CKEDITOR_LIBRARY . DS . 'plugins' . DS . 'toolbarplugins.php';
     // Get the toolbar registry in PHP class format and write it to file
     $buffer = $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins'));
     if (!JFile::write($cfgFile, $buffer)) {
         $modify = $value ? 'publish ' : 'unpublish ';
         JCKHelper::error(JText::sprintf('COM_JCK_PLUGIN_LIST_FAILED_TO_PUBLISH_UNPUBLISH_PLUGINS', $modify));
     }
 }
예제 #19
0
 function onPublish($cid, $value)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $cids = implode(',', $cid);
     $query = 'SELECT name FROM #__jckplugins' . ' WHERE id IN ( ' . $cids . ' )' . ' AND ( checked_out = 0 OR ( checked_out = ' . (int) $user->get('id') . ' ))';
     $db->setQuery($query);
     $pluginnames = $db->loadResultArray();
     if (!$pluginnames) {
         JError::raiseError(500, $db->getErrorMsg());
     }
     jckimport('helper');
     $config = JCKHelper::getEditorPluginConfig();
     foreach ($pluginnames as $pname) {
         $config->setValue($pname, $value);
     }
     $cfgFile = CKEDITOR_LIBRARY . DS . 'plugins' . DS . 'toolbarplugins.php';
     // Get the toolbar registry in PHP class format and write it to file
     $buffer = $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins'));
     if (!JFile::write($cfgFile, $buffer)) {
         JError::raiseWarning(100, 'Failed to ' . ($value ? 'publish ' : 'unpublish ') . ' all selected jckeditor plugins');
     }
 }
예제 #20
0
 function check()
 {
     jckimport('ckeditor.user.user');
     $user =& JCKUser::getInstance();
     return $user->gid > 0;
 }
예제 #21
0
 function beforeLoad(&$params)
 {
     //lets create JS object
     $javascript = new JCKJavascript();
     if ($this->_overwrite) {
         $javascript->addScriptDeclaration("editor.on( 'configLoaded', function()\r\n\t\t\t\t{\r\n\t\t\t\t\teditor.config.plugins = 'html5support,' + editor.config.plugins\r\n\t\t\t\t\tif(editor.config.extraPlugins)\r\n\t\t\t\t\t\teditor.config.extraPlugins += ',video,audio,uicolor,imagedragndrop,ie9selectionoverride';\r\n\t\t\t\t\telse \t\r\n\t\t\t\t\t\teditor.config.extraPlugins += 'video,audio,uicolor,imagedragndrop,ie9selectionoverride';\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.config.toolbar == 'Full')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar toolbar = editor.config.toolbar_Full[editor.config.toolbar_Full.length-1];\r\n\t\t\t\t\t\tvar extra = ['Video','Audio','UIColor'];\r\n\t\t\t\t\t\teditor.config.toolbar_Full[editor.config.toolbar_Full.length-1] = toolbar.concat(extra);\r\n\t\t\t\t\t}\t\r\n\t\t\t\t});");
     }
     $config = JFactory::getConfig();
     $dbname = $config->get('db');
     $db = JFactory::getDBO();
     $query = "SELECT COUNT(1)\r\n\t\tFROM information_schema.tables \r\n\t\tWHERE table_schema = '" . $dbname . "' \r\n\t\tAND table_name = '" . $db->getPrefix() . "jcktoolbarplugins'";
     $db->setQuery($query);
     if (!$db->loadResult()) {
         return $javascript->toRaw();
     }
     $query = "SELECT COUNT(p.id) AS pcount,COUNT(tp.pluginid) AS tpcount FROM #__jckplugins p\r\n\t\tLEFT JOIN #__jcktoolbarplugins tp on tp.pluginid = p.id\r\n\t\tWHERE `name` IN('html5support','video','audio','uicolor') ";
     $db->setQuery($query);
     $info = $db->loadObject();
     if ($info && $info->tpcount) {
         return;
     }
     if (!$info->pcount) {
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \r\n\t\t\t('','html5support','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return $javascript->toRaw();
         }
         $parentid = $db->insertid();
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \r\n            ('Video','video','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\r\n            ('Audio','audio','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\r\n            ('UIColor','uicolor','plugin',3,1,1,'uicolor.gif',1,'',NULL),\t\r\n            ('','imagedragndrop','plugin',0,1,1,'',1,'',NULL),\r\n\t\t\t('','ie9selectionoverride','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return $javascript->toRaw();
         }
         $first = $db->insertid();
         $last = $first + 2;
         //get next layout row  details
         $query = "SELECT row as rowid,MAX(`ordering`) +1 AS rowordering FROM #__jcktoolbarplugins WHERE toolbarid = 1 \r\n                        GROUP BY row\r\n                        ORDER BY row DESC LIMIT 1";
         $db->setQuery($query);
         $rowDetail = $db->loadObject();
         $values = array();
         for ($i = $first; $i <= $last; $i++) {
             $values[] = '(1,' . $i . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering++ . ',1)';
         }
         $query = "INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES " . implode(",", $values);
         $db->setQuery($query);
         $db->query();
     }
     if ($this->_overwrite) {
         //Get toolbar plugins object
         jckimport('ckeditor.plugins');
         jckimport('ckeditor.plugins.toolbarplugins');
         $plugins = new JCKtoolbarPlugins();
         foreach (get_object_vars($plugins) as $key => $value) {
             if (strpos('p' . $key, '_')) {
                 unset($plugins->{$key});
             }
         }
         $plugins->html5support = 1;
         $plugins->video = 1;
         $plugins->audio = 1;
         $plugins->uicolor = 1;
         $plugins->imagedragndrop = 1;
         $plugins->ie9selectionoverride = 1;
         $config = new JRegistry('config');
         $config->loadObject($plugins);
         $cfgFile = '';
         $is1_6plus = file_exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor');
         if ($is1_6plus) {
             $cfgFile = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbarplugins.php';
         } else {
             $cfgFile = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbarplugins.php';
         }
         // Get the config registry in PHP class format and write it to file
         if ($is1_6plus) {
             if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return $javascript->toRaw();
             }
             //if fail then bail out
         } else {
             if (!JFile::write($cfgFile, $config->toString('PHP', 'config', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return $javascript->toRaw();
             }
             //if fail then bail out
         }
         jckimport('ckeditor.toolbar');
         jckimport('ckeditor.toolbar.full');
         $toolbar = new JCKFull();
         //fix toolbar values or they will get wiped out
         foreach (get_object_vars($toolbar) as $k => $v) {
             if (is_null($v)) {
                 $toolbar->{$k} = '';
             }
             if ($k[0] == '_') {
                 $toolbar->{$k} = NULL;
             }
         }
         if (isset($toolbar->Video) || isset($toolbar->Audio) || isset($toolbar->UIColor)) {
             return false;
         }
         $toolbar->Video = '';
         $toolbar->Audio = '';
         $toolbar->UIColor = '';
         $toolbarConfig = new JRegistry('toolbar');
         $toolbarConfig->loadObject($toolbar);
         $filename = '';
         if ($is1_6plus) {
             $filename = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'toolbar' . DS . 'full.php';
         } else {
             $filename = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'toolbar' . DS . 'full.php';
         }
         // Get the config registry in PHP class format and write it to file
         if ($is1_6plus) {
             JFile::write($filename, $toolbarConfig->toString('PHP', array('class' => 'JCKFull extends JCKToolbar')));
         } else {
             JFile::write($filename, $toolbarConfig->toString('PHP', 'toolbar', array('class' => 'JCKFull extends JCKToolbar')));
         }
     }
     return $javascript->toRaw();
 }
예제 #22
0
 static function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe = JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance = JBrowser::getInstance();
     $language = JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $skin = $params->def('skin', 'office2007');
     $hheight = $params->def('hheight', 480);
     $wwidth = $params->def('wwidth', '100%');
     $lang_mode = $params->def('lang_mode', 1);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 2);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     $ftcolor = $params->get('ftcolor', '');
     $textalign = $params->get('textalign', 0);
     $entities = $params->get('entities', 0);
     $formatsource = $params->get('formatsource', 1);
     $minify = $params->get('minify', 1);
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             $lang = "";
             break;
     }
     $params->set('JoomlaLang', $lang);
     $stylesheet =& JCKStylesheet::getInstance($params, $path_root);
     $content_css = $stylesheet->getPath($errors);
     $content_css = JURI::root() . $content_css;
     $content_css = str_replace(DS, '/', $content_css);
     $stylesheetJSO = $stylesheet->getJSObject();
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     if ($textalign) {
         $textalign = "text-align:{$textalign};";
     } else {
         $textalign = "";
     }
     if (!$formatsource) {
         $formatsource = "\n\t\t\t\tvar format = [];\n\t\t\t\tformat['indent'] = false;\n\t\t\t\tformat['breakBeforeOpen'] = false; \n\t\t\t\tformat['breakAfterOpen'] =  false;\n\t\t\t\tformat['breakBeforeClose'] = false;\n\t\t\t\tformat['breakAfterClose'] = false;\n\t\t\t\tvar dtd = CKEDITOR.dtd;\n\t\t\t\tfor ( var e in CKEDITOR.tools.extend( {}, dtd.\$nonBodyContent, dtd.\$block, dtd.\$listItem, dtd.\$tableContent ) ) {\n\t\t\t\t\t\teditor.dataProcessor.writer.setRules( e, format); \n\t\t\t\t} \n\t\t\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\n\t\t\t\t{\n\t\t\t\t\tindent: false\n\t\t\t\t}); \n\t\t\t";
     } else {
         $formatsource = "\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\n\t\t\t\t{\n\t\t\t\t\tindent : false,\n\t\t\t\t\tbreakAfterOpen : false,\t\n\t\t\t\t    breakBeforeClose: false\n\t\t\t\t}); \n\t\t\t";
     }
     $javascript->addScriptDeclaration("\n\t\t\t\n            " . self::addDomReadyEventHandler() . " \n            \n            window.addDomReadyEvent.add(function() \n\t\t\t{\n\t\t\t\n\t\t\t\tCKEDITOR.on('instanceCreated',function(evt)\n\t\t\t\t{\n\t\t\t\t\t var editor = evt.editor;\n\t\t\t\t\t \n\t\t\t\t\t editor.on( 'customConfigLoaded', function()\n\t\t\t\t\t {\n\t\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \n\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\n\t\t\t\t\t\t}, true );\n\t\t\n\t\t\t\t\t });\t \n\t\t\t\t\t \n\t\t\t\t\t //addCustom CSS\n\t\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none;" . $textalign . ";}' );\n\t\t\t\t\t " . ($ftcolor ? "editor.addCss( 'body { color: " . $ftcolor . "; }' )" : "") . "\n\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t});");
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('toolbar');
     JCKPluginsHelper::importPlugin('toolbar');
     $mainframe->triggerEvent('load', array(&$params));
     $toolbar = $params->def('toolbar', 'Publisher');
     $toolbar_ft = $params->def('toolbar_ft', 'Basic');
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     //set session
     $clientid = $mainframe->getClientId();
     $_GET['client'] = $clientid;
     //set jck_toolbar param
     $params->set('jck_toolbar', $toolbar);
     //import core plugins first
     JCKPluginsHelper::storePlugins('core');
     JCKPluginsHelper::importPlugin('core');
     $results = $mainframe->triggerEvent('intialize', array(&$params));
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array(&$params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array(&$params));
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \n\t\t{\n\t\n\t\t\t" . (!empty($results) ? implode(chr(13), $results) : '') . "\t\n\t\t\t\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\n\t\t\t{\n\t\t\t\t var editor = evt.editor;\n\t\t\t\t editor.on( 'customConfigLoaded', function()\n\t\t\t\t {\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\n\t\n\t\t\t\t });\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\n\t\t\t\t\t \n\t\t\t});\n\t\t});");
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \n\t\t{\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\n\t\t\t{\n\t\t\t\t var editor = evt.editor;\n\t\t\t\t {$formatsource}\n\t\t\t\t \t\t\t\t \n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\n\t\t\t});\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\n\t\t\t\t\t\t\t\t   \n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\n\t\t\t\t{\n\t\t\t\t\t//destroy editor instance if one already exist \n\t\t\t\t\tif ( oEditor )\n\t\t\t\t\t\toEditor.destroy();\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\n\t\t\t\t\t//create editor instance\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\n\t\t\t\t\t{ \n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\n\t\t\t\t\t\t skin : '{$skin}',\t\n\t\t\t\t\t\t contentsCss :['{$content_css}'],\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\n\t\t\t\t\t\t language : '{$lang}',\n\t\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \n\t\t\t\t\t\t enterMode : '{$entermode}',\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\n\t\t\t\t\t\t " . ($wwidth ? "width : '{$wwidth}'" : "") . ",\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}',\n\t\t\t\t\t\t entities : " . (int) $entities . "\n\t\t\t\t\t});\n\t\t\t\t}");
     $editorname = JCKOutput::fixId($editorname);
     $javascript->addScriptDeclaration("\n\t\t\t\t\t\t\t\t   \n\t\t\t\t\n\t\twindow.addDomReadyEvent.add(function() \n\t\t{\n \t\t\tCKEDITOR.tools.addHashFunction(function(div)\n\t\t\t{\n\t\t\t\t//create editor instance\n\t\t\t\tvar oEditor = CKEDITOR.replace(div,\n\t\t\t\t{ \n\t\t\t\t\t baseHref : '" . JURI::root() . "',\n\t\t\t\t\t imagePath :  '{$imagepath}',     \n\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\n\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\n\t\t\t\t\t uiColor\t: '{$uicolor}',\n\t\t\t\t\t skin : '{$skin}',\t\n\t\t\t\t\t contentsCss :['{$content_css}'],\n\t\t\t\t\t contentsLangDirection : '{$direction}',\n\t\t\t\t\t language : '{$lang}',\n\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \n\t\t\t\t\t enterMode : '{$entermode}',\n\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\n\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\n\t\t\t\t\t " . ($wwidth ? "width : '{$wwidth}'" : "") . ",\n\t\t\t\t\t " . ($hheight ? "height : '{$hheight}'" : "") . ",\n\t\t\t\t\t entities : " . (int) $entities . "\n\t\t\t\t});\n\t\t\t},'" . $editorname . "');\n\t\t});");
     $handlerjs = "\n\t\t\n\t\tfunction editor_onDoubleClick( ev )\n\t\t{\n\t\t\t// Get the element which fired the event. This is not necessarily the\n\t\t\t// element to which the event has been attached.\n\t\t\tvar element = ev.target || ev.srcElement;\n\t\t\t// Find out the divtext container that holds this element.\n\t\t\t\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\n\t\t\t\telement = element.parentNode;\n\t\t\t\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\n\t\t\t{\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\n\t\t\t\t\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\n\t\t\t\t\tReplaceTextContainer( element,true);\n\t\t\t\t}else{\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\n\t\t\t\t\tReplaceTextContainer( element,false);}\n\t\t\t}\t\t\n\t\t}\n\n\t\tvar editor_implementOnInstanceReady = function() \n\t\t{\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\n\t\t\t\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\n\t\t\t\t{\n\t\t\t\t\tvar editor = evt.editor;\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\n\t\t\t\t\tif(imgElement)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(editor.getSelection())\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t//add double click\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\n\t\t\t\t\t{\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\n\t\t\t\t\t},null,{editor : editor});\n\t\t\t\t\n\t\t\t\t\tif(editor.getSelection())\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\n\t\t\t\t\t\t\n\t\t\t\t}\t\n\n\t\t\t});\n\t\t\t\n\t\t}\t\t\n\t\tif ( window.addEventListener )\n\t\t{\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\n\t\t}\n\t\telse if ( window.attachEvent )\n\t\t{\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     $javascript->setMinify($minify);
     return $javascript;
 }
예제 #23
0
파일: helper.php 프로젝트: justinlyon/scc
 function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe =& JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance =& JBrowser::getInstance();
     $language =& JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $toolbar = $params->def('toolbar', 'Full');
     $toolbar_ft = $params->def('toolbar_ft', 'Full');
     $skin = $params->def('skin', 'office2007');
     $text_direction = $params->def('text_direction', 'ltr');
     $wwidth = $params->def('wwidth', '100%');
     $hheight = $params->def('hheight', 480);
     $lang_mode = $params->def('lang_mode', 0);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 0);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             break;
     }
     $stylesheet =& JCKStylesheet::getInstance($path_root);
     $content_css = $stylesheet->getPath($params, $errors);
     $stylesheetJSO = $stylesheet->getJSObject();
     /*
      $jsloadJSO = 'var ckstyles_template;
      
      			window.addEvent("domready",function()
     			{
     				CKEDITOR.on("instanceReady",function(evt)
     				{
     					ckstyles_template = '.$stylesheetJSO .';
     				});
     			});';	
     $javascript->addScriptDeclaration($jsloadJSO);
     */
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\r\n\t\t\t\t\t\t\t\t\t\t\t}, true );\r\n\t\r\n\t\t\t\t });\t \r\n\t\t\t\t \r\n\t\t\t\t //addCustom CSS\r\n\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none; }' );\r\n\t\t\t\t \r\n\t\t\t});\r\n\t\t\t\t\t\t\t\t\r\n\t\t});");
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     jckimport('ckeditor.plugins.helper');
     $session =& JFactory::getSession();
     //clear stored jckplugins
     $session->clear('jckplugins');
     $_GET['client'] = $mainframe->getClientId();
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array($params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array($params));
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\r\n\t\r\n\t\t\t\t });\r\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\r\n\t\t\t\t\t\r\n\t\t\t\t \r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\t//destroy editor instance if one already exist \r\n\t\t\t\t\tif ( oEditor )\r\n\t\t\t\t\t\toEditor.destroy();\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$AutoDetectLanguage}',\r\n\t\t\t\t\t\t defaultLanguage :'{$lang}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}'\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $javascript->addScriptDeclaration("\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction Replace" . $editorname . "TextContainer(div)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\tvar oEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$AutoDetectLanguage}',\r\n\t\t\t\t\t\t defaultLanguage :'{$lang}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: '{$hheight}'\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $handlerjs = "\r\n\t\t\r\n\t\tfunction editor_onDoubleClick( ev )\r\n\t\t{\r\n\t\t\t// Get the element which fired the event. This is not necessarily the\r\n\t\t\t// element to which the event has been attached.\r\n\t\t\tvar element = ev.target || ev.srcElement;\r\n\t\t\t// Find out the divtext container that holds this element.\r\n\t\t\t\r\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\r\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\r\n\t\t\t\telement = element.parentNode;\r\n\t\t\t\r\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\r\n\t\t\t{\r\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\r\n\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\t\tReplaceTextContainer( element,true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\r\n\t\t\t\t\tReplaceTextContainer( element,false);}\r\n\t\t\t}\t\t\r\n\t\t}\r\n\r\n\t\tvar editor_implementOnInstanceReady = function() \r\n\t\t{\r\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\r\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar editor = evt.editor;\r\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\r\n\t\t\t\t\tif(imgElement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\r\n\t\t\t\t\t}\t\t\r\n\t\t\t\t\t//add double click\r\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\r\n\t\t\t\t\t},null,{editor : editor});\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\r\n\t\t\t});\r\n\t\t\t\r\n\t\t}\t\t\r\n\t\tif ( window.addEventListener )\r\n\t\t{\r\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\r\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\r\n\t\t}\r\n\t\telse if ( window.attachEvent )\r\n\t\t{\r\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\r\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\r\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     return $javascript;
 }
예제 #24
0
 function _parse($file)
 {
     //Get JCK additional styles
     //Get editor params
     $plugin = JPluginHelper::getPlugin('editors', 'jckeditor');
     if (is_string($plugin->params)) {
         //always must do this check
         $params = @new JRegistry($plugin->params);
     } else {
         $params = $plugin->params;
     }
     if (!$params->get('styles_css', true)) {
         $this->_default_beez_template = '';
     }
     $params->set('default_beez_template', $this->_default_beez_template);
     jckimport('ckeditor.plugins.helper');
     //import plugins
     JCKPluginsHelper::storePlugins('stylesheet');
     JCKPluginsHelper::importPlugin('stylesheet');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('load', array(&$params));
     $results = array_reverse($results);
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i]) {
             $this->_readCSS($results[$i]);
         }
     }
     preg_match_all('/^\\s*(?:[a-z0-9\\s\\b]*)@import\\s*(?:url\\()?(?:"|\')?([^"\'\\)]+)(?:"|\')?\\)?;/im', $file, $fmatches, PREG_SET_ORDER);
     foreach ($fmatches as $fmatch) {
         $oldumask = umask(0);
         @chmod($fmatch[1], 0666);
         umask($oldumask);
         if (!strpos($fmatch[1], '://')) {
             $content = file_get_contents($this->_dir . "/" . $fmatch[1]);
         } else {
             $content = file_get_contents($fmatch[1]);
         }
         $this->_parse($content);
     }
     // foreach fmatches
     $this->_readCSS($file);
 }
예제 #25
0
jimport('joomla.environment.uri');
jimport('joomla.environment.request');
jimport('joomla.environment.response');
jimport('joomla.user.user');
jimport('joomla.application.component.model');
jimport('joomla.html.parameter');
//This is required for the User Params
jimport('joomla.utilities.arrayhelper');
//lets set DB configuration
$config = new JConfig();
// Get the global configuration object
$registry = JFactory::getConfig();
// Load the configuration values into the registry
$registry->loadObject($config);
//lets set session
jckimport('ckeditor.user.user');
$session = JCKUser::getSession();
/*** End load joomla core classe **/
/**
 * Simple function required by config.php - discover the server side path
 * to the directory relative to the "$baseUrl" attribute
 *
 * @package CKEditor
 * @subpackage Connector
 * @param string $baseUrl
 * @return string
 */
function resolveUrl($baseUrl)
{
    $fileSystem =& CKEditor_Connector_Core_Factory::getInstance("Utils_FileSystem");
    return $fileSystem->getDocumentRootPath() . $baseUrl;
예제 #26
0
<?php

/*
 * Modified for use as the J plugin installer
 * AW
 */
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die;
define('JCK_PATH', JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor');
define('JCK_PLUGINS', JCK_PATH . DS . 'plugins');
require_once JPATH_COMPONENT . DS . 'tables' . DS . 'plugin.php';
require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
jckimport('helper');
/**
 * Plugin installer
 *
 * @package		Joomla.Framework
 * @subpackage	Installer
 * @since		1.5
 * Renamed JInstallerPlugin to JCKRestorerPlugin
 */
class JCKRestorerPlugin extends JObject
{
    /**
     * Constructor
     *
     * @access	protected
     * @param	object	$parent	Parent object [JInstaller instance]
     * @return	void
     * @since	1.5
     */
예제 #27
0
    $view = $app->input->get('view', 'cpanel');
} else {
    require_once 'helper.php';
    $view = 'cpanel';
    $app->enqueueMessage("COM_JCKMAN_NO_DETECT_EDITOR_MSG");
}
// Require specific controller if requested
jckimport('controllers.' . $view);
if ($view == "install") {
    require_once JPATH_COMPONENT . DS . 'controllers' . DS . 'install.php';
    //load language file,
    $lang = JFactory::getLanguage();
    $lang->load('com_installer', JPATH_ADMINISTRATOR);
    // Create the controller
    jimport('joomla.client.helper');
    $controller = JControllerLegacy::getInstance('Installer', array('base_path' => dirname(__FILE__)));
    if (!is_a($controller, 'InstallerController')) {
        $app->setUserState('com_installer.redirect_url', 'index.php?option=com_jckman&view=install');
    }
    $controller->execute($app->input->get('task'));
    $controller->redirect();
} else {
    // main helper class
    jckimport('helper');
    // global include classes
    jckimport('parameter.parameter');
    jckimport('html.html');
    $controller = JControllerLegacy::getInstance('JCKMan');
    $controller->execute($app->input->get('task'));
    $controller->redirect();
}
예제 #28
0
    public function onSync()
    {
        if (!$this->canDo->get('jckman.sync')) {
            $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_SYNC'), 'error');
            return false;
        }
        jimport('joomla.filesystem.file');
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'pluginoverrides.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'pluginoverrides.php';
        if (!JFile::copy($src, $dest)) {
            $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_UNABLE_MOVE_PLUGINOVERRIDES_PLUGIN'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'acl.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'acl.php';
        if (!JFile::copy($src, $dest)) {
            $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_UNABLE_MOVE_ACL_PLUGIN'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'components.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbar' . DS . 'components.php';
        if (!JFile::copy($src, $dest)) {
            $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_UNABLE_MOVE_COMPONENTS_PLUGIN'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins.php';
        if (!JFile::copy($src, $dest)) {
            $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_UNABLE_MOVE_BASE_PLUGIN'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'scayt.xml';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . 'scayt' . DS . 'scayt.xml';
        if (!JFile::copy($src, $dest)) {
            $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_UNABLE_MOVE_SCAYT_PLUGIN'));
        }
        //Lets try and restore  broken or removed plugins from backup
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'helpers' . DS . 'restorer.php';
        $restorer = JCKRestorer::getInstance();
        $srcBase = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS;
        $destBase = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS;
        $folders = JFolder::folders($srcBase);
        foreach ($folders as $folder) {
            $src = $srcBase . $folder;
            if (!$restorer->install($src)) {
                $this->app->enqueueMessage(JText::sprintf('COM_JCKMAN_CPANEL_UNABLE_RESTORE_FOLDER', $folder), 'error');
            } else {
                $this->app->enqueueMessage(JText::sprintf('COM_JCKMAN_CPANEL_SUCESSFULLY_RESTORE_FOLDER', $folder));
            }
        }
        //check whether plugin is not a core plugin
        //if its not iterate through and see if there are files missing
        //then delete the plugin if there are
        $db = JFactory::getDBO();
        $query = 'SELECT p.id, p.name FROM `#__jckplugins` p WHERE p.iscore = 0';
        $results = $db->setQuery($query)->loadObjectList();
        if (!empty($results)) {
            for ($i = 0; $i < count($results); $i++) {
                if (!JFolder::exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name)) {
                    $query = 'DELETE FROM #__jcktoolbarplugins
								WHERE pluginid =' . $results[$i]->id;
                    $db->setQuery($query)->query();
                    $query = 'DELETE FROM #__jckplugins
								WHERE id =' . $results[$i]->id;
                    $db->setQuery($query)->query();
                }
            }
            //end for loop
        }
        //check for plugins that have not been added to layout -- legacy check
        $query = 'SELECT id,name FROM `#__jcktoolbars`';
        $toolbars = $db->setQuery($query)->loadObjectList();
        $JCKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
        $values = array();
        if (!empty($toolbars)) {
            require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
            //update core plugins layout if needed
            foreach ($toolbars as $row) {
                // get the total number of core plugin records
                $sql = $db->getQuery(true);
                $sql->select('COUNT(*)')->from('#__jcktoolbarplugins tp')->join('INNER', '#__jckplugins p ON tp.pluginid = p.id')->where('tp.toolbarid =' . (int) $row->id)->where('p.iscore = 1');
                $totalRows = $db->setQuery($sql)->loadResult();
                if (!$totalRows) {
                    $filename = $JCKfolder . DS . $row->name . '.php';
                    require_once $filename;
                    $classname = 'JCK' . ucfirst($row->name);
                    $toolbar = new $classname();
                    $sql = $db->getQuery(true);
                    $sql->select('p.id, p.title')->from('#__jckplugins p')->join('LEFT', '#__jckplugins parent ON parent.id = p.parentid AND parent.published = 1')->where('p.title != ""')->where('p.published = 1')->where('p.iscore = 1')->where('(p.parentid IS NULL OR parent.published = 1)');
                    $allplugins = $db->setQuery($sql)->loadObjectList();
                    $values = array();
                    //fix toolbar values or they will get wiped out
                    $l = 1;
                    $n = 1;
                    $j = 1;
                    foreach (get_object_vars($toolbar) as $k => $v) {
                        if ($v) {
                            $n = $n > $v ? $n : $v;
                        }
                        if ($l < $n) {
                            $l = $n;
                            $j = 1;
                        }
                        for ($m = 0; $m < count($allplugins); $m++) {
                            if ($k == $allplugins[$m]->title) {
                                $values[] = '(' . (int) $row->id . ',' . (int) $allplugins[$m]->id . ',' . $n . ',' . $j . ',1)';
                                break;
                            }
                            if (strpos($k, 'brk_') !== false) {
                                $id = preg_match('/[0-9]+$/', $k);
                                $id = $id * -1;
                                $values[] = '(' . (int) $row->id . ',' . $id . ',' . $n . ',' . $j . ',1)';
                                $n++;
                                break;
                            }
                        }
                        $j++;
                    }
                    if (!empty($values)) {
                        $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values);
                        $db->setQuery($query);
                        if (!$db->query()) {
                            JCKHelper::error($db->getErrorMsg());
                        }
                    }
                }
            }
            //update non core plugins layout
            $values = array();
            foreach ($toolbars as $row) {
                $query = 'SELECT id,title FROM `#__jckplugins` p WHERE p.title != "" AND p.iscore = 0  AND p.published = 1' . ' AND NOT EXISTS(SELECT 1 FROM  #__jcktoolbarplugins tp WHERE tp.pluginid = p.id AND tp.toolbarid = ' . $row->id . ')';
                $plugins = $db->setQuery($query)->loadObjectList();
                $tmpfilename = $JCKfolder . DS . $row->name . '.php';
                if (!file_exists($tmpfilename)) {
                    continue;
                }
                //skip
                require_once $tmpfilename;
                $classname = 'JCK' . ucfirst($row->name);
                $toolbar = new $classname();
                $rowDetail = JCKHelper::getNextLayoutRow($row->id);
                foreach (get_object_vars($toolbar) as $k => $v) {
                    foreach ($plugins as $plugin) {
                        if ($plugin->title == $k) {
                            $values[] = '(' . $row->id . ',' . $plugin->id . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering . ',1)';
                            $rowDetail->rowordering++;
                        }
                    }
                }
            }
        }
        //Now add plugins to layouts
        if (!empty($values)) {
            $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values) . ' ON DUPLICATE KEY UPDATE toolbarid = VALUES(toolbarid),pluginid = VALUES(pluginid)';
            $db->setQuery($query);
            if (!$db->query()) {
                JCKHelper::error($db->getErrorMsg());
            }
        }
        //Reload Toolbar if editor is re-installed
        jckimport('event.observable.editor');
        $obs = new JCKEditorObservable('toolbars');
        $handle = $obs->getEventHandler();
        $query = 'SELECT * FROM `#__jcktoolbars` t WHERE exists(SELECT 1 FROM  #__jcktoolbarplugins tp WHERE tp.toolbarid  = t.id)';
        $rowresults = $db->setQuery($query)->loadObjectList();
        foreach ($rowresults as $row) {
            $id = $row->id;
            $name = $row->name;
            $title = $row->title;
            switch ($name) {
                case 'publisher':
                case 'full':
                case 'basic':
                case 'blog':
                case 'image':
                case 'mobile':
                    $isNew = false;
                    break;
                default:
                    $isNew = true;
                    break;
            }
            //end switch
            $handle->onSave($id, $name, $name, $title, $isNew);
        }
        //restore state of published/unpublished plugins
        $obs = new JCKEditorObservable('list');
        $handle = $obs->getEventHandler();
        $where = array();
        $where[] = ' WHERE p.published = 1';
        $where[] = ' WHERE p.published = 0';
        $state = array(1, 0);
        $count = count($where);
        $db = JFactory::getDBO();
        for ($i = 0; $i < $count; $i++) {
            $query = 'SELECT id FROM `#__jckplugins` p' . $where[$i] . ' AND p.iscore = 1 AND type="plugin"';
            $results = $db->setQuery($query)->loadColumn();
            $handle->onPublish($results, $state[$i]);
        }
        //restore language overrides
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'overrides';
        $dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'language' . DS . 'overrides';
        $files = JFolder::files($src);
        foreach ($files as $file) {
            if ($file == 'index.html') {
                continue;
            }
            $source = $src . '/' . $file;
            $path = $dest . '/' . $file;
            if (JFile::exists($file)) {
                $this->app->enqueueMessage(JText::sprintf('COM_JCKMAN_CPANEL_LANGUAGE_EXISTS', $file), 'warning');
            } elseif (!JFile::copy($source, $path)) {
                $this->app->enqueueMessage(JText::sprintf('COM_JCKMAN_CPANEL_UNABLE_RESTORE_LANGUAGE', $file), 'error');
            } else {
                $this->app->enqueueMessage(JText::sprintf('COM_JCKMAN_CPANEL_SUCESSFULLY_RESTORE_LANGUAGE', $file));
            }
        }
        $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_EDITOR_SYNCHRONIZED'));
    }
예제 #29
0
<?php

/*------------------------------------------------------------------------
# Copyright (C) 2005-2013 WebxSolution Ltd. All Rights Reserved.
# @license - GPLv2.0
# Author: WebxSolution Ltd
# Websites:  http://www.webxsolution.com
# Terms of Use: An extension that is derived from the JoomlaCK editor will only be allowed under the following conditions: http://joomlackeditor.com/terms-of-use
# ------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.event.plugin');
jckimport('ckeditor.htmlwriter.javascript');
class plgEditorlanguageOverrides extends JPlugin
{
    function plgEditorlanguageOverrides(&$subject, $config)
    {
        parent::__construct($subject, $config);
    }
    function beforeLoad(&$params)
    {
        $basePath = JPATH_CONFIGURATION . '/administrator/components/com_jckman/editor/lang';
        $languages = JFolder::files($basePath, '.js$', 1, true);
        $js = "";
        $default = $params->get("joomlaLang", "en");
        foreach ($languages as $language) {
            $content = file_get_contents($language);
            $content = preg_replace("/\\/\\*.*?\\*\\//s", "", $content);
            $content = str_replace('"', "'", $content);
            $language = str_replace("\\", "/", $language);
            $parts = explode("/", $language);
            $lang = preg_replace("/\\.js\$/", "", array_pop($parts));
예제 #30
0
 function authorise()
 {
     jckimport('ckeditor.user.user');
     $user = JCKUser::getInstance();
     return $user->gid > 0;
 }