本文整理汇总了PHP中Model_Category::get_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category::get_all方法的具体用法?PHP Model_Category::get_all怎么用?PHP Model_Category::get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Category
的用法示例。
在下文中一共展示了Model_Category::get_all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_moderate
/**
* Action MODERATION
*/
public function action_moderate()
{
//template header
$this->template->title = __('Moderation');
$this->template->meta_description = __('Moderation');
$this->template->scripts['footer'][] = '/js/oc-panel/moderation.js';
//find all tables
$ads = new Model_Ad();
$res_count = $ads->where('status', '=', Model_Ad::STATUS_NOPUBLISHED)->count_all();
if ($res_count > 0) {
$pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
$ads = $ads->where('ad.status', '=', Model_Ad::STATUS_NOPUBLISHED)->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
//find all tables
$hits = new Model_Visit();
$hits->find_all();
$list_cat = Model_Category::get_all();
$list_loc = Model_Location::get_all();
$arr_hits = array();
// array of hit integers
// fill array with hit integers
foreach ($ads as $key_ads) {
// match hits with ad
$h = $hits->where('id_ad', '=', $key_ads->id_ad);
$count = count($h->find_all());
// count individual hits
array_push($arr_hits, $count);
}
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => $ads, 'pagination' => $pagination, 'category' => $list_cat, 'location' => $list_loc, 'hits' => $arr_hits));
// create view, and insert list with data
} else {
Alert::set(Alert::INFO, __('You do not have any advertisements waiting to be published'));
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => NULL));
}
}
示例2: action_update
public function action_update()
{
$name = $this->request->param('id');
$field = new Model_Field();
$field_data = $field->get($name);
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $name));
$this->template->title = __('Edit Custom Field for Advertisement');
//find all, for populating form select fields
list($categories) = Model_Category::get_all();
if ($_POST) {
try {
$options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE);
if ($field->update($name, Core::post('values'), Core::post('categories'), $options)) {
Cache::instance()->delete_all();
Theme::delete_minified();
Alert::set(Alert::SUCCESS, __('Field edited ' . $name));
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
} else {
Alert::set(Alert::ERROR, __('Field cant be edited' . $name));
}
} catch (Exception $e) {
throw new HTTP_Exception_500();
}
}
$this->template->content = View::factory('oc-panel/pages/fields/update', array('field_data' => $field_data, 'name' => $name, 'categories' => $categories));
}
示例3: action_index
/**
* overwrites the default crud index
* @param string $view nothing since we don't use it
* @return void
*/
public function action_index($view = NULL)
{
//Request::current()->redirect(Route::url('oc-panel',array('controller' => 'category','action'=>'dashboard')));
//template header
$this->template->title = __('Categories');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Categories')));
$this->template->styles = array('css/sortable.css' => 'screen');
$this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
$this->template->scripts['footer'][] = 'js/oc-panel/categories.js';
list($cats, $order) = Model_Category::get_all();
$this->template->content = View::factory('oc-panel/pages/categories', array('cats' => $cats, 'order' => $order));
}
示例4: action_index
/**
*
* NEW ADVERTISEMENT
*
*/
public function action_index()
{
if (isset($_SESSION['_wb_app_x'])) {
} else {
//template header
$this->template->title = __('Publish new advertisement');
$this->template->meta_description = __('Publish new advertisement');
$this->template->scripts['footer'] = array('js/new.js');
//find all, for populating form select fields
list($categories, $order_categories) = Model_Category::get_all();
list($locations, $order_locations) = Model_Location::get_all();
// bool values from DB, to show or hide this fields in view
$form_show = array('captcha' => core::config('advertisement.captcha'), 'website' => core::config('advertisement.website'), 'phone' => core::config('advertisement.phone'), 'location' => core::config('advertisement.location'), 'address' => core::config('advertisement.address'), 'price' => core::config('advertisement.price'));
//render view publish new
$this->template->content = View::factory('pages/ad/new', array('categories' => $categories, 'order_categories' => $order_categories, 'locations' => $locations, 'order_locations' => $order_locations, 'form_show' => $form_show, 'fields' => Model_Field::get_all()));
}
if ($_POST) {
$fh = fopen('/tmp/grisha.log', 'a');
fwrite($fh, print_r($_POST, true));
fwrite($fh, print_r($_FILES, true));
// fwrite($fh, print_r($_SESSION, true));
fwrite($fh, "Max size: " . core::config('image.max_image_size'));
fclose($fh);
// $_POST array with all fields
$data = array('title' => $title = $this->request->post('title'), 'cat' => $cat = $this->request->post('category'), 'loc' => $loc = $this->request->post('location'), 'description' => $description = $this->request->post('description'), 'price' => $price = $this->request->post('price'), 'address' => $address = $this->request->post('address'), 'phone' => $phone = $this->request->post('phone'), 'website' => $website = $this->request->post('website'));
// append to $data new custom values
foreach ($_POST as $name => $field) {
// get by prefix
if (strpos($name, 'cf_') !== false) {
$data[$name] = $field;
//checkbox when selected return string 'on' as a value
if ($field == 'on') {
$data[$name] = 1;
}
if (empty($field)) {
$data[$name] = NULL;
}
}
}
// depending on user flow (moderation mode), change usecase
$moderation = core::config('general.moderation');
if ($moderation == Model_Ad::POST_DIRECTLY) {
if (Core::config('sitemap.on_post') == TRUE) {
Sitemap::generate();
}
$status = Model_Ad::STATUS_PUBLISHED;
$this->save_new_ad($data, $status, $published = TRUE, $moderation, $form_show['captcha']);
} elseif ($moderation == Model_Ad::MODERATION_ON || $moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::EMAIL_CONFIRMATION || $moderation == Model_Ad::EMAIL_MODERATION || $moderation == Model_Ad::PAYMENT_MODERATION) {
$status = Model_Ad::STATUS_NOPUBLISHED;
$this->save_new_ad($data, $status, $published = FALSE, $moderation, $form_show['captcha']);
}
}
}
示例5: action_index
public function action_index()
{
$articles = array();
// подключаем БД
$article = new Model_Category();
//считываем оттуда массив данных
$articles = $article->get_all();
// подключаем шаблон и отправляем туда переменные
$content = View::factory('/pages/template')->bind('articles', $articles);
$this->template->content = $content;
$this->template->title = 'Профи-суши';
$this->template->styles = array('bootstrap.min', 'backet', 'main', 'main-page');
}
示例6: action_index
/**
* overwrites the default crud index
* @param string $view nothing since we don't use it
* @return void
*/
public function action_index($view = NULL)
{
//template header
$this->template->title = __('Menu');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Menu')));
$this->template->styles = array('css/sortable.css' => 'screen');
$this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
$this->template->scripts['footer'][] = 'js/oc-panel/menu.js';
//find all, for populating form select fields
list($categories, $order_categories) = Model_Category::get_all();
// d($categories);
$this->template->content = View::factory('oc-panel/pages/menu', array('menu' => Menu::get(), 'categories' => $categories, 'order_categories' => $order_categories));
}
示例7: before
public function before()
{
$articles = array();
// подключаем БД
$article = new Model_Category();
//считываем оттуда массив данных
$articles = $article->get_all();
parent::before();
View::set_global('title', 'Мой сайт');
View::set_global('description', 'Самый лучший сайт');
$this->template->content = '';
$this->template->title = 'Профи-суши';
$this->template->styles = array('bootstrap.min', 'backet', 'main', 'product-list');
$this->template->styles = array('bootstrap.min', 'main');
$this->template->scripts = array('jquery-1.11.3.min', 'bootstrap.min', 'script001');
$this->template->menu = $articles;
}
示例8: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
// get all categories
if ($this->categories != FALSE) {
// loaded category
list($categories, $order_categories) = Model_Category::get_all();
$arr_cat = array();
foreach ($categories as $cat => $value) {
if ($value['id'] != 1) {
$arr_cat[$value['id']] = $value['name'];
}
}
$this->cat_items = $categories;
$this->cat_order_items = $order_categories;
}
// get all locations
if ($this->locations != FALSE) {
list($locations, $order_locations) = Model_Location::get_all();
$this->loc_items = $locations;
$this->loc_order_items = $order_locations;
}
if ($this->price != FALSE) {
$this->price = TRUE;
}
// user
if (Auth::instance()->logged_in()) {
//subscriber
// check if user is already subscribed
$user_id = Auth::instance()->get_user()->id_user;
$obj_subscriber = new Model_Subscribe();
$subscriber = $obj_subscriber->where('id_user', '=', $user_id)->limit(1)->find();
if ($subscriber->loaded()) {
$this->subscriber = TRUE;
}
//if user logged in pass email and id
$this->user_email = Auth::instance()->get_user()->email;
$this->user_id = $user_id;
} else {
$this->user_id = 0;
}
//min - max price selected
$this->min_price = $this->min_price;
$this->max_price = $this->max_price;
}
示例9: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
// get all categories
if ($this->advanced != FALSE) {
// loaded category
list($categories, $order_categories) = Model_Category::get_all();
$arr_cat = array();
foreach ($categories as $cat => $value) {
if ($value['id'] != 1) {
$arr_cat[$value['id']] = $value['name'];
}
}
$this->cat_items = $categories;
$this->cat_order_items = $order_categories;
// get all locations
list($locations, $order_locations) = Model_Location::get_all();
$this->loc_items = $locations;
$this->loc_order_items = $order_locations;
}
if ($this->custom != FALSE) {
$fields = Model_Field::get_all();
$this->custom_fields = $fields;
}
}
示例10: action_index
public function action_index()
{
$email = $this->request->post('email_subscribe');
if (Valid::email($email, TRUE)) {
/* find user and compare emails */
$obj_user = new Model_User();
$user = $obj_user->where('email', '=', $email)->limit(1)->find();
// case when user is not logged in.
// We create new user if he doesn't exists in DB
// and send him mail for ad created + new profile created
if (!$user->loaded()) {
$name = substr($email, '0', stripos($email, '@'));
$new_password_hash = Auth::instance()->hash_password('password');
$user->email = $email;
$user->name = $name;
$user->status = Model_User::STATUS_ACTIVE;
$user->id_role = Model_Role::ROLE_USER;
$user->password = $new_password_hash;
$user->seoname = $name;
try {
$user->save();
Alert::set(Alert::SUCCESS, __('New profile has been created. Welcome ') . $name . ' !');
//we get the QL, and force the regen of token for security
$url_pwch = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'edit'), TRUE);
$ret = $user->email('user.new', array('[URL.PWCH]' => $url_pwch, '[USER.PWD]' => $new_password_hash));
} catch (ORM_Validation_Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
}
/* save this user to data base as subscriber */
$arr_cat = $this->request->post('category_subscribe');
// string in this case is returned as "int,int" so we need to format min/max price
$price = $this->request->post('price_subscribe');
if ($price = $this->request->post('price_subscribe')) {
$min_price = substr($price, '0', stripos($price, ','));
$max_price = substr($price, strrpos($price, ',') + 1);
} else {
//in case of mobile version
// jquery mobile have different slider, so we need to get data differently
$min_price = $this->request->post('price_subscribe-1');
$max_price = $this->request->post('price_subscribe-2');
}
//if categry is not selected, subscribe them for all
$obj_category = new Model_Category();
if ($arr_cat === NULL) {
$all_cats = $obj_category->get_all();
$arr_cat = array();
foreach ($all_cats as $ac) {
foreach ($ac as $key => $v) {
$arr_cat[] = $key;
}
}
}
// create entry table subscriber for each category selected
foreach ($arr_cat as $c => $id_value) {
$obj_subscribe = new Model_Subscribe();
$obj_subscribe->id_user = $user->id_user;
$obj_subscribe->id_category = $id_value;
$obj_subscribe->id_location = $this->request->post('location_subscribe');
$obj_subscribe->min_price = $min_price;
$obj_subscribe->max_price = $max_price;
try {
$obj_subscribe->save();
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
}
Alert::set(Alert::SUCCESS, __('Thank you for subscribing'));
$this->request->redirect(Route::url('default'));
} else {
Alert::set(Alert::ALERT, __('Invalid Email'));
$this->request->redirect(Route::url('default'));
}
}
示例11: action_advanced_search
public function action_advanced_search()
{
//template header
$this->template->title = __('Advanced Search');
$this->template->meta_description = __('Advanced Search');
//breadcrumbs
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
$this->template->scripts['footer'] = array('js/search.js');
// $cat_obj = new Model_Category();
// $loc_obj = new Model_Location();
list($cat_obj, $order_categories) = Model_Category::get_all();
list($loc_obj, $order_locations) = Model_Location::get_all();
$pagination = NULL;
$ads = NULL;
$user = Auth::instance()->get_user() == NULL ? NULL : Auth::instance()->get_user();
if ($this->request->query()) {
// variables
$search_advert = core::get('title');
$search_loc = core::get('location');
// filter by each variable
$ads = new Model_Ad();
//if ad have passed expiration time dont show
if (core::config('advertisement.expire_date') > 0) {
$ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()'));
}
if (!empty($search_advert) or core::get('search') !== NULL and strlen(core::get('search')) >= 3) {
// if user is using search from header
if (core::get('search')) {
$search_advert = core::get('search');
}
$ads->where_open()->where('title', 'like', '%' . $search_advert . '%')->or_where('description', 'like', '%' . $search_advert . '%')->where_close();
}
$cf_fields = array();
foreach ($this->request->query() as $name => $field) {
// get by prefix
if (strpos($name, 'cf_') !== false) {
$cf_fields[$name] = $field;
//checkbox when selected return string 'on' as a value
if ($field == 'on') {
$cf_fields[$name] = 1;
} elseif (empty($field)) {
$cf_fields[$name] = NULL;
}
}
}
$category = NULL;
//filter by category
if (core::get('category') !== NULL) {
$category = new Model_Category();
$category->where('seoname', '=', core::get('category'))->limit(1)->find();
if ($category->loaded()) {
$ads->where('id_category', 'IN', $category->get_siblings_ids());
}
}
$location = NULL;
//filter by location
if (core::get('location') !== NULL) {
$location = new Model_location();
$location->where('seoname', '=', core::get('location'))->limit(1)->find();
if ($location->loaded()) {
$ads->where('id_location', 'IN', $location->get_siblings_ids());
}
}
//filter by price
if (is_numeric(core::get('price-min')) and is_numeric(core::get('price-max'))) {
$ads->where('price', 'BETWEEN', array(core::get('price-min'), core::get('price-max')));
}
foreach ($cf_fields as $key => $value) {
if (isset($value) and $value != NULL) {
if (is_numeric($value)) {
$ads->where($key, '=', $value);
} elseif (is_string($value)) {
$ads->where($key, 'like', '%' . $value . '%');
}
}
}
$ads = $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
// count them for pagination
$res_count = $ads->count_all();
if ($res_count > 0) {
// pagination module
$pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'category' => $category !== NULL ? $category->seoname : NULL));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->offset));
$ads = $ads->order_by('published', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
}
}
$this->template->bind('content', $content);
$this->template->content = View::factory('pages/ad/advanced_search', array('ads' => $ads, 'categories' => $cat_obj, 'order_categories' => $order_categories, 'locations' => $loc_obj, 'order_locations' => $order_locations, 'pagination' => $pagination, 'user' => $user, 'fields' => Model_Field::get_all()));
}
示例12: action_update
/**
* Edit advertisement: Update
*
* All post fields are validated
*/
public function action_update()
{
//template header
$this->template->title = __('Edit advertisement');
$this->template->meta_description = __('Edit advertisement');
//local files
if (Theme::get('cdn_files') == FALSE) {
$this->template->styles = array('css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('js/bootstrap-datepicker.js', 'js/jquery.validate.min.js', 'js/oc-panel/edit_ad.js');
} else {
$this->template->styles = array('http://cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('http://cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/jquery.validate.min.js', 'js/oc-panel/edit_ad.js');
}
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
$form = new Model_Ad($this->request->param('id'));
//find all, for populating form select fields
list($categories, $order_categories) = Model_Category::get_all();
list($locations, $order_locations) = Model_Location::get_all();
if (Auth::instance()->logged_in() && Auth::instance()->get_user()->id_user == $form->id_user || Auth::instance()->logged_in() && Auth::instance()->get_user()->id_role == 10) {
$extra_payment = core::config('payment');
Breadcrumbs::add(Breadcrumb::factory()->set_title("Update"));
$this->template->content = View::factory('oc-panel/profile/edit_ad', array('ad' => $form, 'locations' => $locations, 'order_locations' => $order_locations, 'categories' => $categories, 'order_categories' => $order_categories, 'extra_payment' => $extra_payment, 'fields' => Model_Field::get_all()));
if ($this->request->post()) {
$cat = new Model_Category();
$loc = new Model_Location();
// deleting single image by path
$deleted_image = core::post('img_delete');
if ($deleted_image) {
$img_path = $form->gen_img_path($form->id_ad, $form->created);
if (!is_dir($img_path)) {
return FALSE;
} else {
//delete formated image
unlink($img_path . $deleted_image . '.jpg');
//delete original image
$orig_img = str_replace('thumb_', '', $deleted_image);
unlink($img_path . $orig_img . ".jpg");
$this->request->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $form->id_ad)));
}
}
// end of img delete
$data = array('_auth' => $auth = Auth::instance(), 'title' => $title = Model_Ad::banned_words(core::post('title')), 'seotitle' => $seotitle = core::post('title'), 'loc' => $loc = core::post('location'), 'description' => $description = Model_Ad::banned_words(core::post('description')), 'price' => $price = floatval(str_replace(',', '.', core::post('price'))), 'address' => $address = core::post('address'), 'website' => $website = core::post('website'), 'phone' => $phone = core::post('phone'), 'has_images' => 0, 'user' => $user = new Model_User());
// append to $data new custom values
foreach ($_POST as $name => $field) {
// get by prefix
if (strpos($name, 'cf_') !== false) {
$data[$name] = $field;
//checkbox when selected return string 'on' as a value
if ($field == 'on') {
$data[$name] = 1;
}
}
}
//insert data
if (core::post('title') != $form->title) {
if ($form->has_images == 1) {
$current_path = $form->gen_img_path($form->id_ad, $form->created);
// rename current image path to match new seoname
rename($current_path, $form->gen_img_path($form->id_ad, $form->created));
}
$seotitle = $form->gen_seo_title($data['title']);
$form->seotitle = $seotitle;
} else {
$form->seotitle = $form->seotitle;
}
$form->title = $data['title'];
$form->id_location = $data['loc'];
//$form->id_category = $data['cat'];
$form->description = $data['description'];
// $form->status = $data['status'];
$form->price = $data['price'];
$form->address = $data['address'];
$form->website = $data['website'];
$form->phone = $data['phone'];
// set custom values
foreach ($data as $key => $value) {
// get only custom values with prefix
if (strpos($key, 'cf_') !== false) {
$form->{$key} = $value;
}
}
// d($data['cf_radio']);
$obj_ad = new Model_Ad();
// IMAGE UPLOAD
// in case something wrong happens user is redirected to edit advert.
$filename = NULL;
$counter = 0;
for ($i = 0; $i < core::config("advertisement.num_images"); $i++) {
$counter++;
if (isset($_FILES['image' . $i])) {
$img_files = $_FILES['image' . $i];
$filename = $obj_ad->save_image($img_files, $form->id_ad, $form->created, $form->seotitle, $counter);
}
if ($filename) {
$form->has_images = 1;
//.........这里部分代码省略.........