Source for file ConfigElement.php

Documentation is available at ConfigElement.php

  1. <?php
  2. /**
  3. * Abstract class for each config elements.
  4. *
  5. * PHP version 5
  6. @category  PHP
  7. @package   GeoPrisma
  8. @author    Alexandre Dube
  9. @copyright 2010, Nippour Geomatik
  10. @license   http://www.geoprisma.org/license BSD License
  11. @link      http://www.geoprisma.org
  12. */
  13.  
  14. /**
  15. * Abstract class for each config elements.
  16. @category   PHP
  17. @package    GeoPrisma
  18. @subpackage ConfigElement
  19. @author     Alexandre Dube
  20. @license    http://www.geoprisma.org/license BSD License
  21. @link       http://www.geoprisma.org
  22. */ 
  23.  
  24. {
  25.     /**
  26.     * Return DomElement object of given value.
  27.     *
  28.     * @param string      $pstrType        Type
  29.     * @param string      $pstrValue       Value
  30.     * @param DOMDocument $pobjDomDocument DomDocument object used to create
  31.     *                                      dom elements
  32.     * 
  33.     * @return array 
  34.     */
  35.     public function getDomElements(
  36.         $pstrType$pstrValueDOMDocument $pobjDomDocument
  37.     {
  38.         $objDomElement null;
  39.  
  40.         // support for org_geoprisma_option_Option values
  41.         if (is_object($pstrValue)
  42.             && get_class($pstrValue== "org_geoprisma_option_Option"
  43.         
  44.         {
  45.             $pstrType $pstrValue->getName();
  46.             $pstrValue $pstrValue->getValue();
  47.         }
  48.         
  49.         if (is_array($pstrValue|| is_object($pstrValue)) 
  50.         {
  51.             $strSubType null;
  52.  
  53.             if (strtolower(substr($pstrType-1)) == 's'
  54.             {
  55.                 $strSubType substr($pstrType0-1);
  56.             }
  57.  
  58.             $objDomElement $pobjDomDocument->createElement($pstrType);
  59.             foreach ($pstrValue as $strArrayKey => $strArrayValue
  60.             {
  61.                 if (is_numeric($strArrayKey&& $strSubType
  62.                 {
  63.                     $objChildDomElement $this->getDomElements(
  64.                         $strSubType$strArrayValue$pobjDomDocument
  65.                     );
  66.                 else {
  67.                     $objChildDomElement $this->getDomElements(
  68.                         $strArrayKey$strArrayValue$pobjDomDocument
  69.                     );
  70.                 }
  71.  
  72.                 $objDomElement->appendChild($objChildDomElement);
  73.             }
  74.         else {
  75.             $objDomElement $pobjDomDocument->createElement(
  76.                 $pstrType$pstrValue
  77.             );
  78.         }
  79.  
  80.         return $objDomElement;
  81.     }
  82.  
  83.     /**
  84.     * Given an array of records (that were fetched from sql requests, xml to
  85.     *     array conversion, etc.), validate that the elements are correctly
  86.     *     formated.
  87.     *
  88.     * DEPRECATED
  89.     *
  90.     * @param array $pobjArray The config element array
  91.     * 
  92.     * @return array 
  93.     */
  94.     public function getConfigElements(array $pobjArray
  95.     {
  96.         $pobjArrayMainKeys array_keys($pobjArray);
  97.         $pobjArrayValues $pobjArray[$pobjArrayMainKeys[0]];
  98.  
  99.         if (count($pobjArrayValues== && is_array($pobjArrayValues)) 
  100.         {
  101.             $objArrayKeys array_keys($pobjArrayValues);
  102.  
  103.             if (!is_int($objArrayKeys[0])
  104.                 && is_array($pobjArrayValues[$objArrayKeys[0]])
  105.             
  106.             {
  107.                 $objArrayChildKeys array_keys($pobjArrayValues[$objArrayKeys[0]]);
  108.                 if (is_int($objArrayChildKeys[0])) 
  109.                 {
  110.                     $pobjArray[$pobjArrayMainKeys[0]]
  111.                         = $pobjArrayValues[$objArrayKeys[0]];
  112.                 }
  113.             }
  114.         }
  115.  
  116.         return $pobjArray;
  117.     }
  118. }
  119.   
  120. ?>

Documentation generated on Mon, 20 Feb 2012 13:46:10 -0500 by phpDocumentor 1.4.1