/**
  * Return parameters for client side as JSON format
  * @return string
  */
 private function _getJSConfiguration()
 {
     $input = $this->_application->input;
     $defaultStyles = $this->_getDefaultStyles();
     $installedComponents = PoweradminHelper::getInstalledComponents();
     $supportedExtList = JSNPaExtensionsHelper::getSupportedExtList();
     if (!$this->_params->get('search_coverage')) {
         $coverages = PoweradminHelper::getSearchCoverages();
     } else {
         $coverages = json_decode($this->_params->get('search_coverage', PoweradminHelper::getSearchCoverages()));
     }
     foreach ($supportedExtList as $_supportedExt => $value) {
         $supportedExtAlias = str_replace('com_', JSN_3RD_EXTENSION_STRING . '-', $_supportedExt);
         $_extShortName = str_ireplace('com_', '', $_supportedExt);
         $_plg = JPluginHelper::getPlugin('jsnpoweradmin', $_extShortName);
         if (in_array($_supportedExt, $installedComponents) && !in_array($_supportedExt, $coverages) && !count($_plg) && !in_array($supportedExtAlias, explode(',', $this->_params->get('search_coverage_order')))) {
             array_push($coverages, JSN_3RD_EXTENSION_NOT_INSTALLED_STRING . '-' . $_extShortName);
         }
         if (in_array($_supportedExt, $installedComponents) && count($_plg) && !in_array($supportedExtAlias, explode(',', $this->_params->get('search_coverage_order')))) {
             array_push($coverages, JSN_3RD_EXTENSION_NOT_ENABLED_STRING . '-' . $_extShortName);
         }
     }
     $logoFile = $this->_params->get('logo_file', 'administrator/components/com_poweradmin/assets/images/logo-jsnpoweradmin.png');
     $logoFile = $logoFile == 'N/A' ? '' : JURI::root(true) . '/' . $logoFile;
     $canInstall = $this->_user->authorise('core.manage', 'com_installer');
     // Get editors
     $curEditor = JFactory::getUser()->getParam('editor');
     $editorOptions = array();
     foreach ($this->_getEditorOptions() as $option) {
         $_isAtive = $curEditor == $option->value ? true : false;
         $editorOptions[] = array('value' => $option->value, 'name' => $option->text, 'active' => $_isAtive);
     }
     $conf = array('currentUrl' => $_SERVER["REQUEST_URI"], 'baseUrl' => JURI::base(true) . '/', 'rootUrl' => JURI::root(true) . '/', 'userId' => $this->_user->id, 'protected' => $this->_getProtectedComponents(), 'defaultStyles' => $defaultStyles, 'logoFile' => $logoFile, 'logoLink' => $this->_params->get('logo_link', 'http://www.joomlashine.com/joomla-extensions/jsn-poweradmin.html'), 'logoLinkTarget' => $this->_params->get('logo_target', '_blank'), 'logoTitle' => JText::_($this->_params->get('logo_slogan', JText::_('PLG_JSNADMINBAR_CONFIG_LOGO_SLOGAN_DEFAULT'))), 'allowUninstall' => $this->_params->get('allow_uninstall', true) && $canInstall, 'linkTarget' => $this->_target, 'preloadImages' => array('bg-overlay.png', 'loader.gif', 'dark-loader.gif', 'ui-window-buttons.png'), 'pinned' => $this->_params->get('pinned_bar', true), 'sessionInfinite' => $this->_params->get('admin_session_timer_infinite', false), 'warningTime' => $this->_params->get('session_timeout_warning', 1), 'disableWarning' => $this->_params->get('admin_session_timeout_warning_disabled', false), 'searchCoverages' => $coverages, 'sitemenu' => array('preview' => $this->_preview->getPreviewLink(), 'manager' => JRoute::_('index.php?option=com_poweradmin&view=rawmode', false)), 'usermenu' => array('messages' => $this->_getMessagesCount(), 'profileLink' => "index.php?option=com_admin&task=profile.edit&id={$this->_user->id}&tmpl=component", 'messageLink' => "index.php?option=com_messages", 'logoutLink' => "index.php?option=com_login&task=logout&" . JSession::getFormToken() . "=1"), 'history' => array('url' => 'index.php?option=com_poweradmin&task=history.load'), 'spotlight' => array('limit' => $this->_params->get('search_result_num', 10)), 'urlparams' => array('option' => $input->getVar('option', ''), 'task' => $input->getVar('task', ''), 'view' => $input->getVar('view', ''), 'layout' => $input->getVar('layout', ''), 'id' => $input->getInt('id', 0)), 'editors' => $editorOptions);
     return json_encode($conf);
 }
Esempio n. 2
0
 /**
  * Return array of search coverage
  */
 public static function getSearchCoverages()
 {
     $config = JSNConfigHelper::get('com_poweradmin');
     $searchCoveragesOrder = json_decode($config->search_coverage);
     $coverages = array();
     if (count($searchCoveragesOrder) > 0) {
         $configCoverages = json_decode($config->search_coverage);
         $configCoveragesOrder = explode(",", $config->search_coverage_order);
         if (count($configCoveragesOrder) > 0) {
             foreach ($configCoveragesOrder as $_cov) {
                 if (in_array($_cov, $configCoverages)) {
                     array_push($coverages, $_cov);
                 }
             }
         } else {
             $coverages = $configCoverages;
         }
     } else {
         $coverages = array('articles', 'categories', 'components', 'modules', 'plugins', 'menus', 'templates', 'users');
         include_once JPATH_ROOT . '/administrator/components/com_poweradmin/helpers/extensions.php';
         $installedComponents = self::getInstalledComponents();
         $supportedList = JSNPaExtensionsHelper::getSupportedExtList();
         if (count($supportedList)) {
             foreach ($supportedList as $extName => $value) {
                 if (in_array($extName, $installedComponents)) {
                     $coverages[] = $value->coverage;
                 }
             }
         }
     }
     return $coverages;
 }
    /**
     * Get the language manager markup.
     *
     * @return  string
     */
    protected function getInput()
    {
        require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/extensions.php';
        // Generate field container id
        $id = str_replace('_', '-', $this->id) . '-field';
        // Preset output
        $supportedExtList = JSNPaExtensionsHelper::getSupportedExtList();
        JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/jquery-tipsy/jquery.tipsy.js');
        JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'joomlashine/configuration/extmanager.js');
        $customScript = "var baseUrl       = '" . JURI::root() . "';";
        JSNHtmlAsset::addInlineScript($customScript);
        if (count($supportedExtList)) {
            $installedComponents = PoweradminHelper::getInstalledComponents();
            foreach ($supportedExtList as $key => $ext) {
                $_shortName = str_ireplace("com_", "", $key);
                $ext->name = $_shortName;
                $ext->comInstalled = in_array($key, $installedComponents) ? true : false;
                $extStatus = JSNPaExtensionsHelper::checkInstalledPlugin($_shortName);
                if ($extStatus['isInstalled']) {
                    $ext->plgInstalled = true;
                    $ext->enabled = $extStatus['isEnabled'];
                } else {
                    $ext->plgInstalled = false;
                    $ext->enabled = false;
                }
                $list[$_shortName] = $ext;
            }
        }
        $html[] = '<div class="jsn-supported-ext-list">
					<input type="hidden" id="label-disable" value="' . JText::_('JSN_POWERADMIN_EXTPAGE_DISABLE') . '">
					<input type="hidden" id="label-enable" value="' . JText::_('JSN_POWERADMIN_EXTPAGE_ENABLE') . '">
					<input type="hidden" id="label-install" value="' . JText::_('JSN_POWERADMIN_EXTPAGE_INSTALL') . '">
					';
        $html[] = '<ul class="thumbnails">';
        foreach ($list as $ext) {
            $_className = '';
            $_alt = '';
            $posibleAct = '';
            $_id = JSN_POWERADMIN_EXT_IDENTIFIED_NAME_PREFIX . $ext->name;
            if (!$ext->comInstalled) {
                $_className = 'item-locked';
                $_alt = JText::_('JSN_POWERADMIN_EXTPAGE_COM_NOT_INSTALLED_EXPLAIN');
                $posibleAct = '<a class="btn btn-primary disabled" href="#" title="' . JText::_('JSN_POWERADMIN_EXTPAGE_COM_NOT_INSTALLED_EXPLAIN') . '">' . JText::_('JSN_POWERADMIN_EXTPAGE_INSTALL') . '</a>';
            } else {
                if ($ext->plgInstalled) {
                    if (!$ext->enabled) {
                        $_className = 'item-installed item-disabled';
                        $_alt = JText::_('JSN_POWERADMIN_EXTPAGE_CLICK_TO_ENABLE');
                        $posibleAct = '<a class="btn btn-primary" id="' . $_id . '" act="enable" href="#">' . JText::_('JSN_POWERADMIN_EXTPAGE_ENABLE') . '</a>';
                    } else {
                        $_className = 'item-installed item-enabled';
                        $_alt = JText::_('JSN_POWERADMIN_EXTPAGE_CLICK_TO_DISABLE');
                        $posibleAct = '<a class="btn btn-primary" id="' . $_id . '" act="disable" href="#">' . JText::_('JSN_POWERADMIN_EXTPAGE_DISABLE') . '</a>';
                    }
                } else {
                    $_className = 'item-notinstalled';
                    $_alt = JText::_('JSN_POWERADMIN_EXTPAGE_CLICK_TO_INSTALL');
                    $posibleAct = '<a class="btn btn-primary" id="' . $_id . '" act="install" href="#">' . JText::_('JSN_POWERADMIN_EXTPAGE_INSTALL') . '</a>';
                }
            }
            $html[] = '	 <li class="span4">
								<div class="thumbnail">
									<img src="' . $ext->thumbnail . '" alt="">
									<div class="caption">
										<h2>' . ucfirst($ext->name) . '</h2>
										<p>
											' . $posibleAct . '
										</p>
									</div>
								</div>
							</li>';
        }
        $html[] = '</ul>';
        return implode($html);
    }