Source for file prefix.php

Documentation is available at prefix.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.  * Form Field class for the Joomla Framework.
  13.  *
  14.  * @package  Joomla.Installation
  15.  * @since    1.6
  16.  */
  17. class JFormFieldPrefix extends JFormField
  18. {
  19.     /**
  20.      * The form field type.
  21.      *
  22.      * @var        string 
  23.      * @since   1.6
  24.      */
  25.     protected $type = 'Prefix';
  26.  
  27.     /**
  28.      * Method to get the field input markup.
  29.      *
  30.      * @return  string    The field input markup.
  31.      *
  32.      * @since   1.6
  33.      */
  34.     protected function getInput()
  35.     {
  36.         // Initialize some field attributes.
  37.         $size        $this->element['size'abs((int) $this->element['size']5;
  38.         $maxLength    $this->element['maxlength'' maxlength="' . (int) $this->element['maxlength''"' '';
  39.         $class        $this->element['class'' class="' . (string) $this->element['class''"' '';
  40.         $readonly    ((string) $this->element['readonly'== 'true'' readonly="readonly"' '';
  41.         $disabled    ((string) $this->element['disabled'== 'true'' disabled="disabled"' '';
  42.  
  43.         // Make sure somebody doesn't put in a too large prefix size value:
  44.         if ($size 10)
  45.         {
  46.             $size 10;
  47.         }
  48.  
  49.         // If a prefix is already set, use it instead
  50.         $session JFactory::getSession()->get('setup.options'array());
  51.         if (empty($session['db_prefix']))
  52.         {
  53.             // Create the random prefix:
  54.             $prefix '';
  55.             $chars range('a''z');
  56.             $numbers range(09);
  57.  
  58.             // We want the fist character to be a random letter:
  59.             shuffle($chars);
  60.             $prefix .= $chars[0];
  61.  
  62.             // Next we combine the numbers and characters to get the other characters:
  63.             $symbols array_merge($numbers$chars);
  64.             shuffle($symbols);
  65.  
  66.             for ($i 0$j $size 1$i $j++$i)
  67.             {
  68.                 $prefix .= $symbols[$i];
  69.             }
  70.  
  71.             // Add in the underscore:
  72.             $prefix .= '_';
  73.         }
  74.         else
  75.         {
  76.             $prefix $session['db_prefix'];
  77.         }
  78.  
  79.         // Initialize JavaScript field attributes.
  80.         $onchange    $this->element['onchange'' onchange="' . (string) $this->element['onchange''"' '';
  81.  
  82.         return '<input type="text" name="' $this->name . '" id="' $this->id . '"' .
  83.                 ' value="' htmlspecialchars($prefixENT_COMPAT'UTF-8''"' .
  84.                 $class $disabled $readonly $onchange $maxLength '/>';
  85.     }
  86. }

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