Beispiel #1
0
 /**
  * Get editor parameters
  * @access  public
  * @param 	array $options
  * @return 	object
  */
 public function getParams($options = array())
 {
     if (!isset(self::$params)) {
         self::$params = array();
     }
     // set blank key if not set
     if (!isset($options['key'])) {
         $options['key'] = '';
     }
     // set blank path if not set
     if (!isset($options['path'])) {
         $options['path'] = '';
     }
     $plugin = JRequest::getCmd('plugin');
     if ($plugin) {
         $options['plugin'] = $plugin;
     }
     $signature = serialize($options);
     if (empty(self::$params[$signature])) {
         wfimport('admin.helpers.extension');
         // get plugin
         $editor_plugin = WFExtensionHelper::getPlugin();
         // get params data for this profile
         $profile = $this->getProfile($plugin);
         $profile_params = array();
         $editor_params = array();
         // get params from editor plugin
         if ($editor_plugin->params && $editor_plugin->params !== "{}") {
             $editor_params['editor'] = json_decode($editor_plugin->params, true);
         } else {
             // get component
             $component = WFExtensionHelper::getComponent();
             // get params from component "params" field (legacy)
             if ($component->params && $component->params !== "{}") {
                 $data = json_decode($component->params, true);
                 if (isset($data['editor'])) {
                     $editor_params['editor'] = $data['editor'];
                 }
             }
         }
         if ($profile) {
             $profile_params = json_decode($profile->params, true);
         }
         // make sure we have an empty array if null or false
         if (empty($editor_params)) {
             $editor_params = array();
         }
         // make sure we have an empty array if null or false
         if (empty($profile_params)) {
             $profile_params = array();
         }
         // merge data and convert to json string
         $data = WFParameter::mergeParams($editor_params, $profile_params, true, false);
         self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']);
     }
     return self::$params[$signature];
 }
 /**
  * Get editor parameters
  * @access  public
  * @param 	array $options
  * @return 	object
  */
 public function getParams($options = array())
 {
     if (!isset(self::$params)) {
         self::$params = array();
     }
     // set blank key if not set
     if (!isset($options['key'])) {
         $options['key'] = '';
     }
     // set blank path if not set
     if (!isset($options['path'])) {
         $options['path'] = '';
     }
     $plugin = JRequest::getCmd('plugin');
     if ($plugin) {
         $options['plugin'] = $plugin;
     }
     $signature = serialize($options);
     if (empty(self::$params[$signature])) {
         wfimport('admin.helpers.extension');
         // get component
         $component = WFExtensionHelper::getComponent();
         // get params data for this profile
         $profile = $this->getProfile($plugin);
         $profile_params = array();
         $component_params = array();
         if (!empty($component->params)) {
             $component_params = json_decode($component->params, true);
             // set null as array
             if (!$component_params) {
                 $component_params = array();
             }
         }
         if ($profile) {
             $profile_params = json_decode($profile->params, true);
             // set null as array
             if (!$profile_params) {
                 $profile_params = array();
             }
         }
         // merge data and convert to json string
         $data = WFParameter::mergeParams($component_params, $profile_params);
         self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']);
     }
     return self::$params[$signature];
 }