* @param The Label for the list (will be used as list heading!) * @param The core module name (e.g. "product") * @param The page name (e.g. "product_list" ) * @param Additional varaibles to include as hidden input fields */ function writeSearchHeader( $title, $image="", $modulename, $pagename) { global $sess, $keyword, $VM_LANG; if( !empty( $keyword )) { $keyword = urldecode( $keyword ); } else { $keyword = ""; } $search_date = vmGet( $_REQUEST, 'search_date', null); $show = vmGet( $_REQUEST, "show", "" ); $header = ''; $header .= '
'; if( defined( "_VM_IS_BACKEND") || @$_REQUEST['pshop_mode'] == "admin" ) { $header .= "\n"; } if(( $title != "" ) || !empty( $pagename )) { $header .= ''; if( $title != "" ) { $style = ($image != '') ? 'style="background:url('.$image.') no-repeat;text-indent: 30px;line-height: 50px;"' : ''; $header .= ''."\n"; $GLOBALS['vm_mainframe']->setPageTitle( $title ); } if( !empty( $pagename )) $header .= ''; $header .= "\n

'.$title.'


\n"; } if ( !empty($search_date) ) // Changed search by date $header .= ''; if( !empty($show) ) { $header .= "\n"; } echo $header; } /** * This creates a list footer (page navigation) * @param The core module name (e.g. "product") * @param The page name (e.g. "product_list" ) * @param The Keyword from a search by keyword * @param Additional varaibles to include as hidden input fields */ function writeFooter($keyword, $extra="") { $footer= ""; if( $this->pageNav !== null ) { if( $this->_resultsToShowPageNav <= $this->pageNav->total ) { $footer = $this->pageNav->getListFooter(); } } else { $footer = ""; } if(!empty( $extra )) { $extrafields = explode("&", $extra); array_shift($extrafields); foreach( $extrafields as $key => $value) { $field = explode("=", $value); $footer .= ''."\n"; } } $footer .= '
'; echo $footer; } } /** * This is the class for creating regular forms used in VirtueMart * * Usage: * //First create the object and let it print a form heading * $formObj = &new formFactory( "My Form" ); * //Then Start the form * $formObj->startForm(); * // Add necessary hidden fields * $formObj->hiddenField( 'country_id', $country_id ); * * // Write your form with mixed tags and text fields * // and finally close the form: * $formObj->finishForm( $funcname, $modulename.'.country_list' ); * * @package virtuemart * @subpackage Core * @author soeren */ class formFactory { /** * Constructor * Prints the Form Heading if provided */ function formFactory( $title = '' ) { if( $title != "" ) { echo '

'.$title."

\n"; $GLOBALS['vm_mainframe']->setPageTitle( $title ); } } /** * Writes the form start tag */ function startForm( $formname = 'adminForm', $extra = "" ) { $action = (!defined('_VM_IS_BACKEND' ) && !empty($_REQUEST['next_page'])) ? 'index.php' : $_SERVER['PHP_SELF']; echo '
'; } function hiddenField( $name, $value ) { echo ' '; } /** * Writes necessary hidden input fields * and closes the form */ function finishForm( $func, $page='' ) { $no_menu = vmRequest::getInt('no_menu'); $html = ' '; if( $no_menu ) { $html .= ''; } else { $html .= ''; } $html .= ''; $html .= ''; $html .= ''; if( defined( "_VM_IS_BACKEND") || @$_REQUEST['pshop_mode'] == "admin" ) { $html .= ''; } $html .= '
'; echo $html; } } /** * Tab Creation handler * @package VirtueMart * @subpackage core * @author soeren * Modified to use Panel-in-Panel functionality */ class vmTabPanel { /** @var int Use cookies */ var $useCookies = 0; /** @var string Panel ID */ var $panel_id; var $tabs; /** * Constructor * Includes files needed for displaying tabs and sets cookie options * @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes * @param int show_js, if set to 1 the Javascript Link and Stylesheet will not be printed */ function vmTabPanel($useCookies, $show_js, $panel_id) { vmCommonHTML::loadExtjs(); $this->useCookies = $useCookies; $this->panel_id = $panel_id; $this->tabs = array(); } /** * creates a tab pane and creates JS obj * @param string The Tab Pane Name */ function startPane($id) { echo '
'; $this->pane_id = $id; } /** * Ends Tab Pane */ function endPane() { echo "
"; $scripttag = " Ext.onReady( function() { Ext.QuickTips.init(); var state = Ext.state.Manager; var tabs_{$this->panel_id} = new Ext.TabPanel({ renderTo: '{$this->pane_id}', activeTab: 0, deferredRender: false, enableTabScroll: true, autoScroll: true, autoWidth: true, items: ["; $num = 0; $numTabs = count( $this->tabs ); foreach ( $this->tabs as $id => $title ) { $scripttag .= "{ autoHeight: true, contentEl: '$id', title: '".addslashes($title)."' , tabTip: '".addslashes(strip_tags($title))."' }"; $num++; if( $num < $numTabs ) { $scripttag .= ",\n"; } } $scripttag .= "] });"; reset($this->tabs); if( $this->useCookies ) { $scripttag .= "tabs_{$this->panel_id}.activate(state.get('{$this->panel_id}-active', '".key($this->tabs)."'));"; } else { $scripttag .= "tabs_{$this->panel_id}.activate( '".key($this->tabs)."'); "; } if( $this->useCookies ) { $scripttag .= " Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); tabs_{$this->panel_id}.on('tabchange', function(tp, tab){ state.set('{$this->panel_id}-active', tab.id); }); "; } $scripttag .= "});"; echo vmCommonHTML::scriptTag('', $scripttag ); } /* * Creates a tab with title text and starts that tabs page * @param tabText - This is what is displayed on the tab * @param paneid - This is the parent pane to build this tab on */ function startTab( $tabText, $paneid ) { echo "
"; $this->tabs[$paneid] = $tabText; } /* * Ends a tab page */ function endTab() { echo "
"; } } class mShopTabs extends vmTabPanel { } class vmMooAjax { /** * This is used to print out Javascript code for the moo.ajax script * * @param string $url * @param string $updateId * @param string $onComplete A JS function name to be called after the HTTP transport has been finished * @param array VM_COMPONENT_NAMEs * @param string $varName The name of a variable the ajax object is assigned to */ function writeAjaxUpdater( $url, $updateId, $onComplete, $method='post', $vmDirs=array(), $varName='' ) { echo vmMooAjax::getAjaxUpdater($url, $updateId, $onComplete, $methods, $vmDirs, $varName); } function getAjaxUpdater( $url, $updateId, $onComplete, $method='post', $vmDirs=array(), $varName='' ) { global $mosConfig_live_site; vmCommonHTML::loadMooTools(); $path = defined('_VM_IS_BACKEND' ) ? '/administrator/' : '/'; $vmDirs['method'] = $method; $html = ''; if( $varName ) { $html .= 'var '.$varName.' = '; } if( !strstr( $url, $mosConfig_live_site) && !strstr($url, 'http' )) { $url = $mosConfig_live_site.$path.$url; } $html .= "new ajax('$url', {\n"; foreach (VM_COMPONENT_NAMEs as $key => $val) { if( strstr( $val, '.')) { $html .= "$key: $val,\n"; } else { $html .= "$key: '$val',\n"; } } if( $updateId != '' ) { $html .= "update: '$updateId'"; if( $onComplete ) { $html .= ",\n"; } } if( $onComplete ) { $html .= "onComplete: $onComplete"; } $html .= ' });'; return $html; } } /** * This is the class offering functions for common HTML tasks * */ class vmCommonHTML { /** * function to create a hyperlink * * @param string $link * @param string $text * @param string $target * @param string $title * @param string $attributes * @return string */ function hyperLink( $link, $text, $target='', $title='', $attributes='' ) { if( $target ) { $target = ' target="'.$target.'"'; } if( $title ) { $title = ' title="'.$title.'"'; } if( $attributes ) { $attributes = ' ' . $attributes; } return ''.$text.''; } /** * Function to create an image tag * * @param string $src * @param string $alt * @param int $height * @param int $width * @param string $title * @param int $border * @param string $attributes * @return string */ function imageTag( $src, $alt='', $align='', $height='', $width='', $title='', $border='0', $attributes='' ) { if( $align ) { $align = ' align="'.$align.'"'; } if( $height ) { $height = ' height="'.$height.'"'; } if( $width ) { $width = ' width="'.$width.'"'; } if( $title ) { $title = ' title="'.$title.'"'; } if( $attributes ) { $attributes = ' ' . $attributes; } if( strpos($attributes, 'border=')===false) { $border = ' border="'.$border.'"'; } // Prevent doubled attributes if( strpos($attributes, 'alt=')===false) { $alt = ' alt="'.$alt.'"'; } return ''; } /** * Returns a properly formatted XHTML List * * @param array $listitems * @param string $type Can be ul, ol, ... * @param string $style * @return string */ function getList( $listitems, $type = 'ul', $style='' ) { if( $style ) { $style = 'style="'.$style.'"'; } $html = '<' . $type ." $style>\n"; foreach( $listitems as $item ) { $html .= '
  • ' . $item . "
  • \n"; } $html .= '\n"; return $html; } /** * Returns a script tag. The referenced script will be fetched by a * PHP script called "fetchscript.php" * That allows use gzip compression, so bigger Javascripts don't steal our bandwith * * @param string $src The script src reference * @param string $content A Javascript Text to include in a script tag * @return string */ function scriptTag( $src='', $content = '' ) { global $mosConfig_gzip, $mosConfig_live_site; if( $src == '' && $content == '' ) return; if( $src ) { if( isset( $_REQUEST['usefetchscript'])) { $use_fetchscript = vmRequest::getBool( 'usefetchscript', 1 ); vmRequest::setVar( 'usefetchscript', $use_fetchscript, 'session' ); } else { $use_fetchscript = vmRequest::getBool( 'usefetchscript', 1, 'session' ); } $urlpos = strpos( $src, '?' ); $url_params = ''; if( $urlpos ) { $url_params = '&'.substr( $src, $urlpos ); $src = substr( $src, 0, $urlpos); } if( stristr( $src, 'com_virtuemart' ) && !stristr( $src, '.php' ) && $use_fetchscript ) { $base_source = str_replace( URL, '', $src ); $base_source = str_replace( SECUREURL, '', $base_source ); $base_source = str_replace( '/components/com_virtuemart', '', $base_source); $base_source = str_replace( 'components/com_virtuemart', '', $base_source); $src = $mosConfig_live_site.'/components/com_virtuemart/fetchscript.php?gzip='.$mosConfig_gzip.'&subdir[0]='.dirname( $base_source ) . '&file[0]=' . basename( $src ); } return ''."\n"; } if( $content ) { return "\n"; } } /** * Returns a link tag * * @param string $href * @param string $type * @param string $rel * @return string */ function linkTag( $href, $type='text/css', $rel = 'stylesheet', $media="screen, projection" ) { global $mosConfig_gzip, $mosConfig_live_site; if( isset( $_REQUEST['usefetchscript'])) { $use_fetchscript = vmRequest::getBool( 'usefetchscript', 1 ); vmRequest::setVar( 'usefetchscript', $use_fetchscript, 'session' ); } else { $use_fetchscript = vmRequest::getBool( 'usefetchscript', 1, 'session' ); } if( stristr( $href, 'com_virtuemart' ) && $use_fetchscript) { $base_href = str_replace( URL, '', $href ); $base_href = str_replace( SECUREURL, '', $base_href ); $base_href = str_replace( 'components/com_virtuemart/', '', $base_href); $href = $mosConfig_live_site.'/components/com_virtuemart/fetchscript.php?gzip='.$mosConfig_gzip.'&subdir[0]='.dirname( $base_href ) . '&file[0]=' . basename( $href ); } return ''."\n"; } /** * Writes a "Save Ordering" Button * @param int the number of rows */ function getSaveOrderButton( $num_rows, $funcname='reorder') { global $mosConfig_live_site, $VM_LANG; $n = $num_rows-1; $html = ' '.$VM_LANG->_('VM_SORT_SAVE_ORDER').''; $html .= ' '.$VM_LANG->_('VM_SORT_ALPHA').''; return $html; } function getOrderingField( $ordering ) { return ''; } function getYesNoIcon( $condition, $pos_alt = "Published", $neg_alt = "Unpublished" ) { global $mosConfig_live_site; if( $condition===true || strtoupper( $condition ) == "Y" || $condition == '1' ) { return ''.$pos_alt.''; } else { return ''.$neg_alt.''; } } /** * @param int The row index * @param int The record id * @param boolean * @param string The name of the form element * @return string */ function idBox( $rowNum, $recId, $checkedOut=false, $name='cid' ) { if ( $checkedOut ) { return ''; } else { return ''; } } /** * Manipulates an array and fills the $index with selected="selected" * Indexes within $disableArr will be filled with disabled="disabled" * * @param array $arr * @param int $index * @param string $att * @param array $disableArr */ function setSelectedArray( &$arr, $index, $att='selected', $disableArr=array() ) { if( !isset($arr[$index])) { return; } foreach( $arr as $key => $val ) { $arr[$key] = ''; if( $key == $index ) { $arr[$key] = $att.'="'.$att.'"'; } elseif( in_array( $key, $disableArr )) { $arr[$key] = 'disabled="disabled"'; } } } /** * tests for template/default pathway arrow separator * @author FTW Stroker * @static * @return string The separator for the pathway breadcrumbs */ function pathway_separator() { global $vm_mainframe,$mainframe, $mosConfig_absolute_path, $mosConfig_live_site; $imgPath = 'templates/' . $mainframe->getTemplate() . '/images/arrow.png'; if (file_exists( "$mosConfig_absolute_path/$imgPath" )){ $img = 'arrow'; } else { $imgPath = '/images/M_images/arrow.png'; if (file_exists( $mosConfig_absolute_path . $imgPath )){ $img = 'arrow'; } else { $img = '>'; } } return $img; } /** * Function to include the MooTools JS scripts in the HTML document * http://mootools.net * @static * @since VirtueMart 1.1.0 * */ function loadMooTools( $version='' ) { global $mosConfig_live_site, $vm_mainframe, $VM_LANG; if( !defined( "_MOOTOOLS_LOADED" )) { if( $version == '' ) { $version = 'mootools-release-1.11.js'; } $vm_mainframe->addScriptDeclaration( 'var cart_title = "'.$VM_LANG->_('PHPSHOP_CART_TITLE').'";var ok_lbl="'.$VM_LANG->_('CMN_CONTINUE').'";var cancel_lbl="'.$VM_LANG->_('CMN_CANCEL').'";var notice_lbl="'.$VM_LANG->_('PEAR_LOG_NOTICE').'";var live_site="'.$mosConfig_live_site.'";' ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/mootools/'.$version ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/mootools/mooPrompt.js' ); $vm_mainframe->addStyleSheet( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/mootools/mooPrompt.css' ); define ( "_MOOTOOLS_LOADED", "1" ); } } /** * Function to load the javascript and stylsheet files for Slimbox, * a Lightbox derivate with mootools and prototype.lite * @author http://www.digitalia.be/software/slimbox * * @param boolean $print */ function loadSlimBox( ) { global $mosConfig_live_site, $vm_mainframe; if( !defined( '_SLIMBOX_LOADED' )) { vmCommonHTML::loadMooTools(); $vm_mainframe->addScriptDeclaration( 'var slimboxurl = \''.$mosConfig_live_site.'/components/'. VM_COMPONENT_NAME .'/js/slimbox/\';'); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/slimbox/js/slimbox.js' ); $vm_mainframe->addStyleSheet( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/slimbox/css/slimbox.css' ); define ( '_SLIMBOX_LOADED', '1' ); } } /** * Prototype is a Javascript framework * @author http://prototype.conio.net/ * */ function loadPrototype( ) { global $vm_mainframe, $mosConfig_live_site; if( !defined( "_PROTOTYPE_LOADED" )) { $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/prototype/prototype.js' ); define( '_PROTOTYPE_LOADED', 1 ); } } /** * Loads the CSS and Javascripts needed to run the Greybox * Source: http://orangoo.com/labs/?page_id=5 * */ function loadGreybox( ) { global $mosConfig_live_site, $vm_mainframe; if( !defined( '_GREYBOX_LOADED' )) { $vm_mainframe->addScriptDeclaration( 'var GB_ROOT_DIR = \''.$mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/greybox/\';' ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/greybox/AJS.js' ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/greybox/AJS_fx.js' ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/greybox/gb_scripts.js' ); $vm_mainframe->addStyleSheet( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/greybox/gb_styles.css' ); define ( '_GREYBOX_LOADED', '1' ); } } /** * Loads all necessary script files for Tigra Tree Menu * @static * @since VirtueMart 1.1.0 */ function loadTigraTree( ) { global $mosConfig_live_site, $vm_mainframe; if( !defined( "_TIGRATREE_LOADED" )) { if( vmIsJoomla( '1.5' )) { $js_src = $mosConfig_live_site.'/modules/mod_virtuemart'; } else { $js_src = $mosConfig_live_site.'/modules'; } $vm_mainframe->addScript( $js_src .'/tigratree/tree_tpl.js.php' ); $vm_mainframe->addScript( $js_src .'/tigratree/tree.js' ); define ( "_TIGRATREE_LOADED", "1" ); } } function loadYUI( ) { global $mosConfig_live_site, $vm_mainframe; if( !defined( "_YUI_LOADED" )) { $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/extjs2/yui-utilities.js' ); define ( "_YUI_LOADED", "1" ); } } function loadExtjs() { global $mosConfig_live_site, $vm_mainframe; vmCommonHTML::loadYUI(); if( !defined( "_EXTJS_LOADED" )) { $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/extjs2/ext-yui-adapter.js' ); $vm_mainframe->addScript( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/extjs2/ext-all.js' ); $vm_mainframe->addScriptDeclaration( 'Ext.BLANK_IMAGE_URL = "'.$mosConfig_live_site.'/components/'. VM_COMPONENT_NAME .'/js/extjs2/images/default/s.gif";' ); $vm_mainframe->addStyleSheet( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/extjs2/css/ext-all.css' ); $vm_mainframe->addStyleSheet( $mosConfig_live_site .'/components/'. VM_COMPONENT_NAME .'/js/extjs2/css/xtheme-gray.css' ); define ( "_EXTJS_LOADED", "1" ); } } /** * Returns a properly formatted image link that opens a LightBox2/Slimbox * * @param string $image_link Can be the image src or a complete image tag * @param string $text The Link Text, e.g. 'Click here!' * @param string $title The Link title, will be used as Image Caption * @param string $image_group The image group name when you want to use the gallery functionality * @param string $mootools Set to 'true' if you're using slimbox or another MooTools based image viewing library * @return string */ function getLightboxImageLink( $image_link, $text, $title='', $image_group='' ) { vmCommonHTML::loadSlimBox(); if( $image_group ) { $image_group = '['.$image_group.']'; } $link = vmCommonHTML::hyperLink( $image_link, $text, '', $title, 'rel="lightbox'.$image_group.'"' ); return $link; } function getGreyboxPopUpLink( $url, $text, $target='_blank', $title='', $attributes='', $height=500, $width=600, $no_js_url='' ) { vmCommonHTML::loadGreybox(); if( $no_js_url == '') { $no_js_url = $url; } $link = vmCommonHTML::hyperLink( $no_js_url, $text, $target, $title, $attributes.' onclick="try{ if( !parent.GB ) return GB_showCenter(\''.$title.'\', \''.$url.'\', '.$height.', '.$width.');} catch(e) { }"' ); return $link; } /** * Returns a div element of the class "shop_error" * containing $msg to print out an error * * @param string $msg * @return string HTML code */ function getInfoField( $msg ) { $html = '
    '.$msg.'
    '; return $html; } /** * Returns a div element to indicate success or failure of a function execution after an ajax call * and a div element with all the log messages * * @param boolean $success * @param vmLog_Display $vmLogger */ function getSuccessIndicator( $success, $vmDisplayLogger ) { /*@MWM1*/ echo ''; echo '
    '; $vmDisplayLogger->printLog(); /*@MWM1: Log/Debug enhancements*/ echo '
    '; } /** * Returns a div element of the class "shop_error" * containing $msg to print out an error * * @param string $msg * @return string HTML code */ function getErrorField( $msg ) { $html = '
    '.$msg.'
    '; return $html; } /** * Writes a PDF icon * * @param string $link * @param boolean $use_icon */ function PdfIcon( $link, $use_icon=true ) { global $VM_LANG, $mosConfig_live_site; if ( PSHOP_PDF_BUTTON_ENABLE == '1' && !vmGet( $_REQUEST, 'pop' ) ) { $link .= '&pop=1'; if ( $use_icon ) { $text = vmCommonHTML::ImageCheck( 'pdf_button.png', '/images/M_images/', NULL, NULL, $VM_LANG->_('CMN_PDF'), $VM_LANG->_('CMN_PDF') ); } else { $text = $VM_LANG->_('CMN_PDF') .' '; } return vmPopupLink($link, $text, 640, 480, '_blank', $VM_LANG->_('CMN_PDF')); } } /** * Writes an Email icon * * @param string $link * @param boolean $use_icon */ function EmailIcon( $product_id, $use_icon=true ) { global $VM_LANG, $mosConfig_live_site, $sess; if ( @VM_SHOW_EMAILFRIEND == '1' && !vmGet( $_REQUEST, 'pop' ) && $product_id > 0 ) { $link = $sess->url( 'index2.php?page=shop.recommend&product_id='.$product_id.'&pop=1'.(vmIsJoomla('1.5') ? '&tmpl=component' : '') ); if ( $use_icon ) { $text = vmCommonHTML::ImageCheck( 'emailButton.png', '/images/M_images/', NULL, NULL, $VM_LANG->_('CMN_EMAIL'), $VM_LANG->_('CMN_EMAIL') ); } else { $text = ' '. $VM_LANG->_('CMN_EMAIL'); } return vmPopupLink($link, $text, 640, 480, '_blank', $VM_LANG->_('CMN_EMAIL'), 'screenX=100,screenY=200'); } } function PrintIcon( $link='', $use_icon=true, $add_text='' ) { global $VM_LANG, $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid; if ( @VM_SHOW_PRINTICON == '1' ) { if( !$link ) { $query_string = str_replace( 'only_page=1', 'only_page=0', vmAmpReplace(vmGet($_SERVER,'QUERY_STRING')) ); $link = 'index2.php?'.$query_string.'&pop=1'.(vmIsJoomla('1.5') ? '&tmpl=component' : ''); } // checks template image directory for image, if non found default are loaded if ( $use_icon ) { $text = vmCommonHTML::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, $VM_LANG->_('CMN_PRINT'), $VM_LANG->_('CMN_PRINT') ); $text .= shopMakeHtmlSafe($add_text); } else { $text = '| '. $VM_LANG->_('CMN_PRINT'). ' |'; } $isPopup = vmGet( $_GET, 'pop' ); if ( $isPopup ) { // Print Preview button - used when viewing page $html = ' '. $text .' '; return $html; } else { // Print Button - used in pop-up window return vmPopupLink($link, $text, 640, 480, '_blank', $VM_LANG->_('CMN_PRINT')); } } } /** * Checks to see if an image exists in the current templates image directory * if it does it loads this image. Otherwise the default image is loaded. * Also can be used in conjunction with the menulist param to create the chosen image * load the default or use no image */ function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name=NULL, $type=1, $align='middle', $title=NULL, $admin=NULL ) { global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe; $cur_template = $mainframe->getTemplate(); $name = ( $name ? ' name="'. $name .'"' : '' ); $title = ( $title ? ' title="'. $title .'"' : '' ); $alt = ( $alt ? ' alt="'. $alt .'"' : ' alt=""' ); $align = ( $align ? ' align="'. $align .'"' : '' ); // change directory path from frontend or backend if ($admin) { $path = '/administrator/templates/'. $cur_template .'/images/'; } else { $path = '/templates/'. $cur_template .'/images/'; } if ( $param ) { $image = $mosConfig_live_site. $param_directory . $param; if ( $type ) { $image = ''; } } else if ( $param == -1 ) { $image = ''; } else { if ( file_exists( $mosConfig_absolute_path . $path . $file ) ) { $image = $mosConfig_live_site . $path . $file; } else { // outputs only path to image $image = $mosConfig_live_site. $directory . $file; } // outputs actual html tag if ( $type ) { $image = ''; } } return $image; } /** * this function parses all the text through all content plugins * * @param string $text * @param string $type */ function ParseContentByPlugins( $text, $type = 'content' ) { global $_MAMBOTS; if( VM_CONTENT_PLUGINS_ENABLE == '1') { if( vmIsJoomla('1.0')) { $_MAMBOTS->loadBotGroup( $type ); $row = new stdClass(); $row->text = $text; $params = new mosParameters(''); $_MAMBOTS->trigger( 'onPrepareContent', array( &$row, &$params, 0 ), true ); $text = $row->text; } elseif( vmIsJoomla('1.5')) { $params =& $GLOBALS['mainframe']->getParams('com_content'); $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin($type); $row = new stdClass(); $row->text = $text; $results = $dispatcher->trigger('onPrepareContent', array (&$row, & $params, 0 )); $text = $row->text; } } return $text; } /** * This class allows us to create fieldsets like in Community builder * @author Copyright 2004 - 2005 MamboJoe/JoomlaJoe, Beat and CB team * * @param array $arr * @param string $tag_name * @param string $tag_attribs * @param string $key * @param string $text * @param mixed $selected * @param mixed $required * @return string HTML form code */ // begin class vmCommonHTML extends mosHTML { function radioListArr( &$arr, $tag_name, $tag_attribs, $key, $text, $selected, $required=0 ) { reset( $arr ); $html = array(); $n=count( $arr ); for ($i=0; $i < $n; $i++ ) { $k = stripslashes($arr[$i]->$key); $t = stripslashes($arr[$i]->$text); $id = isset($arr[$i]->id) ? $arr[$i]->id : null; $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $obj) { $k2 = stripslashes($obj->$key); if ($k == $k2) { $extra .= " checked=\"checked\""; break; } } } else { $extra .= ($k == stripslashes($selected) ? " checked=\"checked\"" : ''); } $html[] = " " . ""; } return $html; } function radioList( $arr, $tag_name, $tag_attribs, $key, $text, $selected, $required=0 ) { return "\n\t".implode("\n\t ", vmCommonHTML::radioListArr( $arr, $tag_name, $tag_attribs, $key, $text, $selected, $required ))."\n"; } function radioListTable( $arr, $tag_name, $tag_attribs, $key, $text, $selected, $cols=0, $rows=1, $size=0, $required=0 ) { $cellsHtml = vmCommonHTML::radioListArr( $arr, $tag_name, $tag_attribs, $key, $text, $selected, $required ); return vmCommonHTML::list2Table( $cellsHtml, $cols, $rows, $size ); } /** * Writes a yes/no radio list * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the "; if(!$required) $html .= "\n\t"; $n=count( $arr ); for ($i=0; $i < $n; $i++ ) { $k = stripslashes($arr[$i]->$key); $t = stripslashes($arr[$i]->$text); $id = isset($arr[$i]->id) ? $arr[$i]->id : null; $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $obj) { $k2 = stripslashes($obj->$key); if ($k == $k2) { $extra .= " selected=\"selected\""; break; } } } else { $extra .= ($k == stripslashes($selected) ? " selected=\"selected\"" : ''); } $html .= "\n\t"; } $html .= "\n\n"; return $html; } function checkboxListArr( $arr, $tag_name, $tag_attribs, $key='value', $text='text',$selected=null, $required=0 ) { global $VM_LANG; reset( $arr ); $html = array(); $n=count( $arr ); for ($i=0; $i < $n; $i++ ) { $k = $arr[$i]->$key; $t = $arr[$i]->$text; $id = isset($arr[$i]->id) ? $arr[$i]->id : null; $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $obj) { $k2 = $obj->$key; if ($k == $k2) { $extra .= " checked=\"checked\""; break; } } } else { $extra .= ($k == $selected ? " checked=\"checked\"" : ''); } $tmp = "" . ""; $html[] = $tmp; } return $html; } function checkboxList( $arr, $tag_name, $tag_attribs, $key='value', $text='text',$selected=null, $required=0 ) { return "\n\t".implode("\n\t", vmCommonHTML::checkboxListArr( $arr, $tag_name, $tag_attribs, $key, $text,$selected, $required ))."\n"; } function checkboxListTable( $arr, $tag_name, $tag_attribs, $key='value', $text='text',$selected=null, $cols=0, $rows=0, $size=0, $required=0 ) { $cellsHtml = vmCommonHTML::checkboxListArr( $arr, $tag_name, $tag_attribs, $key, $text,$selected, $required ); return vmCommonHTML::list2Table( $cellsHtml, $cols, $rows, $size ); } // private methods: function list2Table ( $cellsHtml, $cols, $rows, $size ) { $cells = count($cellsHtml); if ($size == 0) { $localstyle = ""; //" style='width:100%'"; } else { $size = (($size-($size % 3)) / 3 ) * 2; // int div 3 * 2 width/heigh ratio $localstyle = " style='width:".$size."em;'"; } $return=""; if ($cells) { if ($rows) { $return = "\n\t"; $cols = ($cells-($cells % $rows)) / $rows; // int div if ($cells % $rows) $cols++; $lineIdx=0; for ($lineIdx=0 ; $lineIdx < min($rows, $cells) ; $lineIdx++) { $return .= "\n\t\t"; for ($i=$lineIdx ; $i < $cells; $i += $rows) { $return .= ""; } $return .= "\n"; } $return .= "\t
    ".$cellsHtml[$i]."
    \n"; } else if ($cols) { $return = "\n\t"; $idx=0; while ($cells) { $return .= "\n\t\t"; for ($i=0, $n=min($cells,$cols); $i < $n; $i++, $cells-- ) { $return .= ""; } $return .= "\n"; } $return .= "\t
    ".$cellsHtml[$idx++]."
    \n"; } else { $return = "\n\t".implode("\n\t ", $cellsHtml)."\n"; } } return $return; } // end class vmCommonHTML, thanks folks! } /** * Utility function to provide ToolTips * * @param string $tooltip ToolTip text * @param string $title The Box title * @param string $image * @param int $width * @param string $text * @param string $href * @param string $link * @return string HTML code for ToolTip */ function vmToolTip( $tooltip, $title='Tip!', $image = "{mosConfig_live_site}/images/M_images/con_info.png", $width='350', $text='', $href='#', $link=false ) { global $mosConfig_live_site, $database; defined( 'vmToolTipCalled') or define('vmToolTipCalled', 1); $tooltip = str_replace('"','"',$tooltip); $tooltip = $database->getEscaped($tooltip); $tooltip = str_replace("'","\'",$tooltip); if ( !empty($width) ) { $width = ',WIDTH, -'.$width; } if ( $title ) { $title = ',TITLE,\''.$title .'\''; } $image = str_replace( "{mosConfig_live_site}", $mosConfig_live_site, $image); if( $image != '' ) { $text = vmCommonHTML::imageTag( $image, '', 'top' ). ' '.$text; } $style = 'style="text-decoration: none; color: #333;"'; if ( $href ) { $style = ''; } if ( $link ) { $tip = vmCommonHTML::hyperLink( $href, $text, '','', "onmouseover=\"Tip( '$tooltip' );\" onmouseout=\"UnTip()\" ". $style ); } else { $tip = "". $text .""; } return $tip; } /** * @deprecated */ function mm_ToolTip( $tooltip, $title='Tip!', $image = "{mosConfig_live_site}/images/M_images/con_info.png", $width='', $text='', $href='#', $link=false ) { return vmToolTip( $tooltip, $title, $image, $width, $text, $href, $link ); } /** * Utility function to provide persistant HelpToolTips * * @param unknown_type $tip * @param unknown_type $linktext */ function vmHelpToolTip( $tip, $linktext = ' [?] ' ) { global $mosConfig_live_site; if( !defined( 'vmHelpToolTipCalled')) { echo ' '; define('vmHelpToolTipCalled', 1); } $tip = str_replace( "\n", "", str_replace( "<", "<", str_replace( ">", ">", str_replace( "&", "&", @htmlentities( $tip, ENT_QUOTES ))))); $varname = 'a'.md5( $tip ); echo ' '; echo ''.$linktext.' '; } /** * Converts all special chars to html entities * * @param string $string * @param string $quote_style * @param boolean $only_special_chars Only Convert Some Special Chars ? ( <, >, &, ... ) * @return string */ function shopMakeHtmlSafe( $string, $quote_style='ENT_QUOTES', $use_entities=false ) { if( defined( $quote_style )) { $quote_style = constant($quote_style); } if( $use_entities ) { $string = @htmlentities( $string, constant($quote_style), vmGetCharset() ); } else { $string = @htmlspecialchars( $string, $quote_style, vmGetCharset() ); } return $string; } function mm_showMyFileName( $filename ) { if (vmShouldDebug()) { /*@MWM1: Logging/Debugging Enhancements */ echo vmToolTip( '
    Begin of File: '. wordwrap( $filename, 70, '
    ', true ).'
    '); } } /** * Wraps HTML Code or simple Text into Javascript * and uses the noscript Tag to support browsers with JavaScript disabled **/ function mm_writeWithJS( $textToWrap, $noscriptText ) { $text = ""; if( !empty( $textToWrap )) { $text = "\n"; } if( !empty( $noscriptText )) { $text .= "\n"; } return $text; } /** * A function to create a XHTML compliant and JS-disabled-safe pop-up link * * @param string $link The HREF attribute * @param string $text The link text * @param int $popupWidth * @param int $popupHeight * @param string $target The value of the target attribute * @param string $title * @param string $windowAttributes * @return string */ function vmPopupLink( $link, $text, $popupWidth=640, $popupHeight=480, $target='_blank', $title='', $windowAttributes='' ) { if( $windowAttributes ) { $windowAttributes = ','.$windowAttributes; } return vmCommonHTML::hyperLink( $link, $text, '', $title, "onclick=\"void window.open('$link', '$target', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=$popupWidth,height=$popupHeight,directories=no,location=no".$windowAttributes."');return false;\"" ); } /** * Creates a formatted address using the store address format * * @param array $address_details */ function vmFormatAddress( $address_details, $use_html=false ) { global $vendor_address_format; $store_address = str_replace( '{storename}', @$address_details['name'], $vendor_address_format ); $store_address = str_replace( '{address_1}', @$address_details['address_1'], $store_address ); $store_address = str_replace( '{address_2}', @$address_details['address_2'], $store_address ); $store_address = str_replace( '{state}', @$address_details['state'], $store_address ); $store_address = str_replace( '{statename}', @$address_details['state_name'], $store_address ); $store_address = str_replace( '{city}', @$address_details['city'], $store_address ); $store_address = str_replace( '{zip}', @$address_details['zip'], $store_address ); $store_address = str_replace( '{country}', @$address_details['country'], $store_address ); $store_address = str_replace( '{phone}', @$address_details['phone'], $store_address ); $store_address = str_replace( '{email}', @$address_details['email'], $store_address ); $store_address = str_replace( '{fax}', @$address_details['fax'], $store_address ); $store_address = str_replace( '{url}', @$address_details['url'], $store_address ); if( $use_html ) { $store_address = nl2br( $store_address ); } else { $store_address = strip_tags( $store_address ); } return $store_address; } ?>