From 3f92c0c765f985bbdf09b511f2e6289b5a506d1f Mon Sep 17 00:00:00 2001 From: stevetruckstuff Date: Tue, 15 Aug 2006 15:44:31 +0000 Subject: [PATCH] Address book templates git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11592 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/addrbook_popup.php | 25 +-- src/addrbook_search.php | 208 +++--------------- src/addrbook_search_html.php | 163 +++----------- src/addressbook.php | 16 +- templates/default/addrbook_search_list.tpl | 102 +++++++++ templates/default/addressbook_list.tpl | 3 +- templates/default/addressbook_popup.tpl | 33 +++ templates/default/addressbook_search_form.tpl | 82 +++++++ templates/default/stylesheet.tpl | 50 ++++- 9 files changed, 328 insertions(+), 354 deletions(-) create mode 100644 templates/default/addrbook_search_list.tpl create mode 100644 templates/default/addressbook_popup.tpl create mode 100644 templates/default/addressbook_search_form.tpl diff --git a/src/addrbook_popup.php b/src/addrbook_popup.php index 54abdbaf..7a974588 100644 --- a/src/addrbook_popup.php +++ b/src/addrbook_popup.php @@ -17,24 +17,9 @@ */ include('../include/init.php'); -?> - +displayHtmlHeader($org_title .': '. _("AddressBook"), '', false, true); - - - - <?php echo "$org_title: " . _("Address Book"); ?> - - - - - - \ No newline at end of file +$oTemplate->display('addressbook_popup.tpl'); + +$oTemplate->display('footer.tpl'); +?> \ No newline at end of file diff --git a/src/addrbook_search.php b/src/addrbook_search.php index f75abff9..a403ca74 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -1,5 +1,4 @@ - -\n"; - - while (list($undef, $row) = each($res)) { - $email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES); - if ($line % 2) { - $tr_bgcolor = $color[12]; - } else { - $tr_bgcolor = $color[4]; - } - echo html_tag( 'tr', '', '', $tr_bgcolor, 'style="white-space: nowrap;"' ) . - html_tag( 'td', - '"._("To")." | " . - '"._("Cc")." | " . - '"._("Bcc")."", - 'center', '', 'valign="top" width="5%" style="white-space: nowrap;"' ) . - html_tag( 'td', ' ' . htmlspecialchars($row['name']), 'left', '', 'valign="top" style="white-space: nowrap;"' ) . - html_tag( 'td', ' ' . - '" . htmlspecialchars($row['email']) . '' - , 'left', '', 'valign="top"' ) . - html_tag( 'td', htmlspecialchars($row['label']), 'left', '', 'valign="top" style="white-space: nowrap;"' ); - if ($includesource) { - echo html_tag( 'td', ' ' . $row['source'], 'left', '', 'valign="top" style="white-space: nowrap;"' ); - } - - echo "\n"; - $line++; - } - echo ''; + $oTemplate->assign('use_js', true); + $oTemplate->assign('include_abook_name', $includesource); + $oTemplate->assign('addresses', formatAddressList($res)); + + $oTemplate->display('addrbook_search_list.tpl'); } /* ================= End of functions ================= */ @@ -169,30 +60,17 @@ if (! sqgetGlobalVar('backend', $backend, SQ_POST)) { } displayHtmlHeader(); +echo "\n"; /** set correct value of $default_charset */ global $default_charset; set_my_charset(); -/* Choose correct colors for top and bottom frame */ -if ($show == 'form' && !isset($listall)) { - echo ''; -} else { - echo '\n"; -} - /* Empty search */ if (empty($query) && empty($show) && !isset($listall)) { - echo html_tag( 'p', '
' . - _("No persons matching your search were found"), - 'center' ) . - "\n\n"; - exit; + $oTemplate->assign('note', htmlspecialchars(_("No persons matching your search were found"))); + $oTemplate->display('note.tpl'); +# exit; } /* Initialize addressbook, show init errors only in bottom frame */ @@ -201,43 +79,13 @@ $abook = addressbook_init($showerr); /* Create search form (top frame) */ if ($show == 'form' && ! isset($listall)) { - echo '
' . "\n" . - html_tag( 'table', '', '', '', 'border="0" width="100%" height="100%"' ) . - html_tag( 'tr' ) . - html_tag( 'td', ' \n", 'left', '', - 'style="white-space: nowrap;" valign="middle" width="10%"' ) . - html_tag( 'td', '', 'left', '', '' ) . - addInput('query', $query, 28); - - /* List all backends to allow the user to choose where to search */ - if ($abook->numbackends > 1) { - echo ' '."\n"; - $selopts = array(); - $selopts['-1'] = _("All address books"); - - $ret = $abook->get_backend_list(); - while (list($undef,$v) = each($ret)) { - $selopts[$v->bnum] = $v->sname; - } - echo addSelect('backend', $selopts, '-1', TRUE); - } else { - echo addHidden('backend', '-1'); - } - - echo '' . - html_tag( 'tr', - html_tag( 'td', '', 'left' ) . - html_tag( 'td', - '' . - ' | ' . "\n" . - ' | ' . "\n" , - 'left' ) - ) . - '
' . "\n"; + echo "
\n"; + + $oTemplate->assign('use_js', true); + $oTemplate->assign('backends', getBackends()); + $oTemplate->display('addressbook_search_form.tpl'); + + echo "
\n"; } else { /** * List addresses (bottom frame) @@ -257,10 +105,7 @@ if ($show == 'form' && ! isset($listall)) { usort($res,'alistcmp'); display_result($res, false); } else { - echo html_tag( 'p', '' . - sprintf(_("Unable to list addresses from %s"), - $abook->backends[$backend]->sname) . '' , - 'center' ) . "\n"; + plain_error_message(sprintf(_("Unable to list addresses from %s"), $abook->backends[$backend]->sname)); } } else { $res = $abook->list_addr(); @@ -278,14 +123,10 @@ if ($show == 'form' && ! isset($listall)) { } if (!is_array($res)) { - echo html_tag( 'p', '
' . - _("Your search failed with the following error(s)") . - ':
' . nl2br(htmlspecialchars($abook->error)) . "
\n" , - 'center' ); + plain_error_message( _("Your search failed with the following error(s)") .':
'. nl2br(htmlspecialchars($abook->error)) ); } elseif (sizeof($res) == 0) { - echo html_tag( 'p', '
' . - _("No persons matching your search were found") . "\n" , - 'center' ); + $oTemplate->assign('note', _("No persons matching your search were found")); + $oTemplate->display('note.tpl'); } else { display_result($res); } @@ -294,8 +135,9 @@ if ($show == 'form' && ! isset($listall)) { * listall is not set, query is not set or empty. * User hit search button without entering search expression. */ - echo html_tag( 'p', '
' . _("Nothing to search") . "\n",'center' ); + plain_error_message(_("Nothing to search")); } } + $oTemplate->display('footer.tpl'); -?> +?> \ No newline at end of file diff --git a/src/addrbook_search_html.php b/src/addrbook_search_html.php index ac0be560..ec379066 100644 --- a/src/addrbook_search_html.php +++ b/src/addrbook_search_html.php @@ -26,10 +26,11 @@ if (!isset($bInit)) { /** SquirrelMail required files. */ include_once(SM_PATH . 'functions/date.php'); include_once(SM_PATH . 'functions/addressbook.php'); +include_once(SM_PATH . 'templates/util_addressbook.php'); sqgetGlobalVar('session', $session, SQ_POST); sqgetGlobalVar('mailbox', $mailbox, SQ_POST); -if (! sqgetGlobalVar('addrquery', $addrquery, SQ_POST)) +if (! sqgetGlobalVar('query', $addrquery, SQ_POST)) $addrquery=''; sqgetGlobalVar('listall', $listall, SQ_POST); sqgetGlobalVar('backend', $backend, SQ_POST); @@ -66,88 +67,21 @@ function addr_insert_hidden() { function addr_display_result($res, $includesource = true) { global $color, $javascript_on, $PHP_SELF, $squirrelmail_language; + global $oTemplate, $oErrorHandler; + if (sizeof($res) <= 0) return; - echo addForm($PHP_SELF, 'post', 'addrbook'). + echo addForm($PHP_SELF, 'post', 'addressbook'). addHidden('html_addr_search_done', 'true'); addr_insert_hidden(); - $line = 0; - if ($javascript_on) { - print - '\n"; - $chk_all = ''._("All").' '._("To").''. - '  '. - '' . _("All") . ' '._("Cc").''. - '  '. - '' . _("All") . ''; - } else { - // check_all links are used only in JavaScript. disable links in js=off environment. - $chk_all = ''; - } - echo html_tag( 'table', '', 'center', '', 'border="0" width="98%"' ) . - html_tag( 'tr', '', '', $color[9] ) . - html_tag( 'th', ' ' . $chk_all, 'left' ) . - html_tag( 'th', ' ' . _("Name"), 'left' ) . - html_tag( 'th', ' ' . _("E-mail"), 'left' ) . - html_tag( 'th', ' ' . _("Info"), 'left' ); - - if ($includesource) { - echo html_tag( 'th', ' ' . _("Source"), 'left', '', 'width="10%"' ); - } - - echo "\n"; - - foreach ($res as $row) { - $email = AddressBook::full_address($row); - if ($line % 2) { - $tr_bgcolor = $color[12]; - } else { - $tr_bgcolor = $color[4]; - } - - echo html_tag( 'tr', '', '', $tr_bgcolor, 'style="white-space: nowrap;"' ) . - html_tag( 'td', - addCheckBox('send_to_search[T'.$line.']', FALSE, $email). - ' ' . _("To") . ' ' . - addCheckBox('send_to_search[C'.$line.']', FALSE, $email). - ' ' . _("Cc") . ' ' . - addCheckBox('send_to_search[B'.$line.']', FALSE, $email). - ' ' . _("Bcc") . ' ' , - 'center', '', 'width="5%" style="white-space: nowrap;"' ) . - html_tag( 'td', ' ' . htmlspecialchars($row['name']) . ' ', 'left', '', 'style="white-space: nowrap;"' ) . - html_tag( 'td', ' ' . htmlspecialchars($row['email']) . ' ', 'left', '', 'style="white-space: nowrap;"' ) . - html_tag( 'td', ' ' . htmlspecialchars($row['label']) . ' ', 'left', '', 'style="white-space: nowrap;"' ); - - if ($includesource) { - echo html_tag( 'td', ' ' . $row['source'] . ' ', 'left', '', 'style="white-space: nowrap;"' ); - } - echo "\n"; - $line ++; - } - if ($includesource) { $td_colspan = '5'; } else { $td_colspan = '4'; } - echo html_tag( 'tr', - html_tag( 'td', - ' ' . - '', - 'center', '', 'colspan="'. $td_colspan .'"' ) - ) . - '' . - addHidden('html_addr_search_done', '1'). - ''; + $oTemplate->assign('use_js', false); + $oTemplate->assign('include_abook_name', $includesource); + $oTemplate->assign('addresses', formatAddressList($res)); + + $oTemplate->display('addrbook_search_list.tpl'); + + echo ''; } /* --- End functions --- */ @@ -167,49 +101,19 @@ set_my_charset(); $abook = addressbook_init(); -echo '
' . -html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', '' . _("Address Book Search") . '', 'center', $color[0] ) - ) , -'center', '', 'width="95%" cellpadding="2" cellspacing="2" border="0"' ); - - /* Search form */ -echo '
' . - html_tag( 'table', '', 'center', '', 'border="0"' ) . - html_tag( 'tr' ) . - html_tag( 'td', '', 'left', '', 'style="white-space: nowrap;" valign="middle"' ) . "\n" . - addForm($PHP_SELF.'?html_addr_search=true', 'post', 'f'). - "\n
\n" . - ' ' . _("Search for") . "\n"; +echo addForm($PHP_SELF.'?html_addr_search=true', 'post', 'f'); addr_insert_hidden(); -echo addInput('addrquery', $addrquery, 26); - -/* List all backends to allow the user to choose where to search */ -if (!isset($backend)) { $backend = ''; } -if ($abook->numbackends > 1) { - echo '' . _("in") . ' '; - - $selopts['-1'] = _("All address books"); - $ret = $abook->get_backend_list(); - - while (list($undef,$v) = each($ret)) { - $selopts[$v->bnum] = $v->sname; - } - echo addSelect('backend', $selopts, $backend, TRUE); -} else { - echo addHidden('backend', '-1'); -} if (isset($session)) { echo addHidden('session', $session); } -echo '' . - ' | ' . "\n" . - '
' . "\n"; -echo '
'; +$oTemplate->assign('use_js', false); +$oTemplate->assign('backends', getBackends()); + +$oTemplate->display('addressbook_search_form.tpl'); + +echo "\n"; do_hook('addrbook_html_search_below'); /* End search form */ @@ -229,10 +133,7 @@ if ($addrquery == '' || ! empty($listall)) { usort($res,'alistcmp'); addr_display_result($res, false); } else { - echo html_tag( 'p', '
' . - sprintf(_("Unable to list addresses from %s"), - $abook->backends[$backend]->sname) . "
\n" , - 'center' ); + plain_error_message(_("Unable to list addresses from %s"), $abook->backends[$backend]->sname); } } else { @@ -251,27 +152,17 @@ if ($addrquery == '' || ! empty($listall)) { } if (!is_array($res)) { - echo html_tag( 'p', '
' . - _("Your search failed with the following error(s)") . - ':
' . nl2br(htmlspecialchars($abook->error)) . "
\n" , - 'center' ) . "\n"; - $oTemplate->display('footer.tpl'); + plain_error_message(_("Your search failed with the following error(s)") .':
'. nl2br(htmlspecialchars($abook->error))); + } elseif (sizeof($res) == 0) { + $oTemplate->assign('note', _("No persons matching your search were found")); + $oTemplate->display('note.tpl'); } else { - if (sizeof($res) == 0) { - echo html_tag( 'p', '
' . - _("No persons matching your search were found") . "\n" , - 'center' ) . "\n"; - $oTemplate->display('footer.tpl'); - } else { - addr_display_result($res); - } + addr_display_result($res); } } else { // not first time display, not listall and search is empty // TODO: I think, this part of control structure is never reached. - echo html_tag( 'p', '
' . - _("Nothing to search") . "\n" , - 'center' ); + plain_error_message(_("Nothing to search")); } if ($addrquery == '' || sizeof($res) == 0) { @@ -282,5 +173,7 @@ if ($addrquery == '' || sizeof($res) == 0) { '
'; } +echo '
'; + $oTemplate->display('footer.tpl'); ?> \ No newline at end of file diff --git a/src/addressbook.php b/src/addressbook.php index 42f5d2dd..4edf5a72 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -20,6 +20,8 @@ include('../include/init.php'); /** SquirrelMail required files. */ /* address book functions */ require_once(SM_PATH . 'functions/addressbook.php'); +include_once(SM_PATH . 'templates/util_addressbook.php'); + /* form functions */ require_once(SM_PATH . 'functions/forms.php'); @@ -251,19 +253,7 @@ while (list($k, $backend) = each ($abook->backends)) { if ($start >= $count) $start = 0; $alist = array_slice($alist,$start,15); - while(list($undef,$row) = each($alist)) { - $contact = array ( - 'FirstName' => htmlspecialchars($row['firstname']), - 'LastName' => htmlspecialchars($row['lastname']), - 'FullName' => htmlspecialchars($row['name']), - 'NickName' => htmlspecialchars($row['nickname']), - 'Email' => htmlspecialchars($row['email']), - 'FullAddress' => htmlspecialchars($abook->full_address($row)), - 'Info' => htmlspecialchars($row['label']), - 'Extra' => (isset($row['extra']) ? $row['extra'] : NULL), - ); - $a['Addresses'][] = $contact; - } + $a['Addresses'] = formatAddressList($alist); $addresses[$backend->bnum] = $a; } diff --git a/templates/default/addrbook_search_list.tpl b/templates/default/addrbook_search_list.tpl new file mode 100644 index 00000000..d581f499 --- /dev/null +++ b/templates/default/addrbook_search_list.tpl @@ -0,0 +1,102 @@ + + +
+ + + + + + + '. _("Source") .''; + } + ?> + + '."\n"; + } + foreach ($addresses as $index=>$contact) { + ?> + > + + + + + '.$contact['Source'].''."\n"; + } + ?> + + +
'._("Address book is empty").'
+ + | + | + + + value= id=> + value= id=> + value= id=> + +
+'."\n"; + echo ''."\n"; +} +?> +
\ No newline at end of file diff --git a/templates/default/addressbook_list.tpl b/templates/default/addressbook_list.tpl index 0907b71d..cb649602 100644 --- a/templates/default/addressbook_list.tpl +++ b/templates/default/addressbook_list.tpl @@ -31,6 +31,8 @@ * $el['Info'] - Additional info about this contact * $el['Extra'] - Additional field, if provided. NULL if this * field is not provided by the book. + * $el['JSEmail'] - email address scrubbed for use with + * javascript functions. * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License @@ -45,7 +47,6 @@ include_once(SM_PATH . 'templates/util_addressbook.php'); /** extract template variables **/ extract($t); -#echo dump_array($addresses).'
'; /** Begin template **/ $source = $addresses[$current_backend]; $colspan = $abook_has_extra_field ? 6 : 5; diff --git a/templates/default/addressbook_popup.tpl b/templates/default/addressbook_popup.tpl new file mode 100644 index 00000000..5ccad0d5 --- /dev/null +++ b/templates/default/addressbook_popup.tpl @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/templates/default/addressbook_search_form.tpl b/templates/default/addressbook_search_form.tpl new file mode 100644 index 00000000..8f6cb696 --- /dev/null +++ b/templates/default/addressbook_search_form.tpl @@ -0,0 +1,82 @@ + +
+ + + + + + + +
+ +
+ + + + + + + + + +
+ + + + + 1) { + ?> + + + + + +
+ /> +    + /> + +    + /> + +
+
+
\ No newline at end of file diff --git a/templates/default/stylesheet.tpl b/templates/default/stylesheet.tpl index 14dd669e..f26d2552 100644 --- a/templates/default/stylesheet.tpl +++ b/templates/default/stylesheet.tpl @@ -311,7 +311,7 @@ tr.odd { } #addressList input { - font-size: 75%; + font-size: 8pt; } #addressList select { @@ -321,7 +321,7 @@ tr.odd { #addressList table { margin-left: auto; margin-right: auto; - width: 90%; + width: 95%; border: 1px solid ; margin-top: 8px; margin-bottom: 8px; @@ -348,6 +348,8 @@ tr.odd { #addressList td.abookField { border-left: 1px solid ; border-right: 1px solid ; + white-space: nowrap; + overflow: hidden; } #addressList td.colHeader { @@ -362,4 +364,48 @@ tr.odd { #addressList td.abookEmpty { text-align:center; font-weight: bold; +} + +#addressList td.abookCompose { + font-size: 8pt; + white-space: nowrap; +} + +#addrBookSearch { + text-align: center; +} + +#addrBookSearch table { + padding: 0; + border: 0; + margin-left: auto; + margin-right: auto; +} + +#addrBookSearch table.wrapper { + border: 1px solid ; + width: 95%; + margin-left: auto; + margin-right: auto; + padding: 0; +} + +#addrBookSearch td { + padding: 2px; +} + +#addrBookSearch label { + font-weight: bold; +} + +#addrBookSearch input { + font-size: 75%; +} + +#addrBookSearch select { + font-size: 75%; +} + +#addrBookSearch td.buttons { + text-align: center; } \ No newline at end of file -- 2.25.1