Comparing revisions for StructDataAction

Additions:
- Wikka 1.1.6.2 & 1.1.6.3
%%(php)<?php
# displays the results of a selection request
# @version 1.00
# @uses Wakka::ReturnSafeHtml()
$table_css = 'class="wikka" cellpadding="2" cellspacing="1" border="2"';
{ // custom formatting, data validation and hyperlink addition
$name = (isset($n_array[1]) ? (ucwords(strtolower($n_array[1])).' ') : ''). ucwords(strtolower($n_array[0]));
$tooltip = isset($tel) ? 'phone: '. $tel : '';
$tooltip .= (isset($fax) ? ($tooltip ? ' / fax: '. $fax : 'fax: ' .$fax) : '');
$mystr = "<a href='mailto:$email' title='$tooltip'>". $name .'</a>'. ($org != '' ? ' ('.$org.')' : '');
{ // type did not match any custom type : fallback to a standard type
$r1 = '<tr>';
$r2 = '<tr>';
$r1 .= '<th class="comment">'. $name .'</th>';
$mystr .= $r1 .'</tr>'. $r2 .'</tr></table>';
$mystr = '<table '. $table_css .'><tr class="comment"><th>name</th><th>value</th></tr>';
$mystr .= '<tr><td class="comment" align="right">'. $name .'</td><td>'. $value .'</td></tr>';
$mystr .= '</table>';
{ // display the data item
$name = (isset($n_array[3])? $n_array[3].' ' : '').(isset($n_array[1]) ? (ucwords(strtolower($n_array[1])).' '):'').(isset($n_array[2])? $n_array[2].' ': '').ucwords(strtolower($n_array[0])).(isset($n_array[4])? ', '.$n_array[4]: '');
$str = 'BEGIN:VCARD\r\nVERSION:2.1\r\nN:'. $row['n'] .'\r\nFN:'. $name .'\r\n';
$str .= $row['org'] ? 'ORG:'. $row['org'] .'\r\n' : '';
$str .= $row['tel'] ? 'TEL;WORK:'. $row['tel'] .'\r\n' : ''; // by default, tel is shown as work phone
$str .= $row['fax'] ? 'TEL;FAX:'. $row['fax'] .'\r\n' : '';
$str .= $row['email'] ? 'EMAIL;INTERNET:'. $row['email'] .'\r\n' : '';
$str .= 'END:VCARD\r\n';
{ // default scope = page
{ // $rows array row format: ('_wikkapage' => <page tag>, 'type' => <dataitem type>, 'field1' => <val1>, 'field2' => <val2>, ...)
$table_css = 'class="wikka" cellpadding="2" cellspacing="1" border="2"';
case 'ItemTable': // p1 = type of dataitem, p2 = column order list, p3 = scope
$mystr0 = '<table '. $table_css .'><tr class="comment">';
$mystr = $mystr0 .'</tr>'. $mystr. '</table>';
{ // empty table: display nothing
$mystr='';
case 'ToDos': // p1 = this owner only; p2 = this status only
{ // transform all dates into a common format for sorting purposes
$mystr = '<table '. $table_css .'><tr class="comment"><th>owner</th><th>description</th><th>due date</th><th>page link</th></tr>';
$mystr .= '</table>';
case 'Cards': // p1 = this org only; p2 = sort key ; p3 = format (vCard or table)
$mystr ='<form action="'.$thisone->href().'/grabcode" method="post" class="grabcode">
$mystr = '<table '. $table_css .'><tr class="comment"><th>Last name</th><th>Given name</th><th>Email</th><th>Phone</th><th>Fax</th>'. (isset($p2) ? '<th>Organization</th>' : '') .'</tr>';
$mystr .= '</table>';
{ // display one-line help for $req
{ // this is a request: load all relevant data in an associative array: $myrows
{ // order: type, then data
{ // order: data, then type
{ // print the result
Deletions:
- Wikka 1.1.6.2 & 1.1.6.3 & 1.1.6.4
- To achieve the best visual rendering of tables in versions 1.1.6.2 and 1.1.6.3, add the second code block below to the ##css/wikka.css## file
1. New ##actions/structdata.php## file:
%%(php)
<?php
# displays the results of a selection request
# @version 1.01
# @uses Wakka::ReturnSafeHTML()
# @uses Wakka::HasAccess()
# @uses Wakka::UserIsOwner()
function SDformat_hcard_element($eltype, $elvalue)
switch ($eltype)
case 'family-name':
$ret = '<span class="family-name">'. ucwords(strtolower($elvalue)) .'</span>';

case 'given-name':
$ret = '<span class="given-name">'. ucwords(strtolower($elvalue)) .'</span>';

case 'additional-name':
$ret = '<span class="additional-name">'. ucwords(strtolower($elvalue)) .'</span>';

case 'url':
$ret = '<a class="url" href="'. $elvalue. '">%s</a>';

case 'org':
$ret = '<div class="org">'. $elvalue .'</div>';

case 'title':
$ret = '<div class="title">'. $elvalue .'</div>';

case 'note':
$ret = '<div class="note">'. $elvalue .'</div>';

case 'email':
$ret = '<div class="email"><a href="mailto:'. $elvalue. '">'. $elvalue .'</a></div>';

case 'adr':
$adr_array = split(';', $elvalue);
$ret = '<div class="adr"><span class="street-address">'. $adr_array[0] .'</span>'.
((isset($adr_array[1]) && ($adr_array[1]!='')) ? '<span class="locality">'. $adr_array[1] .'</span>': '') .
((isset($adr_array[2]) && ($adr_array[2]!='')) ? '<span class="postal-code">'. $adr_array[2] .'</span>': '') .
((isset($adr_array[3]) && ($adr_array[3]!='')) ? '<span class="region">'. $adr_array[3] .'</span>': '') .
((isset($adr_array[4]) && ($adr_array[4]!='')) ? '<span class="country-name">'. $adr_array[4] .'</span>': '') .
'</div>';

default: // ignore silently
$ret = '';
$table_css = 'class="data" cellpadding="2" cellspacing="1" border="2"';
{ // custom formatting, data validation and hyperlink addition
if ('hCard' == $printmode)
{ // hCard microformat
$lastname = SDformat_hcard_element('family-name', $n_array[0]);
$firstname = isset($n_array[1]) ? SDformat_hcard_element('given-name', $n_array[1]).' ' : '';
$middlename = isset($n_array[2]) ? SDformat_hcard_element('additional-name', $n_array[2]) : '';
$fullname = '<span class="n"><span class="fn">'. $firstname . $lastname .'</span>'. $middlename .'</span>';
$hyperlink = isset($url) ? SDformat_hcard_element('url', $url) : '%s';
$orgname = '';
if (isset($org))
if ($org == $n)
{ // this is an organization's card: merge name and organization
$fullname = str_replace('class="fn"', 'class="fn org"', $fullname);
else
$orgname = SDformat_hcard_element('org', $org);
$phone = isset($tel) ? '<div class="tel"><span class="value">'. $tel .'</span></div>' : '';
$fax = isset($fax) ? '<div class="tel"><span class="type">fax</span> <span class="value">'. $fax .'</span></div>' : '';
$address = isset($adr) ? SDformat_hcard_element('adr', $adr) : '';
$mystr = '<div class="vcard">'. sprintf($hyperlink, $fullname). (isset($title) ? SDformat_hcard_element('title', $title) : '').
$orgname . (isset($email) ? SDformat_hcard_element('email', $email) : ''). $phone . $fax.
$address .(isset($note) ? SDformat_hcard_element('note', $note) : '').'</div>';
}
{ // default print mode
$name = (isset($n_array[1]) ? (ucwords(strtolower($n_array[1])).' ') : ''). ucwords(strtolower($n_array[0]));
$tooltip = isset($tel) ? 'phone: '. $tel : '';
$tooltip .= (isset($fax) ? ($tooltip ? ' / fax: '. $fax : 'fax: ' .$fax) : '');
$mystr = "<a href='mailto:$email' title='$tooltip'>". $name .'</a>'. ($org != '' ? ' ('.$org.')' : '');
{ // type did not match any custom type : fallback to a standard type
echo ($printmode);
$r1 = '<thead><tr>';
$r2 = '<tbody><tr>';
$r1 .= '<th>'. $name .'</th>';
$mystr .= $r1 .'</tr></thead>'. $r2 .'</tr></tbody></table>';
$mystr = '<table '. $table_css .'><thead><tr><th>name</th><th>value</th></tr></thead><tbody>';
$mystr .= '<tr><td align="right">'. $name .'</td><td>'. $value .'</td></tr>';
$mystr .= '</tbody></table>';
{ // display the data item
$name = (isset($n_array[3])? $n_array[3].' ' : '').(isset($n_array[1]) ? (ucwords(strtolower($n_array[1])).' '):'').(isset($n_array[2])? $n_array[2].' ': '').ucwords(strtolower($n_array[0]));
$str = "BEGIN:VCARD\r\nVERSION:2.1\r\nN:". $row['n'] ."\r\nFN:". $name ."\r\n";
$str .= $row['org'] ? 'ORG:'. $row['org'] ."\r\n" : '';
$str .= $row['title'] ? 'TITLE:'. $row['title'] ."\r\n" : '';
$str .= $row['url'] ? 'URL:'. $row['url'] ."\r\n" : '';
$str .= $row['tel'] ? 'TEL:'. $row['tel'] ."\r\n" : '';
$str .= $row['fax'] ? 'TEL;FAX:'. $row['fax'] ."\r\n" : '';
$str .= $row['email'] ? 'EMAIL;INTERNET:'. $row['email'] ."\r\n" : '';
if (isset($row['adr']))
$adr_array = split(';', $row['adr']);
$str .= 'ADR:;;'. $adr_array[0] .';'. (isset($adr_array[1]) ? $adr_array[1] : '') .
';'. (isset($adr_array[3]) ? $adr_array[3] : '') .
';'. (isset($adr_array[2]) ? $adr_array[2] : '') .
';'. (isset($adr_array[4]) ? $adr_array[4] : '') . "\r\n";
$str .= $row['note'] ? 'NOTE:'. $row['note'] ."\r\n" : '';
$str .= "END:VCARD\r\n";
{ // default scope = page
{ // $rows array row format: ('_wikkapage' => <page tag>, 'type' => <dataitem type>, 'field1' => <val1>, 'field2' => <val2>, ...)
$table_css = 'class="data" cellpadding="2" cellspacing="1" border="2"';
case 'ItemTable': // p1 = type of dataitem, p2 = column order list, p3 = scope
$mystr0 = '<table '. $table_css .'><thead><tr>';
$mystr = $mystr0 .'</tr></thead><tbody>'. $mystr. '</tbody></table>';
{ // empty table: display nothing
case 'ToDos': // p1 = this owner only; p2 = this status only
{ // transform all dates into a common format for sorting purposes
$mystr = '<table '. $table_css .'><thead><tr><th>owner</th><th>description</th><th>due date</th><th>page link</th></tr></thead><tbody>';
$mystr .= '</tbody></table>';
case 'Cards': // p1 = this org only; p2 = sort key ; p3 = format (vCard or table)
$mystr ='<form action="'.$thisone->Href().'/grabcode" method="post" class="grabcode">
$mystr = '<table '. $table_css .'><thead><tr><th>Last name</th><th>Given name</th><th>Email</th><th>Phone</th><th>Fax</th>'. (isset($p2) ? '<th>Organization</th>' : '') .'</tr></thead><tbody>';
$mystr .= '</tbody></table>';
{ // display one-line help for $req
{ // this is a request: load all relevant data in an associative array: $myrows
{ // order: type, then data
{ // order: data, then type
{ // print the result
2. [versions 1.1.6.2 & 1.1.6.3 only] Add the following lines to ##css/wikka.css##:
%%(php)
table.data {
border: 2px solid #CCC;
border-collapse: collapse;
border-spacing: 0;
table.data caption {
border: 1px solid #CCC;
font-size: 95%;
color: #666;
margin:5px 0;
padding:2px;
table.data thead {
background-color: #DDD;
table.data tfoot {
background-color: #DDD;
table.data th {
border: 1px solid #CCC;
padding: .1em .25em;
table.data thead th {
background-color: #DDD;
table.data tfoot th {
background-color: #DDD;
table.data tbody th {
background-color: #EEE;
table.data tbody tr:hover {
background-color: #E9E9F9;
table.data tbody tr.alt:hover {
background-color: #E9E9F9;
table.data td {
border: 1px solid #CCC;
padding: .1em .25em;
table.data td.number {
text-align: right;
table.data td.datetime {
text-align: right;
white-space: nowrap;
/* --- alternate row & column color --- */
table.data tr.alt {
background-color: #EEE;
table.data th.c1 {
background-color: #CDD;
table.data th.c2 {
background-color: #DCC;
table.data th.c3 {
background-color: #DDC;
table.data th.c4 {
background-color: #CDC;
table.data th.c5 {
background-color: #CCD;
table.data th.c6 {
background-color: #DCD;
table.data td.c1 {
background-color: #EFF;
table.data td.c2 {
background-color: #FEE;
table.data td.c3 {
background-color: #FFE;
table.data td.c4 {
background-color: #EFE;
table.data td.c5 {
background-color: #EEF;
table.data td.c6 {
background-color: #FEF;
table.data tr.alt td.c1 {
background-color: #DEE;
table.data tr.alt td.c2 {
background-color: #EDD;
table.data tr.alt td.c3 {
background-color: #EED;
table.data tr.alt td.c4 {
background-color: #DED;
table.data tr.alt td.c5 {
background-color: #DDE;
table.data tr.alt td.c6 {
background-color: #EDE;
%%
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki