本文整理汇总了PHP中PMF_Utils::chopString方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Utils::chopString方法的具体用法?PHP PMF_Utils::chopString怎么用?PHP PMF_Utils::chopString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Utils
的用法示例。
在下文中一共展示了PMF_Utils::chopString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
}
foreach ($searchResult as $resultSet) {
foreach ($resultSet as $result) {
$mergedResult[] = $result;
}
}
$faqSearchResult->reviewResultset($mergedResult);
if (0 < $faqSearchResult->getNumberOfResults()) {
$response = sprintf('<p>%s</p>', $plr->GetMsg('plmsgSearchAmount', $faqSearchResult->getNumberOfResults()));
$response .= '<ul>';
foreach ($faqSearchResult->getResultset() as $result) {
$url = sprintf('/index.php?action=artikel&cat=%d&id=%d&artlang=%s', $result->category_id, $result->id, $result->lang);
$oLink = new PMF_Link(PMF_Configuration::getInstance()->get('main.referenceURL') . $url);
$oLink->text = PMF_Utils::chopString($result->question, 15);
$oLink->itemTitle = $result->question;
$response .= sprintf('<li>%s<br /><div class="searchpreview">%s...</div></li>', $oLink->toHtmlAnchor(), PMF_Utils::chopString(strip_tags($result->answer), 10));
}
$response .= '</ul>';
$message = array('result' => $response);
} else {
$questionData = array('username' => $name, 'email' => $email, 'category_id' => $ucategory, 'question' => $question, 'is_visible' => $visibility);
$faq->addQuestion($questionData);
$questionMail = "User: " . $questionData['username'] . ", mailto:" . $questionData['email'] . "\n" . $PMF_LANG["msgCategory"] . ": " . $categories[$questionData['category_id']]["name"] . "\n\n" . wordwrap($question, 72) . "\n\n" . $faqconfig->get('main.referenceURL') . '/admin/';
$userId = $cat->getCategoryUser($questionData['category_id']);
$oUser = new PMF_User();
$oUser->getUserById($userId);
$userEmail = $oUser->getUserData('email');
$mainAdminEmail = PMF_Configuration::getInstance()->get('main.administrationMail');
$mail = new PMF_Mail();
$mail->setReplyTo($questionData['email'], $questionData['username']);
$mail->addTo($mainAdminEmail);
示例2: renderSearchResult
/**
* Renders the result page for the main search page
*
* @param PMF_Search_Resultset $resultSet PMF_Search_Resultset object
* @param integer $currentPage Current page number
*
* @return string
*/
public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage)
{
$html = '';
$confPerPage = $this->_config->get('records.numberOfRecordsPerPage');
$numOfResults = $resultSet->getNumberOfResults();
$totalPages = ceil($numOfResults / $confPerPage);
$lastPage = $currentPage * $confPerPage;
$firstPage = $lastPage - $confPerPage;
if ($lastPage > $numOfResults) {
$lastPage = $numOfResults;
}
if (0 < $numOfResults) {
$html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults));
if (1 < $totalPages) {
$html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages));
}
$html .= "<ul class=\"phpmyfaq-search-results\">\n";
$counter = $displayedCounter = 0;
foreach ($resultSet->getResultset() as $result) {
if ($displayedCounter >= $confPerPage) {
break;
}
$counter++;
if ($counter <= $firstPage) {
continue;
}
$displayedCounter++;
// Set language for current category to fetch the correct category name
$this->Category->setLanguage($result->lang);
$categoryInfo = $this->Category->getCategoriesFromArticle($result->id);
$question = PMF_Utils::chopString($result->question, 15);
$answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25);
$searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm);
$searchterm = preg_quote($searchterm, '/');
$searchItems = explode(' ', $searchterm);
if (PMF_String::strlen($searchItems[0]) > 1) {
foreach ($searchItems as $item) {
if (PMF_String::strlen($item) > 2) {
$question = PMF_Utils::setHighlightedString($question, $item);
$answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item);
}
}
}
// Build the link to the faq record
$currentUrl = sprintf('%s?%saction=artikel&cat=%d&id=%d&artlang=%s&highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm));
$oLink = new PMF_Link($currentUrl, $this->_config);
$oLink->text = $question;
$oLink->itemTitle = $oLink->tooltip = $result->question;
$html .= "<li>";
$html .= sprintf("<strong>%s</strong>: %s<br />", $categoryInfo[0]['name'], $oLink->toHtmlAnchor());
$html .= sprintf("<small class=\"searchpreview\"><strong>%s</strong> %s...</small>\n", $this->translation['msgSearchContent'], $answerPreview);
$html .= "</li>";
}
$html .= "</ul>\n";
if (1 < $totalPages) {
$html .= $this->pagination->render();
}
} else {
$html = $this->translation['err_noArticles'];
}
return $html;
}
示例3: getAllRecordPerCategory
/**
* This function returns all not expired records from one category
*
* @param int $category_id Category ID
* @param string $orderby Order by
* @param string $sortby Sorty by
* @return array
*/
public function getAllRecordPerCategory($category_id, $orderby = 'id', $sortby = 'ASC')
{
global $sids;
$faqdata = array();
if ($orderby == 'visits') {
$current_table = 'fv';
} else {
$current_table = 'fd';
}
$now = date('YmdHis');
$query = sprintf("\n SELECT\n fd.id AS id,\n fd.lang AS lang,\n fd.thema AS thema,\n fd.content AS record_content,\n fd.datum AS record_date,\n fcr.category_id AS category_id,\n fv.visits AS visits\n FROM\n %sfaqdata AS fd\n LEFT JOIN\n %sfaqcategoryrelations AS fcr\n ON\n fd.id = fcr.record_id\n AND\n fd.lang = fcr.record_lang\n LEFT JOIN\n %sfaqvisits AS fv\n ON\n fd.id = fv.id\n AND\n fv.lang = fd.lang\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.date_start <= '%s'\n AND\n fd.date_end >= '%s'\n AND\n fd.active = 'yes'\n AND\n fcr.category_id = %d\n AND\n fd.lang = '%s'\n %s\n ORDER BY\n %s.%s %s", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $now, $now, $category_id, $this->_config->getLanguage()->getLanguage(), $this->queryPermission($this->groupSupport), $current_table, $this->_config->getDb()->escape($orderby), $this->_config->getDb()->escape($sortby));
$result = $this->_config->getDb()->query($query);
$num = $this->_config->getDb()->numRows($result);
if ($num > 0) {
while ($row = $this->_config->getDb()->fetchObject($result)) {
if (empty($row->visits)) {
$visits = 0;
} else {
$visits = $row->visits;
}
$url = sprintf('%s?%saction=artikel&cat=%d&id=%d&artlang=%s', PMF_Link::getSystemRelativeUri(), $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link($url, $this->_config);
$oLink->itemTitle = $oLink->text = $oLink->tooltip = $row->thema;
$faqdata[] = array('record_id' => $row->id, 'record_lang' => $row->lang, 'category_id' => $row->category_id, 'record_title' => $row->thema, 'record_preview' => PMF_Utils::chopString(strip_tags($row->record_content), 25), 'record_link' => $oLink->toString(), 'record_date' => $row->record_date, 'visits' => $visits);
}
} else {
return $faqdata;
}
return $faqdata;
}
示例4: getRecordsFromLetter
/**
* Returns all records from the current first letter
*
* @param string $letter Letter
* @return array
* @since 2007-03-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function getRecordsFromLetter($letter = 'A')
{
global $sids, $PMF_LANG;
if ($this->groupSupport) {
$permPart = sprintf("( fdg.group_id IN (%s)\n OR\n (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
} else {
$permPart = sprintf("( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
}
$letter = PMF_String::strtoupper($this->db->escape_string(PMF_String::substr($letter, 0, 1)));
$writeMap = '';
switch ($this->type) {
case 'db2':
case 'sqlite':
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.id = fcr.record_id\n AND\n SUBSTR(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
break;
default:
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.id = fcr.record_id\n AND\n SUBSTRING(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
break;
}
$result = $this->db->query($query);
$oldId = 0;
while ($row = $this->db->fetch_object($result)) {
if ($oldId != $row->id) {
$title = PMF_String::htmlspecialchars($row->thema, ENT_QUOTES, 'utf-8');
$url = sprintf('%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
$oLink->itemTitle = $row->thema;
$oLink->text = $title;
$oLink->tooltip = $title;
$writeMap .= '<li>' . $oLink->toHtmlAnchor() . '<br />' . "\n";
$writeMap .= PMF_Utils::chopString(strip_tags($row->snap), 25) . " ...</li>\n";
}
$oldId = $row->id;
}
$writeMap = empty($writeMap) ? '' : '<ul>' . $writeMap . '</ul>';
return $writeMap;
}
示例5: renderSearchResult
/**
* Renders the result page for the main search page
*
* @param PMF_Search_Resultset $resultSet PMF_Search_Resultset object
* @param integer $currentPage Current page number
*
* @return string
*/
public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage)
{
$html = '';
$confPerPage = PMF_Configuration::getInstance()->get('main.numberOfRecordsPerPage');
$numOfResults = $resultSet->getNumberOfResults();
$totalPages = ceil($numOfResults / $confPerPage);
$lastPage = $currentPage * $confPerPage;
$firstPage = $lastPage - $confPerPage;
if ($lastPage > $numOfResults) {
$lastPage = $numOfResults;
}
if (0 < $numOfResults) {
$html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults));
if (1 < $totalPages) {
$html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages));
}
$html .= "<ul class=\"phpmyfaq_ul\">\n";
foreach ($resultSet->getResultset() as $result) {
$categoryName = $this->categoryLayout->renderBreadcrumb(array($result->category_id));
$question = PMF_Utils::chopString($result->question, 15);
$answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25);
$searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm);
$searchterm = preg_quote($searchterm, '/');
$searchItems = explode(' ', $searchterm);
if (PMF_String::strlen($searchItems[0]) > 1) {
foreach ($searchItems as $item) {
if (PMF_String::strlen($item) > 2) {
$question = PMF_Utils::setHighlightedString($question, $item);
$answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item);
}
}
}
// Build the link to the faq record
$currentUrl = sprintf('%s?%saction=artikel&cat=%d&id=%d&artlang=%s&highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm));
$oLink = new PMF_Link($currentUrl);
$oLink->text = $oLink->itemTitle = $oLink->tooltip = $result->question;
$html .= sprintf("<li><strong>%s</strong>: %s<br /><div class=\"searchpreview\"><strong>%s</strong> %s...</div><br /></li>\n", $categoryName, $oLink->toHtmlAnchor(), $this->translation['msgSearchContent'], $answerPreview);
}
$html .= "</ul>\n";
if (1 > $totalPages) {
$html .= $this->pagination->render();
}
} else {
$html = $this->translation['err_noArticles'];
}
return $html;
}