Changeset 202


Ignore:
Timestamp:
Jul 13, 2006 11:24:01 PM (18 years ago)
Author:
scdev
Message:

Q - updated usage of $nav.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/module.cli.php

    r185 r202  
    285285                \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
    286286                \$frm = array_merge(\$frm, getFormData());
    287                 \$nav->addPage(_("Edit %ITEM_TITLE%"));
     287                \$nav->add(_("Edit %ITEM_TITLE%"));
    288288                \$main_template = '%ADMIN_FORM_TEMPLATE%';
    289289                break;
  • trunk/bin/module_maker/skel/admin.php

    r159 r202  
    2828
    2929// Titles and navigation header.
    30 $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']);
     30$nav->add(_("%TITLE%"), null);
    3131
    3232// The object to validate form input.
     
    7474    // Initialize variables for the form template.
    7575    $frm =& addRecordForm();
    76     $nav->addPage(_("Add %ITEM_TITLE%"));
     76    $nav->add(_("Add %ITEM_TITLE%"));
    7777    $main_template = '%ADMIN_FORM_TEMPLATE%';
    7878    break;
     
    8282    // Initialize variables for the form template.
    8383    $frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
    84     $nav->addPage(_("Edit %ITEM_TITLE%"));
     84    $nav->add(_("Edit %ITEM_TITLE%"));
    8585    $main_template = '%ADMIN_FORM_TEMPLATE%';
    8686    break;
     
    111111        $frm =& addRecordForm();
    112112        $frm = array_merge($frm, getFormData());
    113         $nav->addPage(_("Add %ITEM_TITLE%"));
     113        $nav->add(_("Add %ITEM_TITLE%"));
    114114        $main_template = '%ADMIN_FORM_TEMPLATE%';
    115115    } else {
     
    148148        $frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
    149149        $frm = array_merge($frm, getFormData());
    150         $nav->addPage(_("Edit %ITEM_TITLE%"));
     150        $nav->add(_("Edit %ITEM_TITLE%"));
    151151        $main_template = '%ADMIN_FORM_TEMPLATE%';
    152152    } else {%ADMIN_UPLOAD_UPDATE%
  • trunk/bin/module_maker/skel/public.php

    r154 r202  
    1717
    1818// Titles and navigation header.
    19 $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']);
    20 $nav->setFeature(array('title'=>true));
     19$nav->add(sprintf(_("%TITLE%"), null));
     20$nav->setParam(array(
     21    'title' => true,
     22));
    2123
    2224// Instantiate page numbers. Total items are set and calculation is done in the getRecordList function.
     
    5456
    5557    // Set title and main template.
    56     $nav->addPage($item['__///__']);
     58    $nav->add($item['__///__']);
    5759    $main_template = '%PUBLIC_DETAIL_TEMPLATE%';
    5860
  • trunk/docs/example_config.inc.php

    r136 r202  
    9696$css->setFile('codebase/css/admin.inc.css');
    9797
    98 // Nav class for titles, breadcrumbs, and page features.
    99 require_once 'codebase/lib/Nav.inc.php';
    100 $nav = new Nav();
    101 $nav->path_delimiter = ' / ';
    102 $nav->last_crumb_format = '<b>%s</b>';
     98// Global navigation elements object.
     99require_once 'codebase/lib/Navigation.inc.php';
     100$nav = new Navigation(array(
     101    'path_delimiter' => ' / ',
     102    'last_crumb_format' => '<b>%s</b>',
     103));
    103104
    104105?>
  • trunk/lib/App.inc.php

    r201 r202  
    345345        }
    346346        $this->timer->stop('_app');
    347         $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s.', $this->timer->getTime('_app'), $num_queries), LOG_INFO, __FILE__, __LINE__);
     347        $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s.', $this->timer->getTime('_app'), $num_queries), LOG_DEBUG, __FILE__, __LINE__);
    348348    }
    349349
     
    824824        $url = $this->url($url, $carry_args, $always_include_sid);
    825825
     826        // Should we send a "303 See Other" header here instead of relying on the 302 sent automatically by PHP?
    826827        header(sprintf('Location: %s', $url));
    827828        $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    828829
    829         // End this application.
     830        // End application.
    830831        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
    831832        $this->stop();
  • trunk/lib/Lock.inc.php

    r201 r202  
    318318            // Delete specific user's locks.
    319319            $db->query("DELETE FROM " . $db->escapeString($this->getParam('db_table')) . " WHERE set_by_admin_id = '" . $db->escapeString($user_id) . "'");
    320             $app->logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->get('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
     320            $app->logMsg(sprintf('Record locks owned by user %s have been deleted', $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
    321321        } else {
    322322            // Delete ALL locks.
    323323            $db->query("DELETE FROM " . $db->escapeString($this->getParam('db_table')) . "");
    324             $app->logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->get('auth_name'), $this->_auth->get('username')), LOG_DEBUG, __FILE__, __LINE__);
     324            $app->logMsg(sprintf('All record locks deleted by user %s', $this->_auth->get('username')), LOG_DEBUG, __FILE__, __LINE__);
    325325        }
    326326    }
  • trunk/lib/Utilities.inc.php

    r201 r202  
    295295function humanTime($seconds, $max_unit=null, $format='%01.1f')
    296296{
    297     // Units
     297    // Units: array of seconds in the unit, singular and plural unit names.
    298298    $units = array(
    299299        'second' => array(1, _("second"), _("seconds")),
     
    307307    );
    308308   
    309     // Max unit
     309    // Max unit to calculate.
    310310    $max_unit = isset($units[$max_unit]) ? $max_unit : 'decade';
    311311
  • trunk/services/admins.php

    r159 r202  
    2525
    2626// Titles and navigation header.
    27 $nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']);
     27$nav->add(_("Administrators"), null);
    2828
    2929// The object to validate form input.
     
    8686    // Initialize variables for the form template.
    8787    $frm =& addRecordForm();
    88     $nav->addPage(_("Add Admin"));
     88    $nav->add(_("Add Admin"));
    8989    $main_template = 'admin_form.ihtml';
    9090    break;
     
    9393    // Initialize variables for the form template.
    9494    $frm =& editRecordForm(getFormData('admin_id'));
    95     $nav->addPage(_("Edit Admin"));
     95    $nav->add(_("Edit Admin"));
    9696    $main_template = 'admin_form.ihtml';
    9797    break;
     
    120120        $frm =& addRecordForm();
    121121        $frm = array_merge($frm, getFormData());
    122         $nav->addPage(_("Add Admin"));
     122        $nav->add(_("Add Admin"));
    123123        $main_template = 'admin_form.ihtml';
    124124    } else {
     
    156156        $frm =& editRecordForm(getFormData('admin_id'));
    157157        $frm = array_merge($frm, getFormData());
    158         $nav->addPage(_("Edit Admin"));
     158        $nav->add(_("Edit Admin"));
    159159        $main_template = 'admin_form.ihtml';
    160160    } else {
  • trunk/services/lock.php

    r159 r202  
    4242
    4343// Titles and navigation header.
    44 $nav->addPage(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle()));
     44$nav->add(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle()));
    4545
    4646// Templates.
  • trunk/services/login.php

    r147 r202  
    2121        $app->raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);
    2222        $app->dieBoomerangURL('login');
    23         $app->logMsg(sprintf('%s %s successfully logged-in.', $auth->get('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);
     23        $app->logMsg(sprintf('User %s successfully logged-in.', $frm['username']), LOG_INFO, __FILE__, __LINE__);
    2424    } else {
    2525        $app->raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
    26         $app->logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->get('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
     26        $app->logMsg(sprintf('User %s failed login using (MD5ed) password: %s', $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
    2727    }
    2828}
    2929
    3030// Titles and navigation header.
    31 $nav->addPage(_("Login"));
     31$nav->add(_("Login"));
    3232
    3333// Templates.
  • trunk/services/logs.php

    r153 r202  
    4646
    4747// Titles and navigation header.
    48 $nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $tmp_prefs->get('log_file')), '/admin/logs.php');
     48$nav->add(sprintf(_("Viewing log: <em>%s</em>"), $tmp_prefs->get('log_file')), '/admin/logs.php');
    4949
    5050/********************************************************************
  • trunk/services/password.php

    r147 r202  
    1616
    1717// Titles and navigation header.
    18 $nav->addPage(_("Change password"));
     18$nav->add(_("Change password"));
    1919
    2020// The object to validate form input from the user.
  • trunk/services/versions.php

    r159 r202  
    2626
    2727// Titles and navigation header.
    28 $nav->addPage(_("Versions"), $_SERVER['PHP_SELF']);
     28$nav->add(_("Versions"), null);
    2929
    3030/********************************************************************
     
    5959    $data = $version->getData($version_id);
    6060    $versionrecord = $version->getVerson($version_id);
    61     $nav->addPage(sprintf(_("View <em>%s</em> version %s (%s)"), $versionrecord['version_title'], $version_id, $versionrecord['version_datetime']));
     61    $nav->add(sprintf(_("View <em>%s</em> version %s (%s)"), $versionrecord['version_title'], $version_id, $versionrecord['version_datetime']));
    6262    $main_template = 'versions_view.ihtml';
    6363    break;
     
    7070        $app->raiseMsg(sprintf(_("Version <em>%s</em> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);
    7171    }
    72     $nav->addPage(sprintf(_("Difference between version %s (%s) and current record."), $version_id, $versionrecord['version_datetime']));
     72    $nav->add(sprintf(_("Difference between version %s (%s) and current record."), $version_id, $versionrecord['version_datetime']));
    7373    $main_template = 'versions_diff.ihtml';
    7474    break;
     
    9898    $_POST['version_title'] = $versions[0]['version_title'];
    9999    if (is_array($versions) && !empty($versions)) {
    100         $nav->addPage(sprintf(_("%s versions of record <em>%s</em>"), sizeof($versions), $versions[0]['version_title']));
     100        $nav->add(sprintf(_("%s versions of record <em>%s</em>"), sizeof($versions), $versions[0]['version_title']));
    101101        $main_template = 'versions_list.ihtml';
    102102    } else {
  • trunk/tests/NavTest.php

    r42 r202  
    44
    55/**
    6  * PHPUnit test case for Nav
     6 * PHPUnit test case for Navigation
    77 *
    88 * The method skeletons below need to be filled in with
     
    1313 */
    1414require_once 'PHPUnit.php';
    15 class NavTest extends PHPUnit_TestCase {
     15class NavigationTest extends PHPUnit_TestCase {
    1616
    17     var $Nav;
     17    var $Navigation;
    1818
    19     function NavTest($name)
     19    function NavigationTest($name)
    2020    {
    2121        $this->PHPUnit_TestCase($name);
     
    2525    {
    2626        require dirname(__FILE__) . '/_config.inc.php';
    27         require_once '../lib/Nav.inc.php';
    28         $this->Nav =& new Nav(PARAM);
     27        require_once '../lib/Navigation.inc.php';
     28        $this->Navigation =& new Navigation(PARAM);
    2929    }
    3030
    3131    function tearDown()
    3232    {
    33         unset($this->Nav);
     33        unset($this->Navigation);
    3434    }
    3535
    3636    function test_addpage()
    3737    {
    38         $result = $this->Nav->addpage(PARAM);
     38        $result = $this->Navigation->addpage(PARAM);
    3939        $expected = EXPECTED_VAL;
    4040        $this->assertEquals($expected, $result);
     
    4343    function test_setfeature()
    4444    {
    45         $result = $this->Nav->setfeature(PARAM);
     45        $result = $this->Navigation->setfeature(PARAM);
    4646        $expected = EXPECTED_VAL;
    4747        $this->assertEquals($expected, $result);
     
    5050    function test_clearpath()
    5151    {
    52         $result = $this->Nav->clearpath(PARAM);
     52        $result = $this->Navigation->clearpath(PARAM);
    5353        $expected = EXPECTED_VAL;
    5454        $this->assertEquals($expected, $result);
     
    5757    function test_getfeature()
    5858    {
    59         $result = $this->Nav->getfeature(PARAM);
     59        $result = $this->Navigation->getfeature(PARAM);
    6060        $expected = EXPECTED_VAL;
    6161        $this->assertEquals($expected, $result);
     
    6464    function test_gettitle()
    6565    {
    66         $result = $this->Nav->gettitle(PARAM);
     66        $result = $this->Navigation->gettitle(PARAM);
    6767        $expected = EXPECTED_VAL;
    6868        $this->assertEquals($expected, $result);
     
    7171    function test_printtitle()
    7272    {
    73         $result = $this->Nav->printtitle(PARAM);
     73        $result = $this->Navigation->printtitle(PARAM);
    7474        $expected = EXPECTED_VAL;
    7575        $this->assertEquals($expected, $result);
     
    7878    function test_getpath()
    7979    {
    80         $result = $this->Nav->getpath(PARAM);
     80        $result = $this->Navigation->getpath(PARAM);
    8181        $expected = EXPECTED_VAL;
    8282        $this->assertEquals($expected, $result);
     
    8585    function test_printpath()
    8686    {
    87         $result = $this->Nav->printpath(PARAM);
     87        $result = $this->Navigation->printpath(PARAM);
    8888        $expected = EXPECTED_VAL;
    8989        $this->assertEquals($expected, $result);
     
    9292    function test_getbreadcrumbs()
    9393    {
    94         $result = $this->Nav->getbreadcrumbs(PARAM);
     94        $result = $this->Navigation->getbreadcrumbs(PARAM);
    9595        $expected = EXPECTED_VAL;
    9696        $this->assertEquals($expected, $result);
     
    9999    function test_printbreadcrumbs()
    100100    {
    101         $result = $this->Nav->printbreadcrumbs(PARAM);
     101        $result = $this->Navigation->printbreadcrumbs(PARAM);
    102102        $expected = EXPECTED_VAL;
    103103        $this->assertEquals($expected, $result);
     
    106106    function test_currentpage()
    107107    {
    108         $result = $this->Nav->currentpage(PARAM);
     108        $result = $this->Navigation->currentpage(PARAM);
    109109        $expected = EXPECTED_VAL;
    110110        $this->assertEquals($expected, $result);
     
    113113}
    114114// Running the test.
    115 $suite = new PHPUnit_TestSuite('NavTest');
     115$suite = new PHPUnit_TestSuite('NavigationTest');
    116116$result = PHPUnit::run($suite);
    117117echo $result->toString();
Note: See TracChangeset for help on using the changeset viewer.