[geeklog-cvs] Geeklog-1.x/public_html lib-common.php,1.724,1.725

Michael Jervis mjervis at qs1489.pair.com
Sun Aug 17 10:16:05 EDT 2008


Update of /cvsroot/geeklog/Geeklog-1.x/public_html
In directory qs1489.pair.com:/tmp/cvs-serv3453/public_html

Modified Files:
	lib-common.php 
Log Message:
Auto detect block tempaltes for left and right and fail over to them when rendering blocks for left and right.

Index: lib-common.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/lib-common.php,v
retrieving revision 1.724
retrieving revision 1.725
diff -C2 -d -r1.724 -r1.725
*** lib-common.php	17 Aug 2008 07:39:43 -0000	1.724
--- lib-common.php	17 Aug 2008 14:16:02 -0000	1.725
***************
*** 458,461 ****
--- 458,462 ----
  * @param        string      $blockname      corresponds to name field in block table
  * @param        string      $which          can be either 'header' or 'footer' for corresponding template
+ * @param        string      $position       can be 'left', 'right' or blank. If set, will be used to find a side specific override template.
  * @see function COM_startBlock
  * @see function COM_endBlock
***************
*** 464,470 ****
  * @return   string  template name
  */
! function COM_getBlockTemplate( $blockname, $which )
  {
!     global $_BLOCK_TEMPLATE, $_COM_VERBOSE;
  
      if( $_COM_VERBOSE )
--- 465,471 ----
  * @return   string  template name
  */
! function COM_getBlockTemplate( $blockname, $which, $position='' )
  {
!     global $_BLOCK_TEMPLATE, $_COM_VERBOSE, $_CONF;
  
      if( $_COM_VERBOSE )
***************
*** 511,514 ****
--- 512,530 ----
      }
  
+     // If we have a position specific request, and the template is not already
+     // position specific then look to see if there is a position specific
+     // override.
+     $templateLC = strtolower($template);
+     if( !empty($position) && ( strpos($templateLC, $position) === false ) )
+     {
+         // Trim .thtml from the end.
+         $positionSpecific = substr($template, 0, strlen($template) - 6);
+         $positionSpecific .= '-' . $position . '.thtml';
+         if( file_exists( $_CONF['path_layout'] . $positionSpecific ) )
+         {
+             $template = $positionSpecific;
+         }
+     }
+ 
      if( $_COM_VERBOSE )
      {
***************
*** 2236,2244 ****
  * @param        string      $help       Help file to show
  * @param        string      $title      Title of Menu
  * @see function COM_adminMenu
  *
  */
  
! function COM_userMenu( $help='', $title='' )
  {
      global $_TABLES, $_USER, $_CONF, $LANG01, $LANG04, $_BLOCK_TEMPLATE;
--- 2252,2261 ----
  * @param        string      $help       Help file to show
  * @param        string      $title      Title of Menu
+ * @param        string      $position   Side being shown on 'left', 'right'. Though blank works not likely.
  * @see function COM_adminMenu
  *
  */
  
! function COM_userMenu( $help='', $title='', $position='' )
  {
      global $_TABLES, $_USER, $_CONF, $LANG01, $LANG04, $_BLOCK_TEMPLATE;
***************
*** 2276,2280 ****
  
          $retval .= COM_startBlock( $title, $help,
!                            COM_getBlockTemplate( 'user_block', 'header' ));
  
          // This function will show the user options for all installed plugins
--- 2293,2297 ----
  
          $retval .= COM_startBlock( $title, $help,
!                            COM_getBlockTemplate( 'user_block', 'header', $position ));
  
          // This function will show the user options for all installed plugins
***************
*** 2328,2337 ****
          $usermenu->set_var( 'option_url', $url );
          $retval .= $usermenu->parse( 'item', 'option' );
!         $retval .=  COM_endBlock( COM_getBlockTemplate( 'user_block', 'footer' ));
      }
      else
      {
          $retval .= COM_startBlock( $LANG01[47], $help,
!                            COM_getBlockTemplate( 'user_block', 'header' ));
          $login = new Template( $_CONF['path_layout'] );
          $login->set_file( 'form', 'loginform.thtml' );
--- 2345,2354 ----
          $usermenu->set_var( 'option_url', $url );
          $retval .= $usermenu->parse( 'item', 'option' );
!         $retval .=  COM_endBlock( COM_getBlockTemplate( 'user_block', 'footer', $position ));
      }
      else
      {
          $retval .= COM_startBlock( $LANG01[47], $help,
!                            COM_getBlockTemplate( 'user_block', 'header', $position ));
          $login = new Template( $_CONF['path_layout'] );
          $login->set_file( 'form', 'loginform.thtml' );
***************
*** 2402,2406 ****
  
          $retval .= $login->parse( 'output', 'form' );
!         $retval .= COM_endBlock( COM_getBlockTemplate( 'user_block', 'footer' ));
      }
  
--- 2419,2423 ----
  
          $retval .= $login->parse( 'output', 'form' );
!         $retval .= COM_endBlock( COM_getBlockTemplate( 'user_block', 'footer', $position ));
      }
  
***************
*** 2416,2424 ****
  * @param        string      $help       Help file to show
  * @param        string      $title      Menu Title
  * @see function COM_userMenu
  *
  */
  
! function COM_adminMenu( $help = '', $title = '' )
  {
      global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE, $LANG_PDF,
--- 2433,2442 ----
  * @param        string      $help       Help file to show
  * @param        string      $title      Menu Title
+ * @param        string      $position   Side being shown on 'left', 'right' or blank.
  * @see function COM_userMenu
  *
  */
  
! function COM_adminMenu( $help = '', $title = '', $position = '' )
  {
      global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE, $LANG_PDF,
***************
*** 2465,2469 ****
  
          $retval .= COM_startBlock( $title, $help,
!                            COM_getBlockTemplate( 'admin_block', 'header' ));
  
          $topicsql = '';
--- 2483,2487 ----
  
          $retval .= COM_startBlock( $title, $help,
!                            COM_getBlockTemplate( 'admin_block', 'header', $position ));
  
          $topicsql = '';
***************
*** 2779,2783 ****
          }
  
!         $retval .= COM_endBlock( COM_getBlockTemplate( 'admin_block', 'footer' ));
      }
  
--- 2797,2801 ----
          }
  
!         $retval .= COM_endBlock( COM_getBlockTemplate( 'admin_block', 'footer', $position ));
      }
  
***************
*** 3340,3343 ****
--- 3358,3362 ----
  * @param        string      $help       Help file location
  * @param        string      $title      Title shown in block header
+ * @param        string      $position   Side, 'left', 'right' or empty.
  * @see function COM_showBlocks
  * @return   string  HTML Formated block
***************
*** 3345,3349 ****
  */
  
! function COM_showBlock( $name, $help='', $title='' )
  {
      global $_CONF, $topic, $_TABLES, $_USER;
--- 3364,3368 ----
  */
  
! function COM_showBlock( $name, $help='', $title='', $position='' )
  {
      global $_CONF, $topic, $_TABLES, $_USER;
***************
*** 3367,3382 ****
      {
          case 'user_block':
!             $retval .= COM_userMenu( $help,$title );
              break;
  
          case 'admin_block':
!             $retval .= COM_adminMenu( $help,$title );
              break;
  
          case 'section_block':
              $retval .= COM_startBlock( $title, $help,
!                                COM_getBlockTemplate( $name, 'header' ))
                  . COM_showTopics( $topic )
!                 . COM_endBlock( COM_getBlockTemplate( $name, 'footer' ));
              break;
  
--- 3386,3401 ----
      {
          case 'user_block':
!             $retval .= COM_userMenu( $help,$title, $position );
              break;
  
          case 'admin_block':
!             $retval .= COM_adminMenu( $help,$title, $position );
              break;
  
          case 'section_block':
              $retval .= COM_startBlock( $title, $help,
!                                COM_getBlockTemplate( $name, 'header', $position ))
                  . COM_showTopics( $topic )
!                 . COM_endBlock( COM_getBlockTemplate( $name, 'footer', $position ));
              break;
  
***************
*** 3384,3388 ****
              if( !$_USER['noboxes'] )
              {
!                 $retval .= COM_whatsNewBlock( $help, $title );
              }
              break;
--- 3403,3407 ----
              if( !$_USER['noboxes'] )
              {
!                 $retval .= COM_whatsNewBlock( $help, $title, $position );
              }
              break;
***************
*** 3556,3559 ****
--- 3575,3590 ----
          }
      }
+     
+     if( array_key_exists( 'onleft', $A ) )
+     {
+         if( $A['onleft'] == 1 )
+         {
+             $position = 'left';
+         } else {
+             $position = 'right';
+         }
+     } else {
+         $position = '';
+     }
  
      if( $A['type'] == 'portal' )
***************
*** 3568,3572 ****
      if( $A['type'] == 'gldefault' )
      {
!         $retval .= COM_showBlock( $A['name'], $A['help'], $A['title'] );
      }
  
--- 3599,3603 ----
      if( $A['type'] == 'gldefault' )
      {
!         $retval .= COM_showBlock( $A['name'], $A['help'], $A['title'], $position );
      }
  
***************
*** 3583,3589 ****
              }
              $blkheader = COM_startBlock( $A['title'], $A['help'],
!                     COM_getBlockTemplate( $A['name'], 'header' ));
              $blkfooter = COM_endBlock( COM_getBlockTemplate( $A['name'],
!                     'footer' ));
  
              if( function_exists( $function ))
--- 3614,3620 ----
              }
              $blkheader = COM_startBlock( $A['title'], $A['help'],
!                     COM_getBlockTemplate( $A['name'], 'header', $position ));
              $blkfooter = COM_endBlock( COM_getBlockTemplate( $A['name'],
!                     'footer', $position ));
  
              if( function_exists( $function ))
***************
*** 3633,3639 ****
  
          $retval .= COM_startBlock( $A['title'], $A['help'],
!                        COM_getBlockTemplate( $A['name'], 'header' ))
                  . $blockcontent . LB
!                 . COM_endBlock( COM_getBlockTemplate( $A['name'], 'footer' ));
      }
  
--- 3664,3670 ----
  
          $retval .= COM_startBlock( $A['title'], $A['help'],
!                        COM_getBlockTemplate( $A['name'], 'header', $position ))
                  . $blockcontent . LB
!                 . COM_endBlock( COM_getBlockTemplate( $A['name'], 'footer', $position ));
      }
  
***************
*** 4131,4146 ****
  * Return the HTML that shows any new stories, comments, etc
  *
! * @param    string  $help   Help file for block
! * @param    string  $title  Title used in block header
  * @return   string  Return the HTML that shows any new stories, comments, etc
  *
  */
  
! function COM_whatsNewBlock( $help = '', $title = '' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_WHATSNEW, $page, $newstories;
  
      $retval = COM_startBlock( $title, $help,
!                        COM_getBlockTemplate( 'whats_new_block', 'header' ));
  
      $topicsql = '';
--- 4162,4178 ----
  * Return the HTML that shows any new stories, comments, etc
  *
! * @param    string  $help     Help file for block
! * @param    string  $title    Title used in block header
! * @param    string  $position Position in which block is being rendered 'left', 'right' or blank (for centre)
  * @return   string  Return the HTML that shows any new stories, comments, etc
  *
  */
  
! function COM_whatsNewBlock( $help = '', $title = '', $position = '' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_WHATSNEW, $page, $newstories;
  
      $retval = COM_startBlock( $title, $help,
!                        COM_getBlockTemplate( 'whats_new_block', 'header', $position ));
  
      $topicsql = '';
***************
*** 4363,4367 ****
      }
  
!     $retval .= COM_endBlock( COM_getBlockTemplate( 'whats_new_block', 'footer' ));
  
      return $retval;
--- 4395,4399 ----
      }
  
!     $retval .= COM_endBlock( COM_getBlockTemplate( 'whats_new_block', 'footer', $position ));
  
      return $retval;




More information about the geeklog-cvs mailing list