Example #1
0
/**
 * Get the full url (from server root) for a minisite page
 *
 * the function will cache the minisite navigation object for a site so when called repeatedly it
 * should only instantiate minisite navigation once per site
 *
 * Because this method caches whole sites, it will likely be faster than build_URL() if
 * you are getting the URLs of bunches of pages on a site. If you are getting just a single
 * URL of a single page, or you are getting URLs of a few pages on different sites, build_URL()
 * will likely be faster (and consume less memory).
 * 
 * @param int site_id
 * @param int page_id
 * @param string query_string will be appended to end of returned url
 * @param boolean secure whether to return a link prefaced with http or https
 * @param array viewer can be used to pass in existant minisite_navigation objects indexed by site id when available
 * @return string full url of the minisite page $page_id
 */
function get_minisite_page_link($site_id, $page_id, $query_string = '', $secure = true, $viewer = array())
{
    reason_include_once('minisite_templates/nav_classes/default.php');
    $ret = '';
    if (empty($page_id) || empty($site_id)) {
        trigger_error("get_minisite_page_link must be called with a valid page_id ({$page_id}) and site_id ({$site_id})");
        return '';
    }
    static $nav_cache = array();
    if (isset($nav_cache[$site_id])) {
        $pages =& $nav_cache[$site_id];
    } elseif (isset($viewer[$site_id])) {
        $pages = $viewer[$site_id];
    } else {
        //$s = get_microtime();
        $pages = new MinisiteNavigation();
        $site = new entity($site_id);
        $pages->site_info = $site;
        $pages->init($site_id, id_of('minisite_page'));
        $nav_cache[$site_id] = $pages;
    }
    $ret = $pages->get_full_url($page_id, true, $secure);
    //$ret = $pages->get_url_from_base($page_id);
    if (!empty($query_string)) {
        $ret .= '?' . $query_string;
    }
    return $ret;
}
Example #2
0
 }
 $sites = $es->run_one();
 $info = array();
 foreach ($sites as $site_id => $site) {
     $pages = new MinisiteNavigation();
     $pages->site_info =& $site;
     //for a bot the order probably does not matter, and adding this line will slow things down
     //$pages->order_by = 'sortable.sort_order'
     $pages->init($site_id, id_of('minisite_page'));
     foreach ($pages->values as $page_id => $page) {
         if (!$page->get_value('url')) {
             /* Add code here to only include pages that are indexable. (To be
             			implemented after toggle is added to page interface.) - AF */
             if ('1' == $page->get_value('indexable')) {
                 turn_carl_util_error_output_off();
                 $url = $pages->get_full_url($page_id, true);
                 turn_carl_util_error_output_on;
                 if (!empty($url)) {
                     $info[$page_id] = array('loc' => $url);
                     $priority = $default_priority;
                     if ($pages->root_node() == $page_id) {
                         $priority = $home_page_priority;
                     }
                     $page_type = $page->get_value('custom_page');
                     if (empty($page_type)) {
                         $page_type = 'default';
                     }
                     if (isset($page_type_priorities[$page_type])) {
                         $priority = $page_type_priorities[$page_type];
                     }
                     $info[$page_id]['priority'] = $priority;