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


PHP CRM_Utils_String::ellipsify方法代码示例

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


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

示例1: testEllipsify

 public function testEllipsify()
 {
     $maxLen = 5;
     $cases = array('1' => '1', '12345' => '12345', '123456' => '12...');
     foreach ($cases as $input => $expected) {
         $this->assertEquals($expected, CRM_Utils_String::ellipsify($input, $maxLen));
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:8,代码来源:StringTest.php

示例2: testEllipsify

 public function testEllipsify()
 {
     $maxLen = 5;
     $cases = array('1' => '1', '12345' => '12345', '123456' => '12...');
     foreach ($cases as $input => $expected) {
         $this->assertEquals($expected, CRM_Utils_String::ellipsify($input, $maxLen));
     }
     // test utf-8 string, CRM-18997
     $input = 'Registro de eventos on-line: Taller: "Onboarding - Cómo integrar exitosamente a los nuevos talentos dentro de su organización - Formación práctica."';
     $maxLen = 128;
     $this->assertEquals(TRUE, mb_check_encoding(CRM_Utils_String::ellipsify($input, $maxLen), 'UTF-8'));
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:12,代码来源:StringTest.php

示例3: addParticipant

 /**
  * Process the participant.
  *
  * @param CRM_Core_Form $form
  * @param int $contactID
  *
  * @return \CRM_Event_BAO_Participant
  */
 public static function addParticipant(&$form, $contactID)
 {
     if (empty($form->_params)) {
         return NULL;
     }
     $params = $form->_params;
     $transaction = new CRM_Core_Transaction();
     $groupName = 'participant_role';
     $query = "\nSELECT  v.label as label ,v.value as value\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  v.option_group_id = g.id\n  AND  g.name            = %1\n  AND  v.is_active       = 1\n  AND  g.is_active       = 1\n";
     $p = array(1 => array($groupName, 'String'));
     $dao = CRM_Core_DAO::executeQuery($query, $p);
     if ($dao->fetch()) {
         $roleID = $dao->value;
     }
     // handle register date CRM-4320
     $registerDate = NULL;
     if (!empty($form->_allowConfirmation) && $form->_participantId) {
         $registerDate = $params['participant_register_date'];
     } elseif (!empty($params['participant_register_date']) && is_array($params['participant_register_date']) && !empty($params['participant_register_date'])) {
         $registerDate = CRM_Utils_Date::format($params['participant_register_date']);
     }
     $participantFields = CRM_Event_DAO_Participant::fields();
     $participantParams = array('id' => CRM_Utils_Array::value('participant_id', $params), 'contact_id' => $contactID, 'event_id' => $form->_eventId ? $form->_eventId : $params['event_id'], 'status_id' => CRM_Utils_Array::value('participant_status', $params, 1), 'role_id' => CRM_Utils_Array::value('participant_role_id', $params, $roleID), 'register_date' => $registerDate ? $registerDate : date('YmdHis'), 'source' => CRM_Utils_String::ellipsify(isset($params['participant_source']) ? CRM_Utils_Array::value('participant_source', $params) : CRM_Utils_Array::value('description', $params), $participantFields['participant_source']['maxlength']), 'fee_level' => CRM_Utils_Array::value('amount_level', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'fee_amount' => CRM_Utils_Array::value('fee_amount', $params), 'registered_by_id' => CRM_Utils_Array::value('registered_by_id', $params), 'discount_id' => CRM_Utils_Array::value('discount_id', $params), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
     if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
         $participantParams['is_test'] = 1;
     } else {
         $participantParams['is_test'] = 0;
     }
     if (!empty($form->_params['note'])) {
         $participantParams['note'] = $form->_params['note'];
     } elseif (!empty($form->_params['participant_note'])) {
         $participantParams['note'] = $form->_params['participant_note'];
     }
     // reuse id if one already exists for this one (can happen
     // with back button being hit etc)
     if (!$participantParams['id'] && !empty($params['contributionID'])) {
         $pID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $params['contributionID'], 'participant_id', 'contribution_id');
         $participantParams['id'] = $pID;
     }
     $participantParams['discount_id'] = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
     if (!$participantParams['discount_id']) {
         $participantParams['discount_id'] = "null";
     }
     $participant = CRM_Event_BAO_Participant::create($participantParams);
     $transaction->commit();
     return $participant;
 }
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:55,代码来源:Registration.php

示例4: parseBacktrace

 /**
  * Render a backtrace array as an array.
  *
  * @param array $backTrace
  *   Array of stack frames.
  * @param bool $showArgs
  *   TRUE if we should try to display content of function arguments (which could be sensitive); FALSE to display only the type of each function argument.
  * @param int $maxArgLen
  *   Maximum number of characters to show from each argument string.
  * @return array
  * @see debug_backtrace
  * @see Exception::getTrace()
  */
 public static function parseBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80)
 {
     $ret = array();
     foreach ($backTrace as $trace) {
         $args = array();
         $fnName = CRM_Utils_Array::value('function', $trace);
         $className = isset($trace['class']) ? $trace['class'] . $trace['type'] : '';
         // Do not show args for a few password related functions
         $skipArgs = $className == 'DB::' && $fnName == 'connect' ? TRUE : FALSE;
         if (!empty($trace['args'])) {
             foreach ($trace['args'] as $arg) {
                 if (!$showArgs || $skipArgs) {
                     $args[] = '(' . gettype($arg) . ')';
                     continue;
                 }
                 switch ($type = gettype($arg)) {
                     case 'boolean':
                         $args[] = $arg ? 'TRUE' : 'FALSE';
                         break;
                     case 'integer':
                     case 'double':
                         $args[] = $arg;
                         break;
                     case 'string':
                         $args[] = '"' . CRM_Utils_String::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen) . '"';
                         break;
                     case 'array':
                         $args[] = '(Array:' . count($arg) . ')';
                         break;
                     case 'object':
                         $args[] = 'Object(' . get_class($arg) . ')';
                         break;
                     case 'resource':
                         $args[] = 'Resource';
                         break;
                     case 'NULL':
                         $args[] = 'NULL';
                         break;
                     default:
                         $args[] = "({$type})";
                         break;
                 }
             }
         }
         $ret[] = sprintf("%s(%s): %s%s(%s)", CRM_Utils_Array::value('file', $trace, '[internal function]'), CRM_Utils_Array::value('line', $trace, ''), $className, $fnName, implode(", ", $args));
     }
     return $ret;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:61,代码来源:Error.php

示例5: formatBacktrace

 /**
  * Render a backtrace array as a string
  *
  * @param array $backTrace array of stack frames
  * @param boolean $showArgs TRUE if we should try to display content of function arguments (which could be sensitive); FALSE to display only the type of each function argument
  * @param int $maxArgLen maximum number of characters to show from each argument string
  * @return string printable plain-text
  * @see debug_backtrace
  * @see Exception::getTrace()
  */
 static function formatBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80)
 {
     $message = '';
     foreach ($backTrace as $idx => $trace) {
         $args = array();
         $fnName = CRM_Utils_Array::value('function', $trace);
         $className = array_key_exists('class', $trace) ? $trace['class'] . $trace['type'] : '';
         // do now show args for a few password related functions
         $skipArgs = $className == 'DB::' && $fnName == 'connect' ? TRUE : FALSE;
         foreach ($trace['args'] as $arg) {
             if (!$showArgs || $skipArgs) {
                 $args[] = '(' . gettype($arg) . ')';
                 continue;
             }
             switch ($type = gettype($arg)) {
                 case 'boolean':
                     $args[] = $arg ? 'TRUE' : 'FALSE';
                     break;
                 case 'integer':
                 case 'double':
                     $args[] = $arg;
                     break;
                 case 'string':
                     $args[] = '"' . CRM_Utils_String::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen) . '"';
                     break;
                 case 'array':
                     $args[] = '(Array:' . count($arg) . ')';
                     break;
                 case 'object':
                     $args[] = 'Object(' . get_class($arg) . ')';
                     break;
                 case 'resource':
                     $args[] = 'Resource';
                     break;
                 case 'NULL':
                     $args[] = 'NULL';
                     break;
                 default:
                     $args[] = "({$type})";
                     break;
             }
         }
         $message .= sprintf("#%s %s(%s): %s%s(%s)\n", $idx, CRM_Utils_Array::value('file', $trace, '[internal function]'), CRM_Utils_Array::value('line', $trace, ''), $className, $fnName, implode(", ", $args));
     }
     $message .= sprintf("#%s {main}\n", 1 + $idx);
     return $message;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:57,代码来源:Error.php


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