function display($tpl = null) { $language = JFactory::getLanguage(); $language->load('plg_editors_jce', JPATH_ADMINISTRATOR); $client = JRequest::getWord('client', 'site'); $model = $this->getModel(); $plugin = WFExtensionHelper::getPlugin(); $xml = WF_EDITOR_LIBRARIES . '/xml/config/editor.xml'; $data = null; // get params from editor plugin if ($plugin->params && $plugin->params !== "{}") { $data = json_decode($plugin->params); } else { $component = WFExtensionHelper::getComponent(); // get params from component "params" field (legacy) if ($component->params) { $data = json_decode($component->params); } } // get params definitions $params = new WFParameter($data, $xml, 'editor'); $params->addElementPath(JPATH_COMPONENT . '/elements'); $this->assign('model', $model); $this->assign('params', $params); $this->assign('client', $client); WFToolbarHelper::apply(); WFToolbarHelper::save(); WFToolbarHelper::help('config.about'); parent::display($tpl); }
function display($tpl = null) { $db = JFactory::getDBO(); $client = JRequest::getWord('client', 'admin'); $model = $this->getModel(); $this->document->setTitle(WFText::_('WF_PREFERENCES_TITLE')); $this->document->addStyleSheet('templates/system/css/system.css'); $component = WFExtensionHelper::getComponent(); $xml = JPATH_COMPONENT . '/models/preferences.xml'; // get params definitions $params = new WFParameter($component->params, $xml, 'preferences'); $params->addElementPath(JPATH_COMPONENT . '/elements'); if (WFModel::authorize('admin')) { $form = $model->getForm('permissions'); } else { $form = null; } $this->assign('params', $params); $this->assign('permissons', $form); $this->addStyleSheet('components/com_jce/media/css/preferences.css'); $this->addScript('components/com_jce/media/js/preferences.js'); if (JRequest::getInt('close') == 1) { $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.close();});'); } else { $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.init();});'); } parent::display($tpl); }
function getStyles() { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); wfimport('admin.helpers.extension'); $view = JRequest::getCmd('view', 'cpanel'); $component = WFExtensionHelper::getComponent(); $params = new WFParameter($component->params); $theme = $params->get('preferences.theme', 'jce'); $site_path = JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'libraries' . DS . 'css'; $admin_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'media' . DS . 'css'; // Load styles $styles = array(); if (!JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) { $theme = 'jce'; } if (JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) { $files = JFolder::files($site_path . DS . 'jquery' . DS . $theme, '\\.css'); foreach ($files as $file) { $styles[] = 'components/com_jce/editor/libraries/css/jquery/' . $theme . '/' . $file; } } // admin global css $styles = array_merge($styles, array('administrator/components/com_jce/media/css/global.css')); if (JFile::exists($admin_path . DS . $view . '.css')) { $styles[] = 'administrator/components/com_jce/media/css/' . $view . '.css'; } return $styles; }
function display($tpl = null) { wfimport('admin.models.updates'); $mainframe = JFactory::getApplication(); $model = $this->getModel(); $installer = WFInstaller::getInstance(); $version = $model->getVersion(); // Check Groups DB if (!$installer->profiles) { $link = JHTML::link('index.php?option=com_jce&task=repair&table=profiles', WFText::_('WF_DB_CREATE_RESTORE')); $mainframe->enqueueMessage(WFText::_('WF_DB_PROFILES_ERROR') . ' - ' . $link, 'error'); } $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); $canUpdate = WFModelUpdates::canUpdate(); $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE'))); $this->document->addScript('components/com_jce/media/js/cpanel.js?version=' . $model->getVersion()); $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.CPanel.init(' . json_encode($options) . ')});'); WFToolbarHelper::preferences(); WFToolbarHelper::updates($canUpdate); WFToolbarHelper::help('cpanel.about'); $this->assignRef('icons', $icons); $this->assignRef('model', $model); $this->assignRef('installer', $installer); $this->assignRef('params', $params); $this->assignRef('version', $version); parent::display($tpl); }
/** * Check for extension updates * @return String JSON string of updates */ public function check() { $result = false; // Get all extensions and version numbers $data = array('task' => 'check', 'jversion' => WF_JOOMLA15 ? '1.5' : '2.5'); wfimport('admin.helpers.extension'); $component = WFExtensionHelper::getComponent(); $params = new WFParameter($component->params, '', 'preferences'); // get update key $key = $params->get('updates_key', ''); $type = $params->get('updates_type', ''); // encode it if (!empty($key)) { $data['key'] = urlencode($key); } if ($type) { $data['type'] = $type; } $req = array(); // create request data foreach ($this->getVersions() as $type => $extension) { foreach ($extension as $item => $value) { $data[$type . '[' . urlencode($item) . ']'] = urlencode($value); } } foreach ($data as $key => $value) { $req[] = $key . '=' . urlencode($value); } // connect $result = $this->connect(self::$updateURL, implode('&', $req)); return $result; }
function display($tpl = null) { wfimport('admin.models.updates'); $mainframe = JFactory::getApplication(); $model = $this->getModel(); $version = $model->getVersion(); $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); $canUpdate = WFModelUpdates::canUpdate() && $model->authorize('installer'); $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE'))); $this->document->addScript('components/com_jce/media/js/cpanel.js?version=' . $model->getVersion()); $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.CPanel.init(' . json_encode($options) . ')});'); if ($model->authorize('preferences')) { WFToolbarHelper::preferences(); } if ($model->authorize('installer')) { WFToolbarHelper::updates($canUpdate); } WFToolbarHelper::help('cpanel.about'); $this->assignRef('icons', $icons); $this->assignRef('model', $model); $this->assignRef('installer', $installer); $this->assignRef('params', $params); $this->assignRef('version', $version); parent::display($tpl); }
function getParams($data) { jimport('joomla.form.form'); if (class_exists('JForm')) { //JForm::addFormPath(JPATH_PLUGINS . '/system/jcemediabox'); $xml = JPATH_PLUGINS . '/system/jcemediabox/jcemediabox.xml'; $params = new WFParameter($data, $xml, '', array('control' => 'config:fields:fieldset')); $params->addElementPath(JPATH_PLUGINS . '/system/jcemediabox/elements'); $groups = array(); $array = array(); foreach ($params->getGroups() as $group) { $groups[] = $params->getParams('params', $group); } foreach ($groups as $group) { $array = array_merge($array, $group); } return $array; } else { // get params definitions $params = new JParameter($data, JPATH_PLUGINS . '/system/jcemediabox.xml'); $xml = JPATH_PLUGINS . '/system/jcemediabox.xml'; $params->loadSetupFile($xml); return $params->getParams(); } }
function display($tpl = null) { wfimport('admin.models.updates'); $mainframe = JFactory::getApplication(); $model = $this->getModel(); $version = $model->getVersion(); $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); $canUpdate = WFModelUpdates::canUpdate() && WFModel::authorize('installer'); $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE'))); JHtml::_('behavior.modal'); $this->addScript('components/com_jce/media/js/cpanel.js'); $this->addScriptDeclaration('jQuery.jce.Cpanel.options = ' . json_encode($options) . ';'); // load styles $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/cpanel.css'); if (WFModel::authorize('preferences')) { WFToolbarHelper::preferences(); } if (WFModel::authorize('installer')) { WFToolbarHelper::updates($canUpdate); } WFToolbarHelper::help('cpanel.about'); $views = array('config', 'profiles', 'installer', 'browser', 'mediabox'); $icons = array(); foreach ($views as $view) { // check if its allowed... if (WFModel::authorize($view) === false) { continue; } $attribs = array('target="_self"'); $title = 'WF_' . strtoupper($view); $description = 'WF_' . strtoupper($view) . '_DESC'; $link = 'index.php?option=com_jce&view=' . $view; if ($view == 'browser') { $link = WFModel::getBrowserLink(); $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); $width = (int) $params->get('browser_width', 790); $height = (int) $params->get('browser_height', 560); if (empty($link)) { continue; } $attribs = array('target="_blank"', 'class="browser"', 'onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;"'); $title = 'WF_' . strtoupper($view) . '_TITLE'; $description = 'WF_CPANEL_' . strtoupper($view); } // if its mediabox, check the plugin is installed and enabled if ($view == 'mediabox' && !JPluginHelper::isEnabled('system', 'jcemediabox')) { continue; } $icons[] = '<li class="cpanel-icon wf-tooltip" title="' . WFText::_($title) . '::' . WFText::_($description) . '"><a id="wf-browser-link" href="' . $link . '"' . implode(' ', $attribs) . '><span class="' . $view . '"></span>' . WFText::_($title) . '</a></li>'; } $this->assign('icons', $icons); $this->assign('model', $model); $this->assign('params', $params); $this->assign('version', $version); parent::display($tpl); }
function fetchElement($name, $value, &$node, $control_name) { $attributes = array(); foreach ($node->attributes() as $k => $v) { if ($v != '') { $attributes[$k] = (string) $v; } } /* * Required to avoid a cycle of encoding & * html_entity_decode was used in place of htmlspecialchars_decode because * htmlspecialchars_decode is not compatible with PHP 4 */ $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES); $attributes['class'] = (string) $node->attributes()->class ? (string) $node->attributes()->class . ' text_area' : 'text_area'; $control = $control_name . '[' . $name . ']'; $html = ''; $attributes['value'] = $value; $attributes['type'] = 'text'; $attributes['name'] = $control; $attributes['id'] = preg_replace('#[^a-z0-9_-]#i', '', $control_name . $name); // pattern data attribute for editable select input box if ((string) $node->attributes()->parent) { $prefix = preg_replace(array('#^params#', '#([^\\w]+)#'), '', $control_name); $items = array(); foreach (explode(';', (string) $node->attributes()->parent) as $item) { $items[] = $prefix . $item; } $attributes['data-parent'] = implode(';', $items); } $filter = isset($attributes['data-filter']) ? $attributes['data-filter'] : ''; $html .= '<input'; foreach ($attributes as $k => $v) { if (!in_array($k, array('default', 'label', 'description'))) { $html .= ' ' . $k . ' = "' . $v . '"'; } } $html .= ' />'; $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); $width = (int) $params->get('browser_width', 780); $height = (int) $params->get('browser_height', 560); wfimport('admin.models.model'); $model = new WFModel(); $link = $model->getBrowserLink($attributes['id'], $filter); $html .= '<a href="' . $link . '" id="' . $attributes['id'] . '_browser' . '" class="browser" target="_blank" onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;" title="' . WFText::_('WF_BROWSER_TITLE') . '"><span class="browser"></span></a>'; return $html; }
function display($tpl = null) { $model = $this->getModel(); $language = $model->getLanguage(); $lang = JFactory::getLanguage(); $section = JRequest::getWord('section'); $category = JRequest::getWord('category'); $article = JRequest::getWord('article'); $component = JComponentHelper::getComponent('com_jce'); require_once WF_ADMINISTRATOR . DS . 'classes' . DS . 'parameter.php'; $params = new WFParameter($component->params); $url = $params->get('preferences.help.url', 'http://www.joomlacontenteditor.net'); $method = $params->get('preferences.help.method', 'reference'); $pattern = $params->get('preferences.help.pattern', ''); switch ($method) { default: case 'reference': $url .= '/index.php?option=com_content&view=article&tmpl=component&print=1&mode=inline&task=findkey&lang=' . $language . '&keyref='; break; case 'xml': break; case 'sef': break; } $this->assignRef('model', $model); $this->assign('orientation', $lang->isRTL() ? 'east' : 'west'); $key = array(); if ($section) { $key[] = $section; if ($category) { $key[] = $category; if ($article) { $key[] = $article; } } } $options = array('url' => $url, 'key' => $key, 'pattern' => $pattern); $this->document->addStyleSheet(JURI::root(true) . '/components/com_jce/editor/libraries/css/help.css'); $this->document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/jquery/jquery-ui-layout.js?version=' . $model->getVersion()); $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Help.init(' . json_encode($options) . ');});'); parent::display($tpl); }
function display($tpl = null) { $db = JFactory::getDBO(); $language = JFactory::getLanguage(); $language->load('plg_editors_jce', JPATH_ADMINISTRATOR); $client = JRequest::getWord('client', 'site'); $model = $this->getModel(); $lists = array(); $component = WFExtensionHelper::getComponent(); $xml = WF_EDITOR_LIBRARIES . DS . 'xml' . DS . 'config' . DS . 'editor.xml'; // get params definitions $params = new WFParameter($component->params, $xml, 'editor'); $params->addElementPath(JPATH_COMPONENT . DS . 'elements'); $this->assignRef('model', $model); $this->assignRef('params', $params); $this->assignRef('client', $client); WFToolbarHelper::save(); WFToolbarHelper::apply(); WFToolbarHelper::help('config.about'); parent::display($tpl); }
/** * Get editor parameters * @access public * @param array $options * @return object */ public function getParams($options = array()) { if (!isset(self::$params)) { self::$params = array(); } // set blank key if not set if (!isset($options['key'])) { $options['key'] = ''; } // set blank path if not set if (!isset($options['path'])) { $options['path'] = ''; } $plugin = JRequest::getCmd('plugin'); if ($plugin) { $options['plugin'] = $plugin; } $signature = serialize($options); if (empty(self::$params[$signature])) { wfimport('admin.helpers.extension'); // get plugin $editor_plugin = WFExtensionHelper::getPlugin(); // get params data for this profile $profile = $this->getProfile($plugin); $profile_params = array(); $editor_params = array(); // get params from editor plugin if ($editor_plugin->params && $editor_plugin->params !== "{}") { $editor_params['editor'] = json_decode($editor_plugin->params, true); } else { // get component $component = WFExtensionHelper::getComponent(); // get params from component "params" field (legacy) if ($component->params && $component->params !== "{}") { $data = json_decode($component->params, true); if (isset($data['editor'])) { $editor_params['editor'] = $data['editor']; } } } if ($profile) { $profile_params = json_decode($profile->params, true); } // make sure we have an empty array if null or false if (empty($editor_params)) { $editor_params = array(); } // make sure we have an empty array if null or false if (empty($profile_params)) { $profile_params = array(); } // merge data and convert to json string $data = WFParameter::mergeParams($editor_params, $profile_params, true, false); self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']); } return self::$params[$signature]; }
protected function getStyles() { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); wfimport('admin.helpers.extension'); $view = JRequest::getCmd('view', 'cpanel'); $component = WFExtensionHelper::getComponent(); $params = new WFParameter($component->params); $theme = $params->get('preferences.theme', 'jce'); $site_path = JPATH_SITE . '/component/com_jce/editor/libraries/css'; // Load styles $styles = array(); if (!JFolder::exists($site_path . '/jquery/' . $theme)) { $theme = 'jce'; } // admin global css $styles = array_merge($styles, array('administrator/components/com_jce/media/css/global.css')); return $styles; }
function display($tpl = null) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $acl = JFactory::getACL(); $client = 'admin'; $view = JRequest::getWord('view'); $task = JRequest::getWord('task'); $option = JRequest::getWord('option'); $lists = array(); $model = $this->getModel(); switch ($task) { default: case 'publish': case 'unpublish': case 'remove': case 'save': case 'copy': $filter_order = $app->getUserStateFromRequest("{$option}.{$view}.filter_order", 'filter_order', 'p.ordering', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest("{$option}.{$view}.filter_order_Dir", 'filter_order_Dir', '', 'word'); $filter_state = $app->getUserStateFromRequest("{$option}.{$view}.filter_state", 'filter_state', '', 'word'); $search = $app->getUserStateFromRequest("{$option}.{$view}.search", 'search', '', 'string'); $search = JString::strtolower($search); $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limitstart = $app->getUserStateFromRequest("{$option}.{$view}.limitstart", 'limitstart', 0, 'int'); $where = array(); if ($search) { $where[] = 'LOWER( p.name ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); } if ($filter_state) { if ($filter_state == 'P') { $where[] = 'p.published = 1'; } else { if ($filter_state == 'U') { $where[] = 'p.published = 0'; } } } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; // get the total number of records $query = 'SELECT COUNT(p.id)' . ' FROM #__wf_profiles AS p' . $where; $db->setQuery($query); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); $query = 'SELECT p.*, u.name AS editor' . ' FROM #__wf_profiles AS p' . ' LEFT JOIN #__users AS u ON u.id = p.checked_out' . $where . ' GROUP BY p.id' . $orderby; $db->setQuery($query, $pagination->limitstart, $pagination->limit); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; $this->assignRef('user', JFactory::getUser()); $this->assignRef('lists', $lists); $this->assignRef('rows', $rows); $this->assignRef('pagination', $pagination); //JToolBarHelper::title(WFText::_('WF_PROFILES_TITLE').' : '.WFText::_('WF_PROFILES_LIST'), 'profiles.png' ); WFToolbarHelper::editListX(); WFToolbarHelper::addNewX(); WFToolbarHelper::custom('copy', 'copy.png', 'copy_f2.png', WFText::_('WF_PROFILES_COPY'), true); WFToolbarHelper::export(); if (count($rows) > 1) { WFToolbarHelper::publishList(); WFToolbarHelper::unpublishList(); WFToolbarHelper::deleteList(); } WFToolbarHelper::help('profiles.about'); $options = array('button' => 'upload_button', 'task' => 'import', 'labels' => array('browse' => WFText::_('WF_LABEL_BROWSE'), 'alert' => WFText::_('WF_PROFILES_IMPORT_BROWSE_ERROR'))); $this->document->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/uploads.js?version=' . $model->getVersion()); $this->document->addScriptDeclaration('jQuery(document).ready(function($){$(":file").upload(' . json_encode($options) . ')});'); $this->setLayout('default'); break; case 'apply': case 'add': case 'edit': // Load media $scripts = array('profiles.js', 'extensions.js', 'checklist.js', 'parameter.js'); // Load scripts foreach ($scripts as $script) { $this->document->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/' . $script . '?version=' . $model->getVersion()); } $this->document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/colorpicker.js?version=' . $model->getVersion()); $this->document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/select.js?version=' . $model->getVersion()); $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); $lists = array(); $row = JTable::getInstance('profiles', 'WFTable'); // load the row from the db table $row->load($cid[0]); // fail if checked out not by 'me' if ($row->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('WF_PROFILES_CHECKED_OUT', $row->name); $this->setRedirect('index.php?option=' . $option . '&view=profiles', $msg, 'error'); return false; } // Load editor params $component = JComponentHelper::getComponent('com_jce'); // Load Language $language = JFactory::getLanguage(); $language->load('com_jce', JPATH_SITE); $language->load('plg_editors_jce', JPATH_ADMINISTRATOR); $plugins = $model->getPlugins(); // load the row from the db table if ($cid[0]) { $row->checkout($user->get('id')); } else { $query = 'SELECT COUNT(id)' . ' FROM #__wf_profiles'; $db->setQuery($query); $total = $db->loadResult(); // get the defaults from xml $row = $model->getDefaultProfile(); if (!is_object($row)) { $row->name = ''; $row->description = ''; $row->types = ''; $row->components = ''; $row->area = 0; $row->types = ''; $row->rows = ''; $row->plugins = ''; $row->published = 1; $row->ordering = 0; $row->params = '{}'; } $row->params = json_decode($row->params . ',' . $component->params); } $row->area = isset($row->area) ? $row->area : 0; // build the html select list for ordering $query = 'SELECT ordering AS value, name AS text' . ' FROM #__wf_profiles' . ' WHERE published = 1' . ' AND ordering > -10000' . ' AND ordering < 10000' . ' ORDER BY ordering'; $order = JHTML::_('list.genericordering', $query); $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published); $exclude = array('com_admin', 'com_cache', 'com_jce', 'com_wrapper', 'com_search', 'com_user'); if (WF_JOOMLA15) { $query = "SELECT *" . " FROM #__components" . " WHERE parent = 0" . " AND enabled = 1" . " ORDER BY name"; } else { $query = "SELECT *" . " FROM #__extensions" . " WHERE type = " . $db->Quote('component') . " AND client_id = 1 AND enabled = 1" . " ORDER BY name"; } $db->setQuery($query); $components = $db->loadObjectList(); $options = array(); for ($i = 0; $i < count($components); $i++) { if (isset($components[$i]->element)) { $components[$i]->option = $components[$i]->element; } if (!in_array($components[$i]->option, $exclude)) { $options[] = JHTML::_('select.option', $components[$i]->option, WFText::_($components[$i]->name), 'value', 'text'); } } $disabled = !$row->components ? ' disabled="disabled"' : ''; $lists['components'] = JHTML::_('select.genericlist', $options, 'components[]', 'class="inputbox levels" size="10" multiple="multiple"' . $disabled, 'value', 'text', explode(',', $row->components)); $options = array(); $options[] = JHTML::_('select.option', 'all', WFText::_('WF_PROFILES_COMPONENTS_ALL')); $options[] = JHTML::_('select.option', 'select', WFText::_('WF_PROFILES_COMPONENTS_SELECT')); $lists['components-select'] = JHTML::_('select.radiolist', $options, 'components-select', 'class="inputbox"', 'value', 'text', $row->components ? 'select' : 'all', false); $options = array(); $options[] = JHTML::_('select.option', '', '-- ' . WFText::_('WF_PROFILES_AREA_SELECT') . ' --'); $options[] = JHTML::_('select.option', 0, WFText::_('WF_PROFILES_AREA_BOTH')); $options[] = JHTML::_('select.option', 1, WFText::_('WF_PROFILES_AREA_FRONTEND')); $options[] = JHTML::_('select.option', 2, WFText::_('WF_PROFILES_AREA_BACKEND')); $lists['area'] = JHTML::_('select.genericlist', $options, 'area', 'class="inputbox levels" size="1"', 'value', 'text', $row->area); $query = 'SELECT types' . ' FROM #__wf_profiles' . ' WHERE id NOT IN (17,28,29,30)'; $db->setQuery($query); $types = $db->loadResultArray(); if (WF_JOOMLA15) { // get list of Groups for dropdown filter $query = 'SELECT id AS value, name AS text' . ' FROM #__core_acl_aro_groups' . ' WHERE id NOT IN (17,28,29,30)'; $db->setQuery($query); $types = $db->loadObjectList(); $i = '-'; $options = array(JHTML::_('select.option', '0', WFText::_('Guest'))); foreach ($types as $type) { $options[] = JHTML::_('select.option', $type->value, $i . WFText::_($type->text)); $i .= '-'; } } else { $options = array(); $join = ' LEFT JOIN #__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt'; $where = ''; $query = 'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' . ' FROM #__usergroups AS a' . ' LEFT JOIN #__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt' . ' GROUP BY a.id' . ' ORDER BY a.lft ASC'; // Prevent parenting to children of this item. /*if ($id = $this->form->getValue('id')) { $query->join('LEFT', '`#__usergroups` AS p ON p.id = '.(int) $id); $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); }*/ // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } } $lists['types'] = JHTML::_('select.genericlist', $options, 'types[]', 'class="inputbox levels" size="8" multiple="multiple"', 'value', 'text', $row->types == '' ? '' : explode(',', $row->types)); $options = array(); if ($row->id && $row->users) { $query = 'SELECT id as value, username as text' . ' FROM #__users' . ' WHERE id IN (' . $row->users . ')'; $db->setQuery($query); $gusers = $db->loadObjectList(); if ($gusers) { foreach ($gusers as $guser) { $options[] = JHTML::_('select.option', $guser->value, $guser->text); } } } $lists['users'] = JHTML::_('select.genericlist', $options, 'users[]', 'class="inputbox users" size="10" multiple="multiple"', 'value', 'text', ''); // get params definitions $xml = WF_EDITOR_LIBRARIES . DS . 'xml' . DS . 'config' . DS . 'profiles.xml'; // get editor params $params = new WFParameter($row->params, $xml, 'editor'); $params->addElementPath(JPATH_COMPONENT . DS . 'elements'); $params->addElementPath(WF_EDITOR . DS . 'elements'); // get width $width = $params->get('editor_width', 600); $groups = $params->getGroups(); $this->assign('width', $width); $this->assignRef('lists', $lists); $this->assignRef('profile', $row); $this->assignRef('params', $params); $this->assignRef('groups', $groups); $this->assignRef('plugins', $plugins); $options = WFToolsHelper::getOptions($params); $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Profiles.init(' . json_encode($options) . ')});'); if ($row->id) { JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' :: ' . WFText::_('WF_PROFILES_EDIT') . ' - [' . $row->name . ']', 'logo.png'); } else { JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' :: ' . WFText::_('WF_PROFILES_NEW'), 'logo.png'); } WFToolbarHelper::save(); WFToolbarHelper::apply(); WFToolbarHelper::cancel('cancelEdit', 'Close'); WFToolbarHelper::help('profiles.edit'); JRequest::setVar('hidemainmenu', 1); $this->setLayout('form'); break; } $this->assignRef('model', $model); parent::display($tpl); }
/** * Download update * @return String JSON string */ public function download() { $app = JFactory::getApplication(); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); wfimport('admin.helpers.extension'); $component = WFExtensionHelper::getComponent(); $params = new WFParameter($component->params, '', 'preferences'); $config = JFactory::getConfig(); $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR')); $id = JRequest::getInt('id'); $key = $params->get('updates_key', ''); $data = $this->connect(self::$updateURL . '&task=download&id=' . $id . '&key=' . urlencode($key)); if ($data) { $data = json_decode($data); if (isset($data->error)) { return json_encode(array('error' => $data->error)); } // get update file if ($data->name && $data->url && $data->hash) { // create path for package file $path = $app->getCfg('tmp_path') . '/' . basename($data->name); // download file if ($this->connect($data->url, null, $path)) { if (JFile::exists($path) && @filesize($path) > 0) { // check hash and file type if ($data->hash == md5(md5_file($path)) && preg_match('/\\.(zip|tar|gz)$/', $path)) { $result = array('file' => basename($path), 'hash' => $data->hash, 'installer' => $data->installer, 'type' => isset($data->type) ? $data->type : ''); } else { // fail and delete file $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_VERIFICATION_FAIL')); if (JFile::exists($path)) { @JFile::delete($path); } } } else { $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_MISSING_OR_INVALID')); } } else { $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR_DATA_TRANSFER')); } } else { $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR_MISSING_DATA')); } } return json_encode($result); }
foreach ($params->getGroups() as $group) { $html .= $params->render('params[' . $plugin->name . '][' . $type . ']', $group); } } foreach ($items as $extension) { // get extension xml file $file = $extension->manifest; if ($extension->core == 0) { // Load extension language file $language = JFactory::getLanguage(); $language->load('com_jce_' . $extension->folder . '_' . trim($extension->extension), JPATH_SITE); } if (JFile::exists($file)) { // get params for plugin $key = $plugin->name . '.' . $type . '.' . $extension->extension; $params = new WFParameter($this->profile->params, $file, $key); // add element paths $params->addElementPath(array(WF_EDITOR . '/elements')); // render params if (!$params->hasParent()) { $key = array($plugin->name, $type, $extension->extension); $enabled = (int) $params->get('enable', 1); $checked = $enabled ? ' checked="checked"' : ''; $html .= '<h3><input type="hidden" id="params' . implode('', $key) . 'enable" name="params[' . implode('][', $key) . '][enable]" value="' . $enabled . '" /><input type="checkbox" data-name="' . $extension->extension . '" class="plugins-enable-checkbox"' . $checked . '/>' . WFText::_($extension->name) . '</h3>'; $html .= '<p>' . WFText::_($extension->description) . '</p>'; foreach ($params->getGroups() as $group) { $html .= $params->render('params[' . implode('][', $key) . ']', $group, array('enable')); } } } }
function getLayoutParams(&$row) { // get params definitions $xml = WF_EDITOR_LIBRARIES . '/xml/config/layout.xml'; // get editor params $params = new WFParameter($row->params, $xml, 'editor'); $params->addElementPath(JPATH_COMPONENT . '/elements'); $params->addElementPath(WF_EDITOR . '/elements'); $groups = $params->getGroups(); $row->layout_params = $params; $row->layout_groups = $groups; }
public function save() { // Check for request forgeries JRequest::checkToken() or die('RESTRICTED'); $db = JFactory::getDBO(); $filter = JFilterInput::getInstance(); $row = JTable::getInstance('profiles', 'WFTable'); $task = $this->getTask(); $post = JRequest::get('post', array()); $id = JRequest::getInt('id'); $result = array('error' => false); // load existing profile $row->load($id); // bind data but ignore params and usergroups $row->bind($post, array('params', 'usergroups')); // process values foreach ($post as $key => $value) { // don't process null values if (is_null($value)) { continue; } switch ($key) { case 'name': case 'description': $value = $filter->clean($value); break; case 'components': case 'device': $value = array_filter($value); $value = implode(',', $this->cleanInput($value)); break; case 'usergroups': $key = 'types'; $value = implode(',', $this->cleanInput(array_filter($value), 'int')); break; case 'users': $value = implode(',', $this->cleanInput(array_filter($value), 'int')); break; case 'area': if (empty($value) || count($value) == 2) { $value = 0; } else { $value = $value[0]; } break; case 'plugins': $value = preg_replace('#[^\\w,]+#', '', $value); break; case 'rows': $value = preg_replace('#[^\\w,;]+#', '', $value); break; case 'params': $json = array(); // get params $params = isset($row->params) ? $row->params : ''; // convert params to json data array $data = (array) json_decode($params, true); // assign editor data if (array_key_exists('editor', $value)) { $json['editor'] = $value['editor']; } // get plugins $plugins = explode(',', $row->plugins); // assign plugin data foreach ($plugins as $plugin) { // add plugin params to array if (array_key_exists($plugin, $value)) { $json[$plugin] = $value[$plugin]; } } // combine and encode as json string $value = json_encode(WFParameter::mergeParams($data, $json, false)); break; } $row->bind(array($key => $value)); } if (!$row->check()) { JError::raiseError(500, $db->getErrorMsg()); } if (!$row->store()) { JError::raiseError(500, $db->getErrorMsg()); } $row->checkin(); switch ($task) { case 'apply': $msg = JText::sprintf('WF_PROFILES_SAVED_CHANGES', $row->name); $this->setRedirect('index.php?option=com_jce&view=profiles&task=edit&cid[]=' . $row->id, $msg); break; case 'save': default: $msg = JText::sprintf('WF_PROFILES_SAVED', $row->name); $this->setRedirect('index.php?option=com_jce&view=profiles', $msg); break; } }
echo '</fieldset>'; } // Get extensions supported by this plugin $extensions = $this->model->getExtensions($plugin->name); foreach ($extensions as $extension) { // get extension xml file $file = $extension->manifest; if ($extension->core == 0) { // Load extension language file $language = JFactory::getLanguage(); $language->load('com_jce_' . $extension->folder . '_' . trim($extension->extension), JPATH_SITE); } if (JFile::exists($file)) { // get params for plugin $key = $plugin->name . '.' . $extension->type . '.' . $extension->extension; $params = new WFParameter($this->profile->params, $file, $key); // add element paths $params->addElementPath(JPATH_COMPONENT . DS . 'elements'); $params->addElementPath(JPATH_COMPONENT_SITE . DS . 'elements'); $params->addElementPath(WF_EDITOR . DS . 'elements'); // render params if (!$params->hasParent()) { echo '<fieldset class="adminform panelform"><legend>' . WFText::_($extension->name) . '</legend>'; echo '<p>' . WFText::_($extension->description) . '</p>'; foreach ($params->getGroups() as $group => $num) { echo $params->render('params[' . $plugin->name . '][' . $extension->type . '][' . $group . ']', $group); } echo '</fieldset>'; } } }
/** * Overridden pack function for plugins */ public function pack() { if (JRequest::getCmd('task') == 'pack') { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'parameter.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'packer.php'; $component =& JComponentHelper::getComponent('com_ckeditor'); $params = new WFParameter($component->params); $cache = $params->get('editor.compress_cache', 0); $compress = $params->get('editor.compress_minify', 0); $gzip = $params->get('editor.compress_gzip', 0); $type = JRequest::getWord('type', 'javascript'); // javascript $packer = new WFPacker(array('type' => $type)); $files = array(); switch ($type) { case 'javascript': foreach ($this->getScripts() as $script => $type) { $script .= preg_match('/\\.js$/', $script) ? '' : '.js'; $files[] = $this->urlToPath($script); } break; case 'css': foreach ($this->getStyleSheets() as $style => $type) { $style .= preg_match('/\\.css$/', $style) ? '' : '.css'; $files[] = $this->urlToPath($style); } break; } $packer->setFiles($files); $packer->pack($cache, $compress, $gzip); } }
/** * Get editor parameters * @access public * @param array $options * @return object */ public function getParams($options = array()) { if (!isset(self::$params)) { self::$params = array(); } // set blank key if not set if (!isset($options['key'])) { $options['key'] = ''; } // set blank path if not set if (!isset($options['path'])) { $options['path'] = ''; } $plugin = JRequest::getCmd('plugin'); if ($plugin) { $options['plugin'] = $plugin; } $signature = serialize($options); if (empty(self::$params[$signature])) { wfimport('admin.helpers.extension'); // get component $component = WFExtensionHelper::getComponent(); // get params data for this profile $profile = $this->getProfile($plugin); $profile_params = array(); $component_params = array(); if (!empty($component->params)) { $component_params = json_decode($component->params, true); // set null as array if (!$component_params) { $component_params = array(); } } if ($profile) { $profile_params = json_decode($profile->params, true); // set null as array if (!$profile_params) { $profile_params = array(); } } // merge data and convert to json string $data = WFParameter::mergeParams($component_params, $profile_params); self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']); } return self::$params[$signature]; }
/** * Convert JSON data to JParameter Object * @param $data JSON data */ public static function toObject($data) { $param = new WFParameter(''); $param->bind($data); return $param->getData(); }
public function getParams($options = array()) { static $params; if (!isset($params)) { $params = array(); } // set blank key if not set if (!isset($options['key'])) { $options['key'] = ''; } // set blank path if not set if (!isset($options['path'])) { $options['path'] = ''; } $signature = serialize($options); if (empty($params[$signature])) { wfimport('admin.helpers.extension'); // get component $component = WFExtensionHelper::getComponent(); // get params data for this profile $profile = $this->getProfile(); $profile_params = array(); $component_params = array(); if (!empty($component->params)) { $component_params = json_decode($component->params, true); // set null as array if (!$component_params) { $component_params = array(); } } if ($profile) { $profile_params = json_decode($profile->params, true); // set null as array if (!$profile_params) { $profile_params = array(); } } // merge data and convert to json string $data = WFParameter::array_to_object(array_merge_recursive($component_params, $profile_params)); $params[$signature] = new WFParameter($data, $options['path'], $options['key']); } return $params[$signature]; }
/** * Overridden JTable::store to encrypt parameters * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success. * * @since 2.4 */ public function store($updateNulls = false) { if ($this->id && $this->params) { $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); if ($params->get('secureparams', 0)) { $this->params = WFEncryptHelper::encrypt($this->params); } } return parent::store($updateNulls); }