Esempio n. 1
0
File: new.php Progetto: rair/yacs
     $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
     $fields['index_map'] = 'N';
     // not mentioned at the home page
     $fields['locked'] = 'Y';
     // no direct contributions
     $fields['options'] = 'no_contextual_menu';
     $fields['rank'] = 40000;
     // at the end of the list
     $fields['sections_layout'] = 'directory';
     $fields['title'] = i18n::c('Groups');
     if (!($fields['id'] = Sections::post($fields, FALSE))) {
         Logger::remember('sections/new.php: Impossible to add a section.');
         return;
     }
     // retrieve the new section
     $anchor = Sections::get('groups');
 }
 // we are creating a blog
 if (isset($_REQUEST['space_type']) && $_REQUEST['space_type'] == 'blog') {
     $_REQUEST['articles_layout'] = 'daily';
     $_REQUEST['articles_templates'] = 'simple_template';
     $_REQUEST['content_options'] = 'with_extra_profile with_neighbours';
     $_REQUEST['options'] = 'with_extra_profile';
     $_REQUEST['locked'] = 'Y';
     // only editors can contribute
     // we are creating a project
 } elseif (isset($_REQUEST['space_type']) && $_REQUEST['space_type'] == 'project') {
     $_REQUEST['articles_layout'] = 'none';
     $_REQUEST['locked'] = 'Y';
     // only section owner can create sub-sections
     $_REQUEST['options'] = 'view_as_tabs';
Esempio n. 2
0
File: index.php Progetto: rair/yacs
// 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');
    }
    if (($section = Sections::get('extra_boxes')) && isset($section['id'])) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Extra boxes'), 'basic');
    }
    if (($section = Sections::get('navigation_boxes')) && isset($section['id'])) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Navigation boxes'), 'basic');
    }
}
// save some database requests
$cache_id = 'index.php#extra_news';
if (!($text = Cache::get($cache_id))) {
    // show featured articles -- set in configure.php
    if (isset($context['root_featured_layout']) && $context['root_featured_layout'] != 'none') {
        // set in configure.php
        if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1) {
            $context['root_featured_count'] = 7;
        }
        // the category used to assign featured pages
        $anchor = Categories::get(i18n::c('featured'));
        if ($anchor['id'] && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'] + 1, 'news'))) {
Esempio n. 3
0
 /**
  * called from within a preg_replace_callback() in Article::parse()
  *
  */
 function parse_match($matches)
 {
     global $context;
     // useful if they are a lot of tags to process
     Safe::set_time_limit(30);
     switch ($matches[1]) {
         case 'anchor':
             $this->item['anchor'] = $matches[2];
             break;
         case 'author':
             if ($user = Users::get($matches[2])) {
                 $this->item['create_name'] = $user['nick_name'];
                 $this->item['create_id'] = $user['id'];
                 $this->item['create_address'] = $user['email'];
                 $this->item['publish_name'] = $user['nick_name'];
                 $this->item['publish_id'] = $user['id'];
                 $this->item['publish_address'] = $user['email'];
                 $this->item['edit_name'] = $user['nick_name'];
                 $this->item['edit_id'] = $user['id'];
                 $this->item['edit_address'] = $user['email'];
             }
             break;
         case 'blogid':
         case 'section':
             if ($section = Sections::get($matches[2])) {
                 $this->item['anchor'] = 'section:' . $section['id'];
             }
             break;
         case 'introduction':
             if (isset($this->item['introduction'])) {
                 $this->item['introduction'] .= $matches[2] . ' ';
             } else {
                 $this->item['introduction'] = $matches[2] . ' ';
             }
             break;
         case 'source':
             $this->item['source'] = $matches[2];
             break;
         case 'tags':
             // web form
         // web form
         case 'category':
             // xml-rpc
         // xml-rpc
         case 'categories':
             // legacy
             if (isset($this->item['tags'])) {
                 $this->item['tags'] .= $matches[2] . ' ';
             } else {
                 $this->item['tags'] = $matches[2] . ' ';
             }
             break;
         case 'title':
             if (isset($this->item['title'])) {
                 $this->item['title'] .= $matches[2] . ' ';
             } else {
                 $this->item['title'] = $matches[2] . ' ';
             }
             break;
         default:
             return $matches[0];
     }
     return '';
 }
Esempio n. 4
0
 // sollicitate users for feed-back
 $context['text'] .= '<p><input type="radio" name="action" value="petition" /> ' . i18n::s('Sollicitate users input -- create a petition, or a poll') . '</p>' . "\n";
 // create a forum
 $context['text'] .= '<p><input type="radio" name="action" value="forum" /> ' . i18n::s('Add a forum -- let people interact') . '</p>' . "\n";
 // create a blog
 $context['text'] .= '<p><input type="radio" name="action" value="blog" /> ' . i18n::s('Add a blog -- and share your feeling, your findings, your soul') . '</p>' . "\n";
 // create a wiki
 $context['text'] .= '<p><input type="radio" name="action" value="wiki" /> ' . i18n::s('Add a wiki -- to support collaborative work in a team of peers') . '</p>' . "\n";
 // post original work
 $context['text'] .= '<p><input type="radio" name="action" value="original" /> ' . i18n::s('Post original work -- in a section that will feature author\'s profiles') . '</p>' . "\n";
 // create a book
 $context['text'] .= '<p><input type="radio" name="action" value="book" /> ' . i18n::s('Add an electronic book, or a manual -- actually, a structured set of pages') . '</p>' . "\n";
 // create a section for polls
 $context['text'] .= '<p><input type="radio" name="action" value="polls" /> ' . i18n::s('Add a section for polls -- the most recent is active; previous polls are still listed') . '</p>' . "\n";
 // create a section for partners if none exists
 if (!Sections::get('partners')) {
     $context['text'] .= '<p><input type="radio" name="action" value="partners" /> ' . i18n::s('Add a section for partners -- the special people or sites that are supporting your site') . '</p>' . "\n";
 }
 // create a cookbook
 $context['text'] .= '<p><input type="radio" name="action" value="recipes" /> ' . i18n::s('Add a cookbook -- cooking recipes, the French secret to happiness') . '</p>' . "\n";
 // create a directory of links
 $context['text'] .= '<p><input type="radio" name="action" value="links" /> ' . i18n::s('Add a directory of links -- a small version of Yahoo!, or of DMOZ') . '</p>' . "\n";
 // create sample server profiles
 $context['text'] .= '<p><input type="radio" name="action" value="servers" /> ' . i18n::s('Add sample server profiles -- ping well-known news aggregator and become famous') . '</p>' . "\n";
 // create basic records
 $context['text'] .= '<p><input type="radio" name="action" value="build" /> ' . i18n::s('Add basic items -- in case you would need to replay some steps of the setup process') . '</p>' . "\n";
 // create a test environment
 if (file_exists($context['path_to_root'] . 'tools/populate.php')) {
     $context['text'] .= '<p><input type="radio" name="action" value="test" /> ' . i18n::s('Add sample items -- for test purpose') . '</p>' . "\n";
 }
 // the submit button
Esempio n. 5
0
 /**
  * load the related item
  *
  * @see shared/anchor.php
  *
  * @param int the id of the record to load
  * @param boolean TRUE to always fetch a fresh instance, FALSE to enable cache
  */
 function load_by_id($id, $mutable = FALSE)
 {
     $this->item = Sections::get($id, $mutable);
 }
Esempio n. 6
0
 /**
  * change the template of a section
  *
  * This function saves the template as an attribute of the section.
  *
  * Also, it attempts to translate it as a valid YACS skin made
  * of [code]template.php[/code] and [code]skin.php[/code].
  * The theme name is [code]section_&lt;id&gt;[/code].
  *
  * Lastly, it updates the options field to actually use the template for pages of this section.
  *
  * @param int the id of the target section
  * @param string the new or updated template
  * @return string either a null string, or some text describing an error to be inserted into the html response
  *
  * @see services/blog.php
  * @see skins/import.php
  **/
 public static function put_template($id, $template, $directory = NULL)
 {
     global $context;
     // id cannot be empty
     if (!$id || !is_numeric($id)) {
         return i18n::s('No item has the provided id.');
     }
     // load section attributes
     if (!($item = Sections::get($id))) {
         return i18n::s('No item has the provided id.');
     }
     // locate the new skin
     if (!$directory) {
         $directory = 'section_' . $id;
     }
     // make a valid YACS skin
     include_once $context['path_to_root'] . 'skins/import.php';
     if ($error = Import::process($template, $directory)) {
         return $error;
     }
     // change the skin for this section
     $options = preg_replace('/\\bskin_.+\\b/i', '', $item['options']) . ' skin_' . $directory;
     // set default values for this editor
     Surfer::check_default_editor(array());
     // update an existing record
     $query = "UPDATE " . SQL::table_name('sections') . " SET " . "template='" . SQL::escape($template) . "',\n" . "options='" . SQL::escape($options) . "',\n" . "edit_name='" . SQL::escape($fields['edit_name']) . "',\n" . "edit_id=" . SQL::escape($fields['edit_id']) . ",\n" . "edit_address='" . SQL::escape($fields['edit_address']) . "',\n" . "edit_action='section:update',\n" . "edit_date='" . SQL::escape($fields['edit_date']) . "'\n" . "\tWHERE id = " . SQL::escape($id);
     SQL::query($query);
     // clear the cache because of the new rendering
     Sections::clear(array('sections', 'section:' . $id, 'categories'));
 }
Esempio n. 7
0
File: event.php Progetto: rair/yacs
 /**
  * list dates at some anchor
  *
  * @param string type of replaced items (e.g., 'articles')
  * @param string the anchor to consider (e.g., 'section:123')
  * @param int page index
  * @return string to be inserted in resulting web page, or NULL
  */
 function render($type, $anchor, $page = 1)
 {
     global $context;
     // instead of articles
     if ($type != 'articles') {
         return NULL;
     }
     // get the containing page
     $container = Anchors::get($anchor);
     // handle dates
     include_once $context['path_to_root'] . 'dates/dates.php';
     // the maximum number of articles per page
     if (!defined('DATES_PER_PAGE')) {
         define('DATES_PER_PAGE', 50);
     }
     // where we are
     $offset = ($page - 1) * DATES_PER_PAGE;
     // should we display all dates, or not?
     $with_past_dates = FALSE;
     if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) {
         $with_past_dates = TRUE;
     }
     // menu to be displayed at the top
     $menu = array();
     // empowered users can contribute
     if (Articles::allow_creation(NULL, $container)) {
         Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
         $menu[] = '<div style="display: inline">' . Skin::build_link('articles/edit.php?anchor=' . urlencode($anchor), ARTICLES_ADD_IMG . i18n::s('Add an event'), 'span') . '</div>';
     }
     // ensure access to past dates
     if (!$with_past_dates && ($items = Dates::list_past_for_anchor($anchor, $offset, DATES_PER_PAGE, 'compact'))) {
         // turn an array to a string
         if (is_array($items)) {
             $items =& Skin::build_list($items, 'compact');
         }
         // navigation bar
         $bar = array();
         // count the number of dates in this section
         $stats = Dates::stat_past_for_anchor($anchor);
         if ($stats['count'] > DATES_PER_PAGE) {
             $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
         }
         // navigation commands for dates
         if ($section = Sections::get(str_replace('section:', '', $anchor))) {
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
         }
         // display the bar
         if (is_array($bar)) {
             $items = Skin::build_list($bar, 'menu_bar') . $items;
         }
         // in a separate box
         $menu[] = Skin::build_sliding_box(i18n::s('Past dates'), $items, 'past_dates', TRUE);
     }
     // menu displayed towards the top of the page
     $text = Skin::finalize_list($menu, 'menu_bar');
     // build a list of events
     if (preg_match('/\\blayout_as_list\\b/i', $this->attributes['overlay_parameters'])) {
         // list all dates
         if ($with_past_dates) {
             // navigation bar
             $bar = array();
             // count the number of dates in this section
             $stats = Dates::stat_for_anchor($anchor);
             if ($stats['count'] > DATES_PER_PAGE) {
                 $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])));
             }
             // navigation commands for dates
             $section = Sections::get($anchor);
             $home = Sections::get_permalink($section);
             $prefix = Sections::get_url($section['id'], 'navigate', 'articles');
             $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page));
             // display the bar
             if (count($bar)) {
                 $text .= Skin::build_list($bar, 'menu_bar');
             }
             // list one page of dates
             if ($items = Dates::list_for_anchor($anchor, $offset, DATES_PER_PAGE, 'family')) {
                 $text .= $items;
             }
             // display only future dates to regular surfers
         } else {
             // show future dates on first page
             if ($page == 1 && ($items = Dates::list_future_for_anchor($anchor, 0, 500, 'family', TRUE))) {
                 $text .= $items;
             }
         }
         // deliver a calendar view for current month, plus months around
     } else {
         // show past dates as well
         if ($with_past_dates) {
             $items = Dates::list_for_anchor($anchor, 0, 500, 'links');
         } else {
             $items = Dates::list_future_for_anchor($anchor, 0, 500, 'links', TRUE);
         }
         // layout all these dates
         if ($items) {
             $text .= Dates::build_months($items);
         }
     }
     // integrate this into the page
     return $text;
 }
Esempio n. 8
0
     $fields['content_options'] = 'auto_publish';
     // these will be reviewed anyway
     $fields['index_map'] = 'N';
     // listed with special sections
     $fields['introduction'] = i18n::c('Models to be duplicated');
     $fields['locked'] = 'Y';
     // only associates can contribute
     $fields['title'] = i18n::c('Templates');
     if (Sections::post($fields)) {
         $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // 'threads' section
 if (!Sections::get('threads')) {
     $fields = array();
     $fields['nick_name'] = 'threads';
     $fields['articles_layout'] = 'yabb';
     // these are threads
     $fields['articles_templates'] = 'information_template, question_template, chat_template, event_template';
     $fields['content_options'] = 'auto_publish with_export_tools with_neighbours';
     $fields['index_map'] = 'N';
     // listed with special sections
     $fields['introduction'] =& i18n::c('For standalone pages');
     $fields['maximum_items'] = 20000;
     // limit the overall number of threads
     $fields['title'] =& i18n::c('Threads');
     if (Sections::post($fields)) {
         $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']) . BR . "\n";
     } else {
Esempio n. 9
0
File: manage.php Progetto: rair/yacs
        $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
        $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
        $follow_up .= Skin::finalize_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // nothing to do
    } else {
        Logger::error(i18n::s('No page has been selected.'));
    }
    // unlock pages
} elseif ($action == 'unlock_sections') {
    // sections
    if (isset($_REQUEST['selected_sections'])) {
        $count = 0;
        foreach ($_REQUEST['selected_sections'] as $dummy => $id) {
            // an section to lock
            if (($section = Sections::get($id)) && $section['locked'] == 'Y') {
                $attributes = array();
                $attributes['id'] = $section['id'];
                $attributes['locked'] = 'N';
                $attributes['silent'] = 'Y';
                // too minor to be noted
                if (Sections::put_attributes($attributes)) {
                    $count++;
                }
            }
        }
        // clear cache for containing section
        Sections::clear($item);
        // report on results
        $context['text'] .= '<p>' . sprintf(i18n::ns('%d section has been unlocked.', '%d sections have been unlocked.', $count), $count) . '</p>';
        // follow-up commands
Esempio n. 10
0
            $menu = array_merge($menu, array(Surfer::get_permalink() => i18n::s('Back to my profile')));
        }
        if (count($menu)) {
            $context['text'] .= Skin::build_block(i18n::s('Where do you want to go now?') . Skin::build_list($menu, 'menu_bar'), 'bottom');
        }
    }
} elseif ($with_form) {
    // target user statut doen't allow MP, except from associates
    if (!Surfer::is_associate() && ($overlay->attributes['user_status'] == 'donotdisturb' || $overlay->attributes['user_status'] == 'anonymous' || $item['without_alerts'] == 'Y')) {
        $context['text'] .= '<p>' . sprintf(i18n::s('Sorry, "%s" wish not to receive private message'), $item['nick_name']) . '</p>' . "\n";
        render_skin();
        finalize_page(TRUE);
    }
    $context['text'] .= Users::get_thread_creation_form($item['id']);
    // layout the available contact options
} elseif ($threads = Sections::get('threads')) {
    // do not link to this user profile
    //include_once $context['path_to_root'].'articles/layout_articles_as_timeline.php';
    //$layout = new Layout_articles_as_timeline();
    //$layout->set_variant($item['id']);
    $layout = layouts::new_('last', 'article');
    // i am looking at my own record
    if (Surfer::get_id() == $item['id']) {
        Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
        $url = 'users/contact.php?start=Y&overlaid=Y';
        $label = ARTICLES_ADD_IMG . i18n::s('Start a new thread');
        // new theard is overlaid
        $label = array(null, $label, null, 'edit-overlaid');
        $menu_top = array($url => $label);
        $context['text'] .= Skin::build_list($menu_top, 'menu_bar');
        $context['text'] .= Members::list_surfer_threads(0, 50, $layout);
Esempio n. 11
0
File: index.php Progetto: rair/yacs
        $offset = ($page - 1) * $items_per_page;
        if (!($text = Links::list_by_date($offset, $items_per_page, $layout))) {
            $text = '<p>' . i18n::s('No link has been recorded yet.') . '</p>';
        }
        // we have an array to format
        if (is_array($text)) {
            $text =& Skin::build_list($text, 'decorated');
        }
        // cache this to speed subsequent queries
        Cache::put($cache_id, $text, 'links');
    }
    $context['text'] .= $text;
}
// page tools
if (Surfer::is_associate()) {
    if ($section = Sections::get('clicks')) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Detected clicks'), 'basic');
    }
    $context['page_tools'][] = Skin::build_link('links/check.php', i18n::s('Maintenance'), 'basic');
}
// page extra content
$cache_id = 'links/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // side bar with the list of most popular links
    if ($items = Links::list_by_hits(0, COMPACT_LIST_SIZE, 'compact')) {
        $text .= Skin::build_box(i18n::s('Popular'), Skin::build_list($items, 'compact'), 'boxes');
    }
    // side boxes for related categories, if any
    if ($categories = Categories::list_by_date_for_display('link:index', 0, 7, 'raw')) {
        foreach ($categories as $id => $attributes) {
            // link to the category page from the box title
Esempio n. 12
0
File: import.php Progetto: rair/yacs
 function parse_tag_close($parser, $tag)
 {
     global $context;
     global $in_overlay, $overlay_class, $overlay_parameters;
     global $parsed_cdata, $parsed_item, $parsed_overlay, $parsing_report;
     // save gathered data if necessary
     switch ($tag) {
         case 'article':
             // end of article
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // transcode publisher id
             $parsed_item['publish_id'] = Surfer::get_id();
             if (isset($parsed_item['publish_nick_name']) && ($user = Users::get($parsed_item['publish_nick_name']))) {
                 $parsed_item['publish_id'] = $user['id'];
             }
             // bind to given overlay
             $overlay = NULL;
             if ($overlay_class) {
                 $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
             }
             // when the page has been overlaid
             if (is_object($overlay)) {
                 // update the overlay from content
                 foreach ($parsed_overlay as $label => $value) {
                     $overlay->attributes[$label] = $value;
                 }
                 // save content of the overlay in this item
                 $parsed_item['overlay'] = $overlay->save();
                 $parsed_item['overlay_id'] = $overlay->get_id();
             }
             // find anchor from handle
             if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
                 $parsed_item['anchor'] = $reference;
             }
             // update an existing page
             if (isset($parsed_item['handle']) && ($item = Articles::get($parsed_item['handle']))) {
                 // transcode page id
                 $parsed_item['id'] = $item['id'];
                 // stop on error
                 if (!Articles::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'article:' . $item['id'])) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
                 }
                 // create a new page
             } else {
                 unset($parsed_item['id']);
                 // stop on error
                 if (!($parsed_item['id'] = Articles::post($parsed_item))) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title']));
                 } else {
                     // save overlay content
                     if (is_object($overlay)) {
                         $overlay->remember('insert', $parsed_item, 'article:' . $parsed_item['id']);
                     }
                 }
             }
             // report to surfer
             $parsing_report .= '<li>' . Skin::build_link(Articles::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
             // ready for next item
             $overlay_class = NULL;
             $overlay_parameters = '';
             $parsed_overlay = array();
             $parsed_item = array();
             Safe::set_time_limit(30);
             break;
         case 'overlay':
             // end of overlay data
             $in_overlay = FALSE;
             break;
         case 'section':
             // end of section
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // bind to given overlay
             $overlay = NULL;
             if ($overlay_class) {
                 $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
             }
             // when the page has been overlaid
             if (is_object($overlay)) {
                 // update the overlay from content
                 foreach ($parsed_overlay as $label => $value) {
                     $overlay->attributes[$label] = $value;
                 }
                 // save content of the overlay in this item
                 $parsed_item['overlay'] = $overlay->save();
                 $parsed_item['overlay_id'] = $overlay->get_id();
             }
             // find anchor from handle
             if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
                 $parsed_item['anchor'] = $reference;
             }
             // update an existing section
             if (isset($parsed_item['handle']) && ($item = Sections::get($parsed_item['handle']))) {
                 // transcode section id
                 $parsed_item['id'] = $item['id'];
                 // stop on error
                 if (!Sections::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'section:' . $item['id'])) {
                     Logger::error(sprintf('Unable to save section %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
                 }
                 // create a new page
             } else {
                 unset($parsed_item['id']);
                 // stop on error
                 if (!($parsed_item['id'] = Sections::post($parsed_item))) {
                     Logger::error(sprintf('Unable to save section %s', $parsed_item['title']));
                 } else {
                     // save overlay content
                     if (is_object($overlay)) {
                         $overlay->remember('insert', $parsed_item, 'section:' . $parsed_item['id']);
                     }
                 }
             }
             // report to surfer
             $parsing_report .= '<li>' . Skin::build_link(Sections::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
             // ready for next item
             $overlay_class = NULL;
             $overlay_parameters = '';
             $parsed_overlay = array();
             $parsed_item = array();
             Safe::set_time_limit(30);
             break;
         default:
             // just another attribute
             // decode cdata
             $parsed_cdata = trim(preg_replace(array('/&lt;/', '/&gt;/'), array('<', '>'), $parsed_cdata));
             // feeding the overlay or the item itself
             if ($in_overlay) {
                 $parsed_overlay[$tag] = $parsed_cdata;
             } else {
                 $parsed_item[$tag] = $parsed_cdata;
             }
             // ready for next attribute
             $parsed_cdata = '';
             break;
     }
 }
Esempio n. 13
0
File: go.php Progetto: rair/yacs
}
$id = strip_tags($id);
// load localized strings
i18n::bind('root');
// load the skin
load_skin('go');
// the title of the page
$context['page_title'] = i18n::s('Page locator');
// ensure we have a non-empty string
if (!($id = trim($id)) || !preg_match('/\\w/', $id)) {
    $context['text'] .= '<p>' . i18n::s('Please indicate a nick name to look for.') . "</p>\n";
    // short link to some article
} elseif (!strncmp($id, 'a~', 2) && ($item = Articles::get(restore_number(substr($id, 2))))) {
    Safe::redirect(Articles::get_permalink($item));
    // short link to some section
} elseif (!strncmp($id, 's~', 2) && ($item = Sections::get(restore_number(substr($id, 2))))) {
    Safe::redirect(Sections::get_permalink($item));
    // look in sections
} elseif ($items =& Sections::list_for_name($id, NULL, 'full')) {
    // only one section has this name
    if (count($items) == 1) {
        list($url, $attributes) = each($items);
        Safe::redirect($url);
    }
    // splash
    $context['text'] .= '<p>' . i18n::s('Select below among available sections.') . '</p>';
    // several pages
    $context['text'] .= Skin::build_list($items, 'decorated');
    // look in categories
} elseif (($item = Categories::get($id)) || ($item =& Categories::get_by_keyword($id))) {
    Safe::redirect(Categories::get_permalink($item));
Esempio n. 14
0
// common definitions and initial processing
include_once '../shared/global.php';
// check network credentials, if any
if ($user = Users::authenticate()) {
    Surfer::empower($user['capability']);
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Sections::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// editors have associate-like capabilities
if (isset($item['id']) && Sections::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
    Surfer::empower();
}
// load the skin, maybe with a variant
load_skin('sections', $anchor, isset($item['options']) ? $item['options'] : '');
// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
Esempio n. 15
0
 } else {
     $fields = array();
     $fields['nick_name'] = 'links';
     $fields['title'] = i18n::c('Links');
     $fields['introduction'] = i18n::c('Social bookmarking section');
     $fields['options'] = 'with_links';
     // enable link upload
     $fields['articles_layout'] = 'none';
     if (Sections::post($fields)) {
         $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['nick_name']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // 'my_section' section
 if (Sections::get('my_section')) {
     $text .= sprintf(i18n::s('A section "%s" already exists.'), 'my_section') . BR . "\n";
 } else {
     $fields = array();
     $fields['nick_name'] = 'my_section';
     $fields['title'] = i18n::c('My Section');
     $fields['introduction'] = i18n::c('Sample plain section');
     $fields['content_options'] = 'with_export_tools';
     if (Sections::post($fields)) {
         $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['nick_name']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // categories
 //
Esempio n. 16
0
File: links.php Progetto: rair/yacs
 /**
  * reference another page at this site
  *
  * The function transforms a local reference (e.g;, [code][user=2][/code])
  * to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]),
  * adds a title and, sometimes, set a description as well.
  *
  * @param string any string, maybe with a local reference in it
  * @return an array($url, $title, $description) or NULL
  *
  * @see images/view.php
  * @see links/edit.php
  * @see shared/codes.php
  */
 public static function transform_reference($text)
 {
     global $context;
     // translate this reference to an internal link
     if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) {
         switch ($matches[1]) {
             // article link
             case 'article':
                 if ($item = Articles::get($matches[2])) {
                     return array(Articles::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // section link
             // section link
             case 'section':
                 if ($item = Sections::get($matches[2])) {
                     return array(Sections::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // file link
             // file link
             case 'file':
                 if ($item = Files::get($matches[2])) {
                     return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name'])));
                 }
                 return array('', $text, '');
                 // image link
             // image link
             case 'image':
                 include_once $context['path_to_root'] . 'images/images.php';
                 if ($item = Images::get($matches[2])) {
                     return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
                 }
                 return array('', $text, '');
                 // category link
             // category link
             case 'category':
                 if ($item = Categories::get($matches[2])) {
                     return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // user link
             // user link
             case 'user':
                 if ($item = Users::get($matches[2])) {
                     return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
                 }
                 return array('', $text, '');
         }
     }
     return array('', $text, '');
 }
Esempio n. 17
0
File: codes.php Progetto: rair/yacs
 /**
  * render a link to an object
  *
  * Following types are supported:
  * - article - link to an article page
  * - category - link to a category page
  * - comment - link to a comment page
  * - download - link to a download page
  * - file - link to a file page
  * - flash - display a file as a native flash object, or play a flash video
  * - go
  * - image - display an in-line image
  * - next - link to an article page
  * - previous - link to an article page
  * - section - link to a section page
  * - server - link to a server page
  * - user - link to a user page
  *
  * @param string the type
  * @param string the id, with possible options or variant
  * @return string the rendered text
  **/
 public static function render_object($type, $id)
 {
     global $context;
     $id = Codes::fix_tags($id);
     // depending on type
     switch ($type) {
         // link to an article
         case 'article':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[article=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // insert article description
         // insert article description
         case 'article.description':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[article.description=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'article');
                 // the introduction text, if any
                 $output .= BR . Codes::beautify($item['introduction']);
                 // load overlay, if any
                 if (isset($item['overlay']) && $item['overlay']) {
                     $overlay = Overlay::load($item, 'article:' . $item['id']);
                     // get text related to the overlay, if any
                     if (is_object($overlay)) {
                         $output .= $overlay->get_text('view', $item);
                     }
                 }
                 // the description, which is the actual page body
                 $output .= '<div>' . Codes::beautify($item['description']) . '</div>';
             }
             return $output;
             // link to a category
         // link to a category
         case 'category':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Categories::get($id))) {
                 $output = '[category=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Categories::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // insert category description
         // insert category description
         case 'category.description':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Categories::get($id))) {
                 $output = '[category.description=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Categories::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'category');
                 // the introduction text, if any
                 $output .= BR . Codes::beautify($item['introduction']);
                 // load overlay, if any
                 if (isset($item['overlay']) && $item['overlay']) {
                     $overlay = Overlay::load($item, 'category:' . $item['id']);
                     // get text related to the overlay, if any
                     if (is_object($overlay)) {
                         $output .= $overlay->get_text('view', $item);
                     }
                 }
                 // the description, which is the actual page body
                 $output .= '<div>' . Codes::beautify($item['description']) . '</div>';
             }
             return $output;
             // link to a comment
         // link to a comment
         case 'comment':
             include_once $context['path_to_root'] . 'comments/comments.php';
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Comments::get($id))) {
                 $output = '[comment=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = i18n::s('View this comment');
                 }
                 // make a link to the target page
                 $url = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id']);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'basic');
             }
             return $output;
             // link to a download
         // link to a download
         case 'download':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Files::get($id))) {
                 // file does not exist anymore
                 if (isset($attributes[1]) && $attributes[1]) {
                     $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>';
                 } else {
                     $output = '[download=' . $id . ']';
                 }
             } else {
                 // label for this file
                 $prefix = $text = $suffix = '';
                 // signal restricted and private files
                 if ($item['active'] == 'N') {
                     $prefix .= PRIVATE_FLAG;
                 } elseif ($item['active'] == 'R') {
                     $prefix .= RESTRICTED_FLAG;
                 }
                 // ensure we have a label for this link
                 if (isset($attributes[1]) && $attributes[1]) {
                     $text .= $attributes[1];
                     // this may describe a previous file, which has been replaced
                     if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) {
                         $text .= ' <p class="details">' . i18n::s('[this file has been replaced]') . '</p>';
                         $output = $prefix . $text . $suffix;
                         return $output;
                     }
                 } else {
                     $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
                 }
                 // flag files uploaded recently
                 if ($item['create_date'] >= $context['fresh']) {
                     $suffix .= NEW_FLAG;
                 } elseif ($item['edit_date'] >= $context['fresh']) {
                     $suffix .= UPDATED_FLAG;
                 }
                 // always download the file
                 $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
                 // return a complete anchor
                 $output = $prefix . Skin::build_link($url, $text, 'file') . $suffix;
             }
             return $output;
             // link to a file
         // link to a file
         case 'file':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database --ensure we get a fresh copy of the record, not a cached one
             if (!($item = Files::get($id, TRUE))) {
                 // file does not exist anymore
                 if (isset($attributes[1]) && $attributes[1]) {
                     $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>';
                 } else {
                     $output = '[file=' . $id . ']';
                 }
             } else {
                 // maybe we want to illustrate this file
                 if ($item['edit_action'] != 'file:create' && isset($attributes[1]) && $attributes[1] || !($output = Files::interact($item))) {
                     // label for this file
                     $output = $prefix = $text = $suffix = '';
                     // signal restricted and private files
                     if ($item['active'] == 'N') {
                         $prefix .= PRIVATE_FLAG;
                     } elseif ($item['active'] == 'R') {
                         $prefix .= RESTRICTED_FLAG;
                     }
                     // ensure we have a label for this link
                     if (isset($attributes[1]) && $attributes[1]) {
                         $text .= $attributes[1];
                         // this may describe a previous file, which has been replaced
                         if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) {
                             $text .= '<p class="details">' . i18n::s('[this file has been replaced]') . '</p>';
                             $output = $prefix . $text . $suffix;
                             return $output;
                         }
                     } else {
                         $text .= Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
                     }
                     // flag files uploaded recently
                     if ($item['create_date'] >= $context['fresh']) {
                         $suffix .= NEW_FLAG;
                     } elseif ($item['edit_date'] >= $context['fresh']) {
                         $suffix .= UPDATED_FLAG;
                     }
                     // make a link to the target page
                     $url = Files::get_download_url($item);
                     // return a complete anchor
                     $output .= $prefix . Skin::build_link($url, $text, 'basic') . $suffix;
                 }
             }
             return $output;
             // invoke the selector
         // invoke the selector
         case 'go':
             // extract the label, if any
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $name = $attributes[0];
             // ensure we have a label for this link
             if (isset($attributes[1])) {
                 $text = $attributes[1];
             } else {
                 $text = $name;
             }
             // return a complete anchor
             $output = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . normalize_shortcut($name), $text, 'basic');
             return $output;
             // embed an image
         // embed an image
         case 'image':
             include_once $context['path_to_root'] . 'images/images.php';
             // get the variant, if any
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             if (isset($attributes[1])) {
                 $variant = $attributes[1];
             } else {
                 $variant = 'inline';
             }
             // get the image record
             if (!($image = Images::get($id))) {
                 $output = '[image=' . $id . ']';
                 return $output;
             }
             // a title for the image --do not force a title
             if (isset($image['title'])) {
                 $title = $image['title'];
             } else {
                 $title = '';
             }
             // provide thumbnail if not defined, or forced, or for large images
             if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) {
                 // not inline anymore, but thumbnail --preserve other variants
                 if ($variant == 'inline') {
                     $variant = 'thumbnail';
                 }
                 // where to fetch the image file
                 $href = Images::get_thumbnail_href($image);
                 // to drive to plain image
                 $link = Images::get_icon_href($image);
                 // add an url, if any
             } elseif ($image['link_url']) {
                 // flag large images
                 if ($image['image_size'] > $context['thumbnail_threshold']) {
                     $variant = rtrim('large ' . $variant);
                 }
                 // where to fetch the image file
                 $href = Images::get_icon_href($image);
                 // transform local references, if any
                 include_once $context['path_to_root'] . '/links/links.php';
                 $attributes = Links::transform_reference($image['link_url']);
                 if ($attributes[0]) {
                     $link = $context['url_to_root'] . $attributes[0];
                 } else {
                     $link = $image['link_url'];
                 }
                 // get the <img ... /> element
             } else {
                 // do not append poor titles to inline images
                 if ($variant == 'inline') {
                     $title = '';
                 }
                 // flag large images
                 if ($image['image_size'] > $context['thumbnail_threshold']) {
                     $variant = rtrim('large ' . $variant);
                 }
                 // where to fetch the image file
                 $href = Images::get_icon_href($image);
                 // no link
                 $link = '';
             }
             // use the skin
             if (Images::allow_modification($image['anchor'], $id)) {
                 // build editable image
                 $output =& Skin::build_image($variant, $href, $title, $link, $id);
             } else {
                 $output =& Skin::build_image($variant, $href, $title, $link);
             }
             return $output;
             // embed a stack of images
         // embed a stack of images
         case 'images':
             include_once $context['path_to_root'] . 'images/images.php';
             // get the list of ids
             $ids = preg_split("/\\s*,\\s*/", $id);
             if (!count($ids)) {
                 $output = '[images=id1, id2, ...]';
                 return $output;
             }
             // build the list of images
             $items = array();
             foreach ($ids as $id) {
                 // get the image record
                 if ($image = Images::get($id)) {
                     // a title for the image --do not force a title
                     if (isset($image['title'])) {
                         $title = $image['title'];
                     } else {
                         $title = '';
                     }
                     // provide thumbnail if not defined, or forced, or for large images
                     $variant = 'inline';
                     if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) {
                         // not inline anymore, but thumbnail
                         $variant = 'thumbnail';
                         // where to fetch the image file
                         $href = Images::get_thumbnail_href($image);
                         // to drive to plain image
                         $link = $context['url_to_root'] . Images::get_url($id);
                         // add an url, if any
                     } elseif ($image['link_url']) {
                         // flag large images
                         if ($image['image_size'] > $context['thumbnail_threshold']) {
                             $variant = rtrim('large ' . $variant);
                         }
                         // where to fetch the image file
                         $href = Images::get_icon_href($image);
                         // transform local references, if any
                         include_once $context['path_to_root'] . '/links/links.php';
                         $attributes = Links::transform_reference($image['link_url']);
                         if ($attributes[0]) {
                             $link = $context['url_to_root'] . $attributes[0];
                         } else {
                             $link = $image['link_url'];
                         }
                         // get the <img ... /> element
                     } else {
                         // flag large images
                         if ($image['image_size'] > $context['thumbnail_threshold']) {
                             $variant = rtrim('large ' . $variant);
                         }
                         // where to fetch the image file
                         $href = Images::get_icon_href($image);
                         // no link
                         $link = '';
                     }
                     // use the skin
                     $label =& Skin::build_image($variant, $href, $title, $link);
                     // add item to the stack
                     $items[] = $label;
                 }
             }
             // format the list
             $output = '';
             if (count($items)) {
                 // stack items
                 $output = Skin::finalize_list($items, 'stack');
                 // rotate items
                 $output = Skin::rotate($output);
             }
             // done
             return $output;
             // link to the next article
         // link to the next article
         case 'next':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[next=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'next');
             }
             return $output;
             // link to the previous article
         // link to the previous article
         case 'previous':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[previous=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'previous');
             }
             return $output;
             // link to a section
         // link to a section
         case 'section':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Sections::get($id))) {
                 $output = '[section=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Sections::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // link to a server
         // link to a server
         case 'server':
             include_once $context['path_to_root'] . 'servers/servers.php';
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Servers::get($id))) {
                 $output = '[server=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($id);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // link to a user
         // link to a user
         case 'user':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Users::get($id))) {
                 $output = '[user='******']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } elseif (isset($item['full_name']) && $item['full_name']) {
                     $text = ucfirst($item['full_name']);
                 } else {
                     $text = ucfirst($item['nick_name']);
                 }
                 // make a link to the target page
                 $url = Users::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // invalid type
         // invalid type
         default:
             $output = '[' . $type . ']';
             return $output;
     }
 }