本文整理汇总了PHP中Category_Model类的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model类的具体用法?PHP Category_Model怎么用?PHP Category_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Category_Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Show the profile of a student
*/
public function view($params)
{
$this->setView('view.php');
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
// If the user isn't logged in
if (!$is_logged) {
throw new ActionException('User', 'signin', array('redirect' => $_SERVER['REQUEST_URI']));
}
try {
$student = $this->model->getInfo($params['username']);
$post_model = new Post_Model();
$this->setTitle(htmlspecialchars($student['firstname'] . ' ' . $student['lastname']));
$this->set(array('student' => $student, 'groups' => isset($student['id']) ? Group_Model::getAuth((int) $student['id']) : array(), 'is_owner' => User_Model::$auth_data['username'] == $student['username'], 'is_logged' => true, 'is_student' => $is_student, 'is_admin' => $is_admin, 'username' => User_Model::$auth_data['username']));
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
// If the student is a user, we show their posts
if (isset($student['id'])) {
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$this->set(array('posts' => $post_model->getPosts(array('restricted' => true, 'user_id' => (int) $student['id'], 'category_name' => $category, 'official' => false, 'show_private' => $is_student), Config::POST_DISPLAYED), 'categories' => $category_model->getAll(), 'current_category' => $category));
}
} catch (Exception $e) {
throw new ActionException('Page', 'error404');
}
}
开发者ID:Godefroy,项目名称:iseplive,代码行数:31,代码来源:Student.php
示例2: view
/**
* Show the profile of a group
*/
public function view($params)
{
$this->setView('view.php');
try {
$group = $this->model->getInfoByName($params['group']);
$this->set('group', $group);
} catch (Exception $e) {
throw new ActionException('Page', 'error404');
}
$this->setTitle(__('GROUP_TITLE', array('group' => htmlspecialchars($group['name']))));
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$post_model = new Post_Model();
$this->set(array('is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin, 'categories' => $category_model->getAll(), 'current_category' => $category, 'posts' => $post_model->getPosts(array('restricted' => true, 'group_id' => (int) $group['id'], 'category_name' => $category, 'official' => $is_logged ? null : true, 'show_private' => $is_student), Config::POST_DISPLAYED)));
// Events
$event_model = new Event_Model();
$this->set(array('events' => $event_model->getByMonth((int) date('Y'), (int) date('n'), array('group_id' => (int) $group['id'], 'official' => $is_logged ? null : true, 'show_private' => $is_student)), 'calendar_month' => (int) date('n'), 'calendar_year' => (int) date('Y')));
// If the user is logged
if ($is_logged) {
$this->set(array('username' => User_Model::$auth_data['username'], 'groups_auth' => Group_Model::getAuth()));
}
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
}
开发者ID:Godefroy,项目名称:iseplive,代码行数:31,代码来源:Group.php
示例3: run_install
/**
* Creates the required database tables for the sharing module
*/
public function run_install()
{
// Create the database tables
// Include the table_prefix
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_site`\n\t\t\t(\n\t\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`site_name` varchar(150) NOT NULL COMMENT 'name that appears on the front end',\n\t\t\t\t`site_url` varchar(255) NOT NULL COMMENT 'url of the deployment to share with',\n\t\t\t\t`site_color` varchar(20) DEFAULT 'CC0000' COMMENT 'color that shows the shared reports',\n\t\t\t\t`site_active` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'sharing active or inactive ',\n\t\t\t\t`share_categories` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'sharing active or inactive ',\n\t\t\t\t`share_reports` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'sharing active or inactive ',\n\t\t\t\t`site_username` varchar(150) NOT NULL COMMENT 'username for the remote site',\n\t\t\t\t`site_password` varchar(150) NOT NULL COMMENT 'password for the remote site',\n\t\t\t\tPRIMARY KEY (id)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stores sites we are getting shared reports from'\n\t\t\t");
$result = $this->db->query("SHOW COLUMNS FROM `sharing_site` LIKE 'site_username';");
if ($result->count() == 0) {
$this->db->query('
ALTER TABLE `sharing_site`
ADD COLUMN `site_username` varchar(150) NOT NULL COMMENT \'username for the remote site\',
ADD COLUMN `site_password` varchar(150) NOT NULL COMMENT \'password for the remote site\'
');
}
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident`\n\t\t\t(\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`location_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t`sharing_site_id` INT UNSIGNED NOT NULL,\n\t\t\t\t`remote_incident_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`updated` datetime DEFAULT NULL,\n\t\t\t\t`incident_title` varchar(255) NOT NULL COMMENT 'title of the report',\n\t\t\t\t`incident_description` longtext,\n\t\t\t\t`incident_date` datetime DEFAULT NULL,\n\t\t\t\t`incident_mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1 - WEB, 2 - SMS, 3 - EMAIL, 4 - TWITTER',\n\t\t\t\t`incident_active` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t\t`incident_verified` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t\tPRIMARY KEY (id),\n\t\t\t\tKEY `location_id` (`location_id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stores shared reports'\n\t\t\t");
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_category` (\n\t\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t `category_id` int(11) unsigned NOT NULL DEFAULT '5',\n\t\t\t PRIMARY KEY (`id`),\n\t\t\t UNIQUE KEY `sharing_incident_category_ids` (`sharing_incident_id`,`category_id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stores shared reports categories'\n\t\t\t");
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_media` (\n\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t `media_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t PRIMARY KEY (`id`),\n\t\t\t UNIQUE KEY `sharing_incident_media_ids` (`sharing_incident_id`,`media_id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stores shared reports media'\n\t\t\t");
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_comment` (\n\t\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t `comment_id` int(11) unsigned NOT NULL DEFAULT '5',\n\t\t\t PRIMARY KEY (`id`),\n\t\t\t UNIQUE KEY `sharing_incident_comment_ids` (`sharing_incident_id`,`comment_id`)\n\t\t\t) ENGINE=MyISAM AUTO_INCREMENT=14064 DEFAULT CHARSET=utf8 COMMENT='Stores shared reports comments'\n\t\t\t");
$this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_category`\n\t\t\t(\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`sharing_site_id` INT UNSIGNED NOT NULL,\n\t\t\t\t`category_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`remote_category_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`updated` datetime DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (id),\n\t\t\t UNIQUE KEY `category_id` (`category_id`),\n\t\t\t UNIQUE KEY `remote_category_id` (`sharing_site_id`,`remote_category_id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stores shared categories'\n\t\t\t");
// Create view for querying
$this->db->query("\n\t\t\tCREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW `sharing_combined_incident` AS\n\t\t\t\tSELECT `incident`.`id` AS `id`,\n\t\t\t\t\t`incident`.`incident_title` AS `incident_title`,\n\t\t\t\t\t`incident`.`incident_description` AS `incident_description`,\n\t\t\t\t\t`incident`.`incident_date` AS `incident_date`,\n\t\t\t\t\t`incident`.`incident_mode` AS `incident_mode`,\n\t\t\t\t\t`incident`.`location_id` AS `location_id`,\n\t\t\t\t\t`incident`.`incident_active` AS `incident_active`,\n\t\t\t\t\t`incident`.`incident_verified` AS `incident_verified`,\n\t\t\t\t\t'main' AS `source`,\n\t\t\t\t\tNULL AS `source_url`\n\t\t\t\tFROM `incident`\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\t`sharing_incident`.`id` AS `id`,\n\t\t\t\t\t`sharing_incident`.`incident_title` AS `incident_title`,\n\t\t\t\t\t`sharing_incident`.`incident_description` AS `incident_description`,\n\t\t\t\t\t`sharing_incident`.`incident_date` AS `incident_date`,\n\t\t\t\t\t`sharing_incident`.`incident_mode` AS `incident_mode`,\n\t\t\t\t\t`sharing_incident`.`location_id` AS `location_id`,\n\t\t\t\t\t`sharing_incident`.`incident_active` AS `incident_active`,\n\t\t\t\t\t`sharing_incident`.`incident_verified` AS `incident_verified`,\n\t\t\t\t\t`sharing_incident`.`sharing_site_id` AS `source`,\n\t\t\t\t\t`sharing_site`.`site_url` AS `source_url`\n\t\t\t\tFROM `sharing_incident`\n\t\t\t\tLEFT JOIN `sharing_site`\n\t\t\t\t\tON (`sharing_incident`.`sharing_site_id` = `sharing_site`.`id`)\n\t\t\t");
$this->db->query("\n\t\t\tCREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW `sharing_combined_incident_category` AS\n\t\t\t\tSELECT `incident_category`.`incident_id` AS `incident_id`,\n\t\t\t\t\tNULL AS `sharing_incident_id`,\n\t\t\t\t\t`incident_category`.`category_id` AS `category_id`\n\t\t\t\tFROM `incident_category`\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\tNULL AS `incident_id`,\n\t\t\t\t\t`sharing_incident_category`.`sharing_incident_id` AS `sharing_incident_id`,\n `sharing_incident_category`.`category_id` AS `category_id`\n\t\t\t\tFROM `sharing_incident_category`\n\t\t\t");
//Dump the sharing scheduler item from bundled SQL dump file
$this->db->query("DELETE FROM `" . Kohana::config('database.default.table_prefix') . "scheduler` where scheduler_name = 'Sharing' ");
// Add sharing in to scheduler table
$this->db->query("INSERT IGNORE INTO `" . Kohana::config('database.default.table_prefix') . "scheduler`\n\t\t\t\t(`scheduler_name`,`scheduler_last`,`scheduler_weekday`,`scheduler_day`,`scheduler_hour`,`scheduler_minute`,`scheduler_controller`,`scheduler_active`) VALUES\n\t\t\t\t('Sharing','0','-1','-1','-1','-1','s_sharing','1')");
// Add Other category to the categories list (if it doesn't exist already)
$categoryname = "Other";
$other_category = ORM::factory('category')->where('category_title', $categoryname)->where('parent_id', 0)->find();
$current_other_category_id = Settings_Model::get_setting('sharing_other_category_id');
if ($other_category->loaded && empty($current_other_category_id)) {
// We already have a category "Other", save setting
Settings_Model::save_setting('sharing_other_category_id', $other_category->id);
} else {
// No category named "Other". Do we have an id save though (maybe it's been renamed)
$category = ORM::factory('Category', Settings_Model::get_setting('sharing_other_category_id'));
if (!$category->loaded) {
$this->notices[] = Kohana::lang('import.new_category') . $categoryname;
$category = new Category_Model();
$category->category_title = $categoryname;
// We'll use grey for now. Maybe something random?
$category->category_color = '000000';
$category->category_visible = 1;
// FIXIT: We need to make this zero for non-central deployments?
$category->category_trusted = 1;
// Trusted - can't delete
$category->category_description = "Category with reports that couldn't be categorised from other deployments";
//FIXIT: need to l10n this;
$category->category_position = ORM::factory('category')->count_all();
$category->save();
Settings_Model::save_setting('sharing_other_category_id', $category->id);
}
}
}
开发者ID:rjmackay,项目名称:Ushahidi-plugin-sharing_two,代码行数:56,代码来源:sharing_two_install.php
示例4: insert
public function insert($category, $username, $value)
{
$cat = new Category_Model();
$category = $cat->get_id($category);
$user = new User_Model();
$username = $user->get_id($username);
$results = $this->db->query("INSERT INTO results SET cat_id = ?, user_id = ?, value = ?, result_date = NOW()", $category, $username, $value);
if ($results) {
return true;
} else {
return false;
}
}
开发者ID:ArtemD,项目名称:SpeedFreak,代码行数:13,代码来源:result.php
示例5: testIsValidCategory
/**
* Test the is_valid_category method in Category_Model using a
* valid category id
*
* @test
* @dataProvider providerIsValidCategory
* @param int $valid_category_id ID of a category exisitng in the database
* @param int $invalid_category_id ID of a non-existent/non-numeric category
*/
public function testIsValidCategory($valid_category_id, $invalid_category_id)
{
// Test existence of valid category
$this->assertEquals(TRUE, Category_Model::is_valid_category($valid_category_id));
// Assert invalidity and non-existence of invalid category
$this->assertEquals(FALSE, Category_Model::is_valid_category($invalid_category_id));
}
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:16,代码来源:Category_Model_Test.php
示例6: 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();
}
开发者ID:nastasio,项目名称:Ushahidi_Web,代码行数:28,代码来源:mobile.php
示例7: getInstance
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new Category_Model();
}
return self::$instance;
}
开发者ID:bekoys,项目名称:blog,代码行数:7,代码来源:category_model.php
示例8: GetPanel
public static function GetPanel()
{
$tpl = new Template();
$items = Category_Model::GetCategories();
$tpl->SetParam('cart', $_SESSION['cart']);
return $tpl->Fetch('templates/cart/cart-panel.tpl');
}
开发者ID:pragmatos,项目名称:phpMVCAngular,代码行数:7,代码来源:view.inc.php
示例9: Category_Model
/**
* 单例模式
* @return Category_Model
*/
public static function &instance()
{
if (!isset(self::$instance)) {
// Create a new instance
self::$instance = new Category_Model();
}
return self::$instance;
}
开发者ID:momoim,项目名称:momo-api,代码行数:12,代码来源:category.php
示例10: document
public function document()
{
$allDepartments = Department_Model::getAllDepartments();
$data = array('pageTitle' => 'Document Builder', 'bodyClass' => 'edit', 'builder' => 'document', 'headerModules' => json_decode($this->builder->getModules('header')), 'bodyModules' => json_decode($this->builder->getModules('body')), 'footerModules' => json_decode($this->builder->getModules('footer')), 'draftModules' => json_decode($this->builder->getDraftModules()), 'unpublishedModules' => json_decode($this->builder->getUnpublishedModules()), 'allCategories' => Category_Model::getAllCategories(), 'allDepartments' => Department_Model::getAllDepartments());
$this->load->view('templates/header', $data);
$this->load->view('builder/inner_navbar_view');
$this->load->view('builder/document_builder_view');
$this->load->view('templates/footer');
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:9,代码来源:Builder.php
示例11: update
public function update($category)
{
$cat = new Category_Model();
if ($cat->category_exists($category) and apiler::is_authorized()) {
$xml = apiler::get_xml();
$result = new Result_Model();
if ($result->insert($category, $_SERVER['PHP_AUTH_USER'], $xml['value'])) {
print "OK";
die;
} else {
header("HTTP/1.1 400 Bad Request");
echo "Invalid request";
die;
}
} else {
header("HTTP/1.0 404 Not Found");
die('Category not found or not authorized');
}
}
开发者ID:ArtemD,项目名称:SpeedFreak,代码行数:19,代码来源:results.php
示例12: deleteCategory
public function deleteCategory()
{
$post = $this->input->post();
if (!$this->userObj->admin) {
$error = array('status' => 'error', 'msg' => 'You cannot delete this department.');
echo json_encode($error);
exit;
}
Category_Model::deleteCategory($post['assignId'], $post['deleteId']);
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:10,代码来源:Category.php
示例13: loadData
public function loadData()
{
$currentUserDept = $this->session->department;
//CHM - Pull in the sub-select values
if (!($tName = $this->cache->get('udfFields'))) {
$query = $this->db->select('table_name')->where('field_type', 4)->get('udf');
$tName = array();
foreach ($query->result() as $data) {
$explodeV = explode('_', $data->table_name);
$tName[] = $explodeV[2];
$i++;
}
$this->cache->save('udfFields', $tName, 600);
}
// We need to set a form value for the current user so that
// they can be pre-selected on the form
$availUsers = User_Model::getAllUsers();
$usersArray = array();
foreach ($availUsers as $availUser) {
if ($availUser->id == $this->session->id) {
$availUser->selected = 'checked';
} else {
$availUser->selected = '';
}
array_push($usersArray, $availUser);
}
// We need to set a form value for the current department so that
// it can be pre-selected on the form
$availDepartments = Department_Model::getAllDepartments();
$departmentsArray = array();
foreach ($availDepartments as $availDepartment) {
if ($availDepartment->id == $currentUserDept) {
$availDepartment->selected = 'checked';
} else {
$availDepartment->selected = '';
}
array_push($departmentsArray, $availDepartment);
}
$availCategories = Category_Model::getAllCategories();
$catsArray = array();
foreach ($availCategories as $availCategory) {
array_push($catsArray, $availCategory);
}
//////Populate department perm list/////////////////
$deptPermsArray = array();
foreach ($departmentsArray as $dept) {
$availDeptPerms = new stdClass();
$availDeptPerms->name = $dept->name;
$availDeptPerms->id = $dept->id;
array_push($deptPermsArray, $availDeptPerms);
}
$data = array('tName' => $tName, 'availUsers' => $usersArray, 'allDepartments' => $availDepartments, 'deptPerms' => $departmentsArray, 'availCategories' => $catsArray);
return json_encode($data);
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:54,代码来源:Add_model.php
示例14: index
public function index($params)
{
$this->setView('index.php');
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$this->set(array('is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin, 'categories' => $category_model->getAll(), 'current_category' => $category));
// If the user is logged
if ($is_logged) {
$this->set(array('username' => User_Model::$auth_data['username'], 'groups_auth' => Group_Model::getAuth(), 'posts' => $this->model->getPosts(array('restricted' => true, 'official' => false, 'category_name' => $category, 'show_private' => $is_student), Config::POST_DISPLAYED)));
}
// If the user is a student
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
// Official posts
$this->set('official_posts', $this->model->getPosts(array('restricted' => true, 'official' => true, 'category_name' => $category, 'show_private' => $is_student), Config::POST_DISPLAYED));
// Events
$event_model = new Event_Model();
$this->set(array('events' => $event_model->getByMonth((int) date('Y'), (int) date('n'), array('official' => $is_logged ? null : true, 'show_private' => $is_student)), 'calendar_month' => (int) date('n'), 'calendar_year' => (int) date('Y')));
}
开发者ID:Godefroy,项目名称:iseplive,代码行数:23,代码来源:Post.php
示例15: page
public function page($page_no = 1)
{
$items_per_page = 2;
$cat_id = 2;
$offset = ($page_no - 1) * $items_per_page;
$limit = $items_per_page;
$category = new Category_Model($cat_id);
//$category = ORM::factory('category')->with('catagories_description')->find($cat_id); //without the lazy loading
echo $category->name . '<br>';
echo $category->catagories_description->description . '<br>';
$catalog_list = $category->limit($limit, $offset)->products;
//$catalog_list = $category->limit($limit, $offset)->like('products.name', 'ca')->products;
//$catalog_list = $category->limit($limit, $offset)->where('product_id >', 1)->products;
$catalog_total = $category->count_last_query();
echo 'this category has ' . $catalog_total . ' related products';
foreach ($catalog_list as $p) {
echo $p->name . '<br>';
echo $p->products_description->description . '<br>';
print_r($p->attributes);
}
$pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => $catalog_total, 'items_per_page' => $items_per_page, 'style' => 'classic', 'auto_hide' => TRUE));
echo $pagination->render();
$profile = new Profiler();
}
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:24,代码来源:catalog.php
示例16: categories
public function categories($id = null)
{
if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
return Category_Model::DeleteCategory($id);
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$data = json_decode(file_get_contents("php://input"), true);
return Category_Model::CreateCategory($data);
}
if ($_SERVER['REQUEST_METHOD'] == "PUT") {
$data = json_decode(file_get_contents("php://input"), true);
return Category_Model::UpdateCategory($data, $id);
}
if (isset($id)) {
return Category_Model::GetCategoryById($id);
}
return Category_Model::GetCategories();
}
开发者ID:pragmatos,项目名称:phpMVCAngular,代码行数:18,代码来源:api.php
示例17: geojson
/**
* Generate geojson
*
* @param string $type type of geojson to generate. Valid options are: 'clusters' and 'markers'
**/
protected function geojson($type)
{
$color = Kohana::config('settings.default_map_all');
$icon = "";
$markers = FALSE;
if (Kohana::config('settings.default_map_all_icon_id')) {
$icon_object = ORM::factory('media')->find(Kohana::config('settings.default_map_all_icon_id'));
$icon = url::convert_uploaded_to_abs($icon_object->media_medium);
}
// Category ID
$category_id = (isset($_GET['c']) and intval($_GET['c']) > 0) ? intval($_GET['c']) : 0;
// Get the category colour
if (Category_Model::is_valid_category($category_id)) {
// Get the color & icon
$cat = ORM::factory('category', $category_id);
$color = $cat->category_color;
$icon = "";
if ($cat->category_image) {
$icon = url::convert_uploaded_to_abs($cat->category_image);
}
}
$params = array('color' => $color, 'icon' => $icon);
Event::run('ushahidi_filter.json_alter_params', $params);
$color = $params['color'];
$icon = $params['icon'];
// Run event ushahidi_filter.json_replace_markers
// This allows a plugin to completely replace $markers
// If markers are added at this point we don't bother fetching incidents at all
Event::run('ushahidi_filter.json_replace_markers', $markers);
// Fetch the incidents
if (!$markers) {
$markers = (isset($_GET['page']) and intval($_GET['page']) > 0) ? reports::fetch_incidents(TRUE) : reports::fetch_incidents();
}
// Run event ushahidi_filter.json_alter_markers
// This allows a plugin to alter $markers
// Plugins can add or remove markers as needed
Event::run('ushahidi_filter.json_alter_markers', $markers);
// Get geojson features array
$function = "{$type}_geojson";
$json_features = $this->{$function}($markers, $category_id, $color, $icon);
$this->render_geojson($json_features);
}
开发者ID:niiyatii,项目名称:crowdmap,代码行数:47,代码来源:json.php
示例18: reports
function reports()
{
$this->template->content = new View('admin/stats_reports');
$this->template->content->title = 'Report Stats';
// Retrieve Current Settings
$settings = ORM::factory('settings', 1);
$this->template->content->stat_id = $settings->stat_id;
// Javascript Header
$this->template->protochart_enabled = TRUE;
// Report Data
$data = Stats_Model::get_report_stats();
$reports_chart = new protochart();
$options = array('pies' => array('show' => 'true'), 'legend' => array('show' => 'true'));
// Grab category data
$cats = Category_Model::categories();
$report_data = array();
foreach ($data['category_counts'] as $category_id => $count) {
$category_name = $cats[$category_id]['category_title'];
$report_data[$category_name] = $count;
$colors[$category_name] = $cats[$category_id]['category_color'];
}
$this->template->content->reports_chart = $reports_chart->chart('reports', $report_data, $options, $colors);
$report_status_chart = new protochart();
foreach ($data['verified_counts'] as $ver_or_un => $arr) {
if (!isset($report_staus_data[$ver_or_un][0])) {
$report_staus_data[$ver_or_un][0] = 0;
}
foreach ($arr as $count) {
$report_staus_data[$ver_or_un][0] += $count;
}
}
foreach ($data['approved_counts'] as $app_or_un => $arr) {
if (!isset($report_staus_data[$app_or_un][0])) {
$report_staus_data[$app_or_un][0] = 0;
}
foreach ($arr as $count) {
$report_staus_data[$app_or_un][0] += $count;
}
}
$this->template->content->report_status_chart = $report_status_chart->chart('report_status', $report_staus_data, $options);
}
开发者ID:newrooky,项目名称:Ushahidi_Web,代码行数:41,代码来源:stats.php
示例19: login
<?php
require 'admin_init.php';
login();
//删除单个文章
if (isset($_GET['post_id'])) {
$post_id = $_GET['post_id'];
Post_Model::getInstance()->deleteLog($post_id);
} elseif (isset($_GET['post_ids'])) {
$ids = explode(',', $_GET['post_ids']);
foreach ($ids as $id) {
Post_Model::getInstance()->deleteLog($id);
}
} elseif (isset($_GET['term_id'])) {
Category_Model::getInstance()->deleteTerm($_GET['term_id']);
} elseif (isset($_GET['term_ids'])) {
$ids = explode(',', $_GET['term_ids']);
foreach ($ids as $id) {
Category_Model::getInstance()->deleteTerm($id);
}
}
开发者ID:bekoys,项目名称:blog,代码行数:21,代码来源:admin_delete.php
示例20: index
/**
* Displays all reports.
*/
public function index()
{
$this->template->header->this_page = 'reports';
$this->template->content = new View('reports');
// Filter By Category
$category_filter = isset($_GET['c']) && !empty($_GET['c']) ? "category_id = " . $_GET['c'] : " 1=1 ";
// Pagination
$pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => ORM::factory('incident')->join('incident_category', 'incident.id', 'incident_category.incident_id')->where('incident_active', '1')->where($category_filter)->count_all()));
$incidents = ORM::factory('incident')->select('DISTINCT incident.*')->join('incident_category', 'incident.id', 'incident_category.incident_id')->where('incident_active', '1')->where($category_filter)->groupby('incident.id')->orderby('incident_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page'), $pagination->sql_offset);
$this->template->content->incidents = $incidents;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = '';
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1) {
$plural = '';
} else {
$plural = 's';
}
if ($pagination->total_items > 0) {
$current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
$total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1) {
// If we want to show pagination
$this->template->content->pagination_stats = '(Showing ' . $current_page . ' of ' . $total_pages . ' pages of ' . $pagination->total_items . ' report' . $plural . ')';
$this->template->content->pagination = $pagination;
} else {
// If we don't want to show pagination
$this->template->content->pagination_stats = '(' . $pagination->total_items . ' report' . $plural . ')';
}
} else {
$this->template->content->pagination_stats = '(' . $pagination->total_items . ' report' . $plural . ')';
}
$icon_html = array();
$icon_html[1] = "<img src=\"" . url::base() . "media/img/image.png\">";
//image
$icon_html[2] = "<img src=\"" . url::base() . "media/img/video.png\">";
//video
$icon_html[3] = "";
//audio
$icon_html[4] = "";
//news
$icon_html[5] = "";
//podcast
//Populate media icon array
$this->template->content->media_icons = array();
foreach ($incidents as $incident) {
$incident_id = $incident->id;
if (ORM::factory('media')->where('incident_id', $incident_id)->count_all() > 0) {
$medias = ORM::factory('media')->where('incident_id', $incident_id)->find_all();
//Modifying a tmp var prevents Kohona from throwing an error
$tmp = $this->template->content->media_icons;
$tmp[$incident_id] = '';
foreach ($medias as $media) {
$tmp[$incident_id] .= $icon_html[$media->media_type];
$this->template->content->media_icons = $tmp;
}
}
}
// Category Title, if Category ID available
$category_id = isset($_GET['c']) && !empty($_GET['c']) ? $_GET['c'] : "0";
$category = ORM::factory('category')->find($category_id);
$this->template->content->category_title = $category->loaded ? $category->category_title : "";
// BEGIN CHART CREATION
// Note: The reason this code block is so long is because protochart
// doesn't seem to handle bar charts in time mode so well. The
// bars show up as skinny lines because it uses the timestamp
// to determine location on the graph, which doesn't give the
// bar much wiggle room in just a few hundred pixels.
// Create protochart
$this->template->header->protochart_enabled = TRUE;
$report_chart = new protochart();
// FIXME: Perhaps instead of grabbing the report stats again, we can
// get what we need from above so we can cut down on database
// calls. It will take playing with the incident model to get
// all of the data we need, though.
// Report Data
$data = Stats_Model::get_report_stats(true);
// Grab category data
$cats = Category_Model::categories();
$highest_count = 1;
$report_data = array();
$tick_string_array = array();
foreach ($data['category_counts'] as $category_id => $count_array) {
// Does this category exist locally any more?
if (isset($cats[$category_id])) {
$category_name = $cats[$category_id]['category_title'];
$colors[$category_name] = $cats[$category_id]['category_color'];
$i = 1;
foreach ($count_array as $time => $count) {
$report_data[$category_name][$i] = $count;
// The highest count will determine the number of ticks on the y-axis
if ($count > $highest_count) {
$highest_count = $count;
}
// This statement sets us up so we can convert the key to a date
if (!isset($tick_represents[$i])) {
$tick_represents[$i] = $time;
//.........这里部分代码省略.........
开发者ID:kiirti,项目名称:Ushahidi_MHI,代码行数:101,代码来源:reports.php
注:本文中的Category_Model类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论