本文整理汇总了PHP中string::hstrlen方法的典型用法代码示例。如果您正苦于以下问题:PHP string::hstrlen方法的具体用法?PHP string::hstrlen怎么用?PHP string::hstrlen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string
的用法示例。
在下文中一共展示了string::hstrlen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doview
function doview()
{
$id = $this->get[2];
$did = $this->get[3];
if (!is_numeric($id) || !is_numeric($did) || empty($did)) {
$this->message($this->view->lang['parameterError'], 'BACK', 0);
}
$pic = $_ENV['pic']->get_pic_by_id($id);
$piclist = $_ENV['pic']->get_pic_by_did($did);
$comments = $_ENV['comment']->get_comments($did, $start = 0, $limit = 5);
foreach ($comments as $key => $comment) {
$comments[$key]['comment'] = string::hstrlen($comment['comment']) > 60 ? string::substring($comment['comment'], 0, 60) . "..." : $comment['comment'];
}
$countnum = count($piclist);
foreach ($piclist as $key => $val) {
if ($val['id'] == $id) {
$all_key = $key;
break;
}
}
if ($countnum <= 12) {
$returnlist =& $piclist;
$li_key = $all_key;
} else {
$i = 12 - ($countnum - $all_key);
$li_key = $i > 0 ? $i : 0;
$returnlist = array_slice($piclist, $all_key - $li_key, 12);
}
$this->view->assign('did', $did);
$this->view->assign('max_num', $countnum);
$this->view->assign('all_key', $all_key);
$this->view->assign('li_key', $li_key);
$this->view->assign('comments', $comments);
$this->view->assign('pic', $pic);
$this->view->assign("piclist", $returnlist);
$this->view->assign('navtitle', $pic['title'] . $this->view->lang['image']);
//$this->view->display('viewpic');
$_ENV['block']->view('viewpic');
}
示例2: doimport
function doimport()
{
$title = string::hiconv($this->post['title']);
$data = $_ENV['doc']->get_doc_by_title($title);
$page = $this->cache->getcache('systemdata');
if (empty($page)) {
$page = 1;
}
$_ENV['hdapi']->roll_docs($page, 10);
$this->cache->writecache('systemdata', ++$page);
if ($data) {
$this->message(0, '', 2);
}
$doc['content'] = $_ENV['hdapi']->get_content_import($title, 2, true);
$doc['tags'] = array($title);
$doc['search_tags'] = $title;
if ($doc['content'] && is_string($doc['content'])) {
$doc['category'] = $this->post['cid'];
$doc['title'] = $title;
$doc['letter'] = string::getfirstletter($title);
$doc['content'] = mysql_real_escape_string($doc['content']);
$doc['content'] = str_replace('\\r\\n', "\r\n", $doc['content']);
$doc['tags'] = $_ENV['doc']->jointags($doc['tags']);
$doc['summary'] = trim(string::convercharacter(strip_tags($doc['content'])));
$doc['images'] = util::getimagesnum($doc['content']);
$doc['time'] = $this->time;
$doc['words'] = string::hstrlen($doc['content']);
$doc['visible'] = '1';
//$this->setting['verify_doc']?'0':'1';
$did = $_ENV['doc']->add_doc($doc);
$_ENV['doc']->add_searchindex($did, $doc['title'], $doc['search_tags'], $doc['content']);
$_ENV['user']->add_credit($this->user['uid'], 'doc-create', $this->setting['credit_create']);
$_ENV['user']->update_field('creates', $this->user['creates'] + 1, $this->user['uid']);
$_ENV['category']->update_category_docs($this->post['category']);
//$data = array('did'=>$did, 'name'=>'互动百科 '.$title, 'url'=>'http://www.hudong.com/wiki/'.urlencode($this->post['title']));
//$_ENV['reference']->add($data);
$this->message(1, '', 2);
} else {
if ($doc['content'] && is_array($doc['content'])) {
$this->message($doc['content']['return_type'] . '_' . $doc['content']['return_info'], '', 2);
} else {
$this->message(2, '', 2);
}
}
}
示例3: recent_comment
function recent_comment($start = 0, $limit = 10)
{
$comments = array();
$query = $this->db->query('SELECT u.image,c.* FROM ' . DB_TABLEPRE . 'comment c LEFT JOIN ' . DB_TABLEPRE . 'user u ON c.authorid=u.uid ORDER BY `time` DESC LIMIT ' . "{$start},{$limit}");
while ($comment = $this->db->fetch_array($query)) {
$comment['comment'] = $comment['comment'];
$comment['image'] = $comment['image'] ? $comment['image'] : 'style/default/user.jpg';
$comment['image'] = $_ENV['global']->uc_api_avatar($comment['image'], $comment['authorid'], 'small');
$comment['tipcomment'] = string::hstrlen($comment['comment']) > 12 ? string::substring($comment['comment'], 0, 12) . "..." : $comment['comment'];
$comment['time'] = $this->base->date($comment['time']);
$comments[] = $comment;
}
return $comments;
}
示例4: doimport
function doimport()
{
//global $wmdb;
if (file_exists($this->configfile) && file_exists($this->sumfile)) {
include $this->configfile;
include $this->sumfile;
} else {
$this->message('5|0', '', 2);
}
$this->wmdb = new hddb(WDB_HOST, WDB_USER, WDB_PW, WDB_NAME, WDB_CHARSET, WDB_CONNECT);
//$wmdb = $this->wmdb;
//判断做到哪一步了.
if (file_exists($this->processfile)) {
include $this->processfile;
list($type, $i) = explode('|', $process);
if ($type >= 5) {
$this->message('5|0', '', 2);
}
} else {
list($type, $i) = array(1, 0);
}
$totalnum = array(1 => $catsum, 2 => $usersum, 3 => $docsum, 4 => $clinksum);
$totalnum = $totalnum[$type];
$j = 10;
for (; $i < $totalnum; $i += $j) {
$msg = $type . '|' . (($n = $i + $j) >= $totalnum ? $totalnum : $n);
if ($type == 1 || $type == 2 || $type == 4) {
//导入分类和用户。
$hdsql = $_ENV['mwimport']->get_sql($this->wmdb, $type, $i, $j);
if (!$hdsql || $this->db->query($hdsql)) {
$_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
} else {
$this->message('5|0', '', 2);
}
} elseif ($type == 3) {
include HDWIKI_ROOT . '/plugins/mwimport/text/Mediawiki.php';
$parser = 'Mediawiki';
$text_wiki = new Text_Wiki_Mediawiki();
$sql = "SELECT a.page_id, a.page_title, b.old_text, b.old_flags, b.old_id FROM " . WDB_TABLEPRE . "page a, " . WDB_TABLEPRE . "text b WHERE a.page_namespace = 0 AND a.page_latest = b.old_id limit " . $i . ",{$j}";
$query = $this->wmdb->query($sql);
while ($doc = $this->wmdb->fetch_array($query)) {
if ($_ENV['doc']->get_doc_by_title($doc['page_title'])) {
continue;
}
$doc['did'] = $doc['page_id'];
$doc['title'] = $doc['page_title'];
$doc['letter'] = string::getfirstletter($doc['page_title']);
$wiki = $text_wiki->singleton($parser);
$result = $wiki->transform($source);
$doc['old_text'] = $wiki->transform($doc['old_text']);
//加入对内容的处理和过滤。
$doc['old_text'] = mysql_real_escape_string($doc['old_text']);
$doc['tags'] = '';
$doc['summary'] = trim(string::convercharacter(string::substring(strip_tags($doc['old_text']), 0, 100)));
$doc['images'] = util::getimagesnum($doc['old_text']);
$doc['time'] = $this->time;
$doc['words'] = string::hstrlen($doc['old_text']);
$doc['visible'] = '1';
$doc['cid'] = $_ENV['mwimport']->get_cid($this->wmdb, '', $doc['did']);
$sql = "SELECT rev_user,rev_user_text FROM " . WDB_TABLEPRE . "revision WHERE rev_page = " . $doc['page_id'] . " ORDER BY rev_id ";
$user = $this->wmdb->fetch_first($sql);
$this->db->query("REPLACE INTO " . DB_TABLEPRE . "doc\r\n\t\t\t (did,cid,letter,title,tag ,summary ,content,author,authorid,time,lastedit,lasteditor,lasteditorid,visible,editions)\r\n\t\t\t VALUES (" . $doc['did'] . "," . $doc['cid'] . ",'" . $doc['letter'] . "','" . $doc['title'] . "','" . $doc['tags'] . "','" . $doc['summary'] . "','" . $doc['old_text'] . "',\r\n\t\t\t '" . $user['rev_user_text'] . "','" . $user['rev_user'] . "',\r\n\t\t\t " . $doc['time'] . "," . $doc['time'] . ",'" . $user['rev_user_text'] . "','" . $user['rev_user'] . "','" . $doc['visible'] . "',1)");
}
$_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
}
$this->message($msg, '', 2);
}
$msg = $type + 1 . '|0';
$_ENV['mwimport']->writefile($this->processfile, '<?php $process = "' . $msg . '"; ?>');
$this->message($msg, '', 2);
}
示例5: cooperatedocs
function cooperatedocs($num = 0)
{
$coopdoc = array();
$cooperatedocs = explode(';', $this->base->setting['cooperatedoc']);
if ($num == 0) {
$counts = count($cooperatedocs);
} else {
$counts = $num;
}
for ($i = 0; $i < $counts; $i++) {
if ($cooperatedocs[$i] == '') {
unset($cooperatedocs[$i]);
} else {
$coopdoc[$i]['shorttitle'] = string::hstrlen($cooperatedocs[$i]) > 10 ? string::substring($cooperatedocs[$i], 0, 5) . "..." : $cooperatedocs[$i];
$coopdoc[$i]['title'] = $cooperatedocs[$i];
}
}
return $coopdoc;
}
示例6: docooperate
function docooperate()
{
$coopdoc = array();
$cooperatedocs = explode(';', $this->setting['cooperatedoc']);
$counts = count($cooperatedocs);
for ($i = 0; $i < $counts; $i++) {
if ($cooperatedocs[$i] == '') {
unset($cooperatedocs[$i]);
} else {
$coopdoc[$i]['shorttitle'] = string::hstrlen($cooperatedocs[$i]) > 4 ? string::substring($cooperatedocs[$i], 0, 4) . "..." : $cooperatedocs[$i];
$coopdoc[$i]['title'] = $cooperatedocs[$i];
}
}
$this->view->assign('coopdoc', $coopdoc);
//$this->view->display('cooperate');
$_ENV['block']->view('cooperate');
}