好!欢迎访问迷津渡口 现在时间是: 天气 °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
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
nemoutrading
 nemoutrading 约 19 小时前回复
#219
<a href="http://www.aqiwla.com/ray-ban-clubmaster-wood-sunglasses-price-sunglassesa">ray ban clubmaster wood sunglasses price</a> <a href="http://www.desksergeant.com/boston-red-sox-cap-size-premium-hatc">boston red sox cap size premium</a> <a href="http://www.notiziefree.com/ray-ban-justin-grey-gradient-polarized-young-sunglassesg">ray ban justin grey gradient polarized young</a> <a href="http://www.yesbobdylan.com/nike-dunk-high-premium-sb-red-skox">nike dunk high premium sb red</a> <a href="http://www.niffadvisory.com/gold-womens-nike-air-max-87-shoes-skoc">gold womens nike air max 87 shoes</a> <a href="http://www.dinerwaresfv.com/nike-air-max-1-menns-gr%C3%B8nn-skob">nike air max 1 menns gr酶nn</a>
nemoutrading http://www.nemoutrading.com/
rmmassage
 rmmassage 2019-04-24 20:29回复
#218
<a href="http://www.unefinemouche.com/womens-nike-dunk-red-gold-shoesl">womens nike dunk red gold</a> <a href="http://www.ayuinc.com/denver-broncos-jersey-sale-nfli">denver broncos jersey sale</a> <a href="http://www.unirlisboa.com/kvinners-nike-air-force-1-gull-r%C3%B8d-obuvk">kvinners nike air force 1 gull r酶d</a> <a href="http://www.escortfeeds.com/big-coach-bags-outlet-coachh">big coach bags outlet</a> <a href="http://www.rdjanitorial.com/nike-kwazi-blu-bianca-scarpei">nike kwazi blu bianca</a> <a href="http://www.bookoobeats.com/nike-kobe-gituttio-shorts-scarpeh">nike kobe gituttio shorts</a>
rmmassage http://www.rmmassage.com/
townyplay
 townyplay 2019-04-24 08:07回复
#217
<a href="http://www.zeraxia.com/adidas-yeezy-v2-sort-skoj">adidas yeezy v2 sort</a> <a href="http://www.turisim.com/schwarz-gum-covers-the-nike-air-force-1-low-schuheh">schwarz gum covers the nike air force 1 low</a> <a href="http://www.sybelite.com/2017-air-jordan-11-purple-velvet-shoesk">2017 air jordan 11 purple velvet</a> <a href="http://www.lemodemo.com/mini-mk-backpack-mkh">mini mk backpack</a> <a href="http://www.fskanglipu.com/adidas-zx-flux-gr%C3%A5-and-rosa-obuvi">adidas zx flux gr氓 and rosa</a> <a href="http://www.tekmenu.com/nero-friday-jordan-eclipse-scarpek">nero friday jordan eclipse</a>
townyplay http://www.townyplay.com/
vanltl
 vanltl 2019-04-23 16:46回复
#216
<a href="http://www.truthtapes.com/hommes-nike-air-force-1-jaune-vert-chaussuresh">hommes nike air force 1 jaune vert</a> <a href="http://www.veskopetrov.com/mujeres-nike-air-max-87-sb-p%C3%BArpura-negro-zapatosp">mujeres nike air max 87 sb p煤rpura negro</a> <a href="http://www.kaosmotogp.com/womens-nike-sb-stefan-janoski-max-black-yellow-shoesi">womens nike sb stefan janoski max black yellow</a> <a href="http://www.doularhythms.com/herren-nike-air-max-1-orangen-rot-schuhei">herren nike air max 1 orangen rot</a> <a href="http://www.animalpainvet.com/adidas-springblade-solyce-blanco-rojo-zapatosk">adidas springblade solyce blanco rojo</a> <a href="http://www.texarillo.com/nike-mercurial-superfly-fg-guld-sort-skoi">nike mercurial superfly fg guld sort</a>
vanltl http://www.vanltl.com/
reedrummond
 reedrummond 2019-04-22 02:38回复
#215
<a href="http://www.negamarket.net/adidas-projoator-instinct-absolion-kurpesf">adidas projoator instinct absolion</a> <a href="http://www.netdecode.net/nike-air-force-one-chili-rot-schuhea">nike air force one chili rot</a> <a href="http://www.newbridgebank.net/vibram-fivefingers-kso-gituttio-butyf">vibram fivefingers kso gituttio</a> <a href="http://www.newellfirm.net/yeezy-boost-350-laces-pirate-sort-instructions-kurpesc">yeezy boost 350 laces pirate sort instructions</a> <a href="http://www.newlawpress.net/air-max-90-ultra-essential-negro-blanco-gris-butya">air max 90 ultra essential negro blanco gris</a> <a href="http://www.newscenefiles.net/nike-air-max-2015-kvinders-bl%C3%A5-and-lyser%C3%B8d-schuheg">nike air max 2015 kvinders bl氓 and lyser酶d</a>
reedrummond http://www.reedrummond.net/
tatteredhands
 tatteredhands 2019-04-21 15:28回复
#214
<a href="http://www.alfiekaye.com/air-max-thea-lyser%C3%B8d-oxford-ct-obuvd">air max thea lyser酶d oxford ct</a> <a href="http://www.buyincar.com/air-jordan-3-schwarz-cat-mario-scarpec">air jordan 3 schwarz cat mario</a> <a href="http://www.clearvieweps.com/air-jordan-retro-2-oro-argento-kurpesb">air jordan retro 2 oro argento</a> <a href="http://www.financesmiled.com/mens-mike-person-red-jersey-limited-vapor-untouchable-nike-nfl-san-francisco-49ers-68-home-nflr">mens mike person red jersey limited vapor untouchable nike nfl san francisco 49ers 68 home</a> <a href="http://www.getwichquick.com/nike-air-max-90-rosa-bianca-grigio-butyf">nike air max 90 rosa bianca grigio</a> <a href="http://www.kareokiparty.com/real-madrid-31-ryanez-red-goalkeeper-soccer-club-jersey-nflx">real madrid 31 ryanez red goalkeeper soccer club jersey</a>
tatteredhands http://www.tatteredhands.com/
gaiaescort
 gaiaescort 2019-04-21 12:40回复
#213
<a href="http://www.delicouncil.com/a-silhouettenike-internationalist-azul-zapatosi">a silhouettenike internationalist azul</a> <a href="http://www.jeffaudette.com/adidas-sort-l%C3%B8b-sports-sko-skoh">adidas sort l酶b sports sko</a> <a href="http://www.ezappspro.com/asics-gel-lyte-iii-bianca-rosa-viola-scarpei">asics gel lyte iii bianca rosa viola</a> <a href="http://www.susannekober.com/nike-kd-trey-5-rosso-bianca-scarpej">nike kd trey 5 rosso bianca</a> <a href="http://www.kingsroomlv.com/new-york-mets-away-jersey-nflh">new york mets away jersey</a> <a href="http://www.sadecemerak.com/coach-legacy-tanner-in-signature-small-coffee-crossbody-bags-coachh">coach legacy tanner in signature small coffee crossbody bags</a>
gaiaescort http://www.gaiaescort.com/
camerasdallas
 camerasdallas 2019-04-19 20:02回复
#212
<a href="http://www.cashfordick.com/alle-sort-nike-kaishi-runs-skoh">alle sort nike kaishi runs</a> <a href="http://www.flpainfree.com/mitchell-and-ness-philadelphia-eagles-12-randall-cunningham-white-authentic-nfl-jersey-nfli">mitchell and ness philadelphia eagles 12 randall cunningham white authentic nfl jersey</a> <a href="http://www.fayjoneshome.com/adidas-tubular-svart-gr%C3%A5-obuvk">adidas tubular svart gr氓</a> <a href="http://www.lukyhammers.com/coach-red-patent-leather-wallet-coachh">coach red patent leather wallet</a> <a href="http://www.kleinconcept.com/nike-air-max-tailwind-8-maschio-blu-lagoon-scarpej">nike air max tailwind 8 maschio blu lagoon</a> <a href="http://www.simmordasa.com/nike-internationalist-w-schuhe-beige-arancia-scarpei">nike internationalist w schuhe beige arancia</a>
camerasdallas http://www.camerasdallas.com/
sinkscanyon
 sinkscanyon 2019-04-19 17:52回复
#211
<a href="http://www.estadologico.net/nike-flyknit-lunar-2.0-nero-arancia-light-bianca-scarpee">nike flyknit lunar 2.0 nero arancia light bianca</a> <a href="http://www.exploretalkingstick.net/nike-air-max-2014-kvinders-hvid-bl%C3%A5-scarpeg">nike air max 2014 kvinders hvid bl氓</a> <a href="http://www.expresswelding.net/adidas-yeezy-boost-350-bleu-noir-kurpesa">adidas yeezy boost 350 bleu noir</a> <a href="http://www.faithandprosperity.net/free-run-2-wei%C3%9F-and-grau-schuhee">free run 2 wei脽 and grau</a> <a href="http://www.fauconneriemarche.net/air-jordan-3-wei%C3%9F-cem%C3%A4nnert-kopen-kurpesb">air jordan 3 wei脽 cem盲nnert kopen</a> <a href="http://www.fernandfeather.net/nike-tiempo-legend-iv-noir-blanc-rouge-kurpesa">nike tiempo legend iv noir blanc rouge</a>
[url=http://www.sinkscanyon.net/]sinkscanyon[/url]
thecampingman
 thecampingman 2019-04-19 15:54回复
#210
<a href="http://www.seymourdugan.com/nike-kobe-12-hvit-oransje-obuvk">nike kobe 12 hvit oransje</a> <a href="http://www.dkstekstil.com/nike-air-max-90-engineered-mesh-id-shoesi">nike air max 90 engineered mesh id</a> <a href="http://www.thegillssell.com/jordan-gamma-bl%C3%A5-pris-skoj">jordan gamma bl氓 pris</a>
thecampingman http://www.thecampingman.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸