示例#1
0
 /**
  * get parameters for one meeting facility
  *
  * @see overlays/event.php
  *
  * @return an array of fields or NULL
  */
 function get_event_fields()
 {
     global $context;
     // returned fields
     $fields = array();
     // chairman
     $label = i18n::s('Chairman');
     $input = $this->get_chairman_input();
     $fields[] = array($label, $input);
     // number of seats
     $label = i18n::s('Seats');
     $input = $this->get_seats_input();
     $hint = i18n::s('Maximum number of participants.');
     $fields[] = array($label, $input, $hint);
     // dimdim account
     $label = i18n::s('Account');
     if (!isset($this->attributes['account'])) {
         $this->attributes['account'] = '';
     }
     $input = '<input type="text" name="account" value ="' . encode_field($this->attributes['account']) . '" />';
     $hint = sprintf(i18n::s('Enter a valid %s account'), Skin::build_link('http://www.dimdim.com/', 'DimDim', 'basic'));
     $fields[] = array($label, $input, $hint);
     // dimdim password
     $label = i18n::s('Password');
     if (!isset($this->attributes['password'])) {
         $this->attributes['password'] = '';
     }
     $input = '<input type="text" name="password" value ="' . encode_field($this->attributes['password']) . '" />';
     $fields[] = array($label, $input);
     // add these tabs
     return $fields;
 }
示例#2
0
文件: recipe.php 项目: rair/yacs
 /**
  * build the list of fields for one overlay
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     // the number of plates
     $label = i18n::s('Persons to be served');
     $input = '<input type="text" name="people" value ="' . encode_field($this->attributes['people']) . '" />';
     $hint = i18n::s('Try to standardize your recipes for four people');
     $fields[] = array($label, $input, $hint);
     // the time for the preparation
     $label = i18n::s('Time to prepare');
     $input = '<input type="text" name="preparation_time" value ="' . encode_field($this->attributes['preparation_time']) . '" />';
     $hint = i18n::s('Do not take into account cooking time');
     $fields[] = array($label, $input, $hint);
     // the time for cooking
     $label = i18n::s('Time to cook');
     $input = '<input type="text" name="cooking_time" value ="' . encode_field($this->attributes['cooking_time']) . '" />';
     $hint = i18n::s('Do not take into account time to heat the owen');
     $fields[] = array($label, $input, $hint);
     // the ingredients
     $label = i18n::s('Ingredients');
     $input = '<textarea name="ingredients" rows="6" cols="50">' . encode_field($this->attributes['ingredients']) . '</textarea>';
     $hint = i18n::s('Type each ingredient on one separate line starting with a \'-\' character');
     $fields[] = array($label, $input, $hint);
     return $fields;
 }
示例#3
0
文件: mutable.php 项目: rair/yacs
 /**
  * preserve content across page modification
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     // form fields
     $fields = array();
     // item identifier
     if (!isset($this->attributes['overlay_id'])) {
         $this->attributes['overlay_id'] = '';
     }
     // only associates can change the overlay id
     if (Surfer::is_associate()) {
         // isset($host['anchor']) && ($parent =&  Anchors::get($host['anchor'])) && $parent->is_assigned()) {
         $label = i18n::s('Overlay identifier');
         $input = '<input type="text" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
     } else {
         $label = 'hidden';
         $input = '<input type="hidden" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
     }
     // hidden attributes
     foreach ($this->attributes as $name => $value) {
         if (preg_match('/_content$/', $name)) {
             $input .= '<input type="hidden" name="' . encode_field($name) . '" value="' . encode_field($value) . '" />';
         }
     }
     // we do have something to preserve
     $fields[] = array($label, $input);
     // job done
     return $fields;
 }
示例#4
0
文件: poll.php 项目: rair/yacs
 /**
  * build the list of fields for one overlay
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     // a placeholder for new answers
     if (!isset($this->attributes['answers']) || !is_array($this->attributes['answers'])) {
         $this->attributes['answers'] = array();
         $this->attributes['answers'][] = array(i18n::s('Answer 1'), 0);
         $this->attributes['answers'][] = array(i18n::s('Answer 2'), 0);
         $this->attributes['answers'][] = array(i18n::s('Answer 3'), 0);
     }
     // list existing answers
     if (is_array($this->attributes['answers'])) {
         foreach ($this->attributes['answers'] as $answer) {
             list($text, $count) = $answer;
             $label = i18n::s('Answer');
             $input = '<input type="text" name="answer_texts[]" size="55" value="' . encode_field($text) . '" maxlength="64" />';
             $hint = i18n::s('Delete to suppress');
             $fields[] = array($label, $input, $hint);
             $label = i18n::s('Count');
             $input = '<input type="text" name="answer_counts[]" size="10" value="' . encode_field($count) . '" maxlength="64" />';
             $fields[] = array($label, $input);
         }
     }
     // append one answer
     $label = i18n::s('Add an answer');
     $input = '<input type="text" name="answer_texts[]" size="55" maxlength="64" />';
     $hint = i18n::s('Check this is a valid answer to your question');
     $fields[] = array($label, $input, $hint);
     $label = i18n::s('Count');
     $input = '<input type="text" name="answer_counts[]" size="10" value="0" maxlength="64" />';
     $hint = i18n::s('Do not trick your polls; Start at zero');
     $fields[] = array($label, $input, $hint);
     return $fields;
 }
示例#5
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // the hovering title
         if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
             $hover = strip_tags(Codes::beautify_introduction($item['introduction']));
         } else {
             $hover = i18n::s('View the page');
         }
         // title is a link to the target article
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // use the thumbnail for this article
         if ($icon = trim($item['thumbnail_url'])) {
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
                 $icon = $context['url_to_root'] . $icon;
             }
             // use parameter of the control panel for this one
             $options = '';
             if (isset($context['classes_for_thumbnail_images'])) {
                 $options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
             // use default icon if nothing to display
         } else {
             $icon = MAP_IMG;
         }
         // use the image as a link to the target page
         $icon =& Skin::build_link($url, $icon, 'basic', $hover);
         // add a floating box
         $text .= Skin::build_box($title, $icon, 'floating');
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // end of processing
     SQL::free($result);
     return $text;
 }
示例#6
0
文件: xml.php 项目: rair/yacs
 /**
  * prepare a PHP variable
  *
  * @param mixed an array of variables
  * @param we escape strings only at level 1
  * @return string the corresponding XML string
  */
 public static function encode($content, $level = 0)
 {
     // the new representation
     $text = '';
     // a string
     if (is_string($content)) {
         $text .= $content;
     } elseif (is_int($content)) {
         $text .= $content;
     } elseif (is_array($content)) {
         foreach ($content as $name => $value) {
             $name = str_replace('/', 'j', encode_field($name));
             $text .= "\t" . '<' . $name . '>' . self::encode($value, $level + 1) . '</' . $name . '>' . "\n";
         }
     }
     // we need to escape the string
     if ($level == 1 && (strpos($text, '<') !== FALSE || strpos($text, '>') !== FALSE)) {
         $text = str_replace(array('<', '>', '&'), array('&lt;', '&gt;', '&amp;'), $text);
     }
     // job done
     return $text;
 }
示例#7
0
文件: select.php 项目: rair/yacs
 // make an url
 $url = Categories::get_permalink($attributes);
 // gather information on this category
 $prefix = $suffix = $type = $icon = '';
 $label = Skin::strip($attributes['title']);
 // add background color to distinguish this category against others
 if (isset($attributes['background_color']) && $attributes['background_color']) {
     $label = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $label . '</span>';
 }
 // build a unlink button for this category
 if (Surfer::is_associate()) {
     $suffix .= BR . '<form method="post" action="' . $context['script_url'] . '"><div>' . '<input type="hidden" name="anchor" value="category:' . $category_id . '" />' . '<input type="hidden" name="member" value="' . encode_field($member) . '" />' . Skin::build_submit_button(i18n::s('Unlink')) . '</div></form>';
 }
 // a button to change the thumbnail of the anchored page
 if ($icon) {
     $suffix .= ' <form method="post" action="' . $context['url_to_root'] . 'categories/set_as_thumbnail.php"><div>' . '<input type="hidden" name="anchor" value="' . encode_field($member) . '" />' . '<input type="hidden" name="id" value="' . $category_id . '" />' . Skin::build_submit_button(i18n::s('Use this thumbnail as the thumbnail of the page')) . '</div></form>';
 }
 // list sub-categories to be linked, if any
 // display active and restricted items
 $where = "categories.active='Y'";
 if (Surfer::is_member()) {
     $where .= " OR categories.active='R'";
 }
 if (Surfer::is_associate()) {
     $where .= " OR categories.active='N'";
 }
 // only consider live categories
 $where = '(' . $where . ')' . ' AND ((categories.expiry_date is NULL)' . "\tOR (categories.expiry_date <= '" . NULL_DATE . "') OR (categories.expiry_date > '" . $context['now'] . "'))";
 // limit the query to top level only
 $query = "SELECT categories.id, categories.title " . " FROM " . SQL::table_name('categories') . " AS categories " . " WHERE (" . $where . ") AND (categories.anchor='category:" . $category_id . "')" . " ORDER BY categories.title";
 $result = SQL::query($query);
示例#8
0
文件: new.php 项目: rair/yacs
 $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);
 } elseif ($to) {
     $context['text'] .= i18n::s('A message has been sent to:') . ' ' . encode_field($to) . BR . "\n";
     $recipients_processed = 1;
 } else {
     $context['text'] .= '<b>' . i18n::s('No recipient has been defined.') . "</b>" . BR . "\n";
 }
 // do the job
 if ($recipients_processed) {
     $recipients_ok = Mailer::post($from, $to, $subject, $message, NULL, $headers);
     Mailer::close();
     // we may have more recipients than expected
     if ($recipients_ok > $recipients_processed) {
         $recipients_processed = $recipients_ok;
     }
     // reports on error
     $recipients_errors = $recipients_processed - $recipients_ok;
     if ($recipients_errors || count($context['error'])) {
示例#9
0
// the current avatar, if any
if (isset($item['avatar_url']) && $item['avatar_url']) {
    $context['text'] .= '<p>' . sprintf(i18n::s('Current picture: %s'), BR . '<img src="' . $item['avatar_url'] . '" alt="" style="avatar" />') . '</p>' . "\n";
} else {
    $context['text'] .= '<p>' . i18n::s('No picture has been set for this profile.') . '</p>';
}
// list available avatars, except on error
if (!count($context['error']) && isset($item['id'])) {
    // upload an image
    //
    if (Images::allow_creation($item, null, 'user')) {
        // the form to post an image
        $text = '<form method="post" action="' . $context['url_to_root'] . 'images/edit.php" id="main_form" enctype="multipart/form-data"><div>' . '<input type="hidden" name="anchor" value="user:'******'id'] . '" />' . '<input type="hidden" name="action" value="set_as_avatar" />';
        $fields = array();
        // the image
        $text .= '<input type="file" name="upload" id="upload" size="30" accesskey="i" title="' . encode_field(i18n::s('Press to select a local file')) . '" />';
        $text .= ' ' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
        $text .= BR . '<span class="details">' . i18n::s('Select a .png, .gif or .jpeg image.') . ' (&lt;&nbsp;' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')</span>';
        // end of the form
        $text .= '</div></form>';
        // the script used for form handling at the browser
        Page::insert_script('$("#upload").focus();');
        $context['text'] .= Skin::build_content(NULL, i18n::s('Upload an image'), $text);
    }
    // use the library
    //
    // where images are
    $path = 'skins/_reference/avatars';
    // browse the path to list directories and files
    if ($dir = Safe::opendir($context['path_to_root'] . $path)) {
        $text = '';
示例#10
0
 /**
  * list users
  *
  * @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 (!($count = SQL::count($result))) {
         return $text;
     }
     // allow for several lists in the same page
     static $serial;
     if (isset($serial)) {
         $serial++;
     } else {
         $serial = 1;
     }
     // don't blast too many people
     if ($count > 100) {
         $checked = '';
     } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') {
         $checked = '';
     } else {
         $checked = ' checked="checked"';
     }
     // div prefix
     $text .= '<div id="users_as_mail_panel_' . $serial . '">';
     // allow to select/deslect multiple rows at once
     $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR;
     // process all items in the list
     $count = 0;
     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;
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'user:'******'id']);
         // column to select the row
         $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />';
         // signal restricted and private users
         if ($item['active'] == 'N') {
             $text .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $text .= RESTRICTED_FLAG;
         }
         // the url to view this item
         $url = Users::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['full_name']);
         }
         // sanity check
         if (!$title) {
             $title = $item['nick_name'];
         }
         // link to this page
         $text .= Skin::build_link($url, $title, 'user');
         // the introductory text
         if ($item['introduction']) {
             $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>';
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $item);
         }
         // display all tags
         if ($item['tags']) {
             $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>';
         }
         // append the row
         $text .= BR;
         $count++;
     }
     // the script used to check all items at once
     Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . '	$(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // div suffix
     $text .= '</div>';
     // no valid account has been found
     if (!$count) {
         $text = '';
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
示例#11
0
文件: describe.php 项目: rair/yacs
    }
    // 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');
        Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
示例#12
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;
 }
示例#13
0
文件: configure.php 项目: rair/yacs
 $input .= BR . '<input type="radio" name="root_featured_layout" value="none"';
 if (isset($context['root_featured_layout']) && $context['root_featured_layout'] == 'none') {
     $input .= ' checked="checked"';
 }
 $input .= '/> ' . i18n::s('Do not list featured pages.');
 $fields[] = array($label, $input);
 // news can be either a static or an animated list
 $label = i18n::s('News');
 if (!isset($context['root_news_count']) || $context['root_news_count'] < 1 || $context['root_news_count'] > 7) {
     $context['root_news_count'] = 5;
 }
 $input = '<input type="radio" name="root_news_layout" value="static"';
 if (!isset($context['root_news_layout']) || !preg_match('/(rotate|scroll|none)/', $context['root_news_layout'])) {
     $input .= ' checked="checked"';
 }
 $input .= '/> ' . sprintf(i18n::s('List up to %s news aside.'), '<input type="text" name="root_news_count" value="' . encode_field($context['root_news_count']) . '" size="2" />');
 $input .= BR . '<input type="radio" name="root_news_layout" value="scroll"';
 if (isset($context['root_news_layout']) && $context['root_news_layout'] == 'scroll') {
     $input .= ' checked="checked"';
 }
 $input .= '/> ' . i18n::s('Similar to the first option, except that displayed information is scrolling.');
 $input .= BR . '<input type="radio" name="root_news_layout" value="rotate"';
 if (isset($context['root_news_layout']) && $context['root_news_layout'] == 'rotate') {
     $input .= ' checked="checked"';
 }
 $input .= '/> ' . i18n::s('Similar to the first option, except that news are rotated.');
 $input .= BR . '<input type="radio" name="root_news_layout" value="none"';
 if (isset($context['root_news_layout']) && $context['root_news_layout'] == 'none') {
     $input .= ' checked="checked"';
 }
 $input .= '/> ' . i18n::s('Do not list news.');
示例#14
0
文件: configure.php 项目: rair/yacs
 // the splash message
 $inbound .= '<p>' . sprintf(i18n::s('To extend the list of feeders add adequate %s.'), Skin::build_link('servers/', i18n::s('server profiles'), 'shortcut')) . "</p>\n";
 // feeding period
 if (!isset($context['minutes_between_feeds']) || !$context['minutes_between_feeds']) {
     $context['minutes_between_feeds'] = 60;
 }
 $label = i18n::s('Feeding period');
 $input = '<input type="text" name="minutes_between_feeds" size="10" value="' . encode_field($context['minutes_between_feeds']) . '" maxlength="5" />';
 $hint = i18n::s('In minutes. 60 means one hour, etc. Minimum value is 5 minutes');
 $fields[] = array($label, $input, $hint);
 // maximum_news
 if (!isset($context['maximum_news']) || !$context['maximum_news']) {
     $context['maximum_news'] = 1000;
 }
 $label = i18n::s('Maximum news');
 $input = '<input type="text" name="maximum_news" size="10" value="' . encode_field($context['maximum_news']) . '" maxlength="5" />';
 $hint = i18n::s('Oldest news entries will be deleted');
 $fields[] = array($label, $input, $hint);
 // debug_feeds
 $label = i18n::s('Debug feeds');
 $checked = '';
 if (isset($context['debug_feeds']) && $context['debug_feeds'] == 'Y') {
     $checked = 'checked="checked" ';
 }
 $input = '<input type="checkbox" name="debug_feeds" value="Y" ' . $checked . '/> ' . i18n::s('Save data sent and received in temporary/debug.txt');
 $hint = i18n::s('Use this option only for troubleshooting');
 $fields[] = array($label, $input, $hint);
 // build the form
 $inbound .= Skin::build_form($fields);
 $fields = array();
 //
示例#15
0
文件: fetch.php 项目: rair/yacs
                    return;
                }
                // actual transmission except on a HEAD request
                if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                    fpassthru($handle);
                }
                fclose($handle);
            }
            // the post-processing hook, then exit even on HEAD
            finalize_page();
            return;
        }
        // redirect to the actual file
        $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
    }
    // let the web server provide the actual file
    if (!headers_sent()) {
        Safe::header('Status: 302 Found', TRUE, 302);
        Safe::header('Location: ' . $target_href);
        // this one may be blocked by anti-popup software
    } else {
        $context['site_head'] .= '<meta http-equiv="Refresh" content="1;url=' . $target_href . '" />' . "\n";
    }
    // help the surfer
    $context['text'] .= '<p>' . i18n::s('You are requesting the following file:') . '</p>' . "\n";
    $context['text'] .= '<p><a href="' . encode_field($target_href) . '">' . basename($target_href) . '</a></p>' . "\n";
    // automatic or not
    $context['text'] .= '<p>' . i18n::s('The download should start automatically within seconds. Else hit the provided link to trigger it manually.') . '</p>' . "\n";
}
// render the skin
render_skin();
示例#16
0
 /**
  * list files
  *
  * Recognize following variants:
  * - 'section:123' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user profile
  *
  * @param resource the SQL result
  * @return string HTML text to be displayed, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = '';
     }
     // process all items in the list
     $items = array();
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // we feature only the head of the list, if we are at the origin page
         if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) {
             $box .= Codes::render_object('file', $item['id']);
             // no side icon
             $icon = '';
             // we are listing various files from various places
         } else {
             $prefix = $suffix = '';
             // stream the file
             if (Files::is_stream($item['file_name'])) {
                 $url = Files::get_url($item['id'], 'stream', $item['file_name']);
             } else {
                 $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // absolute url
             $url = $context['url_to_home'] . $context['url_to_root'] . $url;
             // signal restricted and private files
             if ($item['active'] == 'N') {
                 $prefix .= PRIVATE_FLAG;
             } elseif ($item['active'] == 'R') {
                 $prefix .= RESTRICTED_FLAG;
             }
             // file title or file name
             $label = Codes::beautify_title($item['title']);
             if (!$label) {
                 $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
             }
             // show a reference to the file for members
             $hover = i18n::s('Get the file');
             if (Surfer::is_member()) {
                 $hover .= ' [file=' . $item['id'] . ']';
             }
             // flag files uploaded recently
             if ($item['create_date'] >= $context['fresh']) {
                 $suffix .= NEW_FLAG;
             } elseif ($item['edit_date'] >= $context['fresh']) {
                 $suffix .= UPDATED_FLAG;
             }
             // one line of text
             $box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
             // side icon
             if ($item['thumbnail_url']) {
                 $icon = $item['thumbnail_url'];
             } else {
                 $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
         }
         // first line of details
         $details = array();
         // file poster and last action
         if ($this->layout_variant != 'no_author') {
             $details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         } else {
             $details[] = Skin::build_date($item['edit_date']);
         }
         // downloads
         if ($item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
         }
         // file size
         if ($item['file_size'] > 1) {
             $details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
         }
         // anchor link
         if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         // append details
         $details = array();
         // view the file
         $details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic');
         // file has been detached
         if (isset($item['assign_id']) && $item['assign_id']) {
             // who has been assigned?
             if (Surfer::is($item['assign_id'])) {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
             } else {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
             }
         }
         // detach or edit the file
         if (Files::allow_modification($item, $anchor)) {
             if (!isset($item['assign_id']) || !$item['assign_id']) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it'));
             }
             // release reservation
             if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file'));
             }
             if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details'));
             }
         }
         // delete the file
         if (Files::allow_deletion($item, $anchor)) {
             $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         // append details
         if (count($details)) {
             $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert item icon
         if ($icon) {
             $list = array(array($box, $icon));
             $items[] = Skin::finalize_list($list, 'decorated');
             // put the item in a division
         } else {
             $items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>';
         }
     }
     // stack all items in a single column
     $text = Skin::finalize_list($items, 'rows');
     // end of processing
     SQL::free($result);
     return $text;
 }
示例#17
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;
 }
示例#18
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // output as a string
     $text = '';
     // build a list of sections
     $family = '';
     $first = TRUE;
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // close last table only if a section has been already listed
             if (!$first) {
                 $text .= Skin::table_suffix();
             }
             // show the family
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
         } elseif ($first) {
             $text .= Skin::table_prefix('yabb');
             $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
         }
         // done with this case
         $first = FALSE;
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title as a link to the page
         $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover);
         // also use a clickable thumbnail, if any
         if ($item['thumbnail_url']) {
             $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix;
         }
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // board introduction
         if ($item['introduction']) {
             $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']);
         }
         // more details
         $details = '';
         $more = array();
         // board moderators
         if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
             $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
         }
         // children boards
         if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) {
             $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
         }
         // as a compact list
         if (count($more)) {
             $details .= '<ul class="compact">';
             foreach ($more as $list_item) {
                 $details .= '<li>' . $list_item . '</li>' . "\n";
             }
             $details .= '</ul>' . "\n";
         }
         // all details
         if ($details) {
             $details = BR . '<span class="details">' . $details . "</span>\n";
         }
         // count posts here, and in children sections
         $anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
         if (!($count = Articles::count_for_anchor($anchors))) {
             $count = 0;
         }
         // get last post
         $last_post = '--';
         $article =& Articles::get_newest_for_anchor($anchors, TRUE);
         if ($article['id']) {
             // flag articles updated recently
             if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                 $flag = EXPIRED_FLAG . ' ';
             } elseif ($article['create_date'] >= $context['fresh']) {
                 $flag = NEW_FLAG . ' ';
             } elseif ($article['edit_date'] >= $context['fresh']) {
                 $flag = UPDATED_FLAG . ' ';
             } else {
                 $flag = '';
             }
             // title
             $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article');
             // last editor
             if ($article['edit_date']) {
                 // find a name, if any
                 if ($article['edit_name']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     // name of last editor
                     $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id']));
                 }
                 $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>';
             }
         }
         // this is another row of the output
         $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post));
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
示例#19
0
文件: describe.php 项目: rair/yacs
 if ($item['web_address']) {
     $text .= '		<foaf:homepage rdf:resource="' . encode_field($item['web_address']) . '" />' . "\n";
 } else {
     $text .= '		<foaf:homepage rdf:resource="' . encode_field(Users::get_permalink($item)) . '" />' . "\n";
 }
 // the user avatar
 if ($item['avatar_url']) {
     if ($item['avatar_url'][0] == '/') {
         $item['avatar_url'] = str_replace('//', '/', $context['url_to_home'] . $context['url_to_root'] . $item['avatar_url']);
     }
     $text .= '		<foaf:img rdf:resource="' . encode_field($item['avatar_url']) . '" />' . "\n";
 }
 // list watched users by posts
 if ($items =& Members::list_users_by_posts_for_member('user:'******'id'], 0, USERS_PER_PAGE, 'raw')) {
     foreach ($items as $id => $attributes) {
         $text .= '	<foaf:knows>' . "\n" . '		<foaf:Person>' . "\n" . '			<foaf:name>' . encode_field($attributes['full_name']) . '</foaf:name>' . "\n" . '			<rdfs:seeAlso rdf:resource="' . encode_field($context['url_to_home'] . $context['url_to_root'] . Users::get_url($id, 'describe')) . '" />' . "\n" . '		</foaf:Person>' . "\n" . '	</foaf:knows>' . "\n";
     }
 }
 $text .= '	</foaf:Person>' . "\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');
     Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
示例#20
0
文件: query.php 项目: rair/yacs
     $fields[] = $field;
 }
 // the title
 if (!isset($item['title'])) {
     $item['title'] = '';
 }
 $label = i18n::s('Query object') . ' *';
 $input = '<textarea name="title" rows="2" cols="50">' . encode_field($item['title']) . '</textarea>';
 $hint = i18n::s('The main object of your query');
 $fields[] = array($label, $input, $hint);
 // the description
 if (!isset($item['description'])) {
     $item['description'] = '';
 }
 $label = i18n::s('Details of your request');
 $input = '<textarea name="description" rows="20" cols="50">' . encode_field($item['description']) . '</textarea>';
 $hint = i18n::s('Please mention any reference information required to process the request');
 $fields[] = array($label, $input, $hint);
 // build the form
 $context['text'] .= Skin::build_form($fields);
 // bottom commands
 $menu = array();
 // the submit button
 $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
 // step back
 if (isset($_SERVER['HTTP_REFERER'])) {
     $menu[] = Skin::build_link($_SERVER['HTTP_REFERER'], i18n::s('Cancel'), 'span');
 }
 // display the menu
 $context['text'] .= Skin::finalize_list($menu, 'menu_bar');
 // end of the form
示例#21
0
 /**
  * list articles for search requests
  *
  * @param resource the SQL result
  * @return array of resulting items ($score, $summary), or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of array($score, $summary)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         // the introductory text
         if ($introduction) {
             $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
             // link to description, if any
             if ($item['description']) {
                 $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
             }
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // details
         $details = array();
         // the author
         if ($item['create_name'] != $item['edit_name']) {
             $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
         } else {
             $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the main anchor link
         if (is_object($anchor)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // display all tags
         if ($item['tags']) {
             $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // item summary
         $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix;
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // build the complete HTML element
         if ($icon) {
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
             // default icon
         } else {
             $icon = DECORATED_IMG;
         }
         // layout this item
         $list = array(array($box, $icon));
         $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
示例#22
0
文件: petition.php 项目: rair/yacs
 /**
  * build the list of fields for one overlay
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     // accepted voters
     $label = i18n::s('Scope');
     $input = '<input type="radio" name="voters" value="members"';
     if (!isset($this->attributes['voters']) || $this->attributes['voters'] == 'members') {
         $input .= ' checked="checked"';
     }
     $input .= ' /> ' . i18n::s('All members of the community') . BR . "\n";
     $input .= '<input type="radio" name="voters" value="editors"';
     if (isset($this->attributes['voters']) && $this->attributes['voters'] == 'editors') {
         $input .= ' checked="checked"';
     }
     $input .= ' /> ' . i18n::s('Editors of this section') . BR . "\n";
     $input .= '<input type="radio" name="voters" value="associates"';
     if (isset($this->attributes['voters']) && $this->attributes['voters'] == 'associates') {
         $input .= ' checked="checked"';
     }
     $input .= ' /> ' . i18n::s('Associates only') . BR . "\n";
     $input .= '<input type="radio" name="voters" value="custom"';
     if (isset($this->attributes['voters']) && $this->attributes['voters'] == 'custom') {
         $input .= ' checked="checked"';
     }
     $input .= ' /> ' . i18n::s('Following people:') . ' <input type="text" name="voter_list"  onfocus="document.main_form.voters[3].checked=\'checked\'" size="40" />' . BR . "\n";
     $fields[] = array($label, $input);
     // end date
     $label = i18n::s('End date');
     // adjust date from UTC time zone to surfer time zone
     $value = '';
     if (isset($this->attributes['end_date']) && $this->attributes['end_date'] > NULL_DATE) {
         $value = Surfer::from_GMT($this->attributes['end_date']);
     }
     $input = '<input type="text" name="end_date" value ="' . encode_field($value) . '" size="32" maxlength="64" />';
     $hint = i18n::s('YYYY-MM-AA HH:MM');
     $fields[] = array($label, $input, $hint);
     return $fields;
 }
示例#23
0
文件: template.php 项目: rair/yacs
echo "\t" . '<meta http-equiv="Content-Type" content="' . $context['content_type'] . '; charset=' . $context['charset'] . '" />' . "\n";
// we have one style sheet for everything -- media="all" means it is not loaded by Netscape Navigator 4
echo "\t" . '<link rel="stylesheet" href="' . $context['url_to_root'] . 'skins/joi/joi.css" type="text/css" media="all" />' . "\n";
// other head directives
Page::meta();
// end of the header
echo '</head>' . "\n";
// start the body
Page::body();
// limit the horizontal size of everything, and center it in the page
echo '<div id="wrapper">' . "\n";
// the header panel comes before everything
echo '<div id="header_panel">' . "\n";
// the site name -- can be replaced, through CSS, by an image -- access key 1
if ($context['site_name'] && is_callable(array('i18n', 's'))) {
    echo "\t" . '<p id="header_title"><a href="' . $context['url_to_root'] . '" title="' . encode_field(i18n::s('Front page')) . '" accesskey="1">' . $context['site_name'] . '</a></p>' . "\n";
}
// site slogan
if ($context['site_slogan']) {
    echo "\t" . '<p id="header_slogan">' . $context['site_slogan'] . '</p>' . "\n";
}
// end of the header panel
echo '</div>' . "\n";
// the main panel
echo '<div id="main_panel">' . "\n";
// display bread crumbs if not at the front page; if not defined, only the 'Home' link will be displayed
if ($context['skin_variant'] != 'home') {
    Page::bread_crumbs(0);
}
// display main content
Page::content();
示例#24
0
         $panels[] = array('options', i18n::s('Options'), 'options_panel', $text);
     }
     // preserve attributes coming from template duplication
     if (!isset($item['id'])) {
         $hidden = array('behaviors', 'extra', 'icon_url', 'index_map', 'prefix', 'suffix', 'trailer');
         foreach ($hidden as $name) {
             if (isset($item[$name])) {
                 $context['text'] .= '<input type="hidden" name="' . $name . '" value="' . $item[$name] . '" />';
             }
         }
     }
     // or preserve attributes not managed interactively
 } else {
     // preserve overlay type
     if (is_object($overlay)) {
         $context['text'] .= '<input type="hidden" name="overlay_type" value="' . encode_field($overlay->get_type()) . '" />';
     }
     // preserve attributes coming from template duplication
     if (!isset($item['id'])) {
         $hidden = array('behaviors', 'extra', 'icon_url', 'index_map', 'locked', 'meta', 'options', 'prefix', 'rank', 'source', 'suffix', 'thumbnail_url', 'trailer');
         foreach ($hidden as $name) {
             if (isset($item[$name])) {
                 $context['text'] .= '<input type="hidden" name="' . $name . '" value="' . $item[$name] . '" />';
             }
         }
     }
 }
 //
 // assemble all tabs
 //
 $context['text'] .= Skin::build_tabs($panels);
示例#25
0
/**
 * promotion_dialog_markup()
 */
function promotion_dialog_markup($href_this, $current_player, $row, $col, $history)
{
    $current_player = !$current_player;
    $player_pieces = get_player_pieces($current_player);
    $field = rowcol_to_field($row, $col);
    $ret = "<ul class=\"popup\">\n";
    $field_code = encode_field($field);
    $code_r = '(' . $field_code . $player_pieces[PIECE_ROOK] . ')';
    $code_k = '(' . $field_code . $player_pieces[PIECE_KNIGHT] . ')';
    $code_b = '(' . $field_code . $player_pieces[PIECE_BISHOP] . ')';
    $code_q = '(' . $field_code . $player_pieces[PIECE_QUEEN] . ')';
    if ($current_player == WHITES_MOVE) {
        $color = GET_WHITE;
        $next_player = GET_BLACK;
    } else {
        $color = GET_BLACK;
        $next_player = GET_WHITE;
    }
    $t_color = ucfirst($color);
    $href_this = update_href($href_this, GET_PLAYER, $next_player);
    $href_r = update_href($href_this, GET_HISTORY, $history . $code_r);
    $href_n = update_href($href_this, GET_HISTORY, $history . $code_k);
    $href_b = update_href($href_this, GET_HISTORY, $history . $code_b);
    $href_q = update_href($href_this, GET_HISTORY, $history . $code_q);
    if (USE_UNICODE_GLYPHS) {
        $r = '&#9814;';
        $n = '&#9816;';
        $b = '&#9815;';
        $q = '&#9813;';
    } else {
        $r = $player_pieces[PIECE_ROOK];
        $n = $player_pieces[PIECE_KNIGHT];
        $b = $player_pieces[PIECE_BISHOP];
        $q = $player_pieces[PIECE_QUEEN];
    }
    $ret .= "<li><a href=\"{$href_r}\"><div class=\"{$color} rook\" title=\"{$t_color} rook\">{$r}</div></a>\n";
    $ret .= "<li><a href=\"{$href_n}\"><div class=\"{$color} knight\" title=\"{$t_color} knight\">{$n}</div></a>\n";
    $ret .= "<li><a href=\"{$href_b}\"><div class=\"{$color} bishop\" title=\"{$t_color} bishop\">{$b}</div></a>\n";
    $ret .= "<li><a href=\"{$href_q}\"><div class=\"{$color} queen\" title=\"{$t_color} queen\">{$q}</div></a>\n";
    $ret .= "</ul>\n\n";
    return $ret;
}
示例#26
0
文件: blog_test.php 项目: rair/yacs
$target = '';
if (isset($_REQUEST['target'])) {
    $target = $_REQUEST['target'];
} elseif (isset($context['host_name'])) {
    $target = $context['host_name'] . rtrim($context['url_to_root'], '/');
}
$user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
$user_password = isset($_REQUEST['user_password']) ? $_REQUEST['user_password'] : '';
// display a specific form
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
$label = i18n::s('Server address');
$input = '<input type="text" name="target" id="target" size="30" maxlength="128" value="' . encode_field($target) . '" />' . "\n" . ' ' . Skin::build_submit_button(i18n::s('Go'));
$hint = i18n::s('The name or the IP address of the yacs server');
$fields[] = array($label, $input, $hint);
$label = i18n::s('User name');
$input = '<input type="text" name="user_name" size="30" maxlength="128" value="' . encode_field($user_name) . '" />';
$fields[] = array($label, $input);
$label = i18n::s('User password');
$input = '<input type="password" name="user_password" size="30" maxlength="128" value="' . $user_password . '" />';
$fields[] = array($label, $input);
$context['text'] .= Skin::build_form($fields);
$context['text'] .= '</div></form>';
// set the focus at the first field
Page::insert_script('$("#target").focus();');
// do the test
if (isset($_REQUEST['target'])) {
    // call blog web service
    $url = 'http://' . $_REQUEST['target'] . '/services/blog.php';
    // blogger.getUserInfo
    $context['text'] .= Skin::build_block('blogger.getUserInfo', 'title');
    $parameters = array('dummy_appkey', $user_name, $user_password);
示例#27
0
文件: select.php 项目: rair/yacs
     // break an assignment, and also purge the watch list
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && isset($_REQUEST['member'])) {
     Members::free($_REQUEST['anchor'], $_REQUEST['member']);
     if (preg_match('/^user:/', $_REQUEST['anchor'])) {
         Members::free($_REQUEST['member'], $_REQUEST['anchor']);
     }
 }
 // insert anchor prefix
 if (is_object($anchor)) {
     $context['text'] .= $anchor->get_prefix();
 }
 // the current list of linked sections
 $sections =& Members::list_sections_by_title_for_anchor($anchor->get_reference(), 0, SECTIONS_LIST_SIZE, 'raw');
 // the form to link additional sections
 if (!is_array($sections) || count($sections) < SECTIONS_LIST_SIZE) {
     $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . i18n::s('To assign a section, look in the content tree below and assign one section at a time') . BR . '<select name="member">' . Sections::get_options(NULL, $sections) . '</select>' . ' ' . Skin::build_submit_button(' >> ') . '<input type="hidden" name="anchor" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n";
 }
 // splash
 $context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>';
 // layout assigned sections
 if ($sections) {
     // browse the list
     foreach ($sections as $id => $section) {
         // get the related overlay, if any
         $overlay = Overlay::load($section, 'section:' . $id);
         // get parent anchor
         $parent = Anchors::get($section['anchor']);
         // the url to view this item
         $url = Sections::get_permalink($section);
         // use the title to label the link
         if (is_object($overlay)) {
示例#28
0
文件: configure.php 项目: rair/yacs
 $input .= '/> ' . i18n::s('Yes, and following parameters are used for the mapping to the FTP service.') . "\n";
 $fields[] = array($label, $input);
 // the path prefix
 if (!isset($context['files_path'])) {
     $context['files_path'] = '';
 }
 $label = i18n::s('Local path');
 $input = '<input type="text" name="files_path" size="45" value="' . encode_field($context['files_path']) . '" maxlength="255" />';
 $hint = i18n::s('The place where shared files will be written.');
 $fields[] = array($label, $input, $hint);
 // the ftp prefix
 if (!isset($context['files_url'])) {
     $context['files_url'] = '';
 }
 $label = i18n::s('FTP prefix');
 $input = '<input type="text" name="files_url" size="45" value="' . encode_field($context['files_url']) . '" maxlength="255" />';
 $hint = i18n::s('The ftp:// address that is inserted in links used to download files remotely');
 $fields[] = array($label, $input, $hint);
 // put the set of fields in the page
 $store .= Skin::build_form($fields);
 $fields = array();
 //
 // assemble all tabs
 //
 $all_tabs = array(array('extensions', i18n::s('Extensions'), 'extensions_panel', $extensions), array('store', i18n::s('Storage'), 'store_panel', $store));
 // let YACS do the hard job
 $context['text'] .= Skin::build_tabs($all_tabs);
 //
 // bottom commands
 //
 $menu = array();
示例#29
0
文件: atom_codec.php 项目: rair/yacs
 /**
  * suppress tags and codes from a string
  *
  * This function will remove any yacs code, and also any html tag, from the input string.
  *
  * @param string a label to check
  * @param allowed html tags
  * @return a clean string
  */
 function clean($label, $allowed = '')
 {
     // strip all yacs codes
     $label = preg_replace(array('/\\[(.*?)\\]/s', '/\\[\\/(.*?)\\]/s'), ' ', $label);
     // reintroduce new lines
     $label = preg_replace('/<br\\s*\\/>/i', "\n", $label);
     // make some room around titles, paragraphs, and divisions
     $label = preg_replace('/<(code|div|h1|h2|h3|ol|li|p|pre|ul)>/i', ' <$1>', $label);
     $label = preg_replace('#</(code|div|h1|h2|h3|ol|li|p|pre|ul)>#i', '</$1> ', $label);
     // strip all html tags and encode
     $label = strip_tags($label, $allowed);
     // transform Unicode entities
     $label = utf8::transcode($label);
     // strip all html tags and encode
     return encode_field($label);
 }
示例#30
0
文件: describe.php 项目: rair/yacs
 $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']);
 // suggest a name on download
 if (!headers_sent()) {
     $file_name = Skin::strip($context['page_title']) . '.opml.xml';
     $file_name =& utf8::to_ascii($file_name);
     Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);