本文整理汇总了PHP中WFParameter::mergeParams方法的典型用法代码示例。如果您正苦于以下问题:PHP WFParameter::mergeParams方法的具体用法?PHP WFParameter::mergeParams怎么用?PHP WFParameter::mergeParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WFParameter
的用法示例。
在下文中一共展示了WFParameter::mergeParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParams
/**
* 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];
}
示例2: getParams
/**
* 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];
}
示例3: save
public function save()
{
// Check for request forgeries
JRequest::checkToken() or die('RESTRICTED');
$db = JFactory::getDBO();
$filter = JFilterInput::getInstance();
$row = JTable::getInstance('profiles', 'WFTable');
$task = $this->getTask();
$post = JRequest::get('post', array());
$id = JRequest::getInt('id');
$result = array('error' => false);
// load existing profile
$row->load($id);
// bind data but ignore params and usergroups
$row->bind($post, array('params', 'usergroups'));
// process values
foreach ($post as $key => $value) {
// don't process null values
if (is_null($value)) {
continue;
}
switch ($key) {
case 'name':
case 'description':
$value = $filter->clean($value);
break;
case 'components':
case 'device':
$value = array_filter($value);
$value = implode(',', $this->cleanInput($value));
break;
case 'usergroups':
$key = 'types';
$value = implode(',', $this->cleanInput(array_filter($value), 'int'));
break;
case 'users':
$value = implode(',', $this->cleanInput(array_filter($value), 'int'));
break;
case 'area':
if (empty($value) || count($value) == 2) {
$value = 0;
} else {
$value = $value[0];
}
break;
case 'plugins':
$value = preg_replace('#[^\\w,]+#', '', $value);
break;
case 'rows':
$value = preg_replace('#[^\\w,;]+#', '', $value);
break;
case 'params':
$json = array();
// get params
$params = isset($row->params) ? $row->params : '';
// convert params to json data array
$data = (array) json_decode($params, true);
// assign editor data
if (array_key_exists('editor', $value)) {
$json['editor'] = $value['editor'];
}
// get plugins
$plugins = explode(',', $row->plugins);
// assign plugin data
foreach ($plugins as $plugin) {
// add plugin params to array
if (array_key_exists($plugin, $value)) {
$json[$plugin] = $value[$plugin];
}
}
// combine and encode as json string
$value = json_encode(WFParameter::mergeParams($data, $json, false));
break;
}
$row->bind(array($key => $value));
}
if (!$row->check()) {
JError::raiseError(500, $db->getErrorMsg());
}
if (!$row->store()) {
JError::raiseError(500, $db->getErrorMsg());
}
$row->checkin();
switch ($task) {
case 'apply':
$msg = JText::sprintf('WF_PROFILES_SAVED_CHANGES', $row->name);
$this->setRedirect('index.php?option=com_jce&view=profiles&task=edit&cid[]=' . $row->id, $msg);
break;
case 'save':
default:
$msg = JText::sprintf('WF_PROFILES_SAVED', $row->name);
$this->setRedirect('index.php?option=com_jce&view=profiles', $msg);
break;
}
}