From: <gem...@li...> - 2011-10-11 12:25:40
|
Revision: 87 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=87&view=rev Author: matijsdejong Date: 2011-10-11 12:25:29 +0000 (Tue, 11 Oct 2011) Log Message: ----------- Menu reorganized as per ticket #5 Modified Paths: -------------- trunk/library/classes/Gems/Default/ProjectInformationAction.php trunk/library/classes/Gems/Log.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu.php Modified: trunk/library/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-11 11:35:46 UTC (rev 86) +++ trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-11 12:25:29 UTC (rev 87) @@ -54,46 +54,58 @@ $this->html[] = $table; } - public function changelogAction() + protected function _showText($caption, $log_file, $empty_label = null) { - $this->html->h2($this->_('Changelog')); + $this->html->h2($caption); - $log_path = APPLICATION_PATH; - $log_file = $log_path . '/changelog.txt'; - - if ((1 == $this->_getParam(MUtil_Model::REQUEST_ID)) && file_exists($log_file)) { + if ($empty_label && (1 == $this->_getParam(MUtil_Model::REQUEST_ID)) && file_exists($log_file)) { unlink($log_file); } if (file_exists($log_file)) { - $this->html->pre(trim(file_get_contents($log_file)), array('class' => 'logFile')); + $content = trim(file_get_contents($log_file)); + + if ($content) { + $error = false; + } else { + $error = $this->_('empty file'); + } } else { - $this->html->pInfo(sprintf($this->_('No changelog found. Place one in %s.'), $log_file)); + $content = null; + $error = $this->_('file not found'); } - } - public function errorsAction() - { - $this->html->h2($this->_('Logged errors')); + if ($empty_label) { + $buttons = $this->html->buttonDiv(); + if ($error) { + $buttons->actionDisabled($empty_label); + } else { + $buttons->actionLink(array(MUtil_Model::REQUEST_ID => 1), $empty_label); + } + } - $log_path = GEMS_ROOT_DIR . '/var/logs'; - $log_file = $log_path . '/errors.log'; + if ($error) { + $this->html->pre($error, array('class' => 'disabled logFile')); + } else { + $this->html->pre($content, array('class' => 'logFile')); + } - if ((1 == $this->_getParam(MUtil_Model::REQUEST_ID)) && file_exists($log_file)) { - unlink($log_file); + if ($empty_label) { + // Buttons at both bottom and top. + $this->html[] = $buttons; } + } - if (file_exists($log_file)) { - $buttons = $this->html->buttonDiv(); - $buttons->actionLink(array(MUtil_Model::REQUEST_ID => 1), $this->_('Empty logfile')); + public function changelogAction() + { + $this->_showText($this->_('Changelog'), APPLICATION_PATH . '/changelog.txt'); + } - $this->html->pre(trim(file_get_contents($log_file)), array('class' => 'logFile')); + public function errorsAction() + { + $this->logger->shutdown(); - $this->html[] = $buttons; - } else { - $this->html->pInfo($this->_('No logged errors found.')); - $this->html->buttonDiv()->actionDisabled($this->_('Empty logfile')); - } + $this->_showText($this->_('Logged errors'), GEMS_ROOT_DIR . '/var/logs/errors.log', $this->_('Empty logfile')); } public function indexAction() Modified: trunk/library/classes/Gems/Log.php =================================================================== --- trunk/library/classes/Gems/Log.php 2011-10-11 11:35:46 UTC (rev 86) +++ trunk/library/classes/Gems/Log.php 2011-10-11 12:25:29 UTC (rev 87) @@ -3,7 +3,7 @@ /** * Copyright (c) 2011, Erasmus MC * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -25,7 +25,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * @version $Id$ * @package Gems * @subpackage Log @@ -46,7 +46,7 @@ * @var Gems_Log */ private static $_instance = null; - + /** * Returns static instance * @return Gems_Log @@ -56,7 +56,7 @@ if (empty(self::$_instance)) { self::$_instance = new Gems_Log(); } - + return self::$_instance; } @@ -72,17 +72,17 @@ } /** - * Helper method to log exception and (optional) request information + * Helper method to log exception and (optional) request information * @param Exception $exception * @param Zend_Controller_Request_Abstract $request */ public function logError(Exception $exception, Zend_Controller_Request_Abstract $request = null) { $info = array(); - + $info[] = 'Class: ' . get_class($exception); $info[] = 'Message: ' . $this->stripHtml($exception->getMessage()); - + if (($exception instanceof Gems_Exception) && ($text = $exception->getInfo())) { $info[] = 'Info: ' . $this->stripHtml($text); } @@ -98,19 +98,29 @@ $info[] = 'Changed info: ' . $this->stripHtml($text); } } */ - + if (!empty($request)) { $info[] = 'Request Parameters:'; foreach ($request->getParams() as $key => $value) { $info[] = $key . ' => ' . $value; } } - + $info[] = 'Stack trace:'; $info[] = $exception->getTraceAsString(); - + foreach ($info as $line) { $this->log($line, Zend_Log::ERR); } } + + /** + * Closes all writers. + */ + public function shutdown() + { + foreach ($this->_writers as $writer) { + $writer->shutdown(); + } + } } \ No newline at end of file Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-11 11:35:46 UTC (rev 86) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-11 12:25:29 UTC (rev 87) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -37,6 +36,9 @@ */ /** + * Base class for building a menu / button structure where the display of items is dependent + * on both privileges and the availability of parameter information, + * e.g. data to fill an 'id' parameter. * * @package Gems * @subpackage Menu @@ -140,8 +142,25 @@ } /** + * Add a sub item to this item. * - * @param <type> $args_array + * The argumenets can be any of those used for Zend_Navigation_Page as well as some Gems specials.<ul> + * <li>'action' The name of the action.</li> + * <li>'allowed' Is the user allowed to access this menu item. Is checked against ACL using 'privilige'.</li> + * <li>'button_only' Never in the menu, only shown as a button by the program.</li> + * <li>'class' Display class for the menu link.</li> + * <li>'controller' What controller to use.</li> + * <li>'icon' Icon to display with the label.</li> + * <li>'label' The label to display for the menu item.</li> + * <li>'privilege' The privilege needed to choose the item.</li> + * <li>'target' Optional target attribute for the link.</li> + * <li>'type' Optional content type for the link</li> + * <li>'visible' Is the item visible. Is checked against ACL using 'privilige'.</li> + * </ul> + * + * @see Zend_Navigation_Page + * + * @param array $args_array MUtil_Ra::args array with defaults 'visible' and 'allowed' true. * @return Gems_Menu_SubMenuItem */ protected function add($args_array) @@ -198,7 +217,14 @@ return $this->addPage($label, $privilege, $controller, $action, $other); } - public function addMailSetupPage($label) + /** + * Add a Mail menu tree to the menu + * + * @param string $label + * @param array $other + * @return Gems_Menu_SubMenuItem + */ + public function addMailSetupMenu($label) { $setup = $this->addContainer($label); @@ -226,8 +252,7 @@ * @param string $privilege The privilege for the item * @param string $controller What controller to use * @param string $action The name of the action - * @param array $other Array of extra options for this item - * + * @param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only' * @return Gems_Menu_SubMenuItem */ public function addPage($label, $privilege, $controller, $action = 'index', array $other = array()) @@ -260,6 +285,33 @@ return $infoPage; } + /** + * Add pages that show the user technical information about the installation + * in the project. + * + * @param string $label + * @param array $other + * @return Gems_Menu_SubMenuItem + */ + public function addProjectInfoPage($label) + { + $page = $this->addPage($label, 'pr.project-information', 'project-information'); + $page->addAction($this->_('Errors'), null, 'errors'); + $page->addAction($this->_('PHP'), null, 'php'); + $page->addAction($this->_('Project'), null, 'project'); + $page->addAction($this->_('Session'), null, 'session'); + + return $page; + } + + /** + * Add pages that show the user an overview of the tracks / surveys used + * in the project. + * + * @param string $label + * @param array $other + * @return Gems_Menu_SubMenuItem + */ public function addProjectPage($label) { if ($this->escort instanceof Gems_Project_Tracks_SingleTrackInterface) { @@ -300,6 +352,13 @@ return $infoPage; } + /** + * Add a staff browse edit page to the menu, + * + * @param string $label + * @param array $other + * @return Gems_Menu_SubMenuItem + */ public function addStaffPage($label, array $other = array()) { $page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other); @@ -317,6 +376,73 @@ return $page; } + + /** + * Add a Trackbuilder menu tree to the menu + * + * @param string $label + * @param array $other + * @return Gems_Menu_SubMenuItem + */ + public function addTrackBuilderMenu($label, array $other = array()) + { + $setup = $this->addContainer($label); + + // SURVEY SOURCES CONTROLLER + $page = $setup->addBrowsePage($this->_('Survey Sources'), 'pr.source', 'source'); + $page->addDeleteAction(); + $page->addAction($this->_('Check status'), null, 'ping')->addParameters(MUtil_Model::REQUEST_ID); + $page->addAction($this->_('Synchronize surveys'), 'pr.source.synchronize', 'synchronize')->addParameters(MUtil_Model::REQUEST_ID); + $page->addAction($this->_('Check answers'), 'pr.source.check-answers', 'check')->addParameters(MUtil_Model::REQUEST_ID); + $page->addAction($this->_('Synchronize all surveys'), 'pr.source.synchronize-all', 'synchronize-all'); + $page->addAction($this->_('Check all answers'), 'pr.source.check-answers-all', 'check-all'); + + // SURVEY MAINTENANCE CONTROLLER + $page = $setup->addPage($this->_('Surveys'), 'pr.survey-maintenance', 'survey-maintenance'); + $page->addEditAction(); + $page->addShowAction(); + $page->addPdfButton($this->_('PDF'), 'pr.survey-maintenance') + ->addParameters(MUtil_Model::REQUEST_ID) + ->setParameterFilter('gsu_has_pdf', 1); + $page->addAction($this->_('Check answers'), 'pr.survey-maintenance.check', 'check')->addParameters(MUtil_Model::REQUEST_ID); + $page->addAction($this->_('Check all answers'), 'pr.survey-maintenance.check-all', 'check-all'); + + $page->addAutofilterAction(); + + // TRACK MAINTENANCE CONTROLLER + $page = $setup->addBrowsePage($this->_('Tracks'), 'pr.track-maintenance', 'track-maintenance'); + + // Fields + $fpage = $page->addPage($this->_('Fields'), 'pr.track-maintenance', 'track-fields')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track'); + $fpage->addAutofilterAction(); + $fpage->addCreateAction('pr.track-maintenance.create')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track'); + $fpage->addShowAction()->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track', 'fid', 'gtf_id_field'); + $fpage->addEditAction('pr.track-maintenance.edit')->addNamedParameters('fid', 'gtf_id_field', MUtil_Model::REQUEST_ID, 'gtf_id_track'); + + // Standard tracks + $fpage = $page->addPage($this->_('Rounds'), 'pr.track-maintenance', 'track-rounds') + ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track') + ->setParameterFilter('gtr_track_type', 'T'); + $fpage->addAutofilterAction(); + $fpage->addCreateAction('pr.track-maintenance.create')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track'); + $fpage->addShowAction()->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track', Gems_Model::ROUND_ID, 'gro_id_round'); + $fpage->addEditAction('pr.track-maintenance.edit')->addNamedParameters(Gems_Model::ROUND_ID, 'gro_id_round', MUtil_Model::REQUEST_ID, 'gro_id_track'); + + // Single survey tracks + $fpage = $page->addPage($this->_('Round'), 'pr.track-maintenance', 'track-round', 'show') + ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track') + ->setParameterFilter('gtr_track_type', 'S'); + $fpage->addEditAction('pr.track-maintenance.edit') + ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track'); + + $page->addAction($this->_('Check assignments'), 'pr.track-maintenance.check', 'check-track') + ->addParameters(MUtil_Model::REQUEST_ID); + + $page->addAction($this->_('Check all assignments'), 'pr.track-maintenance.check-all', 'check-all'); + + return $setup; + } + public function applyAcl(Zend_Acl $acl, $userRole) { if ($this->_subItems) { Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2011-10-11 11:35:46 UTC (rev 86) +++ trunk/library/classes/Gems/Menu.php 2011-10-11 12:25:29 UTC (rev 87) @@ -163,6 +163,8 @@ { $setup = $this->addContainer($label); + $setup->addProjectInfoPage($this->_('Project setup')); + // DATABASE CONTROLLER $page = $setup->addPage($this->_('Database'), 'pr.database', 'database'); $page->addAutofilterAction(); @@ -183,89 +185,27 @@ } $page->addAction($this->_('Run SQL'), 'pr.database.execute', 'run-sql'); - // PROJECT - $page = $setup->addPage($this->_('Project setup'), 'pr.project-information', 'project-information'); - $page->addAction($this->_('Errors'), null, 'errors'); - $page->addAction($this->_('PHP'), null, 'php'); - $page->addAction($this->_('Project'), null, 'project'); - $page->addAction($this->_('Session'), null, 'session'); + // RECEPTION CODE CONTROLLER + $page->addBrowsePage($this->_('Reception codes'), 'pr.reception', 'reception'); - // COUNTRIES CONTROLLER - // $setup->addBrowsePage($this->_('Countries'), 'pr.country', 'country'); - - // LANGUAGE CONTROLLER - // $setup->addPage($this->_('Languages'), 'pr.language', 'language'); - // CONSENT CONTROLLER - $setup->addBrowsePage($this->_('Consents'), 'pr.consent', 'consent'); + $page->addBrowsePage($this->_('Consents'), 'pr.consent', 'consent'); - // ORGANIZATIONS CONTROLLER - $setup->addBrowsePage($this->_('Organizations'),'pr.organization', 'organization'); - - // GROUPS CONTROLLER - $setup->addBrowsePage($this->_('Groups'), 'pr.group', 'group'); - // ROLES CONTROLLER $page = $setup->addBrowsePage($this->_('Roles'), 'pr.role', 'role'); $page->addAction($this->_('ACL'), null, 'acl'); $page->addAction($this->_('Assigned'), null, 'overview'); $page->addAction($this->_('Privileges'), null, 'privilege'); - // RECEPTION CODE CONTROLLER - $setup->addBrowsePage($this->_('Reception codes'), 'pr.reception', 'reception'); + // GROUPS CONTROLLER + $setup->addBrowsePage($this->_('Groups'), 'pr.group', 'group'); - // SURVEY SOURCES CONTROLLER - $page = $setup->addBrowsePage($this->_('Survey Sources'), 'pr.source', 'source'); - $page->addDeleteAction(); - $page->addAction($this->_('Check status'), null, 'ping')->addParameters(MUtil_Model::REQUEST_ID); - $page->addAction($this->_('Synchronize surveys'), 'pr.source.synchronize', 'synchronize')->addParameters(MUtil_Model::REQUEST_ID); - $page->addAction($this->_('Check answers'), 'pr.source.check-answers', 'check')->addParameters(MUtil_Model::REQUEST_ID); - $page->addAction($this->_('Synchronize all surveys'), 'pr.source.synchronize-all', 'synchronize-all'); - $page->addAction($this->_('Check all answers'), 'pr.source.check-answers-all', 'check-all'); + // ORGANIZATIONS CONTROLLER + $setup->addBrowsePage($this->_('Organizations'),'pr.organization', 'organization'); - // SURVEY MAINTENANCE CONTROLLER - $page = $setup->addPage($this->_('Surveys'), 'pr.survey-maintenance', 'survey-maintenance'); - $page->addEditAction(); - $page->addShowAction(); - $page->addPdfButton($this->_('PDF'), 'pr.survey-maintenance') - ->addParameters(MUtil_Model::REQUEST_ID) - ->setParameterFilter('gsu_has_pdf', 1); - $page->addAction($this->_('Check answers'), 'pr.survey-maintenance.check', 'check')->addParameters(MUtil_Model::REQUEST_ID); - $page->addAction($this->_('Check all answers'), 'pr.survey-maintenance.check-all', 'check-all'); + // STAFF CONTROLLER + $setup->addStaffPage($this->_('Staff')); - $page->addAutofilterAction(); - - // TRACK MAINTENANCE CONTROLLER - $page = $setup->addBrowsePage($this->_('Tracks'), 'pr.track-maintenance', 'track-maintenance'); - - // Fields - $fpage = $page->addPage($this->_('Fields'), 'pr.track-maintenance', 'track-fields')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track'); - $fpage->addAutofilterAction(); - $fpage->addCreateAction('pr.track-maintenance.create')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track'); - $fpage->addShowAction()->addNamedParameters(MUtil_Model::REQUEST_ID, 'gtf_id_track', 'fid', 'gtf_id_field'); - $fpage->addEditAction('pr.track-maintenance.edit')->addNamedParameters('fid', 'gtf_id_field', MUtil_Model::REQUEST_ID, 'gtf_id_track'); - - // Standard tracks - $fpage = $page->addPage($this->_('Rounds'), 'pr.track-maintenance', 'track-rounds') - ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track') - ->setParameterFilter('gtr_track_type', 'T'); - $fpage->addAutofilterAction(); - $fpage->addCreateAction('pr.track-maintenance.create')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track'); - $fpage->addShowAction()->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track', Gems_Model::ROUND_ID, 'gro_id_round'); - $fpage->addEditAction('pr.track-maintenance.edit')->addNamedParameters(Gems_Model::ROUND_ID, 'gro_id_round', MUtil_Model::REQUEST_ID, 'gro_id_track'); - - // Single survey tracks - $fpage = $page->addPage($this->_('Round'), 'pr.track-maintenance', 'track-round', 'show') - ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track') - ->setParameterFilter('gtr_track_type', 'S'); - $fpage->addEditAction('pr.track-maintenance.edit') - ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gro_id_track'); - - $page->addAction($this->_('Check assignments'), 'pr.track-maintenance.check', 'check-track') - ->addParameters(MUtil_Model::REQUEST_ID); - - $page->addAction($this->_('Check all assignments'), 'pr.track-maintenance.check-all', 'check-all'); - // LOG CONTROLLER $page = $setup->addPage($this->_('Logging'), 'pr.log', 'log', 'index'); $page->addAutofilterAction(); @@ -568,27 +508,30 @@ public function loadDefaultMenu() { // MAIN RESPONDENTS ITEM - $this->addRespondentPage($this->escort->_('Respondents')); + $this->addRespondentPage($this->_('Respondents')); // MAIN PLANNING ITEM - $this->addPlanPage($this->escort->_('Overview')); + $this->addPlanPage($this->_('Overview')); // MAIN RESULTS ITEM // $menu->addPage($this->_('Results'), 'pr.result', 'result'); // $menu->addPage($this->_('Invite'), 'pr.invitation', 'invitation'); // PROJECT INFO - $this->addProjectPage($this->escort->_('Project')); + $this->addProjectPage($this->_('Project')); // MAIN STAFF ITEM - $this->addStaffPage($this->escort->_('Staff'), array('order'=>40)); + $this->addStaffPage($this->_('Staff'), array('order'=>40)); // SETUP CONTAINER - $this->addGemsSetupContainer($this->escort->_('Setup')); + $this->addGemsSetupContainer($this->_('Setup')); // MAIL CONTAINER - $this->addMailSetupPage($this->escort->_('Mail')); - + $this->addMailSetupMenu($this->_('Mail')); + + // TRACK BUILDER + $this->addTrackBuilderMenu($this->_('Track Builder')); + // EXPORT DATA $this->addContainer('Export data', 'pr.export', array('controller'=>'export', 'action'=>'index')); @@ -596,7 +539,7 @@ $this->addLogonOffToken(); // CONTACT MENU - $this->addContactPage($this->escort->_('Contact')); + $this->addContactPage($this->_('Contact')); // Privileges not associated with menu item $this->addHiddenPrivilige('pr.plan.choose-org'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |