本文整理汇总了PHP中JCckDev::toJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP JCckDev::toJSON方法的具体用法?PHP JCckDev::toJSON怎么用?PHP JCckDev::toJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCckDev
的用法示例。
在下文中一共展示了JCckDev::toJSON方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: g_onCCK_WebserviceConstruct
public function g_onCCK_WebserviceConstruct(&$data)
{
// JSON
if (isset($data['json']) && is_array($data['json'])) {
foreach ($data['json'] as $k => $v) {
if (is_array($v)) {
$data[$k] = JCckDev::toJSON($v);
}
}
}
// STRING
if (isset($data['string']) && is_array($data['string'])) {
foreach ($data['string'] as $k => $v) {
if (is_array($v)) {
$string = '';
foreach ($v as $s) {
if ($s) {
$string .= $s . '||';
}
}
if ($string) {
$string = substr($string, 0, -2);
}
$data[$k] = $string;
}
}
}
}
示例2: postSaveHook
protected function postSaveHook(CCKModelSite &$model, $validData = array())
{
$recordId = $model->getState($this->context . '.id');
if ($recordId == 10 || $recordId == 500) {
$db = JFactory::getDbo();
$params = JCckDatabase::loadResult('SELECT params FROM #__extensions WHERE element = "com_cck"');
$config = JCckDev::fromJSON($params, 'object');
$config->multisite = 1;
$params = $db->escape(JCckDev::toJSON($config));
JCckDatabase::execute('UPDATE #__extensions SET params = "' . $params . '" WHERE element = "com_cck"');
}
}
示例3: createVersion
public static function createVersion($type, $pk, $note = '', $update = false)
{
$table = JTable::getInstance($type, 'CCK_Table');
$table->load($pk);
// Core
if (isset($table->asset_id)) {
$table->rules = JCckDatabase::loadResult('SELECT rules FROM #__assets WHERE id = ' . (int) $table->asset_id);
}
$version_num = $table->version;
if ($update !== false) {
unset($table->rules);
$table->version++;
$table->store();
}
// Version
$version = JTable::getInstance('version', 'CCK_Table');
$version->e_id = $table->id;
$version->e_title = $table->title;
$version->e_name = $table->name;
$version->e_type = $type;
$version->e_core = JCckDev::toJSON($table);
$version->e_version = $version_num;
$version->date_time = JFactory::getDate()->toSql();
$version->user_id = JFactory::getUser()->get('id');
if ($note) {
$version->note = $note;
}
// More
$clients = $type == 'search' ? array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order') : array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
$count = 0;
$e_more = array();
foreach ($clients as $i => $client) {
$name = 'e_more' . $i;
$fields = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_' . $type . '_field WHERE ' . $type . 'id = ' . $pk . ' AND client ="' . $client . '" ORDER BY ordering');
$positions = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_' . $type . '_position WHERE ' . $type . 'id = ' . $pk . ' AND client ="' . $client . '"');
$data = array('fields' => $fields, 'positions' => $positions);
$e_more[$i] = (string) count($fields);
$version->{$name} = JCckDev::toJSON($data);
}
$version->e_more = JCckDev::toJSON(array('fields' => $e_more));
// --
$version->check();
if (!$version->store()) {
return false;
}
return true;
}
示例4: prepareData
protected function prepareData()
{
$data = JRequest::get('post');
$data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
$client = $data['client'];
$P = 'template_' . $client;
$data[$P] = Helper_Workshop::getTemplateStyleInstance($data[$P], $data['template'], $data['template2'], $data['params'], $data['name'] . ' (' . $client . ')');
$data['options'] = JCckDev::toJSON(@$data['options']);
if (!$data['id']) {
$clients = array('search', 'filter', 'item');
foreach ($clients as $c) {
$P = 'template_' . $c;
if (!$data[$P]) {
$default = Helper_Workshop::getDefaultStyle('seb_one');
$data[$P] = $default->id;
}
}
if (isset($data['tpl_list']) && $data['tpl_list']) {
$default = Helper_Workshop::getDefaultStyle($data['tpl_list']);
$data['template_list'] = $default->id;
$data['content'] = 1;
unset($data['tpl_list']);
}
} else {
$doVersion = JCck::getConfig_Param('version_auto', 2);
if ($doVersion == 1 || $doVersion == 2 && Helper_Version::checkLatest('search', $data['id']) === true) {
Helper_Version::createVersion('search', $data['id']);
}
}
if ($client == 'list') {
$data['content'] = $data[$P] > 0 ? 1 : 0;
}
return $data;
}
示例5: g_onCCK_FieldConstruct
public function g_onCCK_FieldConstruct(&$data)
{
$db = JFactory::getDbo();
$data['display'] = 3;
$data['script'] = JRequest::getVar('script', '', '', 'string', JREQUEST_ALLOWRAW);
if (isset($data['selectlabel']) && $data['selectlabel'] == '') {
$data['selectlabel'] = ' ';
}
// JSON
if (isset($data['json']) && is_array($data['json'])) {
foreach ($data['json'] as $k => $v) {
if (is_array($v)) {
if (isset($v['options'])) {
$options = array();
if (count($v['options'])) {
foreach ($v['options'] as $option) {
$options[] = $option;
}
}
$v['options'] = $options;
}
$data[$k] = JCckDev::toJSON($v);
}
}
}
// STRING
if (isset($data['string']) && is_array($data['string'])) {
foreach ($data['string'] as $k => $v) {
if (is_array($v)) {
$string = '';
foreach ($v as $s) {
if ($s != '') {
$string .= $s . '||';
}
}
if ($string) {
$string = substr($string, 0, -2);
}
$data[$k] = $string;
}
}
}
if (empty($data['storage'])) {
$data['storage'] = 'none';
}
if ($data['storage'] == 'dev') {
$data['published'] = 0;
$data['storage_location'] = '';
$data['storage_table'] = '';
} else {
// No Table for None!
if ($data['storage'] == 'none') {
$data['storage_location'] = '';
$data['storage_table'] = '';
}
// Storage Field is required!
if (!@$data['storage_field']) {
if ($data['storage'] == 'none' && $data['storage_field_prev']) {
$data['storage_field'] = $data['storage_field_prev'];
} else {
$data['storage_field'] = $data['name'];
$dev_prefix = JCck::getConfig_Param('development_prefix', '');
if ($dev_prefix) {
$data['storage_field'] = str_replace($dev_prefix . '_', '', $data['storage_field']);
}
}
}
// Storage Field2 is better for flexibility!
if ($data['storage'] != 'standard' && $data['storage_field']) {
if (($cut = strpos($data['storage_field'], '[')) !== false) {
$data['storage_field2'] = substr($data['storage_field'], $cut + 1, -1);
$data['storage_field'] = substr($data['storage_field'], 0, $cut);
} else {
$data['storage_field2'] = '';
}
}
// Un-existing Fields must be mapped!
if (!isset($data['alterTable'])) {
$data['alterTable'] = true;
}
if ($data['storage_location'] == '' && $data['storage_table'] == '') {
$data['storage'] = 'none';
}
if ($data['alterTable']) {
$data['storage_alter_type'] = isset($data['storage_alter_type']) && $data['storage_alter_type'] ? $data['storage_alter_type'] : 'VARCHAR(255)';
$alter = isset($data['storage_alter']) && $data['storage_alter'] && in_array(1, $data['storage_alter']);
if (isset($data['storage_alter_table']) && $data['storage_alter_table'] && $alter) {
if ($data['storage_table'] && $data['storage_field']) {
$columns = $db->getTableColumns($data['storage_table']);
if (!isset($columns[$data['storage_field']])) {
if ($data['storage_alter_table'] == 2 && $data['storage_field_prev'] != '') {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field_prev']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
} else {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
}
} else {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
}
}
} else {
//.........这里部分代码省略.........
示例6: prepareData
protected function prepareData()
{
$data = JRequest::get('post');
$data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
if (!$data['id']) {
$data = $this->preStore($data);
}
// todo: call generic->store = JSON
if (isset($data['json']) && is_array($data['json'])) {
foreach ($data['json'] as $k => $v) {
if (is_array($v)) {
$data[$k] = JCckDev::toJSON($v);
}
}
}
if (isset($data['aliases']) && is_array($data['aliases'])) {
$data['aliases'] = implode('||', $data['aliases']);
}
// todo: call plugins->prepareStore()
$data['groups'] = $this->_implodeValues($data['groups'], $data['guest_only_group']);
$data['viewlevels'] = $this->_implodeValues($data['viewlevels'], $data['guest_only_viewlevel']);
return $data;
}
示例7: ajax_field_li
public function ajax_field_li($field = NULL, $client = '')
{
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
if (is_object($field)) {
$return = true;
$element = 'type';
$master = $client == 'content' || $client == 'intro' ? 'content' : 'form';
require_once JPATH_COMPONENT . '/helpers/helper_admin.php';
} else {
$return = false;
$fieldname = $app->input->get('fieldname', '');
$element = $app->input->get('element', 'type');
$client = $app->input->get('client', 'admin');
if ($element == 'search') {
$master = $client == 'order' ? 'order' : ($client == 'list' || $client == 'item' ? 'content' : 'search');
$lang->load('plg_cck_field_field_x');
$lang->load('plg_cck_field_group_x');
} else {
$master = $client == 'content' || $client == 'intro' ? 'content' : 'form';
}
$field = JCckDatabase::loadObject('SELECT a.id, a.title, a.name, a.folder, a.type, a.label FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"');
if (!is_object($field)) {
return;
}
require_once JPATH_COMPONENT . '/helpers/helper_admin.php';
require_once JPATH_COMPONENT . '/helpers/helper_workshop.php';
}
require_once JPATH_SITE . '/plugins/cck_field/' . $field->type . '/' . $field->type . '.php';
$lang->load('plg_cck_field_' . $field->type);
$style = array('1' => '', '2' => ' hide', '3' => ' hide', '4' => ' hide', '5' => ' hide', '6' => ' hide', '7' => ' hide');
$data = Helper_Workshop::getParams($element, $master, $client);
JCck::callFunc_Array('plgCCK_Field' . $field->type, 'onCCK_FieldConstruct_' . $element . $master, array(&$field, $style, $data));
$json = array();
ob_start();
Helper_Workshop::displayField($field);
$json["id"] = (int) $field->id;
$json["html"] = ob_get_clean();
if ($return !== false) {
return JCckDev::toJSON($json);
}
echo JCckDev::toJSON($json);
}
示例8: onCCK_FieldPrepareStore
public function onCCK_FieldPrepareStore(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
// Init
if (count($inherit)) {
$xk = isset($inherit['xk']) ? $inherit['xk'] : -1;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
$itemLink = isset($inherit['post']) ? $inherit['post'][$name] : @$config['post'][$name][$xk];
$itemText = isset($inherit['post']) ? @$inherit['post'][$name . '_text'] : @$config['post'][$name . '_text'][$xk];
$itemClass = isset($inherit['post']) ? @$inherit['post'][$name . '_class'] : @$config['post'][$name . '_class'][$xk];
$itemTarget = isset($inherit['post']) ? @$inherit['post'][$name . '_target'] : @$config['post'][$name . '_target'][$xk];
} else {
$name = $field->name;
$itemLink = @$config['post'][$name];
$itemText = @$config['post'][$name . '_text'];
$itemClass = @$config['post'][$name . '_class'];
$itemTarget = @$config['post'][$name . '_target'];
}
// Validate
$value = $itemLink;
$value = str_replace(array('<', '>', '"'), '', $value);
parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config);
$value = array_filter(array('link' => $itemLink, 'text' => $itemText, 'class' => $itemClass, 'target' => $itemTarget));
if (count($value) > 0 && ($value['link'] || $value['text'])) {
$value = JCckDev::toJSON($value);
} else {
$value = NULL;
}
// Set or Return
if ($return === true) {
return $value;
}
$field->value = $value;
parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config);
}
示例9: prepareData
protected function prepareData()
{
$data = JRequest::get('post');
$data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
$client = $data['client'];
$P = 'template_' . $client;
$data[$P] = Helper_Workshop::getTemplateStyleInstance($data[$P], $data['template'], $data['template2'], $data['params'], $data['name'] . ' (' . $client . ')');
$P = 'options_' . $client;
$data[$P] = JCckDev::toJSON(@$data['options']);
if (!$data['id']) {
$clients = array('admin', 'site', 'content', 'intro');
foreach ($clients as $client) {
$P = 'template_' . $client;
if (!$data[$P]) {
$default = Helper_Workshop::getDefaultStyle();
$data[$P] = $default->id;
}
}
} else {
$doVersion = JCck::getConfig_Param('version_auto', 2);
if ($doVersion == 1 || $doVersion == 2 && Helper_Version::checkLatest('type', $data['id']) === true) {
Helper_Version::createVersion('type', $data['id']);
}
}
return $data;
}
示例10: onCCK_FieldPrepareForm
//.........这里部分代码省略.........
if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
$onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"';
$chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete[' . $xk . ']" value="1" />';
}
} elseif ($name[strlen($name) - 1] == ']') {
//GroupX
$nameH = substr($name, 0, -1);
$form_more = '<input class="inputbox" type="hidden" id="' . $id . '_hidden" name="' . $nameH . '_hidden]" value="' . $value2 . '" />';
if ($options2['title_image'] == '1' && @$options2['multivalue_mode'] == '1') {
$form_more2 = self::_addFormText($id . '_title', $nameH . '_title]', $attr_input_text, $title_label, $image_title, self::$type);
}
if ($options2['custom_path'] == '1') {
$form_more3 = self::_addFormText($id . '_path', $nameH . '_path]', $attr_input_text, $path_label, $value2, self::$type, false);
$lock = '<a class="switch lock_img" href="javascript:void(0);"><span class="linkage linked"></span></a>';
//TODO!
}
if (@$options2['desc_image'] == '1' && @$options2['multivalue_mode'] == '1') {
$form_more4 = self::_addFormText($id . '_description', $nameH . '_description]', $attr_input_text, $desc_label, $image_desc, self::$type);
}
if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
$onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"';
$chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete]" value="1" />';
}
} else {
//Default
$form_more = '<input class="inputbox" type="hidden" id="' . $name . '_hidden" name="' . $name . '_hidden" value="' . $value2 . '" />';
if ($options2['title_image'] == '1' && @$options2['multivalue_mode'] == '1') {
$form_more2 = self::_addFormText($id . '_title', $name . '_title', $attr_input_text, $title_label, $image_title, self::$type);
}
if ($options2['custom_path'] == '1') {
$form_more3 = self::_addFormText($id . '_path', $name . '_path', $attr_input_text, $path_label, $value2, self::$type, false);
$lock = '<a class="switch lock_img" href="javascript:void(0);"><span class="linkage linked"></span></a>';
//TODO!
}
if (@$options2['desc_image'] == '1' && @$options2['multivalue_mode'] == '1') {
$form_more4 = self::_addFormText($id . '_description', $name . '_description', $attr_input_text, $desc_label, $image_desc, self::$type);
}
if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
$onchange = ' onchange="$(\'' . $name . '_delete\').checked=true;"';
$chkbox = '<input class="inputbox" type="checkbox" id="' . $name . '_delete" name="' . $name . '_delete" value="1" />';
}
}
$attr = 'class="' . $class . '" size="' . $field->size . '"' . $onchange . ($field->attributes ? ' ' . $field->attributes : '');
$form = '<input type="file" id="' . $id . '" name="' . $name . '" ' . $attr . ' />';
$params['custom_path'] = @$options2['custom_path'];
if ($chkbox != '') {
$form .= '<span title="' . JText::_('COM_CCK_CHECK_TO_DELETE_FILE') . '">' . $chkbox . '</span>';
//TODO
}
if ($options2['form_preview'] != -1 && $value['image_location']) {
$params['image_colorbox'] = '1';
$title_image = self::_getTitle($image_title, $title);
$desc_image = self::_getAlt($image_desc, $image_title, $title);
$title_colorbox = $desc_image;
if ($options2['form_preview'] > 1) {
if ($options2['form_preview'] == 2) {
$width = $options2['image_width'] ? 'width="' . $options2['image_width'] . '"' : '';
$height = $options2['image_height'] ? 'height="' . $options2['image_height'] . '"' : '';
$preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '" ' . $width . ' ' . $height . '>
<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . $value['image_location'] . '" />
</a>';
} else {
$thumb_location = str_replace($title, '_thumb' . ($options2['form_preview'] - 2) . '/' . $title, $value['image_location']);
$preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">
<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . $thumb_location . '" />
</a>';
}
} elseif ($options2['form_preview'] == 1) {
$preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">
<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . 'media/cck/images/16/icon-16-preview.png" />
</a>';
} else {
$preview = '<a class="cck_preview" id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">' . $title_image . '</a>';
}
$preview = self::_addFormPreview($id, JText::_('COM_CCK_PREVIEW'), $preview, self::$type);
} else {
$params['image_colorbox'] = '0';
}
$form = $form . $form_more . $lock . $form_more3 . $form_more2 . $form_more4 . $preview;
// Set
$value = $save_value;
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$field->text = $preview ? $preview : $value['image_location'];
parent::g_getDisplayVariation($field, $field->variation, $value['image_location'], $field->text, $form, $id, $name, '<input', '', $form_more, $config);
}
$field->value = JCckDev::toJSON($value);
self::_addScripts($field->id, $params);
// Return
if ($field->description) {
$field->description = str_replace('*legal_extensions*', $legal_ext, $field->description);
}
if ($return === true) {
return $field;
}
}
示例11: getTemplateStyleInstance
public static function getTemplateStyleInstance($id, $template, $template2, $params, $tag, $force = false)
{
if (!$template) {
return 0;
}
$default = self::getDefaultStyle($template);
if (is_array($params)) {
$params = JCckDev::toJSON($params);
}
$update = 0;
if ($template != $template2) {
$id = $default->id;
$update = 1;
//or ajax reload of template params..
}
if ($id == $default->id) {
if ($params != '{}' && $params != $default->params && $update != 1) {
$ck = JCckTable::getInstance('#__template_styles');
$ck->load($id);
if ($ck->id > 0) {
$ck->id = 0;
$ck->title = $ck->template . ' - ' . $tag;
$ck->params = $params;
$ck->store();
$id = $ck->id ? $ck->id : $id;
}
}
} else {
$ck = JCckTable::getInstance('#__template_styles');
$ck->load($id);
if ($ck->id > 0) {
if ($force != false) {
$ck->id = 0;
$ck->title = $ck->template . ' - ' . $tag;
}
$ck->params = $params;
$ck->store();
$id = $ck->id ? $ck->id : $id;
}
}
return $id;
}