} else { $events .= '<p>' . i18n::s('No event has been logged') . "</p\\>"; } // display in a separate panel if (trim($events)) { $panels[] = array('events', i18n::s('Events'), 'events_panel', $events); } // // values updated in the background // $values = ''; $query = "SELECT * FROM " . SQL::table_name('values') . " ORDER BY id"; if (!($result = SQL::query($query))) { $values .= Logger::error_pop() . BR . "\n"; } else { $values .= Skin::table_prefix('yc-grid'); while ($row = SQL::fetch($result)) { $values .= '<tr><td>' . $row['id'] . '</td><td>' . str_replace("\n", BR, $row['value']) . '</td><td>' . Surfer::from_GMT($row['edit_date']) . "</td></tr>\n"; } $values .= "</table>\n"; } // display in a separate panel if (trim($values)) { $panels[] = array('values', i18n::s('Values'), 'values_panel', $values); } // // script profiles // $profiles = ''; include_once $context['path_to_root'] . 'agents/profiles.php'; if ($rows = Profiles::list_by_hits(0, 50)) {
/** * list articles as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // start a table $text .= Skin::table_prefix('jive'); // headers $text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header'); // build a list of articles $odd = FALSE; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // one row per article $text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>'; $odd = !$odd; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $text .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // use the title as a link to the page $text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic'); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $text .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $text .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $text .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $text .= ' ' . UPDATED_FLAG; } // add details, if any $details = array(); // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date'])); } } // last update $details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date'])); // add details to the title if (count($details)) { $text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>'; } // display all tags if ($item['tags']) { $text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // next cell for the content $text .= '</td><td width="70%">'; // the content to be displayed $content = ''; // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the introductory text if (is_object($overlay)) { $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } else { $content .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $item); } // the description $content .= Skin::build_block($item['description'], 'description', '', $item['options']); // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // count replies if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span'); } // the command to reply if (Comments::allow_creation($item, $anchor)) { Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span'); } // describe attachments $content .= Skin::finalize_list($details, 'menu_bar'); // end the row $text .= $content . '</td></tr>'; } // end of processing SQL::free($result); // return the table $text .= Skin::table_suffix(); return $text; }
$delete_text = i18n::s('delete this file'); } $menu[] = Skin::build_submit_button(sprintf(i18n::s('Yes, I want to %s'), $delete_text), NULL, NULL, 'confirmed', $class_submit); if (!$render_overlaid) { if (isset($item['id'])) { $menu[] = Skin::build_link(Files::get_permalink($item), i18n::s('Cancel'), 'span'); } } else { $menu[] = '<span><a href="javascript:;" onclick="Yacs.closeModalBox();">' . i18n::s('Cancel') . '</a></span>'; } // the submit button $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // use a table for the layout $context['text'] .= Skin::table_prefix('form'); $lines = 1; // the title if ($item['title']) { $cells = array(i18n::s('Title'), 'left=' . $item['title']); $context['text'] .= Skin::table_row($cells, $lines++); } // the description if ($item['description']) { $cells = array(i18n::s('Description'), 'left=' . $item['description']); $context['text'] .= Skin::table_row($cells, $lines++); } // display the source, if any if ($item['source']) { if (preg_match('/http:\\/\\/([^\\s]+)/', $item['source'], $matches)) { $item['source'] = Skin::build_link($matches[0], $matches[0], 'external');
/** * build one table * * Accept following variants: * - csv - to provide a downloadable csv page * - json - to provide all values in one column * - inline - to render tables within articles * - simple - the legacy fixed table * - sortable - click on column to sort the row * * @param the id of the table to build * @param string the variant to provide - default is 'simple' * @return a displayable string */ public static function build($id, $variant = 'simple') { global $context; // split parameters $attributes = preg_split("/\\s*,\\s*/", $id, 3); $id = $attributes[0]; // get the table object if (!($table = Tables::get($id))) { return NULL; } // do the SELECT statement if (!($rows = SQL::query($table['query']))) { Logger::error(sprintf(i18n::s('Error in table query %s'), $id) . BR . htmlspecialchars($table['query']) . BR . SQL::error()); return NULL; } // build the resulting string $text = ''; switch ($variant) { // produce a table readable into MS-Excel case 'csv': // comma separated values $separator = ","; // one row for the title if ($table['title']) { $label = preg_replace('/\\s/', ' ', $table['title']); // encode to ASCII $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); $text .= '"' . $label . '"'; $text .= "\n"; } // one row for header fields $index = 0; while ($field = SQL::fetch_field($rows)) { if ($index++) { $text .= $separator; } $label = trim(preg_replace('/\\s/', ' ', ucfirst($field->name))); // encode $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); $text .= '"' . $label . '"'; } $text .= "\n"; // process every table row $row_index = 0; while ($row = SQL::fetch($rows)) { // one cell at a time $index = 0; foreach ($row as $name => $value) { // glue cells if ($index++) { $text .= $separator; } // remove HTML tags $value = strip_tags(str_replace('</', ' </', str_replace(BR, ' / ', $value))); // clean spaces $label = trim(preg_replace('/\\s+/', ' ', $value)); // encode $label = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); // make a link if this is a reference if ($index == 1 && $table['with_zoom'] == 'Y') { $label = $context['url_to_home'] . $context['url_to_root'] . $label; } // quote data $text .= '"' . $label . '"'; } // new line $text .= "\n"; } return $text; // a JSON set of values // a JSON set of values case 'json': // get header labels $labels = array(); while ($field = SQL::fetch_field($rows)) { $labels[] = trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name))); } // all items $data = array(); $data['items'] = array(); while ($row = SQL::fetch_row($rows)) { // all rows $datum = array(); $label = FALSE; $index = 0; $link = NULL; foreach ($row as $name => $value) { $index++; // first column is only a link if ($index == 1 && $table['with_zoom'] == 'Y') { $link = $context['url_to_home'] . $context['url_to_root'] . ltrim($value, '/'); continue; } // adjust types to not fool the json encoder if (preg_match('/^(\\+|-){0,1}[0-9]+$/', $value)) { $value = intval($value); } elseif (preg_match('/^(\\+|-){0,1}[0-9\\.,]+$/', $value)) { $value = floatval($value); } elseif (preg_match('/^(true|false)$/i', $value)) { $value = intval($value); } // ensure we have some label for SIMILE Exhibit if (!$label) { $label = $value; } // combine first and second columns if ($index == 2 && $link) { $value = Skin::build_link($link, $value, 'basic'); } // save this value $datum[$labels[$name]] = utf8::to_ascii($value, PRINTABLE_SAFE_ALPHABET); } if ($label && !in_array('label', $labels)) { $datum['label'] = utf8::to_ascii($label, PRINTABLE_SAFE_ALPHABET); } // add a tip, if any $data['items'][] = $datum; } include_once $context['path_to_root'] . 'included/json.php'; $text .= json_encode2($data); return $text; // list of facets for SIMILE Exhibit // list of facets for SIMILE Exhibit case 'json-facets': // columns are actual facets $facets = array(); $index = 0; while ($field = SQL::fetch_field($rows)) { $index++; // first column is only a link if ($index == 1 && $table['with_zoom'] == 'Y') { continue; } // first column has a link if ($index == 2 && $table['with_zoom'] == 'Y') { continue; } // column is a facet $label = '.' . trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name))); $title = trim(str_replace(',', '', ucfirst($field->name))); $facets[] = '<div ex:role="facet" ex:expression="' . $label . '" ex:facetLabel="' . $title . '"></div>'; // only last columns can be faceted if (count($facets) > 7) { array_shift($facets); } } // reverse facet order $facets = array_reverse($facets); // job done $text = join("\n", $facets); return $text; // list of columns for SIMILE Exhibit // list of columns for SIMILE Exhibit case 'json-labels': // get header labels $labels = array(); $index = 0; while ($field = SQL::fetch_field($rows)) { $index++; // first column is only a link if ($index == 1 && $table['with_zoom'] == 'Y') { continue; } // column id $labels[] = '.' . trim(preg_replace('/[^\\w]+/', '', ucfirst($field->name))); // limit the number of columns put on screen if (count($labels) >= 7) { break; } } // job done $text = join(', ', $labels); return $text; // titles of columns for SIMILE Exhibit // titles of columns for SIMILE Exhibit case 'json-titles': // get header labels $labels = array(); $index = 0; while ($field = SQL::fetch_field($rows)) { $index++; // first column is only a link if ($index == 1 && $table['with_zoom'] == 'Y') { continue; } // column header $labels[] = trim(str_replace(',', '', ucfirst($field->name))); } $text = join(', ', $labels); return $text; // produce an HTML table // produce an HTML table default: case 'inline': case 'sortable': // a table with a grid $text .= Skin::table_prefix('grid'); // the title, with a menu to download the table into Excel if ($variant == 'inline') { $item_bar = array(); $item_bar += array(Tables::get_url($id) => $table['title']); $item_bar += array(Tables::get_url($id, 'fetch_as_csv') => 'CSV (Excel)'); if (Surfer::is_associate()) { $item_bar += array(Tables::get_url($id, 'edit') => i18n::s('edit')); } if (count($item_bar)) { $text .= '<caption>' . Skin::build_list($item_bar, 'menu') . "</caption>\n"; } } // column headers are clickable links $cells = array(); $index = 0; while ($field = SQL::fetch_field($rows)) { if ($index++ != 0 || $table['with_zoom'] != 'Y') { $cells[] = ucfirst($field->name); } } $text .= "\t\t" . Skin::table_row($cells, 'sortable'); // the table body $count = 0; $row_index = 0; while ($row = SQL::fetch_row($rows)) { $cells = array(); $link = ''; for ($index = 0; $index < count($row); $index++) { if ($index == 0 && $table['with_zoom'] == 'Y') { $link = $row[$index]; } elseif ($link) { $cells[] = Skin::build_link($link, $row[$index]); $link = ''; } else { $cells[] = $row[$index]; } } $text .= "\t\t" . Skin::table_row($cells, $count++); } $text .= Skin::table_suffix(); return $text; // adapted to open chart flash // adapted to open chart flash case 'chart': // get title for y series $y_title = $y2_title = $y3_title = NULL; $y_index = $y2_index = $y3_index = 0; $index = 0; while ($field = SQL::fetch_field($rows)) { // time will be used for x labels if ($index == 0 && $table['with_zoom'] == 'T') { } elseif ($index == 0 && $table['with_zoom'] == 'Y') { } elseif (!$y_title) { $y_title = '"' . ucfirst($field->name) . '"'; $y_index = $index; } elseif (!$y2_title) { $y2_title = '"' . ucfirst($field->name) . '"'; $y2_index = $index; } elseif (!$y3_title) { $y3_title = '"' . ucfirst($field->name) . '"'; $y3_index = $index; break; } $index++; } // process every table row $x_labels = array(); $y_values = array(); $y2_values = array(); $y3_values = array(); $y_min = $y_max = NULL; $count = 1; while ($row = SQL::fetch($rows)) { // one cell at a time $index = 0; foreach ($row as $name => $value) { // clean spaces $label = trim(preg_replace('/\\s/', ' ', $value)); // encode in iso8859 $label = utf8::to_iso8859($label); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); // quote data if (preg_match('/-*[^0-9\\,\\.]/', $label)) { $label = '"' . $label . '"'; } // x labels if ($index == 0) { if ($table['with_zoom'] == 'T') { array_unshift($x_labels, $label); } else { $x_labels[] = $count++; } // y value } elseif ($index == $y_index) { if ($table['with_zoom'] == 'T') { array_unshift($y_values, $label); } else { $y_values[] = $label; } if (!isset($y_min) || intval($label) < $y_min) { $y_min = intval($label); } if (!isset($y_max) || intval($label) > $y_max) { $y_max = intval($label); } // y2 value } elseif ($index == $y2_index) { if ($table['with_zoom'] == 'T') { array_unshift($y2_values, $label); } else { $y_values[] = $label; } if (!isset($y_min) || intval($label) < $y_min) { $y_min = intval($label); } if (!isset($y_max) || intval($label) > $y_max) { $y_max = intval($label); } // y3 value } elseif ($index == $y3_index) { if ($table['with_zoom'] == 'T') { array_unshift($y3_values, $label); } else { $y_values[] = $label; } if (!isset($y_min) || intval($label) < $y_min) { $y_min = intval($label); } if (!isset($y_max) || intval($label) > $y_max) { $y_max = intval($label); } // we won't process the rest break; } // next column $index++; } } // y minimum if ($y_min > 0) { $y_min = 0; } // y maximum $y_max = strval($y_max); if (strlen($y_max) == 1) { $y_max = 10; } elseif (strlen($y_max) == 2) { $y_max = (intval(substr($y_max, 0, 1)) + 1) * 10; } elseif (strlen($y_max) == 3) { $y_max = (intval(substr($y_max, 0, 2)) + 1) * 10; } else { $y_max = strval(intval(substr($y_max, 0, 2)) + 1) . substr('0000000000000000000000000000000000000000000000000000', 0, strlen($y_max) - 2); } // data series $elements = array(); if (count($y_values)) { $elements[] = '{ "type":"bar_glass", "colour":"#BF3B69", "values": [ ' . join(',', $y_values) . ' ], "text": ' . $y_title . ', "font-size": 12 }'; } if (count($y2_values)) { $elements[] = '{ "type": "line", "width": 1, "colour": "#5E4725", "values": [ ' . join(',', $y2_values) . ' ], "text": ' . $y2_title . ', "font-size": 12 }'; } if (count($y3_values)) { $elements[] = '{ "type":"bar_glass", "colour":"#5E0722", "values": [ ' . join(',', $y3_values) . ' ], "text": ' . $y3_title . ', "font-size": 12 }'; } // the full setup $text = '{ "elements": [ ' . join(',', $elements) . ' ], "x_axis": { "offset": false, "steps": 1, "labels": { "steps": 3, "rotate": 310, "labels": [ ' . join(',', $x_labels) . ' ] } }, "y_axis": { "min": ' . $y_min . ', "max": ' . $y_max . ' } }'; return $text; // first number // first number case 'column': // comma separated values $separator = ","; // process every table row while ($row = SQL::fetch($rows)) { // not always the first column $index = 0; foreach ($row as $name => $value) { $index++; // skip dates and links if ($index == 1 && $table['with_zoom'] != 'N') { continue; } // glue cells if ($text) { $text .= $separator; } // clean spaces $label = trim(preg_replace('/\\s/', ' ', $value)); // encode in iso8859 $label = utf8::to_iso8859($label); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); // quote data if (preg_match('/[^a-zA-Z0-9\\,\\.\\-_]/', $label)) { $text .= '"' . $label . '"'; } else { $text .= $label; } // only first column break; } } return $text; // produce a raw table // produce a raw table case 'raw': // comma separated values $separator = ","; // process every table row while ($row = SQL::fetch($rows)) { // one cell at a time $index = 0; foreach ($row as $name => $value) { // glue cells if ($index++) { $text .= $separator; } // clean spaces $label = trim(preg_replace('/\\s/', ' ', $value)); // encode in iso8859 $label = utf8::to_iso8859($label); // escape quotes to preserve them in the data $label = str_replace('"', '""', $label); // make a link if this is a reference if ($index == 0 && $table['with_zoom'] == 'Y') { $label = $context['url_to_home'] . $context['url_to_root'] . $label; } // quote data if (preg_match('/[^a-zA-Z0-9\\-_]/', $label)) { $text .= '"' . $label . '"'; } else { $text .= $label; } } // new line $text .= "\n"; } return $text; // a simple table // a simple table case 'simple': $text .= Skin::table_prefix('table'); // columns headers $index = 0; while ($field = SQL::fetch_field($rows)) { $cells[] = ucfirst($field->name); } $text .= Skin::table_row($cells, 'header'); // other rows while ($row = SQL::fetch_row($rows)) { $text .= Skin::table_row($row, $count++); } $text .= Skin::table_suffix(); return $text; // xml table // xml table case 'xml': $text = ''; while ($row = SQL::fetch($rows)) { $text .= ' <item>' . "\n"; foreach ($row as $name => $value) { $type = preg_replace('/[^a-z0-9]+/i', '_', $name); if (preg_match('/^[^a-z]/i', $type)) { $type = '_' . $type; } $text .= ' <' . $type . '>' . preg_replace('/&(?!(amp|#\\d+);)/i', '&', utf8::transcode(str_replace(array('left=', 'right='), '', $value))) . '</' . $type . '>' . "\n"; } $text .= ' </item>' . "\n\n"; } return '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<items>' . "\n" . $text . '</items>' . "\n"; } }
// [sections=self] $context['text'] .= '[title]' . i18n::s('Assigned sections') . ' [escape][sections=self] [sections=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][sections.folded=self][/escape]</td>' . '<td>[sections.folded=self]</td></tr>' . Skin::table_suffix(); // [categories] $context['text'] .= '[title]' . i18n::s('Categories') . ' [escape][categories] [categories=category:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][categories][/escape]</td>' . '<td>[categories]</td></tr>' . Skin::table_suffix(); // [categories=self] $context['text'] .= '[title]' . i18n::s('Assigned categories') . ' [escape][categories=self] [categories=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][categories=self][/escape]</td>' . '<td>[categories=self]</td></tr>' . Skin::table_suffix(); // [published] $context['text'] .= '[title]' . i18n::s('Recent pages') . ' [escape][published] [published=section:<id>] [published=category:<id>][/escape][/title]' . '<p>' . i18n::s('Use the simplest form to display a compact list of pages, or limit the scope.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][published.decorated][/escape]</td>' . '<td>[published.decorated]</td></tr>' . Skin::table_suffix(); // [published=self] $context['text'] .= '[title]' . i18n::s('Personal pages') . ' [escape][published=self] [published=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][published=self, 20][/escape]</td>' . '<td>[published=self, 20]</td></tr>' . Skin::table_suffix(); // [updated] $context['text'] .= '[title]' . i18n::s('Recent updates') . ' [escape][updated] [updated=section:<id>] [updated=category:<id>][/escape][/title]' . '<p>' . i18n::s('Use the simplest form to display a compact list of pages, or limit the scope.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][updated.timeline][/escape]</td>' . '<td>[updated.timeline]</td></tr>' . Skin::table_suffix(); // [updated=self] $context['text'] .= '[title]' . i18n::s('Personal updates') . ' [escape][updated=self] [updated=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][updated=self, 12][/escape]</td>' . '<td>[updated=self, 12]</td></tr>' . Skin::table_suffix(); // [read] $context['text'] .= '[title]' . i18n::s('Hall of fame') . ' [escape][read] [read=section:<id>][/escape][/title]' . '<p>' . i18n::s('Use the simplest form to display a compact list of pages, or limit the scope.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][read][/escape]</td>' . '<td>[read]</td></tr>' . Skin::table_suffix(); // [read=self] $context['text'] .= '[title]' . i18n::s('Personal hits') . ' [escape][read=self] [read=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][read=self][/escape]</td>' . '<td>[read=self]</td></tr>' . Skin::table_suffix(); // [voted] $context['text'] .= '[title]' . i18n::s('Hall of fame') . ' [escape][voted] [voted=section:<id>][/escape][/title]' . '<p>' . i18n::s('Use the simplest form to display a compact list of pages, or limit the scope.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][voted][/escape]</td>' . '<td>[voted]</td></tr>' . Skin::table_suffix(); // [voted=self] $context['text'] .= '[title]' . i18n::s('Personal hits') . ' [escape][voted=self] [voted=user:<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][voted=self][/escape]</td>' . '<td>[voted=self]</td></tr>' . Skin::table_suffix(); // [users=present] $context['text'] .= '[title]' . i18n::s('Present users') . ' [escape][users=present][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][users=present][/escape]</td>' . '<td>[users=present]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
// [category.description=id] $context['text'] .= '[title]' . i18n::s('Category') . ' [escape][category.description=<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][category.description=featured][/escape]</td>' . '<td>[category.description=featured]</td></tr>' . Skin::table_suffix(); // [user=id] $context['text'] .= '[title]' . i18n::s('User shortcut') . ' [escape][user=<id>] [user=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . sprintf(i18n::s('Have a look at %s'), '[user='******']') . '[/escape]</td>' . '<td>' . sprintf(i18n::s('Have a look at %s'), '[user='******']') . '</td></tr>' . Skin::table_suffix(); // [server=id] $context['text'] .= '[title]' . i18n::s('Server shortcut') . ' [escape][server=<id>] [server=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('Click to view the page of [server=2, this server]') . '[/escape]</td>' . '<td>' . i18n::s('Click to view the page of [server=2, this server]') . '</td></tr>' . Skin::table_suffix(); // [file=id] $context['text'] .= '[title]' . i18n::s('File shortcut') . ' [escape][file=<id>] [file=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . sprintf(i18n::s('Have a look at %s'), '[file=' . $file_id . ']') . '[/escape]</td>' . '<td>' . sprintf(i18n::s('Have a look at %s'), '[file=' . $file_id . ']') . '</td></tr>' . Skin::table_suffix(); // [download=id] $context['text'] .= '[title]' . i18n::s('Download shortcut') . ' [escape][download=<id>] [download=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . sprintf(i18n::s('Click to %s'), '[download=' . $file_id . ', ' . i18n::s('download the file') . ']') . '[/escape]</td>' . '<td>' . sprintf(i18n::s('Click to %s'), '[download=' . $file_id . ', ' . i18n::s('download the file') . ']') . '</td></tr>' . Skin::table_suffix(); // [clicks=id] $context['text'] .= '[title]' . i18n::s('Member clicks') . ' [escape][clicks=<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][clicks=' . $file_id . '][/escape]</td>' . '<td>[clicks=' . $file_id . ']</td></tr>' . Skin::table_suffix(); // [action=id] $context['text'] .= '[title]' . i18n::s('Action shortcut') . ' [escape][action=<id>] [action=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('Click to view the page of [action=2, this action]') . '[/escape]</td>' . '<td>' . i18n::s('Click to view the page of [action=2, this action]') . '</td></tr>' . Skin::table_suffix(); // [comment=id] $context['text'] .= '[title]' . i18n::s('Comment shortcut') . ' [escape][comment=<id>] [comment=<id>, <label>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('Click to view the page of [comment=2, this comment]') . '[/escape]</td>' . '<td>' . i18n::s('Click to view the page of [comment=2, this comment]') . '</td></tr>' . Skin::table_suffix(); // [script]index.php[/script] $context['text'] .= '[title]' . i18n::s('Script shortcut') . ' [escape][script]<path/script.php>[/script][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('You can access the documentation for the script [script]shared/codes.php[/script]') . '[/escape]</td>' . '<td>' . i18n::s('You can access the documentation for the script [script]shared/codes.php[/script]') . '</td></tr>' . Skin::table_suffix(); // [search=yacs] $context['text'] .= '[title]' . i18n::s('Search') . ' [escape][search] [search=<words>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('All you want to know on [search=yacs]') . '[/escape]</td>' . '<td>' . i18n::s('All you want to know on [search=yacs]') . '</td></tr>' . Skin::table_suffix(); // [wikipedia=keyword, label] $context['text'] .= '[title]' . i18n::s('Wikipedia') . ' [escape][wikipedia=keyword] [wikipedia=keyword, label][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('All you want to know on [wikipedia=Web_2, the web 2.0]') . '[/escape]</td>' . '<td>' . i18n::s('All you want to know on [wikipedia=Web_2, the web 2.0]') . '</td></tr>' . Skin::table_suffix(); // [proxy]url[/proxy] $context['text'] .= '[title]' . i18n::s('Proxy') . ' [escape][proxy]web address[/proxy][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][proxy]http://www.google.com/[/proxy][/escape]</td>' . '<td>[proxy]http://www.google.com/[/proxy]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
// ++...++ $context['text'] .= '[title]' . i18n::s('Wiki insertion') . ' [escape]++...++[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text ++has been inserted++.') . '[/escape]</td>' . '<td>' . i18n::s('This text ++has been inserted++.') . '</td></tr>' . Skin::table_suffix(); // [inserted]...[/inserted] $context['text'] .= '[title]' . i18n::s('Inserted') . ' [escape][inserted]...[/inserted][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text [inserted]has been inserted[/inserted].') . '[/escape]</td>' . '<td>' . i18n::s('This text [inserted]has been inserted[/inserted].') . '</td></tr>' . Skin::table_suffix(); // --...-- $context['text'] .= '[title]' . i18n::s('Wiki deletion') . ' [escape]--...--[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text --has been deleted--.') . '[/escape]</td>' . '<td>' . i18n::s('This text --has been deleted--.') . '</td></tr>' . Skin::table_suffix(); // [deleted]...[/deleted] $context['text'] .= '[title]' . i18n::s('Deleted') . ' [escape][deleted]...[/deleted][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text [deleted]has been deleted[/deleted].') . '[/escape]</td>' . '<td>' . i18n::s('This text [deleted]has been deleted[/deleted].') . '</td></tr>' . Skin::table_suffix(); // [flag]...[/flag] $context['text'] .= '[title]' . i18n::s('Flag') . ' [escape][flag]...[/flag][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('[flag]important![/flag] Don\'t forget to give something to your cat today.') . '[/escape]</td>' . '<td>' . i18n::s('[flag]important![/flag] Don\'t forget to give something to your cat today.') . '</td></tr>' . Skin::table_suffix(); // [lang=xy]...[/lang] $context['text'] .= '[title]' . i18n::s('Language') . ' [escape][lang=xy]...[/lang][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][lang=en]This is in English[/lang][lang=fr]Ceci est en français[/lang][/escape]</td>' . '<td>[lang=en]This is in English[/lang][lang=fr]Ceci est en français[/lang]</td></tr>' . Skin::table_suffix(); // [style=serif]...[/style] $context['text'] .= '[title]' . i18n::s('Serif') . ' [escape][style=serif]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=serif]' . i18n::s('This text is in Serif.') . '[/style][/escape]</td>' . '<td>[style=serif]' . i18n::s('This text is in Serif.') . '[/style]</td></tr>' . Skin::table_suffix(); // [style=sans-serif]...[/style] $context['text'] .= '[title]' . i18n::s('Sans-Serif') . ' [escape][style=sans-serif]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=sans-serif]' . i18n::s('This text is in Sans-Serif.') . '[/style][/escape]</td>' . '<td>[style=sans-serif]' . i18n::s('This text is in Sans-Serif.') . '[/style]</td></tr>' . Skin::table_suffix(); // [style=cursive]...[/style] $context['text'] .= '[title]' . i18n::s('Cursive') . ' [escape][style=cursive]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=cursive]' . i18n::s('This text is in Cursive.') . '[/style][/escape]</td>' . '<td>[style=cursive]' . i18n::s('This text is in Cursive.') . '[/style]</td></tr>' . Skin::table_suffix(); // [style=fantasy]...[/style] $context['text'] .= '[title]' . i18n::s('Fantasy') . ' [escape][style=fantasy]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=fantasy]' . i18n::s('This text is in Fantasy.') . '[/style][/escape]</td>' . '<td>[style=fantasy]' . i18n::s('This text is in Fantasy.') . '[/style]</td></tr>' . Skin::table_suffix(); // [style=comic]...[/style] $context['text'] .= '[title]' . i18n::s('Comic') . ' [escape][style=comic]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=comic]' . i18n::s('This text is in Comic.') . '[/style][/escape]</td>' . '<td>[style=comic]' . i18n::s('This text is in Comic.') . '[/style]</td></tr>' . Skin::table_suffix(); // [style]...[/style] $context['text'] .= '[title]' . i18n::s('Use any style') . ' [escape][style=<style name>]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=my_style]' . i18n::s('But where will this rabbit be in some minutes? I don\'t know, but it depends also on the turtle speed...') . '[/style][/escape]</td>' . '<td>[style=my_style]' . i18n::s('But where will this rabbit be in some minutes? I don\'t know, but it depends also on the turtle speed...') . '[/style]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
$fields[] = array($label, $input); // color of inactive link $label = i18n::s('Link color'); $input = '<input class="color {hash:true,required:false}" name="flexible_tabs_a_color" size="10" value="' . encode_field($context['flexible_tabs_a_color']) . '" maxlength="8" onchange="$(\'div#t_sample a.regular span\').each(function(){$(this).css({ \'color\': this.value})});" />'; $fields[] = array($label, $input); Page::insert_script('$("#t_sample .regular span").each(function(){$(this).css({"color": "' . $context['flexible_tabs_a_color'] . '"});});'); // color of hovered link $label = i18n::s('Hover color'); $input = '<input class="color {hash:true,required:false}" name="flexible_tabs_h_color" size="10" value="' . encode_field($context['flexible_tabs_h_color']) . '" maxlength="8" onchange="$(\'div#t_sample a.current span\').each(function(){$(this).css({ \'color\': this.value})});" />'; $fields[] = array($label, $input); Page::insert_script('$("#t_sample .current span").each(function(){$(this).css({"color": "' . $context['flexible_tabs_h_color'] . '"});});'); // put the set of fields in the page $text .= Skin::build_folded_box(i18n::s('Text'), Skin::build_form($fields)); $fields = array(); // tabs selection $input = Skin::table_prefix('layout'); // use actual images for tabs background if ($dir = Safe::opendir('skins/flexible/tabs')) { // list files in the skin directory $items = array(); while (($item = Safe::readdir($dir)) !== FALSE) { if ($item[0] == '.' || is_dir('../skins/flexible/tabs/' . $item)) { continue; } if (!preg_match('/(\\.gif|\\.jpeg|\\.jpg|\\.png)$/i', $item)) { continue; } if (!($position = strpos($item, '-left'))) { continue; } $name = substr($item, 0, $position);
/** * list articles as slashdot do * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // layout in a table $text = Skin::table_prefix('wide'); // 'even' is used for title rows, 'odd' for detail rows $class_title = 'odd'; $class_detail = 'even'; // build a list of sections $family = ''; include_once $context['path_to_root'] . 'articles/article.php'; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide'); } // document this section $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // permalink $url = Sections::get_permalink($item); // get the anchor $anchor = Anchors::get($item['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n"; // document most recent page here $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // branches of this tree $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); // get last post $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // permalink $url = Articles::get_permalink($article); // get the anchor $anchor = Anchors::get($article['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // signal restricted and private articles if ($article['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($article['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the icon to put aside if ($article['thumbnail_url']) { $icon = $article['thumbnail_url']; } // the icon to put aside if (!$icon && is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>'; } // the introductory text if ($article['introduction']) { $content .= Codes::beautify_introduction($article['introduction']); } elseif (!is_object($overlay)) { $handle = new Article(); $handle->load_by_content($article); $content .= $handle->get_teaser('teaser'); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $article); } // link to description, if any if (trim($article['description'])) { $menu[] = Skin::build_link($url, i18n::s('Read more') . MORE_IMG, 'span', i18n::s('View the page')); } // info on related files if ($count = Files::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // discuss if (Comments::allow_creation($article, $anchor)) { $menu[] = Skin::build_link(Comments::get_url('article:' . $article['id'], 'comment'), i18n::s('Discuss'), 'span'); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $article['anchor'] != $this->focus)) { $menu[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'span', i18n::s('View the section')); } // list up to three categories by title, if any if ($items =& Members::list_categories_by_title_for_member('article:' . $article['id'], 0, 3, 'raw')) { foreach ($items as $id => $attributes) { $menu[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'span'); } } // append a menu $content .= '<p>' . Skin::finalize_list($menu, 'menu') . '</p>'; // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . '<h3 class="top"><span>' . Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')) . '</span></h3>' . '<div class="content">' . $icon . $content . '</div>' . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
// the title of the page $context['page_title'] = i18n::s('Codes to format tables'); // the date of last modification if (Surfer::is_associate()) { $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>'; } // page header $context['text'] .= '<p>' . i18n::s('On this page we are showing how to build simple tables. Use the char |, or tab, or two successive spaces, to separate column elements.') . '</p>'; // add a toc $context['text'] .= "\n" . '[toc]' . "\n"; // [table]...[/table] $context['text'] .= '[title]' . i18n::s('Table') . ' [escape][table]...[/table][/escape][/title]' . '<p>' . i18n::s('In this example cells are separated by tabulation characters or by 2 spaces.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table]' . "\n" . i18n::s('Rabbit') . "\t" . i18n::s('Turtle') . "\n" . i18n::s('Stories') . ' ' . i18n::s('Jean[nl]de la Fontaine') . "\n" . '[/table][/escape]</td>' . '<td>[table]' . "\n" . i18n::s('Rabbit') . "\t" . i18n::s('Turtle') . "\n" . i18n::s('Stories') . ' ' . i18n::s('Jean[nl]de la Fontaine') . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // [table=grid]...[/table] $context['text'] .= '[title]' . i18n::s('Table') . ' [escape][table=grid]...[/table][/escape][/title]' . '<p>' . i18n::s('In this example cells are separated by the | character.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=grid]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table][/escape]</td>' . '<td>[table=grid]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // [table=tiny]...[/table] $context['text'] .= '[title]' . i18n::s('Table') . ' [escape][table=tiny]...[/table][/escape][/title]' . '<p>Actually any style can be applied to the generated table.</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=tiny]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table][/escape]</td>' . '<td>[table=tiny]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // [table]...[body]...[/table] $context['text'] .= '[title]' . i18n::s('Separate headers from the body') . ' [escape][table]...[body]...[/table][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=grid]' . "\n" . i18n::s('First Name|Last Name') . "\n" . '[body]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table][/escape]</td>' . '<td>[table=grid]' . "\n" . i18n::s('First Name|Last Name') . "\n" . '[body]' . "\n" . i18n::s('Rabbit|Turtle') . "\n" . i18n::s('Stories|Jean[nl]de la Fontaine') . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // cells alignment $context['text'] .= '[title]' . i18n::s('Explicit cells alignment') . '[/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=grid]' . "\n" . 'left=' . i18n::s('Full Name') . '| center=' . i18n::s('Birth Year') . '| right=' . i18n::s('Net income') . "\n" . '[body]' . "\n" . 'right=' . i18n::s('Speedy Rabbit') . '|center=1888|$11,230' . "\n" . 'center=' . i18n::s('Jean de la Fontaine') . '|center=1675|$234,567' . "\n" . '[/table][/escape]</td>' . '<td>[table=grid]' . "\n" . 'left=' . i18n::s('Full Name') . '| center=' . i18n::s('Birth Year') . '| right=' . i18n::s('Net income') . "\n" . '[body]' . "\n" . 'right=' . i18n::s('Speedy Rabbit') . '|center=1888|$11,230' . "\n" . 'center=' . i18n::s('Jean de la Fontaine') . '|center=1675|$234,567' . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // [table]...[csv]...[/csv]...[/table] $context['text'] .= '[title]' . i18n::s('Comma-separated values') . ' [escape][table][csv]...[/csv][/table][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=grid]' . "\n" . '[csv]' . "\n" . i18n::s('Net income for the year,$2.310') . "\n" . i18n::s('Net income for last year,$2.100') . "\n" . i18n::s('Net income increase,10%') . "\n" . '[/csv]' . "\n" . '[/table][/escape]</td>' . '<td>[table=grid]' . "\n" . '[csv]' . "\n" . i18n::s('Net income for the year,$2.310') . "\n" . i18n::s('Net income for last year,$2.100') . "\n" . i18n::s('Net income increase,10%') . "\n" . '[/csv]' . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // [table]...[csv=;]...[/csv]...[/table] $context['text'] .= '[title]' . i18n::s('Comma-separated values') . ' [escape][table][csv=;]...[/csv][/table][/escape][/title]' . '<p>' . i18n::s('Using a different separator between cells.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][table=grid]' . "\n" . '[csv=;]' . "\n" . i18n::s('Net income for the year;$2.310') . "\n" . i18n::s('Net income for last year;$2.100') . "\n" . i18n::s('Net income increase;10%') . "\n" . '[/csv]' . "\n" . '[/table][/escape]</td>' . '<td>[table=grid]' . "\n" . '[csv=;]' . "\n" . i18n::s('Net income for the year;$2.310') . "\n" . i18n::s('Net income for last year;$2.100') . "\n" . i18n::s('Net income increase;10%') . "\n" . '[/csv]' . "\n" . '[/table]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
// load localized strings i18n::bind('smileys'); // load the skin load_skin('smileys'); // the path to this page $context['path_bar'] = array('help/' => i18n::s('Help index')); // the title of the page $context['page_title'] = i18n::s('Smileys'); // the date of last modification if (Surfer::is_associate()) { $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>'; } // the splash message $context['text'] .= '<p>' . i18n::s('Smileys are small graphical images that can be used to convey an emotion or feeling. If you have used email or Internet chat, you are likely familiar with the smilie concept.') . '</p>' . '<p>' . i18n::s('Let face it, sometimes words alone do not suffice. Adding a winking smilie, for instance, may help you clarify that you are joking.') . '</p>' . '<p>' . i18n::s('Use your smilies sparingly, though -- if overused, smilies can be downright annoying.') . '</p>' . '<p>' . i18n::s('Here is the list of codes that are automatically converted into images by this server.') . '</p>'; // use a table for the layout $context['text'] .= Skin::table_prefix('grid'); $cells = array(); $cells[] = i18n::s('What to type'); $cells[] = i18n::s('Emotion'); $cells[] = i18n::s('Featured image'); $context['text'] .= Skin::table_row($cells, 'header'); $lines = 2; // 8-) :cool: $cells = array(); $cells[] = '[escape]8-) :cool:[/escape]'; $cells[] = i18n::s('sunglass dude'); $cells[] = '8-)'; $context['text'] .= Skin::table_row($cells, $lines++); // :-) :smile: $cells = array(); $cells[] = '[escape]:-) :smile:[/escape]';
/** * list comments as successive notes in a thread * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $output = ''; // empty list if (!SQL::count($result)) { return $output; } // build a list of comments $rows = array(); include_once $context['path_to_root'] . 'comments/comments.php'; while ($item = SQL::fetch($result)) { // get the anchor $anchor = Anchors::get($item['anchor']); // get poster information $poster = array(); if ($item['create_name']) { if (!($poster = Users::get($item['create_id']))) { $poster['id'] = 0; $poster['full_name'] = $item['create_name']; $poster['email'] = $item['create_address']; } } else { if (!($poster = Users::get($item['edit_id']))) { $poster['id'] = 0; $poster['full_name'] = $item['edit_name']; $poster['email'] = $item['edit_address']; } } // author description $author = ''; // avatar, but not for notifications if ($item['type'] != 'notification' && isset($poster['avatar_url']) && $poster['avatar_url']) { $author .= '<img src="' . $poster['avatar_url'] . '" alt="" title="avatar" class="avatar" />' . BR; } // link to poster, if possible if (isset($poster['id'])) { $author .= Users::get_link($poster['full_name'], $poster['email'], $poster['id']); } // commands to handle this comment $menu = array(); // get an icon for this comment $icon = Comments::get_img($item['type']); // link to comment permalink $label = Skin::build_link(Comments::get_url($item['id']), $icon, 'basic', i18n::s('View this comment')) . ' '; // the creation date if ($item['create_date']) { $label .= Skin::build_date($item['create_date'], 'with_hour'); } else { $label .= Skin::build_date($item['edit_date'], 'with_hour'); } // flag new comments if ($item['create_date'] >= $context['fresh']) { $label .= NEW_FLAG; } $menu[] = $label; // an approval -- can be modified, but not deleted if ($item['type'] == 'approval') { // additional commands for associates and poster and editor if ($anchor->is_owned()) { Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif'); $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic'); } // an automatic notification -- can be deleted, but not modified } elseif ($item['type'] == 'notification') { // additional commands for associates and poster and editor if ($anchor->is_owned()) { Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif'); $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic'); } // regular case } else { // additional commands for associates and poster and editor if (Comments::allow_modification($anchor, $item)) { Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif'); $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic'); Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif'); $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic'); } } // comment main text $text = ''; // state clearly that this is an approval if ($item['type'] == 'approval' && isset($poster['id'])) { $text .= '<p>' . sprintf(i18n::s('%s has provided his approval'), Users::get_link($poster['full_name'], $poster['email'], $poster['id'])) . '</p>'; } // display comment main text $text .= $item['description']; // display signature, but not for notifications if ($item['type'] != 'notification') { $text .= Users::get_signature($item['create_id']); } // format and display $text = ucfirst(trim($text)); // float the menu on the right if (count($menu)) { $text = '<div style="text-align: right">' . Skin::finalize_list($menu, 'menu') . '</div>' . $text; } // comment has been modified if ($item['create_name'] && $item['edit_name'] != $item['create_name']) { $text .= '<p class="details">' . ucfirst(sprintf(i18n::s('edited by %s %s'), $item['edit_name'], Skin::build_date($item['edit_date']))) . '</p>'; } // potential replies to this comment if ($item['type'] != 'notification') { // look for replies if ($replies = Comments::list_next($item['id'], 'replies')) { if (is_array($replies)) { $replies = Skin::build_list($replies, 'compact'); } $text .= '<div>' . $replies . '</div>'; } // allow to reply to this comment if (Comments::allow_creation($anchor)) { // the form to edit a comment $text .= '<form method="post" action="' . $context['url_to_root'] . Comments::get_url($item['id'], 'reply') . '" onsubmit="return validateDocumentPost(this)" enctype="multipart/form-data"><div style="margin-top: 1em;">'; // reference the anchor page $text .= '<input type="hidden" name="anchor" value="' . $item['anchor'] . '" />'; // remember the id of the replied comment $text .= '<input type="hidden" name="previous_id" value="' . $item['id'] . '" />'; // notify watchers $text .= '<input type="hidden" name="notify_watchers" value="Y" />'; // ensure id uniqueness static $fuse_id; if (!isset($fuse_id)) { $fuse_id = 1; } else { $fuse_id++; } // a textarea that grow on focus Page::insert_script('var reply' . $fuse_id . '=1;'); $text .= '<textarea name="description" id="reply' . $fuse_id . '"' . ' rows="1" cols="50"' . ' onfocus="if(reply' . $fuse_id . '){$(\'div#submit' . $fuse_id . '\').slideDown(600);reply' . $fuse_id . '=0;}">' . '</textarea>' . "\n"; // fix number of rows in firefox Page::insert_script('$(function(){' . '$("textarea#reply' . $fuse_id . '")' . '.each(function(){' . 'var lineHeight = parseFloat($(this).css("line-height"));' . 'var lines = $(this).attr("rows")*1 || $(this).prop("rows")*1;' . '$(this).css("height", lines*lineHeight);' . '})' . '.autogrow();' . '});' . "\n"); // the submit button $text .= '<div class="menu_bar" style="display: none;" id="submit' . $fuse_id . '">' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</div>'; // end of the form $text .= '</div></form>'; } } // the main part of the comment, with an id $text = '<td class="comment ' . $item['type'] . '" id="comment_' . $item['id'] . '">' . $text . '</td>'; // this is another row of the output $rows[] = '<td class="author ' . $item['type'] . '">' . $author . '</td>' . $text; } // end of processing SQL::free($result); // sanity check if (!count($rows)) { return ''; } // return a table $output = Skin::table_prefix('yabb'); $count = 1; foreach ($rows as $row) { if ($count % 2) { $output .= '<tr class="odd">' . $row . '</tr>'; } else { $output .= '<tr class="even">' . $row . '</tr>'; } $count++; } $output .= '</table>'; // process yacs codes $output = Codes::beautify($output); return $output; }
} else { Safe::redirect($context['url_to_home'] . $context['url_to_root']); } } // page title $context['page_title'] = i18n::s('Welcome!'); // // panels // $panels = array(); // // main panel // $information = ''; // lay fields in a table $information .= Skin::table_prefix('form'); $lines = 1; // a link to the user profile $cells = array(); $cells[] = i18n::s('Your profile'); $cells[] = 'left=' . Surfer::get_link(); $information .= Skin::table_row($cells, $lines++); // the email field if (Surfer::get_email_address()) { $cells = array(); $cells[] = i18n::s('Your address'); $cells[] = 'left=' . Surfer::get_email_address(); $information .= Skin::table_row($cells, $lines++); } // the capability field - associate, member, or subscriber $cells = array();
// the date of last modification if (Surfer::is_associate()) { $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>'; } // page header $context['text'] .= '<p>' . i18n::s('On this page we are introducing codes related to widgets and badges.') . '</p>'; // add a toc $context['text'] .= "\n" . '[toc]' . "\n"; // [newsfeed] $context['text'] .= '[title]' . i18n::s('Newsfeed') . ' [escape][newsfeed=<url>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][newsfeed=http://www.yacs.fr/feeds/rss.php][/escape]</td>' . '<td>[newsfeed=http://www.yacs.fr/feeds/rss.php]</td></tr>' . Skin::table_suffix(); // [newsfeed.embed] $context['text'] .= '[title]' . i18n::s('Newsfeed') . ' [escape][newsfeed.embed=<url>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][newsfeed.embed=http://www.yacs.fr/feeds/rss.php][/escape]</td>' . '<td>[newsfeed.embed=http://www.yacs.fr/feeds/rss.php]</td></tr>' . Skin::table_suffix(); // [twitter] $context['text'] .= '[title]' . i18n::s('Twitter profile') . ' [escape][twitter=<id>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][twitter=bernard357][/escape]</td>' . '<td>[twitter=bernard357]</td></tr>' . Skin::table_suffix(); // [tsearch] $context['text'] .= '[title]' . i18n::s('Twitter search') . ' [escape][tsearch=<keyword>][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][tsearch=#yacs][/escape]</td>' . '<td>[tsearch=#yacs]</td></tr>' . Skin::table_suffix(); // [iframe] $context['text'] .= '[title]' . i18n::s('External page') . ' [escape][iframe=<width>, <height>]<url>[/iframe][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][iframe=500, 320]http://www.cisco.com/[/iframe][/escape]</td>' . '<td>[iframe=500, 320]http://www.cisco.com/[/iframe]</td></tr>' . Skin::table_suffix(); // [cloud] $context['text'] .= '[title]' . i18n::s('Cloud of tags') . ' [escape][cloud] [cloud=<40>][/escape][/title]' . '<p>' . i18n::s('Use the parameter to adjust the number of tags listed.') . '</p>' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][cloud][/escape]</td>' . '<td>[cloud]</td></tr>' . Skin::table_suffix(); // [calendar] $context['text'] .= '[title]' . i18n::s('Events') . ' [escape][calendar][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][calendar][/escape]</td>' . '<td>[calendar]</td></tr>' . Skin::table_suffix(); // [location=latitude, longitude, label] $context['text'] .= '[title]' . i18n::s('Direct location') . ' [escape][location=latitude, longitude, label][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][location=48.871264, 2.307558, Paris][/escape]</td>' . '<td>[location=48.871264, 2.307558, Paris]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
/** * render a table * * @param string the table content * @param string the variant, if any * @return string the rendered text **/ public static function render_static_table($content, $variant = '') { global $context; // we are providing inline tables if ($variant) { $variant = 'inline ' . $variant; } else { $variant = 'inline'; } // do we have headers to proceed? $in_body = !preg_match('/\\[body\\]/i', $content); // start at first line, except if headers have to be printed first if ($in_body) { $count = 1; } else { $count = 2; } // split lines $rows = explode("\n", $content); if (!is_array($rows)) { return ''; } // one row per line - cells are separated by |, \t, or 2 spaces $text =& Skin::table_prefix($variant); foreach ($rows as $row) { // skip blank lines if (!$row) { continue; } // header row if (!$in_body) { if (preg_match('/\\[body\\]/i', $row)) { $in_body = true; } else { $text .= Skin::table_row(preg_split("/([\\|\t]| " . " )/", $row), 'header'); } // body row } else { $text .= Skin::table_row(preg_split("/([\\|\t]| " . " )/", $row), $count++); } } // return the complete table $text .= Skin::table_suffix(); return $text; }
/** * count related items * * This function draws a nice table to show how many items are related to * the anchor that has the focus. * * @param string the target reference * @param string the label to use, if any * @return string some XHTML snippet to send to the browser */ public static function stat_related_to($anchor, $label = NULL) { global $context; // describe related content $related = ''; $lines = 2; // stats for related categories, but only within categories if (strpos($anchor, 'category:') === 0) { if (($stats = Categories::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Categories'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related sections, but only within sections if (strpos($anchor, 'section:') === 0) { if (($stats = Sections::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Sections'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related articles, but only within sections if (strpos($anchor, 'section:') === 0) { if (($stats = Articles::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Pages'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related images include_once $context['path_to_root'] . 'images/images.php'; if (($stats = Images::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Images'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related locations include_once $context['path_to_root'] . 'locations/locations.php'; if (($stats = Locations::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Locations'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related tables include_once $context['path_to_root'] . 'tables/tables.php'; if (($stats = Tables::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Tables'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related files if (($stats = Files::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Files'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related dates include_once $context['path_to_root'] . 'dates/dates.php'; if (($stats = Dates::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Dates'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related comments include_once $context['path_to_root'] . 'comments/comments.php'; if (($stats = Comments::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Comments'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related links include_once $context['path_to_root'] . 'links/links.php'; if (($stats = Links::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Links'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related versions include_once $context['path_to_root'] . 'versions/versions.php'; if (($stats = Versions::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Versions'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // ensure we have a label if (!$label) { $label = i18n::s('Following items are attached to this record and will be impacted as well.'); } // stats for related items in a neat table if ($related) { // make a nice table $related = '<p>' . $label . "</p>\n" . Skin::table_prefix('') . Skin::table_row(array(i18n::s('Table'), i18n::s('Records'), i18n::s('Creation date'), i18n::s('Last edition')), 'header') . $related . Skin::table_suffix(); // put it in a box $related = Skin::build_box(i18n::s('Related items'), $related); } // job done return $related; }
// the title of the page $context['page_title'] = i18n::s('Codes to format lists'); // the date of last modification if (Surfer::is_associate()) { $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>'; } // page header $context['text'] .= '<p>' . i18n::s('On this page we are introducing some formatting codes and live examples of utilization.') . '</p>'; // add a toc $context['text'] .= "\n" . '[toc]' . "\n"; // [*] $context['text'] .= '[title]' . i18n::s('List item') . ' [escape][*][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('A simple list:') . "\n\n" . '[*]' . i18n::s('First item') . "\n\n" . '[*]' . i18n::s('Second item (after one empty line)') . "\n" . '[*]' . i18n::s('Third item (next the previous one)') . '[/escape]</td>' . '<td>' . i18n::s('A simple list:') . "\n\n" . '[*]' . i18n::s('First item') . "\n\n" . '[*]' . i18n::s('Second item (after one empty line)') . "\n" . '[*]' . i18n::s('Third item (next the previous one)') . '</td></tr>' . Skin::table_suffix(); // [list]...[/list] $context['text'] .= '[title]' . i18n::s('Bulleted list') . ' [escape][list]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('A list with bulleted items:') . "\n" . '[list]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('A list with bulleted items:') . "\n" . '[list]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // [list=1]...[/list] $context['text'] .= '[title]' . i18n::s('Numbered list') . ' [escape][list=1]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('A list with numbered items:') . "\n" . '[list=1]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('A list with numbered items:') . "\n" . '[list=1]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // [list=a]...[/list] $context['text'] .= '[title]' . i18n::s('Numbered list') . ' [escape][list=a]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('A list with alphabetically numbered items:') . "\n" . '[list=a]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('A list with alphabetically numbered items:') . "\n" . '[list=a]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // [list=A]...[/list] $context['text'] .= '[title]' . i18n::s('Numbered list') . ' [escape][list=A]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('Another list with alphabetically numbered items:') . "\n" . '[list=A]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('Another list with alphabetically numbered items:') . "\n" . '[list=A]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // [list=i]...[/list] $context['text'] .= '[title]' . i18n::s('Numbered list') . ' [escape][list=i]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('A list with roman numbers:') . "\n" . '[list=i]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('A list with roman numbers:') . "\n" . '[list=i]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // [list=I]...[/list] $context['text'] .= '[title]' . i18n::s('Numbered list') . ' [escape][list=I]...[/list][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('Another list with roman numbers:') . "\n" . '[list=I]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list][/escape]</td>' . '<td>' . i18n::s('Another list with roman numbers:') . "\n" . '[list=I]' . "\n" . '[*]' . i18n::s('First item') . "\n" . '[*]' . i18n::s('Second item') . "\n" . '[/list]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
/** * build a complete table * * @param array headers * @param array rows of cells * @param string a variant, if any, as decribed for table_prefix() * @return a string to be sent to the browser */ public static function &table($headers, &$rows, $variant = 'yc-grid') { $text =& Skin::table_prefix($variant); if (isset($headers) && is_array($headers)) { $text .= Skin::table_row($headers, 'sortable'); } $row_count = 1; if (is_array($rows)) { foreach ($rows as $cells) { $text .= Skin::table_row($cells, $row_count++); } } $text .= Skin::table_suffix(); return $text; }
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // output as a string $text = ''; // build a list of sections $family = ''; $first = TRUE; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // close last table only if a section has been already listed if (!$first) { $text .= Skin::table_suffix(); } // show the family $text .= '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } elseif ($first) { $text .= Skin::table_prefix('yabb'); $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } // done with this case $first = FALSE; // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title as a link to the page $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover); // also use a clickable thumbnail, if any if ($item['thumbnail_url']) { $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix; } // flag sections updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix = EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix = NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix = UPDATED_FLAG . ' '; } // board introduction if ($item['introduction']) { $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']); } // more details $details = ''; $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $details .= '<ul class="compact">'; foreach ($more as $list_item) { $details .= '<li>' . $list_item . '</li>' . "\n"; } $details .= '</ul>' . "\n"; } // all details if ($details) { $details = BR . '<span class="details">' . $details . "</span>\n"; } // count posts here, and in children sections $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); if (!($count = Articles::count_for_anchor($anchors))) { $count = 0; } // get last post $last_post = '--'; $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // title $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article'); // last editor if ($article['edit_date']) { // find a name, if any if ($article['edit_name']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } // name of last editor $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id'])); } $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } } // this is another row of the output $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post)); } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
{ "type": "line", "values": [ 2, 2, 2, 2, 2, 2, 2 ], "dot-style": { "type": "star", "colour": "#8000FF", "dot-size": 4 }, "width": 1, "colour": "#8000FF", "tip": "Purple #val#", "text": "Mr Purple", "font-size": 10, "loop": true } ], "title": { "text": "Radar Chart" }, "radar_axis": { "max": 5, "colour": "#DAD5E0", "grid-colour": "#DAD5E0", "labels": { "labels": [ "Zero", "", "", "Middle", "", "High" ], "colour": "#9F819F" }, "spoke-labels": { "labels": [ "Strength", "Smarts", "Sweet Tooth", "Armour", "Max Hit Points", "foo", "bar" ], "colour": "#9F819F" } }, "tooltip": { "mouse": 1 }, "bg_colour": "#ffffff" }'; // [chart]...[/chart] $context['text'] .= '[title]' . i18n::s('Static chart') . ' [escape][chart]...[/chart][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][chart=320, 256]' . "\n" . $chart_data . "\n" . '[/chart][/escape]</td>' . '<td>[chart=320, 256]' . "\n" . $chart_data . "\n" . '[/chart]</td></tr>' . Skin::table_suffix(); // [execute=tools/echo.php] $context['text'] .= '[title]' . i18n::s('Execute a local script') . ' [escape][execute=tools/echo.php][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][execute=tools/echo.php][/escape]</td>' . '<td>[execute=tools/echo.php]</td></tr>' . Skin::table_suffix(); // [redirect=tools/echo.php] $context['text'] .= '[title]' . i18n::s('Redirect to a local address') . ' [escape][redirect=tools/echo.php][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example')), 'header') . '<tr><td class="sample">[escape][redirect=tools/echo.php][/escape]</td></tr>' . Skin::table_suffix(); // [parameter=page_details] $context['text'] .= '[title]' . i18n::s('Display some parameter') . ' [escape][parameter=site_name][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][parameter=site_name][/escape]</td>' . '<td>[parameter=site_name]</td></tr>' . Skin::table_suffix(); // [escape]...[/escape] $context['text'] .= '[title]' . i18n::s('Prevent code interpretation') . ' [escape][escape]...[/escape][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][escape]hello world[new][/escape][/escape]</td>' . '<td>[escape]hello world[new][/escape]</td></tr>' . Skin::table_suffix(); // [anonymous]...[/anonymous] $context['text'] .= '[title]' . i18n::s('Displayed only to anonymous surfers') . ' [escape][anonymous]...[/anonymous][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][anonymous]' . i18n::s('Displayed only to anonymous surfers') . '[/anonymous][/escape]</td>' . '<td>[anonymous]' . i18n::s('Displayed only to anonymous surfers') . '[/anonymous]</td></tr>' . Skin::table_suffix(); // [authenticated]...[/authenticated] $context['text'] .= '[title]' . i18n::s('Displayed only to authenticated surfers') . ' [escape][authenticated]...[/authenticated][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][authenticated]' . i18n::s('Displayed only to authenticated surfers') . '[/authenticated][/escape]</td>' . '<td>[authenticated]' . i18n::s('Displayed only to authenticated surfers') . '[/authenticated]</td></tr>' . Skin::table_suffix(); // [associate]...[/associate] $context['text'] .= '[title]' . i18n::s('Displayed only to associates') . ' [escape][associate]...[/associate][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][associate]' . i18n::s('Displayed only to associates') . '[/associate][/escape]</td>' . '<td>[associate]' . i18n::s('Displayed only to associates') . '[/associate]</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // table prefix $text .= Skin::table_prefix('yc-grid'); // table headers $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />'; $cells = array($main, i18n::s('Page'), i18n::s('Rank')); $text .= Skin::table_row($cells, 'header'); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $count = 0; while ($item = SQL::fetch($result)) { $cells = array(); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />'; // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files $stats = Files::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']); } // info on related links $stats = Links::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']); } // info on related comments $stats = Comments::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (count($anchors)) { $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors)); } // end of details $suffix .= '</span>'; // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // commands $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />'; // append the row $text .= Skin::table_row($cells, $count++); } // select all rows $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), ''); $text .= Skin::table_row($cells, $count++); // table suffix $text .= Skin::table_suffix(); // end of processing SQL::free($result); return $text; }
$box .= '<p>' . sprintf(i18n::s('If your browser supports side panels and javascript, click on the following link to %s.'), '<a onclick="addSidePanel()">' . i18n::s('add a blogging panel') . '</a>.') . '</p>' . "\n"; // the actual javascript code to add a panel Page::insert_script('function addSidePanel() {' . "\n" . ' if((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {' . "\n" . ' window.sidebar.addPanel("' . strip_tags($context['site_name']) . '", "' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php", "");' . "\n" . ' alert("' . i18n::s('The panel has been added. You may have to ask your browser to make it visible (Ctrl-B for Firefox).') . '");' . "\n" . ' } else {' . "\n" . ' if(document.all) {' . "\n" . ' window.open("' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php?target=_main" ,"_search");' . "\n" . ' } else {' . "\n" . ' var rv = alert("' . i18n::s('Your browser does not support side panels. Have you considered to upgrade to Mozilla Firefox?') . '");' . "\n" . ' if(rv)' . "\n" . ' document.location.href = "http://www.mozilla.org/products/firefox/";' . "\n" . ' }' . "\n" . ' }' . "\n" . '}' . "\n"); // make a nice box out of it $text .= Skin::build_box(i18n::s('Blogging tools'), $box); } // build another tab $all_tabs = array_merge($all_tabs, array(array('content', i18n::s('Content'), 'content_panel', $text))); // // System Management tab // $text = ''; // display a system overview if not a crawler if (!Surfer::is_crawler()) { // use a neat table for the layout $box = Skin::table_prefix('wide'); $lines = 1; // yacs version if (!isset($generation['version'])) { Safe::load('footprints.php'); } // initial archive, or current version $cells = array(); $cells[] = Skin::build_link('http://www.yacs.fr/', 'YACS'); if (isset($generation['version'])) { $cells[] = $generation['version'] . ', ' . $generation['date'] . ', ' . $generation['server']; } else { $cells[] = '---'; } $box .= Skin::table_row($cells, $lines++); // php version
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // layout in a table $text = Skin::table_prefix('wide'); // 'even' is used for title rows, 'odd' for detail rows $class_title = 'odd'; $class_detail = 'even'; // build a list of sections $family = ''; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide'); } // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // use the title as a link to the page $title =& Skin::build_link($url, $title, 'basic', $hover); // flag sections updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix = EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix = NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix = UPDATED_FLAG . ' '; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n"; $count = 1; // get last posts for this board --avoid sticky pages if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) { foreach ($articles as $id => $article) { // get the related overlay, if any $article_overlay = Overlay::load($article, 'article:' . $id); // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // use the title to label the link if (is_object($article_overlay)) { $title = Codes::beautify_title($article_overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // title $title = Skin::build_link(Articles::get_permalink($article), $title, 'article'); // poster $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']); // comments $comments = Comments::count_for_anchor('article:' . $article['id']); // last editor $action = ''; if ($article['edit_date']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n"; } } // more details $details = array(); // board introduction if ($item['introduction']) { $details[] = Codes::beautify_introduction($item['introduction']); } // indicate the total number of threads here if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) { $details[] = sprintf(i18n::s('%d threads'), $count) . ' »'; } // link to the section index page if ($details) { $details = Skin::build_link(Sections::get_permalink($item), join(' - ', $details), 'basic'); } else { $details = ''; } // add a command for new post $poster = ''; if (Surfer::is_empowered()) { $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . ' »', 'basic'); } // insert details in a separate row if ($details || $poster) { $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n"; } // more details $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $content = '<ul class="compact">'; foreach ($more as $list_item) { $content .= '<li>' . $list_item . '</li>' . "\n"; } $content .= '</ul>' . "\n"; // insert details in a separate row $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
// ===...=== $context['text'] .= '[title]' . i18n::s('Header level 2') . ' [escape]===...===[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl]' . '[escape]===' . i18n::s('Rabbit and Turtle') . '===[/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . "\n" . '===' . i18n::s('Rabbit and Turtle') . '===' . "\n" . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // [header2]...[/header2] $context['text'] .= '[title]' . i18n::s('Header level 2') . ' [escape][header2]...[/header2][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl][nl]' . '[escape][header2]' . i18n::s('Rabbit and Turtle') . '[/header2][/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[nl]' . '[header2]' . i18n::s('Rabbit and Turtle') . '[/header2]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // ====...==== $context['text'] .= '[title]' . i18n::s('Header level 3') . ' [escape]====...====[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl]' . '[escape]====' . i18n::s('Rabbit and Turtle') . '====[/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . "\n" . '====' . i18n::s('Rabbit and Turtle') . '====' . "\n" . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // [header3]...[/header3] $context['text'] .= '[title]' . i18n::s('Header level 3') . ' [escape][header3]...[/header3][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl][nl]' . '[escape][header3]' . i18n::s('Rabbit and Turtle') . '[/header3][/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[nl]' . '[header3]' . i18n::s('Rabbit and Turtle') . '[/header3]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // =====...===== $context['text'] .= '[title]' . i18n::s('Header level 4') . ' [escape]=====...=====[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl]' . '[escape]=====' . i18n::s('Rabbit and Turtle') . '=====[/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . "\n" . '=====' . i18n::s('Rabbit and Turtle') . '=====' . "\n" . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // [header4]...[/header4] $context['text'] .= '[title]' . i18n::s('Header level 4') . ' [escape][header4]...[/header4][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl][nl]' . '[escape][header4]' . i18n::s('Rabbit and Turtle') . '[/header4][/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[nl]' . '[header4]' . i18n::s('Rabbit and Turtle') . '[/header4]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // ======...====== $context['text'] .= '[title]' . i18n::s('Header level 5') . ' [escape]======...======[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl]' . '[escape]======' . i18n::s('Rabbit and Turtle') . '======[/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . "\n" . '======' . i18n::s('Rabbit and Turtle') . '======' . "\n" . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // [header5]...[/header5] $context['text'] .= '[title]' . i18n::s('Header level 5') . ' [escape][header5]...[/header5][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape][nl][nl]' . '[escape][header5]' . i18n::s('Rabbit and Turtle') . '[/header5][/escape][nl]' . '[escape]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '[nl]' . '[header5]' . i18n::s('Rabbit and Turtle') . '[/header5]' . i18n::s('But where will this rabbit be in some minutes?[nl]I don\'t know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // [toq] $context['text'] .= '[title]' . i18n::s('Table of Questions') . ' [escape][toq][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][toq][/escape]</td>' . '<td>[toq]</td></tr>' . Skin::table_suffix(); // [question]...[/question] $context['text'] .= '[title]' . i18n::s('Question-title') . ' [escape][question]...[/question][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][question]' . i18n::s('But where will this rabbit be in some minutes?') . '[/question][/escape]</td>' . '<td>[question]' . i18n::s('But where will this rabbit be in some minutes?') . '[/question]</td></tr>' . Skin::table_suffix(); // [question] $context['text'] .= '[title]' . i18n::s('Question') . ' [escape][question][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][question]' . i18n::s('But where is this rabbit right now?') . '[/escape]</td>' . '<td>[question]' . i18n::s('But where is this rabbit right now?') . '</td></tr>' . Skin::table_suffix(); // [answer] $context['text'] .= '[title]' . i18n::s('Answer') . ' [escape][answer][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][answer]' . i18n::s('I do not know, but it depends also on the turtle speed...') . '[/escape]</td>' . '<td>[answer]' . i18n::s('I do not know, but it depends also on the turtle speed...') . '</td></tr>' . Skin::table_suffix(); // transform the text $context['text'] = Codes::beautify($context['text']); // general help on this page $help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); // render the skin render_skin();