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


PHP CRM_Utils_Date::isDate方法代码示例

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


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

示例1: formRule

 /**
  * Enforce valid date ranges.
  *
  * Borrowed from CRM_Report_Form_Contribute_Repeat::formRule().
  *
  * @param array $fields
  *   Fields from the form.
  * @param array $files
  *   Not used.
  * @param object $self
  *   Not used.
  *
  * @return array
  *   Array of errors.
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = $checkDate = $errorCount = array();
     if ($fields['event_start_date1_relative'] == '0') {
         $checkDate['event_start_date1']['event_start_date1_from'] = $fields['event_start_date1_from'];
         $checkDate['event_start_date1']['event_start_date1_to'] = $fields['event_start_date1_to'];
     }
     if ($fields['event_start_date2_relative'] == '0') {
         $checkDate['event_start_date2']['event_start_date2_from'] = $fields['event_start_date2_from'];
         $checkDate['event_start_date2']['event_start_date2_to'] = $fields['event_start_date2_to'];
     }
     foreach ($checkDate as $date_range => $range_data) {
         foreach ($range_data as $key => $value) {
             if (CRM_Utils_Date::isDate($value)) {
                 $errorCount[$date_range][$key]['valid'] = 'true';
                 $errorCount[$date_range][$key]['is_empty'] = 'false';
             } else {
                 $errorCount[$date_range][$key]['valid'] = 'false';
                 $errorCount[$date_range][$key]['is_empty'] = 'true';
                 if (is_array($value)) {
                     foreach ($value as $v) {
                         if ($v) {
                             $errorCount[$date_range][$key]['is_empty'] = 'false';
                         }
                     }
                 } elseif (!isset($value)) {
                     $errorCount[$date_range][$key]['is_empty'] = 'false';
                 }
             }
         }
     }
     $errorText = ts("Select valid date range");
     foreach ($errorCount as $date_range => $error_data) {
         if ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'true' && $error_data[$date_range . '_to']['is_empty'] == 'true') {
                 $errors[$date_range . '_relative'] = $errorText;
             }
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'true' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'true') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
         }
     }
     return $errors;
 }
开发者ID:aghstrategies,项目名称:com.aghstrategies.orgeventattendees,代码行数:70,代码来源:OrgSummary.php

示例2: formRule

 /**
  * @param $fields
  * @param $files
  * @param $self
  *
  * @return array
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = $checkDate = $errorCount = array();
     $rules = array('id' => array('sort_name', 'display_name', 'addressee_display', 'contact_type', 'contact_sub_type', 'email', 'phone', 'state_province_id', 'country_id', 'city', 'street_address', 'supplemental_address_1', 'postal_code'), 'country_id' => array('country_id'), 'state_province_id' => array('country_id', 'state_province_id'), 'contribution_source' => array('contribution_source'), 'financial_type' => array('financial_type'));
     $idMapping = array('id' => ts('Contact'), 'exposed_id' => ts('Contact'), 'country_id' => ts('Country'), 'state_province_id' => ts('State/Province'), 'contribution_source' => ts('Contribution Source'), 'financial_type' => ts('Financial Type'), 'sort_name' => ts('Contact Name'), 'email' => ts('Email'), 'phone' => ts('Phone'));
     if (empty($fields['group_bys'])) {
         $errors['fields'] = ts('Please select at least one Group by field.');
     } elseif ((array_key_exists('contribution_source', $fields['group_bys']) || array_key_exists('contribution_type', $fields['group_bys'])) && count($fields['group_bys']) > 1) {
         $errors['fields'] = ts('You can not use other Group by with Financial type or Contribution source.');
     } else {
         foreach ($fields['fields'] as $fld_id => $value) {
             if (!($fld_id == 'total_amount1') && !($fld_id == 'total_amount2')) {
                 $found = FALSE;
                 $invlidGroups = array();
                 foreach ($fields['group_bys'] as $grp_id => $val) {
                     $validFields = $rules[$grp_id];
                     if (in_array($fld_id, $validFields)) {
                         $found = TRUE;
                     } else {
                         $invlidGroups[] = $idMapping[$grp_id];
                     }
                 }
                 if (!$found) {
                     $erorrGrps = implode(',', $invlidGroups);
                     $tempErrors[] = ts("Do not select field %1 with Group by %2.", array(1 => $idMapping[$fld_id], 2 => $erorrGrps));
                 }
             }
         }
         if (!empty($tempErrors)) {
             $errors['fields'] = implode("<br/>", $tempErrors);
         }
     }
     if (!empty($fields['gid_value']) && !empty($fields['group_bys'])) {
         if (!array_key_exists('id', $fields['group_bys'])) {
             $errors['gid_value'] = ts("Filter with Group only allow with group by Contact");
         }
     }
     if ($fields['receive_date1_relative'] == '0') {
         $checkDate['receive_date1']['receive_date1_from'] = $fields['receive_date1_from'];
         $checkDate['receive_date1']['receive_date1_to'] = $fields['receive_date1_to'];
     }
     if ($fields['receive_date2_relative'] == '0') {
         $checkDate['receive_date2']['receive_date2_from'] = $fields['receive_date2_from'];
         $checkDate['receive_date2']['receive_date2_to'] = $fields['receive_date2_to'];
     }
     foreach ($checkDate as $date_range => $range_data) {
         foreach ($range_data as $key => $value) {
             if (CRM_Utils_Date::isDate($value)) {
                 $errorCount[$date_range][$key]['valid'] = 'true';
                 $errorCount[$date_range][$key]['is_empty'] = 'false';
             } else {
                 $errorCount[$date_range][$key]['valid'] = 'false';
                 $errorCount[$date_range][$key]['is_empty'] = 'true';
                 if (is_array($value)) {
                     foreach ($value as $v) {
                         if ($v) {
                             $errorCount[$date_range][$key]['is_empty'] = 'false';
                         }
                     }
                 } elseif (!isset($value)) {
                     $errorCount[$date_range][$key]['is_empty'] = 'false';
                 }
             }
         }
     }
     $errorText = ts("Select valid date range");
     foreach ($errorCount as $date_range => $error_data) {
         if ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'true' && $error_data[$date_range . '_to']['is_empty'] == 'true') {
                 $errors[$date_range . '_relative'] = $errorText;
             }
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'true' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'true') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
         }
     }
     return $errors;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:96,代码来源:Repeat.php

示例3: formRule

 /**
  * @param $fields
  * @param $files
  * @param $self
  *
  * @return array
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = $grouping = array();
     //check for searching combination of dispaly columns and
     //grouping criteria
     $ignoreFields = array('total_amount', 'sort_name');
     $errors = $self->customDataFormRule($fields, $ignoreFields);
     if (empty($fields['group_bys']['receive_date'])) {
         if (!empty($fields['receive_date_relative']) || CRM_Utils_Date::isDate($fields['receive_date_from']) || CRM_Utils_Date::isDate($fields['receive_date_to'])) {
             $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
         }
     }
     if (empty($fields['fields']['total_amount'])) {
         foreach (array('total_count_value', 'total_sum_value', 'total_avg_value') as $val) {
             if (!empty($fields[$val])) {
                 $errors[$val] = ts("Please select the Amount Statistics");
             }
         }
     }
     return $errors;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:28,代码来源:Summary.php

示例4: upgrade

 function upgrade($rev)
 {
     $upgrade =& new CRM_Upgrade_Form();
     //Run the SQL file
     $upgrade->processSQL($rev);
     // fix for CRM-5162
     // we need to encrypt all smtpPasswords if present
     require_once "CRM/Core/DAO/Preferences.php";
     $mailingDomain =& new CRM_Core_DAO_Preferences();
     $mailingDomain->find();
     while ($mailingDomain->fetch()) {
         if ($mailingDomain->mailing_backend) {
             $values = unserialize($mailingDomain->mailing_backend);
             if (isset($values['smtpPassword'])) {
                 require_once 'CRM/Utils/Crypt.php';
                 $values['smtpPassword'] = CRM_Utils_Crypt::encrypt($values['smtpPassword']);
                 $mailingDomain->mailing_backend = serialize($values);
                 $mailingDomain->save();
             }
         }
     }
     require_once "CRM/Core/DAO/Domain.php";
     $domain =& new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     $domain->selectAdd('config_backend');
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($dateFormat = CRM_Utils_Array::value('dateformatQfDate', $defaults)) {
             $dateFormatArray = explode(" ", $dateFormat);
             //replace new date format based on previous month format
             //%b month name [abbreviated]
             //%B full month name ('January'..'December')
             //%m decimal number, 0-padded ('01'..'12')
             if ($dateFormat == '%b %d %Y') {
                 $defaults['dateInputFormat'] = 'mm/dd/yy';
             } else {
                 if ($dateFormat == '%d-%b-%Y') {
                     $defaults['dateInputFormat'] = 'dd-mm-yy';
                 } else {
                     if (in_array('%b', $dateFormatArray)) {
                         $defaults['dateInputFormat'] = 'M d, yy';
                     } else {
                         if (in_array('%B', $dateFormatArray)) {
                             $defaults['dateInputFormat'] = 'MM d, yy';
                         } else {
                             $defaults['dateInputFormat'] = 'mm/dd/yy';
                         }
                     }
                 }
             }
         }
         // %p - lowercase ante/post meridiem ('am', 'pm')
         // %P - uppercase ante/post meridiem ('AM', 'PM')
         if ($dateTimeFormat = CRM_Utils_Array::value('dateformatQfDatetime', $defaults)) {
             $defaults['timeInputFormat'] = 2;
             $dateTimeFormatArray = explode(" ", $dateFormat);
             if (in_array('%P', $dateTimeFormatArray) || in_array('%p', $dateTimeFormatArray)) {
                 $defaults['timeInputFormat'] = 1;
             }
             unset($defaults['dateformatQfDatetime']);
         }
         unset($defaults['dateformatQfDate']);
         unset($defaults['dateformatTime']);
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::add($defaults);
     }
     $sql = "SELECT id, form_values FROM civicrm_report_instance";
     $instDAO = CRM_Core_DAO::executeQuery($sql);
     while ($instDAO->fetch()) {
         $fromVal = @unserialize($instDAO->form_values);
         foreach ((array) $fromVal as $key => $value) {
             if (strstr($key, '_relative')) {
                 $elementName = substr($key, 0, strlen($key) - strlen('_relative'));
                 $fromNamekey = $elementName . '_from';
                 $toNamekey = $elementName . '_to';
                 $fromNameVal = $fromVal[$fromNamekey];
                 $toNameVal = $fromVal[$toNamekey];
                 //check 'choose date range' is set
                 if ($value == '0') {
                     if (CRM_Utils_Date::isDate($fromNameVal)) {
                         $fromDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($fromNameVal));
                         $fromNameVal = $fromDate[0];
                     } else {
                         $fromNameVal = '';
                     }
                     if (CRM_Utils_Date::isDate($toNameVal)) {
                         $toDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($toNameVal));
                         $toNameVal = $toDate[0];
                     } else {
                         $toNameVal = '';
                     }
                 } else {
                     $fromNameVal = '';
                     $toNameVal = '';
                 }
                 $fromVal[$fromNamekey] = $fromNameVal;
                 $fromVal[$toNamekey] = $toNameVal;
                 continue;
             }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:ThreeOne.php

示例5: formRule

 function formRule(&$fields, &$files, $self)
 {
     require_once 'CRM/Utils/Date.php';
     $errors = $checkDate = $errorCount = array();
     $rules = array('id' => array('display_name', 'email', 'phone', 'state_province_id', 'country_id'), 'country_id' => array('country_id'), 'state_province_id' => array('country_id', 'state_province_id'), 'contribution_source' => array('contribution_source'), 'contribution_type' => array('contribution_type'));
     $idMapping = array('id' => 'Contact', 'country_id' => 'Country', 'state_province_id' => 'State/Province', 'contribution_source' => 'Contribution Source', 'contribution_type' => 'Contribution Type', 'display_name' => 'Contact Name', 'email' => 'Email', 'phone' => 'Phone');
     if (empty($fields['group_bys'])) {
         $errors['fields'] = ts('Please select at least one Group by field.');
     } else {
         if ((array_key_exists('contribution_source', $fields['group_bys']) || array_key_exists('contribution_type', $fields['group_bys'])) && count($fields['group_bys']) > 1) {
             $errors['fields'] = ts('You can not use other Group by with Contribution type or Contribution source.');
         } else {
             foreach ($fields['fields'] as $fld_id => $value) {
                 if (!($fld_id == 'total_amount1') && !($fld_id == 'total_amount2')) {
                     $found = false;
                     $invlidGroups = array();
                     foreach ($fields['group_bys'] as $grp_id => $val) {
                         $validFields = $rules[$grp_id];
                         if (in_array($fld_id, $validFields)) {
                             $found = true;
                         } else {
                             $invlidGroups[] = $idMapping[$grp_id];
                         }
                     }
                     if (!$found) {
                         $erorrGrps = implode(',', $invlidGroups);
                         $tempErrors[] = ts("Do not select field %1 with Group by %2.", array(1 => $idMapping[$fld_id], 2 => $erorrGrps));
                     }
                 }
             }
             if (!empty($tempErrors)) {
                 $errors['fields'] = implode("<br>", $tempErrors);
             }
         }
     }
     if (!empty($fields['gid_value']) && CRM_Utils_Array::value('group_bys', $fields)) {
         if (!array_key_exists('id', $fields['group_bys'])) {
             $errors['gid_value'] = ts("Filter with Group only allow with group by Contact");
         }
     }
     if ($fields['receive_date1_relative'] == '0') {
         $checkDate['receive_date1']['receive_date1_from'] = $fields['receive_date1_from'];
         $checkDate['receive_date1']['receive_date1_to'] = $fields['receive_date1_to'];
     }
     if ($fields['receive_date2_relative'] == '0') {
         $checkDate['receive_date2']['receive_date2_from'] = $fields['receive_date2_from'];
         $checkDate['receive_date2']['receive_date2_to'] = $fields['receive_date2_to'];
     }
     foreach ($checkDate as $date_range => $range_data) {
         foreach ($range_data as $key => $value) {
             if (CRM_Utils_Date::isDate($value)) {
                 $errorCount[$date_range][$key]['valid'] = 'true';
                 $errorCount[$date_range][$key]['is_empty'] = 'false';
             } else {
                 $errorCount[$date_range][$key]['valid'] = 'false';
                 $errorCount[$date_range][$key]['is_empty'] = 'true';
                 foreach ($value as $v) {
                     if ($v) {
                         $errorCount[$date_range][$key]['is_empty'] = 'false';
                     }
                 }
             }
         }
     }
     $errorText = ts("Select valid date range");
     foreach ($errorCount as $date_range => $error_data) {
         if ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'true' && $error_data[$date_range . '_to']['is_empty'] == 'true') {
                 $errors[$date_range . '_relative'] = $errorText;
             }
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'true' && $error_data[$date_range . '_to']['valid'] == 'false') {
             if ($error_data[$date_range . '_to']['is_empty'] == 'false') {
                 $errors[$date_range . '_to'] = $errorText;
             }
         } elseif ($error_data[$date_range . '_from']['valid'] == 'false' && $error_data[$date_range . '_to']['valid'] == 'true') {
             if ($error_data[$date_range . '_from']['is_empty'] == 'false') {
                 $errors[$date_range . '_from'] = $errorText;
             }
         }
     }
     return $errors;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:88,代码来源:Repeat.php

示例6: formRule

 static function formRule($fields, $files, $self)
 {
     $errors = $grouping = array();
     //check for searching combination of dispaly columns and
     //grouping criteria
     $ignoreFields = array('total_amount', 'sort_name');
     $errors = $self->customDataFormRule($fields, $ignoreFields);
     if (CRM_Utils_Array::value('receive_date', $fields['group_bys'])) {
         foreach ($self->_columns as $tableName => $table) {
             if (array_key_exists('fields', $table)) {
                 foreach ($table['fields'] as $fieldName => $field) {
                     if (CRM_Utils_Array::value($field['name'], $fields['fields']) && $fields['fields'][$field['name']] && in_array($field['name'], array('sort_name', 'postal_greeting_display', 'contribution_source', 'contribution_type'))) {
                         $grouping[] = $field['title'];
                     }
                 }
             }
         }
         if (!empty($grouping)) {
             $temp = 'and ' . implode(', ', $grouping);
             $errors['fields'] = ts("Please do not use combination of Receive Date %1", array(1 => $temp));
         }
     }
     if (!CRM_Utils_Array::value('receive_date', $fields['group_bys'])) {
         if (CRM_Utils_Array::value('receive_date_relative', $fields) || CRM_Utils_Date::isDate($fields['receive_date_from']) || CRM_Utils_Date::isDate($fields['receive_date_to'])) {
             $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
         }
     }
     if (!CRM_Utils_Array::value('total_amount', $fields['fields'])) {
         foreach (array('total_count_value', 'total_sum_value', 'total_avg_value') as $val) {
             if (CRM_Utils_Array::value($val, $fields)) {
                 $errors[$val] = ts("Please select the Amount Statistics");
             }
         }
     }
     return $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:36,代码来源:Summary.php

示例7: getFromTo

 static function getFromTo($relative, $from, $to)
 {
     require_once 'CRM/Utils/Date.php';
     if ($relative) {
         list($term, $unit) = explode('.', $relative);
         $dateRange = CRM_Utils_Date::relativeToAbsolute($term, $unit);
         $from = $dateRange['from'];
         $to = $dateRange['to'];
     }
     if (CRM_Utils_Date::isDate($from)) {
         $revDate = array_reverse($from);
         $from = CRM_Utils_Date::format($revDate);
     } else {
         $from = null;
     }
     if (CRM_Utils_Date::isDate($to)) {
         $revDate = array_reverse($to);
         $to = CRM_Utils_Date::format($revDate);
     } else {
         $to = null;
     }
     return array($from, $to);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:23,代码来源:Form.php


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