[geeklog-cvs] MVCnPHP/contactmanager/views ShowContactsFlexy.class.php,NONE,1.1

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Fri Jul 18 17:20:23 EDT 2003


Update of /usr/cvs/geeklog/MVCnPHP/contactmanager/views
In directory internal.geeklog.net:/tmp/cvs-serv23946

Added Files:
	ShowContactsFlexy.class.php 
Log Message:
This is the ShowContacts view using the PEAR::HTML_Template_Flexy class library

--- NEW FILE: ShowContactsFlexy.class.php ---
<?php

/**
* MVCnPHP - Sample Application
*
* This source file is subject to version 2.02 of the PHP license,
* that is bundled with this package in the file LICENSE, and is
* available at through the world-wide-web at
* http://www.php.net/license/2_02.txt.
* If you did not receive a copy of the PHP license and are unable to
* obtain it through the world-wide-web, please send a note to
* license at php.net so we can mail you a copy immediately.
*
* @author Tony Bibbs <tony at geeklog.net>
* @copyright Tony Bibbs 2003
* @package net.geeklog.mvc.sampleapp
* @version $Id: ShowContactsFlexy.class.php,v 1.1 2003/07/18 21:20:21 tony Exp $
*
*/

/**
* Abstract view class
*/
require_once 'BaseView.class.php';

/**
* Flexy HTML Template Library
*/
require_once 'HTML/Template/Flexy.php';

/**
* Shows listing of contacts to administrator using
* PEAR::HTML_Template_Flexy
*
* @author Tony Bibbs <tony at geeklog.net>
* @package net.geeklog.mvc.sampleapp
*
*/
class ShowContactsFlexy extends BaseView {
    var $template;
    var $pageTitle;
    var $contacts;
    var $mvcMessage;
    var $formAction;
    var $oldQuery;
    var $baseURL;
    
    /**
    * Constructor
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    function ShowContactsFlexy()
    {
        global $gConf;
        
        $this->template = $gConf['path_mvc'] . 'contactmanager/views/templates/ShowContacts.html';
        $this->pageTitle = 'MVCnPHP - Show Contacts (Flexy)';
        $this->mvcMessage = $_SESSION[MVC_MESSAGE];
        $this->baseURL = $gConf['site_url'];
        $this->formAction = $gConf['site_url'];
    }
    
    /**
    * Renders the view
    *
    * NOTE: typically a view would use an HTML template class like
    * PEAR::HTML_Template_Flexy instead ofechoing the HTML here.
    * Needless to say this is for demonstration purposes only.
    *
    * @author Tony Bibbs <tony at geeklog.net>
    * @access public
    *
    */
    function getView()
    {
        global $db, $gConf;
        
        
        if (empty($_SESSION['query'])) {
            $result = $db->query("SELECT contact_id, lname, fname, email, home_phone, work_phone, mobile_phone FROM contact ORDER BY lname,fname");
        } else {
            $result = $db->query($_SESSION['query']);
        }
        
        if (DB::isError($result)) {
            die ($result->getMessage());
        }
        
        
        if ($result->numRows() > 0) {
            while ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
                $name = $row['lname'] . ', ' . $row['fname'];
                printf('<TR><TD>[<a href="%s/?cmd=edit&id=%s">Edit</a>]</TD><TD>%s</TD><TD>%s </TD><TD>%s </TD><TD>%s </TD><TD>%s </TD></TR>',
                       $gConf['site_url'], $row['contact_id'], $name, $row['email'], $row['home_phone'], $row['work_phone'], $row['mobile_phone']);
                
            }
        } else {
            //echo '<TR><TD colspan="6">No contacts found</TD></TR>';
        }
        
        $output = new HTML_Template_Flexy();
        $output->compile($this->template);
        $output->outputObject($this);
        
    }
}

?>




More information about the geeklog-cvs mailing list