Changeset 4972
- Timestamp:
- 09/04/07 09:59:17 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSimplePageControllerPlugin/README
r4078 r4972 3 3 == Abstract == 4 4 5 This plugin addsenables to work with pages and page areas. You can define areas in your layout template and fill them with arbitrary actions and components.5 This plugin enables to work with pages and page areas. You can define areas in your layout template and fill them with arbitrary actions and components. 6 6 You can turn an action into a page. Be aware that any "page action" is no longer an action (in the symfony way) but a container for child actions/components/partials. 7 Each child can be secured using credentials, see below for an example. 7 8 8 9 … … 62 63 children: 63 64 main: # area name 64 c1 : # child name65 c11: # child name 65 66 module: user 66 action: login # this adds an action by getPresentationFor() to the area67 params: # you can set optional config values here for each action67 action: login # this adds an action by getPresentationFor() to the area 68 params: # you can set optional config values here for each action 68 69 p1: true 70 c12: 71 module: admin 72 component: contextlinks 73 is_secure: on # this child is only displayed if user is authenticated 74 credentials: admin # and only if user has admin credential 69 75 70 76 sidebar: # area name 71 c 1: # child name77 c21: # child name 72 78 module: gadget 73 component: login_about # this adds a component by get_component() to the area 79 component: login_about # this adds a component by get_component() to the area 80 c22: 81 module: tellafriend 82 component: box 83 is_secure: on # this child is only displayed if user is authenticated 74 84 }}} 75 85 plugins/sfSimplePageControllerPlugin/lib/sfSimplePageArea.php
r4318 r4972 39 39 * 40 40 */ 41 public function addAction($label, $moduleName, $actionName, $viewName = null, $ config= array())41 public function addAction($label, $moduleName, $actionName, $viewName = null, $params = array()) 42 42 { 43 43 $this->label($label); … … 48 48 'action' => $actionName, 49 49 'view' => $viewName, 50 ' config' => $config50 'params' => $params 51 51 ); 52 52 53 53 // set config so that we can access it later in the action 54 if (!empty($ config))54 if (!empty($params)) 55 55 { 56 sfConfig::set('sf_simplepage_child_' . $this->areaName . '_' . $label, $ config);56 sfConfig::set('sf_simplepage_child_' . $this->areaName . '_' . $label, $params); 57 57 } 58 58 … … 65 65 * Same parameters like include_component() and get_component() 66 66 */ 67 public function addComponent($label, $moduleName, $componentName, $vars = array() )67 public function addComponent($label, $moduleName, $componentName, $vars = array(), $params = array()) 68 68 { 69 69 $this->label($label); … … 73 73 'module' => $moduleName, 74 74 'component' => $componentName, 75 'vars' => $vars 75 'vars' => $vars, 76 'params' => $params 76 77 ); 78 79 // set config so that we can access it later in the action 80 if (!empty($params)) 81 { 82 sfConfig::set('sf_simplepage_child_' . $this->areaName . '_' . $label, $params); 83 } 77 84 78 85 $this->hasComponent = true; … … 91 98 'type' => self::PARTIAL, 92 99 'template' => $templateName, 93 'vars' => $vars 100 'vars' => $vars, 101 'params' => $params 94 102 ); 103 104 // set config so that we can access it later in the action 105 if (!empty($params)) 106 { 107 sfConfig::set('sf_simplepage_child_' . $this->areaName . '_' . $label, $params); 108 } 95 109 96 110 $this->hasPartial = true; … … 103 117 public function render() 104 118 { 105 if ($this->hasAction) 106 { 107 $context = sfContext::getInstance(); 108 $controller = $context->getController(); 109 } 119 $context = sfContext::getInstance(); 120 $controller = $context->getController(); 121 $user = $context->getUser(); 110 122 111 123 if ($this->hasComponent || $this->hasPartial) … … 120 132 foreach ($this->contents as $label => $part) 121 133 { 134 if ($part['params']['is_secure'] && !$user->isAuthenticated()) 135 { 136 continue; 137 } 138 139 if ($part['params']['credentials'] && !$user->hasCredential($part['params']['credentials'])) 140 { 141 continue; 142 } 143 122 144 sfConfig::set('sf_simplepage_current_child', $label); 123 145 plugins/sfSimplePageControllerPlugin/lib/sfSimplePageConfigHandler.php
r4318 r4972 70 70 } 71 71 72 // check if there are security settings in 'root level' 73 // and put them into 'params' 74 if (isset($conf['is_secure'])) 75 { 76 $conf['params']['is_secure'] = $conf['is_secure']; 77 } 78 79 if (isset($conf['credentials'])) 80 { 81 $conf['params']['credentials'] = $conf['credentials']; 82 } 83 84 // reset security settings if not set yet 85 if (!isset($conf['params']['is_secure'])) 86 { 87 $conf['params']['is_secure'] = false; 88 } 89 90 if (!isset($conf['params']['credentials'])) 91 { 92 $conf['params']['credentials'] = false; 93 } 94 72 95 // template vars 73 96 if (empty($conf['vars'])) … … 85 108 { 86 109 $code[] = "\$area->addComponent('{$childId}', '{$conf['module']}', '{$conf['component']}', " . 87 var_export($conf['vars'], true) . ' );';110 var_export($conf['vars'], true) . ', ' . var_export($conf['params'], true) . ');'; 88 111 } 89 112 elseif (!empty($conf['partial'])) … … 93 116 $conf['partial'] = $conf['module'] . '/' . $conf['partial']; 94 117 } 95 $code[] = "\$area->addPartial('{$childId}', '{$conf['partial']}', " . var_export($conf['vars'], true) . ');'; 118 $code[] = "\$area->addPartial('{$childId}', '{$conf['partial']}', " . 119 var_export($conf['vars'], true) . ', ' . var_export($conf['params'], true) . ');'; 96 120 } 97 121 else