Skip to content

Commit

Permalink
Version 2.6.1
Browse files Browse the repository at this point in the history
New redirection option
  • Loading branch information
ellor1138 committed Aug 27, 2014
1 parent 77d8051 commit f4c693d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Problems or issues with this plugin can be found at https://github.com/ellor1138

## Requirements
##### I have tested this plugin with the following CFWheels frameworks:
* ColdFusion on Wheels 1.3.1
* ColdFusion on Wheels 1.3
* ColdFusion on Wheels 1.1.8

Expand Down
46 changes: 35 additions & 11 deletions localizator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public function init() {
var loc = {};

this.version = "1.1.8,1.3";
this.version = "1.1.8,1.3,1.3.1";

application.localizator = {};
application.localizator = $initLocalizatorPluginSettings();
Expand Down Expand Up @@ -465,6 +465,7 @@
public struct function addTranslation(required struct params) {
var loc = {};

loc.args = {};
loc.form = arguments.params.localizationForm;

if ( !isDefined("loc.form.text") || (isDefined("loc.form.text") && !Len(loc.form.text)) ) {
Expand Down Expand Up @@ -541,14 +542,21 @@

if ( Len(loc.message) ) {
if ( loc.message CONTAINS "already" ) {
flashInsert(message=loc.message, messageType="error");
StructAppend(loc.args, {message=loc.message, messageType="error"});

} else {
flashInsert(message=loc.message, messageType="success");
StructAppend(loc.args, {message=loc.message, messageType="success"});
}
}

redirectTo(back=true);
if ( StructKeyExists(arguments.params, "redirect") ) {
StructAppend(loc.args, arguments.params.redirect);

} else {
StructAppend(loc.args, {back=true});
}

redirectTo(argumentCollection=loc.args);
}

/* -----------------------
Expand Down Expand Up @@ -594,6 +602,7 @@
public struct function updateTranslation(required struct params) {
var loc = {};

loc.args = {};
loc.form = arguments.params.localizationForm;
loc.text = loc.form.text;
loc.isDynamic = $isDynamic(loc.text);
Expand Down Expand Up @@ -667,10 +676,17 @@
}

if ( Len(loc.message) ) {
flashInsert(message=loc.message, messageType="success");
StructAppend(loc.args, {message=loc.message, messageType="success"});
}

if ( StructKeyExists(arguments.params, "redirect") ) {
StructAppend(loc.args, arguments.params.redirect);

} else {
StructAppend(loc.args, {back=true});
}

redirectTo(back=true);
redirectTo(argumentCollection=loc.args);
}

/* ----------------------------------------------------------
Expand All @@ -680,7 +696,8 @@
public struct function deleteTranslation(required struct params) {
var loc = arguments;

loc.database = {};
loc.args = {};
loc.database = {};
loc.file = {};
loc.message = "";

Expand Down Expand Up @@ -767,10 +784,17 @@
}

if ( Len(loc.message) ) {
flashInsert(message=loc.message, messageType="success");
StructAppend(loc.args, {message=loc.message, messageType="success"});
}

if ( StructKeyExists(arguments.params, "redirect") ) {
StructAppend(loc.args, arguments.params.redirect);

} else {
StructAppend(loc.args, {back=true});
}

redirectTo(back=true);
redirectTo(argumentCollection=loc.args);
}

/* ---------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -890,8 +914,8 @@
loc.plugin = {};
loc.plugin.author = "Simon Allard";
loc.plugin.name = "localizator";
loc.plugin.version = "2.6";
loc.plugin.compatibility = "1.1.8, 1.3";
loc.plugin.version = "2.6.1";
loc.plugin.compatibility = "1.1.8, 1.3, 1.3.1";
loc.plugin.project = "https://github.com/ellor1138/Localizator";
loc.plugin.documentation = "https://github.com/ellor1138/Localizator/wiki";
loc.plugin.issues = "https://github.com/ellor1138/Localizator/issues";
Expand Down
55 changes: 55 additions & 0 deletions src/tabs/functions.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@
<div class="tab-pane" id="Functions">
<div class="pad">
<ul class="list-unstyled">
<li>
<div class="alert alert-success alert-sm">
<p><span class="label label-success">New in 2.6.1</span></p>
<p>You can add a "redirect" struct with the addTranslation(), updateTranslation() and deleteTranslation() functions. This will overwrite the default redirectTo(back=true) function. See examples below.</p>
</div>
</li>
<li><b>addTranslation(required struct params)</b>
<div style="margin:10px 0;">
<p>This function will add a translation.</p>

</div>
<dl class="well">
<dt>How to use it in your controller:</dt>
<dd>
public void function add() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params.redirect = {route="route", controller="controller", action="action"};<br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;localizationForm = addTranslation(params);<br>
}
</dd>
</dl>
</li>

<li><b>updateTranslation(required struct params)</b>
<div style="margin:10px 0;">
<p>This function will update a translation.</p>
</div>
<dl class="well">
<dt>How to use it in your controller:</dt>
<dd>
public void function update() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params.redirect = {route="route", controller="controller", action="action"};<br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;localizationForm = updateTranslation(params);<br>
}
</dd>
</dl>
</li>

<li><b>deleteTranslation(required struct params)</b>
<div style="margin:10px 0;">
<p>This function will delete a translation.</p>
</div>
<dl class="well">
<dt>How to use it in your controller:</dt>
<dd>
public void function delete() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params.redirect = {route="route", controller="controller", action="action"};<br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;localizationForm = deleteTranslation(params);<br>
}
</dd>
</dl>
</li>

<li><b>localizatorGetLanguages()</b>
<div style="margin:10px 0;">This function will return a struct that you can use to populate a drop down menu with your language choices.</div>
<dl class="well">
Expand Down
6 changes: 6 additions & 0 deletions src/tabs/log.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<div class="tab-pane" id="Log">
<div class="pad">
<dl class="dl-horizontal">
<dt>Version 2.6.1</dt>
<dd>August 26, 2014
<ul>
<li>Redirection option added to addTranslation(), updateTranslation() and deleteTranslation() functions.</li>
</ul>
</dd>
<dt>Version 2.6</dt>
<dd>August 11, 2014
<ul>
Expand Down

0 comments on commit f4c693d

Please sign in to comment.