PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

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