[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: templatecss.php 3601 2006-12-20 21:04:54Z calguy1000 $ 20 21 /** 22 * This page is in charge with showing the CSS associated with an element, be it 23 * a template or anything else. 24 * 25 * For more informations about CSS associations please see the header of 26 * addcssassoc.php 27 * 28 * There are compulsory arguments, passed by GET 29 * - $type : the type of element 30 * - $id : the id of the element. 31 * 32 * @since 0.6 33 * @author calexico 34 */ 35 36 37 38 $CMS_ADMIN_PAGE=1; 39 40 require_once ("../include.php"); 41 42 check_login(); 43 44 include_once ("header.php"); 45 global $gCms; 46 $db =& $gCms->GetDb(); 47 48 #****************************************************************************** 49 # global vars definition 50 #****************************************************************************** 51 52 # this var is used to store any error that may occur. 53 $error = ""; 54 55 # this one is used later to store all the css found, because they won't appear in the dropdown 56 $csslist = array(); 57 58 $type = ""; 59 60 #****************************************************************************** 61 # we now get the parameters 62 #****************************************************************************** 63 64 # getting variables 65 if (isset($_GET["type"])) $type = $_GET["type"] ; 66 else $error = lang('typenotvalid'); 67 68 if (isset($_GET["id"])) $id = $_GET["id"] ; 69 else $error = lang('idnotvalid'); 70 71 # if type is template, we get the name 72 if (isset($type) && "template" == $type) 73 { 74 75 $query = "SELECT css_name FROM ".cms_db_prefix()."css WHERE css_id = ?"; 76 $result = $db->Execute($query, array($id)); 77 78 if ($result) 79 { 80 $line = $result->FetchRow(); 81 $name = $line["css_name"]; 82 } 83 else 84 { 85 $error = lang('errorretrievingtemplate'); 86 } 87 } 88 89 #****************************************************************************** 90 # first getting all user permissions 91 #****************************************************************************** 92 $userid = get_userid(); 93 94 $modify = check_permission($userid, 'Modify Stylesheet Assoc'); 95 $delasso = check_permission($userid, 'Remove Stylesheet Assoc'); 96 $addasso = check_permission($userid, 'Add Stylesheet Assoc'); 97 98 $query = "SELECT assoc_to_id, template_name FROM ".cms_db_prefix()."css_assoc, ".cms_db_prefix()."templates 99 WHERE assoc_type=? AND assoc_css_id = ? AND assoc_to_id = template_id"; 100 $result = $db->Execute($query, array($type, $id)); 101 102 #****************************************************************************** 103 # displaying erros if any 104 #****************************************************************************** 105 if (isset($_GET["message"])) { 106 $message = preg_replace('/\</','',$_GET['message']); 107 echo '<div class="pagemcontainer"><p class="pagemessage">'.$message.'</p></div>'; 108 } 109 if ("" != $error) 110 { 111 echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".$error."</p></div>"; 112 } 113 114 if (!$addasso) { 115 echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".lang('noaccessto', array(lang('addcssassociation')))."</p></div>"; 116 } 117 118 else { 119 120 #****************************************************************************** 121 # now really starting 122 #****************************************************************************** 123 ?> 124 125 <div class="pagecontainer"> 126 <?php echo $themeObject->ShowHeader('currentassociations'); ?> 127 <div class="pageoverflow"> 128 <p class="pagetext"><?php echo lang('stylesheet')?> :</p> 129 <p class="pageinput"><?php echo (isset($name)?$name:"")?></p> 130 </div> 131 132 <?php 133 134 # if any css was found. 135 if ($result && $result->RecordCount() > 0) 136 { 137 echo "<table cellspacing=\"0\" class=\"pagetable\">\n"; 138 echo '<thead>'; 139 echo "<tr>\n"; 140 echo "<th>".lang('title')."</th>\n"; 141 echo "<th class=\"pageicon\"> </th>\n"; 142 echo "</tr>\n"; 143 echo '</thead>'; 144 echo '<tbody>'; 145 146 # this var is used to show each line with different color 147 $currow = "row1"; 148 149 # now showing each line 150 while ($one = $result->FetchRow()) 151 { 152 153 # we store ids of templates found for them not to appear in the dropdown 154 $csslist[] = $one["assoc_to_id"]; 155 156 echo "<tr class=\"$currow\" onmouseover=\"this.className='".$currow.'hover'."';\" onmouseout=\"this.className='".$currow."';\">\n"; 157 echo "<td><a href=\"edittemplate.php?template_id=".$one["assoc_to_id"]."&from=cssassoc&cssid=".$id."\">".$one["template_name"]."</a></td>\n"; 158 159 # if user has right to delete 160 if ($delasso) 161 { 162 echo "<td><a href=\"deletetemplateassoc.php?id=".$id."&template_id=".$one["assoc_to_id"]."&type=$type\" onclick=\"return confirm('".lang('deleteconfirm')."');\">"; 163 echo $themeObject->DisplayImage('icons/system/delete.gif', lang('delete'),'','','systemicon'); 164 echo "</a></td>\n"; 165 } 166 else 167 { 168 echo "<td> </td>"; 169 } 170 171 echo "</tr>\n"; 172 173 ("row1" == $currow) ? $currow="row2" : $currow="row1"; 174 175 } ## foreach 176 177 echo '</tbody>'; 178 echo "</table>\n"; 179 180 } # end of if result 181 182 183 # this var is used to store the css ids that should not appear in the 184 # dropdown 185 $notinto = ""; 186 187 foreach($csslist as $key) 188 { 189 $notinto .= "$key,"; 190 } 191 $notinto = substr($notinto, 0, strlen($notinto) - 1); 192 193 # this var contains the dropdown 194 $dropdown = ""; 195 196 # we generate the dropdown 197 if ("" == $notinto) 198 { 199 $query = "SELECT * FROM ".cms_db_prefix()."templates WHERE active = 1 ORDER BY template_name"; 200 } 201 else 202 { 203 $query = "SELECT * FROM ".cms_db_prefix()."templates WHERE template_id NOT IN (".$notinto.") AND active = 1 ORDER BY template_name"; 204 } 205 $result = $db->Execute($query); 206 207 if ($result && $result->RecordCount() > 0) 208 { 209 echo "<form action=\"addtemplateassoc.php\" method=\"post\">"; 210 echo '<div class="pageoverflow"><p class="pageoptions">'; 211 echo "<select name=\"template_id\">\n"; 212 while ($line = $result->FetchRow()) 213 { 214 echo "<option value=\"".$line["template_id"]."\">".$line["template_name"]."</option>\n"; 215 } 216 echo "</select> "; 217 ?> 218 <input type="hidden" name="id" value="<?php echo $id?>" /> 219 <input type="hidden" name="type" value="<?php echo $type?>" /> 220 <input type="submit" value="<?php echo lang('attachtemplate')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover';" onmouseout="this.className='pagebutton';" /> 221 </p> 222 </div> 223 </form> 224 </div> 225 <?php 226 } # end of showing form 227 } 228 229 echo '<p class="pageback"><a class="pageback" href="'.$themeObject->BackUrl().'">« '.lang('back').'</a></p>'; 230 231 include_once ("footer.php"); 232 233 # vim:ts=4 sw=4 noet 234 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |