本文整理汇总了PHP中tpl::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP tpl::truncate方法的具体用法?PHP tpl::truncate怎么用?PHP tpl::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpl
的用法示例。
在下文中一共展示了tpl::truncate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
function view()
{
$nUserID = $this->security->getUserID();
if (bff::$isAjax) {
$aResponse = array();
switch (func::GET('act')) {
case 'comment':
$p = $this->input->postm(array('id' => TYPE_UINT, 'reply' => TYPE_UINT, 'message' => TYPE_STR, 'name' => TYPE_NOHTML, 'captcha' => TYPE_STR));
if (!$p['id']) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
$p['name'] = func::cleanComment($p['name']);
$p['message'] = func::cleanComment($p['message']);
if (empty($p['message'])) {
$this->errors->set('comm_message');
}
if (!$nUserID) {
if (empty($p['name'])) {
$this->errors->set('comm_name');
}
$oProtection = new CCaptchaProtection();
if (!$oProtection->valid(isset($_SESSION['c2']) ? $_SESSION['c2'] : '', $p['captcha'])) {
$aResponse['captcha_wrong'] = 1;
$this->errors->set('comm_wrong_captcha');
}
}
if ($this->errors->no()) {
unset($_SESSION['c2']);
$res = $this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS_COMMENTS . ' (pid, item_id, user_id, comment, name, ip, created)
VALUES(' . $p['reply'] . ', ' . $p['id'] . ', ' . $nUserID . ', :comment, :name, :ip, :created)', array(':comment' => $p['message'], ':name' => $p['name'], ':ip' => func::getRemoteAddress(), ':created' => $this->db->getNOW(false)));
if ($nCommentID = $this->db->insert_id(TABLE_BBS_ITEMS_COMMENTS, 'id')) {
$aData = $this->db->one_array('SELECT IC.*, ( CASE WHEN IC.user_id != 0 THEN U.name ELSE IC.name END) as name,
I.user_id as owner_id, I.contacts_email, U.blocked as user_blocked
FROM ' . TABLE_BBS_ITEMS_COMMENTS . ' IC
LEFT JOIN ' . TABLE_USERS . ' U ON IC.user_id = U.user_id,
' . TABLE_BBS_ITEMS . ' I
WHERE IC.id=' . $nCommentID . ' AND IC.item_id = I.id');
$aData['my'] = $aData['owner_id'] > 0 && $aData['owner_id'] == $nUserID;
$aData['cur_user_id'] = $nUserID;
$aResponse['comment'] = $this->tplFetchPHP($aData, 'item.view.comment.php');
$sEnotifyEmail = false;
if ($aData['owner_id']) {
if (!$nUserID || $nUserID > 0 && $aData['owner_id'] != $nUserID) {
//комментатор > незарег. пользователь или не владелец объявления
// для зарег. пользователей отправляем на email указанный при регистрации
$sEnotifyEmail = $this->db->one_data('SELECT email FROM ' . TABLE_USERS . ' WHERE user_id = ' . $aData['owner_id']);
}
} else {
// для незарег. пользователей отправляем на контактный email
$sEnotifyEmail = $aData['contacts_email'];
if ($this->isEditPassGranted($p['id'])) {
$sEnotifyEmail = false;
// есть доступ к редактированию, значит = владелец объявления
}
}
if (!empty($sEnotifyEmail) && func::IsEmailAddress($sEnotifyEmail)) {
// отправляем уведомление о новом комментарии к объявлению
$this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS_COMMENTS_ENOTIFY . ' (item_id, comment_id, comment, email, created)
VALUES(' . $p['id'] . ', ' . $nCommentID . ', :comment, :email, ' . time() . ')', array(':comment' => nl2br(tpl::truncate($p['message'], 100, '...', true)), ':email' => $sEnotifyEmail));
}
}
}
break;
case 'comment_del':
$p = $this->input->postm(array('id' => TYPE_UINT, 'comment_id' => TYPE_UINT));
if (!$p['id'] || !$p['comment_id']) {
$this->errors->set(Errors::IMPOSSIBLE);
break;
}
if (!$nUserID) {
$this->errors->set(Errors::ACCESSDENIED);
break;
}
$isCommentOwner = $this->db->one_data('SELECT user_id FROM ' . TABLE_BBS_ITEMS_COMMENTS . ' WHERE id = ' . $p['comment_id'] . ' AND user_id = ' . $nUserID);
if ($isCommentOwner) {
$res = $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS_COMMENTS . ' SET deleted = 3 WHERE id = ' . $p['comment_id']);
$aResponse['success'] = !empty($res);
$aResponse['by'] = 3;
} else {
$isOwner = $this->db->one_data('SELECT id FROM ' . TABLE_BBS_ITEMS . ' WHERE id = ' . $p['id'] . ' AND user_id = ' . $nUserID);
if (empty($isOwner)) {
$this->errors->set(Errors::ACCESSDENIED);
break;
}
$res = $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS_COMMENTS . ' SET deleted = 1 WHERE id = ' . $p['comment_id']);
$aResponse['success'] = !empty($res);
$aResponse['by'] = 1;
}
break;
}
$aResponse['res'] = $this->errors->no();
$this->ajaxResponse($aResponse);
}
$nItemID = $this->input->id('id');
if (!$nItemID) {
func::JSRedirect('/');
}
$sqlDate = $this->db->str2sql(date('Y-m-d'));
$dp = $this->initDynprops();
//.........这里部分代码省略.........
示例2:
<b class="upper grey"><?php
echo $i['cat_subtype_title'];
?>
:</b> <?php
}
?>
<a href="/item/<?php
echo $i['id'];
?>
" class="desc-link">
<?php
echo tpl::truncate($i['title'], 200, '...', true);
?>
<br />
<?php
echo tpl::truncate($i['descr'], 200, '...', true);
?>
</a>
<div class="address"><?php
echo $i['cat1_title'];
if ($i['cat2_id']) {
?>
<img src="/img/arrowRightSmall.png" /> <?php
echo $i['cat2_title'];
}
?>
<?php
echo $i['cat_regions'] && !empty($i['descr_regions']) ? '/ ' . $i['descr_regions'] : '';
?>
</div>
</td>