Example #1
0
    /**
     * The function to handle all default page situations
     * not responsible for lists!
     */
    function FORMS_MENU_SAVE_CANCEL()
    {
        global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_lang, $VM_LANG, $page, $limitstart, $vmIcons;
        $no_menu = (int) $_REQUEST['no_menu'];
        $bar =& vmToolBar::getInstance('virtuemart');
        $is_iframe = vmGet($_REQUEST, 'is_iframe', 0);
        $product_parent_id = vmGet($_REQUEST, 'product_parent_id', 0);
        $product_id = vmGet($_REQUEST, 'product_id');
        $script = '';
        if (is_array($product_id)) {
            $product_id = "";
        }
        // These editor arrays tell the toolbar to load correct "getEditorContents" script parts
        // This is necessary for WYSIWYG Editors like TinyMCE / mosCE / FCKEditor
        $editor1_array = array('product.product_form' => 'product_desc', 'shopper.shopper_group_form' => 'shopper_group_desc', 'product.product_category_form' => 'category_description', 'manufacturer.manufacturer_form' => 'mf_desc', 'store.store_form' => 'vendor_store_desc', 'product.product_type_parameter_form' => 'parameter_description', 'product.product_type_form' => 'product_type_description', 'vendor.vendor_form' => 'vendor_store_desc');
        $editor2_array = array('store.store_form' => 'vendor_terms_of_service', 'vendor.vendor_form' => 'vendor_terms_of_service');
        $editor1 = isset($editor1_array[$page]) ? $editor1_array[$page] : '';
        $editor2 = isset($editor2_array[$page]) ? $editor2_array[$page] : '';
        if ($no_menu) {
            vmCommonHTML::loadExtJS();
        }
        $script .= '
var submitbutton = function(pressbutton){
	
	var form = document.adminForm;
	if (pressbutton == \'cancel\') {
		submitform( pressbutton );
		return;
	}	
';
        if ($editor1 != '') {
            if (vmIsJoomla(1.5)) {
                jimport('joomla.html.editor');
                $editor_type = $GLOBALS['mainframe']->getCfg('editor');
                if ($editor_type != 'none') {
                    $editor = JEditor::getInstance();
                    $script .= $editor->getContent($editor1);
                }
            } else {
                ob_start();
                getEditorContents('editor1', $editor1);
                $script .= ob_get_contents();
                ob_end_clean();
            }
        }
        if ($editor2 != '') {
            if (vmIsJoomla(1.5)) {
                jimport('joomla.html.editor');
                $editor_type = $GLOBALS['mainframe']->getCfg('editor');
                if ($editor_type != 'none') {
                    $editor = JEditor::getInstance();
                    $script .= $editor->getContent($editor2);
                }
            } else {
                ob_start();
                getEditorContents('editor2', $editor2);
                $script .= ob_get_contents();
                ob_end_clean();
            }
        }
        if ($no_menu) {
            $admin = defined('_VM_IS_BACKEND') ? '/administrator' : '';
            $script .= "\r\n    // define some private variables\r\n    var dialog, showBtn;\r\n\r\n    var showDialog = function( content ) {\r\n    \tExt.Msg.show( { \r\n            \t\ttitle: '" . $VM_LANG->_('PEAR_LOG_NOTICE') . "',\r\n            \t\tmsg: content,\r\n            \t\tautoCreate: true,\r\n                    width:400,\r\n                    height:180,\r\n                    modal: false,\r\n                    resizable: false,\r\n                    buttons: Ext.Msg.OK,\r\n                    shadow:true,\r\n                    animEl:Ext.get( 'vm-toolbar' )\r\n            });\r\n        " . (DEBUG ? "" : "setTimeout('Ext.Msg.hide()', 3000);") . "\r\n    };\r\n    \r\n    // return a public interface\r\n    var onSuccess = function(o,c) {\r\n\t\tshowDialog( o.responseText );\r\n\t};\r\n    var onFailure = function(o) {\r\n\t\tExt.Msg.alert( 'Error!', 'Save action failed: ' + o.statusText );\r\n\t};\r\n\tvar onCallback=function(o,s,r) {\r\n\t\t//if( s ) alert( 'Success' );\r\n\t\t//else alert( 'Failure' );\r\n\t}\r\n\t\r\n   \tExt.Ajax.request( { method: 'POST',\r\n   \t\t\t\t\t\turl: '{$_SERVER['PHP_SELF']}',\r\n   \t\t\t\t\t\tsuccess: onSuccess,\r\n   \t\t\t\t\t\tfailure: onFailure,\r\n   \t\t\t\t\t\tcallback: onCallback,\r\n   \t\t\t\t\t\tisUpload: true,\r\n   \t\t\t\t\t\tform: document.adminForm,\r\n   \t\t\t\t\t\tparams: { no_html:1 }\r\n   \t\t\t\t\t\t}\r\n   \t\t\t\t\t);\r\n\t";
        } else {
            $script .= "\n\t\t\tsubmitform( pressbutton );\n";
        }
        $script .= "\t\t}\n";
        $bar->buttons .= $script;
        if ($page == "product.product_form" && !empty($product_id)) {
            if (empty($product_parent_id)) {
                // add new attribute
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=product.product_attribute_form&product_id=" . $product_id . "&limitstart=" . $limitstart . "&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_ATTRIBUTE_FORM_MNU');
                $bar->customHref($href, 'new', $alt);
            } else {
                // back to parent product
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=product.product_form&product_id={$product_parent_id}&limitstart=" . $limitstart . "&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_RETURN_LBL');
                $bar->customHref($href, $vmIcons['back_icon'], $vmIcons['back_icon2'], $alt);
                // new child product
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=product.product_form&product_parent_id={$product_parent_id}&limitstart=" . $limitstart . "&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_ADD_ANOTHER_ITEM_MNU');
                $bar->customHref($href, 'new', $alt);
            }
            // Go to Price list
            $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}";
            $alt = $VM_LANG->_('PHPSHOP_PRICE_LIST_MNU');
            $bar->customHref($href, 'new', $alt);
            // add product type
            $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}";
            $alt = $VM_LANG->_('PHPSHOP_PRODUCT_PRODUCT_TYPE_FORM_MNU');
            $bar->customHref($href, 'new', $alt);
            /*** Adding an item is only pssible, if the product has attributes ***/
            if (ps_product::product_has_attributes($product_id)) {
                // Add Item
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=product.product_form&product_parent_id={$product_id}&limitstart={$limitstart}&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL');
                $bar->customHref($href, 'new', $alt);
            }
            $bar->divider();
        } elseif ($page == "admin.country_form") {
            if (!empty($_REQUEST['country_id'])) {
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=admin.country_state_form&country_id=" . intval($_REQUEST['country_id']) . "&limitstart={$limitstart}&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_ADD_STATE');
                $bar->customHref($href, 'new', $alt);
                $href = $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=admin.country_state_list&country_id=" . intval($_REQUEST['country_id']) . "&limitstart={$limitstart}&no_menu={$no_menu}";
                $alt = $VM_LANG->_('PHPSHOP_LIST_STATES');
                $bar->customHref($href, 'new', $alt);
                $bar->divider();
            }
        }
        $bar->save('save', $VM_LANG->_('CMN_SAVE'));
        //$bar->apply( 'apply', $VM_LANG->_('E_APPLY') );
        $bar->cancel();
    }