本文整理汇总了PHP中helper::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::substr方法的具体用法?PHP helper::substr怎么用?PHP helper::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::substr方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
<div class='cards condensed cards-list'>
<?php
$total = 0;
?>
<?php
foreach ($products as $productID => $product) {
?>
<?php
$productLink = helper::createLink('product', 'view', "id={$productID}", "category={$product->categories[$product->category]->alias}&name={$product->alias}");
?>
<div class='card'>
<div class='table-layout'>
<div class='table-cell thumbnail-cell'>
<?php
if (empty($product->image)) {
$productName = helper::substr($product->name, 10, '...');
$imgColor = $product->id * 57 % 360;
echo "<div class='media-holder'><div class='media-placeholder' style='background-color: hsl({$imgColor}, 60%, 80%); color: hsl({$imgColor}, 80%, 30%);' data-id='{$product->id}'>{$productName}</div></div>";
} else {
echo html::image($product->image->primary->middleURL, "title='{$product->name}' alt='{$product->name}'");
}
?>
</div>
<div class='table-cell'>
<table class='table table-layout table-condensed'>
<tbody>
<tr>
<td colspan='2'>
<strong><?php
echo html::a($productLink, $product->name);
?>
示例2: substr
</div>
<div class='item-content'>
<?php
if (!empty($page->image)) {
?>
<div class='media pull-right'>
<?php
$title = $page->image->primary->title ? $page->image->primary->title : $page->title;
echo html::a($url, html::image($page->image->primary->smallURL, "title='{$title}' class='thumbnail'"));
?>
</div>
<?php
}
?>
<div class='text text-muted'><?php
echo helper::substr($page->summary, 120, '...');
?>
</div>
</div>
<div class='item-footer text-muted'>
<span><i class='icon-eye-open'></i> <?php
echo $page->views;
?>
</span>
<span><i class='icon-time'></i> <?php
echo substr($page->addedDate, 0, 10);
?>
</span>
</div>
</div>
<?php
示例3: processArticleList
/**
* Process article list.
*
* @param array $articles
* @param string $type
* @access public
* @return array
*/
public function processArticleList($articles, $type)
{
$categories = $this->dao->select('t2.id, t2.name, t2.abbr, t2.alias, t1.id AS article')->from(TABLE_RELATION)->alias('t1')->leftJoin(TABLE_CATEGORY)->alias('t2')->on('t1.category = t2.id')->where('t2.type')->eq($type)->fetchGroup('article', 'id');
/* Assign categories to it's article. */
foreach ($articles as $article) {
$article->categories = isset($categories[$article->id]) ? $categories[$article->id] : array();
}
foreach ($articles as $article) {
$article->category = current($article->categories);
}
/* Get images for these articles. */
$images = $this->loadModel('file')->getByObject($type, array_keys($articles), $isImage = true);
/* Assign images to it's article. */
foreach ($articles as $article) {
if (empty($images[$article->id])) {
continue;
}
$article->image = new stdclass();
$article->image->list = $images[$article->id];
$article->image->primary = $article->image->list[0];
}
/* Assign summary to it's article. */
foreach ($articles as $article) {
$article->summary = empty($article->summary) ? helper::substr(strip_tags($article->content), 200, '...') : $article->summary;
}
/* Assign comments to it's article. */
$articleIdList = array_keys($articles);
$comments = $this->dao->select("objectID, count(*) as count")->from(TABLE_MESSAGE)->where('type')->eq('comment')->andWhere('objectType')->eq('article')->andWhere('objectID')->in($articleIdList)->andWhere('status')->eq(1)->groupBy('objectID')->fetchPairs('objectID', 'count');
foreach ($articles as $article) {
$article->comments = isset($comments[$article->id]) ? $comments[$article->id] : 0;
}
return $articles;
}
示例4: getList
/**
* Get product list.
*
* @param array $categories
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($categories, $orderBy, $pager = null)
{
$searchWord = $this->get->searchWord;
$categoryID = $this->get->categoryID;
/* Get products(use groupBy to distinct products). */
$productsIdList = array();
if (!empty($categories)) {
$productList = $this->dao->select('id')->from(TABLE_RELATION)->where('type')->eq('product')->andWhere('category')->in($categories)->fetchAll('id');
$productsIdList = array_keys($productList);
}
$products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('1 = 1')->beginIF(!empty($categories))->andWhere('id')->in($productsIdList)->fi()->beginIF(RUN_MODE == 'front')->andWhere('status')->eq('normal')->fi()->beginIF($searchWord)->andWhere('name', true)->like("%{$searchWord}%")->orWhere('brand')->like("%{$searchWord}%")->orWhere('model')->like("%{$searchWord}%")->orWhere('color')->like("%{$searchWord}%")->orWhere('origin')->like("%{$searchWord}%")->orWhere('keywords')->like("%{$searchWord}%")->orWhere('`desc`')->like("%{$searchWord}%")->orWhere('content')->like("%{$searchWord}%")->markRight(1)->fi()->orderBy($orderBy)->page($pager)->fetchAll('id');
if (!$products) {
return array();
}
/* Get categories for these products. */
$categories = $this->dao->select('t2.id, t2.name, t2.abbr, t2.alias, t2.unsaleable, t1.id AS product')->from(TABLE_RELATION)->alias('t1')->leftJoin(TABLE_CATEGORY)->alias('t2')->on('t1.category = t2.id')->where('t2.type')->eq('product')->andWhere('t1.id')->in(array_keys($products))->fetchGroup('product', 'id');
/* Assign categories to it's product. */
foreach ($products as $product) {
$product->categories = !empty($categories[$product->id]) ? $categories[$product->id] : array();
$product->category = current($product->categories);
}
foreach ($products as $product) {
foreach ($product->categories as $category) {
if ($category->unsaleable and !$product->unsaleable) {
$product->unsaleable = 1;
}
}
}
/* Get images for these products. */
$images = $this->loadModel('file')->getByObject('product', array_keys($products), $isImage = true);
/* Assign images to it's product. */
foreach ($products as $product) {
if (empty($images[$product->id])) {
continue;
}
$product->image = new stdclass();
if (isset($images[$product->id])) {
$product->image->list = $images[$product->id];
}
if (!empty($product->image->list)) {
$product->image->primary = $product->image->list[0];
}
$product->desc = empty($product->desc) ? helper::substr(strip_tags($product->content), 250) : $product->desc;
}
return $products;
}
示例5: zget
<strong><?php
echo html::a($url, $product->name);
?>
</strong>
<span class='text-latin'>
<?php
if (!$product->unsaleable) {
if ($product->promotion != 0) {
echo " <strong class='text-danger'>" . zget($this->lang->product->currencySymbols, $this->config->product->currency) . $product->promotion . '</strong>';
if ($product->price != 0) {
echo " <del class='text-muted'>" . zget($this->lang->product->currencySymbols, $this->config->product->currency) . $product->price . '</del>';
}
} else {
if ($product->price != 0) {
echo "<span class='text-muted'> " . zget($this->lang->product->currencySymbols, $this->config->product->currency) . "</span> ";
echo "<strong class='text-important'>" . $product->price . '</strong> ';
}
}
}
?>
</span>
</div>
<div class='card-content text-muted'><?php
echo helper::substr(strip_tags($product->desc), 80);
?>
</div>
</div>
</div>
</div>
<?php
}
示例6: foreach
if (commonModel::isAvailable('forum')) {
?>
<div class='col-xs-6'>
<div class='panel'>
<div class='panel-heading'><strong><?php
echo $lang->admin->thread;
?>
</strong></div>
<div class='panel-body'>
<table class='table table-hover table-condensed table-borderless'>
<?php
foreach ($threads as $thread) {
?>
<?php
$threadTitle = $thread->author . '  ' . helper::substr($thread->title, 25);
?>
<tr>
<td><?php
echo html::a(commonmodel::createFrontLink('thread', 'view', "threadid={$thread->id}"), $threadTitle, "target='_blank'");
?>
</td>
<td><?php
echo substr($thread->addedDate, -8);
?>
</td>
</tr>
<?php
}
?>
<?php
示例7: getList
/**
* Get product list.
*
* @param array $categories
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($categories, $orderBy, $pager = null)
{
/* Get products(use groupBy to distinct products). */
$products = $this->dao->select('t1.*, t2.category')->from(TABLE_PRODUCT)->alias('t1')->leftJoin(TABLE_RELATION)->alias('t2')->on('t1.id = t2.id')->where('1 = 1')->beginIF($categories)->andWhere('t2.category')->in($categories)->fi()->beginIF(RUN_MODE == 'front')->andWhere('t1.status')->eq('normal')->fi()->groupBy('t2.id')->orderBy($orderBy)->page($pager)->fetchAll('id');
if (!$products) {
return array();
}
/* Get categories for these products. */
$categories = $this->dao->select('t2.id, t2.name, t2.alias, t1.id AS product')->from(TABLE_RELATION)->alias('t1')->leftJoin(TABLE_CATEGORY)->alias('t2')->on('t1.category = t2.id')->where('t2.type')->eq('product')->fetchGroup('product', 'id');
/* Assign categories to it's product. */
foreach ($products as $product) {
$product->categories = !empty($categories[$product->id]) ? $categories[$product->id] : array();
}
foreach ($products as $product) {
$product->category = current($product->categories);
}
/* Get images for these products. */
$images = $this->loadModel('file')->getByObject('product', array_keys($products), $isImage = true);
/* Assign images to it's product. */
foreach ($products as $product) {
if (empty($images[$product->id])) {
continue;
}
$product->image = new stdclass();
if (isset($images[$product->id])) {
$product->image->list = $images[$product->id];
}
if (!empty($product->image->list)) {
$product->image->primary = $product->image->list[0];
}
}
/* Assign desc to it's product. */
foreach ($products as $product) {
$product->desc = empty($product->desc) ? helper::substr(strip_tags($product->content), 250) : $product->desc;
}
/* Assign comments to it's product. */
$productList = array_keys($products);
$comments = $this->dao->select("objectID, count(*) as count")->from(TABLE_MESSAGE)->where('type')->eq('comment')->andWhere('objectType')->eq('product')->andWhere('objectID')->in($productList)->andWhere('status')->eq(1)->groupBy('objectID')->fetchPairs('objectID', 'count');
foreach ($products as $product) {
$product->comments = isset($comments[$product->id]) ? $comments[$product->id] : 0;
}
return $products;
}
示例8: getList
/**
* Get article list.
*
* @param string $type
* @param array $categories
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($type, $categories, $orderBy, $pager = null)
{
if ($type == 'page') {
$articles = $this->dao->select('*')->from(TABLE_ARTICLE)->where('type')->eq('page')->orderBy('id_desc')->page($pager)->fetchAll('id');
} else {
/* Get articles(use groupBy to distinct articles). */
$articles = $this->dao->select('t1.*, t2.category')->from(TABLE_ARTICLE)->alias('t1')->leftJoin(TABLE_RELATION)->alias('t2')->on('t1.id = t2.id')->where('t1.type')->eq($type)->beginIf(defined('RUN_MODE') and RUN_MODE == 'front')->andWhere('t1.addedDate')->le(helper::now())->andWhere('t1.status')->eq('normal')->fi()->beginIf($categories)->andWhere('t2.category')->in($categories)->fi()->groupBy('t2.id')->orderBy($orderBy)->page($pager)->fetchAll('id');
}
if (!$articles) {
return array();
}
/* Get categories for these articles. */
$categories = $this->dao->select('t2.id, t2.name, t2.alias, t1.id AS article')->from(TABLE_RELATION)->alias('t1')->leftJoin(TABLE_CATEGORY)->alias('t2')->on('t1.category = t2.id')->where('t2.type')->eq($type)->beginIf($categories)->andWhere('t1.category')->in($categories)->fi()->fetchGroup('article', 'id');
/* Assign categories to it's article. */
foreach ($articles as $article) {
$article->categories = isset($categories[$article->id]) ? $categories[$article->id] : array();
}
/* Get images for these articles. */
$images = $this->loadModel('file')->getByObject($type, array_keys($articles), $isImage = true);
/* Assign images to it's article. */
foreach ($articles as $article) {
if (empty($images[$article->id])) {
continue;
}
$article->image = new stdclass();
$article->image->list = $images[$article->id];
$article->image->primary = $article->image->list[0];
}
/* Assign summary to it's article. */
foreach ($articles as $article) {
$article->summary = empty($article->summary) ? helper::substr(strip_tags($article->content), 200, '...') : $article->summary;
}
/* Assign comments to it's article. */
$articleIdList = array_keys($articles);
$comments = $this->dao->select("objectID, count(*) as count")->from(TABLE_MESSAGE)->where('type')->eq('comment')->andWhere('objectType')->eq('article')->andWhere('objectID')->in($articleIdList)->andWhere('status')->eq(1)->groupBy('objectID')->fetchPairs('objectID', 'count');
foreach ($articles as $article) {
$article->comments = isset($comments[$article->id]) ? $comments[$article->id] : 0;
}
return $articles;
}
示例9: substr
</div>
<div class='item-content'>
<?php
if (!empty($article->image)) {
?>
<div class='media pull-right'>
<?php
$title = $article->image->primary->title ? $article->image->primary->title : $article->title;
echo html::a($url, html::image($article->image->primary->smallURL, "title='{$title}' class='thumbnail'"));
?>
</div>
<?php
}
?>
<div class='text text-muted'><?php
echo helper::substr($article->summary, 120, '...');
?>
</div>
</div>
<div class='item-footer text-muted'>
<span><i class='icon-eye-open'></i> <?php
echo $article->views;
?>
</span>
<span><i class='icon-time'></i> <?php
echo substr($article->createdDate, 0, 10);
?>
</span>
</div>
</div>
<?php
示例10:
</div>
<div class='card-heading'>
<strong><?php
echo $product->name;
?>
</strong>
<span class='text-latin'>
<?php
if ($product->promotion != 0) {
echo " <strong class='text-danger'>" . $this->config->product->currency . $product->promotion . '</strong>';
if ($product->price != 0) {
echo " <del class='text-muted'>" . $this->config->product->currency . $product->price . '</del>';
}
} else {
if ($product->price != 0) {
echo "<span class='text-muted'> {$this->config->product->currency}</span> ";
echo "<strong class='text-important'>" . $product->price . '</strong> ';
}
}
?>
</span>
</div>
<div class='card-content text-muted'><?php
echo helper::substr($product->desc, 80);
?>
</div>
</a>
</div>
</div>
<?php
}
示例11: foreach
<div class='col-xs-10' id='articles'>
<section>
<?php
foreach ($articles as $article) {
?>
<?php
$url = inlink('view', "id={$article->id}");
?>
<div class="card">
<h4 class='card-heading'><?php
echo html::a($url, $article->title);
?>
</h4>
<div class='card-content text-muted'>
<?php
echo helper::substr(strip_tags($article->content), 200, '...');
?>
<?php
if (!empty($article->image)) {
?>
<div class='media pull-right'>
<?php
$title = $article->image->primary->title ? $article->image->primary->title : $article->title;
echo html::a($url, html::image($article->image->primary->smallURL, "title='{$title}' class='thumbnail'"));
?>
</div>
<?php
}
?>
</div>
<div class="card-actions text-muted">
示例12: getList
/**
* Get article list.
*
* @param string $type
* @param array $categories
* @param string $mode
* @param string $param
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($type, $categories, $mode = null, $param = null, $orderBy, $pager = null)
{
$moduleQuery = $type . 'Query';
if ($this->session->{$moduleQuery} == false) {
$this->session->set($moduleQuery, ' 1 = 1');
}
${$moduleQuery} = $this->loadModel('search', 'sys')->replaceDynamic($this->session->{$moduleQuery});
/* Get articles(use groupBy to distinct articles). */
$articles = $this->dao->select('t1.*, t2.category')->from(TABLE_ARTICLE)->alias('t1')->leftJoin(TABLE_RELATION)->alias('t2')->on('t1.id = t2.id')->where('t1.type')->eq($type)->beginIf($categories)->andWhere('t2.category')->in($categories)->fi()->beginIf($mode == 'query' and $param)->andWhere($param)->fi()->beginIf($mode == 'bysearch')->andWhere(${$moduleQuery})->fi()->groupBy('t2.id')->orderBy($orderBy)->page($pager)->fetchAll('id');
if (!$articles) {
return array();
}
/* Get categories for these articles. */
$categories = $this->dao->select('t2.id, t2.name, t2.alias, t1.id AS article')->from(TABLE_RELATION)->alias('t1')->leftJoin(TABLE_CATEGORY)->alias('t2')->on('t1.category = t2.id')->where('t2.type')->eq($type)->beginIf($categories)->andWhere('t1.category')->in($categories)->fi()->fetchGroup('article', 'id');
/* Assign categories to it's article. */
foreach ($articles as $article) {
$article->categories = isset($categories[$article->id]) ? $categories[$article->id] : array();
}
/* Get images for these articles. */
$images = $this->loadModel('file')->getByObject($type, array_keys($articles), $isImage = true);
/* Assign images to it's article. */
foreach ($articles as $article) {
if (empty($images[$article->id])) {
continue;
}
$article->image = new stdclass();
$article->image->list = $images[$article->id];
$article->image->primary = $article->image->list[0];
}
/* Assign summary to it's article. */
foreach ($articles as $article) {
$article->summary = empty($article->summary) ? helper::substr(strip_tags($article->content), 200, '...') : $article->summary;
}
return $articles;
}