好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

emlog MVC解构24--控制器Controller之Search_Controller

Search_Controller控制器用于输出搜索文章结果列表页面,仅有一个方法:display($params)。

function display($params) {
    // 建立日志模型
    $Log_Model = new Log_Model();
    // 建立配置缓存
    $options_cache = Option::getAll();
    // 配置缓存数组键名转换成变量,键值转换为变量值
    extract($options_cache);
    
    // 获取页码,未配置则设为首页1
    $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
    // 获取搜索词,未配置则设为空
    $keyword = isset($params[1]) && $params[1] == 'keyword' ? trim($params[2]) : '';
    // 去除搜索词里面特殊编码,把特殊字符转换成HTML实体,在特殊字符添加转义反斜杠
    $keyword = addslashes(htmlspecialchars(urldecode($keyword)));
    // 替换搜索词里面的%为\%,_为\_,即加反斜杠
    $keyword = str_replace(array('%', '_'), array('\%', '\_'), $keyword);
    
    // 定义访问路径
    $pageurl = '';
    
    // 设置数据搜索条件为标题包含搜索词,从新到旧排列
    $sqlSegment = "and title like '%{$keyword}%' order by date desc";
    // 获取搜索获得的日志总数量
    $lognum = $Log_Model->getLogNum('n', $sqlSegment);
    // 获取搜索列表页面的总页数
    $total_pages = ceil($lognum / $index_lognum);
    if ($page > $total_pages) { // 页码超过总页数时
        // 页码设置为最后一页
        $page = $total_pages;
    }
    
    // 设置访问路径,搜索词编码
    $pageurl .= BLOG_URL.'?keyword='.urlencode($keyword).'&page=';
    
    // 获取搜索得到的日志数组
    $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
    // 利用工具函数获取输出列表页底部页码导航的字符串
    $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
    
    // View调用前台模板的header.php和log_list.php输出搜索结果列表
    include View::getView('header');
    include View::getView('log_list');
}


点赞0
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
jayandarmando
 jayandarmando 2019-02-16 01:02回复
#103
<a href="http://www.govolsrealtor.com/mulberry-purse-ioffer-number-mulberrye">mulberry purse ioffer number</a> <a href="http://www.djdiscgolf.com/nike-free-3.0-v2-dam%C3%A4nner-silber-trainersd">nike free 3.0 v2 dam盲nner silber</a> <a href="http://www.saraviquez.com/canada-goose-montebello-purple-canadagooser">canada goose montebello purple</a> <a href="http://www.dfweliquid.com/ralph-lauren-oblong-silk-scarf-model-scarfa">ralph lauren oblong silk scarf model</a> <a href="http://www.mrforgps.com/prada-totes-yellow-wine-pradad">prada totes yellow wine</a> <a href="http://www.nunbori.com/womens-nike-air-max-90-hyperfuse-premium-skor">womens nike air max 90 hyperfuse premium</a>
jayandarmando http://www.jayandarmando.com/
maplebeyond
 maplebeyond 2019-02-15 00:14回复
#102
<a href="http://www.atrapaniapp.com/femmes-nike-kyrie-2-blanc-jaune-chaussuresh">femmes nike kyrie 2 blanc jaune</a> <a href="http://www.maplebeyond.com/nike-kd-8-femminile-viola-rosso-scarpeq">nike kd 8 femminile viola rosso</a> <a href="http://www.collisionsix.com/mens-nike-air-max-87-sb-green-grey-shoesj">mens nike air max 87 sb green grey</a> <a href="http://www.todololitas.com/nike-kobe-vii-wolf-gr%C3%A5-skoi">nike kobe vii wolf gr氓</a> <a href="http://www.jcwjrlaw.com/nike-flyknit-lunar-3-femminile-oro-grigio-scarpel">nike flyknit lunar 3 femminile oro grigio</a> <a href="http://www.vstsblog.com/mens-asics-gel-noosa-tri-7-silver-blue-shoesj">mens asics gel noosa tri 7 silver blue</a>
maplebeyond http://www.maplebeyond.com/
lmcgroep
 lmcgroep 2019-02-14 18:27回复
#101
<a href="http://www.teamdalarna.com/femminile-air-max-90-hyperfuse-bianca-nero-scarpej">femminile air max 90 hyperfuse bianca nero</a> <a href="http://www.syairshamyoun.com/nike-air-max-90-hyperfuse-pink-purple-shoesh">nike air max 90 hyperfuse pink purple</a> <a href="http://www.fizalisfresh.com/air-jordan-retro-3-mujeres-naranja-oro-zapatosk">air jordan retro 3 mujeres naranja oro</a> <a href="http://www.fsscas.com/hombres-nike-zoom-pegasus-33-verde-azul-zapatosp">hombres nike zoom pegasus 33 verde azul</a> <a href="http://www.imagimp.com/north-face-mens-denali-fleece-hoodie-black-green-northfaceh">north face mens denali fleece hoodie black green</a> <a href="http://www.burmamaritime.com/herren-nike-air-max-lunar-1-rosa-gr%C3%BCn-schuhej">herren nike air max lunar 1 rosa gr眉n</a>
[url=http://www.lmcgroep.com/]lmcgroep[/url]
deputadowasny
 deputadowasny 2019-02-13 11:04回复
#100
<a href="http://www.salerahstore.com/mujeres-nike-flyknit-racer-oro-amarillo-chaussuresd">mujeres nike flyknit racer oro amarillo</a> <a href="http://www.schokostueck.com/jordan-1-low-og-royal-butyg">jordan 1 low og royal</a> <a href="http://www.sftfinance.com/nike-air-flight-89-noir-jaune-exercise-scarpea">nike air flight 89 noir jaune exercise</a> <a href="http://www.cherrytreetv.com/jordan-6-bright-p%C3%BArpura-schuheb">jordan 6 bright p煤rpura</a> <a href="http://www.favarte.com/nike-wmns-air-max-90-essential-hyper-rosa-butyf">nike wmns air max 90 essential hyper rosa</a> <a href="http://www.docelarsjc.com/nike-kobe-9-ni%C3%B1o-butyf">nike kobe 9 ni帽o</a>
deputadowasny http://www.deputadowasny.com/
pennywave
 pennywave 2019-02-11 11:59回复
#99
<a href="http://www.dianaandwill.com/nike-hyperdunk-2011-volt-gr%C3%B8nn-obuvc">nike hyperdunk 2011 volt gr酶nn</a> <a href="http://www.newagecharger.com/toddler-bryce-harper-jersey-nflw">toddler bryce harper jersey</a> <a href="http://www.foliekopen.com/detroit-lions-jason-hanson-jersey-nflv">detroit lions jason hanson jersey</a> <a href="http://www.milapioffret.com/air-jordan-retro-8-red-yellow-white-quilt-skog">air jordan retro 8 red yellow white quilt</a> <a href="http://www.kalraslan.com/air-jordan-1-mid-new-love-tab-skob">air jordan 1 mid new love tab</a> <a href="http://www.umuttekelbayi.com/kansas-city-royals-fitted-cap-zumba-hata">kansas city royals fitted cap zumba</a>
pennywave http://www.pennywave.com/
dinerwaresf
 dinerwaresf 2019-02-11 01:31回复
#98
<a href="http://www.intotheglos.com/nike-5.0-jaune-femmes-tennis-butyd">nike 5.0 jaune femmes tennis</a> <a href="http://www.myslinc.com/nike-zoom-pegasus-33-hombres-zapatos-negro-blanco-naranja-is-kurpesd">nike zoom pegasus 33 hombres zapatos negro blanco naranja is</a> <a href="http://www.shamankin.com/hommes-ralph-lauren-flag-polo-beige-polow">hommes ralph lauren flag polo beige</a> <a href="http://www.singingtoons.com/nike-mercurial-superfly-v-fg-football-total-grass-gr%C3%B8nn-svart-butyf">nike mercurial superfly v fg football total grass gr酶nn svart</a> <a href="http://www.snowdayrealty.com/ralph-lauren-green-polo-short-pony-big-sleeved-breathable-poloz">ralph lauren green polo short pony big sleeved breathable</a> <a href="http://www.totesoftware.com/nike-jordan-superfly-2-basketbtutti-scarpa-nero-chaussuresf">nike jordan superfly 2 basketbtutti scarpa nero</a>
dinerwaresf http://www.dinerwaresf.com/
gisusalon
 gisusalon 2019-02-10 21:23回复
#97
<a href="http://www.sugarforspice.com/chicago-cubs-new-era-mlb-authentic-collection-9-11-patch-low-profile-59fifty-cap-hath">chicago cubs new era mlb authentic collection 9 11 patch low profile 59fifty cap</a> <a href="http://www.mybancorphsa.com/nike-air-max-zero-rose-blanc-chaussuresh">nike air max zero rose blanc</a> <a href="http://www.scopatore.com/nike-free-tr-femmes-violet-rose-chaussuresj">nike free tr femmes violet rose</a> <a href="http://www.galacticlogos.com/herren-nike-roshe-run-triangle-orangen-grau-schuhej">herren nike roshe run triangle orangen grau</a> <a href="http://www.ispardmore.com/adidas-crazylight-boost-gr%C3%B8n-himmelbl%C3%A5-skok">adidas crazylight boost gr酶n himmelbl氓</a> <a href="http://www.radioramabc.com/maschio-nike-roshe-run-floreale-rosso-bianca-scarpeh">maschio nike roshe run floreale rosso bianca</a>
gisusalon http://www.gisusalon.com/
carmelscoffee
 carmelscoffee 2019-02-10 15:54回复
#96
<a href="http://www.adanastarpen.com/nike-lunar-racer-blau-schuhei">nike lunar racer blau</a> <a href="http://www.actconfident.com/nike-roshe-run-high-cielo-azul-rosado-zapatosp">nike roshe run high cielo azul rosado</a> <a href="http://www.erzurumihl.com/nike-lebron-12-guld-gr%C3%A5-skoi">nike lebron 12 guld gr氓</a> <a href="http://www.candctowingil.com/kvinners-nike-flyknit-racer-r%C3%B8d-hvit-obuvq">kvinners nike flyknit racer r酶d hvit</a> <a href="http://www.onlysidekick.com/adidas-neo-campus-red-sky-blue-shoesh">adidas neo campus red sky blue</a> <a href="http://www.rmmassage.com/nike-flyknit-racer-arancia-argento-scarpei">nike flyknit racer arancia argento</a>
carmelscoffee http://www.carmelscoffee.com/
dixiepundit
 dixiepundit 2019-02-08 16:24回复
#95
<a href="http://www.injost.com/calderon-jose-81-jersey-xl-nflg">calderon jose 81 jersey xl</a> <a href="http://www.wonjuvally.com/nike-foamposite-kvinners-runningf">nike foamposite kvinners</a> <a href="http://www.carrollgrp.com/nfl-pittsburgh-steelers-color-rush-limited-antonio-brown-mens-football-jersey-nflv">nfl pittsburgh steelers color rush limited antonio brown mens football jersey</a> <a href="http://www.nrastogi.com/nike-zoom-all-out-black-green-trainersa">nike zoom all out black green</a> <a href="http://www.annersroofing.com/maschio-vibram-fivefingers-kso-trek-blu-scarpec">maschio vibram fivefingers kso trek blu</a> <a href="http://www.orderollie.com/blanco-rosado-and-p%C3%BArpura-jordan-6s-kurpesc">blanco rosado and p煤rpura jordan 6s</a>
dixiepundit http://www.dixiepundit.com/
shahsmkj
 shahsmkj 2019-02-07 13:49回复
#94
<a href="http://www.tomscave.com/jordan-13-rouge-and-noir-chaussuresa">jordan 13 rouge and noir</a> <a href="http://www.veronicaloman.com/air-jordan-17-low-for-verkauf-dalleas-schuhee">air jordan 17 low for verkauf dalleas</a> <a href="http://www.casagranderox.com/nike-lebron-12-low-for-salg-ga-scarpea">nike lebron 12 low for salg ga</a> <a href="http://www.elitoyreviews.com/air-jordan-retro-31-noir-marron-kurpesf">air jordan retro 31 noir marron</a> <a href="http://www.grassmannword.com/nike-mens-rob-gronkowski-elite-navy-blue-home-jersey-new-england-patriots-nfl-87-drift-fashion-nflr">nike mens rob gronkowski elite navy blue home jersey new england patriots nfl 87 drift fashion</a> <a href="http://www.harryselite.com/new-blance-b%C3%B8rn-sko-guld-orange-kurpesf">new blance b酶rn sko guld orange</a>
shahsmkj http://www.shahsmkj.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸