本文整理匯總了PHP中JModelAdmin::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP JModelAdmin::validate方法的具體用法?PHP JModelAdmin::validate怎麽用?PHP JModelAdmin::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JModelAdmin
的用法示例。
在下文中一共展示了JModelAdmin::validate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
public function validate($form, $data, $group = null)
{
$app = JFactory::getApplication();
$values = JRequest::getVar('joomdoc_option_value', array(), 'default', 'array');
$labels = JRequest::getVar('joomdoc_option_label', array(), 'default', 'array');
if (!empty($values) && !empty($labels)) {
// check if field options values and labels are unique
if (count(array_unique($values)) < count($values) || count(array_unique($labels)) < count($labels)) {
$this->setError(JText::_('JOOMDOC_FIELD_OPTIONS_NONUNIQUE'));
$options = array();
foreach ($values as $id => $value) {
$option = new stdClass();
$option->id = $id;
$option->value = $value;
$option->label = $labels[$id];
$options[] = $option;
}
// save current option list into session
$app->setUserState('com_joomdoc.field.options', $options);
return false;
}
}
// options are unique - cleanup session
$app->setUserState('com_joomdoc.field.options', null);
$db = $this->getDbo();
$query = $db->getQuery(true);
// check if field title is unique
$query->select('COUNT(*)')->from('#__joomdoc_field')->where('LOWER(TRIM(title)) = ' . $db->q(JString::strtolower(JString::trim($data['title']))))->where('id <> ' . (int) $data['id']);
if ($db->setQuery($query)->loadResult()) {
$this->setError(JText::_('JOOMDOC_FIELD_NONUNIQUE'));
return false;
}
return parent::validate($form, $data, $group);
}
示例2: validate
public function validate($form, $data, $group = null)
{
// Prepare the data.
$data["level"] = implode(",", $data["level"]);
return parent::validate($form, $data, $group);
// TODO: Change the autogenerated stub
}
示例3: validate
public function validate($form, $data, $group = null) {
// Adicionando a data de criação do export
if (empty($data['created_when'])) {
$date = new DateTime();
$data['created_when'] = $date->format('Y-m-d h:i:s');
}
// Dedo-duro
if (empty($data['created_by'])) {
$user = JFactory::getUser();
$data['created_by'] = $user->get('id');
}
return parent::validate($form, $data, $group);
}
示例4: validate
public function validate($form, $data, $group = null)
{
$data = parent::validate($form, $data, $group);
// fix for magic quotes
if (get_magic_quotes_gpc()) {
$props = json_decode($data['props']);
if ($props == null) {
foreach ($data as $key => $value) {
$data[$key] = stripslashes($value);
}
}
}
return $data;
}
示例5: validate
/**
* Method to validate the form data.
*
* @param object $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 11.1
*/
public function validate($form, $data, $group = null)
{
if ($result = parent::validate($form, $data, $group)) {
// for Fields group
// Convert jform[fields_group][field] to jform[field] or JTable cannot bind data.
// ==========================================================================================
$result = AKHelper::_('array.pivotFromTwoDimension', $result);
}
return $result;
}
示例6: validate
/**
* Method to validate the form data.
*
* @param object $form The form to validate against.
* @param array $data The data to validate.
* @return mixed Array of filtered data if valid, false otherwise.
* @since 1.1
*/
function validate($form, $data)
{
$params = $data['params'];
$ok = parent::validate($form, $data);
//standard jform validation failed so we shouldn't test further as we can't
//be sure of the data
if (!$ok) {
return false;
}
//hack - must be able to add the plugin xml fields file to $form to include in validation
// but cant see how at the moment
$data['params'] = $params;
return $data;
}
示例7: validate
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @see JFormRule
* @see JFilterInput
*
* @return mixed Array of filtered data if valid, false otherwise.
*/
public function validate($form, $data, $group = null)
{
$ok = parent::validate($form, $data);
// Standard jform validation failed so we shouldn't test further as we can't be sure of the data
if (!$ok) {
return false;
}
$db = FabrikWorker::getDbo(true);
if (FabrikWorker::isReserved($data['name'])) {
$this->setError(JText::_('COM_FABRIK_RESEVED_NAME_USED'));
}
$elementModel = $this->getElementPluginModel($data);
$nameChanged = $data['name'] !== $elementModel->getElement()->name;
$elementModel->getElement()->bind($data);
$listModel = $elementModel->getListModel();
if ($data['id'] === 0) {
// Have to forcefully set group id otherwise listmodel id is blank
$elementModel->getElement()->group_id = $data['group_id'];
if ($listModel->canAddFields() === false && $listModel->noTable() === false) {
$this->setError(JText::_('COM_FABRIK_ERR_CANT_ADD_FIELDS'));
}
} else {
if ($listModel->canAlterFields() === false && $nameChanged && $listModel->noTable() === false) {
$this->setError(JText::_('COM_FABRIK_ERR_CANT_ALTER_EXISTING_FIELDS'));
}
}
$listModel = $elementModel->getListModel();
/**
* Test for duplicate names
* unlinking produces this error
*/
if (!JRequest::getVar('unlink', false) && (int) $data['id'] === 0) {
$row->group_id = (int) $data['group_id'];
$query = $db->getQuery(true);
$query->select('t.id')->from('#__{package}_joins AS j');
$query->join('INNER', '#__{package}_lists AS t ON j.table_join = t.db_table_name');
$query->where("group_id = {$row->group_id} AND element_id = 0");
$db->setQuery($query);
$joinTblId = (int) $db->loadResult();
$ignore = array($data['id']);
if ($joinTblId === 0) {
if ($listModel->fieldExists($data['name'], $ignore)) {
$this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
}
} else {
$joinListModel = JModel::getInstance('list', 'FabrikFEModel');
$joinListModel->setId($joinTblId);
$joinEls = $joinListModel->getElements();
foreach ($joinEls as $joinEl) {
if ($joinEl->getElement()->name == $data['name']) {
$ignore[] = $joinEl->getElement()->id;
}
}
if ($joinListModel->fieldExists($data['name'], $ignore)) {
$this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
}
}
}
// Strip <p> tag from label
$data['label'] = JString::str_ireplace(array('<p>', '</p>'), '', $data['label']);
return count($this->getErrors()) == 0 ? $data : false;
}
示例8: validate
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*/
public function validate($form, $data, $group = null)
{
// Fire HUBzero registration check here so that we don't have to duplicate validation code
require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'registration.php';
$registration = new \Components\Members\Models\Registration();
$registration->set('name', $data['name']);
$registration->set('login', $data['username']);
$registration->set('email', $data['email']);
$registration->set('confirmEmail', $data['email']);
if (!$registration->check('create', $data['id'], array('name', 'login', 'email'))) {
$this->setError(implode("<br/>", $registration->_invalid));
return false;
}
return parent::validate($form, $data, $group);
}
示例9: validate
/**
* Loads ContentHelper for filters before validating data.
*
* @param object $form The form to validate against.
* @param array $data The data to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @since 1.1
*/
function validate($form, $data, $group = null)
{
require_once PATH_CORE . '/components/com_content/admin/helpers/content.php';
return parent::validate($form, $data, $group);
}
示例10: validate
public function validate($form, $data, $group = null) {
$date = new DateTime();
$user = JFactory::getUser();
if (empty($data['created_when'])) {
// Adicionando a data de criação da table
$data['created_when'] = $date->format('Y-m-d H:i:s');
} else {
// Ou a data de modificação
$data['modified_when'] = $date->format('Y-m-d H:i:s');
}
if (empty($data['created_by'])) {
// Quem criou
$data['created_by'] = $user->get('id');
} else {
// Ou quem modificou
$data['modified_by'] = $user->get('id');
}
return parent::validate($form, $data, $group);
}
示例11: validate
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 12.2
*/
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (DemoHelper::checkString($data['not_required'])) {
$requiredFields = (array) explode(',', (string) $data['not_required']);
$requiredFields = array_unique($requiredFields);
// now change the required field attributes value
foreach ($requiredFields as $requiredField) {
// make sure there is a string value
if (DemoHelper::checkString($requiredField)) {
// change to false
$form->setFieldAttribute($requiredField, 'required', 'false');
// also clear the data set
$data[$requiredField] = '';
}
}
}
return parent::validate($form, $data, $group);
}
示例12: validate
/**
* needed for saving params- not sure y!
* @param unknown_type $form
* @param unknown_type $data
*/
function validate($form, $data)
{
parent::validate($form, $data);
return $data;
}
示例13: validate
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
*/
public function validate($form, $data, $group = null)
{
parent::validate($form, $data);
return $data;
}
示例14: validate
/**
* Since we now have a dynamic form we have to go around the validation somehow
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*/
public function validate($form, $data, $group = null)
{
// The data that we are receiving should have a cmc_groups
if (isset($data['cmc_groups']['EMAIL'])) {
$data['email'] = $data['cmc_groups']['EMAIL'];
$data['firstname'] = $data['cmc_groups']['FNAME'];
$data['lastname'] = $data['cmc_groups']['LNAME'];
} else {
JFactory::getApplication()->enqueueMessage('Your list doesn\'t have a EMAIL field or you are using a different field name for email(the field name should be EMAIL)');
return false;
}
return parent::validate($form, $data);
}
示例15: validate
public function validate($form, $data, $group = null)
{
// clean up the folder name if it is no picasa album
if (empty($data['id'])) {
// make the foldername for local folders safe
if ($data['foldertype'] == 0) {
$data['folder'] = JFolder::makeSafe($data['folder']);
}
}
$validData = parent::validate($form, $data, $group);
if (is_bool($validData) && $validDate == false) {
return false;
}
if (!isset($data['usergroups']) || count($data['usergroups']) == 0) {
$validData['usergroupids'] = '';
} else {
$validData['usergroupids'] = implode(',', $data['usergroups']);
}
return $validData;
}