/** * retrieve endpoints of last calls * * This is useful to list all servers notified after a publication. * * @param string title of the folded box generated * @return mixed text to be integrated into the page, or array with one item per recipient, or '' */ public static function build_endpoints($title = NULL) { global $context; // nothing to show if (!Surfer::get_id() || !isset($context['servers_endpoints']) || !$context['servers_endpoints']) { return ''; } // return the bare list if (!$title) { return $context['servers_endpoints']; } // build a nice list $list = array(); foreach ($context['servers_endpoints'] as $recipient) { $list[] = htmlspecialchars($recipient); } return Skin::build_box($title, Skin::finalize_list($list, 'compact'), 'folded'); }
Safe::header('Status: 401 Unauthorized', TRUE, 401); die(i18n::s('You are not allowed to perform this operation.')); // the watch list } elseif ($action == 'watch') { render_raw(); // we return some HTML $output = ''; // horizontal menu $menu = array(); // manage command if (Surfer::is_associate() || Surfer::get_id() == $item['id']) { Skin::define_img('USERS_WATCH_IMG', 'users/watch.gif'); $menu[] = Skin::build_link(Users::get_url('user:'******'id'], 'select'), USERS_WATCH_IMG . i18n::s('Manage followers'), 'span'); } // build the menu $output .= Skin::finalize_list($menu, 'menu_bar'); // list watched users by posts $watched = ''; if ($items =& Members::list_connections_for_user('user:'******'id'], 0, 200, 'watch')) { if (is_array($items)) { $items = Skin::build_list($items, 'decorated'); } $watched .= $items; } elseif (Surfer::get_id() == $item['id']) { $watched .= '<p>' . i18n::s('Click on the link above to follow someone.') . '</p>'; } else { $watched .= '<p>' . sprintf(i18n::s('%s is not yet following other persons.'), $item['full_name']) . '</p>'; } // the list of followers $followers = ''; if ($items = Members::list_watchers_by_name_for_anchor('user:'******'id'], 0, 1000, 'compact')) {
if (is_object($parent)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($parent->get_url(), ucfirst($parent->get_title()), 'section')); } // combine in-line details if (count($details)) { $suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>'; } // surfer cannot be deselected if (!strcmp($anchor->get_reference(), 'user:'******'owner_id'])) { $suffix .= ' - <span class="details">' . i18n::s('owner') . '</span>'; } elseif (Surfer::is_associate()) { $link = $context['script_url'] . '?anchor=' . urlencode($anchor->get_reference()) . '&member=section:' . $section['id'] . '&action=reset'; $suffix .= ' - <span class="details">' . Skin::build_link($link, i18n::s('unassign'), 'basic') . '</span>'; } // format the item $new_sections[$url] = array($prefix, $title, $suffix, 'section', $icon); } // display attached sections with unlink buttons $context['text'] .= Skin::build_list($new_sections, 'decorated'); } // back to the anchor page $links = array(); $links[] = Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button'); $context['text'] .= Skin::finalize_list($links, 'assistant_bar'); // insert anchor suffix if (is_object($anchor)) { $context['text'] .= $anchor->get_suffix(); } } // render the skin render_skin();
// page tools if (Surfer::is_associate()) { $context['page_tools'][] = Skin::build_link('sections/edit.php', i18n::s('Add a section')); $context['page_tools'][] = Skin::build_link('help/populate.php', i18n::s('Content Assistant')); $context['page_tools'][] = Skin::build_link('sections/check.php', i18n::s('Maintenance')); } // display extra information $cache_id = 'sections/index.php#extra'; if (!($text = Cache::get($cache_id))) { // see also $lines = array(); $lines[] = Skin::build_link('categories/', i18n::s('Categories')); $lines[] = Skin::build_link('search.php', i18n::s('Search')); $lines[] = Skin::build_link('help/', i18n::s('Help index')); $lines[] = Skin::build_link('query.php', i18n::s('Contact')); $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes'); // list monthly publications in an extra box $anchor = Categories::get(i18n::c('monthly')); if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) { $text .= Skin::build_box($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n"; } // side boxes for related categories, if any if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) { foreach ($categories as $id => $attributes) { // link to the category page from the box title $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category')); // box content if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) { $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n"; } }
/** * list articles for search requests * * @param resource the SQL result * @return array of resulting items ($score, $summary), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of array($score, $summary) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // 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); // 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' && Articles::is_owned($item, $anchor)) { $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; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // details $details = array(); // the author if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])); } else { $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])); } // 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 if ($count = Files::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $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'); } // the main anchor link if (is_object($anchor)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // display all tags if ($item['tags']) { $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // combine in-line details if (count($details)) { $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix; // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // build the complete HTML element if ($icon) { $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); // default icon } else { $icon = DECORATED_IMG; } // layout this item $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); } // end of processing SQL::free($result); return $items; }
/** * list users * * @param resource the SQL result * @return array of resulting items ($score, $summary), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of array($score, $summary) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // process all items in the list while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Users::get_permalink($item); // flag profiles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if ($item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if ($item['full_name']) { $title = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $title = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // show contact information if (Surfer::may_contact()) { $suffix .= Users::build_presence($item); } // the introduction if ($item['introduction']) { if (is_callable(array('codes', 'beautify'))) { $suffix .= ' - ' . Codes::beautify($item['introduction']); } else { $suffix .= ' - ' . $item['introduction']; } } // display all tags if ($item['tags']) { $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // details $details = array(); // capability if ($item['capability'] == 'A') { $details[] = i18n::s('Associate'); } elseif ($item['capability'] == 'S') { $details[] = i18n::s('Subscriber'); } else { $details[] = i18n::s('Member'); } // creation date if ($item['create_date']) { $details[] = sprintf(i18n::s('registered %s'), Skin::build_date($item['create_date'])); } // last login if ($this->layout_variant == 'dates') { if (isset($item['login_date']) && $item['login_date'] > NULL_DATE) { $address = ''; if ($item['login_address']) { $address = ' (' . $item['login_address'] . ')'; } $details[] = sprintf(i18n::s('last login %s'), Skin::build_date($item['login_date']) . $address); } else { $details[] = i18n::s('no login'); } } // last post if ($this->layout_variant == 'dates') { if (isset($item['post_date']) && $item['post_date'] > NULL_DATE) { $details[] = sprintf(i18n::s('last post %s'), Skin::build_date($item['post_date'])); } } // posts if (intval($item['posts']) > 1) { $details[] = sprintf(i18n::s('%d posts'), intval($item['posts'])); } if (count($details)) { if ($this->layout_variant == 'full') { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } else { $suffix .= ' <span class="details">' . implode(', ', $details) . '</span>'; } } // flag idle users if (isset($item['click_date']) && $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'user') . $suffix; // use the avatar, if any if (isset($item['avatar_url']) && isset($context['users_with_avatars']) && $context['users_with_avatars'] == 'Y') { $icon = $item['avatar_url']; } // layout this item if ($icon) { // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); // put the item in a division } else { $items[] = array($item['score'], '<div style="margin: 0 0 1em 0">' . $box . '</div>'); } } // end of processing SQL::free($result); return $items; }
/** * display available recording, if any * * This function retrieves the list of available recordings from the BBB server, * and displays it to the surfer. */ function get_view_text_extension() { global $context; // parameters to list recordings $parameters = array(); $parameters[] = 'meetingID=' . urlencode($this->attributes['id']); // link to list recordings $url = $this->build_link('getRecordings', $parameters); // query the BBB back-end if (($response = http::proceed_natively($url)) && ($xml = simplexml_load_string($response)) && $xml->returncode == 'SUCCESS') { // ok, we have some recording available if ($recordings = $xml->recordings->children()) { // enumerate recordings, but use only the first one foreach ($recordings as $name => $node) { // sanity checks if ($name != 'recording') { continue; } if (!isset($node->playback)) { continue; } if (!isset($node->playback->format)) { continue; } if (!isset($node->playback->format->url)) { continue; } // a button to start the replay in a separate window $menu = array(); $menu[] = Skin::build_link((string) $node->playback->format->url, 'Play the presentation', 'tee'); return Skin::build_box('Presentation', Skin::finalize_list($menu, 'menu_bar')); } } } }
/** * 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; }
$menu = array(); $delete_label = ''; if (is_object($overlay)) { $delete_label = $overlay->get_label('delete_confirmation', 'comments'); } if (!$delete_label) { $delete_label = i18n::s('Yes, I want to delete this comment'); } $menu[] = Skin::build_submit_button($delete_label, NULL, NULL, 'confirmed', $render_overlaid ? 'button submit-overlaid' : 'button'); if (isset($item['id']) && !$render_overlaid) { $menu[] = Skin::build_link(Comments::get_url($item['id']), i18n::s('Cancel'), 'span'); } elseif ($render_overlaid) { $menu[] = '<a href="javascript:;" onclick="Yacs.closeModalBox()">' . i18n::s('Cancel') . '</a>' . "\n"; } // the submit button $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form">' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . (isset($_REQUEST['follow_up']) ? '<input type="hidden" name="follow_up" value="' . $_REQUEST['follow_up'] . '" />' . "\n" : '') . '</form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // display the full comment $context['text'] .= '<div style="padding: 1em; background-color:#CCC;">' . Codes::beautify($item['description']) . '</div>' . "\n"; // details $details = array(); // the poster of this comment $details[] = sprintf(i18n::s('by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date'])); // the last edition of this comment if ($item['create_name'] != $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'])); } // the complete details if ($details) { $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
/** * 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; }
if (Surfer::is_associate()) { $links[] = Skin::build_link('locations/', 'locations', 'shortcut'); } if (Surfer::is_associate()) { $links[] = Skin::build_link('overlays/', 'overlays', 'shortcut'); } $links[] = Skin::build_link('scripts/', 'scripts', 'shortcut'); $links[] = Skin::build_link('sections/', 'sections', 'shortcut'); $links[] = Skin::build_link('servers/', 'servers', 'shortcut'); $links[] = Skin::build_link('services/', 'services', 'shortcut'); $links[] = Skin::build_link('skins/', 'skins', 'shortcut'); $links[] = Skin::build_link('smileys/', 'smileys', 'shortcut'); if (Surfer::is_associate()) { $links[] = Skin::build_link('tables/', 'tables', 'shortcut'); } if (Surfer::is_associate()) { $links[] = Skin::build_link('tools/', 'tools', 'shortcut'); } $links[] = Skin::build_link('users/', 'users', 'shortcut'); // the hook for more modules if (is_callable(array('Hooks', 'link_scripts')) && ($more_links = Hooks::link_scripts('control/index.php#modules', 'array'))) { $links = array_merge($links, $more_links); } // list modules in an extra box $context['components']['boxes'] .= Skin::build_box(i18n::s('Modules'), Skin::finalize_list($links, 'compact'), 'boxes'); } } } } // render the skin render_skin();
// get a PDF version Skin::define_img('ARTICLES_PDF_IMG', 'articles/export_pdf.gif'); $lines[] = Skin::build_link(Articles::get_url($item['id'], 'fetch_as_pdf'), ARTICLES_PDF_IMG . i18n::s('Save as PDF'), 'basic', i18n::s('Save as PDF')); // open in Word Skin::define_img('ARTICLES_WORD_IMG', 'articles/export_word.gif'); $lines[] = Skin::build_link(Articles::get_url($item['id'], 'fetch_as_msword'), ARTICLES_WORD_IMG . i18n::s('Copy in MS-Word'), 'basic', i18n::s('Copy in MS-Word')); } } // print this page if (Surfer::is_logged() || isset($context['with_anonymous_export_tools']) && $context['with_anonymous_export_tools'] == 'Y') { Skin::define_img('TOOLS_PRINT_IMG', 'tools/print.gif'); $lines[] = Skin::build_link(Articles::get_url($item['id'], 'print'), TOOLS_PRINT_IMG . i18n::s('Print this page'), 'basic', i18n::s('Get a paper copy of this page.')); } // in a side box if (count($lines)) { $context['components']['share'] = Skin::build_box(i18n::s('Share'), Skin::finalize_list($lines, 'newlines'), 'share', 'share'); } // 'Information channels' box // $lines = array(); // watch command is provided to logged surfers if (Surfer::get_id()) { $link = Users::get_url('article:' . $item['id'], 'track'); if ($in_watch_list) { $label = i18n::s('Stop notifications'); } else { $label = i18n::s('Watch this page'); } Skin::define_img('TOOLS_WATCH_IMG', 'tools/watch.gif'); $lines[] = Skin::build_link($link, TOOLS_WATCH_IMG . $label, 'basic', i18n::s('Manage your watch list')); }
/** * list files * * @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 = ''; } // 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 = ''; // more details $url = Files::get_permalink($item); // codes $codes = array(); // files that can be embedded if (preg_match('/\\.(3gp|flv|gan|m4v|mm|mov|mp4|swf)$/i', $item['file_name'])) { $codes[] = '[embed=' . $item['id'] . ']'; } // link for direct download $codes[] = '[file=' . $item['id'] . ']'; $codes[] = '[download=' . $item['id'] . ']'; // integrate codes if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') { foreach ($codes as $code) { $suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> '; } } else { $suffix .= join(' ', $codes); } $suffix .= BR . '<span class="details">'; // signal restricted and private files if ($item['active'] == 'N') { $suffix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $suffix .= RESTRICTED_FLAG; } // file title or file name $label = Codes::beautify_title($item['title']); if (!$label) { $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name'])); } $suffix .= $label; // flag files uploaded recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } $suffix .= '</span>'; // details $details = array(); if (Surfer::is_logged() && $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'])); } // the menu bar for associates and poster if (Surfer::is_empowered()) { $details[] = Skin::build_link($url, i18n::s('details'), 'basic'); $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'); $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'); } // append details if (count($details)) { $suffix .= BR . Skin::finalize_list($details, 'menu'); } // explicit icon if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } else { $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']); } // list all components for this item $items[$url] = array($prefix, '_', $suffix, 'file', $icon); } // end of processing SQL::free($result); return $items; }
/** * 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; } // allow for complete styling $text = '<div class="last_articles">'; // build a list of articles 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 $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); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $label = $suffix = $icon = ''; // 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')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag expired articles 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 locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $suffix .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // one box per update $text .= '<div class="last_article" >'; // use the title as a link to the page $text .= Skin::build_block($prefix . ucfirst($title) . $suffix, 'header1'); // some details about this page $details = array(); // page starter and date if ($item['create_name']) { $details[] = sprintf(i18n::s('Started by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])) . ' ' . Skin::build_date($item['create_date']); } // page last modification if ($item['edit_date'] && $item['edit_action'] == 'article:update' && $item['edit_name']) { $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])) . ' ' . Skin::build_date($item['edit_date']); } // friends if ($friends =& Members::list_users_by_posts_for_anchor('article:' . $item['id'], 0, USERS_LIST_SIZE, 'comma5', $item['create_id'])) { $details[] = sprintf(i18n::s('with %s'), $friends); } // people details if ($details) { $text .= '<p class="details">' . join(', ', $details) . "</p>\n"; } // the introductory text $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $text .= '<div style="margin: 1em 0;">' . Codes::beautify_introduction($introduction) . '</div>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // info on related comments if (($count = Comments::count_for_anchor('article:' . $item['id'])) > 1) { $text .= '<div style="margin-top: 1em;"><p class="details">' . sprintf(i18n::s('%d contributions, including:'), $count) . '</p></div>'; } // avoid first file if mentioned in last contribution $file_offset = 0; // get last contribution for this page if ($comment = Comments::get_newest_for_anchor('article:' . $item['id'])) { if (preg_match('/\\[(download|file)=/', $comment['description'])) { $file_offset++; } // bars around the last contribution $bottom_menu = array(); // last contributor $contributor = Users::get_link($comment['create_name'], $comment['create_address'], $comment['create_id']); $flag = ''; if ($comment['create_date'] >= $context['fresh']) { $flag = NEW_FLAG; } elseif ($comment['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG; } $bottom_menu[] = sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($comment['create_date']) . $flag; // offer to reply if (Comments::allow_creation($item, $anchor)) { $link = Comments::get_url($comment['id'], 'reply'); $bottom_menu[] = Skin::build_link($link, i18n::s('Reply'), 'basic'); } // gather pieces $pieces = array(); // last contribution, and user signature $pieces[] = ucfirst(trim($comment['description'])) . Users::get_signature($comment['create_id']); // bottom if ($bottom_menu) { $pieces[] = '<div style="margin-top: 1em;">' . ucfirst(trim(Skin::finalize_list($bottom_menu, 'menu'))) . '</div>'; } // put all pieces together $text .= '<div class="last_comment">' . "\n" . join("\n", $pieces) . '</div>' . "\n"; } // list more recent files if ($items = Files::list_by_date_for_anchor('article:' . $item['id'], $file_offset, 3, 'dates')) { // more files than listed $more = ''; if (($count = Files::count_for_anchor('article:' . $item['id'])) > 3) { $more = '<span class="details">' . sprintf(i18n::s('%d files, including:'), $count) . '</span>'; } if (is_array($items)) { $items = Skin::build_list($items, 'compact'); } $text .= '<div style="margin: 1em 0;">' . $more . $items . '</div>'; } // display all tags if ($item['tags']) { $text .= ' <p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // navigation links $menu = array(); // permalink $menu[] = Skin::build_link($url, i18n::s('View the page'), 'span'); // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $menu[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $menu[] = Skin::build_link($anchor->get_url(), sprintf(i18n::s('in %s'), ucfirst($anchor->get_title())), 'span', i18n::s('View the section')); } // actually insert details $text .= Skin::finalize_list($menu, 'menu_bar'); // bottom of the box $text .= '</div>'; } // close the list of articles $text .= '</div>'; // beautify everything at once $text = Codes::beautify($text); // end of processing SQL::free($result); // done return $text; }
/** * list articles as alistapart did * * @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)) { $output = '<p>' . i18n::s('No page to display.'); if (Surfer::is_associate()) { $output .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut')); } $output .= '</p>'; return $output; } // menu at page bottom $this->menu = array(); // build a list of articles $item_count = 0; $future = array(); $others = array(); 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 $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); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = ''; // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= LOCKED_FLAG; } // flag expired articles, and articles 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 . ' '; } // list separately articles to be published if ($item['publish_date'] <= NULL_DATE) { $prefix = DRAFT_FLAG . $prefix; $future[$url] = array($prefix, $title, $suffix); } elseif ($item['publish_date'] > $context['now']) { $future[$url] = array($prefix, $title, $suffix); } else { $item_count += 1; // layout the newest article if ($item_count == 1) { $text .= $this->layout_newest($item); // display all tags if ($item['tags']) { $context['page_tags'] = Skin::build_tags($item['tags']); } // layout recent articles } else { $others[$url] = array($prefix, $title, $suffix); } } } // build the list of future articles if (@count($future)) { $this->menu[] = Skin::build_sliding_box(i18n::s('Pages under preparation'), Skin::build_list($future, 'compact'), NULL, TRUE); } // build the list of other articles if (@count($others)) { $this->menu[] = Skin::build_sliding_box(i18n::s('Previous pages'), Skin::build_list($others, 'compact'), NULL, TRUE); } // talk about it if (@count($this->menu)) { $text .= Skin::build_box(strlen($text) > 1024 ? i18n::s('Follow-up') : '', Skin::finalize_list($this->menu, 'menu_bar')); } // end of processing SQL::free($result); return $text; }
/** * text to come after page description * * @param array the hosting record, if any * @return some HTML to be inserted into the resulting page */ function &get_trailer_text($host = NULL) { global $context; // the text $text = ''; // actually, a menu of commands $menu = array(); // no end date if (!isset($this->attributes['end_date']) || $this->attributes['end_date'] <= NULL_DATE) { $open = TRUE; } elseif ($this->attributes['end_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $open = TRUE; } else { $open = FALSE; } // different for each surfer Cache::poison(); // link to vote if ($open && Surfer::get_id() && Surfer::get_id() && !Comments::count_approvals_for_anchor($this->anchor->get_reference(), Surfer::get_id())) { $menu[] = Skin::build_link(Comments::get_url($this->anchor->get_reference(), 'approve'), i18n::s('Sign this petition'), 'shortcut'); } $text = Skin::finalize_list($menu, 'menu_bar'); return $text; }
/** * 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; }
$fields[] = array($label, $input); // the password has to be repeated for confirmation $label = i18n::s('Password confirmation'); $input = '<input type="password" name="confirm" size="20" value="' . encode_field(isset($_REQUEST['confirm']) ? $_REQUEST['confirm'] : '') . '" />'; $fields[] = array($label, $input); // append the script used for data checking on the browser Page::insert_script('$("#password").focus();'); } // stop replay attacks and robots if ($field = Surfer::get_robot_stopper()) { $fields[] = $field; } // build the form $context['text'] .= Skin::build_form($fields); // cancel link if (!isset($item['id'])) { $cancel_url = $context['url_to_home'] . $context['url_to_root']; } else { $cancel_url = Users::get_permalink($item); } // bottom commands $context['text'] .= Skin::finalize_list(array(Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'), Skin::build_link($cancel_url, i18n::s('Cancel'), 'span')), 'assistant_bar'); // hidden field that have to be saved as well if (isset($item['id']) && $item['id']) { $context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />'; } // end of the form $context['text'] .= '</div></form>'; } // render the skin render_skin();
/** * list files * * Recognize following variants: * - 'section:123' to list items attached to one particular anchor * - 'no_author' to list items attached to one user profile * * @param resource the SQL result * @return string HTML text to be displayed, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // sanity check if (!isset($this->focus)) { $this->focus = ''; } // process all items in the list $items = array(); while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // get the main anchor $anchor = Anchors::get($item['anchor']); // we feature only the head of the list, if we are at the origin page if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) { $box .= Codes::render_object('file', $item['id']); // no side icon $icon = ''; // we are listing various files from various places } else { $prefix = $suffix = ''; // stream the file if (Files::is_stream($item['file_name'])) { $url = Files::get_url($item['id'], 'stream', $item['file_name']); } else { $url = Files::get_url($item['id'], 'fetch', $item['file_name']); } // absolute url $url = $context['url_to_home'] . $context['url_to_root'] . $url; // signal restricted and private files if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // file title or file name $label = Codes::beautify_title($item['title']); if (!$label) { $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name'])); } // show a reference to the file for members $hover = i18n::s('Get the file'); if (Surfer::is_member()) { $hover .= ' [file=' . $item['id'] . ']'; } // flag files uploaded recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // one line of text $box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix; // side icon if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } else { $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']); } // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); } // first line of details $details = array(); // file poster and last action if ($this->layout_variant != 'no_author') { $details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } else { $details[] = Skin::build_date($item['edit_date']); } // downloads if ($item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('downloads')); } // file size if ($item['file_size'] > 1) { $details[] = Skin::build_number($item['file_size'], i18n::s('bytes')); } // anchor link if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) { $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')); } $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; // append details $details = array(); // view the file $details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic'); // file has been detached if (isset($item['assign_id']) && $item['assign_id']) { // who has been assigned? if (Surfer::is($item['assign_id'])) { $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date'])); } else { $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])); } } // detach or edit the file if (Files::allow_modification($item, $anchor)) { if (!isset($item['assign_id']) || !$item['assign_id']) { $details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it')); } // release reservation if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) { $details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file')); } if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) { $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details')); } } // delete the file if (Files::allow_deletion($item, $anchor)) { $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'); } // append details if (count($details)) { $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert item icon if ($icon) { $list = array(array($box, $icon)); $items[] = Skin::finalize_list($list, 'decorated'); // put the item in a division } else { $items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>'; } } // stack all items in a single column $text = Skin::finalize_list($items, 'rows'); // end of processing SQL::free($result); return $text; }
/** * echo the toolbox * * You can override this function into your skin */ public static function echo_tools() { global $context; // tools are listed into $context if (isset($context['page_tools']) && @count($context['page_tools']) > 0) { echo Skin::build_box(i18n::s('Tools'), Skin::finalize_list($context['page_tools'], 'newlines'), 'extra', 'page_tools'); } }
$details = array(); if (Surfer::is_member() && $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'])); } // page details if (is_array($details)) { $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n"; } // insert anchor suffix if (is_object($anchor)) { $context['text'] .= $anchor->get_suffix(); } // back to the anchor page if (is_object($anchor) && $anchor->is_viewable()) { $menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button')); $context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom'); } // // populate the extra panel // // commands for associates and editors if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) { $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit')); $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete')); // commands for the author } elseif (Surfer::is($item['edit_id'])) { $context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit')); } // referrals, if any, in a sidebar // $context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
} else { $context['text'] .= '<p>' . sprintf(i18n::s('You have been assigned as an editor of %s, and this allows you to contribute to this page, and to be notified of changes.'), Skin::build_link($anchor->get_url(), $anchor->get_title())) . '</p>'; } // cautioon on private areas if ($anchor->get_active() == 'N') { if ($type == 'section') { $context['text'] .= '<p>' . i18n::s('Access to this section is restricted. If you continue, it will become invisible to you, and you will not be able to even browse its content anymore.') . '</p>'; } else { $context['text'] .= '<p>' . i18n::s('Access to this page is restricted. If you continue, it will become invisible to you, and you will not be able to even browse its content anymore.') . '</p>'; } } // ask for confirmation if ($type == 'section') { $context['text'] .= '<p>' . i18n::s('You are about to suppress all your editing rights on this section.') . '</p>'; } else { $context['text'] .= '<p>' . i18n::s('You are about to suppress all your editing rights on this page.') . '</p>'; } $bottom = '<p>' . i18n::s('Are you sure?') . '</p>'; // commands $menu = array(); $menu[] = Skin::build_submit_button(i18n::s('Yes'), NULL, NULL, 'confirmed'); $menu[] = Skin::build_link($anchor->get_url(), i18n::s('No'), 'span'); // render commands $bottom .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $anchor->get_reference() . '" />' . "\n" . '<input type="hidden" name="action" value="leave" />' . "\n" . '</p></form>' . "\n"; // $context['text'] .= Skin::build_block($bottom, 'bottom'); // set the focus Page::insert_script('$("confirmed").focus();'); } // render the skin render_skin();
/** * list articles as an index * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // referenced items $letters = array(); // empty list if (!SQL::count($result)) { return $text; } // build a list of articles 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']); } // reset everything $prefix = $label = $suffix = $icon = $details = ''; // 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')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag articles 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; } // make a link $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix; // the associated letter $letter = strtoupper(ltrim($title[0])); if ($letter < 'A' || $letter > 'Z') { $letter = '#'; } // a new entry for this letter if (!isset($letters[$letter])) { $letters[$letter] = array(); } $letters[$letter][] = $label; } // mention all letters at the top $bar = array(); // all potential letters, in expected order $all = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($index = 0; $index < strlen($all); $index++) { $letter = $all[$index]; // some content for this letter if (isset($letters[$letter])) { // internal link to the right place $bar[] = Skin::build_link('#letter' . $letter, $letter, 'span'); // actual content for this letter $content = '<ul class="index"><li>' . join('</li><li>', $letters[$letter]) . '</li></ul>'; // content displayed in the page $text .= Skin::build_header_box($letter, $content, 'letter' . $letter); // no content for this letter } else { $bar[] = $letter; } } // insert local links at the top $text = Skin::finalize_list($bar, 'menu_bar') . $text; // end of processing SQL::free($result); return $text; }
@array_splice($result, $bucket); $more_results = TRUE; } // display results if ($result) { // drop scores $items = array(); $last_offset = $offset; foreach ($result as $item) { $items[] = $item[1]; $last_offset = $item[0]; } // avoid that the first item of the next slice is the last item of current slice $last_offset -= 1.0E-13; // stack all results $text = Skin::finalize_list($items, 'rows'); // offer to fetch more results if ($more_results) { // make a valid id $id = str_replace('.', '_', $last_offset); // the button to get more results $text .= '<div style="margin-top: 1em; text-align: center;" id="div' . $id . '"><a href="#" class="button wide" id="a' . $id . '">' . i18n::s('Get more results') . '</a></div>'; Page::insert_script('$(function(){' . '$("#div' . $id . ' a").click( function() {' . 'Yacs.update("div' . $id . '", "' . $context['self_url'] . '", {' . 'data: "offset=' . $last_offset . '",' . 'complete: function() {' . 'setTimeout(function() {$("#div' . $id . '").animate({"marginTop":0})}, 500); ' . '}' . '});' . 'return false;' . '});' . '});'); } // return a slice of results to update the search page through ajax call if ($offset < 1.0) { echo $text; return; } } else { $text = sprintf(i18n::s('<p>No page has been found. This will happen with very short words (less than %d letters), that are not fully indexed. This can happen as well if more than half of pages contain the searched words. Try to use most restrictive words and to suppress "noise" words.</p>'), MINIMUM_TOKEN_SIZE) . "\n";
Safe::closedir($dir); } if ($text) { $context['text'] .= Skin::build_content(NULL, i18n::s('Use the library'), $text); } // display the current gravatar, if any if (isset($item['email']) && $item['email']) { $text = ''; // the gravatar url $url = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($item['email']); // it is already in use if (isset($item['avatar_url']) && $url == $item['avatar_url']) { $text .= '<p>' . sprintf(i18n::s('Your are using your %s as current picture.'), Skin::build_link('http://www.gravatar.com/', i18n::s('gravatar'), 'external')) . '</p>' . "\n"; } else { $text .= '<p>' . sprintf(i18n::s('I have a %s and %s'), Skin::build_link('http://www.gravatar.com/', i18n::s('gravatar'), 'external'), '<a href="' . $context['url_to_root'] . 'users/select_avatar.php?id=' . $id . '&avatar=' . urlencode($url) . '">' . i18n::s('would like to use it') . '</a>') . '</p>' . "\n"; } $context['text'] .= Skin::build_content(NULL, i18n::s('Use a gravatar'), $text); } // // bottom commands // $menu = array(); global $render_overlaid; if (!$render_overlaid) { $menu[] = Skin::build_link(Users::get_permalink($item), i18n::s('Cancel'), 'span'); } //$menu[] = Skin::build_link(Users::get_permalink($item), i18n::s('Cancel'), 'button'); $context['text'] .= Skin::finalize_list($menu, 'assistant_bar'); } // render the skin render_skin();
/** * list comments as successive reader notes * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // return some formatted text $text = '<dl class="wiki_comments">'; // build a list of comments $index = 0; include_once $context['path_to_root'] . 'comments/comments.php'; while ($item = SQL::fetch($result)) { // odd or even $index++; if ($index % 2) { $class = 'odd'; } else { $class = 'even'; } // get the anchor $anchor = Anchors::get($item['anchor']); // include a link to comment permalink $text .= '<dt class="' . $class . ' details">'; // a link to the user profile $text .= Users::get_link($item['create_name'], $item['create_address'], $item['create_id']); $menu = array(); // the creation date $label = Skin::build_date($item['create_date']); // flag new comments if ($item['create_date'] >= $context['fresh']) { $label .= NEW_FLAG; } $menu[] = $label; // the menu bar for associates and poster if (Comments::allow_modification($anchor, $item)) { $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'); $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'); } $text .= ' - ' . Skin::finalize_list($menu, 'menu'); $text .= '</dt>'; // each comment has an id $text .= '<dd class="' . $class . '" id="comment_' . $item['id'] . '">'; // the comment itself $text .= ucfirst(trim($item['description'] . Users::get_signature($item['create_id']))); // comment has been modified if ($item['create_name'] && $item['edit_name'] != $item['create_name']) { $text .= BR . '<span class="details">(' . sprintf(i18n::s('modified by %s'), $item['edit_name']) . ')</span>'; } // end of this note $text .= '</dd>'; } // end of the list $text .= '</dl>'; // process yacs codes $text = Codes::beautify($text); // end of processing SQL::free($result); return $text; }
} else { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'articles/'); } } // deletion has to be confirmed } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { Logger::error(i18n::s('The action has not been confirmed.')); } else { // commands $menu = array(); $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this table'), NULL, NULL, 'confirmed'); if (is_object($anchor)) { $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), '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();'); // the title of the table if (isset($item['title'])) { $context['text'] .= Skin::build_block($item['title'], 'title'); } // display the full text $context['text'] .= Skin::build_block($item['description'], 'description'); // execute the query string to build the table if (isset($item['query']) && $item['query']) { $context['text'] .= Tables::build($item['id'], 'sortable'); } // display the query string, if any if (isset($item['query']) && $item['query']) { $context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n";
$label = i18n::s('Details of your request'); $input = '<textarea name="description" rows="20" cols="50">' . encode_field($item['description']) . '</textarea>'; $hint = i18n::s('Please mention any reference information required to process the request'); $fields[] = array($label, $input, $hint); // build the form $context['text'] .= Skin::build_form($fields); // bottom commands $menu = array(); // the submit button $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'); // step back if (isset($_SERVER['HTTP_REFERER'])) { $menu[] = Skin::build_link($_SERVER['HTTP_REFERER'], i18n::s('Cancel'), 'span'); } // display the menu $context['text'] .= Skin::finalize_list($menu, 'menu_bar'); // end of the form $context['text'] .= '</div></form>'; // append the script used for data checking on the browser Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.edit_name.value) {' . "\n" . ' alert("' . i18n::s('Please give your first and last names') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.edit_address.value) {' . "\n" . ' alert("' . i18n::s('Please give your e-mail address') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.title.value) {' . "\n" . ' alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . "\n" . ' if(container.description.value.length > 64000){' . "\n" . ' alert("' . i18n::s('The description should not exceed 64000 characters.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . "\n" . ' return true;' . "\n" . '}' . "\n" . '$("#edit_name").focus();' . "\n"); // general help on this form $text = i18n::s('<p>Use this form to submit any kind of request you can have, from simple suggestions to complex questions.</p><p>Hearty discussion and unpopular viewpoints are welcome, but please keep queries civil. Flaming, trolling, and smarmy queries are discouraged and may be deleted. In fact, we reserve the right to delete any post for any reason. Don\'t make us do it.</p>'); if (Surfer::is_associate()) { $text .= '<p>' . i18n::s('If you paste some existing HTML content and want to avoid the implicit formatting insert the code <code>[formatted]</code> at the very beginning of the description field.'); } else { $text .= '<p>' . i18n::s('Most HTML tags are removed.'); } $text .= ' ' . sprintf(i18n::s('You can use %s to beautify your post'), Skin::build_link('codes/', i18n::s('YACS codes'), 'open')) . '.</p>'; // locate mandatory fields $text .= '<p>' . i18n::s('Mandatory fields are marked with a *') . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $text, 'boxes', 'help');
/** * layout one recent article * * @param array the article * @return an array ($prefix, $label, $suffix) **/ function layout_recent($item) { global $context; // permalink $url = Articles::get_permalink($item); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // 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']); } // reset everything $prefix = $suffix = ''; // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // rating if ($item['rating_count']) { $suffix .= 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 $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); } // other details $details = array(); // the author $author = ''; if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' '; } // date $details[] = $author . Skin::build_date($item['publish_date']); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic'); } // info on related comments $link = Comments::get_url('article:' . $item['id'], 'list'); if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic'); } // discuss if (Comments::allow_creation($item, $anchor)) { $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic'); } // append a menu $suffix .= Skin::finalize_list($details, 'menu'); // display all tags if ($item['tags']) { $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // insert an array of links return array($prefix, $title, $suffix); }
/** * build a small form to post a comment * * @param string reference to the anchor to attach the comment * @param string the place to come back when complete * @return string the HTML tags to put in the page */ public static function get_form($reference, $follow_up = 'comments', $placeholder = null, $file_attachement = true) { global $context, $render_overlaid; // default placeholder if (!$placeholder) { $placeholder = i18n::s('Reply'); } // the form to post a comment $text = '<form method="post" action="' . $context['url_to_root'] . 'comments/edit.php" enctype="multipart/form-data" class="comment_form"><div style="margin: 1em 0;">'; // use the right editor, maybe wysiwyg $text .= Surfer::get_editor('description', '', TRUE, 3, FALSE, $placeholder); // bottom commands $menu = array(); // option to add a file $anchor = Anchors::get($reference); if ($file_attachement && $anchor->allows('creation', 'file')) { include_once $context['path_to_root'] . 'files/files.php'; // input field to appear on demand $text .= '<p id="comment_upload" class="details" style="display: none;">' . '<input type="file" name="upload" id="upload" size="30" onchange="if(/\\.zip$/i.test($(this).val())){$(\'#upload_option\').slideDown();}else{$(\'#upload_option\').slideUp();}" />' . ' (< ' . $context['file_maximum_size'] . i18n::s('bytes') . ')' . '<input type="hidden" name="file_type" value="upload" /></p>' . '<div id="upload_option" style="display: none;" >' . '<input type="checkbox" name="explode_files" checked="checked" /> ' . i18n::s('Extract files from the archive') . '</div>'; // the command to add a file Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif'); $menu[] = '<a href="#" onclick="$(\'#comment_upload\').slideDown(600);$(this).slideUp(); return false;"><span>' . FILES_UPLOAD_IMG . i18n::s('Add a file') . '</span></a>'; } // the submit button $class_submit = $render_overlaid && $follow_up !== 'json' ? 'submit-overlaid' : 'button'; $menu[] = Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's', null, $class_submit); // case of a ajax submission if ($follow_up === 'json') { // insert js only once static $ajax_comment_form = false; if (!$ajax_comment_form) { Page::insert_script('Yacs.initAjaxComments();'); $ajax_comment_form = true; } } // finalize the form $text .= '<input type="hidden" name="anchor" value="' . $reference . '" />' . '<input type="hidden" name="follow_up" value="' . $follow_up . '" />' . '<input type="hidden" name="notify_watchers" value="Y" />' . Skin::finalize_list($menu, 'menu_bar') . '</div></form>'; // done return $text; }