PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_virtuemart/toolbar.virtuemart.html.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 388 lines | 279 code | 51 blank | 58 comment | 39 complexity | afc22d823e46e5209f70a97cdb74c226 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  3. /**
  4. *
  5. * @version $Id: toolbar.virtuemart.html.php 1454 2008-07-08 19:31:54Z soeren_nb $
  6. * @package VirtueMart
  7. * @subpackage core
  8. * @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  10. * VirtueMart is free software. This version may have been modified pursuant
  11. * to the GNU General Public License, and as distributed it includes or
  12. * is derivative of works licensed under the GNU General Public License or
  13. * other free or open source software licenses.
  14. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
  15. *
  16. * http://virtuemart.net
  17. */
  18. $_REQUEST['keyword'] = urldecode(vmGet($_REQUEST, 'keyword', ''));
  19. $keyword = $_REQUEST['keyword'];
  20. $no_menu = vmGet( $_REQUEST, 'no_menu', 0 );
  21. global $vmIcons;
  22. $vmIcons['back_icon'] = $mosConfig_live_site."/administrator/images/back.png";
  23. $vmIcons['back_icon2'] = $mosConfig_live_site."/administrator/images/back_f2.png";
  24. $vmIcons['cancel_icon'] = $mosConfig_live_site."/administrator/images/cancel.png";
  25. $vmIcons['cancel_icon2'] = $mosConfig_live_site."/administrator/images/cancel_f2.png";
  26. $vmIcons['new_icon'] = $mosConfig_live_site."/administrator/images/new.png";
  27. $vmIcons['new_icon2'] = $mosConfig_live_site."/administrator/images/new_f2.png";
  28. $vmIcons['save_icon'] = $mosConfig_live_site."/administrator/images/save.png";
  29. $vmIcons['save_icon2'] = $mosConfig_live_site."/administrator/images/save_f2.png";
  30. $vmIcons['delete_icon'] = $mosConfig_live_site."/administrator/images/delete.png";
  31. $vmIcons['delete_icon2'] = $mosConfig_live_site."/administrator/images/delete_f2.png";
  32. $vmIcons['publish_icon'] = $mosConfig_live_site."/administrator/images/publish.png";
  33. $vmIcons['publish_icon2'] = $mosConfig_live_site."/administrator/images/publish_f2.png";
  34. $vmIcons['unpublish_icon'] = $mosConfig_live_site."/administrator/images/unpublish.png";
  35. $vmIcons['unpublish_icon2'] = $mosConfig_live_site."/administrator/images/unpublish_f2.png";
  36. $vmIcons['apply_icon'] = $mosConfig_live_site."/administrator/images/apply.png";
  37. $vmIcons['apply_icon2'] = $mosConfig_live_site."/administrator/images/apply_f2.png";
  38. class MENU_virtuemart {
  39. /**
  40. * The function to handle all default page situations
  41. * not responsible for lists!
  42. */
  43. function FORMS_MENU_SAVE_CANCEL() {
  44. global $mosConfig_absolute_path,$mosConfig_live_site, $mosConfig_lang, $VM_LANG,
  45. $product_id, $page, $limitstart, $mosConfig_editor, $vmIcons;
  46. $bar = & JToolBar::getInstance('toolbar');
  47. $no_menu = vmGet( $_REQUEST, 'no_menu', 0 );
  48. $is_iframe = vmGet( $_REQUEST, 'is_iframe', 0 );
  49. $product_parent_id = vmGet( $_REQUEST, 'product_parent_id', 0 );
  50. $script = '';
  51. $clone_product = vmRequest::getInt( 'clone_product', 0 );
  52. if( is_array( $product_id )) {
  53. $product_id = "";
  54. }
  55. // These editor arrays tell the toolbar to load correct "getEditorContents" script parts
  56. // This is necessary for WYSIWYG Editors like TinyMCE / mosCE / FCKEditor
  57. $editor1_array = Array('product.product_form' => 'product_desc', 'shopper.shopper_group_form' => 'shopper_group_desc',
  58. 'product.product_category_form' => 'category_description', 'manufacturer.manufacturer_form' => 'mf_desc',
  59. 'store.store_form' => 'vendor_store_desc',
  60. 'product.product_type_parameter_form' => 'parameter_description',
  61. 'product.product_type_form' => 'product_type_description',
  62. 'vendor.vendor_form' => 'vendor_store_desc');
  63. $editor2_array = Array('store.store_form' => 'vendor_terms_of_service',
  64. 'vendor.vendor_form' => 'vendor_terms_of_service');
  65. $editor1 = isset($editor1_array[$page]) ? $editor1_array[$page] : '';
  66. $editor2 = isset($editor2_array[$page]) ? $editor2_array[$page] : '';
  67. if( $no_menu ) {
  68. vmCommonHTML::loadExtjs();
  69. }
  70. $script .= '<script type="text/javascript">
  71. function submitbutton(pressbutton) {
  72. var form = document.adminForm;
  73. if (pressbutton == \'cancel\') {
  74. submitform( pressbutton );
  75. return;
  76. }
  77. ';
  78. if ($editor1 != '') {
  79. if( vmIsJoomla(1.5) ) {
  80. jimport('joomla.html.editor');
  81. $editor_type = $GLOBALS['mainframe']->getCfg('editor');
  82. if( $editor_type != 'none' ) {
  83. $editor = JEditor::getInstance();
  84. $script .= $editor->getContent($editor1);
  85. }
  86. } else {
  87. ob_start();
  88. getEditorContents( 'editor1', $editor1 );
  89. $script .= ob_get_contents(); ob_end_clean();
  90. }
  91. }
  92. if ($editor2 != '') {
  93. if( vmIsJoomla(1.5) ) {
  94. jimport('joomla.html.editor');
  95. $editor_type = $GLOBALS['mainframe']->getCfg('editor');
  96. if( $editor_type != 'none' ) {
  97. $editor = JEditor::getInstance();
  98. $script .= $editor->getContent($editor2);
  99. }
  100. } else {
  101. ob_start();
  102. getEditorContents( 'editor2', $editor2 );
  103. $script .= ob_get_contents(); ob_end_clean();
  104. }
  105. }
  106. if( $no_menu ) {
  107. $admin = defined('_VM_IS_BACKEND') ? '/administrator' : '';
  108. $script .= "
  109. // define some private variables
  110. var dialog, showBtn;
  111. // the second argument is true to indicate file upload.
  112. YAHOO.util.Connect.setForm(form, true);
  113. var showDialog = function( content ) {
  114. Ext.MessageBox.show( {
  115. title: '" . $VM_LANG->_('PEAR_LOG_NOTICE') . "',
  116. msg: content,
  117. autoCreate: true,
  118. width:400,
  119. height:180,
  120. modal: false,
  121. resizable: false,
  122. buttons: Ext.MessageBox.OK,
  123. shadow:true,
  124. animEl:Ext.get( 'vm-toolbar' )
  125. });
  126. setTimeout('Ext.MessageBox.hide()', 3000);
  127. };
  128. // return a public interface
  129. var callback = {
  130. success: function(o) {
  131. //Ext.DomHelper.insertHtml( document.body, o.responseText );
  132. showDialog( o.responseText );
  133. },
  134. failure: function(o) {
  135. Ext.DomHelper.append( document.body, { tag: 'div', id: 'vmLogResult', html: 'Save action failed: ' + o.statusText } );
  136. showDialog( o.responseText );
  137. },
  138. upload : function(o){
  139. //Ext.DomHelper.insertHtml( 'beforeEnd', document.body, o.responseText );
  140. showDialog( o.responseText );
  141. }
  142. };
  143. var cObj = YAHOO.util.Connect.asyncRequest('POST', '{$_SERVER['PHP_SELF']}', callback);
  144. \n";
  145. }
  146. else {
  147. $script .= "\n\t\t\tsubmitform( pressbutton );\n";
  148. }
  149. $script .= "\t\t}
  150. </script>";
  151. $bar->appendButton( 'Custom', $script );
  152. vmMenuBar::startTable();
  153. if ($page == "product.product_form" && !empty($product_id) && $clone_product!=1) {
  154. if( empty($product_parent_id) ) {
  155. // add new attribute
  156. $href=$_SERVER['PHP_SELF']."?option=com_virtuemart&page=product.product_attribute_form&product_id=". $product_id ."&limitstart=". $limitstart."&no_menu=$no_menu";
  157. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_ATTRIBUTE_FORM_MNU');
  158. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  159. vmMenuBar::spacer();
  160. }
  161. else {
  162. // back to parent product
  163. $href=$_SERVER['PHP_SELF']."?option=com_virtuemart&page=product.product_form&product_id=$product_parent_id&limitstart=".$limitstart."&no_menu=$no_menu";
  164. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_FORM_RETURN_LBL');
  165. vmMenuBar::customHref( $href, $vmIcons['back_icon'], $vmIcons['back_icon2'], $alt );
  166. vmMenuBar::spacer();
  167. // new child product
  168. $href=$_SERVER['PHP_SELF']."?option=com_virtuemart&page=product.product_form&product_parent_id=$product_parent_id&limitstart=". $limitstart."&no_menu=$no_menu";
  169. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_FORM_ADD_ANOTHER_ITEM_MNU');
  170. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  171. vmMenuBar::spacer();
  172. }
  173. // Go to Price list
  174. $href = $_SERVER['PHP_SELF']."?page=product.product_price_list&product_id=$product_id&product_parent_id=$product_parent_id&limitstart=$limitstart&return_args=&option=com_virtuemart&no_menu=$no_menu";
  175. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRICE_LIST_MNU');
  176. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  177. vmMenuBar::spacer();
  178. // add product type
  179. $href= $_SERVER['PHP_SELF']."?option=com_virtuemart&page=product.product_product_type_form&product_id=$product_id&product_parent_id=$product_parent_id&limitstart=$limitstart&no_menu=$no_menu";
  180. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_PRODUCT_TYPE_FORM_MNU');
  181. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  182. vmMenuBar::spacer();
  183. /*** Adding an item is only pssible, if the product has attributes ***/
  184. if (ps_product::product_has_attributes( $product_id ) ) {
  185. // Add Item
  186. $href=$_SERVER['PHP_SELF']."?option=com_virtuemart&page=product.product_form&product_parent_id=$product_id&limitstart=$limitstart&no_menu=$no_menu";
  187. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL');
  188. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  189. vmMenuBar::spacer();
  190. }
  191. vmMenuBar::divider();
  192. }
  193. elseif( $page == "admin.country_form" ) {
  194. if( !empty( $_REQUEST['country_id'] )) {
  195. $href= $_SERVER['PHP_SELF'] ."?option=com_virtuemart&page=admin.country_state_form&country_id=". intval($_REQUEST['country_id']) ."&limitstart=$limitstart&no_menu=$no_menu";
  196. $alt = "&nbsp;".$VM_LANG->_('PHPSHOP_ADD_STATE');
  197. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  198. vmMenuBar::spacer();
  199. $href = $_SERVER['PHP_SELF'] ."?option=com_virtuemart&page=admin.country_state_list&country_id=". intval($_REQUEST['country_id']) ."&limitstart=$limitstart&no_menu=$no_menu";
  200. $alt = "&nbsp;".$VM_LANG->_('PHPSHOP_LIST_STATES');
  201. vmMenuBar::customHref( $href, $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  202. vmMenuBar::spacer();
  203. vmMenuBar::divider();
  204. }
  205. }
  206. vmMenuBar::spacer();
  207. vmMenuBar::save( 'save', $VM_LANG->_('CMN_SAVE') );
  208. if( $no_menu == 0 ) {
  209. vmMenuBar::spacer();
  210. vmMenuBar::apply( 'apply', $VM_LANG->_('E_APPLY') );
  211. }
  212. if( (strstr( @$_SERVER['HTTP_REFERER'], $page ) || strstr( @$_SERVER['HTTP_REFERER'], $_SERVER['PHP_SELF'] )) && $no_menu && !$is_iframe ) {
  213. // offer a back button
  214. vmMenuBar::spacer();
  215. vmMenuBar::back();
  216. }
  217. vmMenuBar::spacer();
  218. vmMenuBar::cancel();
  219. vmMenuBar::spacer();
  220. vmMenuBar::endTable();
  221. }
  222. /**
  223. * The function for all page which allow adding new items
  224. * usually when page= *.*_list
  225. */
  226. function LISTS_MENU_NEW() {
  227. global $page, $mosConfig_live_site, $VM_LANG, $limitstart, $vmIcons;
  228. $my_page = str_replace('list','form',$page);
  229. vmMenuBar::addNew( "new", $my_page, $VM_LANG->_('CMN_NEW') );
  230. if ($page == 'admin.country_state_list') {
  231. // Back to the country
  232. vmMenuBar::divider();
  233. $href = $_SERVER['PHP_SELF']. '?option=com_virtuemart&page=admin.country_list';
  234. vmMenuBar::customHref( $href, $vmIcons['back_icon'], $vmIcons['back_icon2'], '&nbsp;'.$VM_LANG->_('PHPSHOP_BACK_TO_COUNTRY') );
  235. }
  236. elseif ($page == 'product.file_list') {
  237. // Close the window
  238. vmMenuBar::divider();
  239. vmMenuBar::cancel();
  240. }
  241. vmMenuBar::spacer();
  242. }
  243. /**
  244. * Draws a list publish button
  245. */
  246. function LISTS_MENU_PUBLISH( $funcName ) {
  247. vmMenuBar::publishList( $funcName );
  248. vmMenuBar::spacer();
  249. vmMenuBar::unpublishList( $funcName );
  250. vmMenuBar::spacer();
  251. }
  252. /**
  253. * Draws a list delete button
  254. */
  255. function LISTS_MENU_DELETE( $funcName ) {
  256. vmMenuBar::deleteList( $funcName );
  257. }
  258. /**
  259. * Handles special task selectors for pages
  260. * like the product list
  261. */
  262. function LISTS_SPECIAL_TASKS( $page ) {
  263. global $mosConfig_live_site, $VM_LANG, $product_id, $vmIcons;
  264. switch( $page ) {
  265. case "product.product_list":
  266. if( empty($_REQUEST['product_parent_id']) ) {
  267. // add new attribute
  268. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_ATTRIBUTE_FORM_MNU');
  269. vmMenuBar::custom( "", "product.product_attribute_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  270. vmMenuBar::spacer();
  271. }
  272. // Go to Price list
  273. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRICE_LIST_MNU');
  274. vmMenuBar::custom( "", "product.product_price_list", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  275. vmMenuBar::spacer();
  276. // add product type
  277. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_PRODUCT_TYPE_FORM_MNU');
  278. vmMenuBar::custom( "", "product.product_product_type_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  279. vmMenuBar::spacer();
  280. /*** Adding an item is only pssible, if the product has attributes ***/
  281. if (ps_product::product_has_attributes( $product_id ) ) {
  282. // Add Item
  283. $alt = "&nbsp;". $VM_LANG->_('PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL');
  284. vmMenuBar::custom( "", "product.product_child_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  285. }
  286. vmMenuBar::divider();
  287. vmMenuBar::spacer();
  288. if( !empty( $_REQUEST['category_id'])) {
  289. $alt = $VM_LANG->_('VM_PRODUCTS_MOVE_TOOLBAR');
  290. vmMenuBar::custom( 'move', 'product.product_move', $mosConfig_live_site.'/administrator/images/move.png', $mosConfig_live_site.'/administrator/images/move_f2.png', $alt );
  291. vmMenuBar::spacer();
  292. vmMenuBar::divider();
  293. vmMenuBar::spacer();
  294. }
  295. break;
  296. case "admin.country_list":
  297. $alt = "&nbsp;".$VM_LANG->_('PHPSHOP_ADD_STATE');
  298. vmMenuBar::custom( "", "admin.country_state_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  299. vmMenuBar::spacer();
  300. $alt = "&nbsp;".$VM_LANG->_('PHPSHOP_LIST_STATES');
  301. vmMenuBar::custom( "", "admin.country_state_list", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt );
  302. vmMenuBar::spacer();
  303. vmMenuBar::divider();
  304. vmMenuBar::spacer();
  305. break;
  306. default:
  307. }
  308. }
  309. /**
  310. * Draws the menu for a New users
  311. */
  312. function _NEW_USERS() {
  313. vmMenuBar::startTable();
  314. vmMenuBar::save();
  315. vmMenuBar::cancel();
  316. vmMenuBar::spacer();
  317. vmMenuBar::endTable();
  318. }
  319. function _EDIT_USERS() {
  320. vmMenuBar::startTable();
  321. vmMenuBar::save();
  322. vmMenuBar::cancel();
  323. vmMenuBar::spacer();
  324. vmMenuBar::endTable();
  325. }
  326. function _DEFAULT_USERS() {
  327. vmMenuBar::startTable();
  328. vmMenuBar::addNew();
  329. vmMenuBar::editList();
  330. vmMenuBar::deleteList();
  331. vmMenuBar::spacer();
  332. vmMenuBar::custom( 'remove_as_customer', 'admin.user_list', IMAGEURL .'ps_image/remove_as_customer.png', IMAGEURL .'ps_image/remove_as_customer_f2.png' );
  333. vmMenuBar::spacer();
  334. vmMenuBar::endTable();
  335. }
  336. }
  337. ?>