Пример #1
0
 /**
  * list users
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         // 			if($item['id'] == Surfer::get_id())
         // 				continue;
         $label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>'))));
         if (!$label) {
             $label = ucfirst($item['nick_name']);
         }
         // one entry per address
         $items[trim($item['email'])] = $label;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Пример #2
0
 /**
  * list images
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Пример #3
0
 /**
  * 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 formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
Пример #4
0
 /**
  * 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 anchor for this link
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url is the link itself
         $url = $item['link_url'];
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = $item['title'];
         } else {
             $label = $url;
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Пример #5
0
 /**
  * check access rights
  *
  * @param string script name
  * @paral string target anchor, if any
  * @return boolean FALSE if access is denied, TRUE otherwise
  */
 function allow($script, $anchor = NULL)
 {
     global $context;
     // limit the scope of our check
     if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
         return TRUE;
     }
     // sanity check
     if (!$anchor) {
         die(i18n::s('No anchor has been found.'));
     }
     // stop here if the agreement has been gathered previously
     if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
         foreach ($agreements as $agreement) {
             if ($agreement == $anchor) {
                 return TRUE;
             }
         }
     }
     // which agreement?
     if (!$this->parameters) {
         die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
     }
     // do we have a related file to display?
     if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
         die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
     }
     // splash message
     $context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
     // load and display the file to be displayed
     $context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
     // target link to record agreement
     if ($context['with_friendly_urls'] == 'Y') {
         $agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
     } else {
         $agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
     }
     // display confirmation buttons at the end of the agreement
     $context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
     $context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
     $context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
     // render the skin based only on text provided by this behavior
     render_skin();
     exit;
 }
Пример #6
0
 /**
  * list users
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the user profile
         $url = Users::get_permalink($item);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // item title
         if ($item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
         }
         // the section
         $section = '';
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // introduction
         $introduction = Codes::beautify($item['introduction']);
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Пример #7
0
 /**
  * list comments
  *
  * @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;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text .= '<dd style="font-style: italic; font-size: smaller;">' . ucfirst(trim($item['description'])) . ' <span class="details">' . Skin::build_date($item['create_date']) . '</span></dd>';
         } else {
             // the title as the label
             if ($item['create_name']) {
                 $label = ucfirst($item['create_name']);
             } else {
                 $label = i18n::s('anonymous');
             }
             // expand a definition list
             $text .= '<dt>' . $label . '</dt>' . '<dd>' . $item['description'] . ' <span class="details">' . Skin::build_date($item['create_date']) . '</span></dd>' . "\n";
         }
     }
     // finalize the definition list
     if ($text) {
         $text = '<dl class="comments">' . $text . '</dl>';
     }
     // process yacs codes at once
     $text = Codes::beautify($text);
     // end of processing
     SQL::free($result);
     return $text;
 }
Пример #8
0
 /**
  * list articles as digg do
  *
  * @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)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (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="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // 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
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $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(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Пример #9
0
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('The action has not been confirmed.'));
    // ask for confirmation
} else {
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this location'), 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 geo_place_name of the location
    $context['text'] .= Skin::build_block($item['geo_place_name'], 'title');
    // display the full text
    $context['text'] .= '<div style="margin: 1em 0;">' . Codes::beautify($item['description']) . '</div>' . "\n";
    // more details
    $details = array();
    // information on uploader
    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']));
    }
    // the complete details
    if ($details) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
}
// render the skin
render_skin();
Пример #10
0
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the article
} else {
    // initialize the rendering engine
    Codes::initialize(Articles::get_permalink($item));
    // compute the url for this article
    $permanent_link = Articles::get_permalink($item);
    // the trackback link
    $trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id'];
    // get a description -- render codes
    if (isset($item['introduction']) && $item['introduction']) {
        $description = Codes::beautify($item['introduction'], $item['options']);
    } else {
        $description = Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
    }
    // prepare the response
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . '		   xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . '		   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '	<rdf:Description' . "\n" . '		trackback:ping="' . $trackback_link . '"' . "\n" . '		dc:identifier="' . $permanent_link . '"' . "\n" . '		rdf:about="' . $permanent_link . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
    if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
        $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
    }
    if (is_object($anchor)) {
        $text .= '	<dc:subject>' . encode_field($anchor->get_title()) . '</dc:subject>' . "\n";
    }
    $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
Пример #11
0
 /**
  * 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('&', '&amp;', $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;
 }
Пример #12
0
    }
    // make a box
    if ($items) {
        $items =& Skin::build_box($title, $items, 'header1', 'recent_articles');
    }
}
$context['text'] .= $items;
// the suffix hook
if (is_callable(array('Hooks', 'include_scripts'))) {
    $context['text'] .= Hooks::include_scripts('index.php#suffix');
}
// the trail of the cover article
if (!isset($context['root_cover_at_home']) || $context['root_cover_at_home'] != 'none') {
    // may be changed in skin.php if necessary
    if (isset($cover_page['trailer'])) {
        $context['text'] .= Codes::beautify($cover_page['trailer']);
    }
}
//
// compute extra information -- $context['extra']
//
// page tools
//
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('configure.php', i18n::s('Configure'));
    if (isset($cover_page['id'])) {
        $context['page_tools'][] = Skin::build_link(Articles::get_permalink($cover_page), i18n::s('Cover page'), 'basic');
    }
    if (($section = Sections::get('gadget_boxes')) && isset($section['id'])) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Gadget boxes'), 'basic');
    }
Пример #13
0
// ++...++
$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&ccedil;ais[/lang][/escape]</td>' . '<td>[lang=en]This is in English[/lang][lang=fr]Ceci est en fran&ccedil;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=&lt;style name&gt;]...[/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();
Пример #14
0
 /**
  * list articles as rows in a table
  *
  * @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;
     }
     // build a list of articles
     $rows = 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 anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $title = $abstract = $author = '';
         // 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')) {
             $title .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $title .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $title .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $title .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $title .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $title .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $title .= ' ' . UPDATED_FLAG;
         }
         // the icon
         if ($item['thumbnail_url']) {
             $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
         }
         // the introductory text
         if (is_object($overlay)) {
             $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } elseif ($item['introduction']) {
             $abstract .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $abstract .= $overlay->get_text('list', $item);
         }
         // make some abstract out of main text
         if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
             $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // 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);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // describe attachments
         if (count($details)) {
             $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>';
         }
         // anchors
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $category_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)) {
             $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>';
         }
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
             }
         }
         // more details
         $details =& Articles::build_dates($anchor, $item);
         // 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');
         }
         // page details
         if (count($details)) {
             $details = '<p class="details">' . join(', ', $details) . '</p>';
         }
         // this is another row of the output -- title, abstract, (author,) details
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             $cells = array($title, $abstract, $author, $details);
         } else {
             $cells = array($title, $abstract, $details);
         }
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details'));
     } else {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details'));
     }
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Пример #15
0
 /**
  * ping back links referenced in some text
  *
  * This is the client implementation of
  * [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link]
  * and [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specifications.
  *
  * This function is triggered by publishing scripts, either [script]articles/publish.php[/script],
  * [script]services/blog.php[/script], [script]agents/messages.php[/script] or [script]agents/uploads.php[/script].
  *
  * @see articles/publish.php
  * @see services/blog.php
  * @see agents/messages.php
  * @see agents/uploads.php
  *
  * It is used to efficiently link pages across a set of web sites according to the following mechanism:
  * - The list of external links is built for this page
  * - Only the 7 first links are kept from the list; others are stripped
  * - If links do not exist, create additional records in the table used for links
  * - Each link (actually, only the 7 most recent) is checked, to see if it's trackback- or pingback-enabled or not
  * - Each trackback-/pingback-enabled link is activated, providing the full URL of the anchor page
  *
  * We are claiming to support most of the trackback client interface here, as described in the [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link] specification.
  * A foreign page is considered as being trackback-enabled if it has a special RDF section
  * linking its reference (i.e., URL) to a Trackback Ping URL.
  *
  * Note that YACS also implements the server part of the trackback specification in [script]links/trackback.php[/script],
  * which supports POST REST calls.
  *
  * @see links/trackback.php
  *
  * We are claiming to fully support the pingback client interface here, as described in the [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specification.
  * A foreign page is considered to be pingback-enabled if it has a meta link to a Pingback Ping URL.
  *
  * Note that YACS also implements the server part of the pingback specification in [script]services/ping.php[/script],
  * which supports XML-RPC calls.
  *
  * @see services/ping.php
  *
  * This function transforms every YACS codes into HTML before extracting links,
  * and before submitting the excerpt to remote site.
  *
  * @param string the referencing text that has to be scanned
  * @param string the local anchor of the referencing text (e.g., 'article:124')
  * @return array list($links, $advertised, $skipped)
  *
  * @link http://www.movabletype.org/docs/mttrackback.html TrackBack Technical Specification
  * @link http://www.hixie.ch/specs/pingback/pingback Pingback specification
  */
 public static function ping($text, $anchor)
 {
     global $context;
     // render all codes
     if (is_callable(array('Codes', 'beautify'))) {
         $text = Codes::beautify($text);
     }
     // suppress all links not coming from anchors (eg, <img src=...)
     $text = strip_tags($text, '<a>');
     // extract all links from the text, including those that have been encoded by YACS
     preg_match_all('/((http:\\/\\/|http%3A%2F%2F)[^ <"]+)/i', $text, $links);
     // nothing to do
     if (!@count($links[1])) {
         return;
     }
     // process each link only once
     $unique_links = array();
     foreach ($links[1] as $url) {
         // decode raw url encoding, if any
         $url = rawurldecode($url);
         // strip the clicking indirection, if any
         $url = rawurldecode(preg_replace('/^' . preg_quote($context['url_to_home'] . $context['url_to_root'] . 'links/click.php?url=', '/') . '/i', '', $url));
         $unique_links[$url] = 1;
     }
     // analyze found links
     $links_processed = array();
     $links_advertised = array();
     $links_skipped = array();
     foreach ($unique_links as $url => $dummy) {
         // analyze no more than 7 links
         if (@count($links_processed) >= 7) {
             break;
         }
         // skip links that point to ourself, and not to an article
         if (preg_match('/^' . preg_quote($context['url_to_home'], '/') . '\\b/i', $url) && !preg_match('/\\/article(-|s\\/view.php)/i', $url)) {
             $links_skipped[] = $url;
             continue;
         }
         // skip invalid links
         if (($content = http::proceed($url)) === FALSE) {
             $links_skipped[] = $url;
             continue;
         }
         // we will use the content to locate pingback and trackback interfaces
         $pages[$url] = $content;
         // ensure enough execution time
         Safe::set_time_limit(30);
         // stats
         $links_processed[] = $url;
     }
     // locate the anchor object for this text, we need its url
     $anchor = Anchors::get($anchor);
     if (!is_object($anchor)) {
         return;
     }
     // build an excerpt from anchor
     $excerpt = $anchor->get_teaser('basic');
     // find blog name for anchor
     if ($parent = $anchor->get_value('anchor')) {
         $blog = Anchors::get($parent);
         if (is_object($blog)) {
             $blog_name = $blog->get_title();
         }
     }
     // build an absolute URL for the source
     $source = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url();
     // process each link
     if (@count($pages)) {
         foreach ($pages as $target => $content) {
             // try trackback, if implemented
             if (Links::ping_as_trackback($content, $source, $target, $anchor->get_title(), $excerpt, $blog_name)) {
                 $links_advertised[] = $target;
             } elseif (Links::ping_as_pingback($content, $source, $target)) {
                 $links_advertised[] = $target;
             }
         }
     }
     return array($links_processed, $links_advertised, $links_skipped);
 }
Пример #16
0
Файл: day.php Проект: rair/yacs
 /**
  * get invitation default message
  *
  * This is put in the invitation form.
  *
  * @see articles/invite.php
  *
  * @param string 'PUBLISH' or 'CANCEL'
  * @return string to be put in the web form
  */
 function get_invite_default_message($method = 'PUBLISH')
 {
     global $context;
     // to be displayed into the web form for this invitation
     $text = '';
     if ($value = $this->anchor->get_title()) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR;
     }
     // dates
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR;
     }
     // build a link to the chairman page, if any
     if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR;
     }
     // event has been cancelled
     if ($method == 'CANCEL') {
         $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>';
     } else {
         // copy content of the introduction field, if any
         if ($value = $this->anchor->get_value('introduction')) {
             $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>';
         }
         // copy the induction message, if any
         if (isset($this->attributes['induction_message'])) {
             $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>';
         }
     }
     // done
     return $text;
 }
Пример #17
0
    if (!Surfer::is_logged()) {
        Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"');
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the section
} else {
    // compute the url for this section
    $url = Sections::get_permalink($item);
    // get a description
    if ($item['introduction']) {
        $description = Codes::beautify($item['introduction']);
    } else {
        $description = Skin::strip(Codes::beautify($item['description']), 50);
    }
    // prepare the response
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n" . '	<rdf:Description rdf:about="' . $url . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
    if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
        $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
    }
    $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
    // suggest a name on download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.opml.xml');
Пример #18
0
 /**
  * list categories
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // 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)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories 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 restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 10);
         // details
         $details = array();
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') {
             $icon = $item['thumbnail_url'];
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Пример #19
0
Файл: page.php Проект: rair/yacs
 /**
  * echo the site menu
  *
  * You can override this function into your skin
  */
 public static function echo_menu()
 {
     global $context;
     // ensure normal conditions
     if (file_exists($context['path_to_root'] . 'parameters/switch.on') && is_callable(array('Articles', 'get')) && is_callable(array('Codes', 'beautify'))) {
         // use content of a named global page
         if ($item = Articles::get('menu')) {
             echo Skin::build_box(Codes::beautify_title($item['title']), Codes::beautify($item['description']), 'navigation', 'main_menu');
         }
     }
 }
Пример #20
0
    }
    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";
    }
}
// render the skin
render_skin();
Пример #21
0
Файл: view.php Проект: rair/yacs
} elseif ($script) {
    $context['page_title'] = i18n::s('Documentation:') . ' ' . $script;
} else {
    $context['page_title'] = i18n::s('View PHP documentation');
}
// no script has been provided -- help web crawlers
if (!$script) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    Logger::error(i18n::s('No script has been provided'));
    // the script has to be there
} elseif (!$row) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    Logger::error(i18n::s('Script does not exist'));
    // display script content
} else {
    $context['text'] = Codes::beautify($row['content']);
    // referrals, if any
    $context['components']['referrals'] =& Skin::build_referrals(Scripts::get_url($script));
    // update the menu bar
    if ($script != 'todo' && $script != 'authors' && $script != 'testers' && $script != 'licenses') {
        // browsing is safe
        $context['page_tools'][] = Skin::build_link(Scripts::get_url($script, 'browse'), i18n::s('Browse the source of this script'));
        // protect from spammers and robots
        if (Surfer::is_logged()) {
            $context['page_tools'][] = Skin::build_link(Scripts::get_url($script, 'fetch'), i18n::s('Fetch the script file'));
        }
    }
    // back to the index
    $context['page_tools'][] = Skin::build_link('scripts/', i18n::s('Server software'));
}
// render the skin
Пример #22
0
 /**
  * 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 .= ' -&nbsp;' . Codes::beautify($item['introduction']);
             } else {
                 $suffix .= ' -&nbsp;' . $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;
 }
Пример #23
0
 /**
  * get some introductory text from an article
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  * Compared to the standard anchor implementation, this one adds the ability to handle overlay data.
  *
  * If there is some introductory text, it is used. Else the description text is used instead.
  * The number of words is capped in both cases.
  *
  * Also, the number of remaining words is provided.
  *
  * Following variants may be selected to adapt to various situations:
  * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
  * - 'hover' - some text to be displayed while hovering a link
  * - 'quote' - strip most HTML tags
  * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
  *
  * @see shared/anchor.php
  *
  * @param string an optional variant, including
  * @return NULL, of some text
  */
 function &get_teaser($variant = 'basic')
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         $text = NULL;
         return $text;
     }
     // the text to be returned
     $text = '';
     // use the introduction field, if any
     if ($this->item['introduction']) {
         $text = trim($this->item['introduction']);
         // may be rendered as an empty strings
         if ($variant != 'hover') {
             // remove toc and toq codes
             $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
             // render all codes
             if (is_callable(array('Codes', 'beautify'))) {
                 $text = Codes::beautify($text, $this->item['options']);
             }
         }
         // combine with description
         if ($variant == 'quote') {
             $text .= BR . BR;
         }
     }
     // use overlay data, if any
     if (!$text) {
         if (!isset($this->overlay) && isset($this->item['overlay'])) {
             $this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']);
         }
         if (is_object($this->overlay)) {
             $text .= $this->overlay->get_text('list', $this->item);
         }
     }
     // use the description field, if any
     $in_description = FALSE;
     if (!$text && $variant != 'hover') {
         $text .= trim($this->item['description']);
         $in_description = TRUE;
         // remove toc and toq codes
         $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text);
         // render all codes
         if ($variant == 'teaser' && is_callable(array('Codes', 'beautify'))) {
             $text = Codes::beautify($text, $this->item['options']);
         }
     }
     // turn html entities to unicode entities
     $text = utf8::transcode($text);
     // now we have to process the provided text
     switch ($variant) {
         // strip everything
         case 'basic':
         default:
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // done
             return $text;
             // some text for pop-up panels
         // some text for pop-up panels
         case 'hover':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 70, NULL, '');
             }
             // ensure we have some text
             if (!$text) {
                 $text = i18n::s('View the page');
             }
             // mention shortcut to article
             if (Surfer::is_associate()) {
                 $text .= ' [article=' . $this->item['id'] . ']';
             }
             // done
             return $text;
             // quote this
         // quote this
         case 'quote':
             // strip every HTML and limit the size
             if (is_callable(array('Skin', 'strip'))) {
                 $text = Skin::strip($text, 300, NULL, '<a><b><br><i><img><strong><u>');
             }
             // done
             return $text;
             // preserve as much as possible
         // preserve as much as possible
         case 'teaser':
             // lower level of titles
             $text = str_replace(array('<h4', '</h4'), array('<h5', '</h5'), $text);
             $text = str_replace(array('<h3', '</h3'), array('<h4', '</h4'), $text);
             $text = str_replace(array('<h2', '</h2'), array('<h3', '</h3'), $text);
             // limit the number of words
             if (is_callable(array('Skin', 'cap'))) {
                 $text = Skin::cap($text, WORDS_IN_TEASER, $this->get_url());
             }
             // done
             return $text;
     }
 }
Пример #24
0
Файл: view.php Проект: rair/yacs
     // there is some box content
     if ($box['text']) {
         $canvas['links'] = Skin::build_content('links', i18n::s('Links'), $box['text'], $box['bar']);
     }
     $canvas['links_count'] = $count;
 }
 //
 // trailer information
 //
 // add trailer information from the overlay, if any
 if (is_object($overlay)) {
     $canvas['trailer'] .= $overlay->get_text('trailer', $item);
 }
 // add trailer information from this item, if any
 if (isset($item['trailer']) && trim($item['trailer'])) {
     $canvas['trailer'] .= Codes::beautify($item['trailer']);
 }
 // buttons to display previous and next pages, if any
 if ($neighbours) {
     $canvas['trailer'] .= Skin::neighbours($neighbours, 'manual');
 }
 // insert anchor suffix
 if (is_object($anchor)) {
     $canvas['trailer'] .= $anchor->get_suffix();
 }
 // reflect content canvas from anchor
 if (!isset($item['canvas']) && is_object($anchor)) {
     $item['canvas'] = $anchor->get_articles_canvas();
 }
 // reflect content canvas from anchor
 if (empty($item['canvas'])) {
Пример #25
0
 /**
  * list categories
  *
  * @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;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // 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)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories 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 restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // details
         $details = array();
         // count related sub-elements
         $related_count = 0;
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         $related_count += $stats['count'];
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             $related_count += $count;
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             $related_count += $count;
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $stats['count'];
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // add a head list of related links
         $details = array();
         // add sub-categories on index pages
         if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related sections if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related articles if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
             foreach ($related as $sub_url => $label) {
                 $sub_prefix = $sub_suffix = $sub_hover = '';
                 if (is_array($label)) {
                     $sub_prefix = $label[0];
                     $sub_suffix = $label[2];
                     if (@$label[5]) {
                         $sub_hover = $label[5];
                     }
                     $label = $label[1];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // give me more
         if (count($details) && $related_count > YAHOO_LIST_SIZE) {
             $details[] = Skin::build_link(Categories::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the category'));
         }
         // layout details
         if (count($details)) {
             $suffix .= BR . "\n&raquo;&nbsp;" . '<span class="details">' . implode(', ', $details) . "</span>\n";
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url'])) {
             $icon = $item['thumbnail_url'];
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 50);
         // some hovering title for this category
         $hover = i18n::s('View the category');
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon, $hover);
     }
     // end of processing
     SQL::free($result);
     $output = Skin::build_list($items, '2-columns');
     return $output;
 }
Пример #26
0
            $items =& Skin::build_list($items, 'compact');
        }
        // displayed as another box
        if ($items) {
            $context['page_menu'] += array('_other_sections' => Skin::build_sliding_box(i18n::s('Other sections'), $items, NULL, TRUE, TRUE));
        }
    }
    // trailer information
    //
    // add trailer information from the overlay, if any
    if (is_object($overlay)) {
        $text .= $overlay->get_text('trailer', $item);
    }
    // add trailer information from this item, if any
    if (isset($item['trailer']) && trim($item['trailer'])) {
        $text .= Codes::beautify($item['trailer']);
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $text .= $anchor->get_suffix();
    }
}
// display in a separate panel
if (trim($text)) {
    $panels[] = array('information', i18n::s('Information'), 'information_panel', $text);
}
//
// append tabs from the overlay, if any -- they have been captured in sections/view.php
//
if (isset($context['tabs']) && is_array($context['tabs'])) {
    $panels = array_merge($panels, $context['tabs']);
Пример #27
0
Файл: new.php Проект: rair/yacs
         }
         // no recipient string
         if (!$label) {
             $to[] = $address;
         } else {
             if (preg_match('/,/', $label)) {
                 $label = implode(' ', array_reverse(preg_split("/[\\s,]+/", $label)));
             }
             $to[] = Mailer::encode_recipient($address, $label);
         }
     }
 }
 // subject
 $subject = $_REQUEST['letter_title'];
 // enable yacs codes in messages
 $text = Codes::beautify($_REQUEST['letter_body']);
 // preserve tagging as much as possible
 $message = Mailer::build_multipart($text);
 // reply-to: from the letters configuration file
 if (isset($context['letter_reply_to']) && $context['letter_reply_to']) {
     $headers[] = 'Reply-To: ' . $context['letter_reply_to'];
 }
 // list and count recipients
 $recipients_errors = $recipients_processed = $recipients_ok = 0;
 if (is_array($to)) {
     $context['text'] .= i18n::s('A message has been sent to:') . "\n" . '<ul>' . "\n";
     foreach ($to as $address) {
         $context['text'] .= '<li>' . encode_field($address) . '</li>' . "\n";
     }
     $context['text'] .= '</ul>' . "\n";
     $recipients_processed = count($to);
Пример #28
0
 /**
  * get some introductory text from this anchor
  *
  * This function is used to introduce comments, or any sub-item related to an anchor.
  *
  * This basic version does not care about the provided parameter.
  *
  * @param string an optional variant
  * @return string some text or NULL
  */
 function &get_teaser($variant = 'basic')
 {
     // nothing to do
     if (!is_array($this->item)) {
         $text = NULL;
     } elseif ($intro = $this->get_introduction()) {
         $text = Codes::beautify($intro, $this->item['options']);
     } else {
         $text = Skin::cap(Codes::beautify($this->item['description'], $this->item['options']), 70);
     }
     // done
     return $text;
 }
Пример #29
0
 /**
  * layout one of the newest articles
  *
  * @param array the article
  * @return string the rendered text
  */
 function layout_newest($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']);
     // the icon to put aside
     $icon = '';
     if ($item['thumbnail_url']) {
         $icon = $item['thumbnail_url'];
     }
     if ($icon) {
         $icon = '<img src="' . $icon . '" class="left_image" alt="" />';
     }
     // 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 articles
     if ($item['active'] == 'N') {
         $title = PRIVATE_FLAG . ' ' . $title;
     } elseif ($item['active'] == 'R') {
         $title = RESTRICTED_FLAG . ' ' . $title;
     }
     // rating
     if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
         $title .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // pack in a block
     $text = '<h3>' . Skin::build_link($url, $icon . $title, 'basic') . '</h3>';
     // display all tags
     if ($item['tags']) {
         $text .= ' <p class="tags" style="margin: 3px 0;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
     }
     // the introduction
     $text .= '<div style="margin: 3px 0;">';
     // the introductory text
     if (is_object($overlay)) {
         $text .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
     } elseif ($item['introduction']) {
         $text .= Codes::beautify_introduction($item['introduction']) . ' ' . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic');
     } else {
         $text .= Skin::cap(Codes::beautify($item['description'], $item['options']), 25, $url);
     }
     // end of the introduction
     $text .= '</div>' . "\n";
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('list', $item);
     }
     // 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
     $text .= Skin::finalize_list($details, 'menu');
     return $text;
 }
Пример #30
0
 /**
  * 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;
 }