Example #1
0
 /**
  * Get the set of sites that share events
  * @return array site entities keyed on Reason id
  * @access private
  */
 protected function _get_sharing_sites()
 {
     static $sharing_sites = array();
     if (empty($sharing_sites)) {
         $es = new entity_selector();
         $es->add_type(id_of('site'));
         $es->add_left_relationship(id_of('event_type'), relationship_id_of('site_shares_type'));
         $es->limit_tables('site');
         $es->limit_fields('site_state');
         $es->add_relation('site_state="Live"');
         $es->set_cache_lifespan($this->_get_cache_lifespan_meta());
         $sharing_sites = $es->run_one();
     }
     return $sharing_sites;
 }
Example #2
0
	/**
	 * Set up an initalization array for a reason calendar object
	 *
	 * @param string $start_date mysql date
	 * @param string $end_date mysql date
	 * @param string $view
	 * @return array
	 */
	function make_reason_calendar_init_array($start_date, $end_date = '', $view = '')
	{
		$init_array = array();
		$init_array['context_site'] = $this->parent->site_info;
		$init_array['site'] = $this->_get_sites();
		$init_array['sharing_mode'] = $this->_get_sharing_mode();
		if(!empty($start_date))
			$init_array['start_date'] = $start_date;
		if(!empty($end_date))
		{
			$init_array['end_date'] = $end_date;
		}
		elseif(!empty($view))
		{
			$init_array['view'] = $view;
		}
		if(!empty($this->pass_vars['audience']))
		{
			$audience = new entity($this->pass_vars['audience']);
			$init_array['audiences'] = array( $audience->id()=>$audience );
		}
		if(!empty($this->pass_vars['category']))
		{
			$category = new entity($this->pass_vars['category']);
			$init_array['categories'] = array( $category->id()=>$category );
		}
		if($this->params['limit_to_page_categories'])
		{
			$es = new entity_selector( $this->parent->site_id );
			$es->description = 'Selecting categories for this page';
			$es->add_type( id_of('category_type') );
			$es->set_env('site',$this->parent->site_id);
			$es->add_right_relationship( $this->parent->cur_page->id(), relationship_id_of('page_to_category') );
			$es->set_cache_lifespan($this->get_cache_lifespan_meta());
			$cats = $es->run_one();
			if(!empty($cats))
			{
				$init_array['or_categories'] = $cats;
			}
		}
		if($this->params['ideal_count'])
			$init_array['ideal_count'] = $this->params['ideal_count'];
		elseif(!empty($this->ideal_count))
			$init_array['ideal_count'] = $this->ideal_count;
		
		if($this->params['default_view_min_days']) 
			$init_array['default_view_min_days'] = $this->params['default_view_min_days'];
		
		$init_array['automagic_window_snap_to_nearest_view'] = $this->snap_to_nearest_view;
		
		if($markup = $this->get_markup_object('list'))
			$display_type = $markup->get_ongoing_display_type();
		else
			$display_type = 'above';
		
		if('inline' == $display_type)
		{
			$init_array['ongoing_count_all_occurrences'] = true;
		}
		elseif('above' == $display_type)
		{
			$init_array['ongoing_count_all_occurrences'] = false;
			$init_array['ongoing_count_pre_start_dates'] = true;
			$init_array['ongoing_count_ends'] = $this->params['ongoing_show_ends'];
		}
		elseif('below' == $display_type)
		{
			$init_array['ongoing_count_all_occurrences'] = false;
			$init_array['ongoing_count_pre_start_dates'] = false;
			$init_array['ongoing_count_ends'] = $this->params['ongoing_show_ends'];
		}
		
		if(!empty($this->request['search']))
		{
			$init_array['simple_search'] = $this->request['search'];
		}
		$init_array['es_callback'] = array($this, 'reason_calendar_master_callback');
		$init_array['cache_lifespan'] = $this->get_cache_lifespan();
		$init_array['cache_lifespan_meta'] = $this->get_cache_lifespan_meta();
		return $init_array;
	}