[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt100.article.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  
  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                  if(empty($value[1])) $value[1] = '';
 114              } else {
 115                  $value = array(0 => $value, 1 => '');
 116              }
 117              
 118              //insert value
 119              $crow["acontent_text"] .= '<'.$clist_listentry.'>'.nl2br(trim($value[0]));
 120              if($clist_listtype['list_type'] == 2 && $value[1]) {
 121                  $crow["acontent_text"] .= LF . '<dd>'.nl2br(trim($value[1])).'</dd>' . LF;
 122              }
 123              
 124              //--------------------------------------------------------
 125  
 126              //check next difference
 127              
 128              if(isset($clist_level[$key+1])) {
 129                  $clist_diff_next = $clist_level[$key] - $clist_level[$key+1];
 130              } else {
 131                  $clist_diff_next = $clist_level[$key];
 132              }
 133              
 134              if($clist_diff_next == 0) {
 135                      //entry close tag
 136                      $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 137              
 138              } else {
 139              
 140                  if($clist_diff_next > 0) {
 141                      //entry close tag and list close tag
 142                      $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF . '</'.$clist_listmain.'>' . LF;
 143                      if($clist_diff_next > 1) {
 144                          for($i=0; $i < (abs($clist_diff_next)-1); $i++) {
 145                              //entry close tag
 146                              if(!$i) $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 147                              //list close tag
 148                              $crow["acontent_text"] .= '</'.$clist_listmain.'>' . LF;
 149                          }
 150                          //entry close tag
 151                          $crow["acontent_text"] .= '</'.$clist_listentry.'>' . LF;
 152                      }
 153                  }
 154              }
 155          }
 156          //list close tag
 157          $crow["acontent_text"] .= '</'.$clist_listmain.'>' . LF;
 158      }
 159  
 160      $CNT_TMP .= $crow["acontent_text"];
 161  
 162  } else {
 163  
 164      // show text only and do nothing else
 165      $CNT_TMP .= nl2br(div_class($crow["acontent_text"], $template_default["article"]["text_class"]));
 166  
 167  }
 168  
 169                                      
 170  ?>


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