b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _country.class.php

Documentation is available at _country.class.php

  1. <?php
  2. /**
  3.  * This file is part of the evoCore framework - {@link http://evocore.net/}
  4.  * See also {@link http://sourceforge.net/projects/evocms/}.
  5.  *
  6.  * @copyright (c)2009 by Francois PLANQUE - {@link http://fplanque.net/}
  7.  *  Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
  8.  *
  9.  *  {@internal License choice
  10.  *  - If you have received this file as part of a package, please find the license.txt file in
  11.  *    the same folder or the closest folder above for complete license terms.
  12.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  13.  *    then you must choose one of the following licenses before using the file:
  14.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  15.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  16.  *  }}}
  17.  *
  18.  *  {@internal Open Source relicensing agreement:
  19.  *  The Evo Factory grants Francois PLANQUE the right to license
  20.  *  The Evo Factory's contributions to this file and the b2evolution project
  21.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  22.  *  }}}
  23.  *
  24.  * @package evocore
  25.  *
  26.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  27.  * @author efy-maxim: Evo Factory / Maxim.
  28.  * @author fplanque: Francois Planque.
  29.  *
  30.  * @version $Id: _country.class.php,v 1.16 2009/09/29 03:14:22 fplanque Exp $
  31.  */
  32.  
  33. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  34.  
  35. load_class'_core/model/dataobjects/_dataobject.class.php''DataObject' );
  36.  
  37. /**
  38.  * Country Class
  39.  */
  40. class Country extends DataObject
  41. {
  42.     var $code = '';
  43.     var $name = '';
  44.     var $curr_ID = '';
  45.     var $enabled = 1;
  46.  
  47.     /**
  48.      * Constructor
  49.      *
  50.      * @param object database row
  51.      */
  52.     function Country$db_row NULL )
  53.     {
  54.         // Call parent constructor:
  55.         parent::DataObject'T_country''ctry_''ctry_ID' );
  56.  
  57.         $this->delete_restrictions = array(
  58.                 array'table'=>'T_users''fk'=>'user_ctry_ID''msg'=>T_('%d related users') ),
  59.             );
  60.  
  61.           $this->delete_cascades = array();
  62.  
  63.          if$db_row )
  64.         {
  65.             $this->ID            = $db_row->ctry_ID;
  66.             $this->code          = $db_row->ctry_code;
  67.             $this->name          = $db_row->ctry_name;
  68.             $this->curr_ID       = $db_row->ctry_curr_ID;
  69.             $this->enabled       = $db_row->ctry_enabled;
  70.         }
  71.     }
  72.  
  73.  
  74.     /**
  75.      * Load data from Request form fields.
  76.      *
  77.      * @return boolean true if loaded data seems valid.
  78.      */
  79.     function load_from_Request()
  80.     {
  81.         // Name
  82.         $this->set_string_from_param'name'true );
  83.  
  84.         // Code
  85.         param'ctry_code''string' );
  86.         param_check_regexp'ctry_code''#^[A-Za-z]{2}$#'T_('Country code must be 2 letters parameter.') );
  87.         $this->set_from_Request'code''ctry_code' );
  88.  
  89.         // Currency Id
  90.         param'ctry_curr_ID''integer' );
  91.         param_check_number'ctry_curr_ID''Please select a currency' );
  92.         $this->set_from_Request'curr_ID''ctry_curr_ID'true );
  93.  
  94.         return param_errors_detected();
  95.     }
  96.  
  97.  
  98.     /**
  99.      * Set param value
  100.      *
  101.      * By default, all values will be considered strings
  102.      *
  103.      * @param string parameter name
  104.      * @param mixed parameter value
  105.      * @param boolean true to set to NULL if empty value
  106.      * @return boolean true, if a value has been set; false if it has not changed
  107.      */
  108.     function set$parname$parvalue$make_null false )
  109.     {
  110.         switch$parname )
  111.         {
  112.             case 'code':
  113.                 $parvalue strtolower($parvalue);
  114.             case 'name':
  115.             case 'curr_ID':
  116.             case 'enabled':
  117.             default:
  118.                 return $this->set_param$parname'string'$parvalue$make_null );
  119.         }
  120.     }
  121.  
  122.  
  123.     /**
  124.      * Get country name.
  125.      *
  126.      * @return string currency code
  127.      */
  128.     function get_name()
  129.     {
  130.         return $this->name;
  131.     }
  132.  
  133.  
  134.     /**
  135.      * Check existence of specified country code in ctry_code unique field.
  136.      *
  137.      * @return int ID if country code exists otherwise NULL/false
  138.      */
  139.     function dbexists()
  140.     {
  141.         return parent::dbexists('ctry_code'$this->code);
  142.     }
  143. }
  144.  
  145.  
  146. /*
  147.  * $Log: _country.class.php,v $
  148.  * Revision 1.16  2009/09/29 03:14:22  fplanque
  149.  * doc
  150.  *
  151.  * Revision 1.15  2009/09/28 20:55:00  efy-khurram
  152.  * Implemented support for enabling disabling countries.
  153.  *
  154.  * Revision 1.14  2009/09/20 20:07:18  blueyed
  155.  *  - DataObject::dbexists quotes always
  156.  *  - phpdoc fixes
  157.  *  - style fixes
  158.  *
  159.  * Revision 1.13  2009/09/14 13:31:35  efy-arrin
  160.  * Included the ClassName in load_class() call with proper UpperCase
  161.  *
  162.  * Revision 1.12  2009/09/12 12:53:44  tblue246
  163.  * Country class: Call load_class() with $classname parameter
  164.  *
  165.  * Revision 1.11  2009/09/12 10:40:40  tblue246
  166.  * Fixed wrong pathname
  167.  *
  168.  * Revision 1.9  2009/09/10 18:24:07  fplanque
  169.  * doc
  170.  *
  171.  */
  172. ?>

Documentation generated on Sat, 06 Mar 2010 04:06:57 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).