Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, November 12, 2026

Diff for Metafox/db.inc.php between version 1.52 and 1.53

version 1.52, 2009/02/11 16:15:24 version 1.53, 2009/06/06 22:43:14
Line 17 
Line 17 
  * http://platon.sk/projects/Metafox/   * http://platon.sk/projects/Metafox/
  */   */
   
 /* $Platon: Metafox/db.inc.php,v 1.51 2008-07-31 16:00:16 nepto Exp $ */  /* $Platon: Metafox/db.inc.php,v 1.52 2009-02-11 16:15:24 nepto Exp $ */
   
 /*  /*
  * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002   * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002
Line 306  function ezin_get_section_list_counts($l
Line 306  function ezin_get_section_list_counts($l
 /*  /*
  * ezin_get_section()   * ezin_get_section()
  */   */
 function ezin_get_section($section_id) /* {{{ */  function ezin_get_section($section_id, $article_id = null) /* {{{ */
 {  {
         global $ezin_sys;          global $ezin_sys;
         global $ezin_db_handle;          global $ezin_db_handle;
   
         $section_id = intval($section_id);          $section_id = intval($section_id);
           $article_id = intval($article_id);
   
         $query = 'SELECT'          $query = 'SELECT'
                 .' sections.id section_id,'                  .' sections.id section_id,'
Line 325  function ezin_get_section($section_id) /
Line 326  function ezin_get_section($section_id) /
                 .' sections.name section_name,'                  .' sections.name section_name,'
                 .' sections.access_key   section_access_key,'                  .' sections.access_key   section_access_key,'
                 .' sections.template_key section_template_key,'                  .' sections.template_key section_template_key,'
                 .' sections.link section_link,'                  .' sections.link section_link'
                 .' UNIX_TIMESTAMP(editorials.datetime) section_editorial_timestamp,'  
                 .' editorials.text_wordcount section_editorial_text_wordcount,'  
                 .' editorials.text_flags     section_editorial_text_flags,'  
                 .' editorials.text           section_editorial_text,'  
                 .' editorials.title          section_editorial_title'  
                 .' FROM '.$ezin_sys['db']['tables']['sections'].' AS sections'                  .' FROM '.$ezin_sys['db']['tables']['sections'].' AS sections'
                 .' LEFT JOIN '.$ezin_sys['db']['tables']['editorials'].' AS editorials'  
                 .' ON sections.id = editorials.section_id'  
                 .' AND (editorials.datetime IS NULL OR editorials.datetime <= SYSDATE())'  
                 /* XXX let this here, although global sections now use direct ID retrieving */                  /* XXX let this here, although global sections now use direct ID retrieving */
                 .' WHERE '.($section_id > 0                  .' WHERE '.($section_id > 0
                                 ? 'sections.id = '.$section_id                                  ? 'sections.id = '.$section_id
                                 : 'sections.type = "global"')                                  : 'sections.type = "global"')
                 .' ORDER BY editorials.datetime DESC LIMIT 1';                  .' ORDER BY sections.id ASC LIMIT 1';
   
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_section() [1]');                  or ezin_db_error('ezin_get_section() [1]');
Line 347  function ezin_get_section($section_id) /
Line 340  function ezin_get_section($section_id) /
                 $row = array();                  $row = array();
         @mysql_free_result($result);          @mysql_free_result($result);
   
         if (is_null($row['section_editorial_timestamp'])          if (count($row) > 0) {
                         && is_null($row['section_editorial_title'])                  $editorial = ezin_get_editorial($section_id, $article_id);
                         && is_null($row['section_editorial_text']))                  if (count($editorial) > 0) {
         {                          foreach ($editorial as $key => $val) {
                 $query = 'SELECT'                                  $row["section_$key"] = $val;
                 .' UNIX_TIMESTAMP(editorials.datetime) section_editorial_timestamp,'                          }
                 .' editorials.text_wordcount section_editorial_text_wordcount,'  
                 .' editorials.text_flags     section_editorial_text_flags,'  
                 .' editorials.text           section_editorial_text,'  
                 .' editorials.title          section_editorial_title'  
                 .' FROM '.$ezin_sys['db']['tables']['editorials'].' AS editorials,'  
                 .' '.$ezin_sys['db']['tables']['sections'].' AS sections'  
                 .' WHERE sections.id = editorials.section_id AND sections.type = "global"'  
                 .' AND (editorials.datetime IS NULL OR editorials.datetime <= SYSDATE())'  
                 .' ORDER BY editorials.datetime DESC LIMIT 1';  
   
                 $result = @mysql_query($query, $ezin_db_handle)  
                         or ezin_db_error('ezin_get_section() [2]');  
                 if (($subrow = mysql_fetch_array($result, MYSQL_ASSOC)) != false) {  
                         $row = array_merge($row, $subrow);  
                         $row['section_editorial_inherited'] = 1;  
                 }                  }
                 @mysql_free_result($result);  
         }          }
   
         return $row;          return $row;
 } /* }}} */  } /* }}} */
   
   function ezin_get_editorial($section_id = null, $article_id = null) /* {{{ */
   {
           global $ezin_sys;
           global $ezin_db_handle;
   
           $section_id = intval($section_id);
           $article_id = intval($article_id);
   
           for ($step = 1; $step <= 3; $step++) {
                   $query = null;
                   if ($step == 1 && $article_id > 0) {
                           $query = 'SELECT'
                                   .' UNIX_TIMESTAMP(editorials.datetime) editorial_timestamp,'
                                   .' editorials.text_wordcount editorial_text_wordcount,'
                                   .' editorials.text_flags     editorial_text_flags,'
                                   .' editorials.text           editorial_text,'
                                   .' editorials.title          editorial_title'
                                   .' FROM '.$ezin_sys['db']['tables']['editorials'].' AS editorials'
                                   .' WHERE article_id = '.$article_id
                                   .' AND (editorials.datetime IS NULL OR editorials.datetime <= SYSDATE())'
                                   .' ORDER BY editorials.datetime DESC LIMIT 1';
                   }
                   if ($step == 2 && $section_id > 0) {
                           $query = 'SELECT'
                                   .' UNIX_TIMESTAMP(editorials.datetime) editorial_timestamp,'
                                   .' editorials.text_wordcount editorial_text_wordcount,'
                                   .' editorials.text_flags     editorial_text_flags,'
                                   .' editorials.text           editorial_text,'
                                   .' editorials.title          editorial_title'
                                   .' FROM '.$ezin_sys['db']['tables']['editorials'].' AS editorials'
                                   .' WHERE section_id = '.$section_id
                                   .' AND (editorials.datetime IS NULL OR editorials.datetime <= SYSDATE())'
                                   .' ORDER BY editorials.datetime DESC LIMIT 1';
                   }
                   if ($step == 3) {
                           $query = 'SELECT'
                                   .' UNIX_TIMESTAMP(editorials.datetime) editorial_timestamp,'
                                   .' editorials.text_wordcount editorial_text_wordcount,'
                                   .' editorials.text_flags     editorial_text_flags,'
                                   .' editorials.text           editorial_text,'
                                   .' editorials.title          editorial_title,'
                                   .' 1                                             editorial_inherited'
                                   .' FROM '.$ezin_sys['db']['tables']['editorials'].' AS editorials,'
                                   .' '.$ezin_sys['db']['tables']['sections'].' AS sections'
                                   .' WHERE sections.id = editorials.section_id AND sections.type = "global"'
                                   .' AND (editorials.datetime IS NULL OR editorials.datetime <= SYSDATE())'
                                   .' ORDER BY editorials.datetime DESC LIMIT 1';
                   }
   
                   if (strlen($query) > 0) {
                           $row = null;
                           $result = @mysql_query($query, $ezin_db_handle)
                                   or ezin_db_error('ezin_get_editorials [1]');
                           if (($row = mysql_fetch_array($result, MYSQL_ASSOC)) != false) {
                                   $row = array_merge($row, $row);
                           }
                           @mysql_free_result($result);
                           if (is_array($row)) {
                                   return $row;
                           }
                   }
           }
           return null;
   } /* }}} */
   
 /*  /*
  * ezin_get_articles_todo()   * ezin_get_articles_todo()
  */   */

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top