예제 #1
0
 protected function get_page_types_using_deprecated_news_modules()
 {
     static $retrieved;
     if (!isset($retrieved)) {
         $rpts =& get_reason_page_types();
         $page_type_names = array();
         foreach ($this->old_school_news_modules as $module_name) {
             if ($page_types = $rpts->get_page_type_names_that_use_module($module_name)) {
                 $page_type_names = array_merge($page_type_names, $page_types);
             }
         }
         if (isset($page_type_names)) {
             // lets find pages using the page type if they exist and link to them.
             foreach ($page_type_names as $page_type_name) {
                 $retrieved[$page_type_name] = array();
                 $es = new entity_selector();
                 $es->limit_tables('page_node');
                 $es->limit_fields('custom_page');
                 $es->add_type(id_of('minisite_page'));
                 $es->add_relation('page_node.custom_page = "' . $page_type_name . '"');
                 $pages_using_news_modules = $es->run_one();
                 if (!empty($pages_using_news_modules)) {
                     foreach ($pages_using_news_modules as $k => $page_entity) {
                         $retrieved[$page_type_name][$k] = $page_entity;
                     }
                 }
             }
         }
     }
     return !empty($retrieved) ? $retrieved : false;
 }
예제 #2
0
 function _build_page_type()
 {
     $rpt =& get_reason_page_types();
     if ($this->controller->get_form_data('page_type_name') != 'new') {
         $this->pt = $rpt->get_page_type($this->controller->get_form_data('page_type_name'));
     } else {
         $this->pt = $rpt->get_page_type('default');
     }
     $loci = $this->pt->get_region_names();
     foreach ($loci as $region) {
         $params_array = json_decode($this->controller->get_form_data($region . "_params"), true);
         $this->pt->set_region($region, $this->controller->get_form_data($region . "_module"), $rpt->resolve_filename($this->controller->get_form_data($region . "_module")), $params_array);
     }
 }
 function should_show_children($id)
 {
     if (empty($this->root_id)) {
         $this->root_id = $this->root_node();
     }
     if ($id != $this->root_id && $this->cur_page_id == $id) {
         $rpts =& get_reason_page_types();
         $page_type_name = $this->values[$id]->get_value('custom_page');
         $pt = $page_type_name ? $rpts->get_page_type($page_type_name) : $rpts->get_page_type();
         if ($pt->has_module('children')) {
             return false;
         }
     }
     return true;
 }
 /**
  * Returns a reference to an array with data about ordered news items
  */
 function &build_news_items($publication_unique_name = NULL)
 {
     $pub_id = $this->get_publication_id();
     if ($pub_id) {
         // The idea of this entity selector is to select all news items that are related to the publication
         // along with the news item owner and id and publication id(s) other than the named publication ...
         // The result should be news items along with a site entity id and publication id(s) - we'll use that
         // data to help build the link.
         $es = new entity_selector();
         // try without site_id for now ... allows this to be used anywhere with a unique publication name
         $es->add_type(id_of('news'));
         $es->enable_multivalue_results();
         $es->limit_tables(array('press_release', 'dated', 'status'));
         $es->limit_fields(array('press_release.release_title', 'dated.datetime', 'status.status'));
         $es->add_left_relationship($pub_id, relationship_id_of('news_to_publication'));
         $alias = $es->add_left_relationship_field('news_to_publication', 'entity', 'id', 'pub_id');
         $es->add_relation($alias['pub_id']['table'] . '.' . $alias['pub_id']['field'] . " != " . $pub_id);
         $es->add_right_relationship_field('owns', 'entity', 'id', 'site_id');
         $es->add_relation('status.status = "published"');
         $es->set_order('dated.datetime DESC');
         $result = $es->run_one();
         if (!empty($result)) {
             $result_keys = array_keys($result);
             $rpts =& get_reason_page_types();
             $valid_page_types = $rpts->get_page_type_names_that_use_module($this->publication_modules);
             foreach (array_keys($valid_page_types) as $k) {
                 quote_walk($valid_page_types[$k], NULL);
             }
             foreach ($result_keys as $key) {
                 $success = $this->augment_entity($result[$key], $valid_page_types);
                 if ($success) {
                     $result[$key]->unset_value('pub_id');
                     $result[$key]->unset_value('site_id');
                 } else {
                     unset($result[$key]);
                 }
             }
         }
         $news_items =& $this->set_order_and_limits($result);
     } else {
         trigger_error('The module needs a publication unique name or a page associated with a publication to select borrowed news items');
         $news_items = array();
     }
     return $news_items;
 }
예제 #5
0
 function init_page_types()
 {
     if (!empty($this->module_sets)) {
         $ms =& reason_get_module_sets();
         foreach ($this->module_sets as $module_set) {
             $modules = $ms->get($module_set);
             if (!empty($modules)) {
                 $this->modules = array_merge($this->modules, $modules);
             }
         }
     }
     if (!empty($this->modules)) {
         $rpts =& get_reason_page_types();
         $page_types = $rpts->get_page_type_names_that_use_module($this->modules);
         foreach ($page_types as $pt) {
             if (!in_array($pt, $this->page_types)) {
                 $this->page_types[] = $pt;
             }
         }
     }
 }
예제 #6
0
 function run_error_checks()
 {
     $rpt =& get_reason_page_types();
     // Validate JSON.
     if ($this->controller->get_form_data('page_type_name') != 'new') {
         $this->pt = $rpt->get_page_type($this->controller->get_form_data('page_type_name'));
     } else {
         $this->pt = $rpt->get_page_type('default');
     }
     $loci = $this->pt->get_region_names();
     foreach ($loci as $region) {
         if ($this->get_value($region . "_params") != NULL || $this->get_value($region . "_params") != "") {
             if ($this->get_value($region . "_module") == NULL || $this->get_value($region . "_module") == "") {
                 $this->set_error($region . '_params', "{$region}: you cannot specify module parameters without assigning a module.");
             }
             if (!is_array(json_decode($this->get_value($region . "_params"), true))) {
                 $this->set_error($region . '_params', "The JSON entered was invalid.");
             }
         }
     }
 }
 /**
  * get the url of the events page
  * @return string
  */
 function _get_events_page_url()
 {
     if (is_null($this->_events_page_url)) {
         // reason_include_once( 'minisite_templates/nav_classes/default.php' );
         $ps = new entity_selector($this->site_id);
         $ps->add_type(id_of('minisite_page'));
         $rels = array();
         $page_types = array();
         $rpts =& get_reason_page_types();
         $page_types = $rpts->get_page_type_names_that_use_module($this->_events_modules);
         $page_types = array_map('reason_sql_string_escape', array_unique($page_types));
         $ps->add_relation('page_node.custom_page IN ("' . implode('","', $page_types) . '")');
         $ps->set_num(1);
         $page_array = $ps->run_one();
         $this->events_page = current($page_array);
         if (!empty($this->events_page)) {
             $this->_events_page_url = $this->_pages->get_full_url($this->events_page->id());
         } else {
             $this->_events_page_url = false;
         }
     }
     return $this->_events_page_url;
 }
예제 #8
0
 /**
  * Determine quote divider from page type parameters - if it cannot be determined, use default_divider
  * To avoid executing this code, use the set_quote_divider  method prior to init
  */
 function init_quote_divider()
 {
     $page = new entity($this->page_id);
     $page_type = $page->get_value('custom_page');
     $rpts =& get_reason_page_types();
     if ($pt = $rpts->get_page_type($page->get_value('custom_page'))) {
         foreach ($pt->get_region_names() as $region) {
             $region_info = $pt->get_region($region);
             if ($region_info['module_name'] == "quote") {
                 if (isset($region_info['module_params']['quote_divider'])) {
                     $this->set_quote_divider($region_info['module_params']['quote_divider']);
                     break;
                 }
             }
         }
     }
     if (empty($this->quote_divider)) {
         $this->set_quote_divider($this->quote_divider_default);
     }
 }
예제 #9
0
	function get_page_type()
	{
		if(!isset($this->page_type))
		{
			reason_include_once( 'classes/page_types.php');
			$requested_page_type_name = ($this->cur_page->get_value('custom_page') !== FALSE) ? $this->cur_page->get_value('custom_page') : null;
		
			// get the fully composed page type - make sure to support legacy alter_page_type operations
			$rpt =& get_reason_page_types();
			$page_type = ($requested_page_type = $rpt->get_page_type($requested_page_type_name)) ? $requested_page_type : 	$rpt->get_page_type();
			$page_type = $this->_legacy_alter_page_type($page_type, $requested_page_type_name);
			$this->alter_reason_page_type($page_type);
			$this->page_type = $page_type;
		}
		return $this->page_type;
	}
예제 #10
0
 function get_events_page_types()
 {
     // Based on the list of modules that show events, figure out which page types use them
     if (empty($this->events_page_types)) {
         $rpts =& get_reason_page_types();
         $this->events_page_types = $rpts->get_page_type_names_that_use_module($this->get_events_modules());
     }
     return $this->events_page_types;
 }
예제 #11
0
function get_blog_page_link($site, $tree, $page_types, $blog)
{
    $relations = array();
    $es = new entity_selector($site->id());
    $es->add_type(id_of('minisite_page'));
    $rpts =& get_reason_page_types();
    $ms =& reason_get_module_sets();
    $publication_modules = $ms->get('publication_item_display');
    foreach ($page_types as $page_type_name) {
        $pt = $rpts->get_page_type($page_type_name);
        $pt_props = $pt->get_properties();
        foreach ($pt_props as $region => $region_info) {
            if (in_array($region_info['module_name'], $publication_modules) && !(isset($region_info['module_params']['related_mode']) && ($region_info['module_params']['related_mode'] == "true" || $region_info['module_params']['related_mode'] == true))) {
                $valid_page_types[] = $page_type_name;
            }
        }
    }
    foreach ($valid_page_types as $page_type) {
        $relations[] = 'page_node.custom_page = "' . $page_type . '"';
    }
    $es->add_relation('(' . implode(' or ', $relations) . ')');
    $es->add_left_relationship($blog->id(), relationship_id_of('page_to_publication'));
    $es->set_num(1);
    $pages = $es->run_one();
    if (!empty($pages)) {
        $page = current($pages);
        return $tree->get_full_url($page->id(), true);
    } else {
        return false;
    }
}
예제 #12
0
		function get_events_page_url()
		{
			if(!$this->queried_for_events_page_url)
			{
				reason_include_once('classes/module_sets.php');
				$ms =& reason_get_module_sets();
				$modules = $ms->get('event_display');
				$rpts =& get_reason_page_types();
				$events_page_types = $rpts->get_page_type_names_that_use_module($modules);
				$ps = new entity_selector($this->site_id );
				$ps->add_type( id_of('minisite_page') );
				$ps->set_num(1);
				$rels = array();
				foreach($events_page_types as $page_type)
				{
					$rels[] = 'page_node.custom_page = "'.$page_type.'"';
				}
				$ps->add_relation('( '.implode(' OR ', $rels).' )');
				$page_array = $ps->run_one();
				if (!empty($page_array))
				{
					$events_page = current($page_array);
					$this->events_page_url = reason_get_page_url($events_page->id());
				}
			}
			return $this->events_page_url;
		}
예제 #13
0
		/**
		 * A nice handler for missing av things. Attempts to point the user to another
		 * place to access the item, even if that place is on another site.
		 * 
		 * Takes the ID of a missing item and looks for it on pages that use a page 
		 * type which uses a module defined in the module set 'av_module_derivatives'.
		 * Requires reason_page_types and reason_module_sets.
		 * 
		 * @param $id int The entity ID of the missing item
		 * @return null;
		 * 
		 */
		function handle_missing_item($id)
		{
			// Get the list of modules
			reason_include_once('classes/module_sets.php');
			$ms =& reason_get_module_sets();
			$av_module_derivatives = $ms->get("av_module_derivatives");
			
			// Get the page types that use these modules.
			$rpts =& get_reason_page_types();
			$allowed_page_types = array();
			foreach ($av_module_derivatives as $mod){
				$allowed_page_types = array_merge($allowed_page_types, array_diff($rpts->get_page_type_names_that_use_module($mod), $allowed_page_types));
			}
			
			// Turn this list into a string.
			$serialized = "'" . implode("','", $allowed_page_types) . "'";
			
			// Build the ES
			$es = new entity_selector();
			$es->add_type(id_of('minisite_page'));
			$es->add_left_relationship($id, relationship_id_of('minisite_page_to_av'));
			$es->add_right_relationship_field('owns', 'entity', 'name', 'site_name');
			$es->add_relation("page_node.custom_page IN ($serialized)");
			$result = $es->run_one();

			echo '<div class="notice itemNotAvailable"><h3>Sorry -- this item is not available</h3>';
			// If there are suitable replacements found, display them...
			if (!empty($result))
			{
				$url = parse_url(get_current_url());
				
				if (count($result) == 1)
				{
					$new_page_link = reason_get_page_url(current($result)->id()) . '?' . $url['query'];
					header( 'Location: ' . $new_page_link, true, 301 );
					exit;
				}
				echo "<p>However, you might be able to find it at the following location" . ((count($result)-1) ? "s" : "" ) . ":</p>\n<ul>\n";
				foreach ($result as $key => $entity)
				{
					// Don't forget to pass a nice query string that includes the item of the av as well as the av_file_id if it's in the request.
					echo '<li><a href="' . reason_get_page_url($key) . "?" . $url['query'] . "\">{$entity->get_value("site_name")}: {$entity->get_value("name")}</a></li>";
				}
				echo "</ul>";
			} else {
			// Else just echo the normal 404. 
				echo '<p>This might be because...</p><ul><li>the page you are coming from has a bad link</li><li>there is a typo in the web address</li><li>the item you are requesting has been removed</li></ul>';
			}
			echo "</div>";
		}
예제 #14
0
 function get_params_of_page_types_that_use_module($module_name)
 {
     $ret = array();
     $rpts =& get_reason_page_types();
     $page_types = $rpts->get_page_type_names_that_use_module($module_name);
     foreach ($page_types as $page_type) {
         $pts = $rpts->get_page_type($page_type);
         $tmps = $pts->get_properties();
         $d = array();
         foreach ($tmps as $key => $tmp) {
             if ($tmp['module_name'] == $module_name) {
                 if (is_array($tmp['module_params'])) {
                     $d['params'] = $tmp['module_params'];
                 }
                 $d['page_type'] = $page_type;
                 $d['location'] = $key;
                 $ret[] = $d;
             }
         }
     }
     return $ret;
 }
예제 #15
0
 function set_modules_to_process()
 {
     $modules = false;
     $rpts =& get_reason_page_types();
     $page =& $this->get_page();
     $page_type_name = $page->get_value('custom_page');
     $page_type = $rpts->get_page_type($page_type_name);
     $regions = $page_type->get_region_names();
     foreach ($regions as $region) {
         $region_info = $page_type->get_region($region);
         if (!empty($region_info['module_name']) && !empty($region_info['module_filename']) && reason_file_exists($region_info['module_filename'])) {
             reason_include_once($region_info['module_filename']);
             $module_class = $GLOBALS['_module_class_names'][$region_info['module_name']];
             $module_obj = new $module_class();
             if (method_exists($module_obj, 'clear_cache')) {
                 $modules[$region_info['module_name']] = $module_obj;
             }
         }
     }
     $this->modules = $modules ? $modules : false;
 }
예제 #16
0
/**
 * Find out what page types use the a given module
 *
 * @param mixed $module_name string or array of module names
 * @return array $page_types
 */
function page_types_that_use_module($module_name)
{
    if (is_array($module_name)) {
        $ret = array();
        foreach ($module_name as $name) {
            $ret = array_merge($ret, page_types_that_use_module($name));
        }
        return $ret;
    } else {
        reason_include_once('classes/page_types.php');
        $rpts =& get_reason_page_types();
        $pt_using_module = $rpts->get_page_type_names_that_use_module($module_name);
        return $pt_using_module;
    }
}
예제 #17
0
$core_local_limiter = isset($request['core_local_limit']) ? check_against_array($request['core_local_limit'], array('core', 'local')) : '';
$num = isset($request['num']) ? turn_into_int($request['num']) : 'All';
if (isset($request['reset'])) {
    header("Location: " . carl_make_redirect(array('limit' => '', 'core_local_limit' => '')));
    exit;
}
// Make an array with first dimension of page type name, second dimension of every page
// ID using the pt, third dimension 'true' for every page type returned by the query.
foreach ($result as $k => $mypage) {
    $page_type_value = $mypage->get_value('custom_page');
    if (empty($page_type_value)) {
        $page_type_value = 'default';
    }
    $reason_page_types[$page_type_value][$k] = 'true';
}
$rpts =& get_reason_page_types();
$all_page_types = $rpts->get_page_types();
foreach ($all_page_types as $page_type_name => $pt_obj) {
    $regions = $pt_obj->get_region_names();
    foreach ($regions as $region) {
        $region_info = $pt_obj->get_region($region);
        if (!empty($region_info['module_name'])) {
            if ($detail_mode) {
                $check = $region_info['module_name'] == $detail_limiter ? true : false;
            } else {
                $check = empty($module_limiter) ? true : stripos($region_info['module_name'], $module_limiter) !== false;
            }
            if (isset($reason_page_types[$page_type_name]) && $check) {
                if (empty($core_local_limiter) || module_location_is_acceptable($region_info['module_name'], $core_local_limiter)) {
                    $modules_by_page_type[$region_info['module_name']][$page_type_name] = $reason_page_types[$page_type_name];
                }
예제 #18
0
	function get_owner_site_info($e)
	{
		$owner_site = $e->get_owner();
		if($owner_site->id() != $this->parent->site_info->id())
		{
			reason_include_once( 'classes/module_sets.php' );
			$ms =& reason_get_module_sets();
			$modules = $ms->get('event_display');
			$rpts =& get_reason_page_types();
			$page_types = $rpts->get_page_type_names_that_use_module($modules);
			if (!empty($page_types))
			{
				$tree = NULL;
				$owner_site->set_value('_link', get_page_link($owner_site, $tree, $page_types, true));
			}
			else
			{
				$owner_site->set_value('_link', $owner_site->get_value('base_url'));
			}
			return $owner_site;
		}
		return false;
	}
 /**
  * Support function for get_news_minisite_page
  */
 function &get_page_types_with_main_post_news()
 {
     $rpts =& get_reason_page_types();
     static $page_types_with_main_post_news;
     if (!isset($page_types_with_main_post_news)) {
         foreach ($this->news_modules as $module) {
             $candidate_page_types = isset($candidate_page_types) ? array_unique(array_merge($candidate_page_types, $rpts->get_page_type_names_that_use_module($module))) : array_unique($rpts->get_page_type_names_that_use_module($module));
         }
         //!working
         foreach ($candidate_page_types as $page_type_name) {
             // we need to make sure one of the news modules is assigned to the main_post area
             $page_type = $rpts->get_page_type($page_type_name);
             if (in_array('main_post', $page_type->get_region_names())) {
                 $region_info = $page_type->get_region('main_post');
                 $main_post_module = $region_info['module_name'];
                 if (in_array($main_post_module, $this->news_modules)) {
                     $page_types_with_main_post_news[$page_type_name] = $page_type_name;
                 }
             }
         }
     }
     return $page_types_with_main_post_news;
 }
예제 #20
0
 function &_get_site_pages_with_valid_publications()
 {
     $rpts =& get_reason_page_types();
     $ms =& reason_get_module_sets();
     $publication_modules = $ms->get('publication_item_display');
     $page_types = $rpts->get_page_type_names_that_use_module($publication_modules);
     // this logic to exclude publication page types with related mode set to true is a bit silly.
     // perhaps we should have in the page types class something that lets us filter a set of page types according to parameter values or something
     foreach ($page_types as $page_type_name) {
         $pt = $rpts->get_page_type($page_type_name);
         $pt_props = $pt->get_properties();
         foreach ($pt_props as $region => $region_info) {
             if (in_array($region_info['module_name'], $publication_modules) && !(isset($region_info['module_params']['related_mode']) && ($region_info['module_params']['related_mode'] == "true" || $region_info['module_params']['related_mode'] == true))) {
                 $valid_page_types[] = $page_type_name;
             }
         }
     }
     if (isset($valid_page_types)) {
         // check each page type to make sure publication is NOT in related mode
         foreach (array_keys($valid_page_types) as $k) {
             quote_walk($valid_page_types[$k], NULL);
         }
         $es = new entity_selector($this->site->id());
         $es->add_type(id_of('minisite_page'));
         $es->limit_tables(array('page_node'));
         $es->limit_fields(array('custom_page'));
         $es->add_left_relationship_field('page_to_publication', 'entity', 'id', 'pub_id');
         $es->add_relation('page_node.custom_page IN (' . implode(",", $valid_page_types) . ')');
         $result = $es->run_one();
     } else {
         $result = false;
     }
     return $result;
 }
예제 #21
0
 /**
  * @return an html string contain the controls for resizing the live preview
  *
  */
 function get_preview_controls()
 {
     //get the parameters, location, and page types that use feature
     //and place the height and width as option tag values, and page type
     // and location as what the user sees when using the select box.
     $rpts =& get_reason_page_types();
     $ptypes = $rpts->get_params_of_page_types_that_use_module('feature/feature');
     $types = array();
     $contents = array();
     foreach ($ptypes as $type) {
         $types[$type['page_type']] = $type;
     }
     //		pray($types);
     if (!empty($types)) {
         $prepped = array();
         foreach ($types as $pt => $type) {
             $prepped[] = reason_sql_string_escape($pt);
         }
         $es = new entity_selector();
         $es->add_type(id_of('minisite_page'));
         $es->add_relation('custom_page IN ("' . implode('","', $prepped) . '")');
         $es->add_left_relationship($this->get_value('id'), relationship_id_of('page_to_feature'));
         $placed_pages = $es->run_one();
         //			pray($placed_pages);
         foreach ($placed_pages as $page) {
             $w = $this->width;
             $h = $this->height;
             if (!empty($types[$page->get_value('custom_page')]['params']['width'])) {
                 $w = htmlspecialchars($types[$page->get_value('custom_page')]['params']['width']);
             }
             if (!empty($types[$page->get_value('custom_page')]['params']['height'])) {
                 $h = htmlspecialchars($types[$page->get_value('custom_page')]['params']['height']);
             }
             $name = strip_tags($page->get_value('name'));
             $contents[] = array('name' => $name, 'w' => $w, 'h' => $h, 'italicize' => true);
         }
         $es = new entity_selector($this->get_value('site_id'));
         $es->add_type(id_of('minisite_page'));
         $es->add_relation('custom_page IN ("' . implode('","', $prepped) . '")');
         if (!empty($placed_pages)) {
             $es->add_relation('entity.id NOT IN ("' . implode('","', array_keys($placed_pages)) . '")');
         }
         $site_pages = $es->run_one();
         foreach ($site_pages as $page) {
             $w = $this->width;
             $h = $this->height;
             if (!empty($types[$page->get_value('custom_page')]['params']['width'])) {
                 $w = htmlspecialchars($types[$page->get_value('custom_page')]['params']['width']);
             }
             if (!empty($types[$page->get_value('custom_page')]['params']['height'])) {
                 $h = htmlspecialchars($types[$page->get_value('custom_page')]['params']['height']);
             }
             $name = strip_tags($page->get_value('name'));
             $contents[] = array('name' => $name, 'w' => $w, 'h' => $h);
         }
     }
     // end if(!empty($types))
     if (empty($contents)) {
         $contents[] = array('name' => "Default Size (No pages show features on the site yet)", 'w' => $this->width, 'h' => $this->height);
     }
     //testing with a ton O' tabs
     /*
     		for($i=100;$i<400;$i=$i+10)
     		{
     			$contents[]=array('name'=>"foo$i",'w'=>$i,'h'=>$i);
     		}
     
     
     		//testing with a ton O' pages
     		for($i=100;$i<400;$i++)
     		{
     			$contents[]=array('name'=>"foo$i",'w'=>400,'h'=>300);
     		}
     */
     $tabs = new Feature_Tabs();
     $tabs->set($contents);
     $w = $this->width;
     $h = $this->height;
     //		echo $w."x".$h;
     //		$tabs->set_active_tab($w."x".$h);
     $tab_html_str = $tabs->get_html();
     $str = "<h4 class=\"size_label\">Preview At Different Sizes </h4>";
     $str .= $tab_html_str;
     return $str;
 }