/**
  * Create a new language line instance.
  *
  * <code>
  *		// Create a new language line instance for a given line
  *		$line = Lang::line('validation.required');
  *
  *		// Create a new language line for a line belonging to a bundle
  *		$line = Lang::line('admin::messages.welcome');
  *
  *		// Specify some replacements for the language line
  *		$line = Lang::line('validation.required', array('attribute' => 'email'));
  * </code>
  *
  * @param  string  $key
  * @param  array   $replacements
  * @param  string  $language
  * @return Lang
  */
 public static function line($key, $replacements = array(), $language = null)
 {
     if (is_null($language)) {
         $language = Config::get('application.language');
     }
     return new static($key, $replacements, $language);
 }
Beispiel #2
0
 /**
  * Render the view.
  *
  * @return string
  * @throws \Exception
  */
 public function render()
 {
     // Events
     Event::fire("laravel.composing: {$this->view}", array($this));
     // Buffer the output
     ob_start();
     try {
         // array of paths where to find the views
         $paths = Config::get('weed::weed.paths');
         // build the Twig object
         $loader = new Twig\Weed\Loader\Filesystem($paths);
         // define the Twig environment
         $config = array('cache' => Config::get('weed::weed.cache'), 'debug' => Config::get('weed::weed.debug'), 'auto_reload' => Config::get('weed::weed.auto_reload'));
         $twig = new \Twig_Environment($loader, $config);
         // register the desired extensions
         foreach (Config::get('weed::weed.extensions') as $extension) {
             $twig->addExtension(new $extension());
         }
         // output the rendered template :-)
         echo $twig->render($this->template, $this->data());
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ob_get_clean();
 }
Beispiel #3
0
 /**
  * Create a new cache driver instance.
  *
  * @param  string  $driver
  * @return Cache\Drivers\Driver
  */
 protected static function factory($driver)
 {
     if (isset(static::$registrar[$driver])) {
         $resolver = static::$registrar[$driver];
         return $resolver();
     }
     switch ($driver) {
         case 'apc':
             return new Cache\Drivers\APC(Config::get('cache.key'));
         case 'file':
             return new Cache\Drivers\File(path('storage') . 'cache' . DS);
         case 'memcached':
             return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key'));
         case 'memory':
             return new Cache\Drivers\Memory();
         case 'redis':
             return new Cache\Drivers\Redis(Redis::db());
         case 'database':
             return new Cache\Drivers\Database(Config::get('cache.key'));
         case 'wincache':
             return new Cache\Drivers\WinCache(Config::get('cache.key'));
         default:
             throw new \Exception("Cache driver {$driver} is not supported.");
     }
 }
Beispiel #4
0
 public static function sessioninit()
 {
     // See if we have passed in a access_token and an account id.
     if (Input::get('access_token') && Input::get('account_id')) {
         $access_token = Input::get('access_token');
         $account_id = Input::get('account_id');
     } else {
         // See if we have a session. If Not do something about it.
         if (!Session::get('AccountId') || !Session::get('AccessToken')) {
             die(header('location: ' . Config::get('site.login_url')));
         }
         $access_token = Session::get('AccessToken');
         $account_id = Session::get('AccountId');
     }
     // Is this a multi tenant setup? If so set the account.
     if (Config::get('cloudmanic.account')) {
         if (!(self::$account = \Accounts::get_by_id($account_id))) {
             $data = array('status' => 0, 'errors' => array());
             $data['errors'][] = 'Account not found.';
             return \Laravel\Response::json($data);
         }
     }
     // Validate the access_token
     if (!($user = Users::get_by_access_token($access_token))) {
         $data = array('status' => 0, 'errors' => array());
         $data['errors'][] = 'Access token not valid.';
         return \Laravel\Response::json($data);
     } else {
         self::_do_user($user);
     }
 }
Beispiel #5
0
 public static function getFields($model)
 {
     $excluded = Config::get('Adminify::settings.fields');
     if (!isset($excluded[$model])) {
         return $excluded['all'];
     }
     return array_merge($excluded['all'], $excluded[$model]);
 }
Beispiel #6
0
 /**
  * Get a module renderer driver instance.
  *
  * @param  string  $driver
  * 
  * @return Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('admin::renderer.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }
Beispiel #7
0
 /**
  * Get files for comparision editing
  *
  * @param string $name
  * @param string $location
  * @param string $translation
  * @return array
  */
 public static function get_files($name, $location, $translation)
 {
     $path = \Laravel\Bundle::path($location);
     if (!is_file($path . 'language/' . $translation . '/' . $name . '.php')) {
         return null;
     }
     $language['from'] = (require $path . 'language/' . \Laravel\Config::get('language-builder::builder.base_lang') . '/' . $name . '.php');
     $language['to'] = (require $path . 'language/' . $translation . '/' . $name . '.php');
     return $language;
 }
Beispiel #8
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->config = Config::get('thirdparty_assetcompressor::assetcompressor');
     $this->config['cache_dir'] = $this->config['cache_dir'] . '/';
     $this->config['cache_dir_path'] = path('public') . $this->config['cache_dir'];
     if (!is_dir($this->config['cache_dir_path'])) {
         mkdir($this->config['cache_dir_path']);
     }
 }
Beispiel #9
0
 /**
  * Get a API driver instance.
  *
  * If no driver name is specified, the default will be returned.
  *
  * <code>
  *		// Get the default API driver instance
  *		$driver = API::driver();
  *
  *		// Get a specific API driver instance by name
  *		$driver = API::driver('mysql');
  * </code>
  *
  * @param  string        $driver
  * @return API\Drivers\Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('layla.' . static::$component . '.api.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }
Beispiel #10
0
 /**
  * Get a DBManager driver instance.
  *
  * If no driver name is specified, the default will be returned.
  *
  * <code>
  *		// Get the default DBManager driver instance
  *		$driver = DBManager::driver();
  *
  *		// Get a specific DBManager driver instance by name
  *		$driver = DBManager::driver('mysql');
  * </code>
  *
  * @param  string        $driver
  * @return DBManager\Drivers\Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('database.connections.' . Config::get('database.default') . '.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }
 public static function db($name = 'default')
 {
     if (!isset(static::$databases[$name])) {
         if (is_null($config = Config::get("database.redis.{$name}"))) {
             throw new \Exception("Redis database [{$name}] is not defined.");
         }
         extract($config);
         static::$databases[$name] = new static($host, $port, $database);
     }
     return static::$databases[$name];
 }
Beispiel #12
0
 /**
  * Get the user from the database table.
  *
  * @param  array  $arguments
  * @return mixed
  */
 protected function get_user($arguments)
 {
     $table = Config::get('auth.table');
     return DB::table($table)->where(function ($query) use($arguments) {
         $username = Config::get('auth.username');
         $query->where($username, '=', $arguments['username']);
         foreach (array_except($arguments, array('username', 'password', 'remember')) as $column => $val) {
             $query->where($column, '=', $val);
         }
     })->first();
 }
Beispiel #13
0
 /**
  * Get a language specific line
  *
  * @param string $key   The Key to search
  * @param array  $subst array The values to substitute
  * @param string $lang  string The language
  *
  * @return string
  */
 public function t($key, $subst = null, $lang = null)
 {
     if (is_null($lang)) {
         $lang = Config::get('application.language', 'en_US');
     }
     if (is_null($subst)) {
         return Lang::line($key, array())->get($lang);
     } else {
         parse_str($subst, $repl);
         return Lang::line($key, $repl)->get($lang);
     }
 }
Beispiel #14
0
 public static function listData()
 {
     $allGroup = Group::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('group_name' => Str::upper(Lang::line('admin.datagroup')->get())));
     $datagrid->setAction(Lang::line('global.manage')->get(), 'datacontent', false);
     $datagrid->setAction(Lang::line('global.edit')->get(), 'editGroup', true, array('dmid'));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteGroup', true, array('dmid', 'group_name'));
     $datagrid->setTable('dataGroup', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allGroup, 'dmid');
     return $datagrid->render();
 }
Beispiel #15
0
 /**
  * Sweep the expired sessions from storage.
  *
  * @param  array  $arguments
  * @return void
  */
 public function sweep($arguments = array())
 {
     $driver = Session::factory(Config::get('session.driver'));
     // If the driver implements the "Sweeper" interface, we know that it
     // can sweep expired sessions from storage. Not all drivers need be
     // sweepers since they do their own.
     if ($driver instanceof Sweeper) {
         $lifetime = Config::get('session.lifetime');
         $driver->sweep(time() - $lifetime * 60);
     }
     echo "The session table has been swept!";
 }
Beispiel #16
0
 public static function listRole()
 {
     $rolelist = Role::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('role' => Str::upper(Lang::line('admin.rolename')->get()), 'roledesc' => Str::upper(Lang::line('admin.roledesc')->get())));
     $datagrid->setAction(Lang::line('global.edit')->get(), 'editRoleModal', true, array('roleid'));
     //false,array('id'=>'roleid','data-toggle'=>'modal'));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteRole', true, array('roleid'));
     $datagrid->setContainer('list01', 'span12');
     $datagrid->setTable('users', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($rolelist, 'roleid');
     return $datagrid->render();
 }
Beispiel #17
0
 public function __construct()
 {
     $this->server = Config::get('mail::smtp.server');
     $this->port = Config::get('mail::smtp.port');
     $this->encryption = Config::get('mail::smtp.encryption');
     $this->username = Config::get('mail::smtp.username');
     $this->password = Config::get('mail::smtp.password');
     $this->realname = Config::get('mail::smtp.realname');
     $this->transport = Swift_SmtpTransport::newInstance($this->server, $this->port, $this->encryption)->setUsername($this->username)->setPassword($this->password);
     $this->mailer = Swift_Mailer::newInstance($this->transport);
     $this->message = Swift_Message::newInstance();
     // Set default sender.
     $this->message->setFrom(array($this->username => $this->realname));
 }
Beispiel #18
0
 /**
  * Get a database connection.
  *
  * If no database name is specified, the default connection will be returned.
  *
  * <code>
  *		// Get the default database connection for the application
  *		$connection = DB::connection();
  *
  *		// Get a specific connection by passing the connection name
  *		$connection = DB::connection('mysql');
  * </code>
  *
  * @param  string      $connection
  * @return Database\Connection
  */
 public static function connection($connection = null)
 {
     if (is_null($connection)) {
         $connection = Config::get('database.default');
     }
     if (!isset(static::$connections[$connection])) {
         $config = Config::get("database.connections.{$connection}");
         if (is_null($config)) {
             throw new \Exception("Database connection is not defined for [{$connection}].");
         }
         static::$connections[$connection] = new Connection(static::connect($config), $config);
     }
     return static::$connections[$connection];
 }
Beispiel #19
0
 /**
  * Open a HTML form.
  *
  * If PUT or DELETE is specified as the form method, a hidden input field will be generated
  * containing the request method. PUT and DELETE are not supported by HTML forms, so the
  * hidden field will allow us to "spoof" PUT and DELETE requests.
  *
  * Unless specified, the "accept-charset" attribute will be set to the application encoding.
  *
  * <code>
  *		// Open a "POST" form to the current request URI
  *		echo Form::open();
  *
  *		// Open a "POST" form to a given URI
  *		echo Form::open('user/profile');
  *
  *		// Open a "PUT" form to a given URI
  *		echo Form::open('user/profile', 'put');
  *
  *		// Open a form that has HTML attributes
  *		echo Form::open('user/profile', 'post', array('class' => 'profile'));
  * </code>
  *
  * @param  string   $action
  * @param  string   $method
  * @param  array    $attributes
  * @param  bool     $https
  * @return string
  */
 public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
 {
     $method = strtoupper($method);
     $attributes['method'] = static::method($method);
     $attributes['action'] = static::action($action, $https);
     if (!array_key_exists('accept-charset', $attributes)) {
         $attributes['accept-charset'] = Config::get('application.encoding');
     }
     $append = '';
     if ($method == 'PUT' or $method == 'DELETE') {
         $append = static::hidden(Request::spoofer, $method);
     }
     return '<form' . HTML::attributes($attributes) . '>' . $append . PHP_EOL;
 }
Beispiel #20
0
 public static function listFlow()
 {
     $allFlow = Flow::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('flowname' => 'Flow'));
     $datagrid->setFields(array('created_at' => 'Created'));
     $datagrid->setFields(array('updated_at' => 'Updated'));
     $datagrid->setAction('edit', 'editFlowModal', true, array('flowid'));
     // $datagrid->setAction('delete','deleteRole',true,array('userid'));
     $datagrid->setAction('step', 'step');
     $datagrid->setTable('flows', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allFlow, 'flowid');
     return $datagrid->render();
 }
 /**
  * Create a new cache driver instance.
  *
  * @param  string  $driver
  * @return Driver
  */
 protected static function factory($driver)
 {
     switch ($driver) {
         case 'apc':
             return new Drivers\APC(Config::get('cache.key'));
         case 'file':
             return new Drivers\File(CACHE_PATH);
         case 'memcached':
             return new Drivers\Memcached(Memcached::instance(), Config::get('cache.key'));
         case 'redis':
             return new Drivers\Redis(Redis::db());
         default:
             throw new \DomainException("Cache driver {$driver} is not supported.");
     }
 }
Beispiel #22
0
 /**
  * Get the rendered contents of the Profiler.
  *
  * @param  Response  $response
  * @return string
  */
 public static function render($response)
 {
     // We only want to send the profiler toolbar if the request is not an AJAX
     // request, as sending it on AJAX requests could mess up JSON driven API
     // type applications, so we will not send anything in those scenarios.
     if (!Request::ajax() and Config::get('application.profiler')) {
         static::$data['memory'] = get_file_size(memory_get_usage(true));
         static::$data['memory_peak'] = get_file_size(memory_get_peak_usage(true));
         static::$data['time'] = number_format((microtime(true) - LARAVEL_START) * 1000, 2);
         foreach (static::$data['timers'] as &$timer) {
             $timer['running_time'] = number_format((microtime(true) - $timer['start']) * 1000, 2);
         }
         return render('path: ' . __DIR__ . '/template' . BLADE_EXT, static::$data);
     }
 }
Beispiel #23
0
 /**
  * Create a new authentication driver instance.
  *
  * @param  string  $driver
  * @return Driver
  */
 protected static function factory($driver)
 {
     if (isset(static::$registrar[$driver])) {
         $resolver = static::$registrar[$driver];
         return $resolver();
     }
     switch ($driver) {
         case 'fluent':
             return new Auth\Drivers\Fluent(Config::get('auth.table'));
         case 'eloquent':
             return new Auth\Drivers\Eloquent(Config::get('auth.model'));
         default:
             throw new \Exception("Auth driver {$driver} is not supported.");
     }
 }
Beispiel #24
0
 public static function listSteps($flowid)
 {
     $flowSteps = Step::left_join('users_roles AS r', 'flows_steps.roleid', '=', 'r.roleid')->where('flowid', '=', $flowid)->paginate(Config::get('system.pagination'), array('r.role', 'flows_steps.*'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('step' => 'Step'));
     $datagrid->setFields(array('role' => 'Action By'));
     $datagrid->setFields(array('next' => 'Next Action'));
     $datagrid->setFields(array('condition1' => 'Condition Action 1'));
     $datagrid->setFields(array('condition2' => 'Condition Action 2'));
     $datagrid->setAction('edit', 'editStep', true, array('stepid'));
     $datagrid->setAction('delete', 'deleteStep', true, array('stepid'));
     $datagrid->setTable('steps', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($flowSteps, 'stepid');
     return $datagrid->render();
 }
Beispiel #25
0
 public static function userSearchList($input)
 {
     $operator = stripos($input['searchval'], '*') ? 'LIKE' : '=';
     $val = str_replace("*", "", $input['searchval']);
     $refval = stripos($input['searchval'], '*') ? '%' . $val . '%' : $val;
     $allUser = User::left_join('users_profiles', 'users.userid', '=', 'users_profiles.userid')->where('icno', $operator, $refval)->or_where('fullname', $operator, $refval)->paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('userprofile/fullname' => Str::upper(Str::title(Lang::line('admin.fullname')->get()))));
     $datagrid->setFields(array('userprofile/emel' => Str::upper(Str::title(Lang::line('admin.activeemel')->get()))));
     $datagrid->setFields(array('userprofile/icno' => Str::upper(Str::title(Lang::line('admin.idno')->get()))));
     $datagrid->setFields(array('status' => Str::upper('Status')));
     $datagrid->setAction(Lang::line('global.edit')->get(), 'viewUser', true, array('userid'));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteAccount', true, array('userid'));
     $datagrid->setAction(Lang::line('global.reset')->get(), 'resetAccount', true, array('userid'));
     $datagrid->setTable('users', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allUser, 'userid');
     return $datagrid->render();
 }
 /**
  * Attempt to log a user into the application.
  *
  * @param  array $arguments
  * @return void
  */
 public function attempt($arguments = array())
 {
     $user = $this->model()->where(function ($query) use($arguments) {
         $username = Config::get('admin::auth.username');
         $query->where($username, '=', $arguments['username']);
         foreach (array_except($arguments, array('username', 'password', 'remember')) as $column => $val) {
             $query->where($column, '=', $val);
         }
     })->first();
     // If the credentials match what is in the database we will just
     // log the user into the application and remember them if asked.
     $password = $arguments['password'];
     $password_field = Config::get('admin::auth.password', 'password');
     if (!is_null($user) and Hash::check($password, $user->{$password_field})) {
         return $this->login($user->get_key(), array_get($arguments, 'remember'));
     }
     return false;
 }
Beispiel #27
0
 /**
  * "Forward" the request
  * 
  * This driver is great for a single server install,
  * and when debugging your application.
  * 
  * @param string 	$method 	GET, POST, PUT, DELETE, etc.
  * @param array 	$segments 	for example array('account', 'all')
  * @param array 	$data 		the post / put data
  */
 public static function request($method, $segments, $data = array())
 {
     $method = strtoupper($method);
     if (in_array($method, array('GET', 'POST', 'PUT', 'DELETE'))) {
         Input::replace($data);
     }
     $config = static::config();
     $_SERVER['PHP_AUTH_USER'] = $config['username'];
     $_SERVER['PHP_AUTH_PW'] = $config['password'];
     list($url, $uri, $query_string) = static::url($segments, $data);
     $prefix = Config::get('layla.domain.url_prefix');
     if (!is_null($prefix)) {
         $prefix .= '/';
     }
     $response = Route::forward($method, $prefix . $uri);
     $code = $response->foundation->getStatusCode();
     $body = $response->content;
     return new Response($code, json_decode($body));
 }
 /**
  * Generate Data datagrid table
  *
  * @return void
  * @author 
  **/
 public static function genListData()
 {
     $allContent = Content::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $tableCol = DB::query('show columns from ' . Content::$table);
     foreach ($tableCol as $value) {
         if ($value->field != 'created_at' && $value->field != 'updated_at' && $value->field != Content::$key) {
             if (stristr($value->field, 'name')) {
                 $title = Str::upper(Lang::line('global.data')->get());
             } elseif (stristr($value->field, 'desc')) {
                 $title = Str::upper(Lang::line('global.desc')->get());
             } else {
                 $title = $value->field;
             }
             $datagrid->setFields(array($value->field => $title));
         }
     }
     $datagrid->setAction(Lang::line('global.edit')->get(), 'editData', true, array(Content::$key));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteData', true, array(Content::$key));
     $datagrid->setTable('contentGroup', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allContent, Content::$key);
     return $datagrid->render();
 }
 /**
  * Creates a %CKEditor instance.
  * In incompatible browsers %CKEditor will downgrade to plain HTML &lt;textarea&gt; element.
  *
  * @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element).
  * @param $value (string) Initial value (optional).
  * @param $config (array) The specific configurations to apply to this editor instance (optional).
  * @param $events (array) Event listeners for this editor instance (optional).
  *
  * Example usage:
  * @code
  * $CKEditor = new CKEditor();
  * $CKEditor->editor("field1", "<p>Initial value.</p>");
  * @endcode
  *
  * Advanced example:
  * @code
  * $CKEditor = new CKEditor();
  * $config = array();
  * $config['toolbar'] = array(
  *     array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
  *     array( 'Image', 'Link', 'Unlink', 'Anchor' )
  * );
  * $events['instanceReady'] = 'function (ev) {
  *     alert("Loaded: " + ev.editor.name);
  * }';
  * $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
  * @endcode
  */
 public function editor($name, $value = "", $config = array(), $events = array())
 {
     $attr = "";
     foreach ($this->textareaAttributes as $key => $val) {
         $attr .= " " . $key . '="' . str_replace('"', '&quot;', $val) . '"';
     }
     $out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n";
     if (!$this->initialized) {
         $out .= $this->init();
     }
     if ($this->KCFinder) {
         $config = array_merge($config, \Laravel\Config::get('ckeditor::config.kcfinder.paths'));
         // Add KCFinder paths
     }
     $_config = $this->configSettings($config, $events);
     $js = $this->returnGlobalEvents();
     if (!empty($_config)) {
         $js .= "CKEDITOR.replace('" . $name . "', " . $this->jsEncode($_config) . ");";
     } else {
         $js .= "CKEDITOR.replace('" . $name . "');";
     }
     $out .= $this->script($js);
     if (!$this->returnOutput) {
         print $out;
         $out = "";
     }
     return $out;
 }
Beispiel #30
0
 /**
  * Retrieves the settings from the config file
  */
 private static function loadConfig()
 {
     static::$cache_path = Config::get('cache_path', '');
     static::$cache_lifetime = Config::get('cache_lifetime', 0);
 }