[ Index ]

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

title

Body

[close]

/include/inc_module/mod_calendar/inc/ -> cnt.article.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  
  31  // Glossary module content part frontend article rendering
  32  
  33  // if you ant to access module vars check that var
  34  // $phpwcms['modules'][$crow["acontent_module"]]
  35  
  36  $content['glossary'] = @unserialize($crow["acontent_form"]);
  37  
  38  // check for template and load default in case of error
  39  if(empty($content['glossary']['glossary_template'])) {
  40  
  41      // load default template
  42      $content['glossary']['glossary_template'] = file_get_contents($phpwcms['modules'][$crow["acontent_module"]]['path'].'template/default/default.tmpl');
  43  
  44  } elseif(file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'].'template/'.$content['glossary']['glossary_template'])) {
  45  
  46      // load custom template
  47      $content['glossary']['glossary_template'] = file_get_contents($phpwcms['modules'][$crow["acontent_module"]]['path'].'template/'.$content['glossary']['glossary_template']);
  48  
  49  } else {
  50  
  51      // again load default template
  52      $content['glossary']['glossary_template'] = file_get_contents($phpwcms['modules'][$crow["acontent_module"]]['path'].'template/default/default.tmpl');
  53      
  54  }
  55  
  56  
  57  
  58  $content['glossary']['where'] = '';
  59  
  60  if(!empty($content['glossary']['glossary_tag'])) {
  61      $content['glossary']['glossary_tag'] = convertStringToArray($content['glossary']['glossary_tag'], ' ');
  62      foreach($content['glossary']['glossary_tag'] as $_filter_c => $content['glossary']['char']) {
  63          $content['glossary']['glossary_tag'][$_filter_c] = "glossary_tag LIKE '%".aporeplace($content['glossary']['char'])."%'";
  64      }
  65      if(count($content['glossary']['glossary_tag'])) {
  66          $content['glossary']['where'] .= ' AND ('.implode(' OR ', $content['glossary']['glossary_tag']).')';
  67      }
  68  }
  69  
  70  
  71  // and now lets check where we are - listing mode or detail view
  72  if(!empty($GLOBALS['_getVar']['glossaryid'])) {
  73  
  74      $GLOBALS['_getVar']['glossaryid'] = intval($GLOBALS['_getVar']['glossaryid']);
  75  
  76      // get detail entry template sections
  77      $content['glossary']['detail_head']        = get_tmpl_section('GLOSSARY_DETAIL_HEAD',        $content['glossary']['glossary_template']);
  78      $content['glossary']['detail_footer']    = get_tmpl_section('GLOSSARY_DETAIL_FOOTER',    $content['glossary']['glossary_template']);
  79      $content['glossary']['detail_entry']    = get_tmpl_section('GLOSSARY_DETAIL_ENTRY',        $content['glossary']['glossary_template']);
  80      
  81      $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_glossary WHERE glossary_status=1 ';
  82      $sql .= 'AND glossary_id='.$GLOBALS['_getVar']['glossaryid'];
  83      $sql .= $content['glossary']['where'];
  84      $content['glossary']['entry'] = _dbQuery($sql);
  85      if(empty($content['glossary']['entry'][0])) {
  86      
  87          $content['glossary']['entry']['glossary_title']    = '';
  88          $content['glossary']['entry']['glossary_text']    = $content['glossary']['glossary_noentry'];
  89      
  90      } else {
  91      
  92          $content['glossary']['entry'] = $content['glossary']['entry'][0];
  93      
  94      }
  95          
  96      unset($GLOBALS['_getVar']['glossaryid']);
  97      $content['glossary']['base_link'] = 'index.php'.returnGlobalGET_QueryString('htmlentities');
  98  
  99      $content['glossary']['detail_head']        = str_replace('{BACKLINK}', $content['glossary']['base_link'], $content['glossary']['detail_head']);
 100      $content['glossary']['detail_footer']    = str_replace('{BACKLINK}', $content['glossary']['base_link'], $content['glossary']['detail_footer']);
 101      $content['glossary']['detail_entry']    = get_tmpl_section('GLOSSARY_DETAIL_ENTRY',        $content['glossary']['glossary_template']);
 102      $content['glossary']['detail_entry']    = render_cnt_template($content['glossary']['detail_entry'], 'TEXT', $content['glossary']['entry']['glossary_text']);
 103      $content['glossary']['detail_entry']    = render_cnt_template($content['glossary']['detail_entry'], 'TITLE', html_specialchars($content['glossary']['entry']['glossary_title']));
 104  
 105      // fine we will display given glossary ID
 106      $CNT_TMP .= $content['glossary']['detail_head'];
 107      $CNT_TMP .= $content['glossary']['detail_entry'];
 108      $CNT_TMP .= $content['glossary']['detail_footer'];
 109  
 110  } else {
 111  
 112      // get list entries template sections
 113      $content['glossary']['list_head']        = get_tmpl_section('GLOSSARY_LIST_HEAD',        $content['glossary']['glossary_template']);
 114      $content['glossary']['list_footer']        = get_tmpl_section('GLOSSARY_LIST_FOOTER',        $content['glossary']['glossary_template']);
 115      $content['glossary']['list_entry']        = get_tmpl_section('GLOSSARY_LIST_ENTRY',        $content['glossary']['glossary_template']);
 116      $content['glossary']['list_spacer']        = get_tmpl_section('GLOSSARY_LIST_SPACER',        $content['glossary']['glossary_template']);
 117  
 118      // OK we build filter
 119      $content['glossary']['glossary_alphabet']        = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 120      $content['glossary']['glossary_filter']            = convertStringToArray(strtoupper($content['glossary']['glossary_filter']), ' ');
 121      $content['glossary']['glossary_filter_active']    = empty($GLOBALS['_getVar']['glossary']) ? '' : strtoupper(clean_slweg($GLOBALS['_getVar']['glossary']));
 122      
 123      if(in_array($content['glossary']['glossary_filter_active'], $content['glossary']['glossary_filter'])) {
 124              
 125              // build SQL query
 126              if(strpos($content['glossary']['glossary_filter_active'], '-')) {
 127                  $content['glossary']['filter']        = explode('-', $content['glossary']['glossary_filter_active']);
 128                  $content['glossary']['filter'][0]    = substr($content['glossary']['filter'][0], 0, 1);
 129                  $content['glossary']['filter'][1]    = empty($content['glossary']['filter'][1]) ? '?' : substr($content['glossary']['filter'][1], 0, 1);
 130                  // is there start and end
 131                  if(strpos($content['glossary']['glossary_alphabet'], $content['glossary']['filter'][0]) !== false && strpos($content['glossary']['glossary_alphabet'], $content['glossary']['filter'][1]) !== false) {
 132                      
 133                      $content['glossary']['glossary_alphabet']    = preg_split('//', $content['glossary']['glossary_alphabet'], -1, PREG_SPLIT_NO_EMPTY);
 134                      $content['glossary']['filters']                = array();
 135                      $content['glossary']['filter_run']            = false;
 136                      foreach($content['glossary']['glossary_alphabet'] as $content['glossary']['char']) {
 137                          
 138                          // OK start here
 139                          if($content['glossary']['char'] == $content['glossary']['filter'][0]) {
 140                              $content['glossary']['filter_run']    = true;
 141                          }
 142                          if($content['glossary']['filter_run']) {
 143                              //$content['glossary']['filters'][] = "TRIM(CONCAT(glossary_tag, glossary_title)) LIKE '".aporeplace($content['glossary']['char'])."%'";
 144                              $content['glossary']['filters'][] = "glossary_title LIKE '".aporeplace($content['glossary']['char'])."%'";
 145                          }
 146                          if($content['glossary']['char'] == $content['glossary']['filter'][1]) {
 147                              break;
 148                          }
 149      
 150                      }
 151                      
 152                      if(count($content['glossary']['filters'])) {
 153                      
 154                          $content['glossary']['where'] = ' AND ('.implode(' OR ', $content['glossary']['filters']).')';
 155                      
 156                      }
 157                      
 158                  }
 159                  
 160              } else {
 161              
 162                  //$content['glossary']['where'] = " AND TRIM(CONCAT(glossary_tag, glossary_title)) LIKE '".aporeplace($content['glossary']['glossary_filter_active'])."%'";
 163                  if($content['glossary']['glossary_filter_active'] != '*' && strlen($content['glossary']['glossary_filter_active']) == 1) {
 164                      $content['glossary']['where'] = " AND glossary_title LIKE '".aporeplace($content['glossary']['glossary_filter_active'])."%'";
 165                  }
 166              }
 167      }
 168  
 169      $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_glossary WHERE glossary_status=1'.$content['glossary']['where'].' ORDER BY glossary_title';
 170      
 171      $content['glossary']['entries'] = _dbQuery($sql);
 172      
 173      unset($GLOBALS['_getVar']['glossary']);
 174      $content['glossary']['base_link'] = 'index.php'.returnGlobalGET_QueryString('htmlentities');
 175      if(strpos($content['glossary']['base_link'], '?') === false) {
 176          $content['glossary']['base_link'] .= '?';
 177      } else {
 178          $content['glossary']['base_link'] .= '&amp;';
 179      }
 180  
 181      $_filter_link    = array();
 182      $_filter_c        = 0;
 183      foreach($content['glossary']['glossary_filter'] as $content['glossary']['filter_value']) {
 184          $_filter_entities = html_specialchars($content['glossary']['filter_value']);
 185          $_filter_link[$_filter_c] = '<a href="'.$content['glossary']['base_link'].'glossary='.$_filter_entities.'"';
 186          // yes - this is the active part
 187          if($content['glossary']['filter_value'] == $content['glossary']['glossary_filter_active']) {
 188              $_filter_link[$_filter_c] .= ' class="active"';
 189          }
 190          $_filter_link[$_filter_c] .= ' title="'.$_filter_entities.'">';
 191          $_filter_link[$_filter_c] .= $_filter_entities.'</a>';
 192          $_filter_c++;
 193      }
 194  
 195      $_filter_link = implode(' ', $_filter_link);
 196      $content['glossary']['list_head']    = render_cnt_template($content['glossary']['list_head'], 'FILTER', $_filter_link);
 197      $content['glossary']['list_footer']    = render_cnt_template($content['glossary']['list_head'], 'FILTER', $_filter_link);
 198      
 199      $CNT_TMP .= $content['glossary']['list_head'];
 200      
 201      if(!count($content['glossary']['entries'])) {
 202      
 203          $content['glossary']['entries'][0]['glossary_title']    = '';
 204          $content['glossary']['entries'][0]['glossary_text']        = $content['glossary']['glossary_noentry'];
 205      
 206          $_no_entry = true;
 207      
 208      } else {
 209      
 210          $_no_entry = false;
 211      
 212      }
 213  
 214      foreach($content['glossary']['entries'] as $_entry_key => $_entry_value) {
 215  
 216          $content['glossary']['entries'][$_entry_key] = str_replace('{LINK}', $_no_entry ? '#' : $content['glossary']['base_link'].'glossaryid='.$_entry_value['glossary_id'], $content['glossary']['list_entry']);
 217          $content['glossary']['entries'][$_entry_key] = render_cnt_template($content['glossary']['entries'][$_entry_key], 'TITLE', html_specialchars($_entry_value['glossary_title']));
 218          
 219          if(!empty($content['glossary']['glossary_maxwords']) && !$_no_entry) {
 220              $_entry_value['glossary_text'] = getCleanSubString(strip_tags($_entry_value['glossary_text']), $content['glossary']['glossary_maxwords'], $template_default['ellipse_sign'], 'word');
 221          }
 222          $content['glossary']['entries'][$_entry_key] = render_cnt_template($content['glossary']['entries'][$_entry_key], 'TEXT', $_entry_value['glossary_text']);
 223          
 224      }
 225      
 226      $CNT_TMP .= implode($content['glossary']['list_spacer'] ,$content['glossary']['entries']);
 227      $CNT_TMP .= $content['glossary']['list_footer'];
 228  
 229  }
 230  
 231  
 232  ?>


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