Source for file sample.php

Documentation is available at sample.php

  1. <?php
  2. /**
  3.  * @package    Joomla.Installation
  4.  *
  5.  * @copyright  Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  6.  * @license    GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8.  
  9. defined('JPATH_BASE'or die;
  10.  
  11.  
  12. /**
  13.  * Sample data Form Field class.
  14.  *
  15.  * @package  Joomla.Installation
  16.  * @since    1.6
  17.  */
  18. {
  19.     /**
  20.      * The form field type.
  21.      *
  22.      * @var        string 
  23.      * @since   1.6
  24.      */
  25.     protected $type = 'Sample';
  26.  
  27.     /**
  28.      * Method to get the field options.
  29.      *
  30.      * @return  array  The field option objects.
  31.      *
  32.      * @since   1.6
  33.      */
  34.     protected function getOptions()
  35.     {
  36.         $lang JFactory::getLanguage();
  37.         $options array();
  38.         $type $this->form->getValue('db_type');
  39.  
  40.         // Some database drivers share DDLs; point these drivers to the correct parent
  41.         if ($type == 'mysqli')
  42.         {
  43.             $type 'mysql';
  44.         }
  45.         elseif ($type == 'sqlsrv')
  46.         {
  47.             $type 'sqlazure';
  48.         }
  49.  
  50.         // Get a list of files in the search path with the given filter.
  51.         $files JFolder::files(JPATH_INSTALLATION '/sql/' $type'^sample.*\.sql$');
  52.  
  53.         // Add option to not install sample data.
  54.         $options[JHtml::_('select.option''',
  55.             JHtml::_('tooltip'JText::_('INSTL_SITE_INSTALL_SAMPLE_NONE_DESC')''''JText::_('INSTL_SITE_INSTALL_SAMPLE_NONE'))
  56.         );
  57.  
  58.         // Build the options list from the list of files.
  59.         if (is_array($files))
  60.         {
  61.             foreach ($files as $file)
  62.             {
  63.                 $options[JHtml::_('select.option'$file$lang->hasKey($key 'INSTL_' ($file JFile::stripExt($file)) '_SET'?
  64.                     JHtml::_('tooltip'JText::_('INSTL_' strtoupper($file JFile::stripExt($file)) '_SET_DESC')'''',
  65.                         JText::_('INSTL_' ($file JFile::stripExt($file)) '_SET')
  66.                     $file
  67.                 );
  68.             }
  69.         }
  70.  
  71.         // Merge any additional options in the XML definition.
  72.         $options array_merge(parent::getOptions()$options);
  73.  
  74.         return $options;
  75.     }
  76.  
  77.     /**
  78.      * Method to get the field input markup.
  79.      *
  80.      * @return  string    The field input markup.
  81.      *
  82.      * @since   1.6
  83.      */
  84.     protected function getInput()
  85.     {
  86.         if (!$this->value)
  87.         {
  88.             $conf JFactory::getConfig();
  89.  
  90.             if ($conf->get('sampledata'))
  91.             {
  92.                 $this->value = $conf->get('sampledata');
  93.             }
  94.             else
  95.             {
  96.                 $this->value = '';
  97.             }
  98.         }
  99.  
  100.         return parent::getInput();
  101.     }
  102. }

Documentation generated on Tue, 19 Nov 2013 15:12:35 +0100 by phpDocumentor 1.4.3