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


PHP Codes::beautify方法代码示例

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


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

示例1: layout

 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         // 			if($item['id'] == Surfer::get_id())
         // 				continue;
         $label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>'))));
         if (!$label) {
             $label = ucfirst($item['nick_name']);
         }
         // one entry per address
         $items[trim($item['email'])] = $label;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:38,代码来源:layout_users_as_address.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)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_images_as_feed.php

示例3: layout

 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:62,代码来源:layout_comments_as_thread.php

示例4: layout

 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this link
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url is the link itself
         $url = $item['link_url'];
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = $item['title'];
         } else {
             $label = $url;
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:56,代码来源:layout_links_as_feed.php

示例5: allow

 /**
  * check access rights
  *
  * @param string script name
  * @paral string target anchor, if any
  * @return boolean FALSE if access is denied, TRUE otherwise
  */
 function allow($script, $anchor = NULL)
 {
     global $context;
     // limit the scope of our check
     if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
         return TRUE;
     }
     // sanity check
     if (!$anchor) {
         die(i18n::s('No anchor has been found.'));
     }
     // stop here if the agreement has been gathered previously
     if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
         foreach ($agreements as $agreement) {
             if ($agreement == $anchor) {
                 return TRUE;
             }
         }
     }
     // which agreement?
     if (!$this->parameters) {
         die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
     }
     // do we have a related file to display?
     if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
         die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
     }
     // splash message
     $context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
     // load and display the file to be displayed
     $context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
     // target link to record agreement
     if ($context['with_friendly_urls'] == 'Y') {
         $agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
     } else {
         $agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
     }
     // display confirmation buttons at the end of the agreement
     $context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
     $context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
     $context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
     // render the skin based only on text provided by this behavior
     render_skin();
     exit;
 }
开发者ID:rair,项目名称:yacs,代码行数:52,代码来源:agree_on_file_access.php

示例6: layout

 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the user profile
         $url = Users::get_permalink($item);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // item title
         if ($item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
         }
         // the section
         $section = '';
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // introduction
         $introduction = Codes::beautify($item['introduction']);
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:51,代码来源:layout_users_as_feed.php

示例7: layout

 /**
  * list comments
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text .= '<dd style="font-style: italic; font-size: smaller;">' . ucfirst(trim($item['description'])) . ' <span class="details">' . Skin::build_date($item['create_date']) . '</span></dd>';
         } else {
             // the title as the label
             if ($item['create_name']) {
                 $label = ucfirst($item['create_name']);
             } else {
                 $label = i18n::s('anonymous');
             }
             // expand a definition list
             $text .= '<dt>' . $label . '</dt>' . '<dd>' . $item['description'] . ' <span class="details">' . Skin::build_date($item['create_date']) . '</span></dd>' . "\n";
         }
     }
     // finalize the definition list
     if ($text) {
         $text = '<dl class="comments">' . $text . '</dl>';
     }
     // process yacs codes at once
     $text = Codes::beautify($text);
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:44,代码来源:layout_comments_as_excerpt.php

示例8: layout

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

示例9: array

    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('The action has not been confirmed.'));
    // ask for confirmation
} else {
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this location'), NULL, NULL, 'confirmed');
    if (is_object($anchor)) {
        $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span');
    }
    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    // the geo_place_name of the location
    $context['text'] .= Skin::build_block($item['geo_place_name'], 'title');
    // display the full text
    $context['text'] .= '<div style="margin: 1em 0;">' . Codes::beautify($item['description']) . '</div>' . "\n";
    // more details
    $details = array();
    // information on uploader
    if (Surfer::is_member() && $item['edit_name']) {
        $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
    }
    // the complete details
    if ($details) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php

示例10: gmdate

    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the article
} else {
    // initialize the rendering engine
    Codes::initialize(Articles::get_permalink($item));
    // compute the url for this article
    $permanent_link = Articles::get_permalink($item);
    // the trackback link
    $trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id'];
    // get a description -- render codes
    if (isset($item['introduction']) && $item['introduction']) {
        $description = Codes::beautify($item['introduction'], $item['options']);
    } else {
        $description = Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
    }
    // prepare the response
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . '		   xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . '		   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '	<rdf:Description' . "\n" . '		trackback:ping="' . $trackback_link . '"' . "\n" . '		dc:identifier="' . $permanent_link . '"' . "\n" . '		rdf:about="' . $permanent_link . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
    if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
        $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
    }
    if (is_object($anchor)) {
        $text .= '	<dc:subject>' . encode_field($anchor->get_title()) . '</dc:subject>' . "\n";
    }
    $text .= '	</rdf:Description>' . "\n" . '</rdf:RDF>';
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:describe.php

示例11: layout

 /**
  * list links
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolink
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'no_anchor';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // flag links uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // the number of clicks
         if ($item['hits'] > 1) {
             $suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // details
         $details = array();
         // item poster
         if ($item['edit_name'] && $this->layout_variant != 'no_author') {
             if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         }
         // show an anchor link
         if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
             $details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // description
         if ($item['description']) {
             $suffix .= BR . Codes::beautify($item['description']);
         }
         // build the actual link to check it
         if ($this->layout_variant == 'review') {
             $icon = $item['link_url'];
         }
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // let the rendering engine guess the type of link
         $link_type = NULL;
         // except if we want to stay within this window
         if (isset($item['link_target']) && $item['link_target'] != 'I') {
             $link_type = 'external';
         }
         // hovering title
         $link_title = NULL;
         if (isset($item['link_title']) && $item['link_title']) {
             $link_title = $item['link_title'];
         }
         // pack everything
         $items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:96,代码来源:layout_links.php

示例12:

    }
    // make a box
    if ($items) {
        $items =& Skin::build_box($title, $items, 'header1', 'recent_articles');
    }
}
$context['text'] .= $items;
// the suffix hook
if (is_callable(array('Hooks', 'include_scripts'))) {
    $context['text'] .= Hooks::include_scripts('index.php#suffix');
}
// the trail of the cover article
if (!isset($context['root_cover_at_home']) || $context['root_cover_at_home'] != 'none') {
    // may be changed in skin.php if necessary
    if (isset($cover_page['trailer'])) {
        $context['text'] .= Codes::beautify($cover_page['trailer']);
    }
}
//
// compute extra information -- $context['extra']
//
// page tools
//
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('configure.php', i18n::s('Configure'));
    if (isset($cover_page['id'])) {
        $context['page_tools'][] = Skin::build_link(Articles::get_permalink($cover_page), i18n::s('Cover page'), 'basic');
    }
    if (($section = Sections::get('gadget_boxes')) && isset($section['id'])) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Gadget boxes'), 'basic');
    }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php

示例13: sprintf

// ++...++
$context['text'] .= '[title]' . i18n::s('Wiki insertion') . ' [escape]++...++[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text ++has been inserted++.') . '[/escape]</td>' . '<td>' . i18n::s('This text ++has been inserted++.') . '</td></tr>' . Skin::table_suffix();
// [inserted]...[/inserted]
$context['text'] .= '[title]' . i18n::s('Inserted') . ' [escape][inserted]...[/inserted][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text [inserted]has been inserted[/inserted].') . '[/escape]</td>' . '<td>' . i18n::s('This text [inserted]has been inserted[/inserted].') . '</td></tr>' . Skin::table_suffix();
// --...--
$context['text'] .= '[title]' . i18n::s('Wiki deletion') . ' [escape]--...--[/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text --has been deleted--.') . '[/escape]</td>' . '<td>' . i18n::s('This text --has been deleted--.') . '</td></tr>' . Skin::table_suffix();
// [deleted]...[/deleted]
$context['text'] .= '[title]' . i18n::s('Deleted') . ' [escape][deleted]...[/deleted][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('This text [deleted]has been deleted[/deleted].') . '[/escape]</td>' . '<td>' . i18n::s('This text [deleted]has been deleted[/deleted].') . '</td></tr>' . Skin::table_suffix();
// [flag]...[/flag]
$context['text'] .= '[title]' . i18n::s('Flag') . ' [escape][flag]...[/flag][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape]' . i18n::s('[flag]important![/flag] Don\'t forget to give something to your cat today.') . '[/escape]</td>' . '<td>' . i18n::s('[flag]important![/flag] Don\'t forget to give something to your cat today.') . '</td></tr>' . Skin::table_suffix();
// [lang=xy]...[/lang]
$context['text'] .= '[title]' . i18n::s('Language') . ' [escape][lang=xy]...[/lang][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][lang=en]This is in English[/lang][lang=fr]Ceci est en fran&ccedil;ais[/lang][/escape]</td>' . '<td>[lang=en]This is in English[/lang][lang=fr]Ceci est en fran&ccedil;ais[/lang]</td></tr>' . Skin::table_suffix();
// [style=serif]...[/style]
$context['text'] .= '[title]' . i18n::s('Serif') . ' [escape][style=serif]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=serif]' . i18n::s('This text is in Serif.') . '[/style][/escape]</td>' . '<td>[style=serif]' . i18n::s('This text is in Serif.') . '[/style]</td></tr>' . Skin::table_suffix();
// [style=sans-serif]...[/style]
$context['text'] .= '[title]' . i18n::s('Sans-Serif') . ' [escape][style=sans-serif]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=sans-serif]' . i18n::s('This text is in Sans-Serif.') . '[/style][/escape]</td>' . '<td>[style=sans-serif]' . i18n::s('This text is in Sans-Serif.') . '[/style]</td></tr>' . Skin::table_suffix();
// [style=cursive]...[/style]
$context['text'] .= '[title]' . i18n::s('Cursive') . ' [escape][style=cursive]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=cursive]' . i18n::s('This text is in Cursive.') . '[/style][/escape]</td>' . '<td>[style=cursive]' . i18n::s('This text is in Cursive.') . '[/style]</td></tr>' . Skin::table_suffix();
// [style=fantasy]...[/style]
$context['text'] .= '[title]' . i18n::s('Fantasy') . ' [escape][style=fantasy]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=fantasy]' . i18n::s('This text is in Fantasy.') . '[/style][/escape]</td>' . '<td>[style=fantasy]' . i18n::s('This text is in Fantasy.') . '[/style]</td></tr>' . Skin::table_suffix();
// [style=comic]...[/style]
$context['text'] .= '[title]' . i18n::s('Comic') . ' [escape][style=comic]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=comic]' . i18n::s('This text is in Comic.') . '[/style][/escape]</td>' . '<td>[style=comic]' . i18n::s('This text is in Comic.') . '[/style]</td></tr>' . Skin::table_suffix();
// [style]...[/style]
$context['text'] .= '[title]' . i18n::s('Use any style') . ' [escape][style=&lt;style name&gt;]...[/style][/escape][/title]' . Skin::table_prefix('wide') . Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header') . '<tr><td class="sample">[escape][style=my_style]' . i18n::s('But where will this rabbit be in some minutes? I don\'t know, but it depends also on the turtle speed...') . '[/style][/escape]</td>' . '<td>[style=my_style]' . i18n::s('But where will this rabbit be in some minutes? I don\'t know, but it depends also on the turtle speed...') . '[/style]</td></tr>' . Skin::table_suffix();
// transform the text
$context['text'] = Codes::beautify($context['text']);
// general help on this page
$help = '<p>' . sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')) . '</p>';
$context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:basic.php

示例14: layout

 /**
  * list articles as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $title = $abstract = $author = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $title .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $title .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $title .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $title .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $title .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $title .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $title .= ' ' . UPDATED_FLAG;
         }
         // the icon
         if ($item['thumbnail_url']) {
             $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
         }
         // the introductory text
         if (is_object($overlay)) {
             $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } elseif ($item['introduction']) {
             $abstract .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $abstract .= $overlay->get_text('list', $item);
         }
         // make some abstract out of main text
         if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
             $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // describe attachments
         if (count($details)) {
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_table.php

示例15: ping

 /**
  * ping back links referenced in some text
  *
  * This is the client implementation of
  * [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link]
  * and [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specifications.
  *
  * This function is triggered by publishing scripts, either [script]articles/publish.php[/script],
  * [script]services/blog.php[/script], [script]agents/messages.php[/script] or [script]agents/uploads.php[/script].
  *
  * @see articles/publish.php
  * @see services/blog.php
  * @see agents/messages.php
  * @see agents/uploads.php
  *
  * It is used to efficiently link pages across a set of web sites according to the following mechanism:
  * - The list of external links is built for this page
  * - Only the 7 first links are kept from the list; others are stripped
  * - If links do not exist, create additional records in the table used for links
  * - Each link (actually, only the 7 most recent) is checked, to see if it's trackback- or pingback-enabled or not
  * - Each trackback-/pingback-enabled link is activated, providing the full URL of the anchor page
  *
  * We are claiming to support most of the trackback client interface here, as described in the [link=trackback]http://www.movabletype.org/docs/mttrackback.html[/link] specification.
  * A foreign page is considered as being trackback-enabled if it has a special RDF section
  * linking its reference (i.e., URL) to a Trackback Ping URL.
  *
  * Note that YACS also implements the server part of the trackback specification in [script]links/trackback.php[/script],
  * which supports POST REST calls.
  *
  * @see links/trackback.php
  *
  * We are claiming to fully support the pingback client interface here, as described in the [link=pingback]http://www.hixie.ch/specs/pingback/pingback[/link] specification.
  * A foreign page is considered to be pingback-enabled if it has a meta link to a Pingback Ping URL.
  *
  * Note that YACS also implements the server part of the pingback specification in [script]services/ping.php[/script],
  * which supports XML-RPC calls.
  *
  * @see services/ping.php
  *
  * This function transforms every YACS codes into HTML before extracting links,
  * and before submitting the excerpt to remote site.
  *
  * @param string the referencing text that has to be scanned
  * @param string the local anchor of the referencing text (e.g., 'article:124')
  * @return array list($links, $advertised, $skipped)
  *
  * @link http://www.movabletype.org/docs/mttrackback.html TrackBack Technical Specification
  * @link http://www.hixie.ch/specs/pingback/pingback Pingback specification
  */
 public static function ping($text, $anchor)
 {
     global $context;
     // render all codes
     if (is_callable(array('Codes', 'beautify'))) {
         $text = Codes::beautify($text);
     }
     // suppress all links not coming from anchors (eg, <img src=...)
     $text = strip_tags($text, '<a>');
     // extract all links from the text, including those that have been encoded by YACS
     preg_match_all('/((http:\\/\\/|http%3A%2F%2F)[^ <"]+)/i', $text, $links);
     // nothing to do
     if (!@count($links[1])) {
         return;
     }
     // process each link only once
     $unique_links = array();
     foreach ($links[1] as $url) {
         // decode raw url encoding, if any
         $url = rawurldecode($url);
         // strip the clicking indirection, if any
         $url = rawurldecode(preg_replace('/^' . preg_quote($context['url_to_home'] . $context['url_to_root'] . 'links/click.php?url=', '/') . '/i', '', $url));
         $unique_links[$url] = 1;
     }
     // analyze found links
     $links_processed = array();
     $links_advertised = array();
     $links_skipped = array();
     foreach ($unique_links as $url => $dummy) {
         // analyze no more than 7 links
         if (@count($links_processed) >= 7) {
             break;
         }
         // skip links that point to ourself, and not to an article
         if (preg_match('/^' . preg_quote($context['url_to_home'], '/') . '\\b/i', $url) && !preg_match('/\\/article(-|s\\/view.php)/i', $url)) {
             $links_skipped[] = $url;
             continue;
         }
         // skip invalid links
         if (($content = http::proceed($url)) === FALSE) {
             $links_skipped[] = $url;
             continue;
         }
         // we will use the content to locate pingback and trackback interfaces
         $pages[$url] = $content;
         // ensure enough execution time
         Safe::set_time_limit(30);
         // stats
         $links_processed[] = $url;
     }
     // locate the anchor object for this text, we need its url
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:links.php


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