new CI-based WebApp released…

#11
[eluser]mr.green[/eluser]
Pages Controller Src

Code:
<?

class Pages extends Controller
{    

    var $data = array();
    var $table = 'pages';
    var $back_url = '/admin/pages/pagelisting/';
    var $pagedata = array();
    var $id;


    function __construct()
    {
        parent::Controller();        

        check_permissions();

        $this->lang->load('application');    
        $this->id = (int) $id = $this->uri->segment(4, 0);        
        $this->load->model('base', 'BaseModel');
        $this->data['page_title'] = $this->lang->line('pages_crud');
        $this->data['current'] = '4';    

        $this->data['breadcrumb'] = array(
            'admin' => $this->config->item('admin_main_page'),
            'admin/pages/orderslist' => 'Текстовые блоки'
        );
    }
    

    function pageslisting()
    {      
        $this->back->captureUrl();

        // PAGINATION
        $pagination_config = array(
            'base_url' => '/admin/pages/pageslisting/page/',
            'total_rows' => $this->db->count_all($this->table),
            'uri_segment' => 5,
            'num_links' => 20,
            'per_page' => $this->config->item('crud_per_page'),
        );    

        $this->pagination->initialize($pagination_config);        

        $this->pagedata['pages'] = $this->BaseModel->GetLimitedData(

            $this->table,
            $offset = (int) $this->uri->segment(5, 0),
            $per_page = $this->config->item('crud_per_page'),
            $extra_where = '',
            $orderby = array('id', 'desc')
        );

        $this->data['page'] = $this->load->view('admin/datagrid/pages_list', $this->pagedata, true);
        $this->load->view('admin/layouts/main', $this->data);
    }


    function edit()
    {
        $this->back_url = $this->db_session->userdata['script_names'][0];

        // GET DATA FROM DATABASE
        if ($this->id)
        {
            $this->db->select('*');
            $query = $this->db->getwhere($this->table, array('id' => $this->id));

            if (!$this->pagedata['form'] = $query->row())
            {
                $this->db_session->set_flashdata('flashError', $this->lang->line('page_not_exists'), 1);
                redirect($this->back_url);
            }
        }

        $this->data['page_title'] .= $this->id
            ? ' / редактирование'
            : ' / добавление';

        // BREADCRUMB
        $this->pagedata['form']->title
            ? array_push_associative($this->data['breadcrumb'], array($this->pagedata['form']->title))
            : array_push_associative($this->data['breadcrumb'], array('Добавление страницы'));        

        // VALIDATION INIT
        $rules['title'] = 'required|trim';
        $fields['title'] = 'Название';

        $rules['text'] = 'required|trim';
        $fields['text'] = 'Текст';    

        $rules['alias'] = 'required|trim|alpha';
        $fields['alias'] = 'Алиас';    

        $this->validation->set_rules($rules);
        $this->validation->set_fields($fields);        
        // ***

        if ($this->validation->run())
        {
            $data['title'] = $this->input->post('title');
            $data['text'] = $this->input->post('text');
            $data['alias'] = $this->input->post('alias');

            if ($this->id) $this->db->update($this->table, $data, "id={$this->id}");
            else $this->db->insert($this->table, $data);                

            $this->db_session->set_flashdata('flashMessage', $this->config->item('success_message'), 1);
            redirect($this->back_url);
        }
        else
        {
            $this->data['page'] = $this->load->view('admin/forms/pages', $this->pagedata, true);
            $this->load->view('admin/layouts/main', $this->data);
        }
    }


    function delete()
    {
            $this->BaseModel->DeleteRow($this->table, $this->id);
            $this->db_session->set_flashdata('flashMessage', $this->lang->line('page_deleted'), 1);
            redirect($this->back_url);
    }
}
?>

#12
[eluser]MpaK69[/eluser]
э, странно, то вроде с моделью работаешь, то без нее

а лучше было бы просто исходники запаковать и выложить на сайте каком-нить, чтобы целиком смотреть, а не по кускам

#13
[eluser]mr.green[/eluser]
[quote author="MpaK69" date="1183475255"]э, странно, то вроде с моделью работаешь, то без нее

а лучше было бы просто исходники запаковать и выложить на сайте каком-нить, чтобы целиком смотреть, а не по кускам[/quote]

Угу. Постараюсь сегодня, архив нужно уменьшить. С базой и картинками весит 60 метров. А насчет модели, просто иногда лень дописывать, сроки ограниченные были

#14
[eluser]MpaK69[/eluser]
ага, понятно, таже беда
я вот тоже стандартный класс модели подумываю заменить на свой, чтобы наследовать такие методы как например

Code:
// Сохраним у себя его данные
    function set( $key, $value = '' ){
        if ( ! is_array($key) ){
            $key = array($key => $value);
        }
        foreach ($key as $k => $v){
            $this->user[$k] = $v;
        }
    }

#15
[eluser]mk3[/eluser]
[quote author="MpaK69" date="1183456996"]
hehe, if I can little bit speak at english, you can learn russian! try it is easy )
sorry for my ugly english ^)[/quote]

For me it is not problem to read russian even if it's in cyrilik or smth like that Smile do not worry... though got some problems in writting Big Grin

#16
[eluser]emperius[/eluser]
I've just almost finished this site about Moldova apartments

http://www.apartments.worldofmoldova.com

This is mt first CI based site Smile

There is not much information there but it will be added soon.

If you have any sidjestions you may write here

#17
[eluser]Unknown[/eluser]
[quote author="emperius" date="1183770729"]I've just almost finished this site about Moldova apartments

http://www.apartments.worldofmoldova.com

This is mt first CI based site Smile

There is not much information there but it will be added soon.

If you have any sidjestions you may write here[/quote]

Nice site, I'm from Moldova, right now I'm try to learn CI...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.