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


PHP CRM_Utils_Date::getDateFormat方法代码示例

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


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

示例1: format


//.........这里部分代码省略.........
         // make sure we have all the name fields.
         foreach ($nameParams as $name => $value) {
             if (empty($formatted[$name]) && $value) {
                 $formatted[$name] = $value;
             }
         }
         $tokens = array();
         CRM_Utils_Hook::tokens($tokens);
         $tokenFields = array();
         foreach ($tokens as $catTokens) {
             foreach ($catTokens as $token => $label) {
                 $tokenFields[] = $token;
             }
         }
         //build the sort name.
         $format = Civi::settings()->get('sort_name_format');
         $sortName = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE, TRUE, $tokenFields);
         $sortName = trim($sortName);
         //build the display name.
         $format = Civi::settings()->get('display_name_format');
         $displayName = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE, TRUE, $tokenFields);
         $displayName = trim($displayName);
     }
     //start further check for email.
     if (empty($sortName) || empty($displayName)) {
         $email = NULL;
         if (!empty($params['email']) && is_array($params['email'])) {
             foreach ($params['email'] as $emailBlock) {
                 if (isset($emailBlock['is_primary'])) {
                     $email = $emailBlock['email'];
                     break;
                 }
             }
         }
         $uniqId = CRM_Utils_Array::value('user_unique_id', $params);
         if (!$email && $contact->id) {
             $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contact->id);
         }
     }
     //now set the names.
     $names = array('displayName' => 'display_name', 'sortName' => 'sort_name');
     foreach ($names as $value => $name) {
         if (empty(${$value})) {
             if ($email) {
                 ${$value} = $email;
             } elseif ($uniqId) {
                 ${$value} = $uniqId;
             } elseif (!empty($params[$name])) {
                 ${$value} = $params[$name];
             } elseif ($displayName) {
                 ${$value} = $displayName;
             }
         }
         //finally if we could not pass anything lets keep db.
         if (!empty(${$value})) {
             $contact->{$name} = ${$value};
         }
     }
     $format = CRM_Utils_Date::getDateFormat('birth');
     if ($date = CRM_Utils_Array::value('birth_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } elseif (in_array($format, array('yy-mm'))) {
             $date = $date . '-01';
         } elseif (in_array($format, array('M yy'))) {
             $date = $date . '-01';
         } elseif (in_array($format, array('yy'))) {
             $date = $date . '-01-01';
         }
         $contact->birth_date = CRM_Utils_Date::processDate($date);
     } elseif ($contact->birth_date) {
         $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
     }
     if ($date = CRM_Utils_Array::value('deceased_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } elseif (in_array($format, array('yy-mm'))) {
             $date = $date . '-01';
         } elseif (in_array($format, array('M yy'))) {
             $date = $date . '-01';
         } elseif (in_array($format, array('yy'))) {
             $date = $date . '-01-01';
         }
         $contact->deceased_date = CRM_Utils_Date::processDate($date);
     } elseif ($contact->deceased_date) {
         $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
     }
     if ($middle_name = CRM_Utils_Array::value('middle_name', $params)) {
         $contact->middle_name = $middle_name;
     }
     return $contact;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:Individual.php

示例2: format


//.........这里部分代码省略.........
             }
         }
     }
     if ($lastName || $firstName || $middleName) {
         if ($lastName && $firstName) {
             $contact->sort_name = trim("{$lastName}, {$firstName}");
         } else {
             $contact->sort_name = trim("{$lastName} {$firstName}");
         }
         $display_name = trim("{$prefix} {$firstName} {$middleName} {$lastName} {$suffix}");
         $display_name = str_replace('  ', ' ', $display_name);
     }
     if (isset($display_name) && trim($display_name)) {
         $contact->display_name = trim($display_name);
     }
     if (CRM_Utils_Array::value('email', $params) && is_array($params['email'])) {
         foreach ($params['email'] as $emailBlock) {
             if (isset($emailBlock['is_primary'])) {
                 $email = $emailBlock['email'];
                 break;
             }
         }
     }
     $uniqId = CRM_Utils_Array::value('user_unique_id', $params);
     if (empty($contact->display_name)) {
         if (isset($email)) {
             $contact->display_name = $email;
         } else {
             if (isset($uniqId)) {
                 $contact->display_name = $uniqId;
             }
         }
     }
     if (empty($contact->sort_name)) {
         if (isset($email)) {
             $contact->sort_name = $email;
         } else {
             if (isset($uniqId)) {
                 $contact->sort_name = $uniqId;
             }
         }
     }
     $format = CRM_Utils_Date::getDateFormat('birth');
     if ($date = CRM_Utils_Array::value('birth_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } else {
             if (in_array($format, array('yy-mm'))) {
                 $date = $date . '-01';
             } else {
                 if (in_array($format, array('M yy'))) {
                     $date = '01 ' . $date;
                 } else {
                     if (in_array($format, array('yy'))) {
                         $date = $date . '-01-01';
                     }
                 }
             }
         }
         $contact->birth_date = CRM_Utils_Date::processDate($date);
     } else {
         if ($contact->birth_date) {
             $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
         }
     }
     if ($date = CRM_Utils_Array::value('deceased_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } else {
             if (in_array($format, array('yy-mm'))) {
                 $date = $date . '-01';
             } else {
                 if (in_array($format, array('M yy'))) {
                     $date = '01 ' . $date;
                 } else {
                     if (in_array($format, array('yy'))) {
                         $date = $date . '-01-01';
                     }
                 }
             }
         }
         $contact->deceased_date = CRM_Utils_Date::processDate($date);
     } else {
         if ($contact->deceased_date) {
             $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
         }
     }
     if ($middle_name = CRM_Utils_Array::value('middle_name', $params)) {
         $contact->middle_name = $middle_name;
     }
     return $contact;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Individual.php

示例3: format


//.........这里部分代码省略.........
         $format = str_replace('contact.', '', $format);
         $sortName = CRM_Utils_Address::format($formatted, $format, false, false, true, $tokenFields);
         $sortName = trim($sortName);
         //build the display name.
         $format = CRM_Core_BAO_Preferences::value('display_name_format');
         $format = str_replace('contact.', '', $format);
         $displayName = CRM_Utils_Address::format($formatted, $format, false, false, true, $tokenFields);
         $displayName = trim($displayName);
     }
     //start further check for email.
     if (empty($sortName) || empty($displayName)) {
         $email = null;
         if (CRM_Utils_Array::value('email', $params) && is_array($params['email'])) {
             foreach ($params['email'] as $emailBlock) {
                 if (isset($emailBlock['is_primary'])) {
                     $email = $emailBlock['email'];
                     break;
                 }
             }
         }
         $uniqId = CRM_Utils_Array::value('user_unique_id', $params);
         if (!$email && $contact->id) {
             $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contact->id);
         }
     }
     //now set the names.
     $names = array('sortName' => 'sort_name', 'displayName' => 'display_name');
     foreach ($names as $value => $name) {
         if (empty(${$value})) {
             if ($email) {
                 ${$value} = $email;
             } else {
                 if ($uniqId) {
                     ${$value} = $uniqId;
                 }
             }
         }
         //finally if we could not pass anything lets keep db.
         if (!empty(${$value})) {
             $contact->{$name} = ${$value};
         }
     }
     $format = CRM_Utils_Date::getDateFormat('birth');
     if ($date = CRM_Utils_Array::value('birth_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } else {
             if (in_array($format, array('yy-mm'))) {
                 $date = $date . '-01';
             } else {
                 if (in_array($format, array('M yy'))) {
                     $date = '01 ' . $date;
                 } else {
                     if (in_array($format, array('yy'))) {
                         $date = $date . '-01-01';
                     }
                 }
             }
         }
         $contact->birth_date = CRM_Utils_Date::processDate($date);
     } else {
         if ($contact->birth_date) {
             $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
         }
     }
     if ($date = CRM_Utils_Array::value('deceased_date', $params)) {
         if (in_array($format, array('dd-mm', 'mm/dd'))) {
             $separator = '/';
             if ($format == 'dd-mm') {
                 $separator = '-';
             }
             $date = $date . $separator . '1902';
         } else {
             if (in_array($format, array('yy-mm'))) {
                 $date = $date . '-01';
             } else {
                 if (in_array($format, array('M yy'))) {
                     $date = '01 ' . $date;
                 } else {
                     if (in_array($format, array('yy'))) {
                         $date = $date . '-01-01';
                     }
                 }
             }
         }
         $contact->deceased_date = CRM_Utils_Date::processDate($date);
     } else {
         if ($contact->deceased_date) {
             $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
         }
     }
     if ($middle_name = CRM_Utils_Array::value('middle_name', $params)) {
         $contact->middle_name = $middle_name;
     }
     return $contact;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Individual.php


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