/** * Look for the available gadgets and put them on the template * * @access public */ function Populate($req_result = '', $onlyMainAction = false) { $default_acl = JAWS_SCRIPT == 'index' ? 'default' : 'default_admin'; $items = $this->GetLayoutItems(); if (!Jaws_Error::IsError($items)) { // temporary store page title/description $title = $this->_Title; $description = $this->_Description; $section = ''; foreach ($items as $item) { $block = 'layout/' . $item['section']; if (!$this->_Template->BlockExists($block)) { continue; } $content = ''; $this->_Template->SetBlock($block); if ($item['gadget'] == '[REQUESTEDGADGET]') { if (JAWS_SCRIPT == 'index') { // increase one level value of heading for requested action $req_result = str_replace(array('<h3>', '</h3>', '<h4>', '</h4>', '<h5>', '</h5>', '<h6>', '</h6>'), array('<h2>', '</h2>', '<h3>', '</h3>', '<h4>', '</h4>', '<h5>', '</h5>'), $req_result); } $item['gadget'] = $GLOBALS['app']->mainGadget; $item['gadget_action'] = $GLOBALS['app']->mainAction; $item['action_params'] = array(); $content = $req_result; } elseif (!$onlyMainAction) { if ($this->IsDisplayable($GLOBALS['app']->mainGadget, $GLOBALS['app']->mainAction, $item['display_when'], $GLOBALS['app']->mainIndex)) { if ($GLOBALS['app']->Session->GetPermission($item['gadget'], $default_acl)) { $item['action_params'] = unserialize($item['action_params']); $content = $this->PutGadget($item['gadget'], $item['gadget_action'], $item['action_params'], $item['action_filename']); } } } if (!empty($content)) { // set gadget,action and first parameter for more customizable view $this->_Template->SetVariable('gadget', strtolower($item['gadget'])); $this->_Template->SetVariable('gadget_action', strtolower($item['gadget'] . '_' . $item['gadget_action'])); if (!empty($item['action_params'])) { $this->_Template->SetVariable('gadget_action_params', strtolower($item['gadget'] . '_' . $item['gadget_action'] . '_' . $item['action_params'][0])); } // set position in section $this->_Template->SetVariable('position', $item['layout_position']); // set action content $this->_Template->SetVariable('ELEMENT', $content . "\n"); } $this->_Template->ParseBlock($block, $ignore = empty($content)); } // restore stored title/description because layout action can't them $this->_Title = $title; $this->_Description = $description; } }