[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_shop/inc/ -> listing.categories.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  $_entry['query']            = '';
  31  
  32  // create pagination
  33  if(isset($_GET['c'])) {
  34      $_SESSION['list_count'] = $_GET['c'] == 'all' ? '99999' : intval($_GET['c']);
  35  }
  36  if(isset($_GET['page'])) {
  37      $_SESSION['detail_page'] = intval($_GET['page']);
  38  }
  39  
  40  // set default values for paginating
  41  if(empty($_SESSION['list_count'])) {
  42      $_SESSION['list_count'] = 25;
  43  }
  44  
  45  // paginate and search form processing
  46  if(isset($_POST['do_pagination'])) {
  47  
  48      $_SESSION['list_active']    = empty($_POST['showactive']) ? 0 : 1;
  49      $_SESSION['list_inactive']    = empty($_POST['showinactive']) ? 0 : 1;
  50  
  51      $_SESSION['filter']            = clean_slweg($_POST['filter']);
  52      if(empty($_SESSION['filter'])) {
  53          unset($_SESSION['filter']);
  54      } else {
  55          $_SESSION['filter']    = convertStringToArray($_SESSION['filter'], ' ');
  56          $_POST['filter']    = $_SESSION['filter'];
  57      }
  58      
  59      $_SESSION['detail_page'] = intval($_POST['page']);
  60  
  61  }
  62  
  63  if(empty($_SESSION['detail_page'])) {
  64      $_SESSION['detail_page'] = 1;
  65  }
  66  
  67  $_entry['list_active']        = isset($_SESSION['list_active'])    ? $_SESSION['list_active']        : 1;
  68  $_entry['list_inactive']    = isset($_SESSION['list_inactive'])    ? $_SESSION['list_inactive']    : 1;
  69  
  70  
  71  // set correct status query
  72  if($_entry['list_active'] != $_entry['list_inactive']) {
  73      
  74      if(!$_entry['list_active']) {
  75          $_entry['query'] .= 'cat_status=0';
  76      }
  77      if(!$_entry['list_inactive']) {
  78          $_entry['query'] .= 'cat_status=1';
  79      }
  80      
  81  } else {
  82      $_entry['query'] .= 'cat_status!=9';
  83  }
  84  $_entry['query'] .= " AND cat_type='module_shop'";
  85  
  86  if(isset($_SESSION['filter']) && is_array($_SESSION['filter']) && count($_SESSION['filter'])) {
  87      
  88      $_entry['filter_array'] = array();
  89  
  90      foreach($_SESSION['filter'] as $_entry['filter']) {
  91          //usr_name, usr_login, usr_email
  92          $_entry['filter_array'][] = "cat_name LIKE '%".aporeplace($_entry['filter'])."%'";
  93          $_entry['filter_array'][] = "cat_info LIKE '%".aporeplace($_entry['filter'])."%'";
  94      }
  95      if(count($_entry['filter_array'])) {
  96          
  97          $_SESSION['filter'] = ' AND ('.implode(' OR ', $_entry['filter_array']).')';
  98          $_entry['query'] .= $_SESSION['filter'];
  99      
 100      }
 101  
 102  } elseif(isset($_SESSION['filter']) && is_string($_SESSION['filter'])) {
 103  
 104      $_entry['query'] .= $_SESSION['filter'];
 105  
 106  }
 107  
 108  // paginating values
 109  $_entry['count_total'] = _dbQuery('SELECT COUNT(cat_id) FROM '.DB_PREPEND.'phpwcms_categories WHERE '.$_entry['query'], 'COUNT');
 110  $_entry['pages_total'] = ceil($_entry['count_total'] / $_SESSION['list_count']);
 111  if($_SESSION['detail_page'] > $_entry['pages_total']) {
 112      $_SESSION['detail_page'] = empty($_entry['pages_total']) ? 1 : $_entry['pages_total'];
 113  }
 114  
 115  
 116  
 117  ?>
 118  <h1 class="title" style="margin-bottom:10px"><?php echo $BLM['listing_title'] ?></h1>
 119  
 120  <div class="navBarLeft imgButton chatlist">
 121      &nbsp;&nbsp;
 122      <a href="<?php echo shop_url(array('controller=cat', 'edit=0')) ?>" title="<?php echo $BLM['create_new'] ?>"><img src="img/famfamfam/tag_blue_add.gif" alt="Add" border="0" /><span><?php echo $BLM['create_new'] ?></span></a>
 123  </div>
 124  
 125  
 126  <form action="<?php echo shop_url('controller=cat') ?>" method="post" name="paginate" id="paginate"><input type="hidden" name="do_pagination" value="1" />
 127  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="paginate" summary="">
 128      <tr>
 129          <td><table border="0" cellpadding="0" cellspacing="0" summary="">
 130              <tr>
 131                  
 132                  <td><input type="checkbox" name="showactive" id="showactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_active'], 1) ?> /></td>
 133                  <td><label for="showactive"><img src="img/button/aktiv_12x13_1.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 134                  <td><input type="checkbox" name="showinactive" id="showinactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_inactive'], 1) ?> /></td>
 135                  <td><label for="showinactive"><img src="img/button/aktiv_12x13_0.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 136  
 137  <?php 
 138  if($_entry['pages_total'] > 1) {
 139  
 140      echo '<td class="chatlist">|&nbsp;</td>';
 141      echo '<td>';
 142      if($_SESSION['detail_page'] > 1) {
 143          echo '<a href="'. shop_url( array('controller=cat', 'page='.($_SESSION['detail_page']-1)) ) . '">';
 144          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" /></a>';
 145      } else {
 146          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" class="inactive" />';
 147      }
 148      echo '</td>';
 149      echo '<td><input type="text" name="page" id="page" maxlength="4" size="4" value="'.$_SESSION['detail_page'];
 150      echo '"  class="textinput" style="margin:0 3px 0 5px;width:30px;font-weight:bold;" /></td>';
 151      echo '<td class="chatlist">/'.$_entry['pages_total'].'&nbsp;</td>';
 152      echo '<td>';
 153      if($_SESSION['detail_page'] < $_entry['pages_total']) {
 154          echo '<a href="'.shop_url( array('controller=cat', 'page='.($_SESSION['detail_page']+1)) ) .'">';
 155          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" /></a>';
 156      } else {
 157          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" class="inactive" />';
 158      }
 159      echo '</td><td class="chatlist">&nbsp;|&nbsp;</td>';
 160  
 161  } else {
 162  
 163      echo '<td class="chatlist">|&nbsp;<input type="hidden" name="page" id="page" value="1" /></td>';
 164  
 165  }
 166  ?>
 167                  <td><input type="text" name="filter" id="filter" size="10" value="<?php 
 168                  
 169                  if(isset($_POST['filter']) && is_array($_POST['filter']) ) {
 170                      echo html_specialchars(implode(' ', $_POST['filter']));
 171                  }
 172                  
 173                  ?>" class="textinput" style="margin:0 2px 0 0;width:110px;text-align:left;" title="filter results by username, name or email" /></td>
 174                  <td><input type="image" name="gofilter" src="img/famfamfam/action_go.gif" style="margin-right:3px;" /></td>
 175              
 176              </tr>
 177          </table></td>
 178  
 179      <td class="chatlist" align="right">
 180          <a href="<?php echo shop_url(array('controller=cat', 'c=10')) ?>">10</a>
 181          <a href="<?php echo shop_url(array('controller=cat', 'c=25')) ?>">25</a>
 182          <a href="<?php echo shop_url(array('controller=cat', 'c=50')) ?>">50</a>
 183          <a href="<?php echo shop_url(array('controller=cat', 'c=100')) ?>">100</a>
 184          <a href="<?php echo shop_url(array('controller=cat', 'c=250')) ?>">250</a>
 185          <a href="<?php echo shop_url(array('controller=cat', 'c=all')) ?>"><?php echo $BL['be_ftptakeover_all'] ?></a>
 186      </td>
 187  
 188      </tr>
 189  </table>
 190  </form>
 191  
 192  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="" class="shop">
 193  
 194      <tr><td colspan="3" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>
 195      
 196  <?php
 197  // loop listing available newsletters
 198  $row_count = 0;
 199  
 200  $sql  = "SELECT C1.*, IFNULL(CONCAT(C2.cat_name, ' / ', C1.cat_name), C1.cat_name) AS category FROM ";
 201  $sql .= DB_PREPEND.'phpwcms_categories C1 ';
 202  $sql .= 'LEFT JOIN '.DB_PREPEND.'phpwcms_categories C2 ';
 203  $sql .= 'ON C1.cat_pid=C2.cat_id ';
 204  $sql .= 'WHERE '.str_replace('cat_', 'C1.cat_', $_entry['query']).' ';
 205  $sql .= 'ORDER BY category ASC ';
 206  $sql .= 'LIMIT '.(($_SESSION['detail_page']-1) * $_SESSION['list_count']).','.$_SESSION['list_count'];
 207  
 208  //dumpVar($sql);
 209  
 210  $data = _dbQuery($sql);
 211  
 212  $_controller_link =  shop_url('controller=cat');
 213  
 214  foreach($data as $row) {
 215  
 216      echo '<tr';
 217      if($row_count % 2) echo ' bgcolor="#F3F5F8"';
 218      if(!$row['cat_pid']) echo " onmouseover=\"Tip('" . $BL['be_admin_page_category'] . " ID: <b>" .$row["cat_id"]. "</b>');\"";
 219      echo '>'.LF;
 220      
 221      echo '<td width="25" style="padding:2px 3px 2px 4px;">';
 222      echo '<img src="img/famfamfam/tag_';
 223      echo $row['cat_pid'] ? 'orange' : 'blue';    
 224      echo '.gif" alt="'.$BLM['shop_category'].'" /></td>'.LF;
 225      
 226      echo '<td class="dir" width="88%">';
 227      echo $row['cat_pid'] ? '&nbsp;&nbsp;&nbsp;&nbsp;' : '&nbsp;';
 228      echo html_specialchars($row['cat_name'])."</td>\n";
 229  
 230  
 231      echo '<td width="10%" align="right" nowrap="nowrap" class="button_td">';
 232      
 233          echo '<a href="'.$_controller_link.'&amp;edit='.$row["cat_id"].'">';        
 234          echo '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>';
 235      
 236          echo '<a href="'.$_controller_link.'&amp;status=' . $row["cat_id"] . '-' . $row["cat_status"] .'">';
 237          echo '<img src="img/button/aktiv_12x13_'.$row["cat_status"].'.gif" border="0" alt="" /></a>';
 238      
 239          echo '<a href="'.$_controller_link.'&amp;delete='.$row["cat_id"];
 240          echo '" title="delete: '.html_specialchars($row['cat_name']).'"';
 241          echo ' onclick="return confirm(\''.$BLM['delete_entry'].js_singlequote($row['cat_name']).'\');">';
 242          echo '<img src="img/button/trash_13x13_1.gif" border="0" alt="" /></a>';
 243      
 244      echo '</td>'.LF;
 245      
 246      echo '</tr>'.LF;
 247  
 248      $row_count++;
 249  }
 250  
 251  if($row_count) {
 252      echo '<tr><td colspan="3" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>';
 253  }
 254  
 255  ?>    
 256  
 257  
 258  </table>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7