Пример #1
0
 function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $document = JFactory::getDocument();
     $document->addScriptDeclaration("\nvar fss_settings_url = '" . JRoute::_('index.php?option=com_fss&view=settings', false) . "';\n");
     $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/settings.js');
     $what = JRequest::getString('what', '');
     $this->tab = JRequest::getVar('tab');
     if (JRequest::getVar('task') == "cancellist") {
         $mainframe = JFactory::getApplication();
         $link = FSSRoute::_('index.php?option=com_fss&view=fsss', false);
         $mainframe->redirect($link);
         return;
     }
     $settings = FSS_Settings::GetAllViewSettings();
     // CHANGE
     $db = JFactory::getDBO();
     if ($what == "save") {
         $data = JRequest::get('POST', JREQUEST_ALLOWRAW);
         foreach ($data as $setting => $value) {
             if (array_key_exists($setting, $settings)) {
                 $settings[$setting] = $value;
             }
         }
         foreach ($settings as $setting => $value) {
             if (!array_key_exists($setting, $data)) {
                 $settings[$setting] = 0;
                 $value = 0;
             }
             $qry = "REPLACE INTO #__fss_settings_view (setting, value) VALUES ('";
             $qry .= FSSJ3Helper::getEscaped($db, $setting) . "','";
             $qry .= FSSJ3Helper::getEscaped($db, $value) . "')";
             $db->setQuery($qry);
             $db->Query();
         }
         $link = 'index.php?option=com_fss&view=settingsview#' . $this->tab;
         if (JRequest::getVar('task') == "save") {
             $link = 'index.php?option=com_fss';
         }
         $mainframe = JFactory::getApplication();
         $mainframe->redirect($link, JText::_("View_Settings_Saved"));
         exit;
     } else {
         $document = JFactory::getDocument();
         $document->addStyleSheet(JURI::root() . 'administrator/components/com_fss/assets/css/js_color_picker_v2.css');
         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/color_functions.js');
         $document->addScript(JURI::root() . 'administrator/components/com_fss/assets/js/js_color_picker_v2.js');
         $this->settings = $settings;
         JToolBarHelper::title(JText::_("FREESTYLE_SUPPORT_PORTAL") . ' - ' . JText::_("VIEW_SETTINGS"), 'fss_viewsettings');
         JToolBarHelper::apply();
         JToolBarHelper::save();
         JToolBarHelper::cancel('cancellist');
         FSSAdminHelper::DoSubToolbar();
         parent::display($tpl);
     }
 }
Пример #2
0
 static function ReplaceGlossary($text)
 {
     if (stripos($text, "id='XXX_GLOSSARY_DONE_XXX'") !== FALSE) {
         return $text;
     }
     self::GetGlossary();
     FSS_Settings::GetAllViewSettings();
     if (count(self::$glossary) == 0) {
         return $text;
     }
     // build a rough list of terms in the document in question. This means less stuff for the preg to check later on
     self::$glo_ref = array();
     foreach (self::$glossary as $offset => &$data) {
         $data->limit = 999;
         if (FSS_Settings::get('glossary_word_limit') > 0) {
             $data->limit = FSS_Settings::get('glossary_word_limit');
         }
         if (empty($data->linkword)) {
             $data->linkword = $data->word;
         }
         $data->anc = self::MakeAnchor($data->word);
         $data->ref = $data->id . "-" . $data->anc;
         $linkanc = self::MakeAnchor($data->linkword);
         $linkref = $data->id . "-" . $data->anc;
         $data->href = "#";
         $data->cs = self::isWordCS($data);
         // word for regex
         $rword = preg_quote($data->word);
         $rword = str_replace("/", "\\/", $rword);
         $data->regex = "/\\b({$rword})\\b/";
         if (!$data->cs) {
             $data->regex .= "i";
         }
         if (FSS_Settings::get('glossary_link')) {
             if (FSS_Settings::$fss_view_settings['glossary_long_desc'] == 1 && $data->longdesc) {
                 // link directly to the item
                 $data->href = FSSRoute::_("index.php?option=com_fss&view=glossary&layout=word&word=" . $linkref, false);
             } else {
                 $data->href = FSSRoute::_('index.php?option=com_fss&view=glossary&letter=' . strtolower(substr($data->linkword, 0, 1)) . '#' . $linkanc, false);
             }
         }
         if (stripos($text, $data->word) !== FALSE) {
             self::$glo_ref[$data->ref] = $offset;
             $data->inuse = true;
         }
     }
     // setup empty dom object
     libxml_use_internal_errors(TRUE);
     $dom = new DOMDocument('1.0', 'UTF-8');
     FSS_Glossary::$cdom = $dom;
     $dom->substituteEntities = false;
     $dom->recover = true;
     $dom->strictErrorChecking = false;
     $dom->resolveExternals = false;
     // load the xml file. Add padding tags as the dom adds crap to the start of the output
     $dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?><meta http-equiv="content-type" content="text/html; charset=utf-8"><xxxglossaryxxx>' . $text . "</xxxglossaryxxx>");
     // get list of html tags to ignore
     $tag_ignore = FSS_Settings::get('glossary_exclude');
     $tag_ignore = explode(",", $tag_ignore);
     $tags = array();
     $tags[] = "a";
     foreach ($tag_ignore as $tag) {
         $tag = trim($tag);
         if (!$tag) {
             continue;
         }
         $tags[] = $tag;
     }
     // replace all glossary terms
     FSS_Glossary::preg_replace_dom($dom->documentElement, $tags);
     // get resultant html
     $result = $dom->saveHTML();
     //$result = str_replace("&amp;","&", $result);
     // use padding added earlier to remove appended content
     $pos1 = strpos($result, "<xxxglossaryxxx>") + 16;
     $pos2 = strrpos($result, "</xxxglossaryxxx>");
     $result = substr($result, $pos1, $pos2 - $pos1) . "<div style='display: none' id='XXX_GLOSSARY_DONE_XXX'></div>";
     return $result;
 }