| [ Index ] |
krapohl.info |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * $Id: function.pc_filter.php,v 1.2 2004/02/11 19:12:44 larsneo Exp $ 4 * 5 * PostCalendar::PostNuke Events Calendar Module 6 * Copyright (C) 2002 The PostCalendar Team 7 * http://postcalendar.tv 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 * To read the license please read the docs/license.txt or visit 24 * http://www.gnu.org/copyleft/gpl.html 25 * 26 */ 27 function smarty_function_pc_filter($args, &$smarty) 28 { 29 extract($args); unset($args); 30 31 if(empty($type)) { 32 $smarty->trigger_error("pc_filter: missing 'type' parameter"); 33 return; 34 } 35 36 $Date = postcalendar_getDate(); 37 if(!isset($y)) $y = substr($Date,0,4); 38 if(!isset($m)) $m = substr($Date,4,2); 39 if(!isset($d)) $d = substr($Date,6,2); 40 41 $tplview = pnVarCleanFromInput('tplview'); 42 $viewtype = pnVarCleanFromInput('viewtype'); 43 $pc_username = pnVarCleanFromInput('pc_username'); 44 45 if(!isset($viewtype)) { $viewtype = _SETTING_DEFAULT_VIEW; } 46 47 $types = explode(',',$type); 48 $output =& new pnHTML(); 49 $output->SetOutputMode(_PNH_RETURNOUTPUT); 50 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); 51 $mdir = pnVarPrepForOS($modinfo['directory']); 52 unset($modinfo); 53 $pcTemplate = pnVarPrepForOS(_SETTING_TEMPLATE); 54 if(empty($pcTemplate)) { $pcTemplate = 'default'; } 55 56 list($dbconn) = pnDBGetConn(); 57 $pntable = pnDBGetTables(); 58 //================================================================ 59 // build the username filter pulldown 60 //================================================================ 61 if(in_array('user',$types)) { 62 @define('_PC_FORM_USERNAME',true); 63 $sql = "SELECT DISTINCT pc_informant 64 FROM $pntable[postcalendar_events] 65 ORDER BY pc_informant"; 66 67 $result = $dbconn->Execute($sql); 68 if($result !== false) { 69 $useroptions = "<select name=\"pc_username\" class=\"$class\">"; 70 $useroptions .= "<option value=\"\" class=\"$class\">"._PC_FILTER_USERS."</option>"; 71 $selected = $pc_username == '__PC_ALL__' ? 'selected="selected"' : ''; 72 $useroptions .= "<option value=\"__PC_ALL__\" class=\"$class\" $selected>"._PC_FILTER_USERS_ALL."</option>"; 73 for(;!$result->EOF;$result->MoveNext()) { 74 $sel = $pc_username == $result->fields[0] ? 'selected="selected"' : ''; 75 $useroptions .= "<option value=\"".$result->fields[0]."\" $sel class=\"$class\">".$result->fields[0]."</option>"; 76 } 77 $useroptions .= '</select>'; 78 $result->Close(); 79 } 80 } 81 //================================================================ 82 // build the category filter pulldown 83 //================================================================ 84 if(in_array('category',$types)) { 85 @define('_PC_FORM_CATEGORY',true); 86 $category = pnVarCleanFromInput('pc_category'); 87 $categories = pnModAPIFunc(__POSTCALENDAR__,'user','getCategories'); 88 $catoptions = "<select name=\"pc_category\" class=\"$class\">"; 89 $catoptions .= "<option value=\"\" class=\"$class\">"._PC_FILTER_CATEGORY."</option>"; 90 foreach($categories as $c) { 91 $sel = $category == $c['id'] ? 'selected="selected"' : ''; 92 $catoptions .= "<option value=\"$c[id]\" $sel class=\"$class\">$c[name]</option>"; 93 } 94 $catoptions .= '</select>'; 95 } 96 //================================================================ 97 // build the topic filter pulldown 98 //================================================================ 99 if(in_array('topic',$types) && _SETTING_DISPLAY_TOPICS) { 100 @define('_PC_FORM_TOPIC',true); 101 $topic = pnVarCleanFromInput('pc_topic'); 102 $topics = pnModAPIFunc(__POSTCALENDAR__,'user','getTopics'); 103 $topoptions = "<select name=\"pc_topic\" class=\"$class\">"; 104 $topoptions .= "<option value=\"\" class=\"$class\">"._PC_FILTER_TOPIC."</option>"; 105 foreach($topics as $t) { 106 if ($t['id'] != "") { 107 $sel = $topic == $t['id'] ? 'selected="selected"' : ''; 108 $topoptions .= "<option value=\"$t[id]\" $sel class=\"$class\">$t[text]</option>"; 109 } 110 } 111 $topoptions .= '</select>'; 112 } else { 113 $topoptions = ''; 114 } 115 116 //================================================================ 117 // build it in the correct order 118 //================================================================ 119 if(!isset($label)) { $label = _PC_TPL_VIEW_SUBMIT; } 120 $submit = "<input type=\"submit\" name=\"submit\" value=\"$label\" class=\"$class\" />"; 121 $orderArray = array('user'=>$useroptions, 'category'=>$catoptions, 'topic'=>$topoptions, 'jump'=>$submit); 122 123 if(isset($order)) { 124 $newOrder = array(); 125 $order = explode(',',$order); 126 foreach($order as $tmp_order) { 127 array_push($newOrder,$orderArray[$tmp_order]); 128 } 129 foreach($orderArray as $key=>$old_order) { 130 if(!in_array($key,$newOrder)) { 131 array_push($newOrder,$orderArray[$old_order]); 132 } 133 } 134 $order = $newOrder; 135 } else { 136 $order = $orderArray; 137 } 138 139 foreach($order as $element) { 140 echo $element; 141 } 142 if(!in_array('user',$types)) { 143 echo $output->FormHidden('pc_username',$pc_username); 144 } 145 } 146 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 16 22:40:07 2005 | Cross-referenced by PHPXref 0.6 |