/** * list links * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the main anchor $anchor = Anchors::get($item['anchor']); // url is the link itself -- hack for xhtml compliance $url = str_replace('&', '&', $item['link_url']); // initialize variables $prefix = $suffix = ''; // flag links that are dead, or created or updated very recently if ($item['edit_date'] >= $context['fresh']) { $suffix = NEW_FLAG; } // make a label $label = Links::clean($item['title'], $item['link_url']); // the main anchor link if (is_object($anchor)) { $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list links * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // url is the link itself $url = $item['link_url']; // initialize variables $prefix = $suffix = ''; // flag links that are dead, or created or updated very recently if ($item['edit_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } // make a label $label = Links::clean($item['title'], $item['link_url'], 30); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list links * * Recognize following variants: * - 'no_anchor' to list items attached to one particular anchor * - 'no_author' to list items attached to one user prolink * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'no_anchor'; } // process all items in the list while ($item = SQL::fetch($result)) { // get the main anchor $anchor = Anchors::get($item['anchor']); // initialize variables $prefix = $suffix = $icon = ''; // make a label $label = Links::clean($item['title'], $item['link_url']); // flag links uploaded recently if ($item['edit_date'] >= $context['fresh']) { $prefix = NEW_FLAG . $prefix; } // the number of clicks if ($item['hits'] > 1) { $suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') '; } // add a separator if ($suffix) { $suffix = ' - ' . $suffix; } // details $details = array(); // item poster if ($item['edit_name'] && $this->layout_variant != 'no_author') { if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } } // show an anchor link if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $anchor_url = $anchor->get_url(); $anchor_label = ucfirst($anchor->get_title()); $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article')); } // the menu bar for associates and poster if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) { $details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span'); $details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span'); } // append details to the suffix if (count($details)) { $suffix .= BR . Skin::finalize_list($details, 'menu'); } // description if ($item['description']) { $suffix .= BR . Codes::beautify($item['description']); } // build the actual link to check it if ($this->layout_variant == 'review') { $icon = $item['link_url']; } // url is the link itself -- hack for xhtml compliance $url = str_replace('&', '&', $item['link_url']); // let the rendering engine guess the type of link $link_type = NULL; // except if we want to stay within this window if (isset($item['link_target']) && $item['link_target'] != 'I') { $link_type = 'external'; } // hovering title $link_title = NULL; if (isset($item['link_title']) && $item['link_title']) { $link_title = $item['link_title']; } // pack everything $items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title); } // end of processing SQL::free($result); return $items; }
/** * list blogmarks * * @param resource the SQL result * @return string resulting text **/ function layout($result) { global $context; // we return a string $text = ''; // empty list if (!SQL::count($result)) { return $text; } // start in north $in_north = TRUE; // define allowed HTML tags for the cover page define('ALLOWED_HTML_TAGS', '<a><b><br><h1><h2><h3><i><img><li><ol><p><ul>'); // build a list of articles $box = array(); $box['content'] = ''; $previous_date = NULL; while ($item = SQL::fetch($result)) { // not the same date $current_date = substr($item['edit_date'], 0, 10); if ($previous_date != $current_date) { // insert a complete box for the previous date if ($box['content']) { if ($in_north) { $text .= '<div class="newest">' . "\n"; } $text .= Skin::build_box($box['title'], $box['content']); if ($in_north) { $text .= '</div>' . "\n"; } $in_north = FALSE; } // prepare a box for a new date $previous_date = $current_date; $box['title'] = Skin::build_date($item['edit_date'], 'no_hour'); $box['content'] = ''; } $box['content'] .= '<br clear="both" />'; // time $box['content'] .= '<span class="details">' . substr($item['edit_date'], 11, 5) . '</span> '; // make a label $label = Links::clean($item['title'], $item['link_url']); $box['content'] .= Skin::build_link($item['link_url'], $label); // flag links updated recently if ($item['edit_date'] >= $context['fresh']) { $box['content'] .= ' ' . NEW_FLAG; } // the description if (trim($item['description'])) { $box['content'] .= "\n<br/>" . Skin::cap(Codes::beautify($item['description']), 500) . "\n"; } // the menu bar for associates and poster if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) { $menu = array('links/edit.php?id=' . $item['id'] => i18n::s('Edit'), 'links/delete.php?id=' . $item['id'] => i18n::s('Delete')); $box['content'] .= ' ' . Skin::build_list($menu, 'menu'); } // append details to the suffix $box['content'] .= BR . '<span class="details">'; // details $details = array(); // item poster if (Surfer::is_member()) { if ($item['edit_name']) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } } else { $details[] = Anchors::get_action_label($item['edit_action']); } // show an anchor link if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $anchor_url = $anchor->get_url(); $anchor_label = ucfirst($anchor->get_title()); $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label)); } // all details $box['content'] .= ucfirst(trim(implode(' ', $details))) . "\n"; // end of details $box['content'] .= '</span><br/><br/>'; } // close the on-going box if ($in_north) { $text .= '<div class="newest">' . "\n"; } $text .= Skin::build_box($box['title'], $box['content']); if ($in_north) { $text .= '</div>' . "\n"; } // end of processing SQL::free($result); return $text; }