當前位置: 首頁>>代碼示例>>PHP>>正文


PHP dmString::truncate方法代碼示例

本文整理匯總了PHP中dmString::truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP dmString::truncate方法的具體用法?PHP dmString::truncate怎麽用?PHP dmString::truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dmString的用法示例。


在下文中一共展示了dmString::truncate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: configure

 public function configure(array $data)
 {
     $isXhr = $data['context']->getRequest()->isXmlHttpRequest();
     $uri = $this->cleanUri(dmArray::get($data['server'], 'PATH_INFO', $data['server']['REQUEST_URI']));
     $milliseconds = (microtime(true) - dm::getStartTime()) * 1000;
     $this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'uri' => dmString::truncate($uri, 500), 'code' => (string) $data['context']->getResponse()->getStatusCode(), 'app' => (string) sfConfig::get('sf_app'), 'env' => (string) sfConfig::get('sf_environment'), 'ip' => (string) $data['server']['REMOTE_ADDR'], 'user_id' => (string) $data['context']->getUser()->getUserId(), 'user_agent' => dmString::truncate($isXhr ? '' : isset($data['server']['HTTP_USER_AGENT']) ? $data['server']['HTTP_USER_AGENT'] : '', 500), 'xhr' => (int) $isXhr, 'mem' => (string) memory_get_peak_usage(true), 'timer' => (string) sprintf('%.0f', $milliseconds), 'cache' => sfConfig::get('dm_internal_page_cached'));
 }
開發者ID:jdart,項目名稱:diem,代碼行數:7,代碼來源:dmRequestLogEntry.php

示例2: configure

 public function configure(array $data)
 {
     $userId = dmArray::get($data, 'user_id', $this->serviceContainer->getService('user')->getUserId());
     if (!$userId && dmConfig::isCli()) {
         $userId = 'task';
     }
     $this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'ip' => (string) $this->getCurrentRequestIp(), 'session_id' => (string) session_id(), 'user_id' => (string) $userId, 'action' => (string) $data['action'], 'type' => (string) $data['type'], 'subject' => dmString::truncate($data['subject'], 500), 'record' => isset($data['record']) ? get_class($data['record']) . ':' . $data['record']->get('id') : '');
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:8,代碼來源:dmEventLogEntry.php

示例3: randomizeDirName

 public static function randomizeDirName($dir, $maxLen = 255)
 {
     $random = dmString::random(4);
     $strip_len = $maxLen - strlen($random);
     $strip_name = dmString::truncate(self::sanitizeDirName($file), $strip_len, "");
     $final_name = $strip_name . "-" . $random;
     return $final_name;
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:8,代碼來源:dmOs.php

示例4: listenToConfigUpdatedEvent

 public function listenToConfigUpdatedEvent(sfEvent $event)
 {
     $setting = $event['setting'];
     if ('internal' == dmString::strtolower($setting->groupName)) {
         return;
     }
     $this->log(array('server' => $_SERVER, 'action' => 'update', 'type' => 'config', 'subject' => sprintf('%s = %s ( %s )', $setting->name, dmString::truncate($setting->value, 80), $event['culture'])));
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:8,代碼來源:dmEventLog.php

示例5: storeInDb

 protected function storeInDb(dmErrorDescription $error)
 {
     dmDb::create('DmError', array('description' => $error->name . "\n" . $error->exception->getTraceAsString(), 'php_class' => $error->class, 'name' => dmString::truncate($error->name, 255, ''), 'module' => $error->module, 'action' => $error->action, 'uri' => $error->uri, 'env' => $error->env))->save();
 }
開發者ID:jdart,項目名稱:diem,代碼行數:4,代碼來源:dmErrorWatcher.php

示例6: _tag

echo _tag('h2.title', __('Menu'));
echo _tag('div.control_wrap.dm_box_inner', _tag('div.control', $controlMenu->render()));
echo _close('div');
// right
echo _open('div.center');
echo _open('ul.content.clearfix');
if ($folder->isRoot()) {
    echo _tag('li.parent_folder', _tag('a.root', _media('dmAdmin/images/media/up2.png')->size(64, 64)));
} else {
    echo _tag('li.parent_folder', _link($sf_context->getRouting()->getMediaUrl($folder->getNode()->getParent()))->text(_media('dmAdmin/images/media/up.png')->size(64, 64)->alt(__('Back to the parent folder'))));
}
if ($children = $folder->getNode()->getChildren()) {
    $arrChildren = array();
    foreach ($children as $f) {
        $arrChildren[$f->getName()] = $f;
    }
    ksort($arrChildren);
    foreach ($arrChildren as $f) {
        echo _tag('li.folder', _link($sf_context->getRouting()->getMediaUrl($f))->text(($f->isWritable() ? _media('dmAdmin/images/media/folder.png')->size(64, 64) : _media('dmAdmin/images/media/folder-locked.png')) . _tag('span.name', media_wrap_text($f->getName())) . _tag('span.more', format_number_choice('[0]no element|[1]1 element|(1,+Inf]%1% elements', array('%1%' => $f->getNbElements()), $f->getNbElements()))));
    }
}
foreach ($files as $f) {
    echo _tag('li.file.media_id_' . $f->getId(), $f->isImage() && $f->checkFileExists() ? _link($sf_context->getRouting()->getMediaUrl($f))->text(_tag('span.image_background', array('style' => sprintf('background: url("%s") top left no-repeat', _media($f)->size(128, 128)->quality(80)->getSrc())), _tag('span.name', media_wrap_text(dmString::truncate($f->getFile(), 40))))) : _link($sf_context->getRouting()->getMediaUrl($f))->text(media_file_image_tag($f) . _tag('span.name', media_wrap_text(dmString::truncate($f->getFile(), 40)))));
}
echo _close('ul');
echo _close('div');
// center
echo _close('div');
// list
echo _close('div');
echo _close('div');
開發者ID:theolymp,項目名稱:diem,代碼行數:31,代碼來源:pathSuccess.php

示例7: _tag

        $parents[] = _tag("a#dmf" . $ancestor->get('id'), $ancestor->get('name'));
    }
}
$parents[] = _tag("a#dmf" . $folder->get('id'), $folder->get('name'));
echo _tag('div.breadCrumb', implode(" » ", $parents));
echo _open("ul.content.clearfix");
if ($folder->getNode()->hasParent()) {
    echo _tag("li.folder#dmf" . $folder->getNode()->getParent()->get('id'), _media('dmCore/images/media/up.png')->size(64, 64));
} else {
    echo _tag('li', _media('dmCore/images/media/up2.png')->size(64, 64));
}
if ($folders = $folder->getNode()->getChildren()) {
    $arrFolders = array();
    foreach ($folders as $f) {
        $arrFolders[$f->getName()] = $f;
    }
    ksort($arrFolders);
    foreach ($arrFolders as $f) {
        echo _tag("li.folder#dmf" . $f->get('id'), ($f->isWritable() ? _media('dmCore/images/media/folder.png')->size(64, 64) : _media('dmCore/images/media/folder-locked.png')->size(64, 64)) . _tag('span.name', media_wrap_text($f->get('name'))));
    }
}
foreach ($folder->getMedias() as $f) {
    echo _open('li.file#dmm' . $f->get('id') . '.' . $f->getMimeGroup());
    if ($f->isImage()) {
        echo _tag('span.image_background', array('style' => sprintf('background: url("%s") top left no-repeat', _media($f)->size(128, 128)->quality(80)->getSrc(false))), _tag("span.name", media_wrap_text(dmString::truncate($f->get('file'), 40))));
    } else {
        echo media_file_image_tag($f) . _tag("span.name", media_wrap_text(dmString::truncate($f->get('file'), 40)));
    }
    echo _close('li');
}
echo _close("ul");
開發者ID:theolymp,項目名稱:diem,代碼行數:31,代碼來源:_mediaBarInner.php

示例8: renderUser

 protected function renderUser(dmEventLogEntry $entry)
 {
     return sprintf('%s%s<br /><span class=light>%s</span>', ($username = $entry->get('username')) ? sprintf('<strong class="mr10">%s</strong>', dmString::escape(dmString::truncate($username, 20, '...'))) : '', $this->renderIp($entry->get('ip')), $entry->get('session_id'));
 }
開發者ID:runopencode,項目名稱:diem-extended,代碼行數:4,代碼來源:dmEventLogView.php

示例9: use_helper

<?php

use_helper('Date');
if (!isset($items)) {
    return;
}
echo _open('ul');
foreach ($items as $item) {
    echo _tag('li.clickable', _link($item->getLink())->text($item->getTitle())->set('.block') . _tag('span.quiet.little', format_date($item->getPubDate(), 'd/MM H:mm') . ' : ' . dmString::truncate(strip_tags($item->getDescription()), 400, _link($item->getLink())->text(' ...')->title(__('Read more')))));
}
echo _close('ul');
開發者ID:Regmaya,項目名稱:diem-project,代碼行數:11,代碼來源:_tracFeed.php

示例10: _tag

<?php

/*
 * Variables available :
 * - $query (string)        the searched query
 * - $form  (mySearchForm)  the search form
 * - $pager (dmSearchPager) the search pager
 */
if (!$pager) {
    echo _tag('h1.t_big', __('No results for "%1%"', array('%1%' => escape($query))));
} else {
    echo _tag('h1.t_big', __('Results %1% to %2% of %3%', array('%1%' => $pager->getFirstIndice(), '%2%' => $pager->getLastIndice(), '%3%' => $pager->getNbResults())));
}
echo $form->open('.big_search_form action=main/search method=get'), $form['query']->field('.big_search_field'), $form->submit('Search'), $form->close();
if (!$pager) {
    return;
}
echo $pager->renderNavigationTop();
echo _open('ol.search_results.clearfix start=' . $pager->getFirstIndice());
foreach ($pager->getResults() as $result) {
    echo _tag('li.search_result.clickable.ml20.mb5', _tag('span.score.mr10', ceil(100 * $result->getScore()) . '%') . _link($result->getPage())->text(_tag('strong', escape($result->getPage()->name))) . _tag('span.ml10', dmString::truncate($result->getPageContent(), 200)));
}
echo _close('ol');
echo $pager->renderNavigationBottom();
開發者ID:Regmaya,項目名稱:diem-project,代碼行數:24,代碼來源:_dmWidgetSearchResults.php

示例11: renderUserTime

 protected function renderUserTime(dmEventLogEntry $entry)
 {
     $username = $entry->get('username');
     return ($username ? '<strong class="mr10">' . dmString::escape(dmString::truncate($username, 20, '...')) . '</strong><br />' : '') . $entry->get('ip');
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:5,代碼來源:dmEventLogViewLittle.php

示例12: renderUserAndBrowser

 protected function renderUserAndBrowser(dmRequestLogEntry $entry)
 {
     $browser = $entry->get('browser');
     return sprintf('<div class="browser %s">%s<br />%s %s</div>', $this->getBrowserIcon($browser), ($username = $entry->get('username')) ? '<strong class="mr5">' . dmString::escape(dmString::truncate($username, 20, '...')) . '</strong>' : $this->renderIp($entry->get('ip')), ucfirst($browser->getName()), $browser->getVersion());
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:5,代碼來源:dmRequestLogViewLittle.php

示例13: use_helper

<?php

use_helper('Date');
/*
 * An $item is an array containing:
 * - title:       title of the feed item
 * - link:        url of the feed item
 * - content:     HTML content
 * - pub_date:    item publication date (timestamp)
 */
echo _open('ul');
foreach ($items as $item) {
    echo _tag('li.clickable', _link($item['link'])->text($item['title'])->set('.block') . _tag('span.quiet.little', format_date($item['pub_date'], 'd/MM H:mm') . ' by ' . trim($item['author_name'], ')') . '<br />' . dmString::truncate(strip_tags($item['content']), 100)));
}
echo _close('ul');
開發者ID:Regmaya,項目名稱:diem-project,代碼行數:15,代碼來源:_dmWidgetFeedReaderShow.php

示例14: _tag

<?php

/*
 * Variables available :
 * - $query (string)        the searched query
 * - $form  (mySearchForm)  the search form
 * - $pager (dmSearchPager) the search pager
 */
if (!$pager) {
    echo _tag('h1', __('No results for "%1%"', array('%1%' => escape($query))));
    return;
}
echo _tag('h1', __('Results %1% to %2% of %3%', array('%1%' => $pager->getFirstIndice(), '%2%' => $pager->getLastIndice(), '%3%' => $pager->getNbResults())));
echo $pager->renderNavigationTop();
echo _open('ol.search_results start=' . $pager->getFirstIndice());
foreach ($pager as $result) {
    $page = $result->getPage();
    echo _tag('li.search_result', _tag('span.score', ceil(100 * $result->getScore()) . '%') . _link($page)->text(_tag('span.page_name', escape($page->name)) . dmString::truncate($result->getPageContent(), 200)));
}
echo _close('ol');
echo $pager->renderNavigationBottom();
開發者ID:theolymp,項目名稱:diem,代碼行數:21,代碼來源:_dmWidgetSearchResults.php

示例15: getShortText

 /**
  * Returns a shorter text of the guestbook entries,
  * to use in admin interface.
  *
  * @return string - short text
  */
 public function getShortText()
 {
     return dmString::truncate($this->getText(), 50);
 }
開發者ID:altralize,項目名稱:alGuestbookPlugin,代碼行數:10,代碼來源:PluginAlGuestbook.class.php


注:本文中的dmString::truncate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。