Example #1
0
	function fetchElement($name, $value, &$node, $control_name)
	{

		global $gantry;
		
		$class = ( $node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="inputbox"' );
		$mode = $node->attributes('mode');
		if (!isset($mode)) $mode = 'dropdown';
		
		$options = array();
		if (!array_key_exists($name,$gantry->presets)) {
				return JText::_('Unable to find the preset information'); 
		}
		foreach ($gantry->presets[$name] as $preset_name => $preset_value)
		{
			$val	= $preset_name;
			$text	= $preset_value['name'];
			$options[] = JHTML::_('select.option', $val, JText::_($text));
		}
		
		if (!defined('GANTRY_PRESET')) {
			gantry_import('core.gantryjson');
			
			$this->template = end(explode(DS, $gantry->templatePath));
			gantry_addScript($gantry->gantryUrl.'/admin/widgets/preset/js/preset.js');
			gantry_addScript($gantry->gantryUrl.'/admin/widgets/preset/js/preset-saver.js');
			gantry_addInlineScript('var Presets = {};var PresetsKeys = {};');
			
			if (isset($gantry->customPresets[$name])) {
				gantry_addInlineScript('var CustomPresets = '.GantryJSON::encode($gantry->customPresets[$name]).';');
			}
			
			define('GANTRY_PRESET', 1);
		}

		$this->presets = $gantry->originalPresets[$name];
		gantry_addInlineScript($this->populatePresets($name));
		
		if ($mode == 'dropdown') {
			include_once('selectbox.php');
			gantry_addInlineScript("window.addEvent('domready', PresetDropdown.init.bind(PresetDropdown, '$name'));");
			$selectbox = new JElementSelectBox;
			$node->addAttribute('preset', true);
			return $selectbox->fetchElement($name, $value, $node, $control_name, $options);
		} else {
			gantry_addInlineScript("window.addEvent('domready', Scroller.init.bind(Scroller, '$name'));");
			return $this->scrollerLayout($name, $value, $node, $control_name);
		}
	}
Example #2
0
 public function getInput()
 {
     /** @var $gantry Gantry */
     global $gantry;
     $name = (string) $this->element['name'];
     $class = $this->element['class'] ? 'class="' . $this->element['class'] . '"' : 'class="inputbox"';
     $mode = $this->element['mode'];
     if (!isset($mode)) {
         $mode = 'dropdown';
     }
     $options = array();
     if (!array_key_exists($name, $gantry->presets)) {
         return 'Unable to find the preset information';
     }
     foreach ($gantry->presets[$name] as $preset_name => $preset_value) {
         $val = $preset_name;
         $text = $preset_value['name'];
         if (!array_key_exists('disabled', $preset_value)) {
             $preset_value['disabled'] = 'false';
         }
         $options[] = GantryHtmlSelect::option((string) $val, JText::_(trim((string) $text)), 'value', 'text', (string) $preset_value['disabled'] == 'true');
     }
     if (!defined('GANTRY_PRESET')) {
         gantry_import('core.gantryjson');
         $template_path_parts = explode('/', $gantry->templatePath);
         $this->template = end($template_path_parts);
         $gantry->addScript($gantry->gantryUrl . '/admin/widgets/preset/js/preset.js');
         $gantry->addScript($gantry->gantryUrl . '/admin/widgets/preset/js/preset-saver.js');
         $gantry->addInlineScript('var Presets = {};var PresetsKeys = {};');
         if (isset($gantry->customPresets[$name])) {
             $gantry->addInlineScript('var CustomPresets = ' . GantryJSON::encode($gantry->customPresets[$name]) . ';');
         } else {
             $gantry->addInlineScript('var CustomPresets = {};');
         }
         define('GANTRY_PRESET', 1);
     }
     $this->presets = $gantry->originalPresets[$name];
     $gantry->addInlineScript($this->populatePresets((string) $this->element['name']));
     if ($mode == 'dropdown') {
         include_once 'selectbox.php';
         $gantry->addDomReadyScript("PresetDropdown.init('" . $name . "');");
         $selectbox = new JElementSelectBox();
         $node->addAttribute('preset', true);
         return $selectbox->fetchElement($name, $value, $node, $control_name, $options);
     } else {
         $gantry->addDomReadyScript("Scroller.init('" . $name . "');");
         return $this->scrollerLayout($this->element);
     }
 }
Example #3
0
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 *
 * Gantry uses the Joomla Framework (http://www.joomla.org), a GNU/GPLv2 content management system
 *
 */
defined('JPATH_BASE') or die();
gantry_import('core.gantryjson');

global $gantry;


$file = $gantry->custom_presets_file;
$action = JRequest::getString('action');

if ($action == 'add') {
	$data = GantryJSON::decode(JRequest::getString('presets-data'), false);

	if (!file_exists($file)) {
		$handle = @fopen($file, 'w');
		@fwrite($handle, "");
	}

	gantry_import('core.gantryini');
	$newEntry = GantryINI::write($file, $data);

	if ($newEntry) echo "success";
} else if ($action == 'delete') {
	$presetTitle = JRequest::getString('preset-title');
	$presetKey = JRequest::getString('preset-key');
	if (!$presetKey || !$presetTitle) return "error";
	
 protected static function _endString(&$encode, $position, &$pos)
 {
     do {
         $position = strpos($encode, '"', $position + 1);
     } while ($position !== false && GantryJSON::_slashedChar($encode, $position - 1));
     if ($position === false) {
         JError::raiseWorning(500, 'Invalid JSON');
     }
     return $position - $pos;
 }
Example #5
0
             }
             $sidebars[$key] = $sb;
         }
         gantry_save_override_sidebars_widgets($override_id, $sidebars);
         die('1');
     }
     die('-1');
     break;
 case 'widgets-save':
     gantry_widgets_save();
     die;
     break;
 case 'widgets-mass-actions':
     $tmp = array();
     $data = stripcslashes($_POST['data']);
     foreach (GantryJSON::decode($data) as $d) {
         array_push($tmp, $d);
     }
     foreach ($tmp as $widget_instance) {
         $instance_array = get_object_vars($widget_instance);
         $id_base = $instance_array['id_base'];
         $widget_number = $instance_array['widget_number'];
         foreach ($instance_array as $key => $value) {
             if (preg_match('/^widget-' . $id_base . '\\[' . $widget_number . '\\]/', $key)) {
                 $subkey = preg_replace('/^widget-' . $id_base . '/', '', $key);
                 preg_match_all('/\\[(\\S+)\\]/U', $subkey, $matches);
                 $sub_array_keys = $matches[1];
                 $post_eval = '$_POST[\'widget-' . $id_base . '\']';
                 foreach ($sub_array_keys as $subarraykey) {
                     $post_eval .= '[\'' . $subarraykey . '\']';
                 }
Example #6
0
<?php

/**
 * @version		1.26 September 14, 2012
 * @author		RocketTheme http://www.rockettheme.com
 * @copyright 	Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
defined('GANTRY_VERSION') or die;
gantry_import('core.gantryjson');
gantry_import('core.utilities.gantrytemplateinfo');
global $gantry;
$action = $_POST['gantry_action'];
if (!current_user_can('edit_theme_options')) {
    die('-1');
}
if ($action == 'get_base_values') {
    $passed_array = array();
    foreach ($gantry->_working_params as $param) {
        $param_name = GantryTemplateInfo::get_field_id($param['name'], 'template-options');
        $passed_array[$param_name] = $param['value'];
    }
    $outdata = GantryJSON::encode($passed_array);
    //$outdata = str_replace('\\\\\\' , '\\', $outdata);
    echo $outdata;
} else {
    return "error";
}
Example #7
0
 * @copyright 	Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 *
 */
defined('GANTRY_VERSION') or die;
gantry_import('core.gantryjson');
global $gantry;
$file = $gantry->custom_presets_file;
$action = $_POST['action'];
// if (!current_user_can('edit_theme_options')) die('-1');
if ($action == 'add') {
    $jsonstring = stripslashes($_POST['presets-data']);
    $data = GantryJSON::decode($jsonstring, false);
    foreach ($data['presets'] as &$preset) {
        foreach ($preset as $key => &$value) {
            if (GantryJSON::isJson($value)) {
                $value = str_replace(chr(34), chr(39), $value);
            }
        }
    }
    if (!file_exists($file)) {
        $handle = @fopen($file, 'w');
        @fwrite($handle, "");
    }
    gantry_import('core.gantryini');
    $newEntry = GantryINI::write($file, $data);
    gantry_import('core.utilities.gantrycache');
    $cache = GantryCache::getInstance();
    $cache->clear('gantry', 'gantry');
    if ($newEntry) {
        echo "success";
            $posName = $param['name'] == "mainbodyPosition" ? "sidebar" : str_replace("Position", "", $param['name']);
            $realCount = $gantry->countModules($posName);
            if ($posName == 'sidebar') {
                $realCount += 1;
            }
            $module_counts[$posName] = $realCount;
        }
    }
    $out->module_counts = $module_counts;
    $app =& JApplication::getInstance('site', array(), 'J');
    $menus = $app->getMenu();
    $menu = $menus->getItem($id);
    $out->tree = array();
    foreach ($menu->tree as $treeid) {
        if ($treeid == $id) {
            break;
        }
        $out->tree[$treeid] = $gantry->readMenuItemParams($treeid, true);
    }
    $outdata = GantryJSON::encode($out);
    $outdata = str_replace('\\\\\\', '\\', $outdata);
    echo $outdata;
} elseif ($action == 'push') {
    $data = JRequest::getString('menuitems-data');
    $data = GantryJSON::decode($data, false);
    foreach ($data as $menuitem => $content) {
        $gantry->writeMenuItemParams($menuitem, $content);
    }
} else {
    return "error";
}
Example #9
0
 * @version		1.26 September 14, 2012
 * @author		RocketTheme http://www.rockettheme.com
 * @copyright 	Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
defined('GANTRY_VERSION') or die;
gantry_import('core.gantryjson');
global $gantry;
$file = $gantry->custom_presets_file;
$action = $_POST['gantry_action'];
if (!current_user_can('edit_theme_options')) {
    die('-1');
}
if ($action == 'add') {
    $jsonstring = stripslashes($_POST['presets-data']);
    $data = GantryJSON::decode($jsonstring, false);
    if (!file_exists($file)) {
        $handle = @fopen($file, 'w');
        @fwrite($handle, "");
    }
    gantry_import('core.gantryini');
    $newEntry = GantryINI::write($file, $data);
    gantry_import('core.utilities.gantrycache');
    $cache = GantryCache::getInstance();
    $cache->clear('gantry', 'gantry');
    if ($newEntry) {
        echo "success";
    }
} else {
    if ($action == 'delete') {
        $presetTitle = $_POST['preset-title'];