public function listContact()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $start = Input::has('start') ? (int) Input::get('start') : 0;
     $length = Input::has('length') ? Input::get('length') : 10;
     $search = Input::has('search') ? Input::get('search') : [];
     $contacts = Contact::select('id', 'contact_name', 'contact_phone', 'contact_email', 'contact_message', 'read', 'created_at')->orderBy('read')->orderBy('created_at');
     if (!empty($search)) {
         foreach ($search as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             if ($key == 'read') {
                 if ($value == 'yes') {
                     $value = 1;
                 } else {
                     $value = 0;
                 }
                 $contacts->where($key, $value);
             } else {
                 $value = ltrim(rtrim($value));
                 $contacts->where($key, 'like', '%' . $value . '%');
             }
         }
     }
     $order = Input::has('order') ? Input::get('order') : [];
     if (!empty($order)) {
         $columns = Input::has('columns') ? Input::get('columns') : [];
         foreach ($order as $value) {
             $column = $value['column'];
             if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
                 continue;
             }
             $contacts->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
         }
     }
     $count = $contacts->count();
     if ($length > 0) {
         $contacts = $contacts->skip($start)->take($length);
     }
     $arrcontacts = $contacts->get()->toArray();
     $arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Page::count(), 'recordsFiltered' => $count, 'data' => []];
     if (!empty($arrcontacts)) {
         foreach ($arrcontacts as $contact) {
             $image = '';
             if (!empty($contact['images'])) {
                 $image = reset($contact['images']);
                 $image = $image['path'];
             }
             $arrReturn['data'][] = array(++$start, $contact['id'], $contact['contact_name'], $contact['contact_phone'], $contact['contact_email'], htmlentities($contact['contact_message']), $contact['read'], $contact['created_at'], htmlentities(nl2br($contact['contact_message'])));
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $counts = array();
     $counts['article_total'] = \Article::count();
     $counts['category_total'] = \Category::count();
     $counts['user_total'] = \User::count();
     $counts['page_total'] = \Page::count();
     return View::make('admin.index.index')->with('counts', $counts);
 }
 public function get_pages($action = null, $id = null)
 {
     if (!is_null($action)) {
         $fn = 'get_' . $action;
         return $this->{$fn}($id);
     }
     $pages = Page::latest()->paginate(10);
     $pages_count = Page::count();
     $title = 'Administrayon Paj (' . $pages_count . ')';
     return View::make('admin.pages.index')->withTitle($title)->withPages($pages)->withPagesCount($pages_count);
 }
Example #4
0
 public function run()
 {
     $model = new Page();
     //条件
     $criteria = new CDbCriteria();
     $title = Yii::app()->request->getParam('title');
     $titleAlias = Yii::app()->request->getParam('titleAlias');
     $title && $criteria->addSearchCondition('title', $title);
     $titleAlias && $criteria->addSearchCondition('title_alias', $titleAlias);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
Example #5
0
 public function actionIndex()
 {
     $model = new Page();
     $criteria = new CDbCriteria();
     $condition = '1';
     $title = $this->_request->getParam('title');
     $titleAlias = $this->_request->getParam('titleAlias');
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $titleAlias && ($condition .= ' AND title_alias LIKE \'%' . $titleAlias . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('page_name_alias', 'page_name'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
<?php

Route::collection(array('before' => 'auth,csrf'), function () {
    /*
    	List Pages
    */
    Route::get(array('admin/pages', 'admin/pages/(:num)'), function ($page = 1) {
        $perpage = Config::meta('posts_per_page');
        $total = Page::count();
        $pages = Page::sort('title')->take($perpage)->skip(($page - 1) * $perpage)->get();
        $url = Uri::to('admin/pages');
        $pagination = new Paginator($pages, $total, $page, $perpage, $url);
        $vars['messages'] = Notify::read();
        $vars['pages'] = $pagination;
        $vars['status'] = 'all';
        return View::create('pages/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
    });
    /*
    	List pages by status and paginate through them
    */
    Route::get(array('admin/pages/status/(:any)', 'admin/pages/status/(:any)/(:num)'), function ($status, $page = 1) {
        $query = Page::where('status', '=', $status);
        $perpage = Config::meta('posts_per_page');
        $total = $query->count();
        $pages = $query->sort('title')->take($perpage)->skip(($page - 1) * $perpage)->get();
        $url = Uri::to('admin/pages/status');
        $pagination = new Paginator($pages, $total, $page, $perpage, $url);
        $vars['messages'] = Notify::read();
        $vars['pages'] = $pagination;
        $vars['status'] = $status;
        return View::create('pages/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
Example #7
0
<?php

include '../../inc/init.inc';
isset($conditions) ? $args['conditions'] = $conditions : '';
$res->total = isset($args) ? Page::count($args) : Page::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->pages = Page::all($args);
$res->search_opts = array(0 => array('label' => 'Quel article cherchez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Wiki");
Example #8
0
 /**
  * Предзагрузка всех страниц и кеширование
  */
 public static function preload()
 {
     $cache_key = self::$cache_key;
     $cache_pages_limit = Config::get('pages.preload_pages_limit');
     if ($cache_pages_limit === NULL) {
         Config::set('pages.not_cached', TRUE);
         return;
     }
     if (Cache::has($cache_key) && !Input::get('drop_pages_cache')) {
         ## From cache
         $pages = Cache::get($cache_key);
     } elseif ($cache_pages_limit === 0 || $cache_pages_limit > 0 && Page::count() <= $cache_pages_limit) {
         #echo "LOAD PAGES FROM DB!";
         ## From DB
         $pages = (new Page())->where('publication', 1)->where('version_of', NULL)->with(['metas', 'blocks.metas', 'seos', 'blocks.meta', 'meta', 'seo'])->get();
         if (isset($pages) && is_object($pages) && count($pages)) {
             $pages_by_slug = new Collection();
             $pages_by_sysname = new Collection();
             $pages_by_id = new Collection();
             foreach ($pages as $p => $page) {
                 #Helper::ta($page);
                 $page->extract(1);
                 #Helper::tad($page);
                 $pages_by_slug[$page->start_page ? '/' : $page->slug] = $page;
                 $pages_by_sysname[$page->sysname] = $page;
                 $pages_by_id[$page->id] = $page;
             }
             $pages = ['by_slug' => $pages_by_slug, 'by_sysname' => $pages_by_sysname, 'by_id' => $pages_by_id];
         }
     }
     ## Save cache
     $cache_lifetime = Config::get('pages.preload_cache_lifetime') ?: NULL;
     if ($cache_lifetime) {
         $expiresAt = Carbon::now()->addMinutes($cache_lifetime);
         Cache::put($cache_key, $pages, $expiresAt);
     }
     Config::set($cache_key, $pages);
     #Helper::tad($pages);
 }
 public function listPage()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $start = Input::has('start') ? (int) Input::get('start') : 0;
     $length = Input::has('length') ? Input::get('length') : 10;
     $search = Input::has('search') ? Input::get('search') : [];
     $pages = Page::select('id', 'name', 'menu_id', 'active', 'type');
     if (!empty($search)) {
         foreach ($search as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             if ($key == 'active' || $key == 'on_menu') {
                 if ($value == 'yes') {
                     $value = 1;
                 } else {
                     $value = 0;
                 }
                 if ($key == 'active') {
                     $pages->where($key, $value);
                 } else {
                     $pages->where('menu_id', '>', 0);
                 }
             } else {
                 $value = ltrim(rtrim($value));
                 $pages->where($key, 'like', '%' . $value . '%');
             }
         }
     }
     $order = Input::has('order') ? Input::get('order') : [];
     if (!empty($order)) {
         $columns = Input::has('columns') ? Input::get('columns') : [];
         foreach ($order as $value) {
             $column = $value['column'];
             if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
                 continue;
             }
             $pages->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
         }
     }
     $count = $pages->count();
     if ($length > 0) {
         $pages = $pages->skip($start)->take($length);
     }
     $arrPages = $pages->get()->toArray();
     $arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Page::count(), 'recordsFiltered' => $count, 'data' => []];
     if (!empty($arrPages)) {
         foreach ($arrPages as $page) {
             $image = '';
             if (!empty($page['images'])) {
                 $image = reset($page['images']);
                 $image = $image['path'];
             }
             $arrReturn['data'][] = array(++$start, $page['id'], $page['name'], ucfirst($page['type']), $page['menu_id'] ? 1 : 0, $page['active']);
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
Example #10
0
        }
        if ($errors = $validator->errors()) {
            Input::flash();
            // Notify::error($errors);
            return Response::json(array('id' => $id, 'errors' => array_flatten($errors, array())));
        }
        if (empty($input['name'])) {
            $input['name'] = $input['title'];
        }
        $input['show_in_menu'] = is_null($input['show_in_menu']) || empty($input['show_in_menu']) ? 0 : 1;
        $input['html'] = parse($input['markdown']);
        $page = Page::create($input);
        $id = $page->id;
        Extend::process('page', $id);
        // Notify::success(__('pages.created'));
        return Response::json(array('id' => $id, 'notification' => __('pages.created'), 'redirect' => Uri::to('admin/pages/edit/' . $id)));
    });
    /*
        Delete Page
    */
    Route::get('admin/pages/delete/(:num)', function ($id) {
        if (Page::count() > 1) {
            Page::find($id)->delete();
            Query::table(Base::table('page_meta'))->where('page', '=', $id)->delete();
            Notify::success(__('pages.deleted'));
        } else {
            Notify::error('Unable to delete page, you must have at least 1 page.');
        }
        return Response::redirect('admin/pages');
    });
});
Example #11
0
 function tools_check_library()
 {
     $type = $this->input->post('type');
     if ($type != 'page' && $type != 'chapter') {
         show_404();
     }
     $page = $this->input->post('page');
     if (!is_numeric($page)) {
         show_404();
     }
     $repair = FALSE;
     if ($this->input->post('repair') == 'repair') {
         $repair = TRUE;
     }
     if ($type == 'page') {
         $count = 300;
         if ($repair) {
             $count = 50;
         }
         $items = new Page();
     }
     if ($type == 'chapter') {
         $count = 15;
         if ($repair) {
             $count = 2;
         }
         $items = new Chapter();
     }
     $offset = $page * $count - $count;
     $items->limit($count, $offset)->get_iterated();
     if ($items->result_count() == 0) {
         if ($type == 'chapter') {
             $pages = new Page();
             $pages_count = $pages->count();
             $this->output->set_output(json_encode(array('status' => 'done', 'pages_count' => $pages_count)));
         } else {
             $this->output->set_output(json_encode(array('status' => 'done')));
         }
         return TRUE;
     }
     foreach ($items as $item) {
         $item->check($repair);
     }
     $warnings = array();
     foreach ($this->notices as $notice) {
         if ($notice['type'] == 'error') {
             if (!$this->input->is_cli_request()) {
                 $this->output->set_output(json_encode(array('status' => 'error', 'message' => $notice['message'])));
             }
             return FALSE;
         }
         if ($notice['type'] == 'warning') {
             $warnings[] = $notice['message'];
         }
     }
     $this->output->set_output(json_encode(array('status' => count($warnings) > 0 ? 'warning' : 'success', 'messages' => $warnings, 'processed' => $items->result_count())));
 }