summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-07-08 13:18:27 +0000
committerTed Trask <ttrask01@yahoo.com>2008-07-08 13:18:27 +0000
commit0c011f565a24bffe9065f67fabf5db57b2be80d9 (patch)
tree9a3847695074eb182a97eda979375ac1fbbaa105
parent5ce937b4b015a329f3aec8dc1bf223fb59f2d599 (diff)
downloadacf-core-0c011f565a24bffe9065f67fabf5db57b2be80d9.tar.bz2
acf-core-0c011f565a24bffe9065f67fabf5db57b2be80d9.tar.xz
Added hidden filename field to common filedetails lsp. Modified acf_www-controller to allow views without actions.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1289 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--app/acf_www-controller.lua47
-rw-r--r--app/filedetails-html.lsp1
2 files changed, 31 insertions, 17 deletions
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 06570a7..ce58893 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -117,6 +117,11 @@ local find_view = function ( appdir, prefix, controller, action, viewtype )
return nil
end
+local has_view = function(self)
+ require("fs")
+ return fs.is_file(self.conf.appdir .. self.conf.prefix .. self.conf.controller .. "-" .. self.conf.action .. "-" .. (self.conf.viewtype or "html") .. ".lsp")
+end
+
-- This function is made available within the view to allow loading of components
local dispatch_component = function(str, clientdata, suppress_view)
-- Before we call dispatch, we have to set up conf and clientdata like it was really called for this component
@@ -348,6 +353,7 @@ end
-- Overload the MVC's dispatch function with our own
-- check permissions and redirect if not allowed to see
-- pass more parameters to the view
+-- allow display of views without actions
dispatch = function (self, userprefix, userctlr, useraction)
local controller = nil
local viewtable
@@ -405,27 +411,34 @@ dispatch = function (self, userprefix, userctlr, useraction)
-- If the controller or action are missing, display an error view
if nil == controller then
- origconf.type = "dispatch"
- error (origconf)
+ -- If we have a view w/o an action, just display the view (passing in the clientdata)
+ if (not self.conf.suppress_view) and has_view(self) and check_permission(self, self.conf.controller, self.conf.action) then
+ viewtable = self.clientdata
+ else
+ origconf.type = "dispatch"
+ error (origconf)
+ end
end
- -- run the (first found) pre_exec code, starting at the controller
- -- and moving up the parents
- if type(controller.worker.mvc.pre_exec) == "function" then
- controller.worker.mvc.pre_exec ( controller )
- end
+ if controller then
+ -- run the (first found) pre_exec code, starting at the controller
+ -- and moving up the parents
+ if type(controller.worker.mvc.pre_exec) == "function" then
+ controller.worker.mvc.pre_exec ( controller )
+ end
- -- run the action
- viewtable = controller.worker[self.conf.action](controller)
+ -- run the action
+ viewtable = controller.worker[self.conf.action](controller)
- -- run the post_exec code
- if type(controller.worker.mvc.post_exec) == "function" then
- controller.worker.mvc.post_exec ( controller )
- end
+ -- run the post_exec code
+ if type(controller.worker.mvc.post_exec) == "function" then
+ controller.worker.mvc.post_exec ( controller )
+ end
- -- we're done with the controller, destroy it
- controller:destroy()
- controller = nil
+ -- we're done with the controller, destroy it
+ controller:destroy()
+ controller = nil
+ end
if not self.conf.suppress_view then
local viewfunc, p1, p2, p3 = view_resolver(self)
@@ -468,7 +481,7 @@ end
-- If we've done something, cause a redirect to the referring page (assuming it's different)
-- Also handles retrieving the result of a previously redirected action
redirect_to_referrer = function(self, result)
- if result then
+ if result and not self.conf.component then
-- If we have a result, then we did something, so we might have to redirect
if not ENV.HTTP_REFERER then
-- If no referrer, we have a problem. Can't let it go through, because action
diff --git a/app/filedetails-html.lsp b/app/filedetails-html.lsp
index 9562687..dac4444 100644
--- a/app/filedetails-html.lsp
+++ b/app/filedetails-html.lsp
@@ -20,6 +20,7 @@ displayitem(form.value.mtime)
<? if form.descr then ?><P CLASS='descr'><?= string.gsub(form.descr, "\n", "<BR>") ?></P><? end ?>
<? if form.errtxt then ?><P CLASS='error'><?= string.gsub(form.errtxt, "\n", "<BR>") ?></P><? end ?>
<form action="<?= page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action ?>" method="POST">
+<input type="hidden" name="filename" value="<?= form.value.filename.value ?>">
<textarea name="filecontent">
<?= form.value.filecontent.value ?>
</textarea>