• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP utf8_substr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         $image = new Image(DIR_IMAGE . $old_image);
         $image->resize($width, $height);
         $image->save(DIR_IMAGE . $new_image);
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return HTTPS_CATALOG . 'image/' . $new_image;
     } else {
         return HTTP_CATALOG . 'image/' . $new_image;
     }
 }
开发者ID:gittrue,项目名称:VIF,代码行数:28,代码来源:image.php


示例2: _insertIntoIndex

 /**
  * @param XenForo_Search_Indexer $indexer
  * @param array $data
  * @param array $parentData
  */
 protected function _insertIntoIndex(XenForo_Search_Indexer $indexer, array $data, array $parentData = null)
 {
     $metadata = array();
     $metadata['album'] = $data['album_id'];
     if (!empty($data['photo_exif']) && !is_array($data['photo_exif'])) {
         $data['photo_exif'] = @unserialize($data['photo_exif']);
     }
     if (!empty($data['photo_exif'])) {
         if (isset($data['photo_exif']['Make']) && isset($data['photo_exif']['Model'])) {
             $metadata['camera'] = $data['photo_exif']['Model'];
         }
         if (isset($data['photo_exif']['ExposureTime'])) {
             $metadata['exposure'] = str_replace('/', '_', $data['photo_exif']['ExposureTime']);
         }
         if (isset($data['photo_exif']['FNumber'])) {
             $f = explode('/', $data['photo_exif']['FNumber']);
             $metadata['aperture'] = str_replace('.', '_', $f[1]);
         }
         if (isset($data['photo_exif']['FocalLength'])) {
             $metadata['focal'] = str_replace('.', '_', str_replace('mm', '', $data['photo_exif']['FocalLength']));
         }
         if (isset($data['photo_exif']['ISOSpeedRatings'])) {
             $metadata['iso'] = intval($data['photo_exif']['ISOSpeedRatings']);
         }
     }
     if (!empty($data['collection_id'])) {
         $metadata['collection'] = $data['collection_id'];
     }
     if (utf8_strlen($data['title']) > 250) {
         $data['title'] = utf8_substr($data['title'], 0, 249);
     }
     $indexer->insertIntoIndex('sonnb_xengallery_photo', $data['content_id'], $data['title'], $data['description'], $data['content_date'], $data['user_id'], 0, $metadata);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:38,代码来源:Photo.php


示例3: utf8_str_pad

/**
* Replacement for str_pad. $padStr may contain multi-byte characters.
*
* @author Oliver Saunders <oliver (a) osinternetservices.com>
* @param string $input
* @param int $length
* @param string $padStr
* @param int $type ( same constants as str_pad )
* @return string
* @see http://www.php.net/str_pad
* @see utf8_substr
* @package utf8
* @subpackage strings
*/
function utf8_str_pad($input, $length, $padStr = ' ', $type = STR_PAD_RIGHT)
{
    $inputLen = utf8_strlen($input);
    if ($length <= $inputLen) {
        return $input;
    }
    $padStrLen = utf8_strlen($padStr);
    $padLen = $length - $inputLen;
    if ($type == STR_PAD_RIGHT) {
        $repeatTimes = ceil($padLen / $padStrLen);
        return utf8_substr($input . str_repeat($padStr, $repeatTimes), 0, $length);
    }
    if ($type == STR_PAD_LEFT) {
        $repeatTimes = ceil($padLen / $padStrLen);
        return utf8_substr(str_repeat($padStr, $repeatTimes), 0, floor($padLen)) . $input;
    }
    if ($type == STR_PAD_BOTH) {
        $padLen /= 2;
        $padAmountLeft = floor($padLen);
        $padAmountRight = ceil($padLen);
        $repeatTimesLeft = ceil($padAmountLeft / $padStrLen);
        $repeatTimesRight = ceil($padAmountRight / $padStrLen);
        $paddingLeft = utf8_substr(str_repeat($padStr, $repeatTimesLeft), 0, $padAmountLeft);
        $paddingRight = utf8_substr(str_repeat($padStr, $repeatTimesRight), 0, $padAmountLeft);
        return $paddingLeft . $input . $paddingRight;
    }
    trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
开发者ID:01J,项目名称:topm,代码行数:42,代码来源:str_pad.php


示例4: resize

 public function resize($filename, $width, $height)
 {
     if (!is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!is_dir(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         if ($width_orig != $width || $height_orig != $height) {
             $image = new Image(DIR_IMAGE . $old_image);
             $image->resize($width, $height);
             $image->save(DIR_IMAGE . $new_image);
         } else {
             copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         }
     }
     if ($this->request->server['HTTPS']) {
         return $this->config->get('config_ssl') . 'image/' . $new_image;
     } else {
         return $this->config->get('config_url') . 'image/' . $new_image;
     }
 }
开发者ID:sir-oga,项目名称:peterpan,代码行数:32,代码来源:image.php


示例5: index

 public function index($setting)
 {
     $this->load->language('module/featured');
     $this->load->language('common/common');
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_heading_desc'] = $this->language->get('text_heading_desc');
     $data['text_see_all'] = $this->language->get('text_see_all');
     $data['text_newsevent'] = $this->language->get('text_newsevent');
     $data['see_all_url'] = $this->url->link('product/manufacturer');
     $this->load->model('catalog/product');
     $this->load->model('tool/image');
     $data['products'] = array();
     if (!$setting['limit']) {
         $setting['limit'] = 9;
     }
     $products = array_slice($setting['product'], 0, (int) $setting['limit']);
     foreach ($products as $product_id) {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         if ($product_info) {
             if ($product_info['image']) {
                 $image = $this->model_tool_image->resize($product_info['image'], $setting['width'], $setting['height']);
             } else {
                 $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
             }
             $data['products'][] = array('product_id' => $product_info['product_id'], 'thumb' => $image, 'name' => $product_info['name'], 'manufacturer' => $product_info['manufacturer'], 'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']));
         }
     }
     if ($data['products']) {
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/featured.tpl')) {
             return $this->load->view($this->config->get('config_template') . '/template/module/featured.tpl', $data);
         } else {
             return $this->load->view('default/template/module/featured.tpl', $data);
         }
     }
 }
开发者ID:wmthiet90,项目名称:hv,代码行数:35,代码来源:featured.php


示例6: getCategories

 protected function getCategories($parent_id, $current_path = '')
 {
     $categoryhome = array();
     $category_id = array_shift($this->path);
     $results = $this->model_catalog_category->getCategories($parent_id);
     $i = 0;
     foreach ($results as $result) {
         if (!$current_path) {
             $new_path = $result['category_id'];
         } else {
             $new_path = $current_path . '_' . $result['category_id'];
         }
         if ($this->category_id == $result['category_id']) {
             $categoryhome[$i]['href'] = $this->url->link('product/category', 'path=' . $new_path);
         } else {
             $categoryhome[$i]['href'] = $this->url->link('product/category', 'path=' . $new_path);
         }
         if ($result['image']) {
             $image = $result['image'];
         } else {
             $image = 'no_image.jpg';
         }
         $categoryhome[$i]['thumb'] = $this->model_tool_image->resize($image, 120, 120);
         $categoryhome[$i]['name'] = $result['name'];
         $categoryhome[$i]['description'] = utf8_substr(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), 0, 100) . '..';
         $i++;
     }
     return $categoryhome;
 }
开发者ID:AlesPravdin,项目名称:FOODYBOX_SITE,代码行数:29,代码来源:categoryhome.php


示例7: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         $config['image_library'] = 'gd2';
         $config['source_image'] = DIR_IMAGE . $old_image;
         $config['new_image'] = DIR_IMAGE . $new_image;
         $config['maintain_ratio'] = TRUE;
         $config['width'] = $width;
         $config['height'] = $height;
         $this->load->library('image_lib');
         $this->image_lib->initialize($config);
         if (!$this->image_lib->resize()) {
             echo $this->image_lib->display_errors();
         }
         $this->image_lib->clear();
     }
     return HTTP_IMAGE . $new_image;
 }
开发者ID:nvmanh,项目名称:codeigniter-shop,代码行数:33,代码来源:image_model.php


示例8: resize

 /**
  *	
  *	@param filename string
  *	@param width 
  *	@param height
  *	@param type char [default, w, h]
  *				default = scale with white space, 
  *				w = fill according to width, 
  *				h = fill according to height
  *	
  */
 public function resize($filename, $width, $height, $type = "")
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . $type . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         if ($width_orig != $width || $height_orig != $height) {
             $image = new Image(DIR_IMAGE . $old_image);
             $image->resize($width, $height, $type);
             $image->save(DIR_IMAGE . $new_image);
         } else {
             copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         }
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return (defined('HTTPS_STATIC_CDN') ? HTTPS_STATIC_CDN : $this->config->get('config_ssl')) . 'image/' . $new_image;
     } else {
         return (defined('HTTP_STATIC_CDN') ? HTTP_STATIC_CDN : $this->config->get('config_url')) . 'image/' . $new_image;
     }
 }
开发者ID:deepakdesai,项目名称:CressoyoWebApp,代码行数:44,代码来源:vq2-catalog_model_tool_image.php


示例9: index

 public function index($setting)
 {
     $this->load->language('module/featuredcategory');
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_view'] = $this->language->get('text_view');
     $this->load->model('catalog/product');
     $this->load->model('catalog/category');
     $this->load->model('tool/image');
     $data['products'] = array();
     $products = explode(',', $this->config->get('featuredcategory_product'));
     if (!$setting['limit']) {
         $setting['limit'] = 4;
     }
     $products = array_slice($setting['product'], 0, (int) $setting['limit']);
     foreach ($products as $category_id) {
         $product_info = $this->model_catalog_category->getCategory($category_id);
         if ($product_info) {
             if ($product_info['image']) {
                 $image = $this->model_tool_image->resize($product_info['image'], $setting['width'], $setting['height']);
             } else {
                 $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
             }
             $data['products'][] = array('category_id' => $product_info['category_id'], 'thumb' => $image, 'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 30) . '..', 'name' => $product_info['name'], 'href' => $this->url->link('product/category', 'path=' . $product_info['category_id']));
         }
     }
     if ($data['products']) {
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/featuredcategory.tpl')) {
             return $this->load->view($this->config->get('config_template') . '/template/module/featuredcategory.tpl', $data);
         } else {
             return $this->load->view('default/template/module/featuredcategory.tpl', $data);
         }
     }
 }
开发者ID:sunbaoshi1975,项目名称:xlight-oc-theme,代码行数:33,代码来源:featuredcategory.php


示例10: cart

 public function cart()
 {
     $this->load->model('tool/image');
     $this->data['products'] = array();
     foreach ($this->cart->getProducts() as $product) {
         if ($product['image']) {
             $image = $this->model_tool_image->resize($product['image'], $this->config->get('image_cart_width'), $this->config->get('image_cart_height'));
         } else {
             $image = '';
         }
         $option_data = array();
         foreach ($product['option'] as $option) {
             if ($option['type'] != 'file') {
                 $value = $option['option_value'];
             } else {
                 $filename = $this->encryption->decrypt($option['option_value']);
                 $value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
             }
             $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value, 'type' => $option['type']);
         }
         $this->data['products'][] = array('product_id' => $product['product_id'], 'key' => $product['key'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $product['tax_percentage'], 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
     }
     // Gift Voucher
     if (!empty($this->session->data['vouchers'])) {
         foreach ($this->session->data['vouchers'] as $key => $voucher) {
             $this->data['products'][] = array('key' => $key, 'name' => $voucher['description'], 'price' => $voucher['amount'], 'amount' => 1, 'total' => $voucher['amount']);
         }
     }
     $this->template = 'cart.tpl';
     $this->response->setOutput($this->render());
 }
开发者ID:wardvanderput,项目名称:SumoStore,代码行数:31,代码来源:index.php


示例11: substr

 /**
  * Shorten a string to a given number of characters
  *
  * The function preserves words, so the result might be a bit shorter or
  * longer than the number of characters given. It strips all tags.
  *
  * @param string  $strString        The string to shorten
  * @param integer $intNumberOfChars The target number of characters
  * @param string  $strEllipsis      An optional ellipsis to append to the shortened string
  *
  * @return string The shortened string
  */
 public static function substr($strString, $intNumberOfChars, $strEllipsis = ' …')
 {
     $strString = preg_replace('/[\\t\\n\\r]+/', ' ', $strString);
     $strString = strip_tags($strString);
     if (utf8_strlen($strString) <= $intNumberOfChars) {
         return $strString;
     }
     $intCharCount = 0;
     $arrWords = array();
     $arrChunks = preg_split('/\\s+/', $strString);
     $blnAddEllipsis = false;
     foreach ($arrChunks as $strChunk) {
         $intCharCount += utf8_strlen(static::decodeEntities($strChunk));
         if ($intCharCount++ <= $intNumberOfChars) {
             $arrWords[] = $strChunk;
             continue;
         }
         // If the first word is longer than $intNumberOfChars already, shorten it
         // with utf8_substr() so the method does not return an empty string.
         if (empty($arrWords)) {
             $arrWords[] = utf8_substr($strChunk, 0, $intNumberOfChars);
         }
         if ($strEllipsis !== false) {
             $blnAddEllipsis = true;
         }
         break;
     }
     // Backwards compatibility
     if ($strEllipsis === true) {
         $strEllipsis = ' …';
     }
     return implode(' ', $arrWords) . ($blnAddEllipsis ? $strEllipsis : '');
 }
开发者ID:Tastaturberuf,项目名称:core,代码行数:45,代码来源:StringUtil.php


示例12: index

 public function index($setting)
 {
     if (empty($setting)) {
         return;
     }
     $this->load->model('bossblog/article');
     $this->load->language('module/blogrecentpost');
     $boss_blogrecentpost = $setting['blogrecentpost_module'];
     $data['text_postby'] = $this->language->get('text_postby');
     $data['heading_title'] = isset($boss_blogrecentpost['title'][$this->config->get('config_language_id')]) ? $boss_blogrecentpost['title'][$this->config->get('config_language_id')] : '';
     if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/bossthemes/bossblog.css')) {
         $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/bossthemes/bossblog.css');
     } else {
         $this->document->addStyle('catalog/view/theme/default/stylesheet/bossthemes/bossblog.css');
     }
     $data['articles'] = array();
     $data_sort = array('sort' => 'ba.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => $boss_blogrecentpost['limit']);
     $results = $this->model_bossblog_article->getArticles($data_sort);
     foreach ($results as $result) {
         $data['articles'][] = array('blog_article_id' => $result['blog_article_id'], 'name' => $result['name'], 'title' => utf8_substr(strip_tags(html_entity_decode($result['title'], ENT_QUOTES, 'UTF-8')), 0, 50) . '...', 'date_added' => $result['date_added'], 'author' => $result['author'], 'href' => $this->url->link('bossblog/article', 'blog_article_id=' . $result['blog_article_id']));
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/blogrecentpost.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/module/blogrecentpost.tpl', $data);
     } else {
         return $this->load->view('default/template/module/blogrecentpost.tpl', $data);
     }
 }
开发者ID:rootcave,项目名称:9livesprints-web,代码行数:27,代码来源:blogrecentpost.php


示例13: convert_authors

function convert_authors($mysql_db, $sqlite_db, $min)
{
    $sqlite_db->query("begin transaction;");
    $sqlite_db->query("DELETE FROM authors");
    $sqltest = "\n\tSELECT libavtorname.aid, libavtorname.FirstName, libavtorname.LastName, libavtorname.MiddleName, COUNT(libavtor.bid) as Number\n\tFROM libavtors AS libavtorname INNER JOIN (\n\t  SELECT DISTINCT libavtor.aid, libavtor.bid\n\t  FROM libavtor INNER JOIN libbook ON libbook.bid=libavtor.bid AND libavtor.role = 'a'\n\t) AS libavtor ON libavtorname.aid=libavtor.aid \n    WHERE libavtorname.aid>{$min}\n\tGROUP BY libavtorname.aid, libavtorname.FirstName, libavtorname.LastName, libavtorname.MiddleName\n  ";
    $char_list = 'А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ы Э Ю Я A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
    $query = $mysql_db->query($sqltest);
    while ($row = $query->fetch_array()) {
        $full_name = trim($row['LastName']) . " " . trim($row['FirstName']) . " " . trim($row['MiddleName']);
        $full_name = str_replace("  ", " ", $full_name);
        $search_name = strtolowerEx($full_name);
        $letter = utf8_substr($full_name, 0, 1);
        $letter = strtoupperEx($letter, 0, 1);
        if (strpos($char_list, $letter) === false) {
            $letter = "#";
        }
        echo "Auth: " . $row['aid'] . " - " . $letter . " - " . $full_name . " - " . $search_name . "\n";
        $sql = "INSERT INTO authors (id, number, letter, full_name, search_name, first_name, middle_name, last_name) VALUES(?,?,?,?,?,?,?,?)";
        $insert = $sqlite_db->prepare($sql);
        if ($insert === false) {
            $err = $dbh->errorInfo();
            die($err[2]);
        }
        $err = $insert->execute(array($row['aid'], $row['Number'], $letter, $full_name, $search_name, trim($row['FirstName']), trim($row['MiddleName']), trim($row['LastName'])));
        if ($err === false) {
            $err = $dbh->errorInfo();
            die($err[2]);
        }
        $insert->closeCursor();
    }
    $sqlite_db->query("commit;");
}
开发者ID:EvgeniiFrolov,项目名称:myrulib,代码行数:32,代码来源:convert.php


示例14: showFirstLevel

 public function showFirstLevel($message)
 {
     global $LANG, $CFG_GLPI;
     $menu = $this->getMenu();
     if ($message != '') {
         echo "<div class='ui-loader ui-body-a ui-corner-all' id='messagebox' style='top: 75px;display:block'>";
         echo "<h1>{$message}</h1>";
         echo "</div>";
         echo "<script>\n               \$('#messagebox').delay(800).fadeOut(2000);\n         </script>";
     }
     echo "<div data-role='content'>";
     echo "<ul data-role='listview' data-inset='true' data-theme='c' data-dividertheme='a'>";
     echo "<li data-role='list-divider'>" . $LANG['plugin_mobile']["title"] . "</li>";
     $i = 1;
     foreach ($menu as $part => $data) {
         if (isset($data['content']) && count($data['content'])) {
             echo "<li id='menu{$i}'>";
             $link = $CFG_GLPI["root_doc"] . "/plugins/mobile/front/ss_menu.php?menu=" . $part;
             if (Toolbox::strlen($data['title']) > 14) {
                 $data['title'] = utf8_substr($data['title'], 0, 14) . "...";
             }
             if (isset($data['icon'])) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/mobile/pics/" . $data['icon'] . "' class='ui-li-icon round-icon' />";
             }
             echo "<a href=\"{$link}\" data-back='false'>" . $data['title'] . "</a>";
             echo "</li>";
             $i++;
         }
     }
     echo "</ul>";
     echo "</div>";
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:32,代码来源:menu.class.php


示例15: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         try {
             $image = new Image(DIR_IMAGE . $old_image);
         } catch (Exception $exc) {
             $this->log->write("The file {$old_image} has wrong format and can not be handled.");
             $image = new Image(DIR_IMAGE . 'no_image.jpg');
         }
         $image->resize($width, $height);
         $image->save(DIR_IMAGE . $new_image);
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return HTTPS_IMAGE . $new_image;
     } else {
         return HTTP_IMAGE . $new_image;
     }
 }
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:33,代码来源:image.php


示例16: formatUserNameMobile

function formatUserNameMobile($ID, $login, $realname, $firstname, $link = 0, $cut = 0)
{
    global $CFG_GLPI;
    $before = "";
    $after = "";
    $viewID = "";
    if (strlen($realname) > 0) {
        $temp = $realname;
        if (strlen($firstname) > 0) {
            if ($CFG_GLPI["names_format"] == FIRSTNAME_BEFORE) {
                $temp = $firstname . " " . $temp;
            } else {
                $temp .= " " . $firstname;
            }
        }
        if ($cut > 0 && utf8_strlen($temp) > $cut) {
            $temp = utf8_substr($temp, 0, $cut);
            $temp .= " ...";
        }
    } else {
        $temp = $login;
    }
    if ($ID > 0 && (strlen($temp) == 0 || $_SESSION["glpiis_ids_visible"])) {
        $viewID = "&nbsp;({$ID})";
    }
    if ($link == 1 && $ID > 0) {
        /*$before="<a title=\"".$temp."\"
          href=\"".$CFG_GLPI["root_doc"]."/front/user.form.php?id=".$ID."\">";*/
        $before = "<a title=\"" . $temp . "\"\n                  href=\"item.php?itemtype=user&menu=" . $_GET['menu'] . "&ssmenu=" . $_GET['ssmenu'] . "&id=" . $ID . "\" data-back='false'>";
        $after = "</a>";
    }
    //$username=$before.$temp.$viewID.$after;
    $username = $temp . $viewID;
    return $username;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:35,代码来源:common.function.php


示例17: toExternalUrl

 /**
  * @param string $internalUrl
  * @return mixed The URL to access the target file from outside, if available, or FALSE.
  */
 public static function toExternalUrl($internalUrl)
 {
     $currentProc = ProcManager::getInstance()->getCurrentProcess();
     if ($currentProc) {
         $checknum = $currentProc->getChecknum();
     } else {
         $checknum = -1;
     }
     $urlParts = AdvancedPathLib::parse_url($internalUrl);
     if ($urlParts === false) {
         return $internalUrl;
     }
     if ($urlParts['scheme'] === EyeosAbstractVirtualFile::URL_SCHEME_SYSTEM) {
         // EXTERN
         try {
             $externPath = AdvancedPathLib::resolvePath($urlParts['path'], '/extern', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             return 'index.php?extern=' . $externPath;
         } catch (Exception $e) {
         }
         // APPS
         try {
             $appPath = AdvancedPathLib::resolvePath($urlParts['path'], '/apps', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             $appName = utf8_substr($appPath, 1, utf8_strpos($appPath, '/', 1));
             $appFile = utf8_substr($appPath, utf8_strlen($appName) + 1);
             return 'index.php?checknum=' . $checknum . '&appName=' . $appName . '&appFile=' . $appFile;
         } catch (Exception $e) {
         }
         return $internalUrl;
     }
     //TODO
     return $internalUrl;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:36,代码来源:EyeosUrlTranslator.php


示例18: _log

 protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
     $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => 'xengallery_album', 'content_id' => $content['album_id'], 'content_user_id' => $content['album_user_id'], 'content_username' => $content['album_username'], 'content_title' => utf8_substr($content['album_title'], 0, 150), 'content_url' => XenForo_Link::buildPublicLink('xengallery/albums', $content), 'discussion_content_type' => 'xengallery_album', 'discussion_content_id' => $content['album_id'], 'action' => $action, 'action_params' => $actionParams));
     $dw->save();
     return $dw->get('moderator_log_id');
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:7,代码来源:Album.php


示例19: cText

 public static function cText($text, $limit, $type = 0)
 {
     //function to cut text
     $text = preg_replace('/<img[^>]+\\>/i', "", $text);
     if ($limit == 0) {
         //no limit
         $allowed_tags = '<b><i><a><small><h1><h2><h3><h4><h5><h6><sup><sub><em><strong><u><br>';
         $text = strip_tags($text, $allowed_tags);
         $text = $text;
     } else {
         if ($type == 1) {
             //character lmit
             $text = JFilterOutput::cleanText($text);
             $sep = strlen($text) > $limit ? '...' : '';
             $text = utf8_substr($text, 0, $limit) . $sep;
         } else {
             //word limit
             $text = JFilterOutput::cleanText($text);
             $text = explode(' ', $text);
             $sep = count($text) > $limit ? '...' : '';
             $text = implode(' ', array_slice($text, 0, $limit)) . $sep;
         }
     }
     return $text;
 }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:25,代码来源:common.php


示例20: index

 public function index($setting)
 {
     $this->load->language('extension/module/blog_popular');
     $this->load->model('blog/blog');
     $data['heading_title'] = $this->language->get('heading_title');
     $data['button_read_more'] = $this->language->get('button_read_more');
     $data['blogs'] = array();
     $results = $this->model_blog_blog->getPopularBlogs($setting['limit']);
     foreach ($results as $result) {
         if ($result['image']) {
             $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
         } else {
             $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
         }
         $tags_array = array();
         if ($result['tag']) {
             $tags = explode(',', $result['tag']);
             foreach ($tags as $tag) {
                 $tags_array[] = array('tag' => trim($tag), 'href' => $this->url->link('blog/blog', 'tag=' . trim(urlencode($tag))));
             }
         }
         $data['blogs'][] = array('blog_id' => $result['blog_id'], 'title' => $result['title'], 'brief' => utf8_substr(strip_tags(html_entity_decode($result['brief'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('cms_blog_brief_length')) . '..', 'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 'date_added' => $result['date_added'], 'thumb' => $image, 'tags' => $tags_array, 'href' => $this->url->link('blog/blog', 'blog_id=' . $result['blog_id']));
     }
     return $this->load->view('extension/module/blog_popular/default', $data);
 }
开发者ID:brunoxu,项目名称:mycncart,代码行数:25,代码来源:blog_popular.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP utf8_substr_replace函数代码示例发布时间:2022-05-23
下一篇:
PHP utf8_strtoupper函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap