当前位置: 首页>>代码示例>>PHP>>正文


PHP JFormHelper::loadRuleType方法代码示例

本文整理汇总了PHP中JFormHelper::loadRuleType方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormHelper::loadRuleType方法的具体用法?PHP JFormHelper::loadRuleType怎么用?PHP JFormHelper::loadRuleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JFormHelper的用法示例。


在下文中一共展示了JFormHelper::loadRuleType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadRuleType

 /**
  * Proxy for JFormHelper::loadRuleType().
  *
  * @param   string  $type  The rule type.
  * @param   bool    $new   Flag to toggle whether we should get a new instance of the object.
  *
  * @return  mixed  JFormRule object on success, false otherwise.
  *
  * @see     JFormHelper::loadRuleType()
  * @since   11.1
  */
 protected function loadRuleType($type, $new = true)
 {
     return JFormHelper::loadRuleType($type, $new);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:15,代码来源:form.php

示例2: loadRuleType

 /**
  * Helper wrapper method for loadRuleType
  *
  * @param   string   $type  The field type.
  * @param   boolean  $new   Flag to toggle whether we should get a new instance of the object.
  *
  * @return mixed  JFormField object on success, false otherwise.
  *
  * @see     JFormHelper::loadRuleType()
  * @since   3.4
  */
 public function loadRuleType($type, $new = true)
 {
     return JFormHelper::loadRuleType($type, $new);
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:15,代码来源:helper.php

示例3: loadValidators

 /**
  * Instance js validators for a field.
  *
  * @access	public static
  * @param	JXMLElement	$element	The XML field node.
  * @param	string	$id	The input id.
  * @return	void
  */
 public static function loadValidators($element, $id)
 {
     //Show the prompt information
     if (isset($element['msg-info'])) {
         self::loadScriptPromptInfo($id, JText::_($element['msg-info']));
     }
     if (!isset($element['class'])) {
         return;
     }
     $class = $element['class'];
     $instanceIt = false;
     preg_match_all('/validate\\[(.+)\\]\\s?/', $class, $matches);
     $validates = array();
     if (count($matches[1])) {
         $validates = explode(",", $matches[1][0]);
     }
     $required = isset($element['required']) ? $element['required'] : in_array('required', $validates);
     if ($required != false) {
         $instanceIt = true;
     } else {
         $element['required'] = true;
     }
     $rules = array();
     if (isset($validates)) {
         foreach ($validates as $ruleType) {
             preg_match_all("/custom\\[([a-zA-Z0-9]+)(_.+)?\\]/", $ruleType, $matchesCustom);
             if (count($matchesCustom[1])) {
                 $ruleType = $matchesCustom[1][0];
             }
             if ($rule = JFormHelper::loadRuleType($ruleType)) {
                 if ($rule->extended) {
                     $rules[] = $rule;
                     $instanceIt = true;
                 }
             }
         }
     }
     if ($instanceIt) {
         return self::render($element, $id, $rules);
     }
 }
开发者ID:gwtrains,项目名称:comRTiPrint,代码行数:49,代码来源:validator.php

示例4: validateJRule

 /**
  * Validate teh element against a Joomla form Rule
  *
  * @param   string  $type   Rule type e.g. 'password'
  * @param   mixed   $value  Value to validate
  * @param   mixed   $path   Optional path to load teh rule from
  *
  * @throws Exception
  *
  * @return bool
  */
 protected function validateJRule($type, $value, $path = null)
 {
     if (!is_null($path)) {
         JFormHelper::addRulePath($path);
     }
     $rule = JFormHelper::loadRuleType($type, true);
     $xml = new SimpleXMLElement('<xml></xml>');
     $this->lang->load('com_users');
     if (!$rule->test($xml, $value)) {
         $this->validationError = '';
         foreach ($this->app->getMessageQueue() as $i => $msg) {
             if ($msg['type'] === 'warning') {
                 $this->validationError .= $msg['message'] . '<br />';
             }
         }
         FabrikWorker::killMessage($this->app, 'warning');
         return false;
     }
     return true;
 }
开发者ID:LGBGit,项目名称:tierno,代码行数:31,代码来源:element.php

示例5: bindData

 public function bindData($data)
 {
     $membership = $this->getMembership();
     $db =& $this->db;
     $user = JFactory::getUser();
     $guest = $user->guest;
     // Create the empty data
     $this->data = new stdClass();
     // Bind username
     if (RSMembershipHelper::getConfig('choose_username')) {
         $username = isset($data['username']) ? $data['username'] : '';
         if ($guest) {
             if (empty($username) || strlen(utf8_decode($username)) < 2) {
                 $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_USERNAME'));
                 return false;
             }
             $query = $db->getQuery(true);
             $query->select($db->qn('id'))->from($db->qn('#__users'))->where($db->qn('username') . ' = ' . $db->q($username));
             $db->setQuery($query);
             if ($db->loadResult()) {
                 $this->setError(JText::_('COM_RSMEMBERSHIP_USERNAME_NOT_OK'));
                 return false;
             }
         }
         $this->data->username = $guest ? $username : $user->username;
     }
     // Bind password
     if (RSMembershipHelper::getConfig('choose_password')) {
         $password = isset($data['password']) ? $data['password'] : '';
         $password2 = isset($data['password2']) ? $data['password2'] : '';
         if ($guest) {
             $version = new JVersion();
             // 3.x password strength
             if ($version->isCompatible('3.1.4')) {
                 JFactory::getLanguage()->load('com_users', JPATH_SITE);
                 $rule = JFormHelper::loadRuleType('password');
                 $field = new SimpleXMLElement('<field></field>');
                 if (!$rule->test($field, $password)) {
                     return false;
                 }
             } else {
                 if (!strlen($password)) {
                     $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_PASSWORD'));
                     return false;
                 } elseif (strlen($password) < 6) {
                     $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_PASSWORD_6'));
                     return false;
                 }
             }
             if ($password != $password2) {
                 $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_CONFIRM_PASSWORD'));
                 return false;
             }
         }
         $this->data->password = $guest ? md5($password) : '';
     }
     // Bind email
     $email = isset($data['email']) ? $data['email'] : '';
     if ($guest) {
         jimport('joomla.mail.helper');
         if (empty($email) || !JMailHelper::isEmailAddress($email)) {
             $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_EMAIL'));
             return false;
         }
     }
     $this->data->email = $guest ? $email : $user->email;
     // Bind name
     $name = isset($data['name']) ? $data['name'] : '';
     if ($guest && empty($name)) {
         $this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_NAME'));
         return false;
     }
     $this->data->name = $guest ? $name : $user->name;
     $sentFields = isset($data['fields']) ? $data['fields'] : array();
     $sentMembershipFields = isset($data['membership_fields']) ? $data['membership_fields'] : array();
     if (isset($data['membership_fields'])) {
         $verifyFields = array_merge($sentFields, $sentMembershipFields);
     }
     $fields = RSMembership::getCustomFields();
     $membership_fields = RSMembership::getCustomMembershipFields($membership->id);
     $fields = array_merge($fields, $membership_fields);
     foreach ($fields as $field) {
         if ($field->required && empty($verifyFields[$field->name]) || $field->rule && !empty($verifyFields[$field->name]) && is_callable('RSMembershipValidation', $field->rule) && !call_user_func(array('RSMembershipValidation', $field->rule), $verifyFields[$field->name])) {
             $message = JText::_($field->validation);
             if (empty($message)) {
                 $message = JText::sprintf('COM_RSMEMBERSHIP_VALIDATION_DEFAULT_ERROR', JText::_($field->label));
             }
             $this->setError($message);
             return false;
         }
     }
     $this->data->fields = $sentFields;
     $this->data->membership_fields = $sentMembershipFields;
     // Bind an empty coupon for legacy reasons
     $this->data->coupon = '';
     return true;
 }
开发者ID:JozefAB,项目名称:qk,代码行数:97,代码来源:subscribe.php


注:本文中的JFormHelper::loadRuleType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。