[ Index ]
 

Code source de CMS made simple 1.0.5

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

title

Body

[fermer]

/admin/ -> listtemplates.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: listtemplates.php 3601 2006-12-20 21:04:54Z calguy1000 $
  20  
  21  $CMS_ADMIN_PAGE=1;
  22  
  23  require_once ("../include.php");
  24  require_once ("../lib/classes/class.template.inc.php");
  25  
  26  check_login();
  27  
  28  include_once ("header.php");
  29  global $gCms;
  30  $db =& $gCms->GetDb();
  31  
  32  if (isset($_GET["message"])) {
  33      $message = preg_replace('/\</','',$_GET['message']);
  34      echo '<div class="pagemcontainer"><p class="pagemessage">'.$message.'</p></div>';
  35  }
  36  
  37  ?>
  38  
  39  <form action="multitemplate.php" method="post">
  40  <div class="pagecontainer">
  41      <div class="pageoverflow">
  42  
  43  <?php
  44  
  45      $userid    = get_userid();
  46      $add = check_permission($userid, 'Add Templates');
  47      $edit = check_permission($userid, 'Modify Templates');
  48      $all = check_permission($userid, 'Modify Any Page');
  49      $remove    = check_permission($userid, 'Remove Templates');
  50      
  51      global $gCms;
  52      $templateops =& $gCms->GetTemplateOperations();
  53  
  54      if ($all && isset($_GET["action"]) && $_GET["action"] == "setallcontent") {
  55          if (isset($_GET["template_id"])) {
  56              $query = "UPDATE ".cms_db_prefix()."content SET template_id = ?";
  57              $result = $db->Execute($query, array($_GET['template_id']));
  58              if ($result) {
  59                  $query = "UPDATE ".cms_db_prefix()."content SET modified_date = ".$db->DBTimeStamp(time());
  60                  $db->Execute($query);
  61                  echo '<p>'.lang('allpagesmodified').'</p>';
  62              } else {
  63                  echo '<p class="error">'.lang('errorupdatingpages').'</p>';
  64              }
  65          }
  66      }
  67  
  68      if (isset($_GET['setdefault']))
  69      {
  70          $templatelist = $templateops->LoadTemplates();
  71          foreach ($templatelist as $onetemplate)
  72          {
  73              if ($onetemplate->id == $_GET['setdefault'])
  74              {
  75                  $onetemplate->default = 1;
  76                  $onetemplate->active = 1;
  77                  $onetemplate->Save();
  78              }
  79              else
  80              {
  81                  $onetemplate->default = 0;
  82                  $onetemplate->Save();
  83              }
  84          }
  85      }
  86  
  87      if (isset($_GET['setactive']) || isset($_GET['setinactive']))
  88      {
  89          $theid = '';
  90          if (isset($_GET['setactive']))
  91          {
  92              $theid = $_GET['setactive'];
  93          }
  94          if (isset($_GET['setinactive']))
  95          {
  96              $theid = $_GET['setinactive'];
  97          }
  98          $thetemplate = $templateops->LoadTemplateByID($theid);
  99          if (isset($thetemplate))
 100          {
 101              if (isset($_GET['setactive']))
 102              {
 103                  $thetemplate->active = 1;
 104                  $thetemplate->Save();
 105              }
 106              if (isset($_GET['setinactive']))
 107              {
 108                  $thetemplate->active = 0;
 109                  $thetemplate->Save();
 110              }
 111          }
 112      }
 113  
 114      $templatelist = $templateops->LoadTemplates();
 115      
 116      $page = 1;
 117      if (isset($_GET['page'])) $page = $_GET['page'];
 118      $limit = 20;
 119      if (count($templatelist) > $limit)
 120      {
 121          echo "<p class=\"pageshowrows\">".pagination($page, count($templatelist), $limit)."</p>";
 122      }
 123      echo $themeObject->ShowHeader('currenttemplates').'</div>';
 124      if ($templatelist && count($templatelist) > 0) {
 125  
 126          echo '<table cellspacing="0" class="pagetable">';
 127          echo '<thead>';
 128          echo "<tr>\n";
 129          echo '<th class="pagew50">'.lang('template').'</th>';
 130          echo "<th class=\"pagepos\">".lang('default')."</th>\n";
 131          echo "<th class=\"pagepos\">".lang('active')."</th>\n";
 132          if ($edit)
 133              echo "<th class=\"pagepos\">&nbsp;</th>\n";
 134          echo "<th class=\"pageicon\">&nbsp;</th>\n";
 135          if ($add)
 136              echo "<th class=\"pageicon\">&nbsp;</th>\n";
 137          if ($remove)
 138              echo "<th class=\"pageicon\">&nbsp;</th>\n";
 139          if ($all)
 140              echo "<th class=\"pageicon\">&nbsp;</th>\n";
 141          echo "<th class=\"pageicon\">&nbsp;</th>\n";
 142  
 143          echo "</tr>\n";
 144          echo '</thead>';
 145          echo '<tbody>';
 146  
 147          $currow = "row1";
 148          $counter=0;
 149  
 150          foreach ($templatelist as $onetemplate)
 151          {
 152              // construct true/false button images
 153              $image_true = "<a href=\"listtemplates.php?setinactive=".$onetemplate->id."\">".$themeObject->DisplayImage('icons/system/true.gif', lang('setfalse'),'','','systemicon')."</a>";
 154              $image_false = "<a href=\"listtemplates.php?setactive=".$onetemplate->id."\">".$themeObject->DisplayImage('icons/system/false.gif', lang('settrue'),'','','systemicon')."</a>";
 155              $default_true =$themeObject->DisplayImage('icons/system/true.gif', lang('true'),'','','systemicon');
 156              $default_false ="<a href=\"listtemplates.php?setdefault=".$onetemplate->id."\">".$themeObject->DisplayImage('icons/system/false.gif', lang('settrue'),'','','systemicon')."</a>";
 157  
 158              if ($counter < $page*$limit && $counter >= ($page*$limit)-$limit) {
 159                    echo "<tr class=\"$currow\" onmouseover=\"this.className='".$currow.'hover'."';\" onmouseout=\"this.className='".$currow."';\">\n";
 160                  echo "<td><a href=\"edittemplate.php?template_id=".$onetemplate->id."\">".$onetemplate->name."</a></td>\n";
 161                  echo "<td class=\"pagepos\">".($onetemplate->default == 1?$default_true:$default_false)."</td>\n";
 162                  if ($onetemplate->default)
 163                      echo "<td class=\"pagepos\">".$themeObject->DisplayImage('icons/system/true.gif', lang('true'),'','','systemicon')."</td>\n";
 164                  else
 165                      echo "<td class=\"pagepos\">".($onetemplate->active == 1?$image_true:$image_false)."</td>\n";
 166  
 167                  # set template to all content
 168                  if ($all)
 169                      echo "<td class=\"pagepos\"><a href=\"listtemplates.php?action=setallcontent&amp;template_id=".$onetemplate->id."\" onclick=\"return confirm('".lang('setallcontentconfirm')."');\">".lang('setallcontent')."</a></td>\n";
 170  
 171                  # view css association
 172                  echo "<td class=\"icons_wide\"><a href=\"listcssassoc.php?type=template&amp;id=".$onetemplate->id."\">";
 173                  echo $themeObject->DisplayImage('icons/system/css.gif', lang('attachstylesheets'),'','','systemicon');
 174                  echo "</a></td>\n";
 175  
 176                  # add new template
 177                  if ($add)
 178                  {
 179                    echo "<td class=\"icons_wide\"><a href=\"copytemplate.php?template_id=".$onetemplate->id."&amp;template_name=".urlencode($onetemplate->name)."\">";
 180                      echo $themeObject->DisplayImage('icons/system/copy.gif', lang('copy'),'','','systemicon');
 181                      echo "</a></td>\n";
 182                  }
 183  
 184                  # edit template
 185                  if ($edit)
 186                  {
 187                      echo "<td class=\"icons_wide\"><a href=\"edittemplate.php?template_id=".$onetemplate->id."\">";
 188                      echo $themeObject->DisplayImage('icons/system/edit.gif', lang('edit'),'','','systemicon');
 189                      echo "</a></td>\n";
 190                  }
 191  
 192                  # remove template
 193                  if ($remove)
 194                  {
 195                      echo "<td class=\"icons_wide\">";
 196                      if ($onetemplate->default)
 197                      {
 198                          echo '&nbsp;';
 199                      }
 200                      else
 201                      {
 202                          echo "<a href=\"deletetemplate.php?template_id=".$onetemplate->id."\" onclick=\"return confirm('".lang('deleteconfirm')."');\">";
 203                          echo $themeObject->DisplayImage('icons/system/delete.gif', lang('delete'),'','','systemicon');
 204                          echo "</a>";
 205                      }
 206                      echo "</td>\n";
 207                  }
 208                  if ($onetemplate->default)
 209                      echo '<td>&nbsp;</td>';
 210                  else
 211                      echo '<td><input type="checkbox" name="multitemplate-'.$onetemplate->id.'" /></td>';
 212                  echo "</tr>\n";
 213  
 214                  ($currow=="row1"?$currow="row2":$currow="row1");
 215  
 216              }
 217              $counter++;
 218          }
 219  
 220          echo '</tbody>';
 221          echo "</table>\n";
 222  
 223      }
 224  
 225  if ($add) {
 226  ?>
 227      <div class="pageoptions">
 228          <p class="pageoptions">
 229              <span style="float: left;">
 230                  <a href="addtemplate.php">
 231                      <?php 
 232                          echo $themeObject->DisplayImage('icons/system/newobject.gif', lang('addtemplate'),'','','systemicon').'</a>';
 233                          echo ' <a class="pageoptions" href="addtemplate.php">'.lang("addtemplate");
 234                      ?>
 235                  </a>
 236              </span>
 237              <span style="margin-right: 30px; float: right; align: right">
 238                  <?php echo lang("selecteditems"); ?>: <select name="multiaction">
 239                  <option value="delete"><?php echo lang('delete') ?></option>
 240                  <option value="active"><?php echo lang('active') ?></option>
 241                  <option value="inactive"><?php echo lang('inactive') ?></option>
 242                  </select>
 243                  <input type="submit" value="<?php echo lang('submit') ?>" />
 244              </span>
 245              <br />
 246          </p>        
 247      </div>
 248  </div>
 249  </form>
 250  <p class="pageback"><a class="pageback" href="<?php echo $themeObject->BackUrl(); ?>">&#171; <?php echo lang('back')?></a></p>
 251  
 252  <?php
 253  }
 254  
 255  include_once ("footer.php");
 256  
 257  # vim:ts=4 sw=4 noet
 258  ?>


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