コード例 #1
0
ファイル: browse.php プロジェクト: schlos/electionleaflets
 function bind()
 {
     $this->page_title = "Browse election leaflets";
     //get top parties
     $parties_counts = tableclass_party::get_party_count(STAT_ZERO_DATE);
     $this->assign("parties_counts", $parties_counts);
     //get categories
     $categories_counts = tableclass_category::get_category_count(STAT_ZERO_DATE);
     $this->assign("categories_counts", $categories_counts);
     //get electorates
     $constituencies_counts = tableclass_constituency::get_constituency_count(STAT_ZERO_DATE);
     $this->assign("constituencies_counts", $constituencies_counts);
     //get top tags
     $tag = factory::create("tag");
     $weighted_tags = $tag->get_weighted_tags();
     $this->assign("weighted_tags", $weighted_tags);
 }
コード例 #2
0
ファイル: index.php プロジェクト: schlos/electionleaflets
 function bind()
 {
     $this->page_title = SITE_TAG_LINE;
     $this->onloadscript = "\$('#divScroller ul').jcarousel({wrap: 'last',initCallback: mycarousel_initCallback,buttonNextHTML: null,buttonPrevHTML: null});";
     //get count of leaflets
     $leaflet = factory::create('leaflet');
     $this->assign("leaflet_count", $leaflet->count_live());
     //get recent leaflets
     $leaflet_search = factory::create("leaflet_search");
     $leaflet_search->start = 0;
     $leaflet_search->number = 60;
     $leaflets = $leaflet_search->search(true);
     //counts
     $party_counts = tableclass_party::get_party_count(STAT_ZERO_DATE);
     $not_spots = tableclass_constituency::get_not_spots();
     $constituency_counts = tableclass_constituency::get_constituency_count(STAT_ZERO_DATE);
     //assign
     $this->assign("party_counts", $party_counts);
     $this->assign("constituency_counts", $constituency_counts);
     $this->assign("constituencies", $constituencies);
     $this->assign("not_spots", $not_spots);
     $this->assign("leaflets", $leaflets);
     $this->assign("is_home", true);
 }
コード例 #3
0
ファイル: leaflets.php プロジェクト: schlos/electionleaflets
 function bind()
 {
     $election_id = get_election_id();
     //get variables
     $this->get_vars();
     //if rss requested, change template
     if ($this->is_rss) {
         $this->reset_smarty("rss.tpl");
     }
     //generic search
     if (isset($this->search_term)) {
         //guess search term
         $search_type = $this->leaflet_search->guess_search_type($this->search_term);
         $this->assign("user_term", $search_type['display']);
         $this->assign("search_type", $search_type['type']);
         //geo vs normal
         $leaflets = array();
         if ($search_type['type'] == "postcode" || ($search_type['type'] = 'partial postcode')) {
             $geocoder = factory::create('geocoder');
             $success = $geocoder->set_from_postcode($search_type['display'], COUNTRY_CODE_TLD);
             if ($success) {
                 $this->leaflet_search->lng = $geocoder->lng;
                 $this->leaflet_search->lat = $geocoder->lat;
             } else {
                 trigger_error("Error geocoding on user search");
             }
         }
     }
     //do search
     $leaflets = array();
     $total_count = 0;
     $current_page = 1;
     $leaflets = $this->leaflet_search->search();
     if ($this->has_vars_set()) {
         //get total count (set out to null and redo)
         //TODO: make this more efficiant by removing joins
         $current_page_number = $this->leaflet_search->start / PAGE_ITEMS_COUNT + 1;
         $this->leaflet_search->start = null;
         $this->leaflet_search->number = null;
         $all_leaflets = $this->leaflet_search->search(true);
         $total_count = count($all_leaflets);
     } else {
         $leaflet = factory::create('leaflet');
         $total_count = $leaflet->count_live();
         $current_page_number = get_http_var("page");
     }
     $total_pages = ceil($total_count / PAGE_ITEMS_COUNT);
     //get other stuff for sidebar
     $search = factory::create('search');
     //get top parties
     $parties = $search->search_cached("party", array(array("major", "=", true), array('party_election.election_id', '=', $election_id)), "AND", array(array("party_election", "inner")), array(array("name", "ASC")));
     $categories = $search->search_cached("category", array(array("1", "=", "1")), "AND", null, array(array("name", "ASC")));
     //assign vars
     $title_parts = $this->get_title();
     $this->rss_link = htmlspecialchars($_SERVER['REQUEST_URI']) . "/rss";
     if (count($title_parts) > 1) {
         $this->page_title = $title_parts[0] . " " . $title_parts[1];
     } else {
         $this->page_title = "Latest leaflets";
     }
     $this->assign("leaflets", $leaflets);
     $this->assign("has_leaflets", count($leaflets) > 0);
     $this->assign("is_search", $this->is_search());
     $this->assign("is_browse", $this->is_browse());
     $this->assign("is_geo", $this->is_geo());
     $this->assign("has_party", isset($this->leaflet_search->publisher_party_id));
     $this->assign("has_category", isset($this->leaflet_search->category_id));
     $this->assign("has_constituency", isset($this->leaflet_search->constituency_id));
     $this->assign("has_tag", isset($this->leaflet_search->tag));
     $this->assign("has_party_attack", isset($this->leaflet_search->party_attack_id));
     $this->assign("heading", $title_parts);
     $this->assign("alert_link", $this->get_alert_link());
     $this->assign("total_count", $total_count);
     $this->assign("show_pagination", $total_count > 1);
     $this->assign("total_pages", $total_pages);
     $this->assign("current_page_number", $current_page_number);
     $this->assign("pagination", $this->get_pagination(1, $total_pages, $current_page_number));
     $this->assign("search_link", WWW_SERVER);
     //get parties
     $parties_counts = tableclass_party::get_party_count(STAT_ZERO_DATE);
     $this->assign("parties_counts", $parties_counts);
     //get categories
     $categories_counts = tableclass_category::get_category_count(STAT_ZERO_DATE);
     $this->assign("categories_counts", $categories_counts);
 }