public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } $value = $value != '' ? (int) $value : (int) $field->defaultvalue; $value = $value ? $value - 1 : 0; $group_id = $field->location != '' ? $field->location : 'cck_tabs1'; // Prepare $form = ''; if ($field->state) { parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'group_id' => $group_id, 'id' => $id, 'identifier' => $field->bool3, 'label' => $field->label, 'url_actions' => $field->bool2, 'value' => $value)); } // Set $field->form = $form; // todo: '<div class="tabbable tabs-left">' $field->value = $field->label; $field->label = ''; // Return if ($return === true) { return $field; } }
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } // Prepare if ($field->bool == 2) { $form = '</div>'; } elseif ($field->bool == 1) { $class = $field->markup_class ? ' class="' . trim($field->markup_class) . '"' : ''; $attr = $class . ($field->attributes ? ' ' . $field->attributes : ''); $form = '</div><div' . $attr . '>'; } else { $class = $field->markup_class ? ' class="' . trim($field->markup_class) . '"' : ''; $attr = $class . ($field->attributes ? ' ' . $field->attributes : ''); $form = '<div' . $attr . '>'; } // Set $field->form = $form; $field->value = ''; $field->label = ''; // 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; } else { $id = $field->name; } // Prepare $form = ''; if ($field->state) { $group_id = $field->location != '' ? $field->location : 'cck_tabs1'; if ($field->bool == 2) { $form = JCckDevTabs::end(); } elseif ($field->bool == 1) { $form = JCckDevTabs::open($group_id, $id, $field->label); } else { $form = JCckDevTabs::start($group_id, $id, $field->label, array('active' => $id)); } } // Set $field->form = $form; $field->value = $field->label; $field->label = ''; // 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 . '"'; 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; } //if ( $config['pk'] ) { $dispatcher = JDispatcher::getInstance(); //} // Prepare $f = self::_getChild($field, $config); $xn = $value ? is_array($value) ? count($value) : $value : $field->rows; $form = array(); if ($xn > 0 && is_object($f)) { for ($xi = 0; $xi < $xn; $xi++) { $f_value = ''; if ($config['pk']) { $table = $f->storage_table; if ($table && !isset($config['storages'][$table])) { $config['storages'][$table] = ''; $dispatcher->trigger('onCCK_Storage_LocationPrepareForm', array(&$f, &$config['storages'][$table], $config['pk'])); } $dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi)); } else { $f_value = @$value[$xi]; } $inherit = array('id' => $name . '__' . $xi, 'name' => $name . '[]', 'xk' => $xi); $clone = clone $f; $results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, $f_value, &$config, $inherit, true)); $form[$xi] = $results[0]; $form[$xi]->name = $f->name; } if ($form[0]) { $field->display = $form[0]->display; } // Empty $inherit = array('id' => $name . '__' . '0', 'name' => $name . '[]', 'xk' => '0', 'empty' => true); $clone = clone $f; $results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, '', &$config, $inherit, true)); $form[$xi] = $results[0]; $form[$xi]->name = $f->name; } // Set $field->form = $form; $field->value = ''; // Return if ($return === true) { return $field; } }
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); // Set $field->form = ''; $field->value = ''; }
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); // Prepare $app = JFactory::getApplication(); if ($app->input->get('option') == 'com_cck' && $app->input->get('view') == 'form') { $form = ''; $value = ''; } else { $alter = true; $alter_type_default = isset($inherit['alter_type_value']) ? $inherit['alter_type_value'] : ''; if (isset($config['item']->id) && $config['item']->id && isset($config['item']->storage_table) && $config['item']->storage_table != '') { $db = JFactory::getDbo(); $prefix = $db->getPrefix(); $table = str_replace('#__', $prefix, $config['item']->storage_table); $tables = $db->getTableList(); if (in_array($table, $tables)) { $column = JCckDatabase::loadObject('SHOW COLUMNS FROM ' . $table . ' WHERE field = "' . $config['item']->storage_field . '"'); $alter_type_value = isset($column->Type) ? strtoupper($column->Type) : $alter_type_default; } else { $alter = false; $alter_type_value = $alter_type_default; $alter_type_default = ''; } } else { $alter_type_value = $alter_type_default; $alter_type_default = ''; } ob_start(); include_once dirname(__FILE__) . '/tmpl/form.php'; $form = ob_get_clean(); } // Set $field->form = $form; $field->value = $value; // Return if ($return === true) { return $field; } }
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $id = $field->name; $name = $field->name; } $value = $field->defaultvalue; // Prepare $value = JCckDevHelper::replaceLive($value); if ($field->bool8) { $field->bool8 = $config['doTranslation']; } if ($field->bool8) { $value = trim(preg_replace('/[^A-Za-z0-9_ ]/', '', strip_tags($value))); if ($value) { $value = JText::_('COM_CCK_' . str_replace(' ', '_', $value)); } } $form = htmlspecialchars_decode($value); // Set if (!$field->variation) { $field->form = $form; if ($field->script) { parent::g_addScriptDeclaration($field->script); } } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '', '', '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
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_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $id = $field->name; $name = $field->name; } $value = $value != '' ? $value : $field->defaultvalue; $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); // Validate $validate = ''; // Prepare $class = 'inputbox hidden' . $validate . ($field->css ? ' ' . $field->css : ''); $form = '<input class="' . $class . '" type="hidden" id="' . $id . '" name="' . $name . '" value="' . $value . '" />'; // Set if (!$field->variation) { $field->form = $form; if ($field->script) { parent::g_addScriptDeclaration($field->script); } } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<input', '', '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
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 $form = ''; $value = ''; // Prepare if ($field->defaultvalue) { $mode = $field->bool ? 'module' : 'position'; $style = $field->style ? ',' . $field->style : ''; $form = '{load' . $mode . ' ' . $field->defaultvalue . $style . '}'; $value = $field->defaultvalue; if ($field->bool2) { $form = JHtml::_('content.prepare', $form); } } // Set $field->form = $form; $field->value = $value; }
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } // Prepare $value = $field->location; $form = '<span class="icon-' . $value . '"></span>'; // Set $field->form = $form; $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_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; $inherited = true; } else { $id = $field->name; $name = $field->name; $inherited = false; } $value = $value != '' ? (int) $value : @(int) $config['asset_id']; // Validate $validate = ''; // Prepare $options2 = JCckDev::fromJSON($field->options2); $component = @$options2['extension'] ? $options2['extension'] : 'com_content'; $section = @$options2['section'] ? $options2['section'] : 'article'; if ($field->bool) { // Default $class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : ''); $xml = ' <form> <field type="' . self::$type2 . '" id="' . $id . '" name="' . $name . '" label="' . htmlspecialchars($field->label) . '" filter="rules" component="' . $component . '" section="' . $section . '" class="' . $class . '" /> <field type="hidden" name="asset_id" readonly="true" class="readonly" /> </form> '; $form = JForm::getInstance($id, $xml); $form->setValue('asset_id', null, $value); $form = $form->getInput($name); $form = str_replace('<select name="' . $name . '[', '<select class="inputbox" name="' . $name . '[', $form); } else { // Modal Box $app = JFactory::getApplication(); 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_PERMISSIONS'); } $link = 'index.php?option=com_cck&task=box.add&tmpl=component&file=plugins/cck_field/' . self::$type . '/tmpl/form.php' . '&id=' . $id . '&name=' . $name . '&type=' . $value . '¶ms=' . $component . '||' . $section; $class = 'jform_rules_box variation_href'; if ($app->input->get('option') == 'com_cck' && $app->input->get('view') != 'form') { // todo: remove later $class .= ' btn'; } $class = 'class="' . $class . '" '; $attr = $class; $rules = ''; $form = '<textarea style="display: none;" id="' . $id . '" name="' . $name . '">' . $rules . '</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('inherited' => $inherited), $config); 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 != '' ? $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); 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; $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 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; } // Prepare $dispatcher = JDispatcher::getInstance(); $fields = self::_getChildren($field, $config); if ($value) { // TODO: call storage plugin. $xn = $field->storage == 'xml' ? is_object($value) ? count($value->children()) : count($value) : $value; } else { $xn = $field->rows; } $form = array(); for ($xi = 0; $xi < $xn; $xi++) { foreach ($fields as $f) { if (is_object($f)) { $f_name = $f->name; $f_value = ''; if ($config['pk']) { if ($field->storage == 'custom') { $f->storage = $field->storage; $f->storage_table = $field->storage_table; $f->storage_field = $field->storage_field; } $table = $f->storage_table; if ($table && !isset($config['storages'][$table])) { $config['storages'][$table] = ''; $dispatcher->trigger('onCCK_Storage_LocationPrepareForm', array(&$f, &$config['storages'][$table], $config['pk'])); } $dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi, $field)); } elseif ((int) $value > 0) { $f->storage = $field->storage; $f->storage_table = $field->storage_table; $f->storage_field = $field->storage_field; $table = $f->storage_table; static $already = 0; if (!$already) { JPluginHelper::importPlugin('cck_storage'); $already = 1; } $dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi, $field)); } $inherit = array('id' => $name . '_' . $xi . '_' . $f_name, 'name' => $name . '[' . $xi . '][' . $f_name . ']'); $clone = clone $f; $results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, $f_value, &$config, $inherit, true)); $form[$xi][$f_name] = $results[0]; @($form[$xi][$f_name]->name = $f->name); } } } if ($field->bool2) { foreach ($fields as $f) { // Empty $f_name = $f->name; $inherit = array('id' => $name . '_' . '0' . '_' . $f_name, 'name' => $name . '[' . '0' . '][' . $f_name . ']', 'empty' => true); $clone = clone $f; $results = $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$clone, '', &$config, $inherit, true)); $form[$xi][$f_name] = $results[0]; @($form[$xi][$f_name]->name = $f->name); } } // Set if ($field->script) { parent::g_addScriptDeclaration($field->script); } $field->form = $form; $field->value = ''; }
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; } }