public
Last active

  • Download Gist
Admin_Bootstrap.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
public function _initResources() {
$view = new Zend_View();
$view->headScript()
->appendFile('public/js/jquery-1.4.2.min.js')
->appendFile('public/js/jquery.tools.min.js')
->appendFile('public/js/jquery-ui-1.8.4.custom.min.js')
->appendFile('public/js/utils.js')
->appendFile('public/ckeditor/ckeditor.js')
->appendFile('public/ckeditor/adapters/jquery.js')
->appendFile('public/js/admin.js')
->appendFile('public/js/ie.utils.js', null, array('conditional' => 'IE'))
->appendFile('public/js/ie.js', null, array('conditional' => 'IE'));
 
$view->headLink()
->appendStylesheet('public/css/blueprint/screen.css', 'screen')
->appendStylesheet('public/css/uploadify.css', 'screen')
->appendStylesheet('public/css/jquery.tools.css', 'screen')
->appendStylesheet('public/css/ui-theme/jquery-ui-1.8.4.custom.css', 'screen')
->appendStylesheet('public/css/blueprint/print.css', 'print')
->appendStylesheet('public/css/admin.css', 'screen')
->appendStylesheet('public/css/blueprint/ie.css', 'screen', 'IE')
->appendStylesheet('public/css/ie.css', 'screen', 'IE');
}
}
Bootstrap.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initLayout() {
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini', 'layout');
$layout = Zend_Layout::startMvc($config);
}
public function _initNavigation() {
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/admin_navigation.xml', 'nav');
$navigation = new Zend_Navigation($config);
 
Zend_Registry::set('Zend_Navigation', $navigation);
}
}
News.php
PHP
1 2 3 4 5 6 7 8 9 10 11
<?php
 
class Admin_Model_News extends Zend_Db_Table_Abstract
{
protected $_name = 'news';
protected $_primary = 'new_id';
 
public function addNews($data) {
$this->insert($data);
}
}
NewsController.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<?php
/**
* Login
*/
class Admin_NewsController extends Zend_Controller_Action {
 
public function preDispatch() {
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('admin');
}
 
public function indexAction() {
 
}
 
public function addAction() {
$db = new Admin_Model_News();
//$this->getHelper('viewRenderer')->setNoRender();
// Calls the Request object
$request = $this->getRequest();
 
if ($request->isPost()) {
// Retrieves form data
$data = array(
"new_title" => $request->getParam('txtTitle'),
"new_text" => htmlentities($request->getParam('txtNews')),
"new_image" => $request->getParam('upName'),
"new_published" => 1
);
// Inserts in the database
if ($this->db->addNews($data)) {
$this->view->output = 1;
} else {
$this->view->output = 0;
}
} else {
$this->view->output = 0;
}
 
$this->_helper->layout->disableLayout();
}
}
application.ini
INI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
 
[staging : production]
 
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
 
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
 
[database]
resources.db.adapter = PDO_MYSQL
resources.db.params.dbname = "ccgss"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.hostname = "localhost"
resources.db.isDefaultTableAdapter = true
 
[layout]
layoutPath = APPLICATION_PATH "/layouts"
layout = default
contentKey = "content"
index.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?php
 
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
 
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
 
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
 
/** Zend_Application */
require_once 'Zend/Application.php';
 
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.