[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_module/mod_glossary/inc/ -> cnt.article.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2010 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          $content['glossary']['entry']['glossary_id']    = 'empty-glossary-id';
  90      
  91      } else {
  92      
  93          $content['glossary']['entry'] = $content['glossary']['entry'][0];
  94      
  95      }
  96          
  97      unset($GLOBALS['_getVar']['glossaryid']);
  98      unset($GLOBALS['_getVar']['glossarytitle']);
  99      $content['glossary']['base_link'] = 'index.php'.returnGlobalGET_QueryString('htmlentities');
 100  
 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_entities($content['glossary']['entry']['glossary_title']));
 104  
 105      $content['glossary']['item'] = $content['glossary']['detail_head'] . $content['glossary']['detail_entry'] . $content['glossary']['detail_footer'];
 106      $content['glossary']['item'] = str_replace('{GLOSSARY_ID}', $content['glossary']['entry']['glossary_id'], $content['glossary']['item']);
 107      $content['glossary']['item'] = str_replace('{BACKLINK}', $content['glossary']['base_link'], $content['glossary']['item']);
 108  
 109      // fine we will display given glossary ID
 110      $CNT_TMP .= $content['glossary']['item'];
 111  
 112  } else {
 113  
 114      // get list entries template sections
 115      $content['glossary']['list_head']        = get_tmpl_section('GLOSSARY_LIST_HEAD',        $content['glossary']['glossary_template']);
 116      $content['glossary']['list_footer']        = get_tmpl_section('GLOSSARY_LIST_FOOTER',        $content['glossary']['glossary_template']);
 117      $content['glossary']['list_entry']        = get_tmpl_section('GLOSSARY_LIST_ENTRY',        $content['glossary']['glossary_template']);
 118      $content['glossary']['list_spacer']        = get_tmpl_section('GLOSSARY_LIST_SPACER',        $content['glossary']['glossary_template']);
 119  
 120      // OK we build filter
 121      $content['glossary']['glossary_alphabet']        = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 122      $content['glossary']['glossary_filter']            = convertStringToArray(strtoupper($content['glossary']['glossary_filter']), ' ');
 123      $content['glossary']['glossary_filter_active']    = empty($GLOBALS['_getVar']['glossary']) ? '' : strtoupper(clean_slweg($GLOBALS['_getVar']['glossary']));
 124      
 125      if(in_array($content['glossary']['glossary_filter_active'], $content['glossary']['glossary_filter'])) {
 126              
 127              // build SQL query
 128              if(strpos($content['glossary']['glossary_filter_active'], '-')) {
 129                  $content['glossary']['filter']        = explode('-', $content['glossary']['glossary_filter_active']);
 130                  $content['glossary']['filter'][0]    = substr($content['glossary']['filter'][0], 0, 1);
 131                  $content['glossary']['filter'][1]    = empty($content['glossary']['filter'][1]) ? '?' : substr($content['glossary']['filter'][1], 0, 1);
 132                  // is there start and end
 133                  if(strpos($content['glossary']['glossary_alphabet'], $content['glossary']['filter'][0]) !== false && strpos($content['glossary']['glossary_alphabet'], $content['glossary']['filter'][1]) !== false) {
 134                      
 135                      $content['glossary']['glossary_alphabet']    = preg_split('//', $content['glossary']['glossary_alphabet'], -1, PREG_SPLIT_NO_EMPTY);
 136                      $content['glossary']['filters']                = array();
 137                      $content['glossary']['filter_run']            = false;
 138                      foreach($content['glossary']['glossary_alphabet'] as $content['glossary']['char']) {
 139                          
 140                          // OK start here
 141                          if($content['glossary']['char'] == $content['glossary']['filter'][0]) {
 142                              $content['glossary']['filter_run']    = true;
 143                          }
 144                          if($content['glossary']['filter_run']) {
 145                              //$content['glossary']['filters'][] = "TRIM(CONCAT(glossary_tag, glossary_title)) LIKE '".aporeplace($content['glossary']['char'])."%'";
 146                              $content['glossary']['filters'][] = "glossary_title LIKE '".aporeplace($content['glossary']['char'])."%'";
 147                          }
 148                          if($content['glossary']['char'] == $content['glossary']['filter'][1]) {
 149                              break;
 150                          }
 151      
 152                      }
 153                      
 154                      if(count($content['glossary']['filters'])) {
 155                      
 156                          $content['glossary']['where'] = ' AND ('.implode(' OR ', $content['glossary']['filters']).')';
 157                      
 158                      }
 159                      
 160                  }
 161                  
 162              } else {
 163              
 164                  //$content['glossary']['where'] = " AND TRIM(CONCAT(glossary_tag, glossary_title)) LIKE '".aporeplace($content['glossary']['glossary_filter_active'])."%'";
 165                  if($content['glossary']['glossary_filter_active'] != '*' && strlen($content['glossary']['glossary_filter_active']) == 1) {
 166                      $content['glossary']['where'] = " AND glossary_title LIKE '".aporeplace($content['glossary']['glossary_filter_active'])."%'";
 167                  }
 168              }
 169      }
 170  
 171      $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_glossary WHERE glossary_status=1'.$content['glossary']['where'].' ORDER BY glossary_title';
 172      
 173      $content['glossary']['entries'] = _dbQuery($sql);
 174      
 175      unset($GLOBALS['_getVar']['glossary']);
 176      $content['glossary']['base_link'] = 'index.php'.returnGlobalGET_QueryString('htmlentities');
 177      if(strpos($content['glossary']['base_link'], '?') === false) {
 178          $content['glossary']['base_link'] .= '?';
 179      } else {
 180          $content['glossary']['base_link'] .= '&amp;';
 181      }
 182  
 183      $_filter_link    = array();
 184      $_filter_c        = 0;
 185      foreach($content['glossary']['glossary_filter'] as $content['glossary']['filter_value']) {
 186          $_filter_entities = html_specialchars($content['glossary']['filter_value']);
 187          $_filter_link[$_filter_c] = '<a href="'.$content['glossary']['base_link'].'glossary='.$_filter_entities.'"';
 188          // yes - this is the active part
 189          if($content['glossary']['filter_value'] == $content['glossary']['glossary_filter_active']) {
 190              $_filter_link[$_filter_c] .= ' class="active"';
 191          }
 192          $_filter_link[$_filter_c] .= ' title="'.$_filter_entities.'">';
 193          $_filter_link[$_filter_c] .= $_filter_entities.'</a>';
 194          $_filter_c++;
 195      }
 196  
 197      $_filter_link = implode(' ', $_filter_link);
 198  
 199      
 200      $CNT_TMP .= render_cnt_template($content['glossary']['list_head'], 'FILTER', $_filter_link);
 201  
 202      if(!count($content['glossary']['entries'])) {
 203      
 204          $content['glossary']['entries'][0]['glossary_title']    = '';
 205          $content['glossary']['entries'][0]['glossary_text']        = $content['glossary']['glossary_noentry'];
 206      
 207          $_no_entry = true;
 208      
 209      } else {
 210      
 211          $_no_entry = false;
 212      
 213      }
 214  
 215      foreach($content['glossary']['entries'] as $_entry_key => $_entry_value) {
 216  
 217          $content['glossary']['entries'][$_entry_key] = str_replace('{GLOSSARY_ID}', $_entry_value['glossary_id'], $content['glossary']['list_entry']);
 218          $content['glossary']['entries'][$_entry_key] = str_replace('{LINK}', $_no_entry ? '#' : $content['glossary']['base_link'].'glossaryid='.$_entry_value['glossary_id'].'&amp;glossarytitle='.urlencode($_entry_value['glossary_title']), $content['glossary']['entries'][$_entry_key]);
 219          $content['glossary']['entries'][$_entry_key] = render_cnt_template($content['glossary']['entries'][$_entry_key], 'TITLE', html_specialchars($_entry_value['glossary_title']));
 220          
 221          if(!empty($content['glossary']['glossary_maxwords']) && !$_no_entry) {
 222              $_entry_value['glossary_text'] = getCleanSubString(strip_tags($_entry_value['glossary_text']), $content['glossary']['glossary_maxwords'], $template_default['ellipse_sign'], 'word');
 223          }
 224          $content['glossary']['entries'][$_entry_key] = render_cnt_template($content['glossary']['entries'][$_entry_key], 'TEXT', $_entry_value['glossary_text']);
 225          
 226      }
 227  
 228      $CNT_TMP .= implode($content['glossary']['list_spacer'] ,$content['glossary']['entries']);
 229      $CNT_TMP .= render_cnt_template($content['glossary']['list_footer'], 'FILTER', $_filter_link);
 230  
 231  }
 232  
 233  // render content part title/subtitle
 234  $CNT_TMP = render_cnt_template($CNT_TMP, 'CP_TITLE', html_specialchars($crow['acontent_title']));
 235  $CNT_TMP = render_cnt_template($CNT_TMP, 'CP_SUBTITLE', html_specialchars($crow['acontent_subtitle']));
 236  
 237  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7