[ Index ]

PHP Cross Reference of Nucleus CMS v3.51 code documentation

title

Body

[close]

/nucleus/libs/ -> BODYACTIONS.php (source)

   1  <?php
   2  
   3  /*

   4   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)

   5   * Copyright (C) 2002-2009 The Nucleus Group

   6   *

   7   * This program is free software; you can redistribute it and/or

   8   * modify it under the terms of the GNU General Public License

   9   * as published by the Free Software Foundation; either version 2

  10   * of the License, or (at your option) any later version.

  11   * (see nucleus/documentation/index.html#license for more info)

  12   */
  13  /**

  14   * A class to parses plugin calls inside items

  15   *

  16   * @license http://nucleuscms.org/license.txt GNU General Public License

  17   * @copyright Copyright (C) 2002-2009 The Nucleus Group

  18   * @version $Id: BODYACTIONS.php 1388 2009-07-18 06:31:28Z shizuki $

  19   */
  20  
  21  class BODYACTIONS extends BaseActions {
  22  
  23      var $currentItem;
  24  
  25      var $template;
  26  
  27  	function BODYACTIONS () {
  28          $this->BaseActions();    
  29      }
  30      
  31  	function setCurrentItem(&$item) {
  32          $this->currentItem =& $item;
  33      }
  34      
  35  	function setTemplate($template) {
  36          $this->template =& $template;
  37      }
  38  
  39  	function getDefinedActions() {
  40          return array('image', 'media', 'popup', 'plugin');
  41      }
  42  
  43  	function parse_plugin($pluginName) {
  44          global $manager;
  45  
  46          // should be already tested from the parser (PARSER.php)

  47          // only continue when the plugin is really installed

  48          /*if (!$manager->pluginInstalled('NP_' . $pluginName)) {

  49              return;

  50          }*/
  51  
  52          $plugin =& $manager->getPlugin('NP_' . $pluginName);
  53          if (!$plugin) return;
  54  
  55          // get arguments

  56          $params = func_get_args();
  57  
  58          // remove plugin name

  59          array_shift($params);
  60  
  61          // add item reference (array_unshift didn't work)

  62          $params = array_merge(array(&$this->currentItem),$params);
  63  
  64          call_user_func_array(array(&$plugin,'doItemVar'), $params);
  65      }
  66      
  67  	function parse_image() {
  68          // image/popup calls have arguments separated by |

  69          $args = func_get_args();
  70          $args = explode('|',implode($args,', '));
  71          call_user_func_array(array(&$this,'createImageCode'),$args);
  72      }
  73      
  74  	function createImageCode($filename, $width, $height, $text = '') {
  75          global $CONF;
  76  
  77          // select private collection when no collection given

  78          if (!strstr($filename,'/')) {
  79              $filename = $this->currentItem->authorid . '/' . $filename;
  80          }
  81  
  82          $windowwidth = $width;
  83          $windowheight = $height;
  84  
  85          $vars['link']            = htmlspecialchars($CONF['MediaURL']. $filename ,ENT_QUOTES);
  86          $vars['text']            = htmlspecialchars($text ,ENT_QUOTES);
  87          $vars['image'] = '<img src="' . $vars['link'] . '" width="' . $width . '" height="' . $height . '" alt="' . $vars['text'] . '" title="' . $vars['text'] . '" />';
  88          $vars['width']             = $width;
  89          $vars['height']            = $height;
  90          $vars['media']             = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';
  91  
  92  
  93          echo TEMPLATE::fill($this->template['IMAGE_CODE'],$vars);;
  94  
  95      }
  96      
  97  	function parse_media() {
  98          // image/popup calls have arguments separated by |

  99          $args = func_get_args();
 100          $args = explode('|',implode($args,', '));
 101          call_user_func_array(array(&$this,'createMediaCode'),$args);
 102      }
 103  
 104  	function createMediaCode($filename, $text = '') {
 105          global $CONF;
 106  
 107          // select private collection when no collection given

 108          if (!strstr($filename,'/')) {
 109              $filename = $this->currentItem->authorid . '/' . $filename;
 110          }
 111  
 112          $vars['link']            = htmlspecialchars($CONF['MediaURL'] . $filename ,ENT_QUOTES);
 113          $vars['text']            = htmlspecialchars($text ,ENT_QUOTES);
 114          $vars['media']             = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';
 115  
 116          echo TEMPLATE::fill($this->template['MEDIA_CODE'],$vars);;
 117      }
 118  
 119  
 120  	function parse_popup() {
 121          // image/popup calls have arguments separated by |

 122          $args = func_get_args();
 123          $args = explode('|',implode($args,', '));
 124          call_user_func_array(array(&$this,'createPopupCode'),$args);
 125      }
 126  
 127  	function createPopupCode($filename, $width, $height, $text = '') {
 128          global $CONF;
 129  
 130          // select private collection when no collection given

 131          if (!strstr($filename,'/')) {
 132              $filename = $this->currentItem->authorid . '/' . $filename;
 133          }
 134  
 135          $windowwidth = $width;
 136          $windowheight = $height;
 137  
 138          $vars['rawpopuplink']     = $CONF['Self'] . "?imagepopup=" . htmlspecialchars($filename,ENT_QUOTES) . "&amp;width=$width&amp;height=$height&amp;imagetext=" . urlencode(htmlspecialchars($text));
 139          $vars['popupcode']         = "window.open(this.href,'imagepopup','status=no,toolbar=no,scrollbars=no,resizable=yes,width=$windowwidth,height=$windowheight');return false;";
 140          $vars['popuptext']         = htmlspecialchars($text,ENT_QUOTES);
 141          $vars['popuplink']         = '<a href="' . $vars['rawpopuplink']. '" onclick="'. $vars['popupcode'].'" >' . $vars['popuptext'] . '</a>';
 142          $vars['width']             = $width;
 143          $vars['height']            = $height;
 144          $vars['text']            = $text;
 145          $vars['link']            = htmlspecialchars($CONF['MediaURL'] . $filename ,ENT_QUOTES);
 146          $vars['media']             = '<a href="' . $vars['link'] . '">' . $vars['popuptext'] . '</a>';
 147  
 148          echo TEMPLATE::fill($this->template['POPUP_CODE'],$vars);
 149      }
 150  
 151  }
 152  ?>


Generated: Sun Aug 1 03:56:06 2010
Open Source related documentation for developers.