示例#1
0
 /**
  * list sections
  *
  * @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
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // more text
         $text .= Sections::to_xml($item, $overlay);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
示例#2
0
文件: export.php 项目: rair/yacs
    include '../error.php';
    // permission denied
} elseif (!Sections::allow_access($item, $anchor)) {
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Sections::get_url($item['id'], 'export')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the article
} else {
    // file header
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<content>' . "\n";
    // item actual content
    $text .= Sections::to_xml($item, $overlay);
    $text .= "\n" . '</content>';
    //
    // 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']) . '.xml');
        Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
    http::expire(1800);
    // strong validator
    $etag = '"' . md5($text) . '"';