Beispiel #1
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";
	
 * @subpackage admin.ajax-models
 * @version		3.2.20 June 19, 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['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();
Beispiel #3
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 . '\']';
                 }
            $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";
}