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


PHP CRM_Utils_String::startsWith方法代码示例

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


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

示例1: getContactActivitySelector

 /**
  * Wrapper for ajax activity selector.
  *
  * @param array $params
  *   Associated array for params record id.
  *
  * @return array
  *   Associated array of contact activities
  */
 public static function getContactActivitySelector(&$params)
 {
     // Format the params.
     $params['offset'] = ($params['page'] - 1) * $params['rp'];
     $params['rowCount'] = $params['rp'];
     $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
     $params['caseId'] = NULL;
     $context = CRM_Utils_Array::value('context', $params);
     $showContactOverlay = !CRM_Utils_String::startsWith($context, "dashlet");
     // Get contact activities.
     $activities = CRM_Activity_BAO_Activity::getActivities($params);
     // Add total.
     $params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
     // Format params and add links.
     $contactActivities = array();
     if (!empty($activities)) {
         $activityStatus = CRM_Core_PseudoConstant::activityStatus();
         // Check logged in user for permission.
         $page = new CRM_Core_Page();
         CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
         $permissions = array($page->_permission);
         if (CRM_Core_Permission::check('delete activities')) {
             $permissions[] = CRM_Core_Permission::DELETE;
         }
         $mask = CRM_Core_Action::mask($permissions);
         foreach ($activities as $activityId => $values) {
             $activity = array();
             $activity['DT_RowId'] = $activityId;
             // Add class to this row if overdue.
             $activity['DT_RowClass'] = 'crm-entity';
             if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
                 $activity['DT_RowClass'] .= ' status-overdue';
             } else {
                 $activity['DT_RowClass'] .= ' status-ontime';
             }
             $activity['DT_RowAttr'] = array();
             $activity['DT_RowAttr']['data-entity'] = 'activity';
             $activity['DT_RowAttr']['data-id'] = $activityId;
             $activity['activity_type'] = $values['activity_type'];
             $activity['subject'] = $values['subject'];
             $activity['source_contact_name'] = '';
             if ($params['contact_id'] == $values['source_contact_id']) {
                 $activity['source_contact_name'] = $values['source_contact_name'];
             } elseif ($values['source_contact_id']) {
                 $srcTypeImage = "";
                 if ($showContactOverlay) {
                     $srcTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(CRM_Contact_BAO_Contact::getContactType($values['source_contact_id']), FALSE, $values['source_contact_id']);
                 }
                 $activity['source_contact_name'] = $srcTypeImage . CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
             } else {
                 $activity['source_contact_name'] = '<em>n/a</em>';
             }
             $activity['target_contact_name'] = '';
             if (isset($values['mailingId']) && !empty($values['mailingId'])) {
                 $activity['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
             } elseif (!empty($values['recipients'])) {
                 $activity['target_contact_name'] = $values['recipients'];
             } elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
                 $activity['target_contact_name'] = '';
                 foreach ($values['target_contact_name'] as $tcID => $tcName) {
                     $targetTypeImage = "";
                     $targetLink = CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
                     if ($showContactOverlay) {
                         $targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(CRM_Contact_BAO_Contact::getContactType($tcID), FALSE, $tcID);
                         $activity['target_contact_name'] .= "<div>{$targetTypeImage}  {$targetLink}";
                     } else {
                         $activity['target_contact_name'] .= $targetLink;
                     }
                 }
                 if ($extraCount = $values['target_contact_counter'] - 1) {
                     $activity['target_contact_name'] .= ";<br />" . "(" . ts('%1 more', array(1 => $extraCount)) . ")";
                 }
                 if ($showContactOverlay) {
                     $activity['target_contact_name'] .= "</div> ";
                 }
             } elseif (!$values['target_contact_name']) {
                 $activity['target_contact_name'] = '<em>n/a</em>';
             }
             $activity['assignee_contact_name'] = '';
             if (empty($values['assignee_contact_name'])) {
                 $activity['assignee_contact_name'] = '<em>n/a</em>';
             } elseif (!empty($values['assignee_contact_name'])) {
                 $count = 0;
                 $activity['assignee_contact_name'] = '';
                 foreach ($values['assignee_contact_name'] as $acID => $acName) {
                     if ($acID && $count < 5) {
                         $assigneeTypeImage = "";
                         $assigneeLink = CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
                         if ($showContactOverlay) {
                             $assigneeTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(CRM_Contact_BAO_Contact::getContactType($acID), FALSE, $acID);
                             $activity['assignee_contact_name'] .= "<div>{$assigneeTypeImage} {$assigneeLink}";
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例2: filterByWildcards

 /**
  * @param string|array $patterns
  * @param array $allStrings
  * @param bool $allowNew
  *   Whether to return new, unrecognized names.
  * @return array
  */
 public static function filterByWildcards($patterns, $allStrings, $allowNew = FALSE)
 {
     $patterns = (array) $patterns;
     $result = array();
     foreach ($patterns as $pattern) {
         if (!\CRM_Utils_String::endsWith($pattern, '*')) {
             if ($allowNew || in_array($pattern, $allStrings)) {
                 $result[] = $pattern;
             }
         } else {
             $prefix = rtrim($pattern, '*');
             foreach ($allStrings as $key) {
                 if (\CRM_Utils_String::startsWith($key, $prefix)) {
                     $result[] = $key;
                 }
             }
         }
     }
     return array_values(array_unique($result));
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:27,代码来源:String.php


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