本文整理汇总了PHP中iPHP::Markdown方法的典型用法代码示例。如果您正苦于以下问题:PHP iPHP::Markdown方法的具体用法?PHP iPHP::Markdown怎么用?PHP iPHP::Markdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iPHP
的用法示例。
在下文中一共展示了iPHP::Markdown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: value
public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
{
$article['appid'] = iCMS_APP_ARTICLE;
$categoryApp = iPHP::app("category");
$category = $categoryApp->category($article['cid'], false);
if ($tpl) {
$category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
} else {
if (empty($category)) {
return false;
}
}
if ($category['status'] == 0) {
return false;
}
if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
return false;
}
$_iurlArray = array($article, $category);
$article['iurl'] = iURL::get('article', $_iurlArray, $page);
$article['url'] = $article['iurl']->href;
$article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
$tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
if ($vars['category_lite']) {
$article['category'] = $categoryApp->get_lite($category);
} else {
$article['category'] = $category;
}
$this->taoke = false;
if ($art_data) {
$pageurl = $article['iurl']->pageurl;
// if(strpos($art_data['body'], '#--iCMS.ArticleData--#')!==false){
// iPHP::app('article.table');
// $art_data['body'] = articleTable::get_text($article['id']);
// }
$art_data['body'] = $this->ubb($art_data['body']);
preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
$p_array = array_unique($pic_array[1]);
if ($p_array) {
foreach ($p_array as $key => $_pic) {
$article['pics'][$key] = trim($_pic);
}
}
if (strpos($art_data['body'], '#--iCMS.Markdown--#') !== false) {
$art_data['body'] = iPHP::Markdown($art_data['body']);
}
$body = explode('#--iCMS.PageBreak--#', $art_data['body']);
$count = count($body);
$total = $count + intval(iCMS::$config['article']['pageno_incr']);
$article['body'] = $this->keywords($body[intval($page - 1)]);
$article['body'] = $this->taoke($article['body']);
$article['subtitle'] = $art_data['subtitle'];
$article['taoke'] = $this->taoke;
unset($art_data);
if ($total > 1) {
$flag = 0;
$num_nav = '';
for ($i = $page - 3; $i <= $page - 1; $i++) {
if ($i < 1) {
continue;
}
$num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
$flag++;
}
$num_nav .= '<span class="current">' . $page . '</span>';
for ($i = $page + 1; $i <= $total; $i++) {
$num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
$flag++;
if ($flag == 6) {
break;
}
}
$index_nav = '<a href="' . $article['url'] . '" class="first" target="_self">' . iPHP::lang('iCMS:page:index') . '</a>';
$prev_url = iPHP::p2num($pageurl, $page - 1 > 1 ? $page - 1 : 1);
$prev_nav = '<a href="' . $prev_url . '" class="prev" target="_self">' . iPHP::lang('iCMS:page:prev') . '</a>';
$next_url = iPHP::p2num($pageurl, $total - $page > 0 ? $page + 1 : $page);
$next_nav = '<a href="' . $next_url . '" class="next" target="_self">' . iPHP::lang('iCMS:page:next') . '</a>';
$end_nav = '<a href="' . iPHP::p2num($pageurl, $total) . '" class="end" target="_self">共' . $total . '页</a>';
$text_nav = $index_nav . $prev_nav . '<span class="current">第' . $page . '页</span>' . $next_nav . $end_nav;
$pagenav = $index_nav . $prev_nav . $num_nav . $next_nav . $end_nav;
}
$article['page'] = array('total' => $total, 'count' => $count, 'current' => $page, 'num' => $num_nav, 'text' => $text_nav, 'nav' => $pagenav, 'prev' => $prev_url, 'next' => $next_url, 'pageurl' => $pageurl, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false);
unset($index_nav, $prev_nav, $num_nav, $next_nav, $end_nav, $pagenav);
//var_dump($page,$total,$count);
if ($pic_array[0]) {
$img_array = array_unique($pic_array[0]);
foreach ($img_array as $key => $img) {
$img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
if (iCMS::$config['article']['pic_center']) {
$img_replace[$key] = '<p align="center">' . $img . '</p>';
} else {
$img_replace[$key] = $img;
}
if (iCMS::$config['article']['pic_next'] && $count > 1) {
$clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
$clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
if (iCMS::$config['article']['pic_center']) {
$img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
$img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
} else {
//.........这里部分代码省略.........
示例2: article_data
function article_data($vars)
{
$vars['aid'] or iPHP::warning('iCMS:article:data 标签出错! 缺少"aid"属性或"aid"值为空.');
$data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $vars['aid'] . "' LIMIT 1;", ARRAY_A);
if ($data['body']) {
$articleApp = iPHP::app("article");
$data['body'] = $articleApp->ubb($data['body']);
if (strpos($data['body'], '#--iCMS.Markdown--#') !== false) {
$data['body'] = iPHP::Markdown($data['body']);
}
$data['body'] = $articleApp->keywords($data['body']);
$data['body'] = $articleApp->taoke($data['body']);
}
return $data;
}