[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt100.article.inc.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  
  32  // Content Type List
  33  // initiated by Jérôme
  34  
  35  $CNT_TMP .= headline($crow["acontent_title"], $crow["acontent_subtitle"], $template_default["article"]);
  36  
  37  if(substr_count ($crow["acontent_text"], '~')) {
  38  
  39      //please proof that section again    
  40      //the first line will always start with an delimeter
  41      //and every linebreak \n will be converted to <br />
  42  
  43      // split into all parent <li>
  44      $crow["acontent_text"] = substr($crow["acontent_text"], 1);
  45      $crow["acontent_text"] = str_replace("\r\n~", '###', $crow["acontent_text"]);
  46      $crow["acontent_text"] = str_replace("\n~", '###', $crow["acontent_text"]);
  47      
  48      $clist_listtype = @unserialize($crow["acontent_form"]);
  49      
  50      switch($clist_listtype['list_type']) {
  51          case 1:        $clist_listmain  = 'ol'; 
  52                      $clist_listentry = 'li';
  53                      break;
  54                      
  55          case 2:        $clist_listmain  = 'dl';
  56                      $clist_listentry = 'dt';
  57                      break;
  58                      
  59          default:    $clist_listmain  = 'ul';
  60                      $clist_listentry = 'li';
  61      }
  62      
  63      
  64      $clist_list = explode('###', $crow["acontent_text"]);
  65      $clist_line = count($clist_list);
  66      
  67      if($clist_line) {
  68  
  69          // start list
  70          $crow["acontent_text"]  = '<'.$clist_listmain.'>' . LF;
  71          
  72          // now check level depth
  73          $clist_level = array();
  74          foreach($clist_list as $key => $value) {
  75              
  76              $clist_diff = 0;
  77              
  78              $clist_level[$key] = 0;
  79              
  80              while(substr($value,0,1) == '~') {
  81                  
  82                  $value = substr($value, 1);
  83                  $clist_level[$key]++;                
  84                  
  85              }
  86              $clist_list[$key] = $value;
  87              
  88          }
  89          
  90          //--------------------------------------------------------
  91      
  92          foreach($clist_list as $key => $value) {
  93          
  94          
  95              //check previous difference
  96              if(isset($clist_level[$key-1])) {
  97                  $clist_diff = $clist_level[$key] - $clist_level[$key-1];
  98              } else {
  99                  $clist_diff = $clist_level[$key];
 100              }
 101              
 102              //now create list stuff before value
 103  
 104              if($clist_diff > 0) {
 105                  for($i=0; $i < $clist_diff; $i++) {
 106                      $crow["acontent_text"] .= '<'.$clist_listmain.'>' . LF;
 107                  }
 108              }
 109              
 110              //proof if it is a <dl> and split into definition and description
 111              if($clist_listtype['list_type'] == 2) {
 112                  $value = explode('|', $value);
 113                  $value[1] = empty($value[1]) ? '' : trim($value[1]);
 114              } else {
 115                  $value = array(0 => $value, 1 => '');
 116              }
 117              
 118              $value[0] = trim($value[0]);
 119              
 120              //insert value
 121              $crow["acontent_text"] .= '<'.$clist_listentry.'>'.plaintext_htmlencode($value[0]);
 122              if($clist_listtype['list_type'] == 2 && $value[1]) {
 123                  $crow["acontent_text"] .= LF . '<dd>'.plaintext_htmlencode($value[1]).'</dd>' . LF;
 124              }
 125              
 126              //--------------------------------------------------------
 127  
 128              //check next difference
 129              
 130              if(isset($clist_level[$key+1])) {
 131                  $clist_diff_next = $clist_level[$key] - $clist_level[$key+1];
 132              } else {
 133                  $clist_diff_next = $clist_level[$key];
 134              }
 135              
 136              if($clist_diff_next == 0) {
 137                      //entry close tag
 138                      $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 139              
 140              } else {
 141              
 142                  if($clist_diff_next > 0) {
 143                      //entry close tag and list close tag
 144                      $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF . '</'.$clist_listmain.'>' . LF;
 145                      if($clist_diff_next >= 1) {
 146                          for($i=0; $i < (abs($clist_diff_next)-1); $i++) {
 147                              //entry close tag
 148                              if(!$i) $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 149                              //list close tag
 150                              $crow["acontent_text"] .= '</'.$clist_listmain.'>' . LF;
 151                          }
 152                          //entry close tag
 153                          $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 154                      }
 155                  }
 156              }
 157          }
 158          //list close tag
 159          $crow["acontent_text"] .= '</'.$clist_listmain.'>' . LF;
 160      }
 161  
 162      $CNT_TMP .= $crow["acontent_text"];
 163  
 164  } else {
 165  
 166      // show text only and do nothing else
 167      $CNT_TMP .= div_class(plaintext_htmlencode($crow["acontent_text"]), $template_default["article"]["text_class"]);
 168  
 169  }
 170  
 171                                      
 172  ?>


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