public function onGetIcons($context) { @(include_once JPATH_ADMINISTRATOR . '/components/com_jce/models/model.php'); // check for class to prevent fatal errors if (!class_exists('WFModel')) { return; } if ($context != $this->params->get('context', 'mod_quickicon') || WFModel::authorize('browser') === false) { return; } $document = JFactory::getDocument(); $language = JFactory::getLanguage(); $language->load('com_jce', JPATH_ADMINISTRATOR); $width = $this->params->get('width', 800); $height = $this->params->get('height', 600); $filter = $this->params->get('filter', ''); JHtml::_('behavior.modal'); $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\tSqueezeBox.assign(\$\$('#plg_quickicon_jcefilebrowser a'), {\n\t\t\t\thandler: 'iframe', size: {x: " . $width . ", y: " . $height . "}\n\t\t\t});\n\t\t});"); require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php'; $version = new JVersion(); $icon = $version->isCompatible('3.0') ? 'pictures' : 'header/icon-48-media.png'; $link = WFBrowserHelper::getBrowserLink('', $filter); if ($link) { return array(array('link' => $link, 'image' => $icon, 'icon' => 'pictures', 'access' => array('jce.browser', 'com_jce'), 'text' => JText::_('WF_QUICKICON_BROWSER'), 'id' => 'plg_quickicon_jcefilebrowser')); } return array(); }
/** * This method is called when the Quick Icons module is constructing its set * of icons. You can return an array which defines a single icon and it will * be rendered right after the stock Quick Icons. * * @param $context The calling context * * @return array A list of icon definition associative arrays, consisting of the * keys link, image, text and access. * * @since 2.5 */ public function onGetIcons($context) { jimport('joomla.application.component.model'); JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce' . DS . 'models'); $model = JModel::getInstance('model', 'WF'); if ($context != $this->params->get('context', 'mod_quickicon') || !$model->authorize('browser')) { return; } $document = JFactory::getDocument(); $language = JFactory::getLanguage(); $language->load('com_jce', JPATH_ADMINISTRATOR); $width = $this->params->get('width', 800); $height = $this->params->get('height', 600); $filter = $this->params->get('filter', ''); JHtml::_('behavior.modal'); $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\tSqueezeBox.assign(\$\$('#plg_quickicon_jcefilebrowser a'), {\n\t\t\t\thandler: 'iframe', size: {x: " . $width . ", y: " . $height . "}\n\t\t\t});\n\t\t});"); require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php'; return array(array('link' => WFBrowserHelper::getBrowserLink('', $filter), 'image' => 'header/icon-48-media.png', 'access' => array('jce.browser', 'com_jce'), 'text' => JText::_('WF_QUICKICON_BROWSER'), 'id' => 'plg_quickicon_jcefilebrowser')); }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/akrecipes.php'; $state = $this->get('State'); $canDo = AkrecipesHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_AKRECIPES_TITLE_RECIPES'), 'recipes.png'); // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/recipe'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('recipe.add', 'JTOOLBAR_NEW'); JToolbarHelper::custom('recipes.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('recipe.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('recipes.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('recipes.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); JToolbarHelper::custom('recipes.featured', 'featured.png', 'featured_f2.png', 'JFEATURE', true); JToolbarHelper::custom('recipes.unfeatured', 'unfeatured.png', 'featured_f2.png', 'JUNFEATURE', true); } elseif (isset($this->items[0])) { // If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'recipes.delete', 'JTOOLBAR_DELETE'); } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('recipes.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('recipes.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } // Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'recipes.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('recipes.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } // Add file browser button require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jce' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'browser.php'; $bar =& JToolBar::getInstance('toolbar'); JToolBarHelper::divider(); $bar->appendButton('Popup', 'folder', 'File browser', WFBrowserHelper::getBrowserLink(), 800, 500); if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_akrecipes'); } // Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_akrecipes&view=recipes'); $this->extra_sidebar = ''; JHtmlSidebar::addFilter(JText::_("JOPTION_SELECT_CATEGORY"), 'filter_catid', JHtml::_('select.options', JHtml::_('category.options', 'com_akrecipes'), "value", "text", $this->state->get('filter.catid'))); //Filter for the field cuisines_id; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_akrecipes.recipe', 'recipe'); $field = $form->getField('cuisines_id'); $query = $form->getFieldAttribute('filter_cuisines_id', 'query'); $translate = $form->getFieldAttribute('filter_cuisines_id', 'translate'); $key = $form->getFieldAttribute('filter_cuisines_id', 'key_field'); $value = $form->getFieldAttribute('filter_cuisines_id', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$Cuisine', 'filter_cuisines_id', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.cuisines_id')), true); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); // JHtmlSidebar::addFilter( // JText::_('Select User'), // 'filter_created_by', // JHtml::_('select.options', "value", "text", $this->state->get('filter.created_by'),true) // ); $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('u.id AS value, u.name AS text')->from('#__users AS u')->join('LEFT', '#__user_usergroup_map AS m ON m.user_id = u.id')->where('u.block = 0')->order('name')->group('u.id'); $db->setQuery($query); $users[] = JHtml::_('select.option', '0', JText::_('JOPTION_NO_USER')); $users = array_merge($users, $db->loadObjectList()); // error_log('users arraay -> ' . print_r($users,true)); JHtmlSidebar::addFilter(JText::_('Select User'), 'filter_created_by', JHtml::_('select.options', $users, "value", "text", $this->state->get('filter.created_by'))); // filter by tag $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('u.id AS value, u.title AS text')->from('#__tags AS u')->order('u.title'); $db->setQuery($query); $tags[] = JHtml::_('select.option', '0', JText::_('JOPTION_SELECT_TAG')); $tags = array_merge($tags, $db->loadObjectList()); //error_log('users arraay -> ' . print_r($tags,true)); JHtmlSidebar::addFilter(JText::_('Select Tag'), 'filter_tag', JHtml::_('select.options', $tags, "value", "text", $this->state->get('filter.tag'))); //Filter for the field contest_id; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_akrecipes.recipe', 'recipe'); $field = $form->getField('contest_id'); $query = $form->getFieldAttribute('filter_contest_id', 'query'); $translate = $form->getFieldAttribute('filter_contest_id', 'translate'); $key = $form->getFieldAttribute('filter_contest_id', 'key_field'); $value = $form->getFieldAttribute('filter_contest_id', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); //error_log("Query == " . $query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$Cuisine', 'filter_contest_id', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.contest_id')), true); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language'))); //error_log('users select options -> ' . JHtml::_('select.options', $users, "value", "text", $this->state->get('filter.created_by'))); //Filter for the field created_by // $this->extra_sidebar .= '<div class="other-filters">'; // $this->extra_sidebar .= '<small><label for="filter_created_by">Created by</label></small>'; // $this->extra_sidebar .= JHtmlList::users('filter_created_by', $this->state->get('filter.created_by'), 1, 'onchange="this.form.submit();"'); // $this->extra_sidebar .= '</div>'; // $this->extra_sidebar .= '<hr class="hr-condensed">'; }
/** * Fetch the HTML for the button * * @param string $type Unused string, formerly button type. * @param string $name Modal name, used to generate element ID * @param string $text The link text * @param integer $width Width of popup * @param integer $height Height of popup * @param string $onClose JavaScript for the onClose event. * @param string $title The title text * * @return string HTML string for the button * * @since 3.0 */ public function fetchButton($type = 'File', $name = 'File', $open = 'Open', $upload = 'Upload', $task = 'file', $width = 640, $height = 480, $onClose = '') { $jce = file_exists(JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php'); $app = JFactory::getApplication(); $user = JFactory::getUser(); $default_editor = JFactory::getConfig()->get('editor'); $editor = $user->getParam('editor', $default_editor); $jce = $editor == 'jce'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration("#{$name}_local1 {margin-bottom:0;height:14px;}"); $doc->addStyleDeclaration("#{$name}_url {margin-bottom:0;height:14px;}"); $doc->addStyleDeclaration("#{$name}_server {margin-bottom:0;height:14px;}"); // Store all data to the options array for use with JLayout $class = $this->fetchIconClass($name); $title = JText::_($name); $open = JText::_($open); $upload = JText::_($upload); $component = substr($task, 0, $i = strpos($task, '.')); $task = substr($task, $i + 1); $doAction = "index.php?option=com_{$component}&task={$task}"; $html = array(); $html[] = "<form name=\"" . $name . "Form\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$doAction}\" style=\"margin:0\">\n"; $html[] = "<div class=\"btn-group input-append\" style=\"margin:0;\">"; $html[] = "<input type=\"hidden\" id=\"" . $name . "_filetype\" name=\"" . $name . "_filetype\" value=\"1\" />"; $html[] = "<input type=\"file\" id=\"" . $name . "_local\" name=\"" . $name . "_local\" />"; $html[] = "<input type=\"text\" id=\"" . $name . "_local1\" class=\"file-button\" placeholder=\"No selected file...\" />"; $html[] = "<input type=\"text\" id=\"" . $name . "_url\" name=\"" . $name . "_url\" class=\"file-button\" placeholder=\"URL\" />"; $html[] = "<input type=\"text\" id=\"" . $name . "_server\" name=\"" . $name . "_server\" class=\"file-button\" placeholder=\"Server\" value=\"\" />"; $html[] = "<button title=\"\" class=\"btn btn-small hasTooltip\" data-toggle=\"dropdown\" id=\"" . $name . "_type\">"; $html[] = "<i class=\"caret\" style=\"margin-bottom:0\"></i>"; $html[] = "</button>"; $html[] = "<ul class=\"dropdown-menu\">"; $html[] = "<li><a href=\"#\" onclick=\"\$('" . $name . "_local1').style.display='';\r\n\t\t\t\$('" . $name . "_local_open').style.display='';\r\n\t\t\t\$('" . $name . "_url').style.display='none';\r\n\t\t\t\$('" . $name . "_server').style.display='none';\r\n\t\t\t" . ($jce ? "\$('" . $name . "_server_open').style.display='none';" : "") . "\r\n\t\t\t\$('" . $name . "_filetype').value=1;\r\n\t\t\t\">Local</a></li>"; $html[] = "<li><a href=\"#\" onclick=\"\$('" . $name . "_local1').style.display='none';\r\n\t\t\t\$('" . $name . "_local_open').style.display='none';\r\n\t\t\t\$('" . $name . "_url').style.display='';\r\n\t\t\t\$('" . $name . "_server').style.display='none';\r\n\t\t\t" . ($jce ? "\$('" . $name . "_server_open').style.display='none';" : "") . "\r\n\t\t\t\$('" . $name . "_filetype').value=2;\r\n\t\t\t\">URL</a></li>"; $html[] = "<li><a href=\"#\" onclick=\"\$('" . $name . "_local1').style.display='none';\r\n\t\t\t\$('" . $name . "_local_open').style.display='none';\r\n\t\t\t\$('" . $name . "_url').style.display='none';\r\n\t\t\t\$('" . $name . "_server').style.display='';\r\n\t\t\t" . ($jce ? "\$('" . $name . "_server_open').style.display='';" : "") . "\r\n\t\t\t\$('" . $name . "_filetype').value=3;\t\t\t\t\t\t\r\n\t\t\t\">Server</a></li>"; $html[] = "</ul>"; $html[] = "<button id=\"" . $name . "_local_open\" onclick=\"javascript:" . $name . "_local.click();return false;\" class=\"btn btn-small\" >"; $html[] = "<i class=\"icon-folder\"></i>"; $html[] = $open; $html[] = "</button>"; if ($jce) { require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php'; $doTask = JUri::base() . WFBrowserHelper::getBrowserLink($name . '_server', 'xml'); $html[] = "<button id=\"{$name}_server_open\" onclick=\"{$doTask}\" class=\"btn btn-small modal\" data-toggle=\"modal\" data-target=\"#{$name}_server_modal\" >"; $html[] = "<i class=\"icon-folder\"></i>"; $html[] = $open; $html[] = "</button>"; // Place modal div and scripts in a new div $html[] = '<div class="btn-group" style="width: 0; margin: 0">'; // Build the options array for the modal $params = array(); $params['title'] = $title; $params['url'] = $doTask; $params['height'] = $height; $params['width'] = $width; $html[] = JHtml::_('bootstrap.renderModal', $name . '_server_modal', $params); $html[] = '</div>'; } $html[] = "<button title=\"{$title}\" class=\"btn btn-small hasTooltip\" type=\"submit\" data-original-title=\"{$title}\">"; $html[] = "<i class=\"icon-upload\"></i> {$upload}"; $html[] = "</button>"; $html[] = '<script> var jQuery; (function ($) { $(document).ready(function () { $(\'#' . $name . '_local\').on(\'change\', function () { $(\'#' . $name . '_local1\').val(this.files[0].name); }); $(\'#' . $name . '_local\').hide(); $(\'#' . $name . '_local1\').on(\'click\', function () { $(\'#' . $name . '_local_open\').click(); return false; }); $(\'#' . $name . '_local1\').attr(\'readonly\',\'readonly\'); $(\'#' . $name . '_url\').hide(); }); })(jQuery); </script>'; // if ($jce) $html[] = '<script> var jQuery; (function ($) { $(document).ready(function () { // $(\'#' . $name . '_server\').attr(\'readonly\',\'readonly\'); $(\'#' . $name . '_server\').hide(); $(\'#' . $name . '_server_open\').hide(); ' . (strlen($onClose) >= 1 ? '$(\'#' . $name . '_server_modal\').on(\'hide\', function () {' . $onClose . ';});' : '') . ' // $(\'#' . $name . '_server\').on(\'click\', function () { // $(\'#' . $name . '_server_open\').click(); // return false; // }); }); })(jQuery); </script>'; $html[] = '</div>'; $html[] = JHTML::_('form.token'); $html[] = '</form>'; return implode("\n", $html); }
protected function getLink($filter = 'images') { require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php'; $link = WFBrowserHelper::getMediaFieldLink('', $filter); return $link; }
$width = $params->get('width', 800); $height = $params->get('height', 600); $filter = $params->get('filter', ''); } $float = $language->isRTL() ? 'right' : 'left'; ?> <div id="cpanel"> <div class="icon-wrapper" style="float:<?php echo $float; ?> ;"> <div class="icon"> <a class="modal" rel="{handler: 'iframe', size: {x: <?php echo $width; ?> , y: <?php echo $height; ?> }}" href="<?php echo WFBrowserHelper::getBrowserLink('', $filter); ?> "> <span class="jce-file-browser"></span> <span><?php echo JText::_('WF_QUICKICON_BROWSER'); ?> </span> </a> </div> </div> </div>