00001 <?php 00002 00003 /* 00004 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 00005 * Copyright (C) 2002-2007 The Nucleus Group 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * (see nucleus/documentation/index.html#license for more info) 00012 */ 00022 class BODYACTIONS extends BaseActions { 00023 00024 var $currentItem; 00025 00026 var $template; 00027 00028 function BODYACTIONS () { 00029 $this->BaseActions(); 00030 } 00031 00032 function setCurrentItem(&$item) { 00033 $this->currentItem =& $item; 00034 } 00035 00036 function setTemplate($template) { 00037 $this->template =& $template; 00038 } 00039 00040 function getDefinedActions() { 00041 return array('image', 'media', 'popup', 'plugin'); 00042 } 00043 00044 function parse_plugin($pluginName) { 00045 global $manager; 00046 00047 // only continue when the plugin is really installed 00048 if (!$manager->pluginInstalled('NP_' . $pluginName)) { 00049 return; 00050 } 00051 00052 $plugin =& $manager->getPlugin('NP_' . $pluginName); 00053 if (!$plugin) return; 00054 00055 // get arguments 00056 $params = func_get_args(); 00057 00058 // remove plugin name 00059 array_shift($params); 00060 00061 // add item reference (array_unshift didn't work) 00062 $params = array_merge(array(&$this->currentItem),$params); 00063 00064 call_user_func_array(array(&$plugin,'doItemVar'), $params); 00065 } 00066 00067 function parse_image() { 00068 // image/popup calls have arguments separated by | 00069 $args = func_get_args(); 00070 $args = explode('|',implode($args,', ')); 00071 call_user_func_array(array(&$this,'createImageCode'),$args); 00072 } 00073 00074 function createImageCode($filename, $width, $height, $text = '') { 00075 global $CONF; 00076 00077 // select private collection when no collection given 00078 if (!strstr($filename,'/')) { 00079 $filename = $this->currentItem->authorid . '/' . $filename; 00080 } 00081 00082 $windowwidth = $width; 00083 $windowheight = $height; 00084 00085 $vars['link'] = htmlspecialchars($CONF['MediaURL']. $filename ,ENT_QUOTES); 00086 $vars['text'] = htmlspecialchars($text ,ENT_QUOTES); 00087 $vars['image'] = '<img src="' . $vars['link'] . '" width="' . $width . '" height="' . $height . '" alt="' . $vars['text'] . '" title="' . $vars['text'] . '" />'; 00088 $vars['width'] = $width; 00089 $vars['height'] = $height; 00090 $vars['media'] = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>'; 00091 00092 00093 echo TEMPLATE::fill($this->template['IMAGE_CODE'],$vars);; 00094 00095 } 00096 00097 function parse_media() { 00098 // image/popup calls have arguments separated by | 00099 $args = func_get_args(); 00100 $args = explode('|',implode($args,', ')); 00101 call_user_func_array(array(&$this,'createMediaCode'),$args); 00102 } 00103 00104 function createMediaCode($filename, $text = '') { 00105 global $CONF; 00106 00107 // select private collection when no collection given 00108 if (!strstr($filename,'/')) { 00109 $filename = $this->currentItem->authorid . '/' . $filename; 00110 } 00111 00112 $vars['link'] = htmlspecialchars($CONF['MediaURL'] . $filename ,ENT_QUOTES); 00113 $vars['text'] = htmlspecialchars($text ,ENT_QUOTES); 00114 $vars['media'] = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>'; 00115 00116 echo TEMPLATE::fill($this->template['MEDIA_CODE'],$vars);; 00117 } 00118 00119 00120 function parse_popup() { 00121 // image/popup calls have arguments separated by | 00122 $args = func_get_args(); 00123 $args = explode('|',implode($args,', ')); 00124 call_user_func_array(array(&$this,'createPopupCode'),$args); 00125 } 00126 00127 function createPopupCode($filename, $width, $height, $text = '') { 00128 global $CONF; 00129 00130 // select private collection when no collection given 00131 if (!strstr($filename,'/')) { 00132 $filename = $this->currentItem->authorid . '/' . $filename; 00133 } 00134 00135 $windowwidth = $width; 00136 $windowheight = $height; 00137 00138 $vars['rawpopuplink'] = $CONF['Self'] . "?imagepopup=" . htmlspecialchars($filename,ENT_QUOTES) . "&width=$width&height=$height&imagetext=" . urlencode(htmlspecialchars($text)); 00139 $vars['popupcode'] = "window.open(this.href,'imagepopup','status=no,toolbar=no,scrollbars=no,resizable=yes,width=$windowwidth,height=$windowheight');return false;"; 00140 $vars['popuptext'] = htmlspecialchars($text,ENT_QUOTES); 00141 $vars['popuplink'] = '<a href="' . $vars['rawpopuplink']. '" onclick="'. $vars['popupcode'].'" >' . $vars['popuptext'] . '</a>'; 00142 $vars['width'] = $width; 00143 $vars['height'] = $height; 00144 $vars['text'] = $text; 00145 $vars['link'] = htmlspecialchars($CONF['MediaURL'] . $filename ,ENT_QUOTES); 00146 $vars['media'] = '<a href="' . $vars['link'] . '">' . $vars['popuptext'] . '</a>'; 00147 00148 echo TEMPLATE::fill($this->template['POPUP_CODE'],$vars); 00149 } 00150 00151 } 00152 ?>