Re: [fw-general] Problem by creating a custom router with "fall back" to a "CMS database module"

2008-09-25 Thread berthausmans

I created a controller plugin to "route" the request to the cms controller.
Has someone suggestions to do this with a router.

class My_Controller_Plugin_CmsRouter extends Zend_Controller_Plugin_Abstract
{
/**
 * Routes all (public) request to unknown modules to the standard 
 * Cms module / Page controller
 *
 * @param Zend_Controller_Request_Abstract $request
 */
public function preDispatch (Zend_Controller_Request_Abstract $request)
{
$dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
if (! $dispatcher->isDispatchable($request, $request)) {
$request->setModuleName('cms');
$request->setControllerName('page');
$request->setActionName('index');
}
}
}


berthausmans wrote:
> 
> I'm building a small CMS and i want to create a router to route the
> request to the right module/controller. Below a list with some valid urls:
> 
> # http://www.domain.com/rss/
> module = rss
> controller = index
> action = index
> 
> # http://www.domain.com/system/sitemap/google/
> module = system
> controller = sitemap
> action = google
> 
> # http://www.domain.com/news/archive/
> module = cms
> controller = page
> action = index
> url = /news/archive/
> page_id = 1 (search in database by url)
> (news is no module, if there's a page '(/news/archive/)' available route
> to the cms module)
> 
> #
> http://www.domain.com/news/archive/item/the-item-alias-in-the-database/param2/value2/
> module = cms
> controller = page
> action = index
> url = /news/archive/
> page_id = 1 (search in database by url)
> item = the-item-alias-in-the-database
> param2 = value2
> (news is no module, if there's a page '(/news/archive/)' available route
> to the cms module)
> 
> Is it possible to create a router/route(s) to handle above url's? I've
> already tried a number of implementations, but I have not succeeded.
> 
> Who can help me?
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-by-creating-a-custom-router-with-%22fall-back%22-to-a-%22CMS-database-module%22-tp19646242p19664328.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Problem by creating a custom router with "fall back" to a "CMS database module"

2008-09-24 Thread berthausmans

I'm building a small CMS and i want to create a router to route the request
to the right module/controller. Below a list with some valid urls:

# http://www.domain.com/rss/
module = rss
controller = index
action = index

# http://www.domain.com/system/sitemap/google/
module = system
controller = sitemap
action = google

# http://www.domain.com/news/archive/
module = cms
controller = page
action = index
url = /news/archive/
page_id = 1 (search in database by url)
(news is no module, if there's a page '(/news/archive/)' available route to
the cms module)

#
http://www.domain.com/news/archive/item/the-item-alias-in-the-database/param2/value2/
module = cms
controller = page
action = index
url = /news/archive/
page_id = 1 (search in database by url)
item = the-item-alias-in-the-database
param2 = value2
(news is no module, if there's a page '(/news/archive/)' available route to
the cms module)

Is it possible to create a router/route(s) to handle above url's? I've
already tried a number of implementations, but I have not succeeded.

Who can help me?
-- 
View this message in context: 
http://www.nabble.com/Problem-by-creating-a-custom-router-with-%22fall-back%22-to-a-%22CMS-database-module%22-tp19646242p19646242.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Populate checkboxes (array) in Zend_Form

2008-09-04 Thread berthausmans

I'm building an ACL management form for the user roles in my application. I
saved the application structure (module - controller - action) in the
database. In another table I link the actions to the roles:

Module -< Controller -< Action -< Role_Action >- Role

In the code example below i'm looping all the modules, controllers and
actions. I add all the actions to a fieldbox (SubForm) grouped by module.
When i populate the checkboxes using the code below, nothing happened.

How can i populate my checkboxes using the database data?

 Build the acion selectors 

// Fetch the modules
$modules = $moduleModel->fetchAll();

// Loop all the available modules
foreach ($modules as $module) {
// Create a new subform based on the module
$subFormActions = new Zend_Form_SubForm($module->module_alias);
$subFormActions->setLegend($module->module_name);
$subFormActions->setIsArray(false);

// Fetch the controllers associated with the module
$controllers = $module->findDependentRowset('ControllerModel');

// Loop all the available controllers associated with the module
foreach ($controllers as $controller) {
// Fetch the actions associated with the controller
$actions = $controller->findDependentRowset('ActionModel');

// Loop all the available actions associated with the controller
foreach ($actions as $action) {
// Create a checkbox for the action
$checkbox = new Zend_Form_Element_Checkbox($action->action_id); 
$checkbox->setLabel($module->module_name . ' - ' .
$controller->controller_name . ' - ' . $action->action_name)
 ->setValue($action->action_id)
 ->setBelongsTo('actions')
 ->setChecked(false);

// Add the checkbox the the module subform
$subFormActions->addElement($checkbox);
}
}

// If the module subform contains elements, add it to the form
if ($subFormActions->count() > 0) {
$this->addSubForm($subFormActions, $module->module_alias);
}
}



 Form output ##










etc...



 Populate the form data ###

// Get the actions that are accessible for this role
$actions =
$roleActionModel->fetchAll($roleActionModel->select()->where('role_id = ?',
$item->role_id));
$actionArray = array();
$actionArray['actions'] = array();
foreach ($actions as $action) {
$actionArray['actions'][$action->action_id] = '1';
}
$this->_form->populate($actionArray);

###
-- 
View this message in context: 
http://www.nabble.com/Populate-checkboxes-%28array%29-in-Zend_Form-tp19305101p19305101.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Problem with Zend_Layout and Zend_View_Helper_Action

2008-03-12 Thread berthausmans

I found the problem. Zend_View_Helper_Action disables the ViewRenderer.
-- 
View this message in context: 
http://www.nabble.com/Problem-with-Zend_Layout-and-Zend_View_Helper_Action-tp16002216s16154p16007119.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Problem with Zend_Layout and Zend_View_Helper_Action

2008-03-12 Thread berthausmans

In a certain controller i want to pass content from another module/controller
into the layout script by using the Zend_View_Helper_Action view helper.
After calling "$this->view->action();" in the controller
"$this->layout()->content;" in the view is empty. How is this possible?

# Controller ##
...
$moduleContent = $this->view->action('login', 'index', 'mod_user'); //
Content is correct
$this->view->placeholder('sidebar')->set($moduleContent);
...

# View ##
...

action('index', 'index', 'mod_menu'); // Works fine! ?>



layout()->content; // No content using
"$this->view->action();" in the controller. ?>



placeholder('sidebar'); // Works fine! ?>

...

-- 
View this message in context: 
http://www.nabble.com/Problem-with-Zend_Layout-and-Zend_View_Helper_Action-tp16002216s16154p16002216.html
Sent from the Zend Framework mailing list archive at Nabble.com.