function loadApi($action)
{
    switch ($action) {
        case 'insert':
            if (!isset($_COOKIE['groupid'])) {
                throw new Exception("You must be login.");
            }
            try {
                if (!($id = Categories::insert(Request::make('send')))) {
                    throw new Exception("Error. " . Database::$error);
                }
                return json_encode(array('error' => 'no'));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'get':
            try {
                $data = Categories::get();
                return json_encode($data);
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
    }
}
 public function index()
 {
     if ($match = Uri::match('\\/jsonCategory')) {
         $keyword = String::encode(Request::get('keyword', ''));
         $loadData = Categories::get(array('where' => "where title LIKE '%{$keyword}%'", 'orderby' => 'order by title asc'));
         $total = count($loadData);
         $li = '';
         for ($i = 0; $i < $total; $i++) {
             $li .= '<li><span data-method="category" data-id="' . $loadData[$i]['catid'] . '" >' . $loadData[$i]['title'] . '</span></li>';
         }
         echo $li;
         die;
     }
     $post = array('alert' => '');
     Model::load('admincp/categories');
     $curPage = 0;
     if ($match = Uri::match('\\/page\\/(\\d+)')) {
         $curPage = $match[1];
     }
     if (Request::has('btnAction')) {
         actionProcess();
     }
     if (Request::has('btnAdd')) {
         try {
             insertProcess();
             $post['alert'] = '<div class="alert alert-success">Add new category success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     if (Request::has('btnSave')) {
         $match = Uri::match('\\/edit\\/(\\d+)');
         try {
             updateProcess($match[1]);
             $post['alert'] = '<div class="alert alert-success">Update category success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     if (Request::has('btnSearch')) {
         filterProcess();
     } else {
         $post['pages'] = Misc::genSmallPage('admincp/categories', $curPage);
         $post['theList'] = Categories::get(array('limitShow' => 20, 'limitPage' => $curPage, 'orderby' => 'order by catid desc', 'cache' => 'no'));
     }
     if ($match = Uri::match('\\/edit\\/(\\d+)')) {
         $loadData = Categories::get(array('where' => "where catid='" . $match[1] . "'", 'cache' => 'no'));
         $post['edit'] = $loadData[0];
     }
     System::setTitle('Categories list - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('categoriesList', $post);
     View::make('admincp/footer');
 }
function updateProcess($id)
{
    $update = Request::get('update');
    $valid = Validator::make(array('update.title' => 'required|min:1|slashes', 'update.parentid' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    if (Request::hasFile('image')) {
        if (Request::isImage('image')) {
            $update['image'] = File::upload('image');
            $loadData = Categories::get(array('where' => "where catid='{$id}'"));
            if (isset($loadData[0]['catid'])) {
                File::remove($loadData[0]['image']);
            }
        }
    }
    Categories::update($id, $update);
}
 public function index()
 {
     if ($match = Uri::match('\\/jsonCategory')) {
         $keyword = String::encode(Request::get('keyword', ''));
         $loadData = Categories::get(array('where' => "where title LIKE '%{$keyword}%'", 'orderby' => 'order by title asc'));
         $total = count($loadData);
         $li = '';
         for ($i = 0; $i < $total; $i++) {
             $li .= '<li><span data-method="category" data-id="' . $loadData[$i]['catid'] . '" >' . $loadData[$i]['title'] . '</span></li>';
         }
         echo $li;
         die;
     }
     $post = array('alert' => '');
     Model::load('admincp/post');
     if ($match = Uri::match('\\/post\\/(\\w+)')) {
         if (method_exists("controlPost", $match[1])) {
             $method = $match[1];
             $this->{$method}();
             die;
         }
     }
     $curPage = 0;
     if ($match = Uri::match('\\/page\\/(\\d+)')) {
         $curPage = $match[1];
     }
     if (Request::has('btnAction')) {
         actionProcess();
     }
     if (Request::has('btnSearch')) {
         filterProcess();
     } else {
         $post['pages'] = Misc::genSmallPage('admincp/post', $curPage);
         $filterPending = '';
         if (Uri::has('\\/status\\/pending')) {
             $filterPending = " WHERE p.status='0' ";
         }
         $post['theList'] = Post::get(array('limitShow' => 20, 'limitPage' => $curPage, 'query' => "select p.*,u.username,c.title as cattitle from " . Database::getPrefix() . "post p left join users u on p.userid=u.userid join " . Database::getPrefix() . "categories c on p.catid=c.catid {$filterPending} order by p.postid desc", 'cache' => 'no'));
     }
     System::setTitle('Post list - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('postList', $post);
     View::make('admincp/footer');
 }
Example #5
0
function loadApi($action)
{
    $groupid = Users::getCookieGroupId();
    $userid = Users::getCookieUserId();
    if ((int) $groupid <= 0 || (int) $userid <= 0) {
        throw new Exception('You must login');
    }
    if ((int) $groupid != 1) {
        throw new Exception('You can not do this action');
    }
    switch ($action) {
        case 'changeHomePage':
            $send_url = trim(Request::get('send_url'));
            $send_url = str_replace(System::getUrl(), '', $send_url);
            $inputData = array('default_page_method' => 'url', 'default_page_url' => $send_url);
            System::saveSetting($inputData);
            break;
        case 'getSetting':
            if (!isset($_COOKIE['groupid'])) {
                throw new Exception("You must be login.");
            }
            try {
                if (!($id = Categories::insert(Request::make('send')))) {
                    throw new Exception("Error. " . Database::$error);
                }
                return json_encode(array('error' => 'no'));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'addSetting':
            try {
                $data = Categories::get();
                return json_encode($data);
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
    }
}
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->dataFieldByName('Title')->setTitle('City Hotel Name');
     $fields->dataFieldByName('Content')->setTitle('City Hotel Introduction');
     $fields->insertBefore(NumericField::create("NoOfRooms")->setTitle("Total Number of Rooms"), 'Content');
     $fields->insertBefore(TextField::create("AirportDistance")->setTitle("Distance from Airport"), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('AtollID', 'Atoll', Atolls::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('IslandID', 'Island', Islands::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('CategoryID', 'Category', Categories::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('TransferTypeID', 'TransferType', TransferTypes::get()->map('ID', 'Name')), 'Content');
     $fields->insertBefore(NumericField::create("Rating")->setTitle("Star Rating"), 'Content');
     $fields->insertBefore(CheckboxField::create("InSide")->setTitle("Show City Hotel in Slide Show"), 'Content');
     $fields->insertBefore(CheckboxField::create("Featured")->setTitle("Show City Hotel in Featured List"), 'Content');
     $fields->insertBefore(TextField::create("Cordinates")->setTitle("Map Cordinates, Longitute & Latitude, separated by comma"), 'Content');
     $imgfield = UploadField::create('FeaturedPhoto')->setTitle("Default Cover Photo");
     $imgfield->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $fields->insertBefore($imgfield, 'Content');
     $defaultTag = $this->Tags()->column('ID');
     // print_r($defaultTag);
     $tagMap = Tags::get()->map('ID', 'Name')->toArray();
     $tagList = ListboxField::create('Tags', 'Tags')->setMultiple(true)->setSource($tagMap)->setDefaultItems($defaultTag);
     $fields->addFieldToTab('Root.Main', $tagList, 'Content');
     $defaultItem = $this->HolidayTypes()->column('ID');
     $Map = HolidayTypes::get()->map('ID', 'Name')->toArray();
     $List = ListboxField::create('HolidayTypes', 'Holiday Types')->setMultiple(true)->setSource($Map)->setDefaultItems($defaultItem);
     $fields->addFieldToTab('Root.Main', $List, 'Content');
     $fields->addFieldToTab('Root.CityHotelImages', $uploadField = new uploadField($name = "CityHotelImages", $title = "Upload one or more images (max 10 in total)"));
     $uploadField->setAllowedMaxFileNumber(10);
     $gridConfig = GridFieldConfig_RelationEditor::create();
     $GridField = new GridField('Rooms', 'Rooms', $this->Rooms(), $gridConfig);
     $fields->addFieldToTab("Root.Rooms", $GridField);
     $GridField = new GridField('Dining', 'Dining', $this->Dining(), $gridConfig);
     $fields->addFieldToTab("Root.Dining", $GridField);
     $GridField = new GridField('Facilities', 'Facilities', $this->Facilities(), $gridConfig);
     $fields->addFieldToTab("Root.Facilities", $GridField);
     $GridField = new GridField('Activities', 'Activities', $this->Activities(), $gridConfig);
     $fields->addFieldToTab("Root.Activities", $GridField);
     return $fields;
 }
Example #7
0
File: index.php Project: rair/yacs
    $context['page_tools'][] = Skin::build_link('sections/edit.php', i18n::s('Add a section'));
    $context['page_tools'][] = Skin::build_link('help/populate.php', i18n::s('Content Assistant'));
    $context['page_tools'][] = Skin::build_link('sections/check.php', i18n::s('Maintenance'));
}
// display extra information
$cache_id = 'sections/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // see also
    $lines = array();
    $lines[] = Skin::build_link('categories/', i18n::s('Categories'));
    $lines[] = Skin::build_link('search.php', i18n::s('Search'));
    $lines[] = Skin::build_link('help/', i18n::s('Help index'));
    $lines[] = Skin::build_link('query.php', i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes');
    // list monthly publications in an extra box
    $anchor = Categories::get(i18n::c('monthly'));
    if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
        $text .= Skin::build_box($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n";
    }
    // side boxes for related categories, if any
    if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) {
        foreach ($categories as $id => $attributes) {
            // link to the category page from the box title
            $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category'));
            // box content
            if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) {
                $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n";
            }
        }
    }
    // save, whatever change, for 5 minutes
Example #8
0
File: print.php Project: rair/yacs
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'categories.php';
include_once '../links/links.php';
// 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 = Categories::get($id);
// get the related anchor
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// associates and editors can do what they want
if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
    $permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
    $permitted = FALSE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
 /**
  * list articles as digg do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $anchor = Categories::get(i18n::c('monthly'));
     if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Example #10
0
function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.keywords' => 'slashes', 'tags' => 'slashes', 'send.catid' => 'slashes', 'send.type' => 'slashes', 'send.allowcomment' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $friendlyUrl = trim(String::makeFriendlyUrl($send['title']));
    $getData = Post::get(array('where' => "where friendly_url='{$friendlyUrl}'"));
    if (isset($getData[0]['postid'])) {
        throw new Exception("This post exists in database.");
    }
    $uploadMethod = Request::get('uploadMethod');
    switch ($uploadMethod) {
        case 'frompc':
            if (Request::hasFile('imageFromPC')) {
                if (Request::isImage('imageFromPC')) {
                    $send['image'] = File::upload('imageFromPC');
                }
            }
            break;
        case 'fromurl':
            if (Request::isImage('imageFromUrl')) {
                $url = Request::get('imageFromUrl');
                $send['image'] = File::upload('uploadFromUrl');
            }
            break;
    }
    $send['userid'] = Users::getCookieUserId();
    if (!Request::has('send.catid')) {
        $loadCat = Categories::get(array('limitShow' => 1));
        if (isset($loadCat[0]['catid'])) {
            $send['catid'] = $loadCat[0]['catid'];
        }
    }
    if (!($id = Post::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
    $tags = trim(Request::get('tags'));
    $parse = explode(',', $tags);
    $total = count($parse);
    $insertData = array();
    for ($i = 0; $i < $total; $i++) {
        $insertData[$i]['title'] = trim($parse[$i]);
        $insertData[$i]['postid'] = $id;
    }
    PostTags::insert($insertData);
}
Example #11
0
 /**
  * load the related item
  *
  * @param int the id of the record to load
  * @param boolean TRUE to always fetch a fresh instance, FALSE to enable cache
  *
  * @see shared/anchor.php
  */
 function load_by_id($id, $mutable = FALSE)
 {
     $this->item = Categories::get($id, $mutable);
 }
Example #12
0
File: go.php Project: rair/yacs
    // 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));
    // look in articles
} elseif ($items =& Articles::list_for_name($id, NULL, 'full')) {
    // only one page 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 pages.') . '</p>';
    // several pages
    $context['text'] .= Skin::build_list($items, 'decorated');
    // look in user profiles
} elseif ($item = Users::get($id)) {
    Safe::redirect(Users::get_permalink($item));
Example #13
0
     }
 }
 // 'monthly' category
 if (!Categories::get(i18n::c('monthly'))) {
     $fields = array();
     $fields['nick_name'] = i18n::c('monthly');
     $fields['title'] = i18n::c('Publications by month');
     $fields['introduction'] = '';
     $fields['rank'] = 22000;
     $fields['options'] = 'no_links';
     if (Categories::post($fields)) {
         $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['title']) . BR . "\n";
     }
 }
 // 'weekly' category
 if (!Categories::get(i18n::c('weekly'))) {
     $fields = array();
     $fields['nick_name'] = i18n::c('weekly');
     $fields['title'] = i18n::c('Publications by week');
     $fields['introduction'] = '';
     $fields['rank'] = 21000;
     $fields['options'] = 'no_links';
     if (Categories::post($fields)) {
         $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['title']) . BR . "\n";
     }
 }
 // nothing added
 if (!$text) {
     $text = i18n::s('No item has been added');
 }
 // report to surfer
Example #14
0
 /**
  * remember publications and tags
  *
  * This function links the provided reference to categories, based
  * on publication time and tags.
  *
  * The reference is linked to weekly and monthly categories, except if the
  * global parameter 'users_without_archiving' has been set to 'Y'.
  *
  * @see users/configure.php
  *
  * Tags can be provided either as a string of keywords separated by commas,
  * or as an array of strings.
  *
  * @param string a reference to the published material (e.g., 'article:12')
  * @param string the publication date and time, if any
  * @param mixed a list of related tags, if any
  *
  * @see articles/articles.php
  * @see categories/check.php
  * @see services/blog.php
  */
 public static function remember($reference, $stamp = NULL, $tags = NULL)
 {
     global $context;
     // if automatic archiving has not been disabled
     if (!isset($context['users_without_archiving']) || $context['users_without_archiving'] != 'Y') {
         // if the stamp has a value, this is a valid publication
         if (is_string($stamp) && $stamp > NULL_DATE && ($stamp = strtotime($stamp)) && ($stamp = getdate($stamp))) {
             // weeks are starting on Monday
             $week = mktime(0, 0, 0, $stamp['mon'], $stamp['mday'] - $stamp['wday'] + 1, $stamp['year']);
             // create the category for this week if it does not exist
             if (!($category = Categories::lookup('week ' . date('y/m/d', $week))) && ($anchor = Categories::get(i18n::c('weekly')))) {
                 $fields = array();
                 $fields['anchor'] = 'category:' . $anchor['id'];
                 $fields['nick_name'] = 'week ' . date('y/m/d', $week);
                 $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $week);
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $week);
                 $fields['title'] = sprintf(i18n::c('Week of&nbsp;%s'), date(i18n::c('m/d/y'), $week));
                 $fields['options'] = 'no_links';
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             }
             // link the reference to this weekly category
             if ($category) {
                 Members::assign($category, $reference);
             }
             // months are starting on day 1
             $month = mktime(0, 0, 0, $stamp['mon'], 1, $stamp['year']);
             // create the category for this month if it does not exist
             if (!($category = Categories::lookup('month ' . date('M Y', $month))) && ($anchor = Categories::get(i18n::c('monthly')))) {
                 $fields = array();
                 $fields['anchor'] = 'category:' . $anchor['id'];
                 $fields['nick_name'] = 'month ' . date('M Y', $month);
                 $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $month);
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', $month);
                 $fields['title'] = Skin::build_date($month, 'month', $context['preferred_language']);
                 $fields['options'] = 'no_links';
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             }
             // link the reference to this monthly category
             if ($category) {
                 Members::assign($category, $reference);
             }
         }
     }
     // link to selected categories --do not accept ; as separator, because this conflicts with UTF-8 encoding
     if (is_string($tags) && $tags) {
         $tags = preg_split('/[ \\t]*,\\s*/', $tags);
     }
     if (is_array($tags) && count($tags)) {
         // create a category to host keywords, if none exists
         if (!($root_category = Categories::lookup('keywords'))) {
             $fields = array();
             $fields['nick_name'] = 'keywords';
             $fields['title'] = i18n::c('Keywords');
             $fields['introduction'] = i18n::c('Classified pages');
             $fields['description'] = i18n::c('This category is a specialized glossary of terms, made out of tags added to pages, and out of search requests.');
             $fields['rank'] = 29000;
             $fields['options'] = 'no_links';
             if ($fields['id'] = Categories::post($fields)) {
                 Categories::clear($fields);
                 $root_category = 'category:' . $fields['id'];
             }
         }
         // one category per tag
         $assigned = array();
         foreach ($tags as $title) {
             // create a category if tag is unknown
             if (!($category =& Categories::get_by_keyword($title))) {
                 $fields = array();
                 $fields['title'] = ucfirst($title);
                 $fields['keywords'] = $title;
                 if ($root_category) {
                     $fields['anchor'] = $root_category;
                 }
                 if ($fields['id'] = Categories::post($fields)) {
                     Categories::clear($fields);
                     $category = 'category:' . $fields['id'];
                 }
             } else {
                 $category = 'category:' . $category['id'];
             }
             // link page to the category
             if ($category) {
                 Members::assign($category, $reference);
                 $assigned[] = $category;
             }
         }
         // back to a string representation
         $tags = join(', ', $tags);
         // clean assignments for removed tags
         // the list of members
         $query = "SELECT anchor FROM " . SQL::table_name('members') . " WHERE (member LIKE '" . SQL::escape($reference) . "') AND (anchor LIKE 'category:%')" . " LIMIT 0, 500";
         if ($result = SQL::query($query)) {
             while ($row = SQL::fetch($result)) {
                 if (in_array($row['anchor'], $assigned)) {
                     continue;
                 }
                 // assigned, and a keyword exists, but not in the string of tags
                 if (($category = Anchors::get($row['anchor'])) && ($keywords = $category->get_value('keywords')) && stripos($tags, $keywords) === FALSE) {
                     Members::free($row['anchor'], $reference);
                 }
             }
         }
     }
 }
Example #15
0
File: new.php Project: rair/yacs
    // end of the form
    $context['text'] .= '</div></form>';
    // the script used for form handling at the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	if(!container.letter_title.value) {' . "\n" . '		alert("' . i18n::s('No title has been provided.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . '// set the focus on first form field' . "\n" . 'document.main_form.letter_title.focus();' . "\n");
    // list featured pages
} elseif (isset($action) && $action == 'featured') {
    // the letter prefix
    if ($context['letter_prefix']) {
        $context['letter_body'] .= '<div>' . $context['letter_prefix'] . '</div>';
    }
    // re-use parameter for featured pages at the front page
    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 (isset($anchor['id']) && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'], 'digest'))) {
        // scan each article
        foreach ($items as $url => $label) {
            // text for this article
            $context['letter_body'] .= "\n";
            // split $label as array($time, $label, $author, $section, $icon, $introduction)
            $time = $author = $section = $icon = $introduction = NULL;
            $sublevel = FALSE;
            if (is_array($label)) {
                $time = $label[0];
                $author = $label[2];
                $section = $label[3];
                $icon = $label[4];
                $introduction = $label[5];
                $label = $label[1];
Example #16
0
 $text .= Skin::build_block(i18n::s('Categories'), 'subtitle');
 // 'my_category' category
 if (Categories::get('my_category')) {
     $text .= sprintf(i18n::s('Category "%s" already exists.'), 'my_category') . BR . "\n";
 } else {
     $fields = array();
     $fields['nick_name'] = 'my_category';
     $fields['title'] = i18n::c('My category');
     $fields['introduction'] = i18n::c('Sample plain category');
     $fields['description'] = i18n::c('This category has been created for experimentation purpose. Feel free to change this text, to add some images, to play with codes, etc. Have you checked the help link on the side of this page? Once you will feel more comfortable with the handling of categories, just delete this one and create other categories of your own.');
     if (Categories::post($fields)) {
         $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['nick_name']) . BR . "\n";
     }
 }
 // 'my_sub_category' category
 if (Categories::get('my_sub_category')) {
     $text .= sprintf(i18n::s('Category "%s" already exists.'), 'my_sub_category') . BR . "\n";
 } elseif ($anchor = Categories::lookup('my_category')) {
     $fields = array();
     $fields['nick_name'] = 'my_sub_category';
     $fields['anchor'] = $anchor;
     $fields['title'] = i18n::c('My sub-category');
     $fields['introduction'] = i18n::c('Sample sub category');
     $fields['description'] = i18n::c('This category has been created for experimentation purpose. Feel free to change this text, to add some images, to play with codes, etc. Have you checked the help link on the side of this page? Once you will feel more comfortable with the handling of categories, just delete this one and create other categories of your own.');
     if (Categories::post($fields)) {
         $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['nick_name']) . BR . "\n";
     }
 }
 // articles
 //
 $text .= Skin::build_block(i18n::s('Pages'), 'subtitle');
Example #17
0
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // ensure we have a keyword
} elseif (!$search) {
    Logger::error(i18n::s('No keyword to search for.'));
} elseif (!($articles = Articles::search($search, 1.0, 50, 'raw'))) {
    Logger::error(i18n::s('No item has been found.'));
    // create a category for this keyword if none exists yet
} elseif (!($category =& Categories::get_by_keyword($search))) {
    $fields = array();
    $fields['keywords'] = $search;
    $fields['anchor'] = $root_category;
    $fields['title'] = ucfirst($search);
    if ($fields['id'] = Categories::post($fields)) {
        Categories::clear($fields);
        $category = Categories::get($fields['id']);
    }
}
// ensure we have a valid category for found articles
if (isset($articles) && (!isset($category) || !$category)) {
    Logger::error(i18n::s('No item has been found.'));
} elseif (isset($articles) && is_array($articles)) {
    foreach ($articles as $id => $not_used) {
        if (!Members::assign('category:' . $category['id'], 'article:' . $id)) {
            break;
        }
    }
    // redirect to the updated category, if no error has happened
    if (!count($context['error'])) {
        Safe::redirect(Categories::get_permalink($category));
    }
Example #18
0
</div>
<div class="col-lg-12">
    <div class="input-group">
      <input type="text" class="form-control" name="txtKeywords" placeholder="Search for...">
      <span class="input-group-btn">
        <button class="btn btn-danger" type="submit"><span class="glyphicon glyphicon-search"></span></button>
      </span>
    </div><!-- /input-group -->
</div>

</div>
</form>
<!-- widget -->
<!-- widget -->
<?php 
$categories = Categories::get(array('where' => "where parentid='0'"));
$li = '';
$total = count($categories);
if (isset($categories[0]['catid'])) {
    for ($i = 0; $i < $total; $i++) {
        $li .= '<li><a href="' . $categories[$i]['url'] . '">' . $categories[$i]['title'] . '</a></li>';
    }
}
$listCat = $li;
?>
<div class="row">
<div class="col-lg-12">
<h4><strong>CATEGORIES</strong></h4>
<ul class="ulMenu1">
  <?php 
echo $listCat;
Example #19
0
File: links.php Project: 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, '');
 }
Example #20
0
File: codes.php Project: 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;
     }
 }