本文整理汇总了PHP中JCckPluginField::g_onCCK_FieldPrepareForm方法的典型用法代码示例。如果您正苦于以下问题:PHP JCckPluginField::g_onCCK_FieldPrepareForm方法的具体用法?PHP JCckPluginField::g_onCCK_FieldPrepareForm怎么用?PHP JCckPluginField::g_onCCK_FieldPrepareForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCckPluginField
的用法示例。
在下文中一共展示了JCckPluginField::g_onCCK_FieldPrepareForm方法的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;
} else {
$id = $field->name;
}
$value = $value != '' ? (int) $value : (int) $field->defaultvalue;
$value = $value ? $value - 1 : 0;
$group_id = $field->location != '' ? $field->location : 'cck_tabs1';
// Prepare
$form = '';
if ($field->state) {
parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'group_id' => $group_id, 'id' => $id, 'identifier' => $field->bool3, 'label' => $field->label, 'url_actions' => $field->bool2, 'value' => $value));
}
// Set
$field->form = $form;
// todo: '<div class="tabbable tabs-left">'
$field->value = $field->label;
$field->label = '';
// 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;
}
//if ( $config['pk'] ) {
$dispatcher = JDispatcher::getInstance();
//}
// Prepare
$f = self::_getChild($field, $config);
$xn = $value ? is_array($value) ? count($value) : $value : $field->rows;
$form = array();
if ($xn > 0 && is_object($f)) {
for ($xi = 0; $xi < $xn; $xi++) {
$f_value = '';
if ($config['pk']) {
$table = $f->storage_table;
if ($table && !isset($config['storages'][$table])) {
$config['storages'][$table] = '';
$dispatcher->trigger('onCCK_Storage_LocationPrepareForm', array(&$f, &$config['storages'][$table], $config['pk']));
}
$dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi));
} else {
$f_value = @$value[$xi];
}
$inherit = array('id' => $name . '__' . $xi, 'name' => $name . '[]', 'xk' => $xi);
$clone = clone $f;
$results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, $f_value, &$config, $inherit, true));
$form[$xi] = $results[0];
$form[$xi]->name = $f->name;
}
if ($form[0]) {
$field->display = $form[0]->display;
}
// Empty
$inherit = array('id' => $name . '__' . '0', 'name' => $name . '[]', 'xk' => '0', 'empty' => true);
$clone = clone $f;
$results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, '', &$config, $inherit, true));
$form[$xi] = $results[0];
$form[$xi]->name = $f->name;
}
// Set
$field->form = $form;
$field->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 != '' ? $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;
}
}
示例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;
}
$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 ($value == 0) {
$form = '';
} else {
$class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
$xml = '
<form addfieldpath="/administrator/components/com_users/models/fields">
<field
type="' . self::$type2 . '"
name="' . $name . '"
id="' . $id . '"
label="' . htmlspecialchars($field->label) . '"
class="' . $class . '"
/>
</form>
';
$form = JForm::getInstance($id, $xml);
$form = $form->getInput($name, '', $value);
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
$field->text = JCckDatabase::loadResult('SELECT title FROM #__usergroups 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;
}
}
示例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;
$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;
}
}
示例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;
}
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;
}
}
示例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);
// Set
$field->form = '';
$field->value = '';
}
示例8: 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;
}
}
示例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;
$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;
}
}
示例10: 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;
}
}
示例11: 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;
}
}
示例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);
// Prepare
$app = JFactory::getApplication();
if ($app->input->get('option') == 'com_cck' && $app->input->get('view') == 'form') {
$form = '';
$value = '';
} else {
$alter = true;
$alter_type_default = isset($inherit['alter_type_value']) ? $inherit['alter_type_value'] : '';
if (isset($config['item']->id) && $config['item']->id && isset($config['item']->storage_table) && $config['item']->storage_table != '') {
$db = JFactory::getDbo();
$prefix = $db->getPrefix();
$table = str_replace('#__', $prefix, $config['item']->storage_table);
$tables = $db->getTableList();
if (in_array($table, $tables)) {
$column = JCckDatabase::loadObject('SHOW COLUMNS FROM ' . $table . ' WHERE field = "' . $config['item']->storage_field . '"');
$alter_type_value = isset($column->Type) ? strtoupper($column->Type) : $alter_type_default;
} else {
$alter = false;
$alter_type_value = $alter_type_default;
$alter_type_default = '';
}
} else {
$alter_type_value = $alter_type_default;
$alter_type_default = '';
}
ob_start();
include_once dirname(__FILE__) . '/tmpl/form.php';
$form = ob_get_clean();
}
// Set
$field->form = $form;
$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;
}
$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 . '"' . ($field->attributes ? ' ' . $field->attributes : '');
$form = '<textarea id="' . $id . '" name="' . $name . '" cols="' . $cols . '" rows="' . $rows . '" ' . $attr . '>' . $value . '</textarea>';
// Set
if (!$field->variation) {
$field->form = $form;
} 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;
}
}
示例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 = $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;
}
}
示例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 = htmlspecialchars($value, ENT_QUOTES);
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
parent::g_onCCK_FieldPrepareForm_Validation($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : '');
$attr = 'class="' . $class . '" size="' . $field->size . '" maxlenght="7"' . ($field->attributes ? ' ' . $field->attributes : '');
$form = '<input class="' . $class . '" type="text" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />';
// Set
if (!$field->variation) {
$field->form = $form;
self::_addScripts($id, array(), $config);
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}