本文整理汇总了PHP中JCckPluginField::g_addScriptDeclaration方法的典型用法代码示例。如果您正苦于以下问题:PHP JCckPluginField::g_addScriptDeclaration方法的具体用法?PHP JCckPluginField::g_addScriptDeclaration怎么用?PHP JCckPluginField::g_addScriptDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCckPluginField
的用法示例。
在下文中一共展示了JCckPluginField::g_addScriptDeclaration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
$xml = '
<form>
<field
type="' . self::$type2 . '"
client="administrator"
name="' . $name . '"
id="' . $id . '"
label="' . htmlspecialchars($field->label) . '"
class="' . $class . '"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
</form>
';
$form = JForm::getInstance($id, $xml);
$form = $form->getInput($name, '', $value);
$form = str_replace('<select ', '<select style="width: 150px"', $form);
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<select', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例2: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$assoc = JCckDevHelper::hasLanguageAssociations();
$form = '';
if ($assoc && $config['pk']) {
if (isset($config['base']->location) && $config['base']->location) {
$location = $config['base']->location;
} else {
$location = JCckdatabase::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $config['type'] . '"');
}
if (is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $location . '/classes/helper.php')) {
require_once JPATH_SITE . '/plugins/cck_storage_location/' . $location . '/classes/helper.php';
$form = JCck::callFunc_Array('plgCCK_Storage_Location' . $location . '_Helper', 'getAssociationsForm', array($id, $name, $config));
}
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
//
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例3: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
if ($config['pk']) {
// hardfix for now
$field->required = '';
} else {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
parent::g_onCCK_FieldPrepareForm_Validation($field, $id, $config, array('minSize' => true));
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
}
// Prepare
$class = 'inputbox password' . $validate . ($field->css ? ' ' . $field->css : '');
$maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : '';
$attr = 'class="' . $class . '" size="' . $field->size . '" autocomplete="off"' . $maxlen . ($field->attributes ? ' ' . $field->attributes : '');
$form = '<input type="password" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />';
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例4: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
if (trim($field->selectlabel)) {
if ($config['doTranslation']) {
$field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel)));
}
}
$options2 = JCckDev::fromJSON($field->options2);
if (isset($options2['prepareform']) && $options2['prepareform'] != '') {
$form = self::_eval($options2['prepareform'], 'form', $field, $value, $name, $id, $config);
} else {
$form = '';
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例5: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$options2 = JCckDev::fromJSON($field->options2);
$opts = self::_getOptionsList($options2, $field, $config);
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
if ($value != '') {
$class .= ' has-value';
}
$attr = 'class="' . $class . '"' . ($field->attributes ? ' ' . $field->attributes : '');
$form = count($opts) ? JHtml::_('select.genericlist', $opts, $name, $attr, 'value', 'text', $value, $id) : '';
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<select', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例6: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $field->defaultvalue;
// Prepare
$value = JCckDevHelper::replaceLive($value);
if ($field->bool8) {
$field->bool8 = $config['doTranslation'];
}
if ($field->bool8) {
$value = trim(preg_replace('/[^A-Za-z0-9_ ]/', '', strip_tags($value)));
if ($value) {
$value = JText::_('COM_CCK_' . str_replace(' ', '_', $value));
}
}
$form = htmlspecialchars_decode($value);
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例7: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
// Validate
$validate = '';
// Prepare
$class = 'inputbox hidden' . $validate . ($field->css ? ' ' . $field->css : '');
$form = '<input class="' . $class . '" type="hidden" id="' . $id . '" name="' . $name . '" value="' . $value . '" />';
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例8: onCCK_FieldPrepareForm
//.........这里部分代码省略.........
}
if ($optgroups !== false) {
$opts[] = JHtml::_('select.option', '</OPTGROUP>');
}
if ($field->bool4 == 2 || $field->bool4 == 3) {
if ($field->bool4 == 3) {
if ($static > 1 && isset($current) && isset($half) && isset($static) && isset($results)) {
for (; $current < $static; $current++) {
$opts[] = $results[$current];
}
}
} else {
$results = self::_getStaticOption($field, $field->options, $config);
foreach ($results as $result) {
$opts[] = $result;
}
}
}
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
if ($value != '') {
$class .= ' has-value';
}
$multi = @$field->bool3 ? ' multiple="multiple"' : '';
$size = !@$field->bool3 ? '1' : (@$field->rows ? $field->rows : count($opts));
$size = (int) $size > 1 ? ' size="' . $size . '"' : '';
$attr = 'class="' . $class . '"' . $size . $multi . ($field->attributes ? ' ' . $field->attributes : '');
$count = count($opts);
$form = '';
if ($field->variation == 'hidden_auto') {
if ($auto == $count && is_object($opts[$auto - 1])) {
$count = 0;
$field->variation = 'hidden';
$value = $opts[$auto - 1]->value;
if (!$field->live) {
JCckDevHelper::secureField($field, $value);
}
} else {
$field->variation = '';
}
}
if ($count) {
if ($attrib) {
$attr = array('id' => $id, 'list.attr' => $attr, 'list.select' => $value, 'list.translate' => false, 'option.attr' => 'data-cck', 'option.key' => 'value', 'option.text' => 'text');
$form = JHtml::_('select.genericlist', $opts, $name, $attr);
} else {
$form = JHtml::_('select.genericlist', $opts, $name, $attr, 'value', 'text', $value, $id);
}
}
/* tmp */
$jtext = $config['doTranslation'];
$config['doTranslation'] = 0;
/* tmp */
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$options_2 = self::_getOptionsList($options2, $field->bool2, $lang_code);
if ($field->options) {
if ($field->bool4 == 3) {
$current = 0;
$static_opts = explode('||', $field->options);
$static_opts1 = array();
$static_opts2 = array();
foreach ($static_opts as $static_opt) {
if ($current < $half) {
$static_opts1[] = $static_opt;
} else {
$static_opts2[] = $static_opt;
}
$current++;
}
$field->optionsList = implode('||', $static_opts1) . '||' . $options_2 . '||' . implode('||', $static_opts2);
} elseif ($field->bool4 == 2) {
$field->optionsList = $options_2 . '||' . $field->options;
} else {
$field->optionsList = $field->options . '||' . $options_2;
}
} else {
$field->optionsList = $options_2;
}
if ($field->bool4) {
$field->text = parent::g_getOptionText($value, $field->optionsList, $divider, $config);
} else {
$field->text = parent::g_getOptionText($value, $options_2, $divider, $config);
}
parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
}
/* tmp */
$config['doTranslation'] = $jtext;
/* tmp */
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例9: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$divider = $field->divider != '' ? $field->divider : ',';
if (!is_array($value)) {
$value = explode($divider, $value);
}
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$attr = array('option.attr' => 'data-cck');
$options = explode('||', $field->options);
if ($field->location) {
$attribs = explode('||', $field->location);
$attrib = count($attribs);
$options2 = json_decode($field->options2);
} else {
$attribs = array();
$attrib = 0;
}
if ($field->bool8) {
$field->bool8 = $config['doTranslation'];
}
if ($field->sorting == 1) {
natsort($options);
$optionsSorted = array_slice($options, 0);
} elseif ($field->sorting == 2) {
natsort($options);
$optionsSorted = array_reverse($options, true);
} else {
$optionsSorted = $options;
}
$opts = array();
if (count($optionsSorted)) {
foreach ($optionsSorted as $i => $val) {
if (trim($val) != '') {
$text = $val;
if (JString::strpos($val, '=') !== false) {
$opt = explode('=', $val);
$text = $opt[0];
$val = $opt[1];
}
if ($field->bool8 && trim($text) != '') {
$text = JText::_('COM_CCK_' . str_replace(' ', '_', trim($text)));
}
if ($attrib) {
$attr['attr'] = '';
foreach ($attribs as $k => $a) {
$attr['attr'] .= ' ' . $a . '="' . $options2->options[$i]->attr[$k] . '"';
}
$opts[] = JHtml::_('select.option', $val, $text, $attr);
} else {
$opts[] = JHtml::_('select.option', $val, $text, 'value', 'text');
}
}
}
}
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
$size = @$field->rows ? $field->rows : count($opts);
$attr = 'class="' . $class . '" size="' . $size . '" multiple="multiple"' . ($field->attributes ? ' ' . $field->attributes : '');
$form = '';
if (count($opts)) {
if ($attrib) {
$attr = array('id' => $id, 'list.attr' => $attr, 'list.select' => $value, 'list.translate' => false, 'option.attr' => 'data-cck', 'option.key' => 'value', 'option.text' => 'text');
$form = JHtml::_('select.genericlist', $opts, $name . '[]', $attr);
} else {
$form = JHtml::_('select.genericlist', $opts, $name . '[]', $attr, 'value', 'text', $value, $id);
}
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$doTranslation = $config['doTranslation'];
if ($config['doTranslation']) {
$config['doTranslation'] = $field->bool8;
}
$field->text = parent::g_getOptionText($value, $field->options, $divider, $config);
$config['doTranslation'] = $doTranslation;
parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
//.........这里部分代码省略.........
示例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: onCCK_FieldPrepareForm
//.........这里部分代码省略.........
if ($field->variation != 'toolbar_button') {
parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id));
}
if (!$task_auto) {
$click = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $click . '}';
}
$click = isset($config['submit']) ? ' onclick="' . $click . '"' : '';
} elseif ($task == 'save2redirect') {
$custom = '';
if (isset($options2['custom']) && $options2['custom']) {
$custom = JCckDevHelper::replaceLive($options2['custom']);
$custom = $custom ? '&' . $custom : '';
}
if ($config['client'] == 'search') {
$pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").attr(\'action\', \'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');');
} else {
$pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . ' input[name=\'config[url]\']").val(\'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');');
}
$click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : '';
} else {
$click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : '';
}
}
if ($field->attributes && strpos($field->attributes, 'onclick="') !== false) {
$matches = array();
$search = '#onclick\\=\\"([a-zA-Z0-9_\\(\\)\\\'\\;\\.]*)"#';
preg_match($search, $field->attributes, $matches);
if (count($matches) && $matches[0]) {
if ($matches[0] == $field->attributes) {
$field->attributes = substr(trim($field->attributes), 0, -1);
$click = ' ' . $field->attributes . '"';
$field->attributes = '';
} else {
$click = ' onclick="' . $matches[1] . '"';
$field->attributes = trim(str_replace($matches[0], '', $field->attributes));
}
}
}
$attr = 'class="' . $class . '"' . $click . ($field->attributes ? ' ' . $field->attributes : '');
if ($field->bool) {
$label = $value;
if (JCck::on()) {
if ($field->bool6 == 3) {
$label = '<span class="icon-' . $options2['icon'] . '"></span>';
$attr .= ' title="' . $value . '"';
} elseif ($field->bool6 == 2) {
$label = $value . "\n" . '<span class="icon-' . $options2['icon'] . '"></span>';
} elseif ($field->bool6 == 1) {
$label = '<span class="icon-' . $options2['icon'] . '"></span>' . "\n" . $value;
}
}
$type = $field->bool7 == 1 ? 'submit' : 'button';
$form = '<button type="' . $type . '" id="' . $id . '" name="' . $name . '" ' . $attr . '>' . $label . '</button>';
$tag = 'button';
} else {
$form = '<input type="submit" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />';
$tag = 'input';
}
if ($field->bool2 == 1) {
$alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
if ($config['client'] == 'search') {
$onclick = 'onclick="jQuery(\'#' . $config['formId'] . '\').clearForm();"';
$form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_RESET') . '">' . JText::_('COM_CCK_RESET') . '</a>';
} else {
$onclick = 'onclick="JCck.Core.submitForm(\'cancel\', document.getElementById(\'seblod_form\'));"';
$form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_CANCEL') . '">' . JText::_('COM_CCK_CANCEL') . '</a>';
}
} elseif ($field->bool2 == 2) {
$alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
$field2 = (object) array('link' => $options2['alt_link'], 'link_options' => $options2['alt_link_options'], 'id' => $id, 'name' => $name, 'text' => htmlspecialchars($options2['alt_link_text']), 'value' => '');
JCckPluginLink::g_setLink($field2, $config);
JCckPluginLink::g_setHtml($field2, 'text');
$form .= $alt . $field2->html;
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
if ($field->variation == 'toolbar_button') {
$field->form = '';
$icon = isset($options2['icon']) && $options2['icon'] ? 'icon-' . $options2['icon'] : '';
$onclick = $pre_task . 'JCck.Core.submit(\'' . $task . '\')';
if (!$task_auto) {
$onclick = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $onclick . '}';
}
$html = '<button class="btn btn-small' . ($field->css ? ' ' . $field->css : '') . '" onclick="' . $onclick . '" href="#"><i class="' . $icon . '"></i> ' . $value . '</button>';
parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'button' => array('html' => $html, 'icon' => @$options2['icon']), 'pre_task' => $pre_task, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id));
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<' . $tag, ' ', '', $config);
}
}
$field->value = '';
// Return
if ($return === true) {
return $field;
}
}
示例12: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
if (is_file(JPATH_LIBRARIES . '/joomla/html/html/category.php')) {
require_once JPATH_LIBRARIES . '/joomla/html/html/category.php';
}
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$app = JFactory::getApplication();
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
if (parent::g_isStaticVariation($field, $field->variation, true)) {
$form = '';
$field->text = '';
parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
} elseif ($field->variation == 'value') {
$form = '';
$field->text = JCckDatabase::loadResult('SELECT title FROM #__categories WHERE id = ' . (int) $value);
parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
} else {
$opt = '';
$options2 = JCckDev::fromJSON($field->options2);
if (trim($field->selectlabel)) {
if ($config['doTranslation']) {
$field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel)));
}
$opt = '<option value="' . ($field->storage_field == 'parent_id' ? 1 : '') . '">' . '- ' . $field->selectlabel . ' -' . '</option>';
}
if ($config['client'] == 'search') {
$opt .= '<option value="">' . '- ' . JText::_('COM_CCK_ALL_CATEGORIES') . ' -' . '</option>';
}
$multiple = $field->bool3 == 1 ? 'multiple="multiple"' : '';
$size = $field->rows ? $field->rows : 1;
$extension = $app->input->getString('extension', @$options2['extension']);
$extension = $extension ? $extension : 'com_content';
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
$xml = '
<form>
<field
type="' . self::$type2 . '"
name="' . $name . '"
id="' . $id . '"
label="' . htmlspecialchars($field->label) . '"
extension="' . $extension . '"
' . $multiple . '
class="' . $class . '"
size="' . $size . '"
>' . $opt . '</field>
</form>
';
$form = JForm::getInstance($id, $xml);
if ($config['client'] == 'admin' || $config['client'] == 'site' || $config['client'] == 'search') {
if ($config['pk']) {
$form->setFieldAttribute($name, 'action', 'core.edit');
$form->setFieldAttribute($name, 'action', 'core.edit.own');
} else {
$form->setFieldAttribute($name, 'action', 'core.create');
}
}
$form = $form->getInput($name, '', $value);
if ($field->attributes) {
$form = str_replace('<select', '<select ' . $field->attributes, $form);
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$field->text = JCckDatabase::loadResult('SELECT title FROM #__categories WHERE id = ' . (int) $value);
parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
}
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例13: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
if ($config['client'] == 'admin' && !$config['pk'] && !$value) {
$value = array(2);
} elseif ($value && is_string($value) && strpos($value, ',') !== false) {
$value = explode(',', $value);
} elseif (is_null($value)) {
$value = $field->defaultvalue;
}
if (!is_array($value)) {
$value = array($value);
}
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$class = $field->css ? ' class="' . $field->css . '"' : '';
$form = JHtml::_('access.usergroups', $name, $value);
// JForm UserGroups ?!
$form = '<div id="' . $name . '"' . $class . '>' . $form . '</div>';
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$values = is_array($value) ? implode(',', $value) : $value;
$field->text = JCckDatabase::loadColumn('SELECT title FROM #__usergroups WHERE id IN (' . (string) $values . ')');
$field->text = implode(',', $field->text);
//todo
parent::g_getDisplayVariation($field, $field->variation, $values, $field->text, $form, $id, $name, '<input', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例14: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $field->bool2 ? self::_p2nl($value) : self::_br2nl($value) : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
parent::g_onCCK_FieldPrepareForm_Validation($field, $id, $config, array('minSize' => true, 'maxSize' => true));
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$class = 'inputbox textarea' . $validate . ($field->css ? ' ' . $field->css : '');
$cols = $field->cols ? $field->cols : 25;
$rows = $field->rows ? $field->rows : 3;
$attr = 'class="' . $class . '"';
if ($field->attributes != '') {
if (strpos($field->attributes, 'J(') !== false) {
$matches = '';
$search = '#J\\((.*)\\)#U';
preg_match_all($search, $field->attributes, $matches);
if (count($matches[1])) {
foreach ($matches[1] as $text) {
$field->attributes = str_replace('J(' . $text . ')', JText::_('COM_CCK_' . str_replace(' ', '_', trim($text))), $field->attributes);
}
}
}
$attr .= ' ' . $field->attributes;
}
$form = '<textarea id="' . $id . '" name="' . $name . '" cols="' . $cols . '" rows="' . $rows . '" ' . $attr . '>' . $value . '</textarea>';
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$hidden = '<textarea class="inputbox" style="display: none;" id="_' . $id . '" name="' . $name . '" />' . $value . '</textarea>';
parent::g_getDisplayVariation($field, $field->variation, $value, self::_bn2br(self::_bn2clear($value)), $form, $id, $name, '<textarea', $hidden, '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例15: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$app = JFactory::getApplication();
$assoc = isset($app->item_associations) ? $app->item_associations : 0;
$form = '';
if ($assoc && $config['pk']) {
$languages = JLanguageHelper::getLanguages('lang_code');
// Create Form
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', $name);
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
$fieldset->addAttribute('description', 'COM_CONTENT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$fieldset->addAttribute('addfieldpath', '/administrator/components/com_content/models/fields');
$hasForm = false;
foreach ($languages as $tag => $language) {
if (empty($config['language']) || $tag != $config['language']) {
$hasForm = true;
$f = $fieldset->addChild('field');
$f->addAttribute('name', $tag);
$f->addAttribute('type', 'modal_article');
$f->addAttribute('language', $tag);
$f->addAttribute('label', $language->title);
$f->addAttribute('translate_label', 'false');
}
}
$form = JForm::getInstance($id, $addform->asXML());
if ($hasForm) {
$form->load($addform, false);
$associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $config['pk']);
if (count($associations)) {
foreach ($associations as $tag => $association) {
$form->setValue($tag, $name, $association->id);
}
}
if ($config['translate_id'] && isset($config['translate'])) {
$form->setValue($config['translate'], $name, $config['translate_id']);
}
}
// Render Form
$fields = $form->getFieldset('item_associations');
$form = '';
foreach ($fields as $f) {
$form .= '<div class="control-group"><div class="control-label">' . $f->label . '</div><div class="controls">' . $f->input . '</div></div>';
}
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
//
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}