本文整理汇总了PHP中Category_Model::getCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model::getCategories方法的具体用法?PHP Category_Model::getCategories怎么用?PHP Category_Model::getCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category_Model
的用法示例。
在下文中一共展示了Category_Model::getCategories方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->template->content = new View('mobile/main');
// Get 10 Most Recent Reports
$this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->with('location')->find_all();
// Get all active top level categories
$parent_categories = array();
$parentCategoryId = 0;
foreach (Category_Model::getCategories($parentCategoryId) as $category) {
// Get The Children
$children = array();
foreach ($category->children as $child) {
$children[$child->id] = array($child->category_title, $child->category_color, $child->category_image, $this->_category_count($child->id));
}
// Put it all together
$parent_categories[$category->id] = array($category->category_title, $category->category_color, $category->category_image, $this->_category_count($category->id), $children);
if ($category->category_trusted) {
// Get Trusted Category Count
$trusted = ORM::factory("incident")->join("incident_category", "incident.id", "incident_category.incident_id")->where("category_id", $category->id);
if (!$trusted->count_all()) {
unset($parent_categories[$category->id]);
}
}
}
$this->template->content->categories = $parent_categories;
// Get RSS News Feeds
$this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all();
}
示例2: index
public function index()
{
$this->template->header->this_page = 'home';
$this->template->content = new View('main');
// Cacheable Main Controller
$this->is_cachable = TRUE;
// Map and Slider Blocks
$div_map = new View('main_map');
$div_timeline = new View('main_timeline');
// Filter::map_main - Modify Main Map Block
Event::run('ushahidi_filter.map_main', $div_map);
// Filter::map_timeline - Modify Main Map Block
Event::run('ushahidi_filter.map_timeline', $div_timeline);
$this->template->content->div_map = $div_map;
$this->template->content->div_timeline = $div_timeline;
// Check if there is a site message
$this->template->content->site_message = '';
$site_message = trim(Kohana::config('settings.site_message'));
if($site_message != '')
{
$this->template->content->site_message = $site_message;
}
// Get locale
$l = Kohana::config('locale.language.0');
// Get all active top level categories
$parent_categories = array();
$parentCategoryId = 0;
foreach ( Category_Model::getCategories($parentCategoryId) as $category )
{
// Get The Children
$children = array();
foreach ($category->children as $child)
{
// Check for localization of child category
$translated_title = Category_Lang_Model::category_title($child->id,$l);
if($translated_title)
{
$display_title = $translated_title;
}
else
{
$display_title = $child->category_title;
}
$children[$child->id] = array(
$display_title,
$child->category_color,
$child->category_image
);
if ($child->category_trusted)
{ // Get Trusted Category Count
$trusted = ORM::factory("incident")
->join("incident_category","incident.id","incident_category.incident_id")
->where("category_id",$child->id);
if ( ! $trusted->count_all())
{
unset($children[$child->id]);
}
}
}
// Check for localization of parent category
$translated_title = Category_Lang_Model::category_title($category->id,$l);
if($translated_title)
{
$display_title = $translated_title;
}else{
$display_title = $category->category_title;
}
// Put it all together
$parent_categories[$category->id] = array(
$display_title,
$category->category_color,
$category->category_image,
$children
);
if ($category->category_trusted)
{ // Get Trusted Category Count
$trusted = ORM::factory("incident")
->join("incident_category","incident.id","incident_category.incident_id")
->where("category_id",$category->id);
if ( ! $trusted->count_all())
{
unset($parent_categories[$category->id]);
}
}
}
$this->template->content->categories = $parent_categories;
//.........这里部分代码省略.........
示例3: index
public function index()
{
$this->template->content = new View('keitai/main');
$latlong = "";
$lat = "";
$lon = "";
$latmin = "";
$latmax = "";
$lonmin = "";
$lonmax = "";
$this->template->content->area_name = "";
if (isset($_GET['latlong'])) {
$latlong = $_GET['latlong'];
if (preg_match("/^([0-9\.]+),([0-9\.]+)/", $latlong, $matches)) {
$lat = $matches[1];
$lon = $matches[2];
$latmin = $lat - 0.0277778;
$latmax = $lat + 0.0277778;
$lonmin = $lon - 0.0277778;
$lonmax = $lon + 0.0277778;
$lon_center = ($lonmin+$lonmax) / 2;
$lat_center = ($latmin+$latmax) / 2;
$geo_url = 'http://maps.google.com/maps/api/geocode/json?region=jp&language=ja&latlng='.$lat_center.','.$lon_center.'&sensor=false';
$geo_google = json_decode(file_get_contents($geo_url) , true);
foreach($geo_google["results"] as $geo_val){
if($geo_val["types"][0]=="locality" && $geo_val["types"][1]=="political" && count($geo_val["types"])==2){
$area_name = explode(',',$geo_val["formatted_address"]);
}
}
if(isset($area_name))$this->template->content->area_name = $area_name[1];
}
}
$this->template->content->lat = $lat;
$this->template->content->lon = $lon;
$this->template->content->latlong = $latlong;
$this->template->content->device = $this->checkdevice($_SERVER['HTTP_USER_AGENT']);
// Get 10 Most Recent Reports
if ($latlong) {
$this->template->content->incidents = ORM::factory('incident')
->where(array('location.latitude >=' => $latmin))
->where(array('location.latitude <=' => $latmax))
->where(array('location.longitude >=' => $lonmin))
->where(array('location.longitude <=' => $lonmax))
->where('incident_active', '1')
->limit('3')
->orderby('incident_date', 'desc')
->with('location')
->find_all();
} else {
$this->template->content->incidents = ORM::factory('incident')
->where('incident_active', '1')
->limit('3')
->orderby('incident_date', 'desc')
->with('location')
->find_all();
}
// Get all active top level categories
$parent_categories = array();
$parentCategoryId = 0;
foreach ( Category_Model::getCategories($parentCategoryId) as $category )
{
// Get The Children
$children = array();
foreach ($category->children as $child) {
$children[$child->id] = array(
$child->category_title,
$child->category_color,
$child->category_image,
$this->_category_count($child->id,$latmin,$latmax,$lonmin,$lonmax)
);
}
// Put it all together
$parent_categories[$category->id] = array(
$category->category_title,
$category->category_color,
$category->category_image,
$this->_category_count($category->id,$latmin,$latmax,$lonmin,$lonmax),
$children
);
if ($category->category_trusted) { // Get Trusted Category Count
$trusted = ORM::factory("incident")
->join("incident_category","incident.id","incident_category.incident_id")
->where("category_id",$category->id);
if ( ! $trusted->count_all()) {
unset($parent_categories[$category->id]);
}
}
}
$this->template->content->categories = $parent_categories;
// Get RSS News Feeds
$this->template->content->feeds = ORM::factory('feed_item')
->limit('3')
->orderby('item_date', 'desc')
->find_all();
//.........这里部分代码省略.........