Skip to content

Commit

Permalink
added confirmation pages for delete actions (dust box) (refs #2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
martini2002jp committed May 17, 2011
1 parent a0c8841 commit 433f564
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 1 deletion.
8 changes: 8 additions & 0 deletions apps/mobile_frontend/i18n/messages.ja.xml
Expand Up @@ -106,6 +106,14 @@
<source>Cannot send the message.</source>
<target>メッセージを送信できませんでした。</target>
</trans-unit>
<trans-unit id="">
<source>Delete this message</source>
<target>このメッセージを削除する</target>
</trans-unit>
<trans-unit id="">
<source>Delete messages</source>
<target>メッセージを削除する</target>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,11 @@
<?php
op_mobile_page_title(__('Delete this message'));
?>
<?php echo __('Do you delete this message?') ?><br /><br />
<?php echo $form->renderFormTag(url_for($deleteButton)); ?>
<?php echo $form ?>
<center>
<input type="submit" value="<?php echo __('Delete') ?>" />
</center>
</form>

@@ -0,0 +1,38 @@
<?php
op_mobile_page_title(__('Delete messages'));
?>
<?php echo __('Do you delete messages?') ?><br /><br />

<form action="<?php echo url_for('@'.$messageType.'List') ?>" method="post">

<?php slot('form') ?>
<?php echo $form->renderHiddenFields() ?>
<?php
foreach($form->getValue('message_ids') as $s_key => $s_value)
{
$tw = new sfWidgetFormInputHidden(array(), array());
$tw->addOption('name_format',$form->getWidgetSchema()->getNameFormat());
$tn = strtr($form->getWidgetSchema()->getNameFormat(),array('%s' =>"message_ids"));
echo $tw->render($tn.'['.$s_key.']', $s_value);
}
?>
<?php end_slot(); ?>


<?php slot('form_global_error') ?>
<?php if ($form->hasGlobalErrors()): ?>
<?php echo $form->renderGlobalErrors() ?>
<?php endif; ?>
<?php end_slot(); ?>
<?php if (get_slot('form_global_error')): ?>
<?php echo get_slot('form_global_error') ?><br><br>
<?php endif; ?>

<?php include_slot('form') ?>

<div align="center">
<input type="submit" value="<?php echo __('Delete') ?>">
<input type="hidden" name="only_hidden" value="true">
<input type="hidden" name="page" value="<?php echo $pager->getPage() ?>">
</div>
</form>
8 changes: 8 additions & 0 deletions apps/pc_frontend/i18n/messages.ja.xml
Expand Up @@ -130,6 +130,14 @@
<source>Cannot send the message.</source>
<target>メッセージを送信できませんでした。</target>
</trans-unit>
<trans-unit id="">
<source>Delete this message</source>
<target>このメッセージを削除する</target>
</trans-unit>
<trans-unit id="">
<source>Delete messages</source>
<target>メッセージを削除する</target>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,23 @@
<?php decorate_with('layoutC') ?>
<div id="formMessageDelete" class="dparts box">
<div class="parts">
<div class="partsHeading">
<h3><?php echo __('Delete this message') ?></h3>
</div>
<div class="block">
<p><?php echo __('Do you delete this message?') ?></p>
<?php echo $form->renderFormTag(url_for($deleteButton)); ?>
<?php echo $form ?>
<div class="operation">
<ul class="moreInfo button">
<li>
<input class="input_submit" type="submit" value="<?php echo __('Delete') ?>" />
</li>
</ul>
</div>
</form>
</div>
</div></div>

<?php use_helper('Javascript') ?>
<?php op_include_line('backLink', link_to_function(__('Back to previous page'), 'history.back()')) ?>
@@ -0,0 +1,48 @@
<?php decorate_with('layoutC') ?>
<div id="formMessageDeleteList" class="dparts box">
<div class="parts">
<div class="partsHeading">
<h3><?php echo __('Delete messages') ?></h3>
</div>
<div class="block">
<p><?php echo __('Do you delete messages?') ?></p>
<form action="<?php echo url_for('@'.$messageType.'List') ?>" method="post">
<?php slot('form') ?>
<?php echo $form->renderHiddenFields() ?>
<?php
foreach($form->getValue('message_ids') as $s_key => $s_value)
{
$tw = new sfWidgetFormInputHidden(array(), array());
$tw->addOption('name_format',$form->getWidgetSchema()->getNameFormat());
$tn = strtr($form->getWidgetSchema()->getNameFormat(),array('%s' =>"message_ids"));
echo $tw->render($tn.'['.$s_key.']', $s_value);
}
?>
<?php end_slot(); ?>


<?php slot('form_global_error') ?>
<?php if ($form->hasGlobalErrors()): ?>
<?php echo $form->renderGlobalErrors() ?>
<?php endif; ?>
<?php end_slot(); ?>
<?php if (get_slot('form_global_error')): ?>
<?php echo get_slot('form_global_error') ?><br><br>
<?php endif; ?>

<?php include_slot('form') ?>
<div class="operation">
<ul class="moreInfo button">
<li>
<input class="input_submit" type="submit" value="<?php echo __('Delete') ?>" />
<input type="hidden" name="only_hidden" value="true">
<input type="hidden" name="page" value="<?php echo $pager->getPage() ?>">
</li>
</ul>
</div>
</form>
</div>
</div></div>

<?php use_helper('Javascript') ?>
<?php op_include_line('backLink', link_to_function(__('Back to previous page'), 'history.back()')) ?>
15 changes: 15 additions & 0 deletions i18n/messages.ja.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<xliff version="1.0">
<file orginal="global" source-language="en" datatype="plaintext">
<body>
<trans-unit id="">
<source>Do you delete this message?</source>
<target>削除してよろしいですか?</target>
</trans-unit>
<trans-unit id="">
<source>Do you delete messages?</source>
<target>削除してよろしいですか?</target>
</trans-unit>
</body>
</file>
</xliff>
33 changes: 32 additions & 1 deletion lib/action/opMessagePluginMessageActions.class.php
Expand Up @@ -82,6 +82,11 @@ public function executeList(sfWebRequest $request)
$this->form->bind($params);
if ($this->form->isValid())
{
if ($this->messageType == "dust" && (!$request->getParameter('restore')) && $request->getParameter('only_hidden') != true)
{
$this->setTemplate("deleteListConfirm");
return sfView::SUCCESS;
}
$this->message = $this->form->save();
$this->redirect('@'.$this->messageType.'List');
}
Expand Down Expand Up @@ -114,13 +119,39 @@ public function executeShow(sfWebRequest $request)
$this->deleteButton = '@deleteSendMessage?id='.$this->message->getId();
break;
case "dust":
$this->deleteButton = '@deleteDustMessage?id='.$message->getId();
$this->deleteButton = '@deleteConfirmDustMessage?id='.$this->message->getId();
$this->deletedId = $message->getId();
break;
default :
throw new LogicException();
}
}

/**
* Executes deleteconfirm action
*
* @param sfWebRequest $request A request object
*/
public function executeDeleteConfirm(sfWebRequest $request)
{
$this->message = SendMessageDataPeer::retrieveByPk($request->getParameter('id'));
$this->messageType = $request->getParameter('type');
$this->forward404unless($message = $this->isReadable($this->messageType));

$this->form = new sfForm();

if ("dust" == $this->messageType)
{
$this->deleteButton = '@deleteDustMessage?id='.$message->getId();
$this->deletedId = $message->getId();
}
else
{
throw new LogicException();
}

$this->setTemplate("deleteConfirm");
}

/**
* Executes delete action
Expand Down
9 changes: 9 additions & 0 deletions lib/opMessagePluginRouting.class.php
Expand Up @@ -90,5 +90,14 @@ static public function listenToRoutingLoadConfigurationEvent(sfEvent $event)
array('id' => '\d+')
)
);

//delete message confirm
$routing->prependRoute('deleteConfirmDustMessage',
new sfRoute(
'/message/deleteConfirm/:id',
array('module' => 'message', 'action' => 'deleteConfirm', 'type' => 'dust'),
array('id' => '\d+')
)
);
}
}

0 comments on commit 433f564

Please sign in to comment.