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


PHP strlen_utf函数代码示例

本文整理汇总了PHP中strlen_utf函数的典型用法代码示例。如果您正苦于以下问题:PHP strlen_utf函数的具体用法?PHP strlen_utf怎么用?PHP strlen_utf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: substr_utf

/**
* Extended substr function. If it finds mbstring extension it will use, else
* it will use old substr() function
*
* @param string $string String that need to be fixed
* @param integer $start Start extracting from
* @param integer $length Extract number of characters
* @return string
*/
function substr_utf($string, $start = 0, $length = null)
{
    $start = (int) $start >= 0 ? (int) $start : 0;
    if (is_null($length)) {
        $length = strlen_utf($string) - $start;
    }
    return substr($string, $start, $length);
}
开发者ID:urichalex,项目名称:sourcebansv1,代码行数:17,代码来源:system-functions.php

示例2: substr_utf

/**
 * Extended substr function. If it finds mbstring extension it will use, else 
 * it will use old substr() function
 *
 * @param string $string
 * @param integer $start
 * @param integer $length
 * @return string
 */
function substr_utf($string, $start = 0, $length = null)
{
    $start = (int) $start >= 0 ? (int) $start : 0;
    if (is_null($length)) {
        $lenght = strlen_utf($string) - $start;
    }
    // if
    return CAN_USE_MBSTRING ? mb_substr($string, $start, $length, 'UTF-8') : substr($string, $start, $length);
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:18,代码来源:utf.php

示例3: getPreviewText

	/**
	 * Return the first $len - 3 characters of the comment's text followed by "..."
	 *
	 * @param unknown_type $len
	 */
	function getPreviewText($len = 30) {
		if ($len <= 3) return "...";
		$text = $this->getText();
		if (strlen_utf($text) > $len) {
			return substr_utf($text, 0, $len - 3) . "...";
		} else {
			return $text;
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:14,代码来源:Comment.class.php

示例4: substr_utf

/**
 * Extended substr function. If it finds mbstring extension it will use, else 
 * it will use old substr() function
 *
 * @access public
 * @param string $string String that need to be fixed
 * @param integer $start Start extracting from
 * @param integer $length Extract number of characters
 * @return string
 */
function substr_utf($string, $start = 0, $length = null)
{
    $start = (int) $start >= 0 ? (int) $start : 0;
    if (is_null($length)) {
        $length = strlen_utf($string) - $start;
    }
    // if
    if (function_exists('mb_substr')) {
        return mb_substr($string, $start, $length);
    } else {
        return substr($string, $start, $length);
    }
    // if
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:24,代码来源:utf.php

示例5: getObjectName

 /**
  * Return object name
  *
  * @access public
  * @param void
  * @return string
  */
 function getObjectName($charLimit = 0)
 {
     $name = $this->getTitle();
     if (!$name) {
         $name = $this->getText();
     }
     if ($charLimit > 0 && strlen_utf($name) > $charLimit) {
         return substr_utf($name, 0, $charLimit) . '...';
     } else {
         return $name;
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:19,代码来源:ProjectTask.class.php

示例6: format_date

            } else {
                $real_duration = $event_duration;
            }
        }
    }
    $pre_tf = $real_start->getDay() == $real_duration->getDay() ? '' : 'D j, ';
    $ev_hour_text = format_date($real_start, $pre_tf . $timeformat, 0) . " - " . format_date($real_duration, $pre_tf . $timeformat, 0);
    $assigned = "";
    if ($event instanceof ProjectTask && $event->getAssignedToContactId() > 0) {
        $assigned = "<br>" . lang('assigned to') . ': ' . $event->getAssignedToName();
        $tipBody = purify_html($event->getText());
    } else {
        $tipBody = $ev_hour_text . $assigned . (trim(clean($event->getDescription())) != '' ? '<br><br>' . clean($event->getDescription()) : '');
        $tipBody = str_replace(array("\r", "\n"), array(' ', '<br>'), $tipBody);
    }
    if (strlen_utf($tipBody) > 200) {
        $tipBody = substr_utf($tipBody, 0, strpos($tipBody, ' ', 200)) . ' ...';
    }
    ?>
												<script>
													if (<?php 
    echo $top;
    ?>
 < scroll_to || scroll_to == -1) {
														scroll_to = <?php 
    echo $top;
    ?>
;
													}
													addTip('d_ev_div_' + <?php 
    echo $event->getId();
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:viewdate.php

示例7: get_conversation_info

 function get_conversation_info()
 {
     $email = MailContents::findById(array_var($_GET, 'id'));
     if (!$email instanceof MailContent) {
         flash_error(lang('email dnx'));
         ajx_current("empty");
         return;
     }
     $info = array();
     $mails = MailContents::getMailsFromConversation($email);
     foreach ($mails as $mail) {
         $text = $mail->getBodyPlain();
         if (strlen_utf($text) > 80) {
             $text = substr_utf($text, 0, 80) . "...";
         }
         $state = $mail->getState();
         $show_user_icon = false;
         if ($state == 1 || $state == 3 || $state == 5) {
             if ($mail->getCreatedById() == logged_user()->getId()) {
                 $from = lang('you');
             } else {
                 $from = $mail->getCreatedByDisplayName();
             }
             $show_user_icon = true;
         } else {
             $from = $mail->getFrom();
         }
         $info[] = array('id' => $mail->getId(), 'date' => $mail->getReceivedDate() instanceof DateTimeValue ? $mail->getReceivedDate()->isToday() ? format_time($mail->getReceivedDate()) : format_datetime($mail->getReceivedDate()) : lang('n/a'), 'has_att' => $mail->getHasAttachments(), 'text' => htmlentities($text), 'read' => $mail->getIsRead(logged_user()->getId()), 'from_name' => $state == 1 || $state == 3 || $state == 5 ? lang('you') : $mail->getFromName(), 'from' => $from, 'show_ico' => $show_user_icon);
     }
     tpl_assign('source_email_id', array_var($_GET, 'id'));
     tpl_assign('emails_info', $info);
     $this->setLayout("html");
     $this->setTemplate("llo_email_conversation");
     ajx_current("empty");
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:35,代码来源:MailController.class.php

示例8: export_to_csv_file

 function export_to_csv_file()
 {
     $ids = array_var($_REQUEST, 'ids');
     $idsall = array_var($_REQUEST, 'allIds');
     $export_all = array_var($_REQUEST, 'export_all');
     $this->setTemplate('csv_export');
     $type = array_var($_REQUEST, 'type', array_var($_SESSION, 'import_type', 'contact'));
     //type of import (contact - company)
     tpl_assign('import_type', $type);
     if (!isset($_SESSION['import_type']) || $type != $_SESSION['import_type'] && $type != '') {
         $_SESSION['import_type'] = $type;
     }
     $delimiter = array_var($_REQUEST, 'delimiter', ',');
     if ($delimiter == '') {
         $delimiter = ',';
     }
     $checked_fields = $type == 'contact' ? array_var($_REQUEST, 'check_contact') : array_var($_REQUEST, 'check_company');
     if (is_array($checked_fields) && ($ids || $idsall || $export_all)) {
         $titles = '';
         $imp_type = array_var($_SESSION, 'import_type', 'contact');
         if ($imp_type == 'contact') {
             $field_names = Contacts::getContactFieldNames();
             foreach ($checked_fields as $k => $v) {
                 if (isset($field_names["contact[{$k}]"]) && $v == 'checked') {
                     $titles .= $field_names["contact[{$k}]"] . $delimiter;
                 }
             }
             $titles = substr_utf($titles, 0, strlen_utf($titles) - 1) . "\n";
         } else {
             $field_names = Contacts::getCompanyFieldNames();
             foreach ($checked_fields as $k => $v) {
                 if (isset($field_names["company[{$k}]"]) && $v == 'checked') {
                     $titles .= $field_names["company[{$k}]"] . $delimiter;
                 }
             }
             $titles = substr_utf($titles, 0, strlen_utf($titles) - 1) . "\n";
         }
         // export the same type of contact objects that are enabled in the contacts tab.
         $extra_conditions = "";
         if (array_var($_SESSION, 'import_type', 'contact') == 'contact') {
             $extra_conditions = '  `is_company` = 0 ';
             if (!user_config_option("viewContactsChecked")) {
                 $extra_conditions .= ' AND  `user_type` != 0 ';
             }
             if (!user_config_option("viewUsersChecked")) {
                 $extra_conditions .= ' AND `user_type` < 1 ';
             }
         }
         // --
         $filename = rand() . '.tmp';
         $handle = fopen(ROOT . '/tmp/' . $filename, 'wb');
         fwrite($handle, $titles);
         $conditions = $extra_conditions;
         $ids_sql = "";
         if (!$export_all) {
             $ids_sql = $ids ? " AND id IN (" . $ids . ") " : "";
         }
         $members = active_context_members(false);
         $context_condition = $this->getActiveContextConditions();
         if (array_var($_SESSION, 'import_type', 'contact') == 'contact') {
             $conditions .= " AND `archived_by_id` = 0 ";
             $conditions .= $ids_sql;
             $conditions .= $context_condition;
             $contacts = Contacts::instance()->getAllowedContacts($conditions);
             foreach ($contacts as $contact) {
                 fwrite($handle, $this->build_csv_from_contact($contact, $checked_fields, $delimiter) . "\n");
             }
         } else {
             $conditions .= ($conditions == "" ? "" : " AND ") . "`archived_by_id` = 0" . ($conditions ? " AND {$conditions}" : "");
             $conditions .= $ids_sql;
             $conditions .= $context_condition;
             $companies = Contacts::getVisibleCompanies(logged_user(), $conditions);
             foreach ($companies as $company) {
                 fwrite($handle, $this->build_csv_from_company($company, $checked_fields, $delimiter) . "\n");
             }
         }
         fclose($handle);
         $_SESSION['contact_export_filename'] = $filename;
         flash_success($imp_type == 'contact' ? lang('success export contacts') : lang('success export companies'));
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:81,代码来源:ContactController.class.php

示例9: getObjectName

 /**
  * Return object name
  *
  * @access public
  * @param void
  * @return string
  */
 function getObjectName()
 {
     $return = substr_utf($this->getText(), 0, 50);
     return strlen_utf($this->getText()) > 50 ? $return . '...' : $return;
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:12,代码来源:ProjectTask.class.php

示例10: getShortDescription

 /**
  * Return shortened description
  *
  * @access public
  * @param void
  * @return string
  */
 function getShortDescription()
 {
     $return = substr_utf($this->getDescription(), 0, 50);
     return strlen_utf($this->getDescription()) > 50 ? $return . '...' : $return;
 }
开发者ID:469306621,项目名称:Languages,代码行数:12,代码来源:ProjectCategory.class.php

示例11: getActivityLogComment

 /**
  * Return comment that need to be stored in activity log
  * 
  * By default this function will extract data from body field (if present). 
  * If you need a bit different behavior override this function in subclasses
  *
  * @param void
  * @return string
  */
 function getActivityLogComment()
 {
     $body = strip_tags($this->getBody());
     if ($body) {
         $beginning = substr_utf($body, 0, 120);
         if (strlen_utf($beginning) < strlen_utf($body)) {
             $beginning .= '...';
         }
         // if
         return $beginning;
     }
     // if
     return null;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:23,代码来源:ProjectObject.class.php

示例12: getObjectName

 /**
  * Return object name
  *
  * @access public
  * @param void
  * @return string
  */
 function getObjectName()
 {
     $name = $this->getText();
     $len = strlen_utf($name);
     $i = strpos($name, "\n");
     if ($i !== false) {
         $name = substr_utf($name, 0, $i - 1);
     }
     $return = substr_utf($name, 0, 50);
     return $len > 50 ? $return . '...' : $return;
 }
开发者ID:469306621,项目名称:Languages,代码行数:18,代码来源:ProjectTask.class.php

示例13: prepare_html

/**
 * Prepare HTML before saving it into database
 *
 * @param string $value
 * @param boolean $purify
 * @return string
 */
function prepare_html($value, $purify = false)
{
    require_once ANGIE_PATH . '/classes/htmlpurifier/init.php';
    $value = trim($value);
    if ($value != '') {
        // Remove brs from the end of the string
        if (str_ends_with($value, '<br /><br />')) {
            $value = substr_utf($value, 0, strlen_utf($value) - 12);
        }
        // if
        if ($purify) {
            $value = purify_html($value);
        }
        // if
        // Clean up Microsoft Office paste:
        // <p> &lt;!--  /* Font Definitions */--&gt;  </p>
        if (str_starts_with($value, '<p> &lt;!--  /* Font Definitions */')) {
            $value = preg_replace('/(<p>)[\\s]+(\\&lt;\\!--)[\\s]+(\\/\\*)[\\s]+(Font)[\\s]+(Definitions)[\\s]+(\\*\\/)(.*)(--\\&gt\\;)[\\s]+(<\\/p>)/i', '', $value);
        }
        // if
        return str_replace(array('<br>', '<br/>', '<br />'), array("\n", "\n", "\n"), $value);
    }
    // if
    return '';
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:32,代码来源:general.php

示例14: minWordLength

	private function minWordLength($str) {
		$min = null ;		
		foreach ( explode(" ", $str) as $word ){
			if ( $len = strlen_utf(trim($word)) ){
				if (is_null($min) || $len < $min) {
					$min = $len ;
				}
			}
		}
		return $min ;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:11,代码来源:SearchController.class.php

示例15: lang

													$tip_pre = 'end_';
												} else {
													$tip_title = lang('start of task');
													$img_url = image_url('/16x16/task_start.png');
													$tip_pre = 'st_';
												}
												$tip_pre .= gen_id()."_";
												$count++;
												if ($count <= $max_events_to_show){
													$color = 'B1BFAC'; 
													$subject = clean($task->getObjectName()).'- <span class="italic">'.lang('task').'</span>';
													$cal_text = clean($task->getObjectName());
													
													$tip_text = str_replace("\r", '', lang('assigned to') .': '. clean($task->getAssignedToName()) . (trim($task->getText()) == '' ? '' : '<br><br>'. $task->getText()));
													$tip_text = purify_html(str_replace("\n", '<br>', $tip_text));													
													if (strlen_utf($tip_text) > 200) $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
								?>
													<div id="m_ta_div_<?php echo $tip_pre.$task->getId()?>" class="<?php echo "og-wsname-color-$ws_color" ?>" style="height:20px;margin: 1px;padding-left:1px;padding-bottom:0px;border-radius:4px;border: 1px solid;border-color:<?php echo $border_color ?>;<?php echo $extra_style ?>">
														<a href='<?php echo $task->getViewUrl()?>' class='internalLink nobr' onclick="og.disableEventPropagation(event);return true;"  style="border-width:0px">
															<img src="<?php echo $img_url ?>" style="vertical-align: middle;">
														 	<span><?php echo $cal_text ?></span>
														</a>
													</div>
													<script>
														addTip('m_ta_div_<?php echo $tip_pre.$task->getId() ?>', '<span class="italic">' + '<?php echo $tip_title ?>' + '</span> - ' + <?php echo json_encode(clean($task->getTitle()))?>, <?php echo json_encode(trim($tip_text) != '' ? trim($tip_text) : '');?>);
														<?php if (!logged_user()->isGuest()) { ?>
														og.createMonthlyViewDrag('m_ta_div_<?php echo $tip_pre.$task->getId() ?>', '<?php echo $task->getId()?>', false, 'task'); // Drag
														<?php } ?>
													</script>
								<?php
												}//if count
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:calendar.php


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