PageCookery收藏系统的开发

最近把Asaph搭建的收藏夹也整合到了微博里,减少登陆次数,更方便自己跟自己玩。
记下来备忘一下:

首先是index.php里加一套fav的模版,并判断登陆状态:

  1. case 'fav':
  2.         if ($is_guest)
  3.         {
  4.             show_login();
  5.         }
  6.         else
  7.             {
  8.                 $template =& new Template('fav', NULL, 'fav');
  9.             }
  10. break;

编写fav.html模版文件,搞一个抓取当前页面url的框框:

  1. {template header}
  2. <?php
  3. $title = $_GET['title'];
  4. $url = $_GET['url'];
  5. ?>
  6. <form action="?act=save" method="post" enctype="multipart/form-data" id="entry_post">
  7. <h2 class="write_nickname"><echo>get_username_by_id($User['id'])</echo></h2>               
  8. <select name="prefix" class="write_prefix" id="prefix">
  9. <option value="33" class="shares">收藏</option>
  10. <option value="18" class="shares">分享</option>
  11. </select>
  12. <input type="text" name="message" class="text" value="<?php echo $title; ?> - <a href='http://uicss.cn/go.php?<?php echo $url; ?>' rel='nofollow'>url</a>" /> <a onclick="$('#entry_post').submit();" class="btn_update">提交</a>
  13. </form>

书签的js:

  1. javascript:(function(){var d=document;var l=location;var t=d.title;var u=l.toString();var s=d.createElement('script');var b='http://uicss.cn/talk/';var c='2';var n=b+'?act=fav'+'&title='+encodeURIComponent(t)+ '&url='+encodeURIComponent(u);window.open(n);})();

演示效果:

最后修正一下过长的目录url:http://uicss.cn/talk/?act=prefix_blog&pid=33
首选方案是rewrite,但重启服务器不方便,
索性直接搞了个fav.php,读数据库中pid是33的收藏分类下内容并修改分页:

  1. $entry = $SQL->RunQuery("SELECT * FROM entry WHERE prefix = 33 ORDER BY time DESC LIMIT " . Pages::GetQueryLimit(intval($_GET['page']), $entry_limit));
  2. $pages_total = $SQL->QueryRowsArray("SELECT COUNT(id) AS count FROM entry WHERE prefix = 33");
  3. $pages = Pages::DrawPages($pages_total['count'], 20, '?act=prefix_blog&pid=33', array('page' => intval($_GET['page'])));
崔凯博客
Powered by WordPress | Theme by ck web design | TOP 顶部
Copyright © 崔凯 All rights reserved. 蜀ICP备12025891号.