Пример #1
0
 public static function getTemplateColors()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $colors = array();
     $path = '';
     $templates = self::getTemplates();
     foreach ($templates as $template) {
         // Template CSS
         $path = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'css';
         // get the first path that exists
         if (is_dir($path)) {
             break;
         }
         // reset path
         $path = '';
     }
     if ($path) {
         $files = JFolder::files($path, '\\.css$', false, true);
         foreach ($files as $file) {
             $colors = array_merge($colors, WFToolsHelper::parseColors($file));
         }
     }
     return implode(",", array_unique($colors));
 }
Пример #2
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_jcemediabox');
     $client = JRequest::getWord('client', 'site');
     $model = $this->getModel();
     $plugin = JPluginHelper::getPlugin('system', 'jcemediabox');
     $params = $this->getParams($plugin->params);
     $this->assignRef('params', $params);
     $this->assignRef('client', $client);
     $this->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/colorpicker.js?version=' . $model->getVersion());
     $this->addStyleSheet('components/com_jce/media/css/colorpicker.css?version=' . $model->getVersion());
     $options = array('template_colors' => WFToolsHelper::getTemplateColors(), 'custom_colors' => '', 'labels' => array('picker' => WFText::_('WF_COLORPICKER_PICKER'), 'palette' => WFText::_('WF_COLORPICKER_PALETTE'), 'named' => WFText::_('WF_COLORPICKER_NAMED'), 'template' => WFText::_('WF_COLORPICKER_TEMPLATE'), 'custom' => WFText::_('WF_COLORPICKER_CUSTOM'), 'color' => WFText::_('WF_COLORPICKER_COLOR'), 'apply' => WFText::_('WF_COLORPICKER_APPLY'), 'name' => WFText::_('WF_COLORPICKER_NAME')));
     $this->addScriptDeclaration('jQuery(document).ready(function($){$("input.color").colorpicker(' . json_encode($options) . ');});');
     WFToolbarHelper::apply();
     WFToolbarHelper::save();
     WFToolbarHelper::help('mediabox.config');
     parent::display($tpl);
 }
Пример #3
0
 public 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', '', 'cmd');
             $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('%' . method_exists($db, 'escape') ? $db->escape($search, true) : $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';
                     }
                 }
             }
             $order = array($filter_order, $filter_order_Dir);
             // get the total number of records
             $query = $db->getQuery(true);
             if (is_object($query)) {
                 $query->select('COUNT(p.id)')->from('#__wf_profiles AS p');
                 if (count($where)) {
                     $query->where($where);
                 }
             } else {
                 $query = 'SELECT COUNT(p.id)' . ' FROM #__wf_profiles AS p' . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '');
             }
             $db->setQuery($query);
             $total = $db->loadResult();
             jimport('joomla.html.pagination');
             $pagination = new JPagination($total, $limitstart, $limit);
             $query = $db->getQuery(true);
             if (is_object($query)) {
                 $query->select('p.*, u.name AS editor')->from('#__wf_profiles AS p')->join('LEFT', '#__users AS u ON u.id = p.checked_out');
                 if (count($where)) {
                     $query->where($where);
                 }
                 $query->order(trim(implode(' ', $order)));
             } else {
                 $query = 'SELECT p.*, u.name AS editor' . ' FROM #__wf_profiles AS p' . ' LEFT JOIN #__users AS u ON u.id = p.checked_out' . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '') . ' ORDER BY ' . trim(implode(' ', $order));
             }
             $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', $user);
             $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::addNewX();
             WFToolbarHelper::editListX();
             WFToolbarHelper::custom('copy', 'copy.png', 'copy_f2.png', 'WF_PROFILES_COPY', true);
             WFToolbarHelper::export();
             if (count($rows) > 1) {
                 WFToolbarHelper::publishList();
                 WFToolbarHelper::unpublishList();
                 WFToolbarHelper::deleteList('', 'remove', 'WF_PROFILES_DELETE');
             }
             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->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/uploads.js?version=' . $model->getVersion());
             $this->addScriptDeclaration('jQuery(document).ready(function($){$(\'input[type="file"]\').upload(' . json_encode($options) . ')});');
             // load styles
             $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/upload.css');
             $this->setLayout('default');
             break;
         case 'apply':
         case 'add':
         case 'edit':
             JHtml::_('behavior.modal');
             // Load media
             $scripts = array('profiles.js', 'extensions.js', 'checklist.js', 'parameter.js');
             // Load scripts
             foreach ($scripts as $script) {
                 $this->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/' . $script . '?version=' . $model->getVersion());
             }
             $this->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/colorpicker.js?version=' . $model->getVersion());
             $this->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/select.js?version=' . $model->getVersion());
             // load styles
             $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/profiles.css');
             $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_ADMINISTRATOR);
             $language->load('com_jce', JPATH_SITE);
             $language->load('plg_editors_jce', JPATH_ADMINISTRATOR);
             $plugins = $model->getPlugins();
             // load plugin languages
             foreach ($plugins as $plugin) {
                 if ($plugin->core == 0) {
                     // Load Language for plugin
                     $language->load('com_jce_' . $plugin->name, JPATH_SITE);
                 }
             }
             // load the row from the db table
             if ($cid[0]) {
                 $row->checkout($user->get('id'));
             } else {
                 $query = $db->getQuery(true);
                 if (is_object($query)) {
                     $query->select('COUNT(id)')->from('#__wf_profiles');
                 } 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;
             $query = $db->getQuery(true);
             if (is_object($query)) {
                 $query->select('ordering AS value, name AS text')->from('#__wf_profiles')->where(array('published = 1', 'ordering > -10000', 'ordering < 10000'))->order('ordering');
             } else {
                 // 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'] = '';
             $options = array(1 => WFText::_('WF_OPTION_YES'), 0 => WFTEXT::_('WF_OPTION_NO'));
             foreach ($options as $value => $text) {
                 $checked = '';
                 if ($value == $row->published) {
                     $checked = ' checked="checked"';
                 }
                 $lists['published'] .= '<label class="radio inline"><input type="radio" id="published-' . $value . '" name="published" value="' . $value . '"' . $checked . ' />' . $text . '</label>';
             }
             $exclude = array('com_admin', 'com_cache', 'com_checkin', 'com_config', 'com_cpanel', 'com_finder', 'com_installer', 'com_languages', 'com_jce', 'com_login', 'com_menus', 'com_media', 'com_messages', 'com_newsfeeds', 'com_plugins', 'com_redirect', 'com_templates', 'com_users', 'com_wrapper', 'com_search', 'com_user', 'com_updates');
             $query = $db->getQuery(true);
             if (is_object($query)) {
                 $query->select('element AS value, name AS text')->from('#__extensions')->where(array('type = ' . $db->Quote('component'), 'client_id = 1', 'enabled = 1'))->order('name');
             } else {
                 $query = "SELECT `option` AS value, name AS text" . " FROM #__components" . " WHERE parent = 0" . " AND enabled = 1" . " ORDER BY name";
             }
             $db->setQuery($query);
             $components = $db->loadObjectList();
             $options = array();
             // load component languages
             for ($i = 0; $i < count($components); $i++) {
                 if (!in_array($components[$i]->value, $exclude)) {
                     $options[] = $components[$i];
                     // load system language file
                     $language->load($components[$i]->value . '.sys', JPATH_ADMINISTRATOR);
                 }
             }
             // set disabled attribute
             $disabled = !$row->components ? ' disabled="disabled"' : '';
             // components list
             $lists['components'] = '<ul id="components" class="checkbox-list">';
             foreach ($options as $option) {
                 $checked = in_array($option->value, explode(',', $row->components)) ? ' checked="checked"' : '';
                 $lists['components'] .= '<li><input type="checkbox" name="components[]" value="' . $option->value . '"' . $checked . $disabled . ' /><label class="checkbox">' . JText::_($option->text) . '</label></li>';
             }
             $lists['components'] .= '</ul>';
             // components select
             $options = array('all' => WFText::_('WF_PROFILES_COMPONENTS_ALL'), 'select' => WFText::_('WF_PROFILES_COMPONENTS_SELECT'));
             $lists['components-select'] = '';
             foreach ($options as $value => $text) {
                 $checked = '';
                 if ($row->components) {
                     if ($value == 'select') {
                         $checked = ' checked="checked"';
                     }
                 } else {
                     if ($value == 'all') {
                         $checked = ' checked="checked"';
                     }
                 }
                 $lists['components-select'] .= '<label class="radio inline"><input type="radio" id="components-select-' . $value . '" name="components-select" value="' . $value . '"' . $checked . ' />' . $text . '</label>';
             }
             // area
             $options = array(1 => WFText::_('WF_PROFILES_AREA_FRONTEND'), 2 => WFText::_('WF_PROFILES_AREA_BACKEND'));
             $lists['area'] = '';
             foreach ($options as $value => $text) {
                 $checked = '';
                 if (!isset($row->area) || empty($row->area) || in_array($value, explode(',', $row->area))) {
                     $checked = ' checked="checked"';
                 }
                 $lists['area'] .= '<label class="checkbox inline"><input type="checkbox" name="area[]" value="' . $value . '"' . $checked . ' />' . $text . '</label>';
             }
             // device
             $options = array('desktop' => WFText::_('WF_PROFILES_DEVICE_DESKTOP'), 'tablet' => WFText::_('WF_PROFILES_DEVICE_TABLET'), 'phone' => WFText::_('WF_PROFILES_DEVICE_PHONE'));
             $lists['device'] = '<div class="">';
             foreach ($options as $value => $text) {
                 $checked = '';
                 if (!isset($row->device) || empty($row->device) || in_array($value, explode(',', $row->device))) {
                     $checked = ' checked="checked"';
                 }
                 $lists['device'] .= '<label class="checkbox inline"><input type="checkbox" name="device[]" value="' . $value . '"' . $checked . ' />' . $text . '</label>';
             }
             $lists['device'] .= '</div>';
             // user types from profile
             $query = $db->getQuery(true);
             if (is_object($query)) {
                 $query->select('types')->from('#__wf_profiles')->where('id NOT IN (17,28,29,30)');
             } else {
                 $query = 'SELECT types' . ' FROM #__wf_profiles' . ' WHERE id NOT IN (17,28,29,30)';
             }
             $db->setQuery($query);
             $types = $db->loadResultArray();
             if (defined('JPATH_PLATFORM')) {
                 $options = array();
                 $query = $db->getQuery(true);
                 $query->select('a.id AS value, a.title AS text')->from('#__usergroups AS a');
                 // Add the level in the tree.
                 $query->select('COUNT(DISTINCT b.id) AS level');
                 $query->join('LEFT OUTER', '#__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt');
                 $query->group('a.id, a.lft, a.rgt, a.parent_id, a.title');
                 $query->order('a.lft ASC');
                 // Get the options.
                 $db->setQuery($query);
                 $options = $db->loadObjectList() or die($db->stdErr());
                 // 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('<span class="gi">|&mdash;</span>', $options[$i]->level) . $options[$i]->text;
                 }
             } else {
                 // 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 .= '|&mdash;';
                 }
             }
             $lists['usergroups'] = '<ul id="user-groups" class="checkbox-list">';
             foreach ($options as $option) {
                 $checked = in_array($option->value, explode(',', $row->types)) ? ' checked="checked"' : '';
                 $lists['usergroups'] .= '<li><input type="checkbox" name="usergroups[]" value="' . $option->value . '"' . $checked . ' /><label class="checkbox">' . $option->text . '</label></li>';
             }
             $lists['usergroups'] .= '</ul>';
             // users
             $options = array();
             if ($row->id && $row->users) {
                 $query = $db->getQuery(true);
                 if (is_object($query)) {
                     $query->select('id AS value, username AS text')->from('#__users')->where('id IN (' . $row->users . ')');
                 } else {
                     $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'] = '<ul id="users" class="users-list">';
             foreach ($options as $option) {
                 $lists['users'] .= '<li><input type="hidden" name="users[]" value="' . $option->value . '" /><label><span class="users-list-delete"></span>' . $option->text . '</label></li>';
             }
             $lists['users'] .= '</ul>';
             // Get layout rows
             $rows = $model->getRowArray($row->rows);
             // assign params to row
             $model->getEditorParams($row);
             $model->getLayoutParams($row);
             // create $params object for "editor"
             $params = new WFParameter($row->params, '', 'editor');
             // load other theme css
             foreach ($model->getThemes() as $theme) {
                 $files = JFolder::files($theme, 'ui([\\w\\.]*)\\.css$');
                 foreach ($files as $file) {
                     $this->addStyleSheet(JURI::root(true) . '/components/com_jce/editor/tiny_mce/themes/advanced/skins/' . basename($theme) . '/' . $file);
                 }
             }
             // assign references
             $this->assignRef('lists', $lists);
             $this->assignRef('profile', $row);
             $this->assignRef('rows', $rows);
             $this->assignRef('params', $params);
             $this->assignRef('plugins', $plugins);
             $options = WFToolsHelper::getOptions($params);
             //$this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Profiles.init(' . json_encode($options) . ')});');
             $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Profiles.init(' . json_encode($options) . ')});');
             // set toolbar
             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');
             }
             // set buttons
             WFToolbarHelper::apply();
             WFToolbarHelper::save();
             WFToolbarHelper::cancel('cancelEdit', 'Close');
             WFToolbarHelper::help('profiles.edit');
             JRequest::setVar('hidemainmenu', 1);
             $this->setLayout('form');
             break;
     }
     $this->assignRef('model', $model);
     parent::display($tpl);
 }
Пример #4
0
 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', '', 'cmd');
             $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 . $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', $user);
             $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 `option` AS value, name AS text" . " FROM #__components" . " WHERE parent = 0" . " AND enabled = 1" . " ORDER BY name";
             } else {
                 $query = "SELECT element AS value, name AS text" . " 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 (!in_array($components[$i]->value, $exclude)) {
                     $options[] = $components[$i];
                 }
             }
             $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));
             $lists['components'] = '<ul id="components" class="checkbox-list">';
             foreach ($options as $option) {
                 $checked = in_array($option->value, explode(',', $row->components)) ? ' checked="checked"' : '';
                 $lists['components'] .= '<li><input type="checkbox" name="components[]" value="' . $option->value . '"' . $checked . $disabled . ' /><label>' . $option->text . '</label></li>';
             }
             $lists['components'] .= '</ul>';
             $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 .= '|&mdash;';
                 }
             } 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, a.title, a.lft, a.rgt' . ' 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('<span class="gi">|&mdash;</span>', $options[$i]->level) . $options[$i]->text;
                 }
             }
             $lists['usergroups'] = '<ul id="user-groups" class="checkbox-list">';
             foreach ($options as $option) {
                 $checked = in_array($option->value, explode(',', $row->types)) ? ' checked="checked"' : '';
                 $lists['usergroups'] .= '<li><input type="checkbox" name="usergroups[]" value="' . $option->value . '"' . $checked . ' /><label>' . $option->text . '</label></li>';
             }
             $lists['usergroups'] .= '</ul>';
             $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', '');
             $rows = $model->getRowArray($row->rows);
             $model->getEditorParams($row);
             $model->getLayoutParams($row);
             $params = new WFParameter($row->params, '', 'editor');
             // load other theme css
             foreach ($model->getThemes() as $theme) {
                 $files = JFolder::files($theme, 'ui([\\w\\.]*)\\.css$');
                 foreach ($files as $file) {
                     $this->document->addStyleSheet(JURI::root(true) . '/components/com_jce/editor/tiny_mce/themes/advanced/skins/' . basename($theme) . '/' . $file);
                 }
             }
             $this->assignRef('lists', $lists);
             $this->assignRef('profile', $row);
             $this->assignRef('rows', $rows);
             $this->assignRef('params', $params);
             $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);
 }
Пример #5
0
 /**
  * Show the theme dialog
  * @access private
  */
 private function display()
 {
     jimport('joomla.filesystem.folder');
     $document = WFDocument::getInstance();
     // get UI Theme
     $uitheme = $this->getParam('editor.dialog_theme', 'jce');
     $document->addScript(array('tiny_mce_popup'), 'tiny_mce');
     // jquery versions
     $jquery = array('jquery/jquery-' . WF_JQUERY . '.min.js', 'jquery/jquery-ui-' . WF_JQUERYUI . '.custom.min.js');
     $document->addScript($jquery, 'libraries');
     $ui = JFolder::files(WF_EDITOR_LIBRARIES . DS . 'css' . DS . 'jquery' . DS . $uitheme, '\\.css$');
     $document->addStyleSheet(array('jquery/' . $uitheme . '/' . basename($ui[0], '.css'), 'plugin'), 'libraries');
     $document->addStyleSheet(array('themes/' . $this->get('theme') . '/css/' . $this->get('dialog')), 'tiny_mce');
     if ($this->get('dialog') == 'colorpicker') {
         $document->addScript(array('colorpicker'), 'libraries');
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'tools.php';
         $settings = array('template_colors' => WFToolsHelper::getTemplateColors(), 'custom_colors' => $this->getParam('editor.custom_colors'));
         $document->addScriptDeclaration('ColorPicker.settings=' . json_encode($settings));
     }
     $document->addScript(array('themes/' . $this->get('theme') . '/js/' . $this->get('dialog')), 'tiny_mce');
     $tabs = WFTabs::getInstance(array('base_path' => WF_EDITOR_THEMES . DS . $this->get('theme')));
     $tabs->addPanel($this->get('dialog'), 1);
 }
Пример #6
0
 public function getSettings()
 {
     wfimport('admin.helpers.tools');
     $settings = array('template_colors' => WFToolsHelper::getTemplateColors(), 'custom_colors' => $this->getParam('editor.custom_colors', ''));
     return parent::getSettings($settings);
 }
Пример #7
0
 /**
  * Display plugin
  * @access private
  */
 public function display()
 {
     jimport('joomla.filesystem.folder');
     $document = WFDocument::getInstance();
     if ($document->get('standalone') == 0) {
         $document->addScript(array('tiny_mce_popup'), 'tiny_mce');
         $document->addScript(array('tiny_mce_utils'), 'libraries');
     }
     $document->addScript(array('jquery-' . WF_JQUERY . '.min', 'jquery-ui-' . WF_JQUERYUI . '.custom.min', 'jquery.ui.touch-punch.min'), 'jquery');
     // add colorpicker
     if ($this->get('colorpicker')) {
         wfimport('admin.helpers.tools');
         $document->addScript(array('colorpicker'), 'libraries');
         $document->addScriptDeclaration('ColorPicker.settings=' . json_encode(array('template_colors' => WFToolsHelper::getTemplateColors(), 'custom_colors' => $this->getParam('editor.custom_colors', ''))) . ';');
     }
     $document->addScript(array('html5', 'select', 'tips', 'plugin'), 'libraries');
     // load plugin dialog language file if necessary
     if ($this->getParam('editor.compress_javascript', 0)) {
         $file = "/langs/" . WFLanguage::getCode() . "_dlg.js";
         if (!JFile::exists(WF_EDITOR_PLUGIN . $file)) {
             $file = "/langs/en_dlg.js";
         }
         if (JFile::exists(WF_EDITOR_PLUGIN . $file)) {
             $document->addScript(array('plugins/' . $this->getName() . $file), 'tiny_mce');
         }
     }
     $document->addStyleSheet(array('plugin'), 'libraries');
     // MediaElement in the future perhaps?
     /*if ($this->get('mediaplayer')) {
           $document->addScript(array('mediaelement-and-player.min'), 'mediaelement');
           $document->addStyleSheet(array('mediaelementplayer.min'), 'mediaelement');
       }*/
     // add custom plugin.css if exists
     if (is_file(JPATH_SITE . '/media/jce/css/plugin.css')) {
         $document->addStyleSheet(array('media/jce/css/plugin.css'), 'joomla');
     }
 }
Пример #8
0
 public static function getTemplateColors()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $colors = array();
     $path = '';
     $templates = self::getTemplates();
     foreach ($templates as $template) {
         // Template CSS
         $path = JPATH_SITE . '/templates/' . $template . '/css';
         // get the first path that exists
         if (is_dir($path)) {
             break;
         }
         // reset path
         $path = '';
     }
     if ($path) {
         $files = JFolder::files($path, '\\.css$', false, true);
         foreach ($files as $file) {
             $colors = array_merge($colors, WFToolsHelper::parseColors($file));
         }
     }
     // make all colors 6 character hex, eg: #333 to #333333
     for ($i = 0; $i < count($colors); $i++) {
         if ($colors[$i][0] == '#' && strlen($colors[$i]) == 4) {
             $colors[$i] .= substr($colors[$i], -3);
         }
     }
     // sort
     $colors = self::sort_hex_colors($colors);
     return implode(",", array_unique($colors));
 }