[geeklog-cvs] Geeklog-2/views BaseViewFlexy.php,1.2,1.3
tony at iowaoutdoors.org
tony at iowaoutdoors.org
Thu Mar 3 00:14:32 EST 2005
- Previous message (by thread): [geeklog-cvs] Geeklog-2/views BaseViewFlexyUser.php,1.2,1.3
- Next message (by thread): [geeklog-cvs] MVCnPHP ArrayLoader.php,1.2,1.3 BaseLoader.php,1.2,1.3 BaseView.php,1.2,1.3 CHANGELOG,1.1.1.1,1.2 CommandFactory.php,1.2,1.3 CommandInterface.php,1.2,1.3 Constants.php,1.2,1.3 Controller.php,1.2,1.3 Form.php,1.2,1.3 LoaderFactory.php,1.2,1.3 Mapping.php,1.2,1.3 README.txt,1.1.1.1,1.2 Validator.php,1.2,1.3 ViewFactory.php,1.2,1.3 ViewInterface.php,1.2,1.3 XMLLoader.php,1.2,1.3 buildPackage.php,1.1.1.1,1.2 package.xml,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/cvs/Geeklog-2/views
In directory www:/tmp/cvs-serv5651/views
Modified Files:
BaseViewFlexy.php
Log Message:
Space issue. Significant change is that getView() now properly receives whatever processView returns for forwards.
Index: BaseViewFlexy.php
===================================================================
RCS file: /var/cvs/Geeklog-2/views/BaseViewFlexy.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BaseViewFlexy.php 18 Dec 2004 07:12:33 -0000 1.2
--- BaseViewFlexy.php 3 Mar 2005 05:14:30 -0000 1.3
***************
*** 1,435 ****
! <?php
!
! /* Reminder: always indent with 4 spaces (no tabs). */
! /**
! * Hunting Log Application
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright Tony Bibbs 2004
! * @version $Id$
! *
! */
!
! /**
! * BaseView object
! *
! */
! require_once 'MVCnPHP/BaseView.php';
!
! /**
! * Bring in translation library
! */
! require_once 'Translation2.php';
!
! /**
! * PEAR::HTML_Template_Flexy HTML Template Library
! */
! require_once 'HTML/Template/Flexy.php';
!
! /**
! * PEAR::HTML_Template_Flexy_Element
! */
! require_once 'HTML/Template/Flexy/Element.php';
!
! /**
! * This class extends the MVCnPHP Base View by adding implementing support
! * for PEAR::HTML_Template_Flexy
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.views
! *
! */
! abstract class Geeklog_BaseViewFlexy extends MVCnPHP_BaseView {
! /**
! * base URL to be used by flexy
! *
! * @access public
! * @var string
! */
! public $baseUrl = '';
!
! /**
! * Array of flexy options
! *
! * @access private
! * @var array
! */
! private $options = null;
!
! /**
! * Title of this view
! *
! * @access protected
! * @var string
! */
! public $pageTitle = null;
!
! /**
! * Indicates if we should show navigation or not
! *
! * @access private
! * @var boolean
! */
! protected $showNavigation = null;
!
! /**
! * Meta tags to put in the HTML <head> section
! *
! * @access private
! * @var string
! */
! public $metaTags = null;
!
! /**
! * Indicates if user is an administrator
! * @access private
! * @var boolean
! */
! protected $isAdmin = null;
!
! /**
! * Handle to instance of a flexy object
! *
! * @access private
! * @var object
! */
! protected $flexyHandle = null;
!
! /**
! * PEAR::HTML_Template_Flexy form elements
! *
! * @access public
! * @var Array
! */
! public $flexyElements = null;
!
!
! /**
! * Holds any MVC messages, note this should be treated as private...flexy
! * requires this to start without the underscore.
! *
! * @access private
! * @var array
! */
! protected $mvcMessages = null;
!
! /**
! * Initializes PEAR::HTML_Template_Flexy
! *
! * Sets the config optiosn for Flexy and then creates an instance of Flexy that is then
! * available to all descendants
! *
! */
! protected function initializeFlexy($theme = 'default', $lang = 'en')
! {
! global $glConf;
!
! // Add base URL to variable that can be used by flexy
! $this->baseUrl = $glConf['site_url'];
!
! $this->showNavigation = true;
! $this->options = array(
! 'templateDir' => $glConf['path_themes'] . $theme,
! 'compileDir' => $glConf['path_themes'] . "$theme/compiled_templates",
! 'forceCompile' => 0,
! 'debug' => 0,
! 'locale' => $lang,
! //'compiler' => 'Standard',
! 'Translation2' => array('driver' => 'XML', array('filename'=>'il8nxml','save_on_shutdown'=>true))
! );
!
! $this->flexyHandle = new HTML_Template_Flexy($this->options);
! }
!
! /**
! * Sets the title for the HTML page being outputted
! *
! * @author Tony Bibs <tony at geeklog.net
! * @access public
! * @param string $pageTitle Title to give the page
! *
! */
! public function setPageTitle($pageTitle)
! {
! $this->pageTitle = $pageTitle;
! }
!
! /**
! * Sets the keywords meta tags for the page
! *
! * @author Tony Bibs <tony at geeklog.net
! * @access public
! * @param string $metaTags Meta tags to assign to page
! *
! */
! public function setMetaTags($metaTags)
! {
! $this->metaTags = $metaTags;
! }
!
! /**
! * Returns the page title
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function getPageTitle()
! {
! return $this->pageTitle;
! }
!
! /**
! * Returns the meta tags to show in the page
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function getMetaTags()
! {
! return $this->metaTags;
! }
!
! /**
! * Translates a string to the right language
! *
! * Uses PEAR::Translation2 to convert an english string to
! * the right language
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string $stringToTranslate English string to Translate
! * @return string Translated string
! *
! */
! public function translate($stringToTranslate)
! {
!
! }
!
! /**
! * Shows the page header
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access private
! * @param string $pageTitle Title of the page
! * @param boolean $showNavigation Indicates if the navigation bar should be displayed
! * @param string $metaTags String of XHTML meta tags specific to this page
! *
! */
! protected function showHeader($showNavigation = true)
! {
! if (empty($this->pageTitle)) {
! $this->pageTitle = 'Geeklog: Page Not Named';
! }
! if (empty($this->metaTags)) {
! $this->metaTags = '';
! }
!
! if (!is_bool($showNavigation)) {
! $this->showNavigation = true;
! } else {
! $this->showNavigation = $showNavigation;
! }
!
! $this->flexyHandle->compile('Header.thtml');
! $this->flexyHandle->outputObject($this);
! }
!
! /**
! * Shows the page footer
! *
! * @author TonyBibbs
! * @acces private
! *
! */
! protected function showFooter()
! {
! $this->flexyHandle->compile('Footer.thtml');
! $this->flexyHandle->outputObject($this);
! }
!
! /**
! * Returns if we should show the navigation bar
! *
! * @author Tony Bibbs <tony at geeklog.net
! * @access public
! *
! */
! public function mustShowNavigation()
! {
! return $this->showNavigation;
! }
! /**
! * Renders the view to the user's browser
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! public function getView()
! {
! $this->initializeFlexy();
! $this->processView();
! }
!
! /**
! * This is where all the magic happens. Specifically this is where the view of the view gets
! * generated.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! abstract public function processView();
!
! /**
! * Calls a function on an object and returns the result
! *
! * @author Tony Bibbs <tony at geeklog.net>
! *
! */
! public function callOnObject($method, $object) {
! return call_user_func(array(&$object, $method));
! }
!
! /**
! * Calls a function on an array element and returns the result
! *
! * @author Tony Bibbs <tony at geeklog.net>
! *
! */
! public function callOnArray($method, $array, $num) {
! $object = &$array[$num];
! return call_user_func(array(&$object, $method));
! }
!
! /**
! * Used by flexy to determine if a <option> tag should be
! * displayed with selected or not
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function isEqual($key, $value) {
! if ($key == $value) {
! return true;
! }
! return false;
! }
!
! /**
! * Removes any messages from the session
! *
! * Necessary to preserve memory
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! public function clearMessages()
! {
! session_unregister(MVC_MESSAGES);
! }
!
! /**
! * Gets any MVC errors or MVC messages
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string separator Separator to give to implode()
! * @return string All messages seperated by separator given
! *
! */
! public function getMessages($separator = "<br/>") {
! if (is_array($_REQUEST[MVC_ERRORS])) {
! $errors = implode($separator,$_REQUEST[MVC_ERRORS]);
! }
! if (is_array($_REQUEST[MVC_MESSAGES])) {
! $messages = implode($separator,$_REQUEST[MVC_MESSAGES]);
! }
! if (empty($errors) AND empty($messages)) {
! return '';
! } else {
! return $errors . $separator . $messages;
! }
! }
!
! /**
! * This short piece of code converts a request into a Propel model objec that the
! * developer can work directly with.
! *
! * It is possible to map form fields directly to model objects so that the command that catches
! * the request can begin working with the objects immediately and not have to do the form field
! * to domain object mapping themselves.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return array Array of objects
! *
! */
! protected function requestToObjects()
! {
! $postVars = array_keys($_REQUEST);
! foreach ($postVars as $curVarName) {
! if (stristr($curVarName, '->')) {
! $tmpArray = explode('->',$curVarName);
! $objArray[$tmpArray[0]][$tmpArray[1]] = $_REQUEST[$curVarName];
! }
! }
! $objNames = array_keys($objArray);
! $objInstances = array();
! foreach ($objNames as $curObj) {
! if (empty($objInstances[$curObj])) {
! $obj = new $curObj();
! $objInstances[$curObj] = $obj;
! } else {
! $obj = $objInstances[$curObj];
! }
! $objAttributes = array_keys($objArray[$curObj]);
! foreach ($objAttributes as $curAttribute) {
! $fnName = 'set' . ucwords($curAttribute);
! //echo "calling $fnName({<br/>";
! $obj->$fnName($objArray[$curObj][$curAttribute]);
! }
! $objInstances[$curObj] = $obj;
! }
! return $objInstances;
! }
!
! protected function getDropDown($dropDownName, $htmlFieldName, $queryArgs = '' , $setValue = ''
! , $idAttribute = '', $displayAttribute = '')
! {
! $resultArray = array();
! $dao = DAOFactory::getDAO();
! if (is_array($queryArgs) AND (count($queryArgs) > 0)) {
! $objArray = $dao->find($dropDownName, $queryArgs);
! } else {
! $objArray = $dao->find($dropDownName);
! }
! $idGetMethod = 'get' . ucwords($idAttribute);
! $displayGetMethod = 'get' . ucwords($displayAttribute);
! foreach ($objArray as $curObj) {
! $resultArray[$curObj->$idGetMethod()] = $curObj->$displayGetMethod();
! }
! $this->flexyElements[$htmlFieldName] = new HTML_Template_Flexy_Element;
! $this->flexyElements[$htmlFieldName]->setOptions($resultArray);
! if (!empty($setValue)) {
! $this->flexyElements[$htmlFieldName]->setValue($setValue);
! }
! }
!
! protected Function getDropDownFromArray($dataArray, $htmlFieldName, $setValue='')
! {
! $this->flexyElements[$htmlFieldName] = new HTML_Template_Flexy_Element;
! $this->flexyElements[$htmlFieldName]->setOptions($dataArray);
! if (!empty($setValue)) {
! $this->flexyElements[$htmlFieldName]->setValue($setValue);
! }
! }
}
\ No newline at end of file
--- 1,437 ----
! <?php
!
! /* Reminder: always indent with 4 spaces (no tabs). */
!
! /**
! * Hunting Log Application
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright Tony Bibbs 2004
! * @version $Id$
! *
! */
!
! /**
! * BaseView object
! *
! */
! require_once 'Geeklog/MVCnPHP/BaseView.php';
!
! /**
! * Bring in translation library
! */
! require_once 'Translation2.php';
!
! /**
! * PEAR::HTML_Template_Flexy HTML Template Library
! */
! require_once 'HTML/Template/Flexy.php';
!
! /**
! * PEAR::HTML_Template_Flexy_Element
! */
! require_once 'HTML/Template/Flexy/Element.php';
!
! /**
! * This class extends the MVCnPHP Base View by adding implementing support
! * for PEAR::HTML_Template_Flexy
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.views
! *
! */
! abstract class Geeklog_BaseViewFlexy extends MVCnPHP_BaseView {
! /**
! * base URL to be used by flexy
! *
! * @access public
! * @var string
! */
! public $baseUrl = '';
!
! /**
! * Array of flexy options
! *
! * @access private
! * @var array
! */
! private $options = null;
!
! /**
! * Title of this view
! *
! * @access protected
! * @var string
! */
! public $pageTitle = null;
!
! /**
! * Indicates if we should show navigation or not
! *
! * @access private
! * @var boolean
! */
! protected $showNavigation = null;
!
! /**
! * Meta tags to put in the HTML <head> section
! *
! * @access private
! * @var string
! */
! public $metaTags = null;
!
! /**
! * Indicates if user is an administrator
! * @access private
! * @var boolean
! */
! protected $isAdmin = null;
!
! /**
! * Handle to instance of a flexy object
! *
! * @access private
! * @var object
! */
! protected $flexyHandle = null;
!
! /**
! * PEAR::HTML_Template_Flexy form elements
! *
! * @access public
! * @var Array
! */
! public $flexyElements = null;
!
!
! /**
! * Holds any MVC messages, note this should be treated as private...flexy
! * requires this to start without the underscore.
! *
! * @access private
! * @var array
! */
! protected $mvcMessages = null;
!
! /**
! * Initializes PEAR::HTML_Template_Flexy
! *
! * Sets the config optiosn for Flexy and then creates an instance of Flexy that is then
! * available to all descendants
! *
! */
! protected function initializeFlexy($theme = 'default', $lang = 'en')
! {
! global $glConf;
!
! // Add base URL to variable that can be used by flexy
! $this->baseUrl = $glConf['site_url'];
!
! $this->showNavigation = true;
! $this->options = array(
! 'templateDir' => $glConf['path_themes'] . $theme,
! 'compileDir' => $glConf['path_themes'] . "$theme/compiled_templates",
! 'forceCompile' => 0,
! 'debug' => 0,
! 'locale' => $lang,
! //'compiler' => 'Standard',
! 'Translation2' => array('driver' => 'XML', array('filename'=>'il8nxml','save_on_shutdown'=>true))
! );
!
! $this->flexyHandle = new HTML_Template_Flexy($this->options);
! }
!
! /**
! * Sets the title for the HTML page being outputted
! *
! * @author Tony Bibs <tony at geeklog.net
! * @access public
! * @param string $pageTitle Title to give the page
! *
! */
! public function setPageTitle($pageTitle)
! {
! $this->pageTitle = $pageTitle;
! }
!
! /**
! * Sets the keywords meta tags for the page
! *
! * @author Tony Bibs <tony at geeklog.net
! * @access public
! * @param string $metaTags Meta tags to assign to page
! *
! */
! public function setMetaTags($metaTags)
! {
! $this->metaTags = $metaTags;
! }
!
! /**
! * Returns the page title
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function getPageTitle()
! {
! return $this->pageTitle;
! }
!
! /**
! * Returns the meta tags to show in the page
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function getMetaTags()
! {
! return $this->metaTags;
! }
!
! /**
! * Translates a string to the right language
! *
! * Uses PEAR::Translation2 to convert an english string to
! * the right language
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string $stringToTranslate English string to Translate
! * @return string Translated string
! *
! */
! public function translate($stringToTranslate)
! {
!
! }
!
! /**
! * Shows the page header
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access private
! * @param string $pageTitle Title of the page
! * @param boolean $showNavigation Indicates if the navigation bar should be displayed
! * @param string $metaTags String of XHTML meta tags specific to this page
! *
! */
! protected function showHeader($showNavigation = true)
! {
! if (empty($this->pageTitle)) {
! $this->pageTitle = 'Geeklog: Page Not Named';
! }
! if (empty($this->metaTags)) {
! $this->metaTags = '';
! }
!
! if (!is_bool($showNavigation)) {
! $this->showNavigation = true;
! } else {
! $this->showNavigation = $showNavigation;
! }
!
! $this->flexyHandle->compile('Header.thtml');
! $this->flexyHandle->outputObject($this);
! }
!
! /**
! * Shows the page footer
! *
! * @author TonyBibbs
! * @acces private
! *
! */
! protected function showFooter()
! {
! $this->flexyHandle->compile('Footer.thtml');
! $this->flexyHandle->outputObject($this);
! }
!
! /**
! * Returns if we should show the navigation bar
! *
! * @author Tony Bibbs <tony at geeklog.net
! * @access public
! *
! */
! public function mustShowNavigation()
! {
! return $this->showNavigation;
! }
!
! /**
! * Renders the view to the user's browser
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! public function getView()
! {
! $this->initializeFlexy();
! return $this->processView();
! }
!
! /**
! * This is where all the magic happens. Specifically this is where the view of the view gets
! * generated.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! abstract public function processView();
!
! /**
! * Calls a function on an object and returns the result
! *
! * @author Tony Bibbs <tony at geeklog.net>
! *
! */
! public function callOnObject($method, $object) {
! return call_user_func(array(&$object, $method));
! }
!
! /**
! * Calls a function on an array element and returns the result
! *
! * @author Tony Bibbs <tony at geeklog.net>
! *
! */
! public function callOnArray($method, $array, $num) {
! $object = &$array[$num];
! return call_user_func(array(&$object, $method));
! }
!
! /**
! * Used by flexy to determine if a <option> tag should be
! * displayed with selected or not
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return boolean
! *
! */
! public function isEqual($key, $value) {
! if ($key == $value) {
! return true;
! }
! return false;
! }
!
! /**
! * Removes any messages from the session
! *
! * Necessary to preserve memory
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! *
! */
! public function clearMessages()
! {
! session_unregister(MVC_MESSAGES);
! }
!
! /**
! * Gets any MVC errors or MVC messages
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @param string separator Separator to give to implode()
! * @return string All messages seperated by separator given
! *
! */
! public function getMessages($separator = "<br/>") {
! if (is_array($_REQUEST[MVC_ERRORS])) {
! $errors = implode($separator,$_REQUEST[MVC_ERRORS]);
! }
! if (is_array($_REQUEST[MVC_MESSAGES])) {
! $messages = implode($separator,$_REQUEST[MVC_MESSAGES]);
! }
! if (empty($errors) AND empty($messages)) {
! return '';
! } else {
! return $errors . $separator . $messages;
! }
! }
!
! /**
! * This short piece of code converts a request into a Propel model objec that the
! * developer can work directly with.
! *
! * It is possible to map form fields directly to model objects so that the command that catches
! * the request can begin working with the objects immediately and not have to do the form field
! * to domain object mapping themselves.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @access public
! * @return array Array of objects
! *
! */
! protected function requestToObjects()
! {
! $postVars = array_keys($_REQUEST);
! foreach ($postVars as $curVarName) {
! if (stristr($curVarName, '->')) {
! $tmpArray = explode('->',$curVarName);
! $objArray[$tmpArray[0]][$tmpArray[1]] = $_REQUEST[$curVarName];
! }
! }
! $objNames = array_keys($objArray);
! $objInstances = array();
! foreach ($objNames as $curObj) {
! if (empty($objInstances[$curObj])) {
! $obj = new $curObj();
! $objInstances[$curObj] = $obj;
! } else {
! $obj = $objInstances[$curObj];
! }
! $objAttributes = array_keys($objArray[$curObj]);
! foreach ($objAttributes as $curAttribute) {
! $fnName = 'set' . ucwords($curAttribute);
! //echo "calling $fnName({<br/>";
! $obj->$fnName($objArray[$curObj][$curAttribute]);
! }
! $objInstances[$curObj] = $obj;
! }
! return $objInstances;
! }
!
! protected function getDropDown($dropDownName, $htmlFieldName, $queryArgs = '' , $setValue = ''
! , $idAttribute = '', $displayAttribute = '')
! {
! $resultArray = array();
! $dao = DAOFactory::getDAO();
! if (is_array($queryArgs) AND (count($queryArgs) > 0)) {
! $objArray = $dao->find($dropDownName, $queryArgs);
! } else {
! $objArray = $dao->find($dropDownName);
! }
! $idGetMethod = 'get' . ucwords($idAttribute);
! $displayGetMethod = 'get' . ucwords($displayAttribute);
! foreach ($objArray as $curObj) {
! $resultArray[$curObj->$idGetMethod()] = $curObj->$displayGetMethod();
! }
! $this->flexyElements[$htmlFieldName] = new HTML_Template_Flexy_Element;
! $this->flexyElements[$htmlFieldName]->setOptions($resultArray);
! if (!empty($setValue)) {
! $this->flexyElements[$htmlFieldName]->setValue($setValue);
! }
! }
!
! protected Function getDropDownFromArray($dataArray, $htmlFieldName, $setValue='')
! {
! $this->flexyElements[$htmlFieldName] = new HTML_Template_Flexy_Element;
! $this->flexyElements[$htmlFieldName]->setOptions($dataArray);
! if (!empty($setValue)) {
! $this->flexyElements[$htmlFieldName]->setValue($setValue);
! }
! }
}
\ No newline at end of file
- Previous message (by thread): [geeklog-cvs] Geeklog-2/views BaseViewFlexyUser.php,1.2,1.3
- Next message (by thread): [geeklog-cvs] MVCnPHP ArrayLoader.php,1.2,1.3 BaseLoader.php,1.2,1.3 BaseView.php,1.2,1.3 CHANGELOG,1.1.1.1,1.2 CommandFactory.php,1.2,1.3 CommandInterface.php,1.2,1.3 Constants.php,1.2,1.3 Controller.php,1.2,1.3 Form.php,1.2,1.3 LoaderFactory.php,1.2,1.3 Mapping.php,1.2,1.3 README.txt,1.1.1.1,1.2 Validator.php,1.2,1.3 ViewFactory.php,1.2,1.3 ViewInterface.php,1.2,1.3 XMLLoader.php,1.2,1.3 buildPackage.php,1.1.1.1,1.2 package.xml,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list