コード例 #1
0
ファイル: preset.php プロジェクト: juanmcortez/Lectorum
 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);
     }
 }
コード例 #2
0
ファイル: preset.php プロジェクト: rkern21/videoeditor
	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);
		}
	}
コード例 #3
0
 /**
  * Method to convert a variable to a JSON represtative string value
  *
  * This method is used by GantryJSON::encode method but should be used
  * to do these convertions too:
  *
  * - JSON string to time() integer:
  *
  *        GantryJSON::convert(decodedDate:String):time()
  *
  *    If You recieve a date string rappresentation You
  *    could convert into respective time() integer.
  *    Example:
  *        GantryJSON::convert(GantryJSON::decode($clienttime));
  *        // i.e. $clienttime = 2006-11-09T14:42:30
  *        // returned time will be an integer useful with gmdate or date
  *        // to create, for example, this string
  *              // Thu Nov 09 2006 14:42:30 GMT+0100 (Rome, Europe)
  *
  * - time() to JSON string:
  *
  *        GantryJSON::convert(time():Int32, true:Boolean):JSON Date String format
  *
  *    You could send server time() informations and send them to clients.
  *    Example:
  *        GantryJSON::convert(time(), true);
  *        // i.e. 2006-11-09T14:42:30
  *
  * - associative array to generic class:
  *
  *        GantryJSON::convert(array(params=>values), new GenericClass):new Instance of GenericClass
  * This method is used by GantryJSON::encode method but should be used
  * to do these convertions too:
  *
  * - JSON string to time() integer:
  *
  *        GantryJSON::convert(decodedDate:String):time()
  *
  *    If You recieve a date string rappresentation You
  *    could convert into respective time() integer.
  *    Example:
  *        GantryJSON::convert(GantryJSON::decode($clienttime));
  *        // i.e. $clienttime = 2006-11-09T14:42:30
  *        // returned time will be an integer useful with gmdate or date
  *        // to create, for example, this string
  *              // Thu Nov 09 2006 14:42:30 GMT+0100 (Rome, Europe)
  *
  * - time() to JSON string:
  *
  *        GantryJSON::convert(time():Int32, true:Boolean):JSON Date String format
  *
  *    You could send server time() informations and send them to clients.
  *    Example:
  *        GantryJSON::convert(time(), true);
  *        // i.e. 2006-11-09T14:42:30
  *
  * - associative array to generic class:
  *
  *        GantryJSON::convert(array(params=>values), new GenericClass):new Instance of GenericClass
  *
  * @access    public
  *
  * @param              $params
  * @param    object    $result    Optional object if first parameter is an object
  *
  * @internal  param mixed $param The variable to convert into JSON
  * @return    string    time() value or new object with parameters
  * @since     1.0
  */
 public static function convert($params, $result = null)
 {
     switch (gettype($params)) {
         case 'array':
             $tmp = array();
             foreach ($params as $key => $value) {
                 if (($value = GantryJSON::encode($value)) !== '') {
                     array_push($tmp, GantryJSON::encode(strval($key)) . ':' . $value);
                 }
             }
             $result = '{' . implode(',', $tmp) . '}';
             break;
         case 'boolean':
             $result = $params ? 'true' : 'false';
             break;
         case 'double':
         case 'float':
         case 'integer':
             $result = $result !== null ? strftime('%Y-%m-%dT%H:%M:%S', $params) : strval($params);
             break;
         case 'NULL':
             $result = 'null';
             break;
         case 'string':
             $i = create_function('&$e, $p, $l', 'return intval(substr($e, $p, $l));');
             if (preg_match('/^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $params)) {
                 $result = mktime($i($params, 11, 2), $i($params, 14, 2), $i($params, 17, 2), $i($params, 5, 2), $i($params, 9, 2), $i($params, 0, 4));
             }
             break;
         case 'object':
             $tmp = array();
             if (is_object($result)) {
                 foreach ($params as $key => $value) {
                     $result->{$key} = $value;
                 }
             } else {
                 $result = get_object_vars($params);
                 foreach ($result as $key => $value) {
                     if (($value = GantryJSON::encode($value)) !== '') {
                         array_push($tmp, GantryJSON::encode($key) . ':' . $value);
                     }
                 }
                 $result = '{' . implode(',', $tmp) . '}';
             }
             break;
     }
     return $result;
 }
コード例 #4
0
ファイル: overrides.php プロジェクト: rotoballer/emily
<?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";
}
コード例 #5
0
            $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";
}