[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/ -> listcssassoc.php (source)

   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: listcssassoc.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  $name = '';
  61  
  62  #******************************************************************************
  63  # we now get the parameters
  64  #******************************************************************************
  65  
  66  # getting variables
  67  if (isset($_GET["type"])) $type    = $_GET["type"] ;
  68  else $error = lang('typenotvalid');
  69  
  70  if (isset($_GET["id"]))    $id    = $_GET["id"] ;
  71  else $error = lang('idnotvalid');
  72  
  73  # if type is template, we get the name
  74  if (isset($type) && "template" == $type) 
  75  {
  76  
  77      $query = "SELECT template_name FROM ".cms_db_prefix()."templates WHERE template_id = ?";
  78      $result = $db->Execute($query, array($id));
  79  
  80      if ($result)
  81      {
  82          $line = $result->FetchRow();
  83          $name = $line['template_name'];
  84      }
  85      else
  86      {
  87          $error = lang('errorretrievingtemplate');
  88      }
  89  }
  90  
  91  #******************************************************************************
  92  # first getting all user permissions
  93  #******************************************************************************
  94      $userid = get_userid();
  95  
  96      $modify  = check_permission($userid, 'Modify Stylesheet Assoc');
  97      $delasso = check_permission($userid, 'Remove Stylesheet Assoc');
  98      $addasso = check_permission($userid, 'Add Stylesheet Assoc');
  99  
 100      $query = "SELECT assoc_css_id, css_name FROM ".cms_db_prefix()."css_assoc ca INNER JOIN ".cms_db_prefix()."css ON assoc_css_id = css_id WHERE assoc_type=? AND assoc_to_id = ? ORDER BY ca.create_date";
 101      $result = $db->Execute($query, array($type, $id));
 102  
 103  #******************************************************************************
 104  # displaying erros if any
 105  #******************************************************************************
 106  if (isset($_GET["message"])) {
 107      $message = preg_replace('/\</','',$_GET['message']);
 108      echo '<div class="pagemcontainer"><p class="pagemessage">'.$message.'</p></div>';
 109  }
 110      if ("" != $error)
 111      {
 112          echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".$error."</p></div>";
 113      }
 114  
 115      if (!$addasso) {
 116          echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".lang('noaccessto', array(lang('addcssassociation')))."</p></div>";
 117      }
 118  
 119  #******************************************************************************
 120  # now really starting
 121  #******************************************************************************
 122  else {
 123  ?>
 124  
 125  <div class="pagecontainer">
 126      <?php echo $themeObject->ShowHeader('currentassociations'); ?>
 127          <div class="pageoverflow">
 128              <p class="pagetext"><?php echo lang('template')?> :</p>
 129                  <p class="pageinput"><?php echo '<a href="edittemplate.php?template_id='.$_GET['id'].'"  name="edittemplate">'.(isset($name)?$name:"").'</a>';?></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\">&nbsp;</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 css found for them not to appear in the dropdown
 154              $csslist[] = $one["assoc_css_id"];
 155           
 156              echo "<tr class=\"$currow\" onmouseover=\"this.className='".$currow.'hover'."';\" onmouseout=\"this.className='".$currow."';\">\n";         
 157              echo "<td><a href=\"editcss.php?css_id=".$one["assoc_css_id"]."&amp;from=templatecssassoc&amp;templateid=".$id."\">".$one["css_name"]."</a></td>\n";
 158  
 159              # if user has right to delete
 160              if ($delasso)
 161              {
 162                  echo "<td><a href=\"deletecssassoc.php?id=$id&amp;css_id=".$one["assoc_css_id"]."&amp;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>&nbsp;</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      # this var is used to store the css ids that should not appear in the
 183      # dropdown
 184      $notinto = "";
 185  
 186      foreach($csslist as $key)
 187      {
 188          $notinto .= "$key,";
 189      }
 190      $notinto = substr($notinto, 0, strlen($notinto) - 1);
 191  
 192      # this var contains the dropdown
 193      $dropdown = "";
 194      $result = '';
 195  
 196      # we generate the dropdown
 197      if ("" == $notinto)
 198      {
 199          $query = "SELECT * FROM ".cms_db_prefix()."css ORDER BY css_name";
 200      }
 201      else
 202      {
 203          $query = "SELECT * FROM ".cms_db_prefix()."css WHERE css_id NOT IN (".$notinto.") ORDER BY css_name";
 204      }
 205      $result = $db->Execute($query);
 206  
 207      if ($result && $result->RecordCount() > 0)
 208      {
 209          $form = "<form action=\"addcssassoc.php\" method=\"post\">";
 210      
 211          $dropdown = "<select name=\"css_id\">\n";
 212          while ($line = $result->FetchRow())
 213          {
 214              $dropdown .= "<option value=\"".$line["css_id"]."\">".$line["css_name"]."</option>\n";
 215          }
 216          $dropdown .= "</select>";
 217  
 218          echo $form.'<div class="pageoverflow"><p class="pageoptions">'.$dropdown.' ';
 219  ?>
 220          <input type="hidden" name="id" value="<?php echo $id?>" />
 221          <input type="hidden" name="type" value="<?php echo $type?>" />
 222          <input type="submit" value="<?php echo lang('addcss')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover';" onmouseout="this.className='pagebutton';" />
 223          </p>
 224          </div>
 225          </form>
 226  
 227  <?php
 228          } # end of showing form
 229      echo '</div>';
 230  }
 231  echo '<p class="pageback"><a class="pageback" href="'.$themeObject->BackUrl().'">&#171; '.lang('back').'</a></p>';
 232  
 233  include_once ("footer.php");
 234  
 235  # vim:ts=4 sw=4 noet
 236  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7