本文整理汇总了PHP中UTIL_String类的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String类的具体用法?PHP UTIL_String怎么用?PHP UTIL_String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UTIL_String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateCache
public function generateCache($languageId)
{
$event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
OW::getEventManager()->trigger($event);
$globalVars = call_user_func_array('array_merge', $event->getData());
$values = $this->keyDao->findAllWithValues($languageId);
$result = array();
// fix begin
// remove cache files from \ow_pluginfiles\base\lang_{1,2}.php and open site in debug mode
$valuesReserv = $this->keyDao->findAllWithValues($languageId == 1 ? 2 : 1);
foreach ($valuesReserv as $v) {
$key = $v['prefix'] . '+' . $v['key'];
$v['value'] = UTIL_String::replaceVars($v['value'], $globalVars);
$result[$key] = $v['value'];
}
// fix end
foreach ($values as $v) {
$key = $v['prefix'] . '+' . $v['key'];
$v['value'] = UTIL_String::replaceVars($v['value'], $globalVars);
$result[$key] = $v['value'];
}
$cacheContent = "<?php\n\$language[{$languageId}] = " . var_export($result, true) . ";\n?>";
$filename = $this->languageCacheDir . 'lang_' . $languageId . '.php';
file_put_contents($filename, $cacheContent);
@chmod($filename, 0666);
$this->loadFromCahce();
}
示例2: getAboutMeContent
protected function getAboutMeContent()
{
$settings = BOL_ComponentEntityService::getInstance()->findSettingList('profile-BASE_CMP_AboutMeWidget', $this->user->id, array('content'));
if (empty($settings['content'])) {
return null;
}
return $this->length === null ? $settings['content'] : UTIL_String::truncate($settings['content'], $this->length, "...");
}
示例3: generateToken
/**
* Generates and returns CSRF token
*
* @return string
*/
public static function generateToken()
{
$tokenList = self::getTokenList();
$token = base64_encode(time() . UTIL_String::getRandomString(32));
$tokenList[$token] = time();
self::saveTokenList($tokenList);
return $token;
}
示例4: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$service = LinkService::getInstance();
$userId = $params->additionalParamList['entityId'];
if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) {
$this->setVisible(false);
return;
}
/* Check privacy permissions */
$eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
$this->setVisible(false);
return;
}
/* */
if ($service->countUserLinks($userId) == 0 && !$params->customizeMode) {
$this->setVisible(false);
return;
}
$this->assign('displayname', BOL_UserService::getInstance()->getDisplayName($userId));
$this->assign('username', BOL_UserService::getInstance()->getUsername($userId));
$list = array();
$count = $params->customParamList['count'];
$userLinkList = $service->findUserLinkList($userId, 0, $count);
$idList = array();
foreach ($userLinkList as $item) {
/* Check privacy permissions */
if ($item->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) {
$eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $item->userId, 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
continue;
}
}
/* */
$list[] = $item;
$idList[] = $item->id;
}
$commentInfo = array();
if (!empty($idList)) {
$commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
$tb = array();
foreach ($list as $key => $item) {
if (mb_strlen($item->getDescription()) > 100) {
$item->setDescription(UTIL_String::truncate($item->getDescription(), 100, '...'));
}
$list[$key]->setDescription(strip_tags($item->getDescription()));
$tb[$item->getId()] = array(array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('links', 'comments'), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $item->getId()))), array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date'));
}
$this->assign('tb', $tb);
}
$this->assign('list', $list);
$this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('links-user', array('user' => BOL_UserService::getInstance()->getUserName($userId))))));
}
示例5: smarty_modifier_more
/**
* Smarty truncate modifier.
*
* @author Sergey Kambalin <greyexpert@gmail.com>
* @package ow.ow_smarty.plugin
* @since 1.0
*/
function smarty_modifier_more($string, $length)
{
$truncated = UTIL_String::truncate($string, $length);
if (strlen($string) - strlen($truncated) < 50) {
return $string;
}
$uniqId = uniqid("more-");
$seeMoreEmbed = '<a href="javascript://" class="ow_small" onclick="$(\'#' . $uniqId . '\').attr(\'data-collapsed\', 0);" style="padding-left:4px;">' . OW::getLanguage()->text("base", "comments_see_more_label") . '</a>';
return '<span class="ow_more_text" data-collapsed="1" id="' . $uniqId . '">' . '<span data-text="full">' . $string . '</span>' . '<span data-text="truncated">' . $truncated . '...' . $seeMoreEmbed . '</span>' . '</span>';
}
示例6: onBeforeRender
public function onBeforeRender()
{
parent::onBeforeRender();
if (!empty($this->oembed['title'])) {
$this->oembed['title'] = UTIL_String::truncate($this->oembed['title'], 23, '...');
}
if (!empty($this->oembed['description'])) {
$this->oembed['description'] = UTIL_String::truncate($this->oembed['description'], 40, '...');
}
$this->assign('message', $this->message);
$this->assign('data', $this->oembed);
}
示例7: redirect
/**
* Makes permanent redirect to provided URL or URI.
*
* @param string $redirectTo
*/
public function redirect($redirectTo = null)
{
// if empty redirect location -> current URI is used
if ($redirectTo === null) {
$redirectTo = OW::getRequest()->getRequestUri();
}
// if URI is provided need to add site home URL
if (!strstr($redirectTo, 'http://') && !strstr($redirectTo, 'https://')) {
$redirectTo = OW::getRouter()->getBaseUrl() . UTIL_String::removeFirstAndLastSlashes($redirectTo);
}
UTIL_Url::redirect($redirectTo);
}
示例8: getRealRequestUri
/**
* Removes site installation subfolder from request URI
*
* @param string $urlHome
* @param string $requestUri
* @return string
*/
public static function getRealRequestUri($urlHome, $requestUri)
{
$urlArray = parse_url($urlHome);
$originalUri = UTIL_String::removeFirstAndLastSlashes($requestUri);
$originalPath = UTIL_String::removeFirstAndLastSlashes($urlArray['path']);
if ($originalPath === '') {
return $originalUri;
}
$uri = mb_substr($originalUri, mb_strpos($originalUri, $originalPath) + mb_strlen($originalPath));
$uri = trim(UTIL_String::removeFirstAndLastSlashes($uri));
return $uri ? self::secureUri($uri) : '';
}
示例9: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$service = PostService::getInstance();
$count = $params->customParamList['count'];
$previewLength = $params->customParamList['previewLength'];
$list = $service->findList(0, $count);
if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) {
$this->setVisible(false);
return;
}
$posts = array();
$userService = BOL_UserService::getInstance();
$postIdList = array();
foreach ($list as $dto) {
/* @var $dto Post */
if (mb_strlen($dto->getTitle()) > 50) {
$dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...')));
}
$text = $service->processPostText($dto->getPost());
$posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())));
$idList[] = $dto->getAuthorId();
$postIdList[] = $dto->id;
}
$commentInfo = array();
if (!empty($idList)) {
$avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false);
$this->assign('avatars', $avatars);
$urls = BOL_UserService::getInstance()->getUserUrlsForList($idList);
$commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList);
$toolbars = array();
foreach ($list as $dto) {
$toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
}
$this->assign('tbars', $toolbars);
}
$this->assign('commentInfo', $commentInfo);
$this->assign('list', $posts);
if ($service->countPosts() > 0) {
$toolbar = array();
if (OW::getUser()->isAuthorized('blogs', 'add')) {
$toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new'));
}
if (OW::getUser()->isAuthorized('blogs', 'view')) {
$toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs'));
}
if (!empty($toolbar)) {
$this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
}
}
}
示例10: question
public function question($params)
{
$questionId = (int) $params['qid'];
$question = $this->service->findQuestion($questionId);
if (empty($question)) {
throw new Redirect404Exception();
}
$language = OW::getLanguage();
OW::getDocument()->setTitle($language->text('equestions', 'question_page_title'));
OW::getDocument()->setDescription($language->text('equestions', 'question_page_description', array('question' => UTIL_String::truncate(strip_tags($question->text), 200))));
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'equestions', 'main_menu_list');
$cmp = new EQUESTIONS_CMP_Question($questionId, null, null, array('focusToPost' => isset($_GET['f'])));
$this->addComponent('question', $cmp);
}
示例11: feedOnProjectAdd
public function feedOnProjectAdd(OW_Event $e)
{
$params = $e->getParams();
if ($params['entityType'] != 'ocsfundraising_project') {
return;
}
$service = OCSFUNDRAISING_BOL_Service::getInstance();
$project = $service->getGoalById($params['entityId']);
if (!$project) {
return;
}
$content = array("format" => "image_content", "vars" => array("image" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image, false) : null, "thumbnail" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image) : null, "title" => UTIL_String::truncate(strip_tags($project['dto']->name), 100, '...'), "description" => UTIL_String::truncate(strip_tags($project['dto']->description), 150, '...'), "url" => array("routeName" => "ocsfundraising.project", "vars" => array('id' => $project['dto']->id)), "iconClass" => "ow_ic_folder"));
$data = array('time' => (int) $project['dto']->startStamp, 'ownerId' => $project['dto']->ownerId, 'string' => array('key' => 'ocsfundraising+feed_add_project_label'), 'content' => $content, 'view' => array('iconClass' => 'ow_ic_folder'));
$e->setData($data);
}
示例12: __construct
/**
* @param OW_Route $route
* @param callback $serviceCallback
* @param string $dtoProperty
*/
public function __construct(OW_Route $route, $serviceCallback, $dtoProperty, $pathProperty, $entityType)
{
$this->route = $route;
$objArr = (array) $route;
$name = $objArr["OW_RouterouteName"];
$path = UTIL_String::removeFirstAndLastSlashes($objArr["OW_RouteroutePath"]);
$da = $objArr["OW_RoutedispatchAttrs"];
$paramsOptions = $objArr["OW_RouterouteParamOptions"];
parent::__construct($name, $path, $da['controller'], $da['action'], $paramsOptions);
$this->serviceCallback = $serviceCallback;
$this->seoService = OASEO_BOL_Service::getInstance();
$this->entityType = $entityType;
$this->dtoProperty = $dtoProperty;
$this->pathProperty = $pathProperty;
$this->pathArray = explode('/', $path);
}
示例13: onBeforeRender
public function onBeforeRender()
{
parent::onBeforeRender();
$tplList = array();
foreach ($this->response['feed']['entry'] as $item) {
$vid = $item['media$group']['yt$videoid']['$t'];
$uploaded = strtotime($item['media$group']['yt$uploaded']['$t']);
$duration = $item['media$group']['yt$duration']['seconds'];
$description = UTIL_String::truncate(strip_tags($item['media$group']['media$description']['$t']), 130, ' ...');
$title = UTIL_String::truncate(strip_tags($item['media$group']['media$title']['$t']), 65, ' ...');
$thumb = $item['media$group']['media$thumbnail'][0]['url'];
$image = $item['media$group']['media$thumbnail'][1]['url'];
$oembed = array('thumbnail_url' => $image, 'type' => 'video', 'title' => $title, 'description' => $description, 'html' => '<iframe class="attp-yt-iframe" width="300" height="230" src="http://www.youtube.com/embed/' . $vid . '?autoplay=1" frameborder="0" allowfullscreen></iframe>');
$tplList[] = array('title' => $title, 'description' => $description, 'thumb' => $thumb, 'video' => $vid, 'duration' => round($duration / 60), 'uploaded' => $uploaded, 'date' => UTIL_DateTime::formatDate($uploaded), 'oembed' => json_encode($oembed));
}
$this->assign('list', $tplList);
}
示例14: text
public function text($prefix, $key, array $vars = null)
{
if (empty($prefix) || empty($key)) {
return $prefix . '+' . $key;
}
$text = null;
try {
$text = BOL_LanguageService::getInstance()->getText(BOL_LanguageService::getInstance()->getCurrent()->getId(), $prefix, $key);
} catch (Exception $e) {
return $prefix . '+' . $key;
}
if ($text === null) {
return $prefix . '+' . $key;
}
$text = UTIL_String::replaceVars($text, $vars);
return $text;
}
示例15: findUserVideos
public function findUserVideos($userId, $start, $offset)
{
$clipDao = VIDEO_BOL_ClipDao::getInstance();
$example = new OW_Example();
$example->andFieldEqual('status', 'approved');
$example->andFieldEqual('userId', $userId);
$example->setOrder('`addDatetime` DESC');
$example->setLimitClause($start, $offset);
$list = $clipDao->findListByExample($example);
$out = array();
foreach ($list as $video) {
$id = $video->id;
$videoThumb = VIDEO_BOL_ClipService::getInstance()->getClipThumbUrl($id);
$out[$id] = array('id' => $id, 'embed' => $video->code, 'title' => UTIL_String::truncate($video->title, 65, ' ...'), 'description' => UTIL_String::truncate($video->description, 130, ' ...'), 'thumb' => $videoThumb == 'undefined' ? null : $videoThumb, 'date' => UTIL_DateTime::formatDate($video->addDatetime), 'permalink' => OW::getRouter()->urlForRoute('view_clip', array('id' => $id)));
$out[$id]['oembed'] = json_encode(array('type' => 'video', 'thumbnail_url' => $out[$id]['thumb'], 'html' => $out[$id]['embed'], 'title' => $out[$id]['title'], 'description' => $out[$id]['description']));
}
return $out;
}