function run_job()
 {
     reason_include_once('minisite_templates/nav_classes/default.php');
     $page_ids = $this->config('page_ids');
     $id = reset($page_ids);
     $page = new entity($id);
     $site = $page->get_owner();
     // lets make and get the page tree
     $page_tree = new MinisiteNavigation();
     $page_tree->order_by = 'sortable.sort_order';
     $page_tree->init($site->id(), id_of('minisite_page'));
     foreach ($page_ids as $page_id) {
         $children = $page_tree->children($page_id);
         $diff = array_diff($children, $page_ids);
         // are we trying to move a page without its children?
         if (!empty($diff)) {
             $problem[] = 'Cannot move page id ' . $page_id . ' without also moving child pages with ids (' . implode(", ", $diff) . ')';
         }
     }
     if (isset($problem)) {
         $report = 'Blocking any further jobs. When moving pages you need to move entire branches';
         $report .= '<ul>';
         $report .= '<li>' . implode("</li><li>", $problem) . '</li>';
         $report .= '</ul>';
         $this->set_report($report);
         $this->block_jobs();
         return false;
     } else {
         $this->set_report('Verified that the page tree integrity is preserved with this move.');
     }
     return true;
 }
 function get_selection_page_set($site_id)
 {
     reason_include_once('minisite_templates/nav_classes/default.php');
     $pages = new MinisiteNavigation();
     $site = new entity($site_id);
     $pages->site_info = $site;
     $pages->init($site_id, id_of('minisite_page'));
     return $this->flatten_page_tree($pages->get_tree_data());
 }
Example #3
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 #4
0
     }
 }
 // This script could take a while if the
 set_time_limit(3600);
 $es = new entity_selector();
 $es->add_type(id_of('site'));
 $es->add_relation('site_state = "Live"');
 /* Add new relation to indicate to only include sites that are indexable. - AF*/
 //$es->set_num(200);
 if (!empty($exclude_sites)) {
     $es->add_relation('`entity`.`id` NOT IN ("' . implode('","', $exclude_sites) . '")');
 }
 $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;
 function get_page_tree($site)
 {
     $pages = new MinisiteNavigation();
     $pages->site_info = $site;
     $pages->init($this->site_id, id_of('minisite_page'));
     return $pages;
 }