当前位置: 首页>>代码示例>>PHP>>正文


PHP Skin::build_number方法代码示例

本文整理汇总了PHP中Skin::build_number方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::build_number方法的具体用法?PHP Skin::build_number怎么用?PHP Skin::build_number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Skin的用法示例。


在下文中一共展示了Skin::build_number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: layout

 /**
  * list files
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // initialize variables
         $prefix = $suffix = '';
         // flag files that are dead, or created or updated very recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // 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']));
         }
         // with hits
         if ($item['hits'] > 1) {
             $suffix .= ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('downloads')) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:51,代码来源:layout_files_as_hits.php

示例2: layout

 /**
  * 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)) {
         // url to view the image
         $url = Images::get_url($item['id']);
         // initialize variables
         $prefix = $suffix = '';
         // flag new images
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // image title or image name
         $label = Skin::strip($item['title'], 10);
         if (!$label) {
             $name_as_title = TRUE;
             $label = ucfirst($item['image_name']);
         }
         $label = str_replace('_', ' ', str_replace('%20', ' ', $label));
         // with hits
         if ($item['hits'] > 1) {
             $suffix .= ' ' . Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:46,代码来源:layout_images_as_hits.php

示例3: array

    // display in a separate panel
    if (trim($referrals)) {
        $panels[] = array('referrals', i18n::s('Referrals'), 'referrals_panel', $referrals);
    }
    //
    // requests from search engines
    //
    $searches = '';
    include_once $context['path_to_root'] . 'agents/referrals.php';
    if ($result = Referrals::list_by_keywords(0, 50)) {
        // table row
        $headers = array(i18n::s('Keywords'), i18n::s('Count'));
        // table rows
        $rows = array();
        while ($item = SQL::fetch($result)) {
            $rows[] = array('left=' . Skin::build_link($item['referer'], $item['keywords'], 'external'), 'left=' . Skin::build_number($item['hits']));
        }
        // render the table
        $searches .= Skin::table($headers, $rows);
    }
    // display in a separate panel
    if (trim($searches)) {
        $panels[] = array('searches', i18n::s('Searches'), 'searches_panel', $searches);
    }
    //
    // assemble all tabs
    //
    $context['text'] .= Skin::build_tabs($panels);
}
// referrals, if any
$context['components']['referrals'] = Skin::build_referrals('agents/index.php');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php

示例4: list

             list($link, $title, $description) = $attributes;
             $item['source'] = Skin::build_link($link, $title);
         }
     }
     $cells = array(i18n::s('Source'), 'left=' . $item['source']);
     $context['text'] .= Skin::table_row($cells, $lines++);
 }
 // actual file name
 $cells = array(i18n::s('Actual file'), 'left=' . $item['file_name']);
 $context['text'] .= Skin::table_row($cells, $lines++);
 // file size
 $cells = array(i18n::s('File size'), 'left=' . sprintf(i18n::s('%d bytes'), $item['file_size']));
 $context['text'] .= Skin::table_row($cells, $lines++);
 // hits
 if ($item['hits'] > 1) {
     $cells = array(i18n::s('Downloads'), 'left=' . Skin::build_number($item['hits'], i18n::s('downloads')));
     $context['text'] .= Skin::table_row($cells, $lines++);
 }
 // the first poster
 if ($item['create_name']) {
     $cells = array(i18n::s('Posted by'), $item['create_name']);
     $context['text'] .= Skin::table_row($cells, $lines++);
 }
 // the last poster
 if ($item['edit_name'] != $item['create_name']) {
     $cells = array(i18n::s('Updated by'), $item['edit_name']);
     $context['text'] .= Skin::table_row($cells, $lines++);
 }
 // date of last action
 $cells = array(i18n::s('Last action'), Skin::build_date($item['edit_date']));
 $context['text'] .= Skin::table_row($cells, $lines++);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php

示例5: layout

 /**
  * list articles for manual review
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @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
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = '';
         // 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;
         }
         // details
         $details = array();
         // the author(s)
         if ($item['create_name'] != $item['edit_name']) {
             $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
         } else {
             $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $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'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // append details to the suffix
         $suffix .= ' -&nbsp;<span class="details">' . ucfirst(trim(implode(', ', $details))) . '</span>';
         // commands to review the article
         $menu = array();
         // read the page
         $menu = array_merge($menu, array($url => i18n::s('Read')));
         // validate the page
         $menu = array_merge($menu, array('articles/stamp.php?id=' . $item['id'] . '&amp;confirm=review' => i18n::s('Validate')));
         // add a menu
         $suffix .= ' ' . Skin::build_list($menu, 'menu');
         // list all components for this item
         $items[$url] = array($prefix, $title, $suffix, 'basic', NULL);
     }
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_review.php

示例6: sprintf

    $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:' . $item['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 = '';
        if (Surfer::may_upload()) {
            $text .= '<p>' . i18n::s('Click on one image below to make it your new picture.') . '</p>' . "\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select_avatar.php

示例7: layout

 /**
  * 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
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_files.php

示例8: layout


//.........这里部分代码省略.........
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // the introductory text
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name'] != $item['edit_name']) {
                 $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
             } else {
                 $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
             }
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         $stats = Files::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
         }
         // info on related links
         $stats = Links::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
         }
         // info on related comments
         $stats = Comments::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // list up to three categories by title, if any
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (count($anchors)) {
             $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
         }
         // end of details
         $suffix .= '</span>';
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         // commands
         $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
         // link to this page
         $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
         // ranking
         $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
         // append the row
         $text .= Skin::table_row($cells, $count++);
     }
     // select all rows
     $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
     $text .= Skin::table_row($cells, $count++);
     // table suffix
     $text .= Skin::table_suffix();
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_manage.php

示例9: upload


//.........这里部分代码省略.........
                     return FALSE;
                 }
                 // one single file has been uploaded
             } else {
                 $context['uploaded_files'] = array($file_name);
             }
             // ensure we know the surfer
             Surfer::check_default_editor($_REQUEST);
             // post-process all uploaded files
             foreach ($context['uploaded_files'] as $file_name) {
                 // this will be filtered by umask anyway
                 Safe::chmod($context['path_to_root'] . $file_path . $file_name, $context['file_mask']);
                 // invoke post-processing function
                 if ($target && is_callable($target)) {
                     call_user_func($target, $file_name, $context['path_to_root'] . $file_path);
                     // we have to update an anchor page
                 } elseif ($target && is_string($target)) {
                     $fields = array();
                     // update a file with the same name for this anchor
                     if ($matching =& Files::get_by_anchor_and_name($target, $file_name)) {
                         $fields['id'] = $matching['id'];
                     } elseif (isset($input['id']) && ($matching = Files::get($input['id']))) {
                         $fields['id'] = $matching['id'];
                         // silently delete the previous version of the file
                         if (isset($matching['file_name'])) {
                             Safe::unlink($file_path . '/' . $matching['file_name']);
                         }
                     }
                     // prepare file record
                     $fields['file_name'] = $file_name;
                     $fields['file_size'] = filesize($context['path_to_root'] . $file_path . $file_name);
                     $fields['file_href'] = '';
                     $fields['anchor'] = $target;
                     // change title
                     if (isset($_REQUEST['title'])) {
                         $fields['title'] = $_REQUEST['title'];
                     }
                     // change has been documented
                     if (!isset($_REQUEST['version']) || !$_REQUEST['version']) {
                         $_REQUEST['version'] = '';
                     } else {
                         $_REQUEST['version'] = ' - ' . $_REQUEST['version'];
                     }
                     // always remember file uploads, for traceability
                     $_REQUEST['version'] = $fields['file_name'] . ' (' . Skin::build_number($fields['file_size'], i18n::s('bytes')) . ')' . $_REQUEST['version'];
                     // add to file history
                     $fields['description'] = Files::add_to_history($matching, $_REQUEST['version']);
                     // if this is an image, maybe we can derive a thumbnail for it?
                     if (Files::is_image($file_name)) {
                         include_once $context['path_to_root'] . 'images/image.php';
                         Image::shrink($context['path_to_root'] . $file_path . $file_name, $context['path_to_root'] . $file_path . 'thumbs/' . $file_name);
                         if (file_exists($context['path_to_root'] . $file_path . 'thumbs/' . $file_name)) {
                             $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . $file_path . 'thumbs/' . rawurlencode($file_name);
                         }
                     }
                     // change active_set
                     if (isset($_REQUEST['active_set'])) {
                         $fields['active_set'] = $_REQUEST['active_set'];
                     }
                     // change source
                     if (isset($_REQUEST['source'])) {
                         $fields['source'] = $_REQUEST['source'];
                     }
                     // change keywords
                     if (isset($_REQUEST['keywords'])) {
                         $fields['keywords'] = $_REQUEST['keywords'];
                     }
                     // change alternate_href
                     if (isset($_REQUEST['alternate_href'])) {
                         $fields['alternate_href'] = $_REQUEST['alternate_href'];
                     }
                     // overlay, if any
                     if (is_object($overlay)) {
                         // allow for change detection
                         $overlay->snapshot();
                         // update the overlay from form content
                         $overlay->parse_fields($_REQUEST);
                         // save content of the overlay in this item
                         $fields['overlay'] = $overlay->save();
                         $fields['overlay_id'] = $overlay->get_id();
                     }
                     // create the record in the database
                     if (!($fields['id'] = Files::post($fields))) {
                         return FALSE;
                     }
                     // record surfer activity
                     Activities::post('file:' . $fields['id'], 'upload');
                 }
             }
             // so far so good
             if (count($context['uploaded_files']) == 1) {
                 return $context['uploaded_files'][0];
             } else {
                 return $context['uploaded_files'];
             }
         }
     }
     // some error has occured
     return FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:files.php

示例10: layout


//.........这里部分代码省略.........
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title as a link to the page
         $title = $prefix . Skin::build_link($url, ucfirst($title), 'basic', $hover) . $suffix;
         $suffix = '';
         // the introductory text
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } elseif ($item['introduction']) {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // shortcuts to comments pages
         if (isset($item['comments_count']) && ($pages = (int) ceil($item['comments_count'] / $layout->items_per_page())) && $pages > 1) {
             $suffix .= '<p class="details">Pages ';
             for ($index = 1; $index <= $pages; $index++) {
                 $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&amp;page=' . $index, $index, 'basic', i18n::s('One page of comments')) . ' ';
             }
             $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&amp;page=' . $pages, MORE_IMG, 'basic', i18n::s('Most recent comments')) . '</p>';
         }
         // links to sections and categories
         $anchors = array();
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $anchors[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic', i18n::s('In this section'));
         }
         // list categories by title, if any
         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>';
                 }
                 if (!isset($this->focus) || $this->focus != 'category:' . $category_id) {
                     $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic', i18n::s('Related topics'));
                 }
             }
         }
         // list section and categories in the suffix
         if (@count($anchors)) {
             $suffix .= '<p class="tags">' . implode(' ', $anchors) . '</p>';
         }
         // the creator of this article
         $starter = '';
         if ($item['create_name']) {
             $starter = '<span class="details">' . Users::get_link($item['create_name'], $item['create_address'], $item['create_id']) . '</span>';
         }
         // the last editor
         $details = '';
         if ($item['edit_date']) {
             // find a name, if any
             $user = '';
             if ($item['edit_name']) {
                 // label the action
                 if (isset($item['edit_action'])) {
                     $user .= Anchors::get_action_label($item['edit_action']) . ' ';
                 }
                 // name of last editor
                 $user .= sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
             }
             $details .= $user . ' ' . Skin::build_date($item['edit_date']);
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $details .= ', ' . LOCKED_FLAG;
         }
         // poster details
         if ($details) {
             $details = '<p class="details">' . $details . "</p>\n";
         }
         if (!isset($item['comments_count'])) {
             $item['comments_count'] = 0;
         }
         // this is another row of the output
         $cells = array($title . $suffix, 'center=' . $starter, 'center=' . $item['comments_count'], 'center=' . Skin::build_number($item['hits']), $details);
         if (THREAD_IMG) {
             $cells = array_merge(array($icon), $cells);
         }
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     $headers = array(i18n::s('Topic'), 'center=' . i18n::s('Poster'), 'center=' . i18n::s('Replies'), 'center=' . i18n::s('Views'), i18n::s('Last post'));
     if (THREAD_IMG) {
         $headers = array_merge(array(''), $headers);
     }
     // make a sortable table
     $output = Skin::table($headers, $rows, 'yabb');
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_yabb.php

示例11: list_by_hits

 /**
  * list most popular referrals
  *
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  */
 public static function list_by_hits($offset = 0, $count = 10)
 {
     global $context;
     // the list of referrals
     $query = "SELECT referer, sum(hits) as hits FROM " . SQL::table_name('referrals') . " GROUP BY referer" . " ORDER BY hits DESC LIMIT " . $offset . ', ' . $count;
     if ($result = SQL::query($query, $context['connection'])) {
         while ($row = SQL::fetch($result)) {
             $url = $row['referer'];
             $items[$url] = Skin::build_number($row['hits']);
         }
     }
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:19,代码来源:referrals.php

示例12: sprintf

         $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
     }
     // file size
     if (isset($item['image_size'])) {
         $details[] = Skin::build_number($item['image_size'], i18n::s('bytes'));
     }
     if (count($details)) {
         $input .= ucfirst(implode(BR, $details)) . BR . BR;
     }
 }
 // the upload entry requires rights to upload
 if (Surfer::may_upload()) {
     if (isset($item['id'])) {
         $input .= i18n::s('Select another image to replace the current one') . BR;
     }
     $input .= '<input type="file" name="upload" id="upload" size="30" accesskey="i" title="' . encode_field(i18n::s('Press to select a local file')) . '" />' . ' (&lt;&nbsp;' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')';
     // we are updating a user profile
     if (is_object($anchor) && preg_match('/^user:/i', $anchor->get_reference())) {
         $hint = i18n::s('Select a picture to illustrate this user profile.');
     } elseif ($action == 'avatar') {
         $hint = i18n::s('Select a picture to illustrate this user profile.');
     } elseif ($action == 'thumbnail') {
         $hint = i18n::s('Select a thumbnail picture for this page.');
     } elseif (is_object($anchor)) {
         $hint = i18n::s('Select a .png, .gif or .jpeg image, or a .zip file containing several images.');
     }
 }
 $fields[] = array($label, $input, $hint);
 // not just a bare upload
 if ($action != 'avatar' && $action != 'icon' && $action != 'thumbnail') {
     // the title
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例13: layout

 /**
  * list files 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
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         $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
         $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']));
         // 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'));
         }
         // 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']));
             }
         }
         // the main anchor link
         if (is_object($anchor)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'article'));
         }
         // append details
         if (count($details)) {
             $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // layout this item
         if ($icon) {
             $list = array(array($box, $icon));
             $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
             // put the item in a division
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_files_as_search.php

示例14: layout

 /**
  * list articles
  *
  * Accept following variants:
  * - 'hits', compact plus the number of hits
  * - 'no_author', for articles in the user page
  * - 'category:xxx', if the list is displayed at categories/view.php
  * - 'section:xxx', if the list is displayed at sections/view.php
  *
  * @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 = 'decorated';
     }
     // 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)) {
         // 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;
         }
         // the compact version
         if ($this->layout_variant == 'compact') {
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // with hits
         if ($this->layout_variant == 'hits') {
             if ($item['hits'] > 1) {
                 $suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>';
             }
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // 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
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles.php

示例15: array

    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    // the title of the link
    if ($item['title']) {
        $context['text'] .= Skin::build_block($item['title'], 'title');
    } else {
        $context['text'] .= Skin::build_block($item['link_url'], 'title');
    }
    // the link url, if it has not already been used as title
    if ($item['title']) {
        $context['text'] .= '<p>' . $item['link_url'] . "</p>\n";
    }
    // display the full text
    $context['text'] .= '<div style="margin: 1em 0;">' . Codes::beautify($item['description']) . '</div>' . "\n";
    // 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']));
    }
    // hits
    if ($item['hits'] > 1) {
        $details[] = Skin::build_number($item['hits'], i18n::s('clicks'));
    }
    // all details
    if ($details) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php


注:本文中的Skin::build_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。