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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
public function onCCK_FieldPrepareSearch(&$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 $options2 = JCckDev::fromJSON($field->options2); 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 = trim($value) != '' ? trim($value) : trim($field->defaultvalue); if (trim($value) == '' || $value == '0000-00-00 00:00:00') { $Jdate = ''; $value = ''; $storedDate = ''; } else { $options2['storage_format'] = isset($options2['storage_format']) ? $options2['storage_format'] : '0'; $value = $options2['storage_format'] == '0' ? strtotime($value) : $value; $Jdate = date('Y-m-d H:i:s', $value); $storedDate = date('Ymd', $value); $value = date(@$options2['format'], $value); } $default_hour = @$options2['default_hour']; $default_min = @$options2['default_min']; $default_sec = @$options2['default_sec']; $format_jscal2 = self::_toJScal2Format(array('format' => @$options2['format'], 'default_hour' => $default_hour, 'default_min' => $default_min, 'default_sec' => $default_sec, 'time' => $options2['time'])); $format_search = self::_toSearchFormat(array('format' => @$options2['format'], 'default_hour' => $default_hour, 'default_min' => $default_min, 'default_sec' => $default_sec, 'time' => $options2['time'])); // 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 (strpos($name, '[]') !== false) { //FieldX $nameH = substr($name, 0, -2); $form_more = '<input class="inputbox" type="hidden" id="' . $id . '" name="' . $nameH . '[]" value="' . $Jdate . '" />'; } elseif ($name[strlen($name) - 1] == ']') { //GroupX $nameH = substr($name, 0, -1); $form_more = '<input class="inputbox" type="hidden" id="' . $id . '" name="' . $nameH . ']" value="' . $Jdate . '" />'; } else { //Default $form_more = '<input class="inputbox" type="hidden" id="' . $id . '" name="' . $name . '" value="' . $Jdate . '" />'; } $class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : ''); $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : ''; $readonly = $field->bool2 ? '' : ' readonly="readonly"'; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $readonly . $maxlen . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<input type="text" id="' . $id . '_hidden" name="' . $name . '_hidden" value="' . $value . '" ' . $attr . ' />' . $form_more; // Set if (!$field->variation) { if (JCck::on()) { $form .= '<button class="btn" id="' . $id . '_hidden-trigger"><span class="icon-calendar"></span></button>'; } else { $form .= '<img src="' . self::$path . 'assets/images/calendar.png" alt="Calendar" class="calendar" id="' . $id . '_hidden-trigger" />'; } $form .= self::_addScript($id, array('dateFormat' => $format_jscal2, 'time' => @$options2['time'], 'weekNumbers' => @$options2['week_numbers'], 'timePos' => @$options2['time_pos'], 'dates' => @$options2['dates'], 'storedDate' => $storedDate, 'default_hour' => $default_hour, 'default_min' => $default_min, 'default_sec' => $default_sec, 'type' => 'search', 'input_text' => $field->bool2)); $field->form = $form; $field->markup_class .= ' input-append'; self::_addScripts(array('theme' => @$options2['theme'])); } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config); } // Set $field->value = $Jdate == '' ? '' : date($format_search, strtotime($Jdate)); // Return if ($return === true) { return $field; } }
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 $opts = array(); if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } $opts[] = JHtml::_('select.option', '', '- ' . $field->selectlabel . ' -', 'value', 'text'); } $options = '"' . str_replace('||', '","', $field->options) . '"'; $opts2 = JCckDatabase::loadObjectList('SELECT title AS text, id AS value FROM ' . self::$table . ' WHERE catid IN(' . $options . ') AND state = 1 ORDER BY title', 'value'); if (count($opts2)) { $opts = array_merge($opts, $opts2); } $class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : ''); $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 { $field->text = isset($opts2[$value]->text) ? $opts2[$value]->text : $value; parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
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; } $field->defaultvalue = '{"imageUrl":"","areas":[{"href":"","coords":[]}]}'; $value = json_decode($value) != NULL ? json_decode($value) : json_decode($field->defaultvalue); $value_raw = json_encode($value); // 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 : ''); //$maxlen = ( $field->maxlength > 0 ) ? ' maxlength="'.$field->maxlength.'"' : ''; $xml = ' <form> <field type="media" name="' . $name . '" id="img_' . $id . '" label="' . htmlspecialchars($field->label) . '" class="' . $class . '" size="10" /> </form> '; $imgurl = ""; if (isset($value->imageUrl)) { $imgurl = $value->imageUrl; } $imginput = JForm::getInstance($id, $xml); $imginput = $imginput->getInput($name, '', $imgurl); $attr = 'class="' . $class . '" size="' . $field->size . '"' . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<input type="hidden" id="' . $id . '" name="' . $name . '" value="' . htmlentities($value_raw) . '" ' . $attr . ' />'; $form = ' <div id="imgmap_' . $id . '"> <div class="htmlimgmap_img">' . $imginput . '</div> <div>' . $form . '</div> <div class="htmlimgmap_ctrls"> <button class="btn remove"><span class="icon-remove"></span> remove</button> <button class="btn reset"><span class="icon-loop"></span> reset</button> <button class="btn add"><span class="icon-save-new"></span> add</button> </div> <div class="htmlimgmap"></div> <div class="htmlimgmap_layers"> <ul class="sortable"></ul> </div> </div> '; // Set if (!$field->variation) { $field->form = $form; self::_addScripts($id, array(), $config, $value_raw); 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; } }
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; } }
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 = JCckDev::fromJSON($value); $value['text'] = htmlspecialchars(@$value['text'], ENT_QUOTES); $preview = ''; // 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)); $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : ''; } // Prepare $class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : ''); $class2 = 'inputbox text'; $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : ''; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $maxlen . ($field->attributes ? ' ' . $field->attributes : ''); $attr2 = 'class="' . $class2 . '" size="' . $field->size . '"' . $maxlen; $options2 = JCckDev::fromJSON($field->options2); if ($config['doTranslation']) { $link_label = trim(@$options2['link_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['link_label']))) : ''; $text_label = trim(@$options2['text_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['text_label']))) : ''; } else { $link_label = @$options2['link_label'] != '' ? trim($options2['link_label']) : ''; $text_label = @$options2['text_label'] != '' ? $options2['text_label'] : ''; } if (strpos($name, '[]') !== false) { //FieldX $nameH = substr($name, 0, -2); $nameLink = $name; $nameText = $nameH . '_text[]'; $nameClass = $nameH . '_class[]'; $nameTarget = $nameH . '_target[]'; } elseif ($name[strlen($name) - 1] == ']') { //GroupX $nameH = substr($name, 0, -1); $nameLink = $name; $nameText = $nameH . '_text]'; $nameClass = $nameH . '_class]'; $nameTarget = $nameH . '_target]'; } else { //Default $nameH = $name; $nameLink = $name; $nameText = $nameH . '_text'; $nameClass = $nameH . '_class'; $nameTarget = $nameH . '_target'; } $form = self::_addInput($id, $nameLink, $attr, $link_label, @$value['link'], 'link'); if ($field->bool2 == 1) { $form .= self::_addInput($id . '_text', $nameText, $attr2, $text_label, @$value['text'], 'text'); } if ($field->bool3 == 1) { $form .= self::_addInput($id . '_class', $nameClass, $attr2, JText::_('COM_CCK_CLASS'), @$value['class'], 'class'); } if ($field->bool4 == 1) { $form .= self::_addSelect($id . '_target', JText::_('COM_CCK_TARGET'), 'target', 'core_options_target', @$value['target'], array('storage_field' => $nameTarget)); } if ($field->bool5 == 1 && $config['pk'] && @$value['link'] != '') { $p_link = @$value['link']; $p_text = @$value['text'] ? @$value['text'] : $p_link; $p_link = strpos($p_link, 'index.php') === 0 ? $p_link : (strpos($p_link, 'http://') === false && strpos($p_link, 'https://') === false ? 'http://' . $p_link : $p_link); $preview = '<a href="' . $p_link . '" class="cck_preview" target="_blank">' . $p_text . '</a>'; $preview = self::_addPreview($id . '_preview', JText::_('COM_CCK_PREVIEW'), $preview, 'preview'); } // Set if (!$field->variation) { $field->form = $form . $preview; 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; } }
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); // Preview Video $options2 = JCckDev::fromJSON($field->options2); $preview = isset($options2['video_preview']) ? $options2['video_preview'] : '0'; $width = isset($options2['video_width']) ? $options2['video_width'] : '300'; $height = isset($options2['video_height']) ? $options2['video_height'] : '300'; $video = ''; if ($preview == 1) { $v_int = preg_match('/\\?v=.*/i', $value, $v_value); if ($v_int > 0) { $v_tag = str_replace('?v=', '', $v_value[0]); } else { $v_tag = $value; } if (isset($v_tag) && $v_tag != '') { if ($field->bool2 == 0) { $video .= '<iframe width="' . $width . '" height="' . $height . '" '; $video .= 'frameborder="0" allowfullscreen src="'; $video .= 'http://www.youtube.com/embed/' . $v_tag; $video .= '" ></iframe>'; } else { $video .= '<object width="' . $width . '" height="' . $height . '">'; $video .= '<param value="' . $value . '" name="movie"><param value="transparent" name="wmode">'; $video .= '<embed width="' . $width . '" height="' . $height . '" wmode="transparent" type="application/x-shockwave-flash" src="'; $video .= 'http://www.youtube.com/v/' . $v_tag; $video .= '"></object>'; } $video .= '<div class="clear"></div>'; } } // 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)); $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : ''; } // Prepare $class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : ''); $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : ''; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $maxlen . ($field->attributes ? ' ' . $field->attributes : ''); $form = $video . '<input type="text" 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; } }
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; $name = @$field->bool3 ? $name . '[]' : $name; $divider = ''; if ($field->bool3) { $divider = $field->divider != '' ? $field->divider : ','; if (!is_array($value)) { $value = explode($divider, $value); } } else { $field->divider = ''; } // 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); } else { $attr = array('option.attr' => 'data-cck'); $auto = 1; $items = array(); $opts = array(); if ($field->location) { $attribs = explode('||', $field->location); $attrib = count($attribs); } else { $attribs = array(); $attrib = 0; } if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } if ($attrib) { $attr['attr'] = ''; foreach ($attribs as $k => $a) { $attr['attr'] .= ' ' . $a . '=""'; } $opts[] = JHtml::_('select.option', '', '- ' . $field->selectlabel . ' -', $attr); } else { $opts[] = JHtml::_('select.option', '', '- ' . $field->selectlabel . ' -', 'value', 'text'); } if ($field->required) { $auto++; } } $count2 = JCck::getConfig_Param('development_attr', 6); $opt_attr = ''; $opt_attrs = array(); $options2 = JCckDev::fromJSON($field->options2); $optgroups = false; if ($field->bool4 == 1 || $field->bool4 == 3) { $results = self::_getStaticOption($field, $field->options, $config, $optgroups); $static = count($results); if ($field->bool4 == 3) { if ($static > 0) { $current = 0; $half = (int) ($static / 2); $half = $static % 2 ? $half + 1 : $half; for ($current = 0; $current < $half; $current++) { $opts[] = $results[$current]; } } } else { foreach ($results as $result) { $opts[] = $result; } } } if ($field->bool2 == 0) { $opt_table = isset($options2['table']) ? ' FROM ' . $options2['table'] : ''; $opt_name = isset($options2['name']) ? $options2['name'] : ''; $opt_value = isset($options2['value']) ? $options2['value'] : ''; if ($count2) { for ($i = 1; $i <= $count2; $i++) { $opt_attrs[] = isset($options2['attr' . $i]) && $options2['attr' . $i] != '' ? $options2['attr' . $i] : ''; } } $opt_where = @$options2['where'] != '' ? ' WHERE ' . $options2['where'] : ''; $opt_orderby = @$options2['orderby'] != '' ? ' ORDER BY ' . $options2['orderby'] . ' ' . (@$options2['orderby_direction'] != '' ? $options2['orderby_direction'] : 'ASC') : ''; $opt_limit = @$options2['limit'] > 0 ? ' LIMIT ' . $options2['limit'] : ''; // Language Detection $count2 = count($opt_attrs); $lang_code = ''; self::_languageDetection($lang_code, $value, $options2); $opt_value = str_replace('[lang]', $lang_code, $opt_value); $opt_name = str_replace('[lang]', $lang_code, $opt_name); $opt_where = str_replace('[lang]', $lang_code, $opt_where); $opt_orderby = str_replace('[lang]', $lang_code, $opt_orderby); $opt_group = ''; if ($count2) { foreach ($opt_attrs as $k => $v) { if ($v != '') { $v = str_replace('[lang]', $lang_code, $v) . ' AS attr' . ($k + 1); $opt_attr .= ',' . $v; } } if ($opt_attr == ',') { $opt_attr = ''; } } if ($opt_name && $opt_value && $opt_table) { $query = 'SELECT ' . $opt_name . ',' . $opt_value . $opt_attr . $opt_table . $opt_where . $opt_orderby . $opt_limit; $query = JCckDevHelper::replaceLive($query); if ($config['client'] == '' || $config['client'] == 'dev') { $tables = JCckDatabaseCache::getTableList(); $prefix = JFactory::getDbo()->getPrefix(); $items = in_array(str_replace('#__', $prefix, $options2['table']), $tables) ? JCckDatabase::loadObjectList($query) : array(); } else { $items = JCckDatabase::loadObjectList($query); } } } else { if (@$options2['query'] != '') { // Language Detection $lang_code = ''; self::_languageDetection($lang_code, $value, $options2); $query = str_replace('[lang]', $lang_code, $options2['query']); $query = JCckDevHelper::replaceLive($query); if (strpos($query, ' value ') !== false || strpos($query, 'AS value') !== false || strpos($query, ' value,') !== false) { $items = JCckDatabase::loadObjectList($query); } else { $opts2 = JCckDatabase::loadColumn($query); if (count($opts2)) { $opts2 = array_combine(array_values($opts2), $opts2); } $opts = array_merge($opts, $opts2); } } $opt_name = 'text'; $opt_value = 'value'; $opt_group = 'optgroup'; } if (count($items)) { if ($opt_group) { $group = ''; foreach ($items as $o) { if (isset($o->optgroup) && $o->optgroup != $group) { if ($group) { $opts[] = JHtml::_('select.option', '</OPTGROUP>'); } $opts[] = JHtml::_('select.option', '<OPTGROUP>', $o->optgroup); $group = $o->optgroup; } if ($attrib) { $attr['attr'] = ''; foreach ($attribs as $k => $a) { $ka = 'attr' . ($k + 1); if (isset($o->{$ka})) { $va = $o->{$ka}; } else { $ka = isset($options2['attr' . ($k + 1)]) ? $options2['attr' . ($k + 1)] : ''; $va = $ka != '' && isset($o->{$ka}) ? $o->{$ka} : ''; } $attr['attr'] .= ' ' . $a . '="' . $va . '"'; } $opts[] = JHtml::_('select.option', $o->value, $o->text, $attr); } else { $opts[] = JHtml::_('select.option', $o->value, $o->text, 'value', 'text'); } } if ($group) { $opts[] = JHtml::_('select.option', '</OPTGROUP>'); } } else { if ($attrib) { foreach ($items as $o) { $attr['attr'] = ''; foreach ($attribs as $k => $a) { $ka = 'attr' . ($k + 1); if (isset($o->{$ka})) { $va = $o->{$ka}; } else { $ka = isset($options2['attr' . ($k + 1)]) ? $options2['attr' . ($k + 1)] : ''; $va = $ka != '' && isset($o->{$ka}) ? $o->{$ka} : ''; } $attr['attr'] .= ' ' . $a . '="' . $va . '"'; } $opts[] = JHtml::_('select.option', $o->{$opt_value}, $o->{$opt_name}, $attr); } } else { foreach ($items as $o) { $opts[] = JHtml::_('select.option', $o->{$opt_value}, $o->{$opt_name}, 'value', 'text'); } } } } 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; } }
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); } $field->value = $value; // Return if ($return === true) { return $field; } }
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 = array(); if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } $opts[] = JHtml::_('select.option', '', '- ' . $field->selectlabel . ' -', 'value', 'text'); } if (isset($options2['first']) && $options2['first'] != '') { if (strpos($options2['first'], '=') !== false) { $opt = explode('=', $options2['first']); $opt[0] = trim($opt[0]); $opts[] = JHtml::_('select.option', $opt[1], JText::_('COM_CCK_' . str_replace(' ', '_', $opt[0])), 'value', 'text'); } else { $opts[] = JHtml::_('select.option', $options2['first'], $options2['first'], 'value', 'text'); } } $val = $options2['start'] ? $options2['start'] : 0; $step = $options2['step'] ? $options2['step'] : 0; $limit = $options2['end'] ? $options2['end'] : 0; $math = isset($options2['math']) ? $options2['math'] : NULL; $force = isset($options2['force_digits']) && $options2['force_digits'] ? $options2['force_digits'] : 0; if ($step && $val || $step && $limit || $step && $val && $limit) { while (69) { if ($force) { $val = str_pad($val, $force, '0', STR_PAD_LEFT); } if ($math == 0 && $val <= $limit) { $opts[] = JHtml::_('select.option', $val, $val, 'value', 'text'); $val = $val + $step; } elseif ($math == 1 && $val <= $limit) { $opts[] = JHtml::_('select.option', $val, $val, 'value', 'text'); $val = $val * $step; } elseif ($math == 2 && $val >= $limit) { $opts[] = JHtml::_('select.option', $val, $val, 'value', 'text'); $val = $val - $step; } elseif ($math == 3 && $val > $limit) { $opts[] = JHtml::_('select.option', $val, $val, 'value', 'text'); $val = floor($val / $step); } else { break; } } } if (isset($options2['last']) && $options2['last'] != '') { if (strpos($options2['last'], '=') !== false) { $opt = explode('=', $options2['last']); $opt[0] = trim($opt[0]); $opts[] = JHtml::_('select.option', $opt[1], JText::_('COM_CCK_' . str_replace(' ', '_', $opt[0])), 'value', 'text'); } else { $opts[] = JHtml::_('select.option', $options2['last'], $options2['last'], 'value', 'text'); } } $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; } }
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; $name = strpos($name, '[]') !== false ? substr($name, 0, -1) . $inherit['xk'] . ']' : $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); parent::g_onCCK_FieldPrepareForm_Validation($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'); } } } } $count = count($opts); if ($field->bool) { $orientation = ' vertical'; $field->bool2 = !$field->bool2 ? 1 : $field->bool2; $modulo = $count % $field->bool2; $columns = (int) ($count / (!$field->bool2 ? 1 : $field->bool2)); } else { $orientation = ''; } $class = 'checkboxes' . $orientation . ($field->css ? ' ' . $field->css : ''); $attr = 'class="' . $class . '"' . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<fieldset id="' . $id . '" ' . $attr . '>'; if (JCck::on()) { $attr = 'class="checkbox' . $validate . '" size="1"'; } else { $attr = 'class="inputbox checkbox' . $validate . '" size="1"'; } $attr_key = 'data-cck'; if ($field->bool && $field->bool2 > 1 && $count > 1) { $k = 0; foreach ($opts as $i => $o) { if ($i == 0) { $form .= '<div class="cck-fl">'; } elseif ($modulo && $k % ($columns + 1) == 0 || $modulo <= 0 && $k % $columns == 0) { $form .= '</div><div class="cck-fl">'; $modulo--; $k = 0; } $k++; $attr2 = isset($o->{$attr_key}) ? $o->{$attr_key} : ''; $checked = in_array((string) $o->value, (array) $value) ? ' checked="checked" ' : ''; $form .= '<input type="checkbox" id="' . $id . $i . '" name="' . $name . '[]" value="' . $o->value . '" ' . $checked . $attr . $attr2 . ' />'; $form .= '<label for="' . $id . $i . '">' . $o->text . '</label>'; } $form .= '</div>'; } else { if ($count == 1 && strpos($optionsSorted[0], '=') === false) { foreach ($opts as $i => $o) { $attr2 = isset($o->{$attr_key}) ? $o->{$attr_key} : ''; $checked = in_array((string) $o->value, (array) $value) ? ' checked="checked" ' : ''; $form .= '<input type="checkbox" id="' . $id . $i . '" name="' . $name . '[]" value="' . $o->value . '" ' . $checked . $attr . $attr2 . ' />'; } } else { foreach ($opts as $i => $o) { $attr2 = isset($o->{$attr_key}) ? $o->{$attr_key} : ''; $checked = in_array((string) $o->value, (array) $value) ? ' checked="checked" ' : ''; $form .= '<input type="checkbox" id="' . $id . $i . '" name="' . $name . '[]" value="' . $o->value . '" ' . $checked . $attr . $attr2 . ' />'; $form .= '<label for="' . $id . $i . '">' . $o->text . '</label>'; } } } $form .= '</fieldset>'; // 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, '<input', '', '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
public function g_onCCK_FieldPrepareStore_Validation(&$field, $name, &$value, &$config = array()) { if ($config['doValidation'] == 1 || $config['doValidation'] == 3) { if ($field->required) { plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareStore($field, $name, $value, $config); } $validation = $field->validation; if (!$validation) { return; } require_once JPATH_PLUGINS . '/cck_field_validation/' . $validation . '/' . $validation . '.php'; JCck::callFunc_Array('plgCCK_Field_Validation' . $validation, 'onCCK_Field_ValidationPrepareStore', array(&$field, $name, &$value, &$config)); } }
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); // Captcha only for Guest $user = JFactory::getUser(); if ($user->get('id') > 0 && $user->guest != 1) { $field->form = ''; $field->value = ''; $field->display = 0; return; } // 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_QUOTES); // 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)); $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : ''; } // Prepare $math = array(1 => '+', 2 => '*', 4 => '-'); $num1 = rand(1, 5); $num2 = rand(6, 10); shuffle($math); $glue = $math[0]; $eval = $num2 . $glue . $num1; eval("\$secure_session_var=" . $eval . ";"); $ask = '<span class="variation_value">' . $num2 . ' ' . $glue . ' ' . $num1 . ' = </span>'; if (empty($field->description)) { $field->description = JText::_('COM_CCK_CAPTCHA_DO_THE_MATH'); } $class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : ''); $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : ''; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $maxlen . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<input type="text" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />'; // Set if (!$field->variation) { $field->form = $ask . $form; // Special $session = JFactory::getSession(); $session->set('secure_cckaptcha', $name); $session->set('secure_' . $name, $secure_session_var); 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; } }
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; $xk = isset($inherit['xk']) ? $inherit['xk'] : ''; } else { $id = $field->name; $name = $field->name; $xk = ''; } // Validate $validate = ''; if ($config['doValidation'] > 1) { plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config); $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : ''; } // Prepare $value = trim($value); if ($value == '') { $value = array('file_location' => '', 'file_title' => ''); } else { $value_json = JCckDev::fromJSON($value); if (is_array($value_json) && !empty($value_json)) { $value_json['file_location'] = trim($value_json['file_location']); $value = $value_json; } else { $value = array('file_location' => $value, 'file_title' => ''); } } $save_value = $value; $options2 = JCckDev::fromJSON($field->options2); if ($config['doTranslation']) { $title_label = trim(@$options2['title_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['title_label']))) : ''; } else { $title_label = @$options2['title_label']; } $value2 = @$options2['storage_format'] ? $options2['path'] : ''; if (@$options2['storage_format'] && $config['pk']) { $value2 .= @$options2['path_content'] ? $config['pk'] . '/' : ''; } $value2 .= $value['file_location'] != '' ? $value['file_location'] : ''; $location = $value['file_location'] != '' ? $value['file_location'] : $field->defaultvalue; $value3 = @$options2['storage_format'] ? substr($value2, strrpos($value2, '/') + 1) : ($value2 ? $value2 : $options2['path']); if (!@$options2['storage_format'] && $config['pk']) { if (strpos($value2, '/' . $config['pk'] . '/') === false && $options2['path_content']) { $value2 = $config['pk'] . '/' . $value2; } if (strpos($value2, $options2['path']) === false) { $value2 = $options2['path'] . $value2; } if (strpos($location, '/' . $config['pk'] . '/') === false && $options2['path_content']) { $location = $config['pk'] . '/' . $location; } if (strpos($location, $options2['path']) === false) { $location = $options2['path'] . $location; } } $fold_3 = @$options2['storage_format'] && $config['pk'] ? ' ( ' . substr($value2, 0, strrpos($value2, '/') + 1) . ' )' : ''; $chkbox = ''; $onchange = ''; $preview = ''; $form_more2 = ''; $form_more3 = ''; $lock = ''; $file_title = trim(@$value['file_title']); $file_title = htmlspecialchars($file_title, ENT_QUOTES); $params = array(); $legal_ext = isset($options2['media_extensions']) ? $options2['media_extensions'] : 'custom'; if ($legal_ext == 'custom') { $legal_ext = $options2['legal_extensions']; } else { $legal_ext = JCck::getConfig_Param('media_' . $legal_ext . '_extensions'); if (!$legal_ext) { $legal_ext = $options2['legal_extensions']; } } $class = 'inputbox file' . $validate . ($field->css ? ' ' . $field->css : ''); $attr_input_text = 'class="inputbox text" size="' . $field->size . '"'; if (strpos($name, '[]') !== false) { //FieldX $nameH = substr($name, 0, -2); $form_more = '<input class="inputbox" type="hidden" id="' . $id . '_hidden" name="' . $nameH . '_hidden[]" value="' . $location . '" />'; if ($options2['custom_path'] == '1') { $form_more2 = self::_addFormText($id . '_path', $nameH . '_path[]', $attr_input_text, @$options2['path_label'] . $fold_3, $value3, 'upload_file', false); } if ($options2['delete_box'] && $value['file_location'] && $location != '') { $onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"'; $chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete[' . $xk . ']" value="1" />'; } if ($options2['title_file'] == '1' && $options2['multivalue_mode'] == '1') { $form_more3 = self::_addFormText($id . '_title', $nameH . '_title[]', $attr_input_text, $title_label, $file_title, 'upload_file'); } } 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="' . $location . '" />'; if ($options2['custom_path'] == '1') { $form_more2 = self::_addFormText($id . '_path', $nameH . '_path]', $attr_input_text, @$options2['path_label'] . $fold_3, $value3, 'upload_file', false); } if ($options2['delete_box'] && $value['file_location'] && $location != '') { $onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"'; $chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete]" value="1" />'; } if ($options2['title_file'] == '1' && $options2['multivalue_mode'] == '1') { $form_more3 = self::_addFormText($id . '_title', $nameH . '_title]', $attr_input_text, $title_label, $file_title, 'upload_file'); } } else { //Default $form_more = '<input class="inputbox" type="hidden" id="' . $name . '_hidden" name="' . $name . '_hidden" value="' . $location . '" />'; if ($options2['custom_path'] == '1') { $form_more2 = self::_addFormText($id . '_path', $name . '_path', $attr_input_text, @$options2['path_label'] . $fold_3, $value3, 'upload_file', false); } if ($options2['delete_box'] && $value['file_location'] && $location != '') { $onchange = ' onchange="$(\'' . $name . '_delete\').checked=true;"'; $chkbox = '<input class="inputbox" type="checkbox" id="' . $name . '_delete" name="' . $name . '_delete" value="1" />'; } if ($options2['title_file'] == '1' && $options2['multivalue_mode'] == '1') { $form_more3 = self::_addFormText($id . '_title', $name . '_title', $attr_input_text, $title_label, $file_title, 'upload_file'); } } $params['custom_path'] = @$options2['custom_path']; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $onchange . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<input type="file" id="' . $id . '" name="' . $name . '" ' . $attr . ' />'; if ($options2['custom_path'] == '1') { $lock = '<a class="switch lock_file" href="javascript:void(0);"><span class="linkage linked"></span></a>'; //TODO } if ($chkbox != '') { $form .= '<span title="' . JText::_('COM_CCK_CHECK_TO_DELETE_FILE') . '">' . $chkbox . '</span>'; //TODO } $form = $form . $form_more . $lock . $form_more2 . $form_more3; if ($options2['preview'] != -1 && $value['file_location'] && $value2 != '') { $label = JText::_('COM_CCK_PREVIEW'); $link = 'javascript: SqueezeBox.fromElement(\'' . JURI::root() . $value2 . '\', {handler: \'image\'});'; $title = $value['file_title'] != '' ? $value['file_title'] : (strrpos($value2, '/') === false ? $value2 : substr($value2, strrpos($value2, '/') + 1)); if ($options2['preview'] == 8) { $label = ''; $preview = '<span class="cck_preview">' . $title . '</span>'; } else { if ($options2['preview'] == 1) { $preview = '<a href="' . JURI::root() . $value2 . '" target="_blank" title="' . $value['file_title'] . '"><img src="' . JURI::root() . 'media/cck/images/16/icon-16-preview.png" alt="" title=""/></a>'; } else { $preview = '<a class="cck_preview" href="' . JURI::root() . $value2 . '" target="_blank" title="' . $value['file_title'] . '">' . $title . '</a>'; } } $preview = self::_addFormPreview($id, $label, $preview, 'upload_file'); $form .= $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; $value2 = is_array($value) && isset($value['file_location']) ? $value['file_location'] : $value; parent::g_getDisplayVariation($field, $field->variation, $value2, $field->text, $form, $id, $name, '<input', '', $form_more, $config); } $field->value = $value; self::_addScripts($params); // Return if ($field->description) { $field->description = str_replace('*legal_extensions*', $legal_ext, $field->description); } if ($return === true) { return $field; } }
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 (JCck::isSite() === true && !$config['pk'] && ($config['client'] == 'admin' || $config['client'] == 'site') && $value != '') { $levels = JCck::getSite()->viewlevels; $levels = explode(',', $levels); sort($levels); $value = $levels[0]; } $opt = ''; if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } $opt = '<option value="">' . '- ' . $field->selectlabel . ' -' . '</option>'; } $class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : ''); $xml = ' <form> <field type="' . self::$type2 . '" name="' . $name . '" id="' . $id . '" label="' . htmlspecialchars($field->label) . '" extension="com_content" class="' . $class . '" >' . $opt . '</field> </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 #__viewlevels 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; } }
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; $inherited = true; } else { $id = $field->name; $name = $field->name; $inherited = false; } $value = $value != '' ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : @$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(); $options2 = JCckDev::fromJSON($field->options2); $user = JFactory::getUser(); if ($config['pk'] && @$options2['import'] && $field->storage_location) { if (!JCckDatabase::loadResult('SELECT pk FROM #__cck_core WHERE pk=' . (int) $config['pk'] . ' AND storage_location="' . (string) $field->storage_location . '"')) { $properties = array('custom', 'table'); $properties = JCck::callFunc('plgCCK_Storage_Location' . $field->storage_location, 'getStaticProperties', $properties); $custom = $options2['import'] == 2 ? 'fulltext' : $properties['custom']; $value = $config['storages'][$properties['table']]->{$custom}; } } if (!$user->id && $this->params->get('guest_access', 0) == 0) { $form = ''; } else { $width = @$options2['width'] ? str_replace('px', '', $options2['width']) : '100%'; $height = @$options2['height'] ? str_replace('px', '', $options2['height']) : '280'; $asset = $config['asset_id'] > 0 ? $config['asset_id'] : $config['asset']; if ($app->input->get('option') == 'com_cck' && $app->input->get('view') == 'form' && $config['client'] == '') { $field->bool = 1; } if ($field->bool) { // Default $buttons = array('pagebreak', 'readmore'); $editor = JFactory::getEditor(@$options2['editor'] ? $options2['editor'] : null); $form = '<div>' . $editor->display($name, $value, $width, $height, '60', '20', $buttons, $id, $asset) . '</div>'; } else { // Modal Box if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } $buttonlabel = $field->selectlabel; } else { $buttonlabel = JText::_('COM_CCK_EDITOR'); } $e_type = @$options2['editor'] != '' ? '&type=' . $options2['editor'] : ''; $link = 'index.php?option=com_cck&task=box.add&tmpl=component&file=plugins/cck_field/' . self::$type . '/tmpl/form.php' . '&id=' . $id . '&name=' . $name . $e_type . '¶ms=' . urlencode(urlencode($width)) . '||' . $height . '||' . $asset; $app = JFactory::getApplication(); $class = 'wysiwyg_editor_box variation_href'; $component = $app->input->get('option'); if ($component == 'com_cck' && $app->input->get('view') != 'form' || $component == 'com_cck_ecommerce' || $component == 'com_cck_toolbox' || $component == 'com_cck_webservices') { // todo: remove later $class .= ' btn'; } $class = 'class="' . $class . '" '; $attr = $class; $form = '<textarea style="display: none;" id="' . $id . '" name="' . $name . '">' . $value . '</textarea>'; $form .= '<a href="' . $link . '" ' . $attr . '>' . $buttonlabel . '</a>'; $field->markup_class .= ' cck_form_wysiwyg_editor_box'; } } // Set if (!$field->variation) { $field->form = $form; self::_addScripts($field->bool, array('height' => @$height, 'inherited' => $inherited), $config); } else { $hidden = '<textarea class="inputbox" style="display: none;" id="' . $id . '" name="' . $name . '" />' . $value . '</textarea>'; parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<textarea', $hidden, '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
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; $userid = JFactory::getUser()->get('id'); if ($config['client'] != 'search') { if (!$value && $userid && !($field->storage_field == 'modified_by' || $field->storage_field == 'modified_user_id') || $config['pk'] > 0 && ($field->storage_field == 'modified_by' || $field->storage_field == 'modified_user_id')) { // todo: this must be changed asap! $value = $userid; } } // 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 = JCckDatabase::loadResult('SELECT name FROM #__users WHERE id = ' . (int) $value); parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config); } else { $class = 'inputbox text' . $validate . ($field->css ? ' ' . $field->css : ''); $xml = ' <form> <field type="' . self::$type2 . '" name="' . $name . '" id="' . $id . '" label="' . htmlspecialchars($field->label) . '" class="' . $class . '" size="18" /> </form> '; $form = JForm::getInstance($id, $xml); $form = $form->getInput($name, '', $value); // Set if (!$field->variation) { if (JFactory::getApplication()->isSite()) { $form = str_replace('index.php?', 'administrator/index.php?', $form); } $field->form = $form; if ($field->script) { parent::g_addScriptDeclaration($field->script); } } else { $field->text = JCckDatabase::loadResult('SELECT name FROM #__users WHERE id = ' . (int) $value); parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<input', '', '', $config); } } $field->value = $value; // Return if ($return === true) { return $field; } }
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; } }
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) { 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 text' . $validate . ($field->css ? ' ' . $field->css : ''); if ($value != '') { $class .= ' has-value'; } $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : ''; $attr = 'class="' . $class . '" size="' . $field->size . '"' . $maxlen; 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; } if (strpos($field->variation, 'custom_') !== false) { $isCustom = true; $type = substr($field->variation, 7); } else { $isCustom = false; $type = 'text'; } $form = '<input type="' . $type . '" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />'; // Set if (!$field->variation || $isCustom) { $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; } }
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 $opt = ''; if (trim($field->selectlabel)) { if ($config['doTranslation']) { $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel))); } $opt = '<option value="">' . '- ' . $field->selectlabel . ' -' . '</option>'; } $class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : ''); $xml = ' <form> <field type="' . self::$type2 . '" name="' . $name . '" id="' . $id . '" label="' . htmlspecialchars($field->label) . '" class="' . $class . '" size="1" >' . $opt . '</field> </form> '; $form = JForm::getInstance($id, $xml); $form = $form->getInput($name, '', $value); if (strpos($id, '-') !== false) { $id2 = str_replace('-', '_', $id); $form = str_replace('id="' . $id2 . '"', 'id="' . $id . '"', $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; } }
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; $xk = isset($inherit['xk']) ? $inherit['xk'] : ''; } else { $id = $field->name; $name = $field->name; $xk = ''; } // 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); if ($config['doTranslation']) { $title_label = trim(@$options2['title_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['title_label']))) : ''; $path_label = trim(@$options2['path_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['path_label']))) : ''; $desc_label = trim(@$options2['desc_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['desc_label']))) : ''; } else { $title_label = @$options2['title_label']; $path_label = @$options2['path_label']; $desc_label = @$options2['desc_label']; } $value = trim($value); if ($value == '') { $value = array('image_location' => '', 'image_title' => '', 'image_description' => ''); } else { $value_json = JCckDev::fromJSON($value); if (is_array($value_json) && !empty($value_json)) { $value_json['image_location'] = trim($value_json['image_location']); $value = $value_json; } else { $value = array('image_location' => $value, 'image_title' => '', 'image_description' => ''); } } $save_value = $value; $value2 = $value['image_location'] != '' ? $value['image_location'] : $options2['path']; $value['image_location'] = $value['image_location'] != '' ? $value['image_location'] : $field->defaultvalue; $title = $value['image_location'] == '' ? '' : substr(strrchr(JFile::stripExt($value['image_location']), '/'), 1); $image_title = @$value['image_title'] ? trim($value['image_title']) : substr(strrchr($value['image_location'], '/'), 1); $image_title = htmlspecialchars($image_title, ENT_QUOTES); $image_desc = isset($value_json['image_description']) ? trim($value_json['image_description']) : (isset($value_json['image_descr']) ? trim($value_json['image_descr']) : ''); $image_desc = htmlspecialchars($image_desc, ENT_QUOTES); $form_more2 = ''; $form_more3 = ''; $form_more4 = ''; $chkbox = ''; $onchange = ''; $preview = ''; $lock = ''; $params = array(); $legal_ext = isset($options2['media_extensions']) ? $options2['media_extensions'] : 'custom'; if ($legal_ext == 'custom') { $legal_ext = $options2['legal_extensions']; } else { $legal_ext = JCck::getConfig_Param('media_' . $legal_ext . '_extensions'); if (!$legal_ext) { $legal_ext = $options2['legal_extensions']; } } if ($value['image_location'] && JFile::exists(JPATH_ROOT . '/' . $value['image_location'])) { $path = substr($value['image_location'], 0, strrpos($value['image_location'], '/')) . '/'; for ($i = 1; $i < 11; $i++) { $thumb = $path . '_thumb' . $i . '/' . substr(strrchr($value['image_location'], '/'), 1); $field->{'thumb' . $i} = JFile::exists(JPATH_ROOT . '/' . $thumb) ? $thumb : ''; } self::_addThumbs($field, $options2, $value['image_location'], $path); } $class = 'inputbox file' . $validate . ($field->css ? ' ' . $field->css : ''); $attr_input_text = 'class="inputbox text" size="' . $field->size . '"'; if (strpos($name, '[]') !== false) { //FieldX $nameH = substr($name, 0, -2); $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[' . $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; } }