Ratings::index PHP Method

index() public method

public index ( )
    public function index()
    {
        $this->user->restrict('Admin.Ratings');
        $this->lang->load('ratings');
        $this->template->setTitle($this->lang->line('text_title'));
        $this->template->setHeading($this->lang->line('text_heading'));
        $this->template->setButton($this->lang->line('button_save'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#edit-form\').submit();'));
        $this->template->setScriptTag(assets_url('js/jquery-sortable.js'), 'jquery-sortable-js');
        if ($this->input->post() and $this->_updateRating() === TRUE) {
            redirect('ratings');
        }
        if ($this->input->post('ratings')) {
            $results = $this->input->post('ratings');
        } else {
            if ($this->config->item('ratings')) {
                $ratings = $this->config->item('ratings');
                $results = $ratings['ratings'];
            } else {
                $results = '';
            }
        }
        $data['ratings'] = array();
        if (is_array($results)) {
            foreach ($results as $key => $value) {
                $data['ratings'][$key] = $value;
            }
        }
        $this->template->render('ratings', $data);
    }