truongdx Posted May 22, 2014 Share Posted May 22, 2014 Chào các bạn! Mình đã cố gắng tìm hiểu nhưng chưa xử lí được vấn đềMình đang viết 1 module với các chức năng thêm sửa xóa được quản lí ở back-officeđây là thông báo lỗi từ trình duyệtFatal error: Class name must be a valid object or a string in E:\phan mem hoc tap\xampp 1.7\xampp\htdocs\prestashop\prestashop\classes\controller\AdminController.php on line 2886 Đây là file AdminCreatePage.php:<?phprequire_once (dirname(__file__) . '/create_page.php');require_once (dirname(__file__) . '/classes/CreatePage.php');class AdminCreatePage extends AdminController{ public function __construct() { $this->context = Context::getContext(); $this->table = 'create_page'; //$this->className = 'CreatePage'; $this->addRowAction('edit'); $this->addRowAction('delete'); // $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), // 'confirm' => $this->l('Delete selected items?')), ); $this->fields_list = array( 'id_create_page' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'title' => array('title' => $this->l('Title'), 'width' => 40, 'align' => 'center'), ); parent::__construct(); } public function renderForm() { $this->display = 'edit'; $this->initToolbar(); $this->fields_form = array( //'tinymce' => TRUE, // 'legend' => array('title' => $this->l('Field'), //'image' =>'../img/admin/tab-categories.gif'), 'input' => array( array( 'type' => 'text', 'label' => $this->l('ID:'), 'name' => 'id_create_page', 'id' => 'id_create_page', //'lang' => TRUE, 'required' => TRUE, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 50), array( 'type' => 'text', 'label' => $this->l('Title:'), 'name' => 'title', 'id' => 'title', //'lang' => TRUE, 'required' => TRUE, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 50), // array( // 'type' => 'textarea', // 'label' => $this->l('Block content'), // 'name' => 'content', // 'autoload_rte' => TRUE, // 'lang' => TRUE, // 'required' => TRUE, // 'rows' => 5, // 'cols' => 40, // 'hint' => $this->l('Invalid characters:').' <>;=#{}'), ), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button') ); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso', ); } return parent::renderForm(); } } còn đây là file tâng Model CreatePage.php<?phpclass CreatePage extends ObjectModel{ /** @var string Name */ public $id_create_page; public $title; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'create_page', 'primary' => 'id_create_page', 'multilang' => TRUE, 'fields' => array( 'id_create_page' => array('type' => self::TYPE_INT), 'title' => array('type' => self::TYPE_INT), ), ); public function add($autodate = TRUE, $null_values = FALSE) { $this->id_create_page = self::getLastPosition(); return parent::add($autodate, TRUE); } // public function update($null_values = FALSE) // { // if (parent::update($null_values)) { // return $this->cleanPositions(); // } // return FALSE; // } // public function delete() // { // if (parent::delete()) { // return $this->cleanPositions(); // } // return FALSE; // } public static function getLastPosition() { $sql = ' SELECT MAX(id_create_page) + 1 FROM `'._DB_PREFIX_.'create_page`'; return (Db::getInstance()->getValue($sql)); } // public static function cleanPositions() // { // $sql = ' // SELECT `id_create_page` // FROM `'._DB_PREFIX_.'create_page` // ORDER BY `id_create_page`'; // $result = Db::getInstance()->executeS($sql); // for ($i = 0, $total = count($result); $i < $total; ++$i) { // $sql = 'UPDATE `'._DB_PREFIX_.'create_page` // SET `title` = '.(int)$i.' // WHERE `id_create_page` = '.(int)$result[$i]['id_create_page']; // Db::getInstance()->execute($sql); // } // return TRUE; // } // public function updatePosition($way, $position) // { // if (!$res = Db::getInstance()->executeS(' // SELECT cp.`id_belvg_faq`, cp.`position` // FROM `'._DB_PREFIX_.'belvg_faq` cp // ORDER BY cp.`position` ASC' // )) { // return FALSE; // } // foreach ($res as $faq) { // if ((int)$faq['id_belvg_faq'] == (int)$this->id) { // $moved_faq = $faq; // } // } // if (!isset($moved_faq) || !isset($position)) { // return FALSE; // } // // < and > statements rather than BETWEEN operator // // since BETWEEN is treated differently according to databases // return (Db::getInstance()->execute(' // UPDATE `'._DB_PREFIX_.'belvg_faq` // SET `position`= `position` '.($way ? '- 1' : '+ 1').' // WHERE `position` // '.($way // ? '> '.(int)$moved_faq['position'].' AND `position` <= '.(int)$position // : '< '.(int)$moved_faq['position'].' AND `position` >= '.(int)$position)) // && Db::getInstance()->execute(' // UPDATE `'._DB_PREFIX_.'belvg_faq` // SET `position` = '.(int)$position.' // WHERE `id_belvg_faq` = '.(int)$moved_faq['id_belvg_faq'])); // }} Rất mong mọi người giúp đỡ.Mình xin cảm ơn! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now