} else { $context['page_title'] = i18n::s('Select categories for this page'); } // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!is_object($anchor)) { Safe::header('Status: 404 Not Found', TRUE, 404); Logger::error(i18n::s('No item has been found.')); // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($member, 'select'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // build a form to associates some categories to this item } else { // actual update if (isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) { // on error display the form again if ($error = Members::toggle($_REQUEST['anchor'], $_REQUEST['member'], isset($_REQUEST['father']) ? $_REQUEST['father'] : '')) { Logger::error($error); } } // the current list of linked categories $categories =& Members::list_categories_by_title_for_member($member, 0, CATEGORIES_LIST_SIZE, 'raw');
/** * get the url to display the main page for this anchor * * @param string the targeted action ('view', 'print', 'edit', 'delete', ...) * @return an anchor to the viewing script, or NULL * * @see shared/anchor.php */ function get_url($action = 'view') { if (isset($this->item['id'])) { if ($action == 'view') { return Categories::get_permalink($this->item); } else { return Categories::get_url($this->item['id'], $action, $this->item['title']); } } return NULL; }
// the title of the page if (isset($item['title'])) { $context['page_title'] = $item['title']; } // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($item['id'], 'print'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the category } else { // the introduction text $context['text'] .= Skin::build_block($item['introduction'], 'introduction'); // the beautified description, which is the actual page body $context['text'] .= Skin::build_block($item['description'], 'description'); // // date of last update // $context['text'] .= i18n::s('Last update').' '.Skin::build_date($item['edit_date']); // // the section of sub-categories //
} // in a navigation box $box_popup = ''; $context['components']['contextual'] = Skin::build_box($box_title, $menu, 'contextual', 'contextual_menu', $box_url, $box_popup); } // categories attached to this article, if not at another follow-up page if (!$zoom_type || $zoom_type == 'categories') { // build a complete box $box['bar'] = array(); $box['text'] = ''; // list categories by title $offset = ($zoom_index - 1) * CATEGORIES_PER_PAGE; $items =& Members::list_categories_by_title_for_member('article:' . $item['id'], $offset, CATEGORIES_PER_PAGE, 'sidebar'); // the command to change categories assignments if (Categories::allow_assign($item, $anchor)) { $items = array_merge($items, array(Categories::get_url('article:' . $item['id'], 'select') => i18n::s('Assign categories'))); } // actually render the html for the section if (is_array($box['bar'])) { $box['text'] .= Skin::build_list($box['bar'], 'menu_bar'); } if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'compact'); } if ($box['text']) { $context['components']['categories'] = Skin::build_box(i18n::s('See also'), $box['text'], 'categories', 'categories'); } } // referrals, if any $context['components']['referrals'] =& Skin::build_referrals(Articles::get_permalink($item)); }
} } // adjust dates from surfer time zone to UTC time zone if (isset($_REQUEST['expiry_date'])) { $_REQUEST['expiry_date'] = Surfer::to_GMT($_REQUEST['expiry_date']); } // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // permission denied } elseif (!$permitted) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { if (isset($item['id'])) { $link = Categories::get_url($item['id'], 'edit'); } elseif (isset($_REQUEST['anchor'])) { $link = 'categories/edit.php?anchor=' . urlencode($_REQUEST['anchor']); } else { $link = 'categories/edit.php'; } Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode($link)); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // an error occured } elseif (count($context['error'])) { $item = $_REQUEST; $with_form = TRUE; // update an existing category
// full articles $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Pages with full content') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('articles') . '"' . " />\n"; // newest comments $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Comments') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('comments') . '"' . " />\n"; // the file rss feed for podcasting, etc. $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Files and podcasts') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('files') . '"' . " />\n"; // one feed per section if ($items = Sections::list_by_title_for_anchor(NULL, 0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($id, 'feed') . '"' . " />\n"; } } // one feed per category if ($items = Categories::list_by_date(0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Categories::get_url($id, 'feed') . '"' . " />\n"; } } // one feed per user if ($items = Users::list_by_posts(0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['nick_name']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($id, 'feed') . '"' . " />\n"; } } // the postamble $text .= '</body>' . "\n" . '</opml>' . "\n"; // put in cache Safe::file_put_contents($cache_id, $text); } // // transfer to the user agent
/** * get permanent address * * @param array page attributes * @return string the permanent web address to this item, relative to the installation path */ public static function get_permalink($item) { global $context; // sanity check if (!isset($item['id'])) { throw new Exception('bad input parameter'); } // absolute link return $context['url_to_home'] . $context['url_to_root'] . Categories::get_url($item['id'], 'view', $item['title']); }
if (Links::allow_trackback()) { Skin::define_img('TOOLS_TRACKBACK_IMG', 'tools/trackback.gif'); $lines[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('category:' . $item['id']), TOOLS_TRACKBACK_IMG . i18n::s('Reference this page'), 'basic', i18n::s('Various means to link to this page')); } // print this page if (Surfer::is_logged()) { Skin::define_img('TOOLS_PRINT_IMG', 'tools/print.gif'); $lines[] = Skin::build_link(Categories::get_url($item['id'], 'print'), TOOLS_PRINT_IMG . i18n::s('Print this page'), 'basic', i18n::s('Get a paper copy of this page.')); } // in a side box if (count($lines)) { $context['components']['share'] = Skin::build_box(i18n::s('Share'), Skin::finalize_list($lines, 'newlines'), 'share', 'share'); } // get news from rss if (isset($item['id']) && (!isset($context['skins_general_without_feed']) || $context['skins_general_without_feed'] != 'Y')) { $content = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . Categories::get_url($item['id'], 'feed'), i18n::s('Recent pages'), 'xml'); // public aggregators // if(!isset($context['without_internet_visibility']) || ($context['without_internet_visibility'] != 'Y')) // $content .= BR.join(BR, Skin::build_subscribers($context['url_to_home'].$context['url_to_root'].Categories::get_url($item['id'], 'feed'), $item['title'])); $context['components']['channels'] = Skin::build_box(i18n::s('Monitor'), $content, 'channels', 'feeds'); } // search on keyword, if any if ($item['keywords']) { // internal search $label = sprintf(i18n::s('Maybe some new pages or additional material can be found by submitting the following keyword to our search engine. Give it a try. %s'), Codes::beautify('[search=' . $item['keywords'] . ']')); $context['components']['boxes'] .= Skin::build_box(i18n::s('Internal search'), $label, 'extra'); // external search $content = '<p>' . sprintf(i18n::s('Search for %s at:'), $item['keywords']) . ' '; // encode for urls, but preserve unicode chars $search = urlencode(utf8::from_unicode($item['keywords'])); // Google