[ Index ]

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

title

Body

[close]

/include/inc_front/ -> js.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  // Frontend JavaScript Wrapper
  31  
  32  // set array for possible custom html head additions
  33  $block['custom_htmlhead']    = array();
  34  
  35  // set array to hold global onLoad and onDomReady events
  36  $block['js_onunload']        = array();
  37  $block['js_ondomready']        = array();
  38  $block['js_inline']            = array();
  39  
  40  // set default JS library
  41  if(empty($block['jslib'])) {
  42      $block['jslib'] = key($phpwcms['js_lib']);
  43  }
  44  
  45  // set if Google Ajax Library should be used and if it should from which base URI
  46  define('USE_GOOGLE_AJAX_LIB', !empty($block['googleapi']) || !isset($block['googleapi']) ? 'http://ajax.googleapis.com/ajax/libs/' : FALSE);
  47  
  48  // include the related JavaScript Library wrapper
  49  @include PHPWCMS_ROOT.'/include/inc_front/lib/js.'.$block['jslib'].'.inc.php';
  50  
  51  // check if selected JavaScript should be loaded permanently
  52  if(!empty($block['jslibload'])) {
  53      initJSLib();
  54  }
  55  
  56  // check if frontend.js should be loaded always - it is  more for historic reasons
  57  if(!empty($block['frontendjs'])) {
  58      initFrontendJS();
  59  }
  60  
  61  /**
  62   * Deprecated function to initialize the Slimbox
  63   */
  64  function initializeLightbox() {
  65      initSlimbox();
  66  }
  67  
  68  /**
  69   * Init SwfObject JavaScript Library
  70   */
  71  function initSwfObject() {
  72      if(empty($GLOBALS['block']['custom_htmlhead']['swfobject.js'])) {
  73          if(!USE_GOOGLE_AJAX_LIB) {
  74              $GLOBALS['block']['custom_htmlhead']['swfobject.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/swfobject/swfobject.js');
  75          } else {
  76              $GLOBALS['block']['custom_htmlhead']['swfobject.js'] = getJavaScriptSourceLink(USE_GOOGLE_AJAX_LIB.'swfobject/2/swfobject.js');
  77          }
  78      }
  79      return TRUE;
  80  }
  81  
  82  function initFrontendJS() {
  83      $GLOBALS['block']['custom_htmlhead']['frontend.js'] = '  <script src="'.TEMPLATE_PATH.'inc_js/frontend.js" type="text/javascript"></script>';
  84  }
  85  
  86  function inlineJS($js='', $prefix='    ') {
  87      if($js) {
  88          $block['js_inline'][] = $prefix.$js;
  89      }
  90  }
  91  
  92  /**
  93   * render <!-- JS: PluginName|my.js //Whatever text -->
  94   */
  95  function renderHeadJS($js) {
  96      
  97      if(empty($js[1])) {
  98          return '';
  99      }
 100      
 101      $js = trim($js[1]);
 102      
 103      // test for .js
 104      $ext = which_ext($js);
 105      
 106      // decide it is a  plugin or qualified .js
 107      if($ext == 'js') {
 108          
 109          // replace {TEMPLATE}
 110          $js        = str_replace('{TEMPLATE}', TEMPLATE_PATH, $js);
 111          $GLOBALS['block']['custom_htmlhead'][md5($js)] = getJavaScriptSourceLink(html_specialchars($js));
 112          
 113      } else {
 114          
 115          initJSLib();
 116          
 117          if(strtolower($js) != 'initlib') {
 118  
 119              initJSPlugin($js);
 120              
 121          }
 122          
 123      }
 124      
 125      return '';
 126      
 127  }
 128  
 129  
 130  ?>


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