issue 46 validator apply to layout module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8513 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-06-21 08:31:10 +00:00
parent ee58f755a8
commit c8c03a898c
10 changed files with 93 additions and 26 deletions

View file

@ -18,16 +18,16 @@
<action name="dispLayoutAdminDownloadedMobileList" type="view" standalone="true" />
<action name="procLayoutAdminInsert" type="controller" standalone="true" />
<action name="procLayoutAdminUpdate" type="controller" standalone="true" />
<action name="procLayoutAdminInsert" type="controller" standalone="true" ruleset="insertLayout" />
<action name="procLayoutAdminUpdate" type="controller" standalone="true" ruleset="updateLayout" />
<action name="procLayoutAdminDelete" type="controller" standalone="true" />
<action name="procLayoutAdminCodeUpdate" type="controller" standalone="true" />
<action name="procLayoutAdminCodeUpdate" type="controller" standalone="true" ruleset="codeUpdate" />
<action name="procLayoutAdminCodeReset" type="controller" standalone="true" />
<action name="procLayoutAdminUserImageUpload" type="controller" standalone="true" />
<action name="procLayoutAdminUserImageUpload" type="controller" standalone="true" ruleset="imageUpload" />
<action name="procLayoutAdminUserImageDelete" type="controller" standalone="true" />
<action name="procLayoutAdminUserValueInsert" type="controller" standalone="true" />
<action name="procLayoutAdminUserLayoutExport" type="controller" standalone="true" />
<action name="procLayoutAdminUserLayoutImport" type="controller" standalone="true" />
<action name="procLayoutAdminUserLayoutImport" type="controller" standalone="true" ruleset="userLayoutImport" />
</actions>
</module>

View file

@ -33,12 +33,20 @@
$this->initLayout($args->layout_srl, $args->layout);
// Return result
$this->add('layout_srl', $args->layout_srl);
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminContent');
header('location:'.$returnUrl);
return;
}
}
// Insert layout information into the DB
function insertLayout($args) {
$output = executeQuery("layout.insertLayout", $args);
return $output;
}
// Initiate if it is faceoff layout
function initLayout($layout_srl, $layout_name){
$oLayoutModel = &getModel('layout');
@ -162,10 +170,15 @@
$output = $this->updateLayout($args);
if(!$output->toBool()) return $output;
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('default_layout.html');
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile("top_refresh.html");
//$this->setLayoutPath('./common/tpl');
//$this->setLayoutFile('default_layout.html');
//$this->setTemplatePath($this->module_path.'tpl');
//$this->setTemplateFile("top_refresh.html");
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminModify', 'layout_srl', Context::get('layout_srl'));
header('location:'.$returnUrl);
return;
}
}
function updateLayout($args) {
@ -221,12 +234,12 @@
$layout_css_file = $oLayoutModel->getUserLayoutCss($layout_srl);
FileHandler::writeFile($layout_css_file, $code_css);
if($is_post) {
if(!$return_url) $return_url = getUrl('module','admin','act','dispLayoutAdminEdit', 'layout_srl', $layout_srl);
header('Location: '.$return_url);
} else {
$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', 'dispLayoutAdminEdit', 'layout_srl', $layout_srl);
header('location:'.$returnUrl);
return;
}
$this->setMessage('success_updated');
}
/**
@ -266,13 +279,15 @@
$layout_srl = Context::get('layout_srl');
if(!is_uploaded_file($image['tmp_name'])) exit();
if(!preg_match('/\.(gif|jpg|jpeg|gif|png|swf|flv)$/i', $image['name'])){
return false;
}
$this->insertUserLayoutImage($layout_srl, $image);
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile("top_refresh.html");
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminEdit', 'layout_srl', Context::get('layout_srl'));
header('location:'.$returnUrl);
return;
}
}
/**

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="imageExtension" type="regex" test="/\.(gif|jpg|jpeg|gif|png|swf|flv)$/i" />
</customrules>
<fields>
<field name="user_layout_image['name']" required="true" rule="imageExtension" />
<field name="layout_srl" required="true" rule="number" />
</fields>
</ruleset>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="imageExtension" type="regex" test="/\.(gif|jpg|jpeg|gif|png|swf|flv)$/i" />
</customrules>
<fields>
<field name="user_layout_image['name']" required="true" rule="imageExtension" />
<field name="layout_srl" required="true" rule="number" />
</fields>
</ruleset>

View file

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

View file

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

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="importExtension" type="regex" test="/\.(tar)$/i" />
</customrules>
<fields>
<field name="file['name']" required="true" rule="importExtension" />
<field name="layout_srl" required="true" rule="number" />
</fields>
</ruleset>

View file

@ -1,8 +1,8 @@
<!--%import("filter/insert_layout.xml")-->
<!--#include("header.html")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_layout)">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="insertLayout" action="./" method="post">
<input type="hidden" name="act" value="procLayoutAdminInsert" />
<input type="hidden" name="layout_type" value="{$layout_type}" />
<table cellspacing="0" class="rowTable">

View file

@ -16,7 +16,9 @@
<h4 class="xeAdmin">{$lang->layout_image_repository}</h4>
<p class="summary">{nl2br($lang->about_layout_image_repository)}</p>
<form action="{Context::getRequestUri()}" target="hidden_iframe" method="post" onsubmit="return checkFile(this)" enctype="multipart/form-data">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="imageUpload" action="{Context::getRequestUri()}" method="post" enctype="multipart/form-data">
<input type="hidden" name="module" value="layout" />
<input type="hidden" name="act" value="procLayoutAdminUserImageUpload" />
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
@ -70,7 +72,7 @@
<tr>
<th scope="row"><div>{$lang->layout_import}</div></th>
<td>
<form action="{getUrl('')}" method="post" enctype="multipart/form-data" target="hidden_iframe">
<form ruleset="userLayoutImport" action="{getUrl('')}" method="post" enctype="multipart/form-data">
<input type="hidden" name="module" value="layout" />
<input type="hidden" name="act" value="procLayoutAdminUserLayoutImport" />
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
@ -84,7 +86,7 @@
<!--@end-->
<form id="fo_layout" action="{getUrl('','module','admin')}" method="post">
<form ruleset="codeUpdate" id="fo_layout" action="{getUrl('','module','admin')}" method="post">
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
<input type="hidden" name="act" value="procLayoutAdminCodeUpdate" />
<input type="hidden" name="_filter" value="update_layout_code" />
@ -109,9 +111,11 @@
</tr>
<tr>
<th class="button">
<span class="button black strong"><button type="submit" onclick="this.form.act.value='procLayoutAdminCodeUpdate'">{$lang->cmd_save}</button></span>
<span class="button black strong"><button type="submit">{$lang->cmd_save}</button></span>
<span class="button"><button type="button" onclick="doPreviewLayoutCode();">{$lang->cmd_preview}</button></span>
<span class="button red"><button type="reset" onclick="doResetLayoutCode('{$layout_srl}')">{$lang->cmd_reset}</button></span>
<!--button type="submit" name="act" value="procCommunicationMoveFriend">{$lang->cmd_move}</button>
<button type="submit" name="act" value="procCommunicationDeleteFriend">{$lang->cmd_delete}</button-->
</th>
</tr>
</tbody>

View file

@ -10,7 +10,8 @@
</ul>
</div>
<form id="fo_layout" action="./" method="post" enctype="multipart/form-data" target="hidden_iframe">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="updateLayout" id="fo_layout" action="./" method="post" enctype="multipart/form-data">
<input type="hidden" name="module" value="layout" />
<input type="hidden" name="act" value="procLayoutAdminUpdate" />
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
@ -176,5 +177,6 @@
<a href="{getUrl('act','')}" class="button"><span>{$lang->cmd_back}</span></a>
<!--@end-->
</div>
</form>
<iframe name="hidden_iframe" frameborder="0" style="display:none"></iframe>