我想更改自定義擴展名中的Delete Confirm消息,但我不知道如何。有人可以幫我嗎?
DutyController.php
class Nothing_Duty_Adminhtml_DutyController extends Mage_Adminhtml_Controller_Action
{
protected function _initAction()
{
$this->loadLayout()->_setActiveMenu("duty/duty")->_addBreadcrumb(Mage::helper("adminhtml")->__("Duty Manager"),Mage::helper("adminhtml")->__("Duty Manager"));
return $this;
}
public function indexAction()
{
$this->_title($this->__("Duty"));
$this->_title($this->__("Teste Criação de Grid"));
$this->_initAction();
$this->renderLayout();
}
public function editAction()
{
$this->_title($this->__("Editar Item"));
$id = $this->getRequest()->getParam("id");
$model = Mage::getModel("duty/cake")->load($id);
if ($model->getId()) {
Mage::register("duty_data", $model);
$this->loadLayout();
$this->_setActiveMenu("duty/duty");
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Duty Manager"), Mage::helper("adminhtml")->__("Duty Manager"));
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Duty Description"), Mage::helper("adminhtml")->__("Duty Description"));
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock("duty/adminhtml_duty_edit"))->_addLeft($this->getLayout()->createBlock("duty/adminhtml_duty_edit_tabs"));
$this->renderLayout();
}
else {
Mage::getSingleton("adminhtml/session")->addError(Mage::helper("duty")->__("Item does not exist."));
$this->_redirect("*/*/");
}
}
public function newAction()
{
$this->_title($this->__("Novo item"));
$id = $this->getRequest()->getParam("id");
$model = Mage::getModel("duty/cake")->load($id);
$data = Mage::getSingleton("adminhtml/session")->getFormData(true);
if (!empty($data)) {
$model->setData($data);
}
Mage::register("duty_data", $model);
$this->loadLayout();
$this->_setActiveMenu("duty/duty");
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Duty Manager"), Mage::helper("adminhtml")->__("Duty Manager"));
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Duty Description"), Mage::helper("adminhtml")->__("Duty Description"));
$this->_addContent($this->getLayout()->createBlock("duty/adminhtml_duty_edit"))->_addLeft($this->getLayout()->createBlock("duty/adminhtml_duty_edit_tabs"));
$this->renderLayout();
}
public function saveAction()
{
$post_data=$this->getRequest()->getPost();
if ($post_data) {
try {
$model = Mage::getModel("duty/cake")
->addData($post_data)
->setId($this->getRequest()->getParam("id"))
->save();
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("O item foi salvo com sucesso!"));
Mage::getSingleton("adminhtml/session")->setDutyData(false);
if ($this->getRequest()->getParam("back")) {
$this->_redirect("*/*/edit", array("id" => $model->getId()));
return;
}
$this->_redirect("*/*/");
return;
}
catch (Exception $e) {
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
Mage::getSingleton("adminhtml/session")->setDutyData($this->getRequest()->getPost());
$this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
return;
}
}
$this->_redirect("*/*/");
}
public function deleteAction()
{
if( $this->getRequest()->getParam("id") > 0 ) {
try {
$model = Mage::getModel("duty/cake");
$model->setId($this->getRequest()->getParam("id"))->delete();
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item foi deletado com sucesso!"));
$this->_redirect("*/*/");
}
catch (Exception $e) {
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
$this->_redirect("*/*/delete", array("id" => $this->getRequest()->getParam("id")));
}
}
$this->_redirect("*/*/");
}
public function massRemoveAction()
{
try {
$ids = $this->getRequest()->getPost('codigos', array());
foreach ($ids as $id) {
$model = Mage::getModel("duty/cake");
$model->setId($id)->delete();
}
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item removido com sucesso!"));
}
catch (Exception $e) {
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
}
$this->_redirect('*/*/');
}
public function exportCsvAction()
{
$fileName = 'arquivocsv.csv';
$grid = $this->getLayout()->createBlock('duty/adminhtml_duty_grid');
$this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
}
public function exportExcelAction()
{
$fileName = 'arquivoxml.xml';
$grid = $this->getLayout()->createBlock('duty/adminhtml_duty_grid');
$this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
}
}
Edit.php
class Nothing_Duty_Block_Adminhtml_Duty_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_objectId = "codigo";
$this->_blockGroup = "duty";
$this->_controller = "adminhtml_duty";
$this->_updateButton("save", "label", Mage::helper("duty")->__("Salvar Item"));
$this->_updateButton("delete", "label", Mage::helper("duty")->__("Deletar Item"));
$this->_addButton("saveandcontinue", array(
"label" => Mage::helper("duty")->__("Salvar e Continuar a Editar"),
"onclick" => "saveAndContinueEdit()",
"class" => "save",
), -100);
$this->_formScripts[] = "
function saveAndContinueEdit(){
editForm.submit($('edit_form').action+'back/edit/');
}
";
}
public function getHeaderText()
{
if( Mage::registry("duty_data") && Mage::registry("duty_data")->getId() ){
return Mage::helper("duty")->__("Editar Item '%s'", $this->htmlEscape(Mage::registry("duty_data")->getId()));
}
else{
return Mage::helper("duty")->__("Adicionar");
}
}
}
ps:此按鈕的功能是DeleteAction