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


PHP substr_utf函数代码示例

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


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

示例1: add

	/**
	 * Add webpage
	 *
	 * @access public
	 * @param void
	 * @return null
	 */
	function add() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$this->setTemplate('add');
		
		$notAllowedMember = '';
		if(!ProjectWebpage::canAdd(logged_user(), active_context(), $notAllowedMember)) {
			if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
			else flash_error(lang('no context permissions to add',lang("webpages"), $notAllowedMember));
			ajx_current("empty");
			return;
		} // if

		$webpage = new ProjectWebpage();

		$webpage_data = array_var($_POST, 'webpage');
		
		if(is_array(array_var($_POST, 'webpage'))) {
			try {
				if(substr_utf($webpage_data['url'],0,7) != 'http://' && substr_utf($webpage_data['url'],0,7) != 'file://' && substr_utf($webpage_data['url'],0,8) != 'https://' && substr_utf($webpage_data['url'],0,6) != 'about:' && substr_utf($webpage_data['url'],0,6) != 'ftp://') {
					$webpage_data['url'] = 'http://' . $webpage_data['url'];
				}
				
				$webpage->setFromAttributes($webpage_data);
				
				DB::beginWork();
				$webpage->save();

				$member_ids = json_decode(array_var($_POST, 'members'));
				
				//link it!
                                $object_controller = new ObjectController();
                                $object_controller->add_subscribers($webpage);
                                $object_controller->add_to_members($webpage, $member_ids);
                                $object_controller->link_to_new_object($webpage);
				$object_controller->add_subscribers($webpage);
                                $object_controller->add_custom_properties($webpage);

				ApplicationLogs::createLog($webpage, ApplicationLogs::ACTION_ADD);
				DB::commit();


				flash_success(lang('success add webpage', $webpage->getObjectName()));
				ajx_current("back");
				// Error...
			} catch(Exception $e) {
				DB::rollback();
				flash_error($e->getMessage());
				ajx_current("empty");
			}

		}

		tpl_assign('webpage', $webpage);
		tpl_assign('webpage_data', $webpage_data);
	} // add
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:WebpageController.class.php

示例2: 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

示例3: add

 /**
  * Add webpage
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add');
     if (!ProjectWebpage::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $webpage = new ProjectWebpage();
     $webpage_data = array_var($_POST, 'webpage');
     if (!is_array($webpage_data)) {
         $webpage_data = array('milestone_id' => array_var($_GET, 'milestone_id'));
         // array
     }
     // if
     if (is_array(array_var($_POST, 'webpage'))) {
         try {
             if (substr_utf($webpage_data['url'], 0, 7) != 'http://' && substr_utf($webpage_data['url'], 0, 7) != 'file://' && substr_utf($webpage_data['url'], 0, 8) != 'https://' && substr_utf($webpage_data['url'], 0, 6) != 'about:' && substr_utf($webpage_data['url'], 0, 6) != 'ftp://') {
                 $webpage_data['url'] = 'http://' . $webpage_data['url'];
             }
             $webpage->setFromAttributes($webpage_data);
             $webpage->setIsPrivate(false);
             // Options are reserved only for members of owner company
             if (!logged_user()->isMemberOfOwnerCompany()) {
                 $webpage->setIsPrivate(false);
             }
             // if
             DB::beginWork();
             $webpage->save();
             $webpage->setTagsFromCSV(array_var($webpage_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($webpage);
             $object_controller->link_to_new_object($webpage);
             $object_controller->add_subscribers($webpage);
             $object_controller->add_custom_properties($webpage);
             ApplicationLogs::createLog($webpage, $webpage->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add webpage', $webpage->getTitle()));
             ajx_current("back");
             // Error...
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
         // try
     }
     // if
     tpl_assign('webpage', $webpage);
     tpl_assign('webpage_data', $webpage_data);
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:64,代码来源:WebpageController.class.php

示例4: build_events_data

	function build_events_data($ical_events_data, $tz_diff) {
		$result = array();
		
		foreach($ical_events_data as $ical_ev) {
			$data = array();
			$data['name'] = substr_utf(array_var($ical_ev, 'summary', lang("untitle event")), 0, 100);
			$data['description'] = array_var($ical_ev, 'description', '');
			$data['name'] = html_entity_decode($data['name']);
			$data['name'] = str_replace('<br />', "\n", $data['name']);
			$data['description'] = html_entity_decode($data['description']);
			$data['description'] = str_replace('<br />', "\n", $data['description']);
			$data['type_id'] = array_var($ical_ev, 'all_day', 0) == 0 ? 1 : 2;
			
			$data['start'] = date('Y-m-d H:i:s', array_var($ical_ev, 'start_unix') - $tz_diff * 3600);
			$data['duration'] = date('Y-m-d H:i:s', array_var($ical_ev, 'end_unix') - $tz_diff * 3600);

                        $data['repeat_num'] = 0;
			$data['repeat_h'] = 0;
			$data['repeat_d'] = 0;
			$data['repeat_m'] = 0;
			$data['repeat_y'] = 0;
			$data['repeat_forever'] = 0;
			$data['repeat_end'] =  0;
			
			$rrule = array_var($ical_ev, 'rrule', null);
			if ($rrule != null) {
				$data['repeat_end'] = isset($rrule['until_unix']) ? date('Y-m-d', array_var($rrule, 'until_unix')) : 0;
				$data['repeat_num'] = array_var($rrule, 'count', 0);
				$freq = array_var($rrule, 'freq', null);
				$jump = array_var($rrule, 'interval', 1);
				if ($freq != null) {
					switch ($freq) {
						case 'DAILY': $data['repeat_d'] = $jump; break;
						case 'WEEKLY': $data['repeat_d'] = 7 * $jump; break;
						case 'MONTHLY': $data['repeat_m'] = $jump; break;
						case 'YEARLY': $data['repeat_y'] = $jump; break;
					}					
				}
				if ($data['repeat_end'] == 0 && $data['repeat_num'] == 0) $data['repeat_forever'] = 1;
			}
			$data['users_to_invite'] = array();
			$data['users_to_invite'][logged_user()->getId()] = 1; 

			$status = array_var($ical_ev, 'status', 'CONFIRMED');
			switch ($status) {
				case 'CONFIRMED': $data['confirmAttendance'] = 1; break;
				case 'CANCELLED': $data['confirmAttendance'] = 2; break;
				case 'TENTATIVE': $data['confirmAttendance'] = 3; break;
			}
			
			$result[] = $data;
		}
		
		return $result;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:55,代码来源:CalFormatUtilities.php

示例5: getDisplayName

 /**
  * Return display name
  *
  * @param boolean $short
  * @return string
  */
 function getDisplayName($short = false)
 {
     $name = $this->getName();
     if ($short) {
         $pieces = explode(' ', $name);
         if (count($pieces) == 2) {
             return $pieces[0] . ' ' . substr_utf($pieces[1], 0, 1) . '.';
         } else {
             return $name;
         }
     } else {
         return $name;
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:21,代码来源:AnonymousUser.class.php

示例6: 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

示例7: 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

示例8: getObjectName

 /**
  * Return object name
  *
  * @param void
  * @return string
  */
 function getObjectName()
 {
     $object = $this->getObject();
     return $object instanceof ProjectDataObject ? lang('comment on object', substr_utf($this->getText(), 0, 50) . '...', $object->getObjectName()) : $this->getObjectTypeName();
 }
开发者ID:469306621,项目名称:Languages,代码行数:11,代码来源:Comment.class.php

示例9: is_valid_function_name

/**
 * This function will return true if $str is valid function name (made out of alpha numeric characters + underscore)
 *
 * @param string $str
 * @return boolean
 */
function is_valid_function_name($str)
{
    $check_str = trim($str);
    if ($check_str == '') {
        return false;
    }
    // empty string
    $first_char = substr_utf($check_str, 0, 1);
    if (is_numeric($first_char)) {
        return false;
    }
    // first char can't be number
    return (bool) preg_match("/^([a-zA-Z0-9_]*)\$/", $check_str);
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:20,代码来源:general.php

示例10: clean

                                }
                            }
                            $count++;
                            if ($count <= 3) {
                                $cal_text = clean($task->getTitle());
                                $cal_text = mb_strlen($cal_text) < $to_show_len ? $cal_text : mb_substr($cal_text, 0, $to_show_len - 3) . "...";
                                $output .= '<div class="event_block">';
                                $output .= "<span id='o_ta_div_{$tip_pre}" . $task->getId() . "'>";
                                $output .= "<a class=\"internalLink link-ico {$ico}\" style='vertical-align:bottom;' href='" . $task->getViewUrl() . "' onclick=\"og.disableEventPropagation(event);\" >";
                                $output .= $cal_text . "</a>";
                                $output .= '</span>';
                                $output .= "</div>";
                                $tip_text = str_replace("\r", '', lang('assigned to') . ': ' . clean($task->getAssignedToName()) . (trim(clean($task->getText())) == '' ? '' : '<br><br>' . clean($task->getText())));
                                $tip_text = str_replace("\n", '<br>', $tip_text);
                                if (strlen_utf($tip_text) > 200) {
                                    $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
                                }
                                ?>
									<script>
										addTip('o_ta_div_<?php 
                                echo $tip_pre;
                                ?>
' + <?php 
                                echo $task->getId();
                                ?>
, '<i>' + '<?php 
                                echo $tip_title;
                                ?>
' + '</i> - ' + <?php 
                                echo json_encode(clean($task->getTitle()));
                                ?>
开发者ID:rorteg,项目名称:fengoffice,代码行数:31,代码来源:widget_calendar.php

示例11: createMinimumUser

 function createMinimumUser($email, $compId)
 {
     $contact = Contacts::getByEmail($email);
     $posArr = strpos_utf($email, '@') === FALSE ? null : strpos($email, '@');
     $user_data = array('username' => $email, 'display_name' => $posArr != null ? substr_utf($email, 0, $posArr) : $email, 'email' => $email, 'contact_id' => isset($contact) ? $contact->getId() : null, 'password_generator' => 'random', 'timezone' => isset($contact) ? $contact->getTimezone() : 0, 'create_contact' => !isset($contact), 'company_id' => $compId, 'send_email_notification' => true);
     // array
     $user = null;
     $user = create_user($user_data, false, '');
     return $user;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:10,代码来源:ObjectController.class.php

示例12: format_datetime

				} else {
					$datetime = format_datetime($object->getArchivedOn(), $date_format, logged_user()->getTimezone());
					echo lang('user date', $archive_user->getCardUserUrl(), $username, $datetime, clean($archive_user->getObjectName()));
				}
			}
			 ?></div>
		<?php } // if ?>
		
		<?php
		if ($object instanceof ProjectFile && $object->getLastRevision() instanceof ProjectFileRevision) { ?>
			<span style="color:#333333;font-weight:bolder;">
    			<?php echo lang('mime type') ?>:
    			<?php $mime = $object->getLastRevision()->getTypeString(); ?>
			</span><br/><div style="padding-left:10px" title="<?php echo  $mime ?>">
				<?php if (strlen($mime) > 30) {
					echo substr_utf($mime, 0, 15) . '&hellip;' . substr_utf($mime, -15);
				} else {
					echo $object->getLastRevision()->getTypeString();
				}?>
			</div>
		<?php if ($object->isCheckedOut()) { ?>
	    		<span style="color:#333333;font-weight:bolder;">
	    			<?php echo lang('checked out by') ?>:
				</span><br/><div style="padding-left:10px">
				<?php
				$checkout_user = Contacts::findById($object->getCheckedOutById());
				if ($checkout_user instanceof Contact && $checkout_user->isUser()){
					if (logged_user()->getId() == $checkout_user->getId())
						$username = lang('you');
					else
						$username = clean($checkout_user->getObjectName());
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:properties.php

示例13: foreach

if ($show_help_option == 'always' || ($show_help_option == 'until_close' && user_config_option('show_active_tasks_widget_context_help', true, logged_user()->getId()))) { 
	render_context_help($this, 'chelp active tasks widget', 'active_tasks_widget');
} ?>

<div style="padding:10px">
<table id="dashTableTIP" style="width:100%;">
<?php
$c = 0;
foreach ($tasks_in_progress as $task) {
	$stCount = $task->countAllSubTasks();
	$c++;
	$text = $task->getText();
	if ($text != '')
		$text = ": " . $text;
	if(strlen_utf($text)>100)
		$text = substr_utf($text,0,100) . " ...";
	$text = clean($text);
	?>
		<tr class="<?php echo $c % 2 == 1? '':'dashAltRow'?>"><td><div class="db-ico ico-task">&nbsp;></div></td><td style="padding-left:5px;padding-bottom:2px">
	<?php $dws = $task->getWorkspaces(logged_user()->getWorkspacesQuery());
	$projectLinks = array();
	foreach ($dws as $ws) {
		$projectLinks[] = $ws->getId();
	}
	echo '<span class="project-replace">' . implode(',',$projectLinks) . '</span>';?>
	<a class='internalLink' href='<?php echo $task->getViewUrl() ?>'><?php echo clean($task->getTitle())?><?php echo $text ?></a></td>
	<?php /*<td align="right"><?php $timeslot = Timeslots::getOpenTimeslotByObject($task,logged_user());
		if ($timeslot) { 
			if (!$timeslot->isPaused()) {?>
			<div id="<?php echo $genid . $task->getId() ?>timespan"></div>
			<script>
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:widget_active_tasks.php

示例14: substr_utf

         $read_style = "";
         if (!$info->getIsRead(logged_user()->getId())) {
             $read_style = "font-weight: bold;";
             $unread++;
         }
         $conversation_block .= '<td style="width:20px;' . $read_style . '">';
         if ($info->getHasAttachments()) {
             $conversation_block .= '<div class="db-ico ico-attachment"></div>';
         }
         $conversation_block .= '<td style="width:20px;' . $read_style . '">';
         if ($show_user_icon) {
             $conversation_block .= '<div class="db-ico ico-user"></div>';
         }
         $info_text = $info->getTextBody();
         if (strlen_utf($info_text) > 90) {
             $info_text = substr_utf($info_text, 0, 90) . "...";
         }
         $view_url = get_url('mail', 'view', array('id' => $info->getId(), 'replace' => 1));
         $conversation_block .= '<td>';
         $conversation_block .= '	<a style="' . $read_style . '" class="internalLink" href="' . $view_url . '" onclick="og.openLink(\'' . $view_url . '\');return false;" title="' . $info->getFrom() . '">';
         $conversation_block .= $from;
         if (!$is_current) {
             $conversation_block .= '	</a><span class="desc">- ' . $info_text . '</span></td>';
         }
         $info_date = $info->getReceivedDate() instanceof DateTimeValue ? $info->getReceivedDate()->isToday() ? format_time($info->getReceivedDate()) : format_datetime($info->getReceivedDate()) : lang('n/a');
         $conversation_block .= '</td><td style="text-align:right;padding-right:3px"><span class="desc">' . lang('date') . ': </span>' . $info_date . '</td>';
     }
     //foreach
     $conversation_block .= '</table>';
     $conversation_block .= '</div>';
 } else {
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:31,代码来源:view.php

示例15: prepareSQL

 /**
  * Prepare SQL (replace ? with data from $arguments array)
  *
  * @param string $sql SQL that need to be prepared
  * @param array $arguments Array of SQL arguments...
  * @return string
  */
 function prepareSQL($sql, $arguments = null)
 {
     if (is_foreachable($arguments)) {
         $offset = 0;
         foreach ($arguments as $argument) {
             $question_mark_pos = strpos_utf($sql, '?', $offset);
             if ($question_mark_pos !== false) {
                 $escaped = $this->escapeString($argument);
                 $escaped_len = strlen_utf($escaped);
                 $sql = substr_utf($sql, 0, $question_mark_pos) . $escaped . substr_utf($sql, $question_mark_pos + 1, strlen_utf($sql));
                 $offset = $question_mark_pos + $escaped_len;
             }
             // if
         }
         // foreach
     }
     // if
     return $sql;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:26,代码来源:DBConnection.class.php


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