PHP Classes

File: examples/blog/app/admin/controllers/comments.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil  >  PHP Skeleton Framework  >  examples/blog/app/admin/controllers/comments.php  >  Download  
File: examples/blog/app/admin/controllers/comments.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 5 years ago
Size: 2,424 bytes


Class file image Download
//namespace admin\controllers;
use blog\models\commentsModel;

comments extends A_Controller_Action {

     * This function is called only if it exists. Front Controller pre-filter
     * calls it to get required groups for this controller
public function _requireGroups(){
        return array(
index($locator) {
$template = $this->_load()->template();
listing($locator) {
$usersession = $locator->get('UserSession');
$db = $locator->get('Db');
$template = $this->_load('controller')->template('listing');
// create a data object that has the interface needed by the Pager object
$datasource = new A_Pagination_Adapter_Db($db, "SELECT * FROM `blog_comments`");
// create a request processor to set pager from GET parameters
$pager = new A_Pagination_Request($datasource);
// initialize using values from $_GET
// create a "standard" view object to create pagination links
$view = new A_Pagination_View_Standard($pager);
$rows = $pager->getItems();

$template->set('rows', $rows);
$template->set('links', $view->render()); // display the pagination links
$this->response->set('maincontent', $template->render());

edit($locator) {
$template = $this->_load('controller')->template();
$comments = $this->_load('module=blog')->model('comments', $locator->get('Db'));
// Hand the Form the fields and rules from the model
$form = new A_Model_Form();
// ask the form if it is valid. The form checks internally if the model fields are valid
// save
$result = $comments->save($form->getSaveValues());
$form->setErrorMsg('databaseerror', 'Could not save to the database');

        } elseif (!
$this->_request()->has('save') && $this->_request()->has('id')) {
$id = $this->_request()->get('id');
// load data
$rows = $comments->find($id);
            if (isset(
$rows[0])) {
                foreach (
$rows[0] as $name => $value) {
$template->set('errorMsg', $form->getErrorMsg(', '));
$this->response->set('maincontent', $template->render());


For more information send a message to info at phpclasses dot org.