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


PHP FText::sprintf方法代码示例

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


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

示例1: validate

 /**
  * Validate the elements data against the rule
  *
  * @param   string $data          To check
  * @param   int    $repeatCounter Repeat group counter
  *
  * @return  bool  true if validation passes, false if fails
  */
 public function validate($data, $repeatCounter)
 {
     $errors = array();
     $currentTime = JFactory::getDate();
     /* DO ID LENGTH TEST */
     if (strlen($data) == 13) {
         /* SPLIT ID INTO SECTIONS */
         $year = substr($data, 0, 2);
         $month = substr($data, 2, 2);
         $day = substr($data, 4, 2);
         $gender = substr($data, 6, 4) * 1;
         $citizen = substr($data, 10, 2) * 1;
         $check_sum = substr($data, 12, 1) * 1;
         /* DO YEAR TEST */
         $nowYearNotCentury = $currentTime->format('Y');
         $nowYearNotCentury = substr($nowYearNotCentury, 2, 2);
         $year = $year <= $nowYearNotCentury ? '20' . $year : '19' . $year;
         if (!($year > 1900 && $year < $currentTime->format('Y'))) {
             $errors[] = FText::_('PLG_VALIDATION_RSA_YEAR_IS_NOT_VALID');
         }
         /* DO MONTH TEST */
         if (!($month > 0 && $month < 13)) {
             $errors[] = FText::_('PLG_VALIDATION_RSA_MONTH_IS_NOT_VALID');
         }
         /* DO DAY TEST */
         if (!($day > 0 && $day < 32)) {
             $errors[] = 'Day is not valid';
         }
         /* DO DATE TEST */
         if (($month == 4 || $month == 6 || $month == 9 || $month == 11) && $day == 31) {
             $errors[] = FText::_('PLG_VALIDATION_RSA_MONTH_NOT_31_DAYS');
         }
         if ($month == 2) {
             // check for february 29th
             $isLeap = $year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0);
             if ($day > 29 || $day == 29 && !$isLeap) {
                 $errors[] = FText::sprintf('PLG_VALIDATION_RSA_FEB_CHECK', $day, $year);
             }
         }
         /* DO GENDER TEST */
         if (!($gender >= 0 && $gender < 10000)) {
             $errors[] = FText::sprintf('PLG_VALIDATION_RSA_GENDER_NOT_VALID');
         }
         /* DO CITIZEN TEST */
         //08 or 09 SA citizen
         //18 or 19 Not SA citizen but with residence permit
         if (!($citizen == 8 || $citizen == 9 || $citizen == 18 || $citizen == 19)) {
             $errors[] = FText::sprintf('PLG_VALIDATION_RSA_CITIZEN_NOT_VALID');
         }
         /* GET CHECKSUM VALUE */
         $checkSumOdd = 0;
         $checkSumEven = 0;
         $checkSumEvenTemp = '';
         // Get ODD Value
         for ($count = 0; $count < 11; $count += 2) {
             $checkSumOdd += substr($data, $count, 1);
         }
         // Get EVEN Value
         for ($count = 0; $count < 12; $count += 2) {
             $checkSumEvenTemp = $checkSumEvenTemp . substr($data, $count + 1, 1) + '';
         }
         $checkSumEvenTemp = $checkSumEvenTemp * 2;
         $checkSumEvenTemp = $checkSumEvenTemp + '';
         for ($count = 0; $count < strlen($checkSumEvenTemp); $count++) {
             $checkSumEven += substr($checkSumEvenTemp, $count, 1) * 1;
         }
         // GET Checksum Value
         $checkSumValue = $checkSumOdd * 1 + $checkSumEven * 1;
         $checkSumValue = $checkSumValue . 'xxx';
         $checkSumValue = 10 - substr($checkSumValue, 1, 1) * 1;
         if ($checkSumValue == 10) {
             $checkSumValue = 0;
         }
         /* DO CHECKSUM TEST */
         if ($checkSumValue !== $check_sum) {
             $errors[] = FText::_('PLG_VALIDATION_RSA_CHECKSUM_NOT_VALID');
         }
     } else {
         $errors[] = FText::_('PLG_VALIDATION_RSA_ID_NOT_THE_RIGHT_LENGTH');
     }
     if (!empty($errors)) {
         $this->errorMsg = implode('<br />', $errors);
         return false;
     }
     return true;
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:94,代码来源:rsa_id.php


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