| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:35:25 2008 ] | [ bBlog 0.7.6 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 // function.getposts.php 3 // 4 // Written by Reverend Jim <jim@revjim.net> 5 // 6 /* 7 ** bBlog Weblog http://www.bblog.com/ 8 ** Copyright (C) 2003 Eaden McKee <email@eadz.co.nz> 9 ** 10 ** This program is free software; you can redistribute it and/or modify 11 ** it under the terms of the GNU General Public License as published by 12 ** the Free Software Foundation; either version 2 of the License, or 13 ** (at your option) any later version. 14 ** 15 ** This program is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with this program; if not, write to the Free Software 22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24 function identify_function_getarchiveposts () { 25 $help = ' 26 <p>the {getarchiveposts} function is used to retrieve recent posts. It takes the following parameters:<br /> 27 <br /> 28 assign: variable to assign data to<br /> 29 archive: to get ascending sorted results<br /> 30 section: to request recent items in a section<br /> 31 year: year of posts<br /> 32 month: month of posts<br /> 33 day: day of posts<br /> 34 hour: hour of posts<br /> 35 minute: minute of posts<br /> 36 second: second of posts'; 37 38 return array ( 39 'name' =>'getarchiveposts', 40 'type' =>'function', 41 'nicename' =>'GetArchivetPosts', 42 'description' =>'Retrieves recent blog posts', 43 'authors' =>'Reverend Jim <jim@revjim.net>', 44 'licence' =>'GPL', 45 'help' => $help 46 ); 47 } 48 function smarty_function_getarchiveposts($params, &$bBlog) { 49 $ar = array(); 50 $opt = array(); 51 52 // If "assign" is not set... we'll establish a default. 53 if($params['assign'] == '') { 54 $params['assign'] = 'posts'; 55 } 56 57 // If "archive" is set, order them ASCENDING by posttime. 58 if($params['archive']) { 59 $opt['order']=" ORDER BY posttime "; 60 } 61 62 if(is_numeric($params['num'])) { 63 $opt['num'] = $params['num']; 64 } 65 66 if(is_numeric($params['year'])) { 67 if(strlen($params['year']) != 4) { 68 $bBlog->trigger_error('getarchiveposts: year parameter requires a 4 digit year'); 69 return ''; 70 } 71 $opt['year'] = $params['year']; 72 } 73 74 if(is_numeric($params['month'])) { 75 if(strlen($params['month']) != 2) { 76 $bBlog->trigger_error('getarchiveposts: month parameter requires a 2 digit month'); 77 return ''; 78 } 79 $opt['month'] = $params['month']; 80 } 81 82 if(is_numeric($params['day'])) { 83 if(strlen($params['day']) != 2) { 84 $bBlog->trigger_error('getarchiveposts: day parameter requires a 2 digit day'); 85 return ''; 86 } 87 $opt['day'] = $params['day']; 88 } 89 90 if(is_numeric($params['hour'])) { 91 if(strlen($params['hour']) != 2) { 92 $bBlog->trigger_error('getarchiveposts: hour parameter requires a 2 digit hour'); 93 return ''; 94 } 95 $opt['hour'] = $params['hour']; 96 } 97 98 if(is_numeric($params['minute'])) { 99 if(strlen($params['minute']) != 2) { 100 $bBlog->trigger_error('getarchiveposts: minute parameter requires a 2 digit minute'); 101 return ''; 102 } 103 $opt['minute'] = $params['minute']; 104 } 105 106 if(is_numeric($params['second'])) { 107 if(strlen($params['second']) != 2) { 108 $bBlog->trigger_error('getarchiveposts: second parameter requires a 2 digit second'); 109 return ''; 110 } 111 $opt['second'] = $params['second']; 112 } 113 114 if ($params['section'] != '') { 115 $opt['sectionid'] = $bBlog->sect_by_name[$params['section']]; 116 } 117 118 $q = $bBlog->make_post_query($opt); 119 120 $ar['posts'] = $bBlog->get_posts($q); 121 122 // No posts. 123 if(!is_array($ar['posts'])) { 124 return ''; 125 } 126 127 $lastmonth = ''; 128 $lastdate = ''; 129 130 foreach($ar['posts'] as $key => $value) { 131 // It seems silly to do this. Especially since, 132 // this kind of check can be done in Smarty template. 133 // Additionally, since {newday} and {newmonth} require 134 // the data to be in a variable named "post" it may not 135 // function at all. 136 // 137 // We'll leave it here for now. 138 139 if(date('Fy',$ar['posts'][$key]['posttime']) != $lastmonth) { 140 $ar['posts'][$key]['newmonth'] = 'yes'; 141 } 142 $lastmonth = date('Fy',$ar['posts'][$key]['posttime']); 143 144 if(date('Ymd',$ar['posts'][$key]['posttime']) != $lastdate) { 145 $ar['posts'][$key]['newday'] = 'yes'; 146 } 147 $lastdate = date('Ymd',$ar['posts'][$key]['posttime']); 148 } 149 150 $bBlog->assign($params['assign'],$ar['posts']); 151 152 return ''; 153 154 } 155 156 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |