File: /var/www/vhosts/pgkdistribution.com.au/citisolar.com.au/tmp/admin/views/settings/view.html.php
<?php
/**
* @Copyright Freestyle Joomla (C) 2010
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*
* This file is part of Freestyle Testimonials
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
?>
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport( 'joomla.application.component.view' );
require_once (JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_fst'.DS.'settings.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_fst'.DS.'helper'.DS.'parser.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_fst'.DS.'helper'.DS.'fields.php');
class FstsViewSettings extends JView
{
function display($tpl = null)
{
JHTML::_('behavior.modal');
$what = JRequest::getString('what','');
if (JRequest::getVar('task') == "cancellist")
{
$mainframe = JFactory::getApplication();
$link = JRoute::_('index.php?option=com_fst&view=fsts',false);
$mainframe->redirect($link);
return;
}
$settings = FST_Settings::GetAllSettings();
$db = & JFactory::getDBO();
if ($what == "testref")
{
return $this->TestRef();
} else if ($what == "save")
{
//
$large = FST_Settings::GetLargeList();
$templates = FST_Settings::GetTemplateList();
// save any large settings that arent in the templates list
foreach($large as $setting)
{
// skip any setting that is in the templates list
if (array_key_exists($setting,$templates))
continue;
//
$value = JRequest::getVar($setting, '', 'post', 'string', JREQUEST_ALLOWRAW);
$qry = "REPLACE INTO #__fst_settings_big (setting, value) VALUES ('";
$qry .= $db->getEscaped($setting) . "','";
$qry .= $db->getEscaped($value) . "')";
$db->setQuery($qry);$db->Query();
$qry = "DELETE FROM #__fst_settings WHERE setting = '{$db->getEscaped($setting)}'";
$db->setQuery($qry);$db->Query();
unset($_POST[$setting]);
}
$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;
}
// skip any setting that is in the templates list
if (array_key_exists($setting,$templates))
continue;
if (array_key_exists($setting,$large))
continue;
$qry = "REPLACE INTO #__fst_settings (setting, value) VALUES ('";
$qry .= $db->getEscaped($setting) . "','";
$qry .= $db->getEscaped($value) . "')";
$db->setQuery($qry);$db->Query();
//echo $qry."<br>";
}
$link = 'index.php?option=com_fst&view=settings';
if (JRequest::getVar('task') == "save")
$link = 'index.php?option=com_fst';
//exit;
$mainframe = JFactory::getApplication();
$mainframe->redirect($link, JText::_("Settings_Saved"));
exit;
} else if ($what == "customtemplate") {
$this->CustomTemplate();
exit;
} else {
$qry = "SELECT * FROM #__fst_templates WHERE template = 'custom'";
$db->setQuery($qry);
$rows = $db->loadAssocList();
if (count($rows) > 0)
{
foreach ($rows as $row)
{
if ($row['tpltype'])
{
$settings['support_list_head'] = $row['value'];
} else {
$settings['support_list_row'] = $row['value'];
}
}
} else {
$settings['support_list_head'] = '';
$settings['support_list_row'] = '';
}
//
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::root().'administrator/components/com_fst/assets/css/js_color_picker_v2.css');
$document->addScript(JURI::root().'administrator/components/com_fst/assets/js/color_functions.js');
$document->addScript(JURI::root().'administrator/components/com_fst/assets/js/js_color_picker_v2.js');
$this->assignRef('settings',$settings);
JToolBarHelper::title( JText::_("FREESTYLE_TESTIMONIALS") .' - '. JText::_("SETTINGS") , 'fst_settings' );
JToolBarHelper::apply();
JToolBarHelper::save();
JToolBarHelper::cancel('cancellist');
FSTAdminHelper::DoSubToolbar();
parent::display($tpl);
}
}
function ParseParams(&$aparams)
{
$out = array();
$bits = explode(";",$aparams);
foreach ($bits as $bit)
{
if (trim($bit) == "") continue;
$res = explode(":",$bit,2);
if (count($res) == 2)
{
$out[$res[0]] = $res[1];
}
}
return $out;
}
function CustomTemplate()
{
$template = JRequest::getVar('name');
$db = & JFactory::getDBO();
$qry = "SELECT * FROM #__fst_templates WHERE template = '" . $db->getEscaped($template) . "'";
$db->setQuery($qry);
$rows = $db->loadAssocList();
$output = array();
foreach ($rows as $row)
{
if ($row['tpltype'])
{
$output['head'] = $row['value'];
} else {
$output['row'] = $row['value'];
}
}
echo json_encode($output);
exit;
}
function TestRef()
{
$format = JRequest::getVar('ref');
$ref = FST_Helper::createRef(1234,$format);
echo $ref;
exit;
}
}