function normalize_driver_types()
 {
     // get the drivers configured
     \Config::load('auth', true);
     $drivers = \Config::get('auth.driver', array());
     is_array($drivers) or $drivers = array($drivers);
     $results = array();
     foreach ($drivers as $driver) {
         // determine the driver classname
         $class = \Inflector::get_namespace($driver) . 'Auth_Login_' . \Str::ucwords(\Inflector::denamespace($driver));
         // Auth's Simpleauth
         if ($class == 'Auth_Login_Simpleauth' or $class == 'Auth\\Auth_Login_Simpleauth') {
             $driver = 'Simpleauth';
         } elseif ($class == 'Auth_Login_Ormauth' or $class == 'Auth\\Auth_Login_Ormauth') {
             $driver = 'Ormauth';
         } elseif (class_exists($class)) {
             // Extended fromm Auth's Simpleauth
             if (get_parent_class($class) == 'Auth\\Auth_Login_Simpleauth') {
                 $driver = 'Simpleauth';
             } elseif (get_parent_class($class) == 'Auth\\Auth_Login_Ormauth') {
                 $driver = 'Ormauth';
             }
         }
         // store the normalized driver name
         in_array($driver, $results) or $results[] = $driver;
     }
     return $results;
 }
Пример #2
0
 /**
  * Takes an underscore or dash separated word and turns it into a human looking title.
  *
  * @param string $string    The string to titleize.
  * @param string $separator The separator (either _ or -).
  * @param bool   $ucwords   Whether or not to capitalize the first letter of every word.
  * 
  * @return string
  */
 public static function titleize($string, $separator = '_', $ucwords = true)
 {
     $string = str_replace($separator, ' ', strval($string));
     if ($ucwords) {
         $string = Str::ucwords($string);
     }
     return $string;
 }
Пример #3
0
 /**
  * Gets a new instance of gateway $class_name.
  *
  * @param Model_Gateway  $gateway    The gateway model to use for the driver.
  * @param Model_Customer $customer   The customer model to use for the driver.
  * @param string         $class_name The class name to call on the driver.
  *
  * @return Gateway_Model
  */
 public static function forge(Model_Gateway $gateway, Model_Customer $customer = null, $class_name)
 {
     $driver_name = str_replace('Gateway_', '', get_called_class());
     $driver_name = str_replace('_Driver', '', $driver_name);
     $class = 'Gateway_' . Str::ucwords(Inflector::denamespace($driver_name)) . '_' . Str::ucwords(Inflector::denamespace($class_name));
     if (!class_exists($class)) {
         throw new GatewayException('Call to undefined class ' . $class);
     }
     $driver = Gateway::instance($gateway, $customer);
     return new $class($driver);
 }
Пример #4
0
 /**
  * Gets a new instance of gateway driver class.
  *
  * @param Model_Gateway  $gateway  The gateway model to use (for gateway auth and such).
  * @param Model_Customer $customer The customer model to use.
  *
  * @return Gateway_Driver|bool
  */
 public static function forge(Model_Gateway $gateway, Model_Customer $customer = null)
 {
     $driver_name = $gateway->processor;
     $class = 'Gateway_' . Str::ucwords(Inflector::denamespace($driver_name)) . '_Driver';
     if (!class_exists($class)) {
         return false;
     }
     $driver = new $class($gateway, $customer);
     static::$_instances[$driver_name] = $driver;
     is_null(static::$_instance) and static::$_instance = $driver;
     return $driver;
 }
Пример #5
0
 public static function forge(array $config = array())
 {
     // default driver id to driver name when not given
     !array_key_exists('id', $config) && ($config['id'] = $config['driver']);
     $class = \Inflector::get_namespace($config['driver']) . 'Auth_Login_' . \Str::ucwords(\Inflector::denamespace($config['driver']));
     $driver = new $class($config);
     static::$_instances[$driver->get_id()] = $driver;
     is_null(static::$_instance) and static::$_instance = $driver;
     foreach ($driver->get_config('drivers', array()) as $type => $drivers) {
         foreach ($drivers as $d => $custom) {
             $custom = is_int($d) ? array('driver' => $custom) : array_merge($custom, array('driver' => $d));
             $class = 'Auth_' . \Str::ucwords($type) . '_Driver';
             $class::forge($custom);
         }
     }
     return $driver;
 }
Пример #6
0
 /**
  * Init
  *
  * Initialise breadcrumb based on URI segments
  *
  * @access	protected
  * @return	void
  */
 protected static function initialise()
 {
     $home = \Config::get('breadcrumb.home', static::$home);
     $use_lang = \Config::get('breadcrumb.use_lang', static::$use_lang);
     static::set($home['name'], $home['link']);
     $segments = \Uri::segments();
     $link = '';
     foreach ($segments as $segment) {
         if (preg_match('/^([0-9])+$/', $segment) > 0 or $segment === 'index') {
             continue;
         }
         $link .= '/' . $segment;
         if ($use_lang === true) {
             static::set(\Lang::get($segment), $link);
         } else {
             static::set(\Str::ucwords(str_replace('_', ' ', $segment)), $link);
         }
     }
 }
Пример #7
0
 /**
  * Get Original Value
  * 
  * Gets the original value of
  * the header, as specified by
  * the user
  * 
  * @access	public
  * @return	string	Original value
  */
 public function get_original_value()
 {
     // Lazy load the original value
     if (!$this->_original_value) {
         // Lazy set the header
         if (!$this->has_data('header')) {
             // Make the header
             $header = \Str::ucwords(str_replace('_', ' ', $this->get_column()->get_identifier()));
             // Change fields just to
             // look more English proper
             switch ($header) {
                 case 'Id':
                     $header = 'ID';
                     break;
             }
             $this->set_data('header', $header);
         }
         // Set the modified header metadata to the orginal
         // value property
         $this->_original_value = $this->get_data('header');
     }
     return $this->_original_value;
 }
Пример #8
0
 /**
  * Always load packages, modules, classes, config & language files set in always_load.php config
  *
  * @param
  *        	array what to autoload
  */
 public static function always_load($array = null)
 {
     is_null($array) and $array = \Config::get('always_load', array());
     isset($array['packages']) and \Package::load($array['packages']);
     isset($array['modules']) and \Module::load($array['modules']);
     if (isset($array['classes'])) {
         foreach ($array['classes'] as $class) {
             if (!class_exists($class = \Str::ucwords($class))) {
                 throw new \FuelException('Class ' . $class . ' defined in your "always_load" config could not be loaded.');
             }
         }
     }
     /**
      * Config and Lang must be either just the filename, example: array(filename)
      * or the filename as key and the group as value, example: array(filename => some_group)
      */
     if (isset($array['config'])) {
         foreach ($array['config'] as $config => $config_group) {
             \Config::load(is_int($config) ? $config_group : $config, is_int($config) ? true : $config_group);
         }
     }
     if (isset($array['language'])) {
         foreach ($array['language'] as $lang => $lang_group) {
             \Lang::load(is_int($lang) ? $lang_group : $lang, is_int($lang) ? true : $lang_group);
         }
     }
 }
Пример #9
0
echo $singular;
?>
 #' . $<?php 
echo $singular;
?>
->id . '.');

				Response::redirect('<?php 
echo $controller_uri;
?>
');
			}

			else
			{
				Session::set_flash('notice', 'Could not save <?php 
echo $singular;
?>
.');
			}
		}

		$this->template->title = "<?php 
echo \Str::ucwords($plural);
?>
";
		$this->template->content = View::forge('<?php 
echo $controller_uri;
?>
/create');
Пример #10
0
echo $singular_name;
?>
->id.'.'));
					Response::redirect('<?php 
echo $uri;
?>
');
				}
				else
				{
					Session::set_flash('error', e('Could not save <?php 
echo $singular_name;
?>
.'));
				}
			}
			else
			{
				Session::set_flash('error', $val->error());
			}
		}

		$this->template->title = "<?php 
echo \Str::ucwords($plural_name);
?>
";
		$this->template->content = View::forge('<?php 
echo $view_path;
?>
/create');
Пример #11
0
 /**
  * Retrieve a loaded driver instance
  * (loading must be done by other driver class)
  *
  * @param   string       driver type
  * @param   string|true  driver id or true for an array of all loaded drivers
  * @return  Auth_Driver|array
  */
 protected static function _driver_instance($type, $instance)
 {
     $class = 'Auth_' . \Str::ucwords($type) . '_Driver';
     return $class::instance($instance);
 }
Пример #12
0
 /**
  * Test for Str::ucwords()
  *
  * @test
  */
 public function test_ucwords()
 {
     $output = Str::ucwords('hello world');
     $expected = "Hello World";
     $this->assertEquals($expected, $output);
 }
Пример #13
0
<?php

$processor = Str::ucwords($gateway->processor);
$layout->title = 'Edit';
$layout->subtitle = $processor;
$layout->breadcrumbs['Settings'] = 'settings';
$layout->breadcrumbs['Gateways'] = 'settings/gateways';
$layout->breadcrumbs['Edit: ' . $processor] = '';
$types = array();
foreach (Arr::get($config, 'types') as $type) {
    $types[$type] = Inflector::titleize($type);
}
$processors = array();
foreach (Arr::get($config, 'processors') as $processor) {
    $processors[$processor] = Inflector::titleize($processor);
}
?>

<?php 
echo Form::open(array('class' => 'form-horizontal form-validate'));
?>
	<div class="control-group<?php 
if (!empty($errors['type'])) {
    echo ' error';
}
?>
">
		<?php 
echo Form::label('Type', 'type', array('class' => 'control-label'));
?>
		<div class="controls">