本文整理汇总了PHP中JForm::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::getValue方法的具体用法?PHP JForm::getValue怎么用?PHP JForm::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
$this->assoc = $this->get('Assoc');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
JFactory::getApplication()->input->set('hidemainmenu', true);
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例2: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
// Initialise variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例3: display
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$user = JFactory::getUser();
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->modules = $this->get('Modules');
$this->levels = $this->get('ViewLevels');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
// Check if we're allowed to edit this item
// No need to check for create, because then the moduletype select is empty
if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
parent::display($tpl);
$this->addToolbar();
}
示例4: canEditState
/**
* Method to test whether a record can be deleted.
*
* @param JForm $record a record object.
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*/
protected function canEditState($record)
{
if (!empty($record)) {
if ($record instanceof JForm) {
return JoomDOCAccessDocument::editState($record->getValue('id'), $record->getValue('checked_out'), $record->getValue('path'));
} else {
return JoomDOCAccessDocument::editState($record->id, $record->checked_out, $record->path);
}
}
return parent::canEditState($record);
}
示例5: date
/**
* Display date form field. If field value equal database null date reset to empty string.
*
* @param string $field form field name
* @return string field form html
*/
public function date($field)
{
static $nullDate;
if (empty($nullDate)) {
$db = JFactory::getDbo();
/* @var $db JDatabaseMySQL */
$nullDate = $db->getNullDate();
}
if ($this->form->getValue($field) == $nullDate) {
$this->form->setValue($field, null, '');
}
return $this->form->getInput($field);
}
示例6: display
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
if ($this->getLayout() == 'pagebreak') {
// TODO: This is really dogy - should change this one day.
$eName = JFactory::getApplication()->input->getCmd('e_name');
$eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
$this->document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
$this->eName =& $eName;
return parent::display($tpl);
}
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_content', 'article', $this->item->id);
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例7: test
/**
* Method to test the username for uniqueness.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*
* @since 11.1
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('COUNT(*)')->from('#__users')->where('username = ' . $db->quote($value));
// Get the extra field check attribute.
$userId = $form instanceof JForm ? $form->getValue('id') : '';
$query->where($db->quoteName('id') . ' <> ' . (int) $userId);
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate) {
return false;
}
return true;
}
示例8: preprocessForm
//.........这里部分代码省略.........
$fieldset->addAttribute('name', $section);
$fieldset->addAttribute('label', $section);
continue;
} elseif (!$header && preg_match('/^;(.*)$/', $line, $matches)) {
$key = $matches[1];
$field = $fieldset->addChild('field');
$field->addAttribute('label', $key);
$field->addAttribute('type', 'spacer');
$field->addAttribute('class', 'text');
continue;
} elseif (preg_match('/^([A-Z][A-Z0-9_\\-\\.]*)\\s*=/', $line, $matches)) {
$header = false;
$key = $matches[1];
$field = $fieldset->addChild('field');
$string = $refsections['keys'][$key];
$translated = isset($sections['keys'][$key]);
$modified = $translated && $sections['keys'][$key] != $refsections['keys'][$key];
$status = $modified ? 'translated' : ($translated ? 'unchanged' : 'untranslated');
$default = $translated ? $sections['keys'][$key] : '';
$label = '<b>' . $key . '</b><br />' . htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
$field->addAttribute('status', $status);
$field->addAttribute('description', $string);
if ($default) {
$field->addAttribute('default', $default);
} else {
$field->addAttribute('default', $string);
}
$field->addAttribute('label', $label);
$field->addAttribute('name', $key);
$field->addAttribute('type', 'key');
$field->addAttribute('filter', 'raw');
continue;
} elseif (!preg_match('/^(|(\\[[^\\]]*\\])|([A-Z][A-Z0-9_\\-\\.]*\\s*=(\\s*(("[^"]*")|(_QQ_)))+))\\s*(;.*)?$/', $line)) {
$this->item->error[] = $lineNumber;
}
}
$stream->close();
$newstrings = false;
if (!empty($sections['keys'])) {
foreach ($sections['keys'] as $key => $string) {
if (!isset($refsections['keys'][$key])) {
if (!$newstrings) {
$newstrings = true;
$form->load($addform, false);
$section = 'New Strings';
$addform = new JXMLElement('<form />');
$group = $addform->addChild('fields');
$group->addAttribute('name', 'strings');
$fieldset = $group->addChild('fieldset');
$fieldset->addAttribute('name', $section);
$fieldset->addAttribute('label', $section);
}
$field = $fieldset->addChild('field');
$status = 'extra';
$default = $string;
$label = '<b>' . $key . '</b>';
$field->addAttribute('status', $status);
$field->addAttribute('description', $string);
if ($default) {
$field->addAttribute('default', $default);
} else {
$field->addAttribute('default', $string);
}
$field->addAttribute('label', $label);
$field->addAttribute('name', $key);
$field->addAttribute('type', 'key');
$field->addAttribute('filter', 'raw');
}
}
}
}
$form->load($addform, false);
}
// Check the session for previously entered form data.
$data = $app->getUserState('com_localise.edit.translation.data', array());
// Bind the form data if present.
if (!empty($data)) {
$form->bind($data);
}
if ($origin != '_thirdparty' && $origin != '_override') {
$packages = LocaliseHelper::getPackages();
$package = $packages[$origin];
if (!empty($package->author)) {
$form->setValue('author', $package->author);
$form->setFieldAttribute('author', 'readonly', 'true');
}
if (!empty($package->copyright)) {
$form->setValue('maincopyright', $package->copyright);
$form->setFieldAttribute('maincopyright', 'readonly', 'true');
}
if (!empty($package->license)) {
$form->setValue('license', $package->license);
$form->setFieldAttribute('license', 'readonly', 'true');
}
}
if ($form->getValue('description') == '' && array_key_exists($tag, $languages[$client])) {
$form->setValue('description', $filename . ' ' . $languages[$client][$tag]['name']);
}
return $form;
}
示例9: _dataCompare
/**
* Compare form data and session data.
*
* @param object $form JForm object with populated input values.
* @param array $data An associative array of form values.
*
* @return boolean
*
* @since 2.5
*/
private function _dataCompare(JForm $form, $data)
{
foreach ($data as $key => $value) {
if ($form->getValue($key) != $value) {
return false;
}
}
return true;
}