4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2007 The Nucleus Group
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)
14 * A class to parses plugin calls inside items
16 * @license http://nucleuscms.org/license.txt GNU General Public License
17 * @copyright Copyright (C) 2002-2007 The Nucleus Group
18 * @version $Id: BODYACTIONS.php,v 1.7 2008-02-08 09:31:22 kimitake Exp $
19 * @version $NucleusJP: BODYACTIONS.php,v 1.6.2.1 2007/08/08 05:27:14 kimitake Exp $
22 class BODYACTIONS extends BaseActions {
28 function BODYACTIONS () {
32 function setCurrentItem(&$item) {
33 $this->currentItem =& $item;
36 function setTemplate($template) {
37 $this->template =& $template;
40 function getDefinedActions() {
41 return array('image', 'media', 'popup', 'plugin');
44 function parse_plugin($pluginName) {
47 // only continue when the plugin is really installed
48 if (!$manager->pluginInstalled('NP_' . $pluginName)) {
52 $plugin =& $manager->getPlugin('NP_' . $pluginName);
56 $params = func_get_args();
61 // add item reference (array_unshift didn't work)
62 $params = array_merge(array(&$this->currentItem),$params);
64 call_user_func_array(array(&$plugin,'doItemVar'), $params);
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);
74 function createImageCode($filename, $width, $height, $text = '') {
77 // select private collection when no collection given
78 if (!strstr($filename,'/')) {
79 $filename = $this->currentItem->authorid . '/' . $filename;
82 $windowwidth = $width;
83 $windowheight = $height;
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>';
93 echo TEMPLATE::fill($this->template['IMAGE_CODE'],$vars);;
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);
104 function createMediaCode($filename, $text = '') {
107 // select private collection when no collection given
108 if (!strstr($filename,'/')) {
109 $filename = $this->currentItem->authorid . '/' . $filename;
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>';
116 echo TEMPLATE::fill($this->template['MEDIA_CODE'],$vars);;
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);
127 function createPopupCode($filename, $width, $height, $text = '') {
130 // select private collection when no collection given
131 if (!strstr($filename,'/')) {
132 $filename = $this->currentItem->authorid . '/' . $filename;
135 $windowwidth = $width;
136 $windowheight = $height;
138 $vars['rawpopuplink'] = $CONF['Self'] . "?imagepopup=" . htmlspecialchars($filename,ENT_QUOTES) . "&width=$width&height=$height&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>';
148 echo TEMPLATE::fill($this->template['POPUP_CODE'],$vars);