Exemplo n.º 1
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     JToolBarHelper::title(JText::_('COM_JCKMAN_SUBMENU_LAYOUT_NAME'), 'layout.png');
     if ($this->canDo->get('core.create')) {
         JToolBarHelper::addNew('toolbars.add');
     }
     if ($this->canDo->get('core.edit')) {
         JToolBarHelper::editList('toolbars.edit');
     }
     if ($this->canDo->get('core.create')) {
         JToolBarHelper::custom('toolbars.copy', 'copy', 'copy', JText::_('JLIB_HTML_BATCH_COPY'), true);
     }
     if ($this->canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'toolbars.remove');
     }
     if ($this->canDo->get('core.edit.state')) {
         JToolbarHelper::checkin('toolbars.checkin');
     }
     // Add a Link button for Control Panel
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&view=cpanel');
     JToolBarHelper::help($this->app->input->get('view'), false, 'http://www.joomlackeditor.com/installation-guide?start=17#layout_man');
     JHtmlSidebar::setAction('index.php?option=com_jckman&view=' . JFactory::getApplication()->input->get('view', 'toolbars'));
     JCKHelper::addSubmenu($this->app->input->get('view'));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 2
0
 static function &geTtoolbarParams($editor, $args = array())
 {
     if (count($args) > 1) {
         $row = $args[1];
     }
     if (is_a($args[0], 'JParameter')) {
         $params = $args[0];
     } else {
         if ($row) {
             $params = new JParameter($row->params);
         } else {
             $row =& JCKHelper::getTable('toolbar');
             // load the row from the db table
             $row->load($args[0]);
             //get toolbar parameter
             $params = new JParameter($row->params);
         }
     }
     $editor_params = new JParameter($editor->params);
     $toolbar = $params->get('toolbar', $row->name);
     $skins = $params->get('skin', $editor_params->def('skin', 'office2003'));
     $width = $params->get('wwidth', $editor_params->def('wwidth', '100%'));
     $editor_params->set('toolbar', $toolbar);
     $editor_params->set('skin', $skins);
     $editor_params->set('wwidth', $width);
     $editor_params->Set('hheight', 300);
     return $editor_params;
 }
Exemplo n.º 3
0
function addCustomSubMenus($controller, $type, $subMenus, $task = '', $action = 'Get')
{
    $canDo = JCKHelper::getActions();
    switch ($action) {
        case 'Post':
            JSubMenuHelper::addEntry(JText::_($controller), '#" onclick="javascript:document.adminForm.view.value=\'' . $controller . '\'; document.adminForm.task.value=\'\';Joomla.submitbutton(\'\');', !in_array($type, $subMenus));
            foreach ($subMenus as $name => $extension) {
                if ($name == 'Installer' && !$canDo->get('jckman.install')) {
                    continue;
                } elseif ($name == 'Restore Backup' && !$canDo->get('core.edit')) {
                    continue;
                } elseif ($name == 'Plugins' && !$canDo->get('jckman.uninstall')) {
                    continue;
                }
                JSubMenuHelper::addEntry(JText::_($name), '#" onclick="javascript:document.adminForm.view.value=\'' . $extension . '\';Joomla.submitbutton(\'' . $task . '\');', $extension == $type);
            }
            break;
        default:
            if ($type == '') {
                $type = $controller;
            }
            foreach ($subMenus as $name => $extension) {
                JSubMenuHelper::addEntry(JText::_($name), 'index.php?option=com_jckman&controller=' . $extension . '"', $extension == $type);
            }
    }
}
Exemplo n.º 4
0
 function _loadItems()
 {
     // Get a database connector
     $db = JFactory::getDBO();
     $sql = $db->getQuery(true);
     $sql->select('id, tag, filename')->from('#__jcklanguages')->order('id DESC');
     if ($search = $this->state->get('filter.string')) {
         $sql->where('title LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false));
     }
     $rows = $db->setQuery($sql)->loadObjectList();
     // Get the plugin base path
     $baseDir = JPATH_COMPONENT . '/language';
     $numRows = count($rows);
     for ($i = 0; $i < $numRows; $i++) {
         $row =& $rows[$i];
         // Get the plugin xml file
         $xmlfile = $baseDir . '/overrides/' . $row->filename;
         if (!file_exists($xmlfile)) {
             $xmlfile = $baseDir . '/' . $row->tag . '/' . $row->filename;
         }
         if (file_exists($xmlfile)) {
             if ($data = JCKHelper::parseXMLInstallFile($xmlfile)) {
                 foreach ($data as $key => $value) {
                     $row->{$key} = $value;
                 }
             }
         }
     }
     $this->setState('pagination.total', $numRows);
     if ($this->state->get('pagination.limit') > 0) {
         $this->_items = array_slice($rows, $this->state->get('pagination.offset'), $this->state->get('pagination.limit'));
     } else {
         $this->_items = $rows;
     }
 }
Exemplo n.º 5
0
 function display($tpl = null)
 {
     $canDo = JCKHelper::getActions();
     $app = JFactory::getApplication();
     if (!$canDo->get('jckman.install')) {
         $app->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_INSTALL'), 'error');
         return false;
     }
     //end if
     /*
      * Set toolbar items for the page
      */
     $bar =& JToolBar::getInstance('toolbar');
     // Add a Link button for Control Panel
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&controller=cpanel');
     JToolBarHelper::help('screen.installer');
     $paths = new stdClass();
     $paths->first = '';
     $lookup = array(JHTML::_('select.option', 0, JText::_('All')));
     $selections =& $this->get('ToolbarList');
     $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $lookup, 'selections');
     $this->assignRef('paths', $paths);
     $this->assignRef('state', $this->get('state'));
     $this->assignRef('lists', $lists);
     parent::display($tpl);
 }
Exemplo n.º 6
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     $canDo = JCKHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JCKMAN_SUBMENU_PLUGIN_NAME'), 'plugin.png');
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('list.edit');
     }
     //end if
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::publishList('list.publish');
         JToolBarHelper::unpublishList('list.unpublish');
         JToolbarHelper::checkin('list.checkin');
     }
     //end if
     // Add a Link button for Control Panel
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&view=cpanel');
     JToolBarHelper::help($this->app->input->get('view'), false, 'http://www.joomlackeditor.com/installation-guide?start=14#plugin_man_help');
     JCKHelper::addSubmenu($this->app->input->get('view'));
     JHtmlSidebar::setAction('index.php?option=com_jckman&view=list');
     // FILTERS
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JCKHelper::getStateOptions(), 'value', 'text', $this->state->get('filter.state')));
     JHtmlSidebar::addFilter(JText::_('- Select Core Type -'), 'filter_iscore', JHtml::_('select.options', array(JHtml::_('select.option', '1', 'Core Plugins'), JHtml::_('select.option', '0', 'Not Core Plugins')), 'value', 'text', $this->state->get('filter.iscore')));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 7
0
 function _loadItems()
 {
     // Get a database connector
     $db = JFactory::getDBO();
     $sql = $db->getQuery(true);
     $sql->select('id, title, type, name')->from('#__jckplugins')->where('type = "plugin"')->where('iscore = 0')->order('name');
     if ($search = $this->state->get('filter.string')) {
         $sql->where('title LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false));
     }
     $rows = $db->setQuery($sql)->loadObjectList();
     // Get the plugin base path
     $baseDir = JCK_PLUGINS;
     $numRows = count($rows);
     for ($i = 0; $i < $numRows; $i++) {
         $row =& $rows[$i];
         // Get the plugin xml file
         $xmlfile = $baseDir . DS . $row->name . DS . $row->name . ".xml";
         if (file_exists($xmlfile)) {
             if ($data = JCKHelper::parseXMLInstallFile($xmlfile)) {
                 foreach ($data as $key => $value) {
                     if ($value) {
                         $row->{$key} = $value;
                     }
                 }
             }
         }
     }
     $this->setState('pagination.total', $numRows);
     if ($this->state->get('pagination.limit') > 0) {
         $this->_items = array_slice($rows, $this->state->get('pagination.offset'), $this->state->get('pagination.limit'));
     } else {
         $this->_items = $rows;
     }
 }
Exemplo n.º 8
0
 /**
  * Load the editor
  *
  * @access	private
  * @param	array	Associative array of editor config paramaters
  * @since	1.5
  */
 function _loadEditor($config = array())
 {
     //check if editor is already loaded
     if (!is_null($this->_editor)) {
         return;
     }
     jimport('joomla.filesystem.file');
     // Build the path to the needed editor plugin
     $name = JFilterInput::clean($this->_name, 'cmd');
     $path = JPATH_SITE . DS . 'plugins' . DS . 'editors' . DS . $name . '.php';
     if (!JFile::exists($path)) {
         $message = JText::_('Cannot load the editor');
         JCKHelper::error($message);
         return false;
     }
     // Require plugin file
     require_once $path;
     // Build editor plugin classname
     $name = 'plgEditor' . $this->_name;
     if ($this->_editor = new $name($this, $config)) {
         // load plugin parameters
         $this->initialise();
         JPluginHelper::importPlugin('editors-xtd');
     }
 }
Exemplo n.º 9
0
 /**
  * constructor
  *
  * @access	protected
  * @param	string	The event handler
  */
 function __construct($eventHandlerName)
 {
     $eventListenerClassName = 'JCK' . JString::ucfirst($eventHandlerName) . 'ControllerListener';
     if (class_exists($eventListenerClassName)) {
         $this->_eventHandler = new $eventListenerClassName($this);
     } else {
         JCKHelper::error('No Event listener ' . $eventListenerClassName . ' class found.');
     }
 }
Exemplo n.º 10
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     JToolBarHelper::title(JText::_('JCK Manager'), 'cpanel.png');
     if ($this->canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_jckman');
     }
     JCKHelper::addSubmenu($this->app->input->get('view'));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 11
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     JToolBarHelper::title(JText::_('COM_JCKMAN_SUBMENU_INSTALL_NAME'), 'plugin.png');
     // Add a Link button for Control Panel
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&view=cpanel');
     JToolBarHelper::help($this->app->input->get('view'), false, 'http://www.joomlackeditor.com/installation-guide?start=16#installer_help');
     JCKHelper::addSubmenu($this->app->input->get('view'));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 12
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     JToolBarHelper::title(JText::_('COM_JCKMAN_SUBMENU_UNINSTALL_NAME'), 'plugin.png');
     if ($this->canDo->get('core.edit.state')) {
         JToolBarHelper::deleteList('', 'manage.remove', JText::_('JTOOLBAR_UNINSTALL'));
     }
     //end if
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&view=cpanel');
     JCKHelper::addSubmenu($this->app->input->get('view'));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 13
0
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     $canDo = JCKHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JCKMAN_SUBMENU_IMPORT_NAME'), 'plugin.png');
     if (!JCKHelper::isMobile() && !JCKHelper::isiPad()) {
         $bar->appendButton('Link', 'export', JText::_('JTOOLBAR_EXPORT'), 'index.php?option=com_jckman&task=cpanel.export');
     }
     $bar->appendButton('Link', 'cpanel', JText::_('COM_JCKMAN_SUBMENU_CPANEL_NAME'), 'index.php?option=com_jckman&view=cpanel');
     JToolBarHelper::help($this->app->input->get('view'), false, 'http://www.joomlackeditor.com/installation-guide?start=20#restore');
     JCKHelper::addSubmenu($this->app->input->get('view'));
     $this->sidebar = JHtmlSidebar::render();
 }
Exemplo n.º 14
0
 protected function getOptions()
 {
     $options = array();
     $items = JCKHelper::getEditorToolbars();
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             $options[] = JHtml::_('select.option', $item, $item);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 15
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('JoomlaCK Editor Manager'), 'cpanel.png');
     $canDo = JCKHelper::getActions();
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_jckman');
     }
     $lang = JFactory::getLanguage();
     $pane = JPane::getInstance('sliders');
     $icons = JCKModuleHelper::getModules('jck_icon');
     $modules = JCKModuleHelper::getModules('jck_cpanel');
     $this->assignRef('icons', $icons);
     $this->assignRef('pane', $pane);
     $this->assignRef('modules', $modules);
     parent::display($tpl);
 }
Exemplo n.º 16
0
 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)) {
         require_once $eventListenerFile;
         $this->editor_obervable = new JCKEditorObservable($name);
     } else {
         JCKHelper::error('No Event listener found for ' . $name . ' controller');
     }
     //load style sheet
     $document = JFactory::getDocument();
     $document->addStyleSheet(JCK_COMPONENT . '/css/header.css', 'text/css');
 }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 function display($tpl = null)
 {
     $canDo = JCKHelper::getActions();
     $app = JFactory::getApplication();
     if (!$canDo->get('jckman.uninstall')) {
         $app->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_INSTALL'), 'error');
         return false;
     }
     //end
     /*
      * Set toolbar items for the page
      */
     $bar =& JToolBar::getInstance('toolbar');
     // Add a Link button for Control Panel
     $bar->appendButton('Link', 'cpanel', 'Control Panel', 'index.php?option=com_jckman&controller=cpanel');
     JToolBarHelper::deleteList('', 'remove', 'Uninstall');
     $lookup = array(JHTML::_('select.option', 0, JText::_('All')));
     // Get data from the model
     $items =& $this->get('Items');
     $pagination =& $this->get('Pagination');
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Exemplo n.º 19
0
 /**
  * Tries to find the package manifest file
  *
  * @return  boolean  True on success, False on error
  *
  * @since 11.1
  */
 public function findManifest()
 {
     // Get an array of all the XML files from the installation directory
     $xmlfiles = JFolder::files($this->getPath('source'), '.xml$', 1, true);
     // If at least one XML file exists
     if (!empty($xmlfiles)) {
         foreach ($xmlfiles as $file) {
             // Is it a valid Joomla installation manifest file?
             $manifest = $this->isManifest($file);
             if (!is_null($manifest)) {
                 // If the root method attribute is set to upgrade, allow file overwrite
                 if ((string) $manifest->attributes()->method == 'upgrade') {
                     $this->upgrade = true;
                     $this->overwrite = true;
                 }
                 // If the overwrite option is set, allow file overwriting
                 if ((string) $manifest->attributes()->overwrite == 'true') {
                     $this->overwrite = true;
                 }
                 // Set the manifest object and path
                 $this->manifest = $manifest;
                 $this->setPath('manifest', $file);
                 // Set the installation source path to that of the manifest file
                 $this->setPath('source', dirname($file));
                 return true;
             }
         }
         // None of the XML files found were valid install files
         JCKHelper::error(JText::_('JLIB_INSTALLER_ERROR_NOTFINDJOOMLAXMLSETUPFILE'));
         return false;
     } else {
         // No XML files were found in the install folder
         JCKHelper::error(JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'));
         return false;
     }
 }
Exemplo n.º 20
0
 function __construct($default = array())
 {
     parent::__construct($default);
     $this->canDo = JCKHelper::getActions();
 }
Exemplo n.º 21
0
 function prepareForm(&$item)
 {
     if ($item->iscore) {
         @($data = file_get_contents(JPATH_COMPONENT . DS . 'editor' . DS . 'plugins' . DS . $item->name . '.xml'));
     } else {
         @($data = file_get_contents(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $item->name . DS . $item->name . '.xml'));
     }
     if ($data) {
         $data = preg_replace(array('/\\<params group="options">/i', '/\\<params>/i', '/\\<params(.*)\\<\\/params\\>/is'), array('<params name="advanced">', '<params name="basic">', '<config><fields name="params"><fieldset$1</fieldset></fields></config>'), $data);
         $data = str_replace(array('<install', '</install', '<params', '</params', '<param', '</param'), array('<form', '</form', '<fieldset', '</fieldset', '<field', '</field'), $data);
         // Re-style fields to J3.0
         // Can't just str_replace because fields might already have a class
         $xml = JCKHelper::getXML($data, false);
         $nodes = $xml->xpath('//field[@type="radio" or @type="resizeradio"]');
         foreach ($nodes as $node) {
             $radio = 'btn-group';
             $class = (string) $node->attributes()->class ? (string) $node->attributes()->class . chr(32) . $radio : $radio;
             if ($node->attributes()->class) {
                 $node->attributes()->class = $class;
             } else {
                 $node->addAttribute('class', $class);
             }
         }
         $data = $xml->asXML();
     } else {
         $data = '<install><form>dummy data</form></install>';
     }
     //end if
     JCKForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
     $form = JCKForm::getInstance('com_jckman.plugin', $data, array(), true, '//config');
     //$model 	= $this->getModel();
     //$form 	= $model->getPluginForm($data);
     //load plugins language file
     $lang = JFactory::getLanguage();
     $lang->load('com_plugins', JPATH_ADMINISTRATOR, null, false, false);
     JPluginHelper::importPlugin('content');
     $dispatcher = JDispatcher::getInstance();
     // Trigger the form preparation event.
     $jpara = new JRegistry($item->params);
     $data = $jpara->toArray();
     $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
     $form->bind($data);
     return $form;
 }
Exemplo n.º 22
0
 function update($parent)
 {
     $this->install($parent);
     $db = JFactory::getDBO();
     if (method_exists($parent, 'extension_root')) {
         $sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.sql';
     } else {
         $sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.sql';
     }
     // Don't modify below this line
     $buffer = file_get_contents($sqlfile);
     if ($buffer !== false) {
         jimport('joomla.installer.helper');
         $queries = JInstallerHelper::splitSql($buffer);
         if (count($queries) != 0) {
             foreach ($queries as $query) {
                 $query = trim($query);
                 if ($query != '' && $query[0] != '#') {
                     $db->setQuery($query);
                     if (!$db->query()) {
                         if (!class_exists('JCKHelper')) {
                             require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helper.php';
                         }
                         JCKHelper::error(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
                         return false;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
?>
	});
</script>
<form action="<?php 
echo JRoute::_('index.php?option=com_jckman&task=list.edit&cid=' . (int) $this->item->id);
?>
" method="post" name="adminForm" id="style-form" class="form-validate form-horizontal">
<?php 
if (!empty($this->sidebar)) {
    ?>
	<div id="sidebar-container" class="span2">
		<?php 
    echo $this->sidebar;
    ?>
		<?php 
    JCKHelper::fixBug();
    ?>
	</div>
	<div id="main-container" class="span10">
<?php 
} else {
    ?>
	<div id="main-container">
<?php 
}
?>
		<fieldset class="adminform">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#details" data-toggle="tab"><?php 
echo JText::_('JDETAILS');
?>
Exemplo n.º 24
0
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $canDo = JCKHelper::getActions();
     if (!$canDo->get('core.edit')) {
         $mainframe->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error');
         return false;
     }
     //end if
     JToolBarHelper::title(JText::_('JCK Plugin') . ': <small><small>[' . JText::_('Edit') . ']</small></small>', 'plugin.png');
     JToolBarHelper::save('save');
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancelEdit', 'Close');
     JToolBarHelper::help('screen.plugins.edit');
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $lists = array();
     $user = JFactory::getUser();
     $row = JCKHelper::getTable('plugin');
     // load the row from the db table
     $row->load($cid[0]);
     // Hide CK's plugin
     if (!$row || in_array($row->name, JCKHelper::getHiddenPlugins())) {
         $mainframe->redirect('index.php?option=com_jckman&view=list', 'Could Not Load Plugin.', 'error');
         return false;
     }
     // fail if checked out not by 'me'
     if ($row->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The plugin'), $row->title ? $row->title : $row->name);
         $this->setRedirect('index.php?option=' . $option . '&controller=list', $msg, 'error');
         return false;
     }
     $xmlPath = '';
     if ($row->iscore) {
         $path = JPATH_COMPONENT . DS . 'editor' . DS . plugins;
         $xmlPath = $path . DS . $row->name . '.xml';
     } else {
         $path = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $row->name;
         $xmlPath = $path . DS . $row->name . '.xml';
     }
     //AW
     if ($cid[0]) {
         $row->checkout($user->get('id'));
         if (JFile::exists($xmlPath)) {
             $data = JApplicationHelper::parseXMLInstallFile($xmlPath);
             $row->description = $data['description'];
         } else {
             $row->description = '';
         }
     } else {
         $row->type = 'plugin';
         $row->published = 1;
         $row->description = 'From XML install file';
         $row->icon = '';
         $row->params = '';
         $ordering = array();
     }
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
     // get toolbar selections
     //get Model
     $listModel = JModel::getInstance('list', 'ListModel');
     $installModel = JModel::getInstance('install', 'InstallerModel');
     $lookup = $listModel->getSelectedToolbarList();
     $selections = $installModel->getToolbarList();
     $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $lookup, 'selections');
     if (empty($lookup)) {
         $lookup = array(JHTML::_('select.option', '0'));
         $row->pages = 'none';
     } elseif (count($lookup) == count($selections)) {
         $row->pages = 'all';
     } else {
         $row->pages = NULL;
     }
     $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $lookup, 'selections');
     //ACL stuff
     $groups = $listModel->getUserGroupList();
     $allowedGroups = array();
     if (is_null($row->acl)) {
         //not set so everyone can see
         $allowedGroups = $groups;
     } else {
         $allowedGroups = json_decode($row->acl);
     }
     if (empty($allowedGroups)) {
         $allowedGroups = array(JHTML::_('select.option', '0'));
         $row->groups = 'special';
     } elseif (count($allowedGroups) == count($groups)) {
         $row->groups = 'all';
     } else {
         $row->groups = NULL;
     }
     $lists['groups'] = JHTML::_('select.genericlist', $groups, 'groups[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $allowedGroups, 'groups');
     $params = $this->prepareForm($row);
     $this->assignRef('lists', $lists);
     $this->assignRef('plugin', $row);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Exemplo n.º 25
0
 function checkin()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $canDo = JCKHelper::getActions();
     if (!$canDo->get('core.edit.state')) {
         $this->setRedirect(JRoute::_('index.php?option=com_jckman&view=toolbars', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_CHECK'), 'error');
         return false;
     }
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $cid = $app->input->get('cid', array(0), 'array');
     $sql = $db->getQuery(true);
     JArrayHelper::toInteger($cid, array(0));
     if (count($cid) < 1) {
         JError::raiseWarning(101, JText::_('Select a toolbar to checkin'));
     }
     $cids = implode(',', $cid);
     $sql->update('#__jcktoolbars')->set(array('checked_out = 0', 'checked_out_time = "0000-00-00 00:00:00"'))->where('id IN ( ' . $cids . ' )')->where('checked_out = ' . (int) $user->get('id'));
     $db->setQuery($sql);
     if (!$db->query()) {
         JError::raiseError(500, $db->getErrorMsg());
     }
     $this->event_args = array('cid' => $cid, 'value' => true);
     $plural = count($cid) > 1 ? '(s)' : '';
     $msg = (int) count($cid) . chr(32) . 'plugin' . $toolbar . ' checked in';
     $this->setRedirect(JRoute::_('index.php?option=com_jckman&view=' . $app->input->get('view', 'toolbars'), false), $msg);
 }
Exemplo n.º 26
0
 /**
  * Install an extension from a directory
  *
  * @static
  * @return boolean True on success
  * @since 1.0
  */
 protected function _getPackageFromFolder()
 {
     // Get the path to the package to install
     $p_dir = JRequest::getString('install_directory');
     $p_dir = JPath::clean($p_dir);
     // Did you give us a valid directory?
     if (!is_dir($p_dir)) {
         JCKHelper::error(JText::_('COM_INSTALLER_MSG_INSTALL_PLEASE_ENTER_A_PACKAGE_DIRECTORY'));
         return false;
     }
     // Detect the package type
     $type = JInstallerHelper::detectType($p_dir);
     // Did you give us a valid package?
     if (!$type) {
         JCKHelper::error(JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'));
         return false;
     }
     $package['packagefile'] = null;
     $package['extractdir'] = null;
     $package['dir'] = $p_dir;
     $package['type'] = $type;
     return $package;
 }
Exemplo n.º 27
0
 function _createEditorToolbar($id, $name, $oldname)
 {
     require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
     $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
     $newfilename = $CKfolder . DS . $name . '.php';
     $oldfilename = $CKfolder . DS . $oldname . '.php';
     $classname = 'JCK' . ucfirst($name);
     $toolbar = new stdclass();
     $toolbarConfig = new JRegistry('toolbar');
     $db = JFactory::getDBO();
     $query = 'SELECT tp.pluginid AS id,p.title,tp.row' . ' FROM #__jcktoolbarplugins tp' . ' LEFT JOIN #__jckplugins p ON p.id = tp.pluginid' . ' WHERE tp.state = 1' . ' AND tp.toolbarid = ' . $id . ' ORDER BY tp.row ASC,tp.ordering ASC';
     $db->setQuery($query);
     $toolbarplugins = $db->loadObjectList();
     if ($toolbarplugins) {
         foreach ($toolbarplugins as $plugin) {
             if ($plugin->id < 0) {
                 $property = 'brk_' . $plugin->id * -1;
                 $toolbar->{$property} = $plugin->row;
             } else {
                 $property = $plugin->title;
                 $toolbar->{$property} = $plugin->row;
             }
         }
     }
     $toolbarConfig->loadObject($toolbar);
     // Get the config registry in PHP class format and write it to file
     $buffer = $toolbarConfig->toString('PHP', array('class' => $classname . ' extends JCKToolbar'));
     if (!JFile::write($oldfilename, $buffer)) {
         JCKHelper::error(JText::sprintf('COM_JCKMAN_LAYOUT_MANAGER_FAILED_WRITE_FILE', $classname));
     }
     if ($newfilename != $oldfilename) {
         if (!JFile::move($oldfilename, $newfilename)) {
             JCKHelper::error(JText::sprintf('COM_JCKMAN_LAYOUT_MANAGER_FAILED_WRITE_FILE', $classname));
         }
     }
 }
Exemplo n.º 28
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $values = array();
     $this->_texts = array();
     if (empty($this->value)) {
         foreach ($this->element->children() as $option) {
             // Only add <option /> elements.
             if ($option->getName() != 'option') {
                 continue;
             }
             // Create a new option object based on the <option /> element.
             $tmp = JHtml::_('select.option', (string) $option, (string) $option, 'value', 'text', false);
             // Add the option object to the result set.
             $this->_texts[] = $tmp;
             $tmp = JHtml::_('select.option', (string) $option['value'], (string) $option['value'], 'value', 'text', false);
             // Add the option object to the result set.
             $values[] = $tmp;
         }
     } else {
         $name = (string) $this->element['name'];
         $plugin = JCKHelper::getTable('plugin');
         $cid = JRequest::getVar('cid', array(0));
         $plugin->load($cid[0]);
         $registry = new JRegistry($plugin->params);
         $texts = $registry->get($name . '_text');
         foreach ($this->value as $key => $value) {
             //lets split option into array of  text and value
             $text = $texts[$key];
             if (!$text) {
                 $text = $value;
             }
             $tmp = JHTML::_('select.option', $text, $text, 'value', 'text', false);
             // Add the option object to the result set.
             $this->_texts[] = $tmp;
             $tmp = JHTML::_('select.option', $value, $value, 'value', 'text', false);
             // Add the option object to the result set.
             $values[] = $tmp;
         }
     }
     reset($this->_texts);
     reset($values);
     return $values;
 }
Exemplo n.º 29
0
 /**
  * Remove (uninstall) an extension
  *
  * @param	array	An array of identifiers
  * @return	boolean	True on success
  * @since	1.5
  */
 function remove($eid = array())
 {
     // Initialise variables.
     $user = JFactory::getUser();
     if ($user->authorise('core.delete', 'com_installer')) {
         // Initialise variables.
         $failed = array();
         /*
          * Ensure eid is an array of extension ids in the form id => client_id
          * TODO: If it isn't an array do we want to set an error and fail?
          */
         if (!is_array($eid)) {
             $eid = array($eid => 0);
         }
         // Get a database connector
         $db = JFactory::getDBO();
         // Get an installer object for the extension type
         jimport('joomla.installer.installer');
         $installer = JInstaller::getInstance();
         $row = JTable::getInstance('extension');
         // Uninstall the chosen extensions
         foreach ($eid as $id) {
             $id = trim($id);
             $row->load($id);
             if ($row->type) {
                 $result = $installer->uninstall($row->type, $id);
                 // Build an array of extensions that failed to uninstall
                 if ($result === false) {
                     $failed[] = $id;
                 }
             } else {
                 $failed[] = $id;
             }
         }
         $langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type);
         $rowtype = JText::_($langstring);
         if (strpos($rowtype, $langstring) !== false) {
             $rowtype = $row->type;
         }
         if (count($failed)) {
             // There was an error in uninstalling the package
             $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype);
             $result = false;
         } else {
             // Package uninstalled sucessfully
             $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype);
             $result = true;
         }
         $app = JFactory::getApplication();
         $app->enqueueMessage($msg);
         $this->setState('action', 'remove');
         $this->setState('name', $installer->get('name'));
         $app->setUserState('com_installer.message', $installer->message);
         $app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
         return $result;
     } else {
         $result = false;
         JCKHelper::error(JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
     }
 }
Exemplo n.º 30
0
 function beforeLoad(&$params)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     if ($user->authorise('core.admin')) {
         return;
     }
     $query = 'SELECT id,name,acl,parentid FROM #__jckplugins WHERE published = 1';
     $db->setQuery($query);
     $plugins = $db->loadObjectList();
     if (!is_array($plugins)) {
         JCKHelper::error($db->getErrorMsg());
     }
     if (empty($plugins)) {
         return;
     }
     $groups = $user->getAuthorisedGroups();
     $js = '';
     $deniedPlugins = array();
     $removePlugins = array();
     foreach ($plugins as $plugin) {
         if (is_null($plugin->acl)) {
             continue;
         }
         $acl = json_decode($plugin->acl);
         $allow = true;
         if (empty($acl)) {
             $allow = false;
             $deniedPlugins[] = $plugin->id;
             $removePlugins[] = $plugin->name;
         } else {
             if ($groups) {
                 $allow = false;
                 for ($n = 0, $i = count($groups); $n < $i; $n++) {
                     if (in_array($groups[$n], $acl)) {
                         $allow = true;
                         break;
                     }
                     //end if
                 }
                 //end for loop
                 if (!$allow) {
                     $deniedPlugins[] = $plugin->id;
                     $removePlugins[] = $plugin->name;
                 }
             }
             //end if
             // check to see if parent plugin access view level is denied. If is then parent settings override
             if ($allow && in_array($plugin->parentid, $deniedPlugins)) {
                 $deniedPlugins[] = $plugin->id;
                 $removePlugins[] = $plugin->name;
             }
         }
     }
     //var_dump($removePlugins);
     if (empty($removePlugins)) {
         return;
     }
     //lets create JS object
     $javascript = new JCKJavascript();
     $plugs = implode(',', $removePlugins);
     $javascript->addScriptDeclaration("editor.on( 'configLoaded', function()\r\n\t\t\t{\r\n\t\t\t\tif(editor.config.removePlugins) \r\n\t\t\t\t\teditor.config.removePlugins += '," . $plugs . "';\r\n\t\t\t\telse \t\r\n\t\t\t\t\teditor.config.removePlugins += '" . $plugs . "';\r\n\t\t\t});");
     return $javascript->toRaw();
 }