Exemple #1
0
// if it was a HEAD request, stop here
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
    return;
}
// add language information, if known
if (isset($context['page_language'])) {
    $language = ' xml:lang="' . $context['page_language'] . '" ';
} else {
    $language = '';
}
// do our own rendering
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . "\n" . '<html ' . $language . ' xmlns="http://www.w3.org/1999/xhtml">' . "\n" . '<head>' . "\n";
// the title
if (isset($context['page_title'])) {
    echo '<title>' . ucfirst(strip_tags($context['page_title'])) . '</title>';
}
// styles
echo '<style type="text/css" media="screen">' . "\n" . '<!--' . "\n" . '	body, body p {' . "\n" . '		font-family: Verdana, Arial, Helvetica, sans-serif;' . "\n" . '		font-size:	  x-small;' . "\n" . '		voice-family: "\\"}\\"";' . "\n" . '		voice-family: inherit;' . "\n" . '		font-size:	  small;' . "\n" . '	}' . "\n" . "\n" . '	body {' . "\n" . '		scrollbar-face-color: #FFFFAA;' . "\n" . '	}' . "\n" . "\n" . '	textarea {' . "\n" . '		border: 0px none;' . "\n" . '		width: 99%;' . "\n" . '		background-color: rgb(255, 255, 170);' . "\n" . '	}' . "\n" . '-->' . "\n" . '</style>' . "\n";
// end of meta information
echo "</head>\n<body>\n";
// display error messages, if any
echo Skin::build_error_block();
// render and display the content
if (isset($context['text'])) {
    echo $context['text'];
}
// debug output, if any
if (is_array($context['debug']) && count($context['debug'])) {
    echo "\n" . '<ul id="debug">' . "\n" . '<li>' . implode('</li>' . "\n" . '<li>', $context['debug']) . '<li>' . "\n" . '</ul>' . "\n";
}
echo "\n</body>\n</html>";
Exemple #2
0
 // link to the original page
 $context['text'] .= '<p>' . sprintf(i18n::s('The original page is located at %s'), Skin::build_link(Articles::get_permalink($item), Articles::get_permalink($item))) . "</p>\n";
 // insert anchor suffix
 if (is_object($anchor)) {
     $context['text'] .= $anchor->get_suffix();
 }
 //
 // special rendering if everything is ok
 //
 $text = '<html><body>' . "\n";
 // display the title
 if (isset($context['page_title']) && $context['page_title']) {
     $text .= Skin::build_block($context['page_title'], 'page_title');
 }
 // display error messages, if any
 $text .= Skin::build_error_block();
 // render and display the content, if any
 $text .= $context['text'] . "\n";
 $text .= '</body></html>' . "\n";
 // MS-WORD won't import pictures
 $text = preg_replace('/<img (.*?)\\/>/i', '', $text);
 // strip relative links
 $text = preg_replace('/<a (.*?)>(.*?)<\\/a>/is', '\\2', $text);
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('application/msword; charset=' . $context['charset']);
 // suggest a download
 if (!headers_sent()) {
     $file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.doc');
Exemple #3
0
 /**
  * echo error messages
  *
  * You can override this function into your skin
  */
 public static function echo_error()
 {
     global $context;
     // delegate this to the skin
     if (is_callable(array('Skin', 'build_error_block'))) {
         echo Skin::build_error_block();
     }
 }
Exemple #4
0
 /**
  * decorate some text
  *
  * Useful for highlighting snippets of code or other types of text information
  *
  * Accepted variants:
  * - 'bottom' the last div in the content area
  * - 'caution' get reader attention
  * - 'center' some centered text
  * - 'code' a snippet of code
  * - 'decorated' to add on beauty
  * - 'description' main content
  * - 'error' an error message
  * - 'indent' an indented block
  * - 'introduction' some decorated text at the beginning of the page
  * - 'note' get reader attention
  * - 'page_title' the single page title
  * - 'question' as a title
  * - 'quote' some quoted text
  * - 'right' some right-centered text
  * - 'search' a form to search some text
  * - 'subtitle' a second-level title
  * - 'title' a first-level title
  * - default make a &lt;span class=...>
  *
  * Example to build a title:
  * [php]
  * echo Skin::build_block($title, 'title');
  * [/php]
  *
  * Example to build a subtitle:
  * [php]
  * echo Skin::build_block($title', 'subtitle');
  * [/php]
  *
  * The access key 4 for the search box has been suggested by Mark Pilgrim.
  *
  * @link http://diveintoaccessibility.org/day_29_making_everything_searchable.html Dive Into Accessibility: Making everything searchable
  *
  * @param mixed the text, or an array of strings
  * @param the variant, if any
  * @param string a unique object id, if any
  * @param mixed rendering parameters, if any
  * @return string the rendered text
  *
  * @see shared/codes.php
  **/
 public static function &build_block($text, $variant = '', $id = '', $options = NULL)
 {
     global $context;
     $text = Codes::fix_tags($text);
     // turn list to a string
     if (is_array($text)) {
         $concatenated = '';
         foreach ($text as $line) {
             $concatenated .= '<p>' . $line . '</p>' . "\n";
         }
         $text = $concatenated;
     }
     // sanity check
     $text = trim($text);
     // make the id explicit
     if ($id) {
         $id = ' id="' . $id . '" ';
     }
     // depending on variant
     switch ($variant) {
         case 'bottom':
             if ($text) {
                 $text = '<div class="bottom"' . $id . '>' . $text . '</div>';
             }
             break;
         case 'caution':
             Skin::define_img('CAUTION_FLAG', 'codes/caution.gif', i18n::s('<b>Warning:</b> '), '!!!');
             if ($text) {
                 $text = '<div class="caution"' . $id . '>' . CAUTION_FLAG . $text . '</div>';
             }
             break;
         case 'center':
             if ($text) {
                 $text = '<div class="center"' . $id . '>' . $text . '</div>';
             }
             break;
         case 'code':
             if ($text) {
                 $text = '<pre' . $id . '>' . $text . '</pre>';
             }
             break;
         case 'decorated':
             if ($text) {
                 $text = '<table class="decorated"' . $id . '><tr>' . '<td class="image">' . DECORATED_IMG . '</td>' . '<td class="content">' . $text . '</td>' . "</tr></table>\n";
             }
             break;
         case 'description':
             if ($text) {
                 $text = '<div class="description"' . $id . '>' . Codes::beautify($text, $options) . '</div>' . "\n";
             }
             break;
         case 'error':
             if ($text) {
                 $text = Skin::build_error_block($text, $id);
             }
             break;
         case 'header1':
         case 'title':
             if ($text) {
                 $text = '<h2' . $id . '><span>' . Codes::beautify_title($text) . '</span></h2>';
             }
             break;
         case 'header2':
         case 'subtitle':
             if ($text) {
                 $text = '<h3' . $id . '><span>' . Codes::beautify_title($text) . '</span></h3>';
             }
             break;
         case 'header3':
             if ($text) {
                 $text = '<h4' . $id . '>' . Codes::beautify_title($text) . '</h4>';
             }
             break;
         case 'header4':
             if ($text) {
                 $text = '<h5' . $id . '>' . Codes::beautify_title($text) . '</h5>';
             }
             break;
         case 'header5':
             if ($text) {
                 $text = '<h6' . $id . '>' . Codes::beautify_title($text) . '</h6>';
             }
             break;
         case 'indent':
             if ($text) {
                 $text = '<div class="indent"' . $id . '>' . $text . '</div>';
             }
             break;
         case 'introduction':
             if ($text) {
                 $text = '<div class="introduction"' . $id . '>' . Codes::beautify('<p>' . $text . '</p>', $options) . '</div>' . "\n";
             }
             break;
         case 'note':
             Skin::define_img('NOTICE_FLAG', 'codes/note.gif', i18n::s('<b>Note:</b> '));
             if ($text) {
                 $text = '<div class="note"' . $id . '>' . NOTICE_FLAG . $text . '</div>';
             }
             break;
         case 'page_title':
             if ($text) {
                 $text = '<h1' . $id . '><span>' . Codes::beautify_title($text) . "</span></h1>\n";
             }
             break;
         case 'question':
             if ($text) {
                 $text = '<h2' . $id . ' class="question"><span>' . Codes::beautify_title($text) . '</span></h2>';
             }
             break;
         case 'quote':
             if ($text) {
                 $text =& Skin::build_quote_block($text);
             }
             break;
         case 'right':
             if ($text) {
                 $text = '<div' . $id . ' class="right">' . $text . '</div>';
             }
             break;
         case 'search':
             // delegate search requests to an external web address
             if (isset($context['skins_delegate_search']) && $context['skins_delegate_search'] == 'Y' && isset($context['skins_search_form']) && $context['skins_search_form']) {
                 $text = str_replace('%s', encode_field($text), $context['skins_search_form']);
             } elseif (isset($context['skins_delegate_search']) && ($context['skins_delegate_search'] == 'S' || $context['skins_delegate_search'] == 'X')) {
                 if (!$text) {
                     $text = i18n::s('Search...');
                 }
                 $text = '<form action="' . $context['url_to_root'] . 'search.php" method="get" id="search_box">' . '<p style="margin: 0; padding: 0;">' . '<input type="text" name="search" size="10" value="' . encode_field($text) . '" onfocus="this.value=\'\'" maxlength="128" />' . Skin::build_submit_button(i18n::s('Go')) . '</p>' . '</form>';
                 // simples search form
             } else {
                 if (!$text) {
                     $text = i18n::s('Search...');
                 }
                 $text = '<form action="' . $context['url_to_root'] . 'search.php" method="get" id="search_box">' . '<p style="margin: 0; padding: 0;">' . '<input type="text" name="search" size="10" value="' . encode_field($text) . '" onfocus="this.value=\'\'" maxlength="128" />' . Skin::build_submit_button(i18n::s('Go')) . '</p>' . '</form>';
             }
             break;
         case 'sidecolumn':
             if ($text) {
                 $text = '<div' . $id . ' class="sidecolumn">' . $text . '</div>';
             }
             break;
         default:
             if ($variant && $text) {
                 $text = '<span class="' . $variant . '"' . $id . '>' . $text . '</span>';
             }
             break;
     }
     // job done
     return $text;
 }