issue 46 apply validator to poll module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8548 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-06-30 00:54:10 +00:00
parent a65976f913
commit f020e75e09
11 changed files with 67 additions and 19 deletions

View file

@ -13,9 +13,9 @@
<action name="getPollAdminTarget" type="model" standalone="true" /> <action name="getPollAdminTarget" type="model" standalone="true" />
<action name="procInsert" type="controller" standalone="true" /> <action name="procInsert" type="controller" standalone="true" />
<action name="procPoll" type="controller" standalone="true" /> <action name="procPoll" type="controller" standalone="true" ruleset="poll" />
<action name="procPollViewResult" type="controller" standalone="true" /> <action name="procPollViewResult" type="controller" standalone="true" />
<action name="procPollAdminDeleteChecked" type="controller" standalone="true" /> <action name="procPollAdminDeleteChecked" type="controller" standalone="true" ruleset="deleteChecked" />
<action name="procPollAdminInsertConfig" type="controller" standalone="true" /> <action name="procPollAdminInsertConfig" type="controller" standalone="true" ruleset="insertConfig" />
</actions> </actions>
</module> </module>

View file

@ -24,6 +24,11 @@
$oModuleController->insertModuleConfig('poll', $config); $oModuleController->insertModuleConfig('poll', $config);
$this->setMessage('success_updated'); $this->setMessage('success_updated');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPollAdminConfig');
header('location:'.$returnUrl);
return;
}
} }
/** /**
@ -32,9 +37,10 @@
function procPollAdminDeleteChecked() { function procPollAdminDeleteChecked() {
// Display an error no post is selected // Display an error no post is selected
$cart = Context::get('cart'); $cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
$poll_srl_list= explode('|@|', $cart); if(is_array($cart)) $poll_srl_list = $cart;
else $poll_srl_list= explode('|@|', $cart);
$poll_count = count($poll_srl_list); $poll_count = count($poll_srl_list);
if(!$poll_count) return $this->stop('msg_cart_is_null'); if(!$poll_count) return $this->stop('msg_cart_is_null');
// Delete the post // Delete the post
@ -47,6 +53,11 @@
} }
$this->setMessage( sprintf(Context::getLang('msg_checked_poll_is_deleted'), $poll_count) ); $this->setMessage( sprintf(Context::getLang('msg_checked_poll_is_deleted'), $poll_count) );
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPollAdminList');
header('location:'.$returnUrl);
return;
}
} }
/** /**

View file

@ -119,6 +119,7 @@
if(!$srl) continue; if(!$srl) continue;
$item_srls[] = $srl; $item_srls[] = $srl;
} }
// If there is no response item, display an error // If there is no response item, display an error
if(!count($item_srls)) return new Object(-1, 'msg_check_poll_item'); if(!count($item_srls)) return new Object(-1, 'msg_check_poll_item');
// Make sure is the poll has already been taken // Make sure is the poll has already been taken
@ -167,6 +168,11 @@
$this->add('poll_srl', $poll_srl); $this->add('poll_srl', $poll_srl);
$this->add('tpl',$tpl); $this->add('tpl',$tpl);
$this->setMessage('success_poll'); $this->setMessage('success_poll');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPollAdminConfig');
header('location:'.$returnUrl);
return;
}
} }
/** /**

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
</customrules>
<fields>
<field name="cart" required="true" />
</fields>
</ruleset>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
</customrules>
<fields>
<field name="skin" required="true" />
<field name="colorset" required="true" />
</fields>
</ruleset>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
</customrules>
<fields>
<field name="poll_srl" required="true" rule="number" />
<field name="poll_srl_indexes" required="true" />
</fields>
</ruleset>

View file

@ -1,4 +1,3 @@
<load target="filter/poll.xml" />
<!--@if(__DEBUG__)--> <!--@if(__DEBUG__)-->
<load target="css/poll.css" /> <load target="css/poll.css" />
<load target="../../tpl/js/poll.js" /> <load target="../../tpl/js/poll.js" />
@ -13,10 +12,13 @@
<div id="poll_{$poll->poll_srl}" style="{$poll->style}"> <div id="poll_{$poll->poll_srl}" style="{$poll->style}">
<form action="./" method="get" onsubmit="return doPoll(this)"> <p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="poll" action="./" method="post" onsubmit="return doPoll(this)">
<input type="hidden" name="act" value="procPoll" />
<input type="hidden" name="poll_srl" value="{$poll->poll_srl}" /> <input type="hidden" name="poll_srl" value="{$poll->poll_srl}" />
<input type="hidden" name="poll_srl_indexes" value="" /> <input type="hidden" name="poll_srl_indexes" value="" />
<input type="hidden" name="skin" value="{$skin}" /> <input type="hidden" name="skin" value="{$skin}" />
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
<table cellspacing="0" class="poll_table"> <table cellspacing="0" class="poll_table">
<col width="7" /> <col width="7" />

View file

@ -1,4 +1,3 @@
<load target="filter/poll.xml" />
<!--@if(__DEBUG__)--> <!--@if(__DEBUG__)-->
<load target="css/poll.css" /> <load target="css/poll.css" />
<load target="../../tpl/js/poll.js" /> <load target="../../tpl/js/poll.js" />
@ -13,10 +12,13 @@
<div id="poll_{$poll->poll_srl}" style="{$poll->style}"> <div id="poll_{$poll->poll_srl}" style="{$poll->style}">
<form action="./" method="get" onsubmit="return doPoll(this)"> <p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form action="./" method="post" onsubmit="return doPoll(this)">
<input type="hidden" name="act" value="procPoll" />
<input type="hidden" name="poll_srl" value="{$poll->poll_srl}" /> <input type="hidden" name="poll_srl" value="{$poll->poll_srl}" />
<input type="hidden" name="poll_srl_indexes" value="" /> <input type="hidden" name="poll_srl_indexes" value="" />
<input type="hidden" name="skin" value="{$skin}" /> <input type="hidden" name="skin" value="{$skin}" />
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
<table cellspacing="0" class="simple_poll"> <table cellspacing="0" class="simple_poll">
<tr> <tr>

View file

@ -1,8 +1,9 @@
<!--%import("filter/insert_config.xml")-->
<!--%import("js/poll_admin.js")--> <!--%import("js/poll_admin.js")-->
<!--#include("./header.html")--> <!--#include("./header.html")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_config);" id="fo_poll"> <p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="insertConfig" action="./" method="post" id="fo_poll">
<input type="hidden" name="act" value="procPollAdminInsertConfig" />
<table cellspacing="0" class="rowTable"> <table cellspacing="0" class="rowTable">
<tr> <tr>

View file

@ -37,8 +37,7 @@ function doPoll(fo_obj) {
} }
fo_obj.poll_srl_indexes.value = poll_srl_indexes; fo_obj.poll_srl_indexes.value = poll_srl_indexes;
procFilter(fo_obj, poll); fo_obj.submit();
return false;
} }
jQuery(function($){ jQuery(function($){

View file

@ -1,9 +1,10 @@
<!--%import("filter/delete_checked.xml")-->
<!--%import("js/poll_admin.js")--> <!--%import("js/poll_admin.js")-->
<!--#include("./header.html")--> <!--#include("./header.html")-->
<form action="./" method="get" onsubmit="return procFilter(this, delete_checked)" id="fo_list"> <p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="deleteChecked" action="./" method="post" id="fo_list">
<input type="hidden" name="act" value="procPollAdminDeleteChecked" />
<input type="hidden" name="page" value="{$page}" /> <input type="hidden" name="page" value="{$page}" />
<!-- 목록 --> <!-- 목록 -->
@ -12,7 +13,7 @@
<thead> <thead>
<tr> <tr>
<th scope="col"><div>{$lang->no}</div></th> <th scope="col"><div>{$lang->no}</div></th>
<th scope="col"><div><input type="checkbox" onclick="XE.checkboxToggleAll(); return false;" /></div></th> <th scope="col"><div><input type="checkbox" onclick="XE.checkboxToggleAll('cart[]'); return false;" /></div></th>
<th scope="col" class="wide"><div>{$lang->title}</div></th> <th scope="col" class="wide"><div>{$lang->title}</div></th>
<th scope="col"><div>{$lang->poll_checkcount}</div></th> <th scope="col"><div>{$lang->poll_checkcount}</div></th>
<th scope="col"><div>{$lang->poll_join_count}</div></th> <th scope="col"><div>{$lang->poll_join_count}</div></th>
@ -24,7 +25,7 @@
<!--@foreach($poll_list as $no => $val)--> <!--@foreach($poll_list as $no => $val)-->
<tr class="row{$cycle_idx}"> <tr class="row{$cycle_idx}">
<td class="number center">{$no}</td> <td class="number center">{$no}</td>
<td class="center"><input type="checkbox" name="cart" value="{$val->poll_index_srl}" /></td> <td class="center"><input type="checkbox" name="cart[]" value="{$val->poll_index_srl}" /></td>
<td><a href="#" onclick="doMovePoll({$val->poll_srl},{$val->upload_target_srl});return false;">{htmlspecialchars($val->title)}</a></td> <td><a href="#" onclick="doMovePoll({$val->poll_srl},{$val->upload_target_srl});return false;">{htmlspecialchars($val->title)}</a></td>
<td class="number center">{$val->checkcount}</td> <td class="number center">{$val->checkcount}</td>
<td class="number center">{$val->poll_count}</td> <td class="number center">{$val->poll_count}</td>
@ -38,8 +39,8 @@
<!-- 버튼 --> <!-- 버튼 -->
<div class="clear"> <div class="clear">
<div class="fl"> <div class="fl">
<a href="javascript:XE.checkboxToggleAll({ checked:false })" class="button"><span>{$lang->cmd_unselect_all}</span></a> <a href="javascript:XE.checkboxToggleAll('cart[]', { checked:false })" class="button"><span>{$lang->cmd_unselect_all}</span></a>
<a href="javascript:XE.checkboxToggleAll()" class="button"><span>{$lang->cmd_reverse_all}</span></a> <a href="javascript:XE.checkboxToggleAll('cart[]')" class="button"><span>{$lang->cmd_reverse_all}</span></a>
</div> </div>
<div class="fr"> <div class="fr">
<span class="button black strong"><input type="submit" value="{$lang->cmd_delete_checked_poll}" /></span> <span class="button black strong"><input type="submit" value="{$lang->cmd_delete_checked_poll}" /></span>