/**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     // dd(hash_file('crc32b', app_path('Support/helpers.php')));
     // hash_file(app_path(), filename);
     // dd(disk_free_space('/') / disk_total_space('/') * 100);
     function outputList($list)
     {
         $out = '<ul>';
         foreach ($list as $key => $value) {
             $out .= '<li class="' . (is_array($value) ? 'array' : 'string') . '">';
             $out .= '<h2 style="display:inline;">' . $key . '</h2> ';
             $out .= is_array($value) ? outputList($value) : $value;
             $out .= '</li>';
         }
         $out .= '</ul>';
         return $out;
     }
     // $trans = trans('copy.site.title');
     // $output = [];
     // foreach ($trans as $key => $value) {
     // 	$output[md5($key)] = $key;
     // }
     // return $output;
     // return $trans;
     $lang = ['passwords' => trans('passwords'), 'pagination' => trans('pagination'), 'validation' => trans('validation'), 'copy' => trans('copy')];
     $langDot = array_dot($lang);
     $langFinal = [];
     foreach ($langDot as $key => $value) {
         array_set($langFinal, $key, $value);
     }
     $langinfo = outputList($langFinal);
     return $this->view('welcome')->with('langinfo', $langinfo);
 }
Example #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $args = $this->argument();
     $opts = $this->option();
     $type = $args['type'] ?: 'app';
     $file = file_get_contents(__DIR__ . '/../../views/generators/angular/' . $type . '.js.stub');
     if ($type == 'app') {
         $name = $args['name'];
     } else {
         $name = $args['name'] . ucfirst(strtolower($type));
     }
     $data = array_dot(['namespace' => $args['name'], 'name' => $name, 'modules' => isset($opts['modules']) ? $opts['modules'] : '']);
     $file = Str::smrtr($file, $data, ['<%= ', ' %>']);
     if (!$args['folder']) {
         $args['folder'] = 'components';
     }
     $path = $opts['path'] . '/' . $args['folder'] . '/' . $args['name'] . '/';
     if (isset($opts['bench'])) {
         $path = 'workench/' . $opts['bench'] . '/public/src/js/';
     }
     if (!is_dir($path)) {
         mkdir($path, 0775, true);
     }
     $filepath = $path . $name . '.js';
     file_put_contents($filepath, $file);
     $this->info($filepath . ' created');
 }
 /** {@inheritDoc} */
 public function register()
 {
     /** @var \Illuminate\Foundation\Application $app */
     $app = parent::register();
     $config = array_dot($this->app['config']['blade_extensions']);
     if ($config['example_views'] === true) {
         $this->viewDirs = ['views' => 'blade-ext'];
     }
     AssignmentDirectives::attach($app);
     DebugDirectives::attach($app);
     ForeachDirectives::attach($app);
     EmbeddingDirectives::attach($app);
     MacroDirectives::attach($app);
     MinifyDirectives::attach($app);
     # Optional markdown compiler, engines and directives
     if ($config['markdown.enabled']) {
         if (!class_exists($config['markdown.renderer'])) {
             throw new Exception('The configured markdown renderer class does not exist');
         }
         $app->bind('Radic\\BladeExtensions\\Contracts\\MarkdownRenderer', $config['markdown.renderer']);
         $app->singleton('markdown', function (Application $app) {
             return $app->make('Radic\\BladeExtensions\\Contracts\\MarkdownRenderer');
         });
         $app->singleton('markdown.compiler', function (Application $app) {
             $markdownRenderer = $app->make('markdown');
             $files = $app->make('files');
             $storagePath = $app['config']->get('view.compiled');
             return new MarkdownCompiler($markdownRenderer, $files, $storagePath);
         });
         MarkdownDirectives::attach($app);
     }
 }
Example #4
0
 /**
  * getVars
  *
  * @param null $packageName
  * @return array
  */
 public function getGeneratorVars($directory)
 {
     $stubDir = $this->docit->config('stubs_path');
     $destDir = $this->docit->getRootDir() . DIRECTORY_SEPARATOR . $directory;
     $vars = ['config' => array_dot($this->docit->config()), 'open' => '<?php', 'stubDir' => $stubDir, 'destDir' => $destDir, 'directory' => $directory];
     return $vars;
 }
Example #5
0
 public function merge($items)
 {
     foreach (array_dot($items) as $key => $value) {
         $this->set($key, $value);
     }
     return $this;
 }
Example #6
0
 /**
  * Handler
  *
  * @param \Illuminate\Contracts\Mail\Mailer $mailer
  * @param \Illuminate\Contracts\View\Factory $view
  * @param \Illuminate\Contracts\Validation\Factory $validator
  * @throws \Exception
  * @return void
  */
 public function handle(Mailer $mailer, Factory $view, Validator $validator)
 {
     $queue = $this->messageQueue;
     $queue->status = 'in_processes';
     $queue->save();
     $queue->load('event', 'event.template');
     $parameters = array_merge_recursive($queue->event->template->parameters, $queue->event->parameters, $queue->parameters);
     $messageParameters = array_dot($this->getMessageParameters($validator, $parameters['message']));
     $renderView = $queue->event->template->getRender($parameters['view']);
     $mailer->send('message-sender::providers.plain', ['content' => $renderView], function ($message) use($parameters, $messageParameters) {
         $message->from($messageParameters['from.address'], $messageParameters['from.name']);
         $message->to($messageParameters['to.address'], $messageParameters['from.name']);
         $message->subject($parameters['provider']['subject']);
         if (isset($parameters['provider']['headers'])) {
             $mailHeaders = $message->getSwiftMessage()->getHeaders();
             foreach ($parameters['provider']['headers'] as $header) {
                 $mailHeaders->addTextHeader($header['name'], $header['value']);
             }
         }
     });
     if (count($mailer->failures()) > 0) {
         throw new \Exception('Mail send failed.');
     } else {
         $queue->status = 'sent';
         $queue->save();
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Filesystem $files)
 {
     $langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
     $diff = [];
     foreach (ModulesLoader::getRegisteredModules() as $module) {
         if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
             continue;
         }
         $locale = $this->input->getOption('locale');
         foreach ($files->directories($module->getLocalePath()) as $localeDir) {
             foreach ($files->allFiles($localeDir) as $localeFile) {
                 $vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
                 $vendorFilePath = $langDirectory . $vendorFileDir;
                 if (file_exists($vendorFilePath)) {
                     $localArray = $files->getRequire($localeFile->getRealPath());
                     $vendorArray = $files->getRequire($vendorFilePath);
                     $array = array_keys_exists_recursive($localArray, $vendorArray);
                     $arrayDiff = '';
                     foreach (array_dot($array) as $key => $value) {
                         $arrayDiff .= "{$key}: {$value}\n";
                     }
                     if (empty($arrayDiff)) {
                         continue;
                     }
                     $diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
                     $diff[] = new TableSeparator();
                     $diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
                     $diff[] = new TableSeparator();
                 }
             }
         }
     }
     $this->table($this->headers, $diff);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     if (!$this->isInstalled()) {
         $this->app['command.twostream.install'] = $this->app->share(function ($app) {
             return new Install($this->getAppNamespace());
         });
         return $this->commands(['command.twostream.install']);
     }
     parent::register();
     $this->app['command.twostream.listen'] = $this->app->share(function ($app) {
         return new Server($app);
     });
     $this->app['command.twostream.stop'] = $this->app->share(function ($app) {
         return new Stop();
     });
     $this->commands($this->commands);
     $this->mergeConfigFrom(__DIR__ . '/../config/twostream.php', 'twostream');
     $this->app->bindShared('CupOfTea\\TwoStream\\Contracts\\Factory', function ($app) {
         $config = array_dot($this->app['config']['twostream']);
         return new TwoStream($config);
     });
     $this->app->bindShared('CupOfTea\\TwoStream\\Contracts\\Session\\ReadOnly', function ($app) {
         return new ReadOnly($this->app['config']['session.cookie']);
     });
 }
Example #9
0
File: Engine.php Project: joadr/cms
 public function evaluateOne($text, $dependencies = [])
 {
     $parts = explode('>', $text);
     if (count($parts) < 2) {
         return '';
     }
     if ($parts[0] == 'Dict') {
         $default = '';
         $item = $this->getOneDict($parts[1], $default);
         if (count($parts) == 3) {
             $array = array_dot($item->toArray());
             if (!array_key_exists($parts[2], $array)) {
                 return '';
             }
             return $array[$parts[2]];
         }
         return $item;
     } else {
         $identifier = $parts[1];
         if (starts_with($identifier, ':')) {
             $identifier = str_replace(':', '', $identifier);
             $identifier = $dependencies[$identifier];
         }
         $item = $this->getOneEntity($parts[0], $identifier);
         if (!$item) {
             return '';
         }
         $array = array_dot($item->toArray());
         if (!array_key_exists($parts[2], $array)) {
             return '';
         }
         return $array[$parts[2]];
     }
 }
Example #10
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 403);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     if (!$request->user()->isAdmin() && $request->user()->cannot('dashboard_view')) {
         $this->auth->logout();
         return redirect()->guest('auth/login')->withErrors(trans('messages.permission_denied'));
     }
     $route_array = explode('.', $request->route()->getName());
     $permission_name = array_search($route_array[2], array_dot($this->permission_fields));
     if ($permission_name) {
         $route_array[2] = explode('.', $permission_name)[0];
     }
     // $route_name = implode('_', $route_array);
     $route_name = $route_array[1] . '_' . $route_array[2];
     if (!$request->user()->isAdmin() && $request->user()->cannot($route_name)) {
         //PATCH 为null
         if ($request->ajax()) {
             return response()->json(['status' => trans('messages.permission_denied'), 'type' => 'error', 'code' => 403]);
         } else {
             return view('errors.403');
         }
     }
     return $next($request);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     //
     $tutorials = objectToArray(DB::select(DB::raw('select id from tutorials')));
     $tutorials = array_dot($tutorials);
     $students = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id`  from `students`'))));
     $teachers = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id`  from `teachers`'))));
     $subjects = array_dot(objectToArray(DB::select(DB::raw('SELECT id from subjects'))));
     $minimum = $this->option('minimum');
     $assessmenttitle = "This is a {title|heading|header} for Assessment.";
     $assessmentdesc = "This is a sample {data|words|description} for Assessment.";
     for ($i = 1; $i <= $minimum; $i++) {
         $assessment = new Assessments();
         $assessment->title = self::spintax($assessmenttitle);
         $assessment->description = self::spintax($assessmentdesc);
         $assessment->assessmenttype = "presentation";
         $assessment->tutorialid = rand(1, 100);
         $assessment->teacherid = array_rand($teachers);
         $assessment->subjectid = rand(1, 55);
         $assessment->studentid = array_rand($students);
         $assessment->marks = rand(75, 100);
         $assessment->created_at = self::randDate('10th January 2013', date('jS F o'));
         $assessment->save();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function write(array $storage)
 {
     $storage = array_dot($storage);
     $update = array();
     // key-value pairs to be updated later
     $delete = array();
     // key-value pairs to be deleted later
     $keys = Setting::withTrashed()->lists('key');
     // existing keys
     // check what keys we have to update/create and which to delete
     foreach ($keys as $key) {
         if (isset($storage[$key])) {
             $update[$key] = $storage[$key];
         } else {
             $delete[] = $key;
         }
         unset($storage[$key]);
     }
     // $update now keeps only those key-value pairs which are to be updated
     foreach ($update as $key => $value) {
         Setting::withTrashed()->where('key', $key)->update(['value' => $value]);
         $setting = Setting::withTrashed()->where('key', $key)->first();
         if ($setting->trashed()) {
             $setting->restore();
         }
     }
     // $storage now keeps only those key-value pairs which are to be created
     foreach ($storage as $key => $value) {
         Setting::create(['key' => $key, 'value' => $value]);
     }
     // $delete now keeps only those key-value pairs which are to be deleted
     Setting::whereIn('key', $delete)->delete();
 }
 public function process(Request $request)
 {
     // Ajax-validation is only possible, if the _formID was submitted (automatically done by the FormBuilder).
     if (\Request::has('_formID')) {
         // The FormBuilder should have saved the requestObject this form uses inside the session.
         // We check, if it is there, and can continue only, if it is.
         $sessionKeyForRequestObject = 'htmlBuilder.formBuilder.requestObjects.' . \Request::input('_formID');
         if (Session::has($sessionKeyForRequestObject)) {
             // Normally we assume a successful submission and return just an empty JSON-array.
             $returnCode = 200;
             $return = [];
             // We instantiate the requestObject.
             $formRequest = FormBuilderTools::getRequestObject(Session::get($sessionKeyForRequestObject));
             // We instantiate a controller with the submitted request-data
             // and the rules and messages from the requestObject.
             $validator = Validator::make(\Request::all(), $formRequest->rules(), $formRequest->messages());
             // Perform validation, extract error-messages for all fields on failure, put them inside a $return['errors']-array, and return status code 422.
             if ($validator->fails()) {
                 $errors = [];
                 foreach (array_dot(\Request::all()) as $fieldName => $fieldValue) {
                     $fieldErrors = FormBuilderTools::extractErrorsForField($fieldName, $validator->errors()->getMessages(), \Request::all());
                     if (count($fieldErrors) > 0) {
                         $errors[FormBuilderTools::convertArrayFieldDotNotation2HtmlName($fieldName)] = $fieldErrors;
                     }
                 }
                 $return['errors'] = $errors;
                 $returnCode = 422;
             }
             return new JsonResponse($return, $returnCode);
         }
     }
 }
 public function postIndex(Request $request)
 {
     $trans = $request->all();
     $language = $this->language->where('locale', '=', $this->trans->locale())->first();
     if (!$language) {
         \App::abort();
     }
     foreach ($trans as $groupKey => $group) {
         if (is_array($group)) {
             $group = array_dot($group);
             foreach ($group as $key => $value) {
                 $entry = $language->entries()->where('group', '=', $groupKey)->where('item', '=', $key)->first();
                 if (!$entry) {
                     $language->entries()->create(['group' => $groupKey, 'item' => $key, 'text' => $value]);
                 } else {
                     $entry->text = $value;
                     if ($entry->isDirty()) {
                         $entry->save();
                     }
                 }
             }
         }
     }
     return redirect()->back()->withInput();
 }
Example #15
0
 public function run()
 {
     // we create the admin role
     $admin = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'admin', 'position' => 1]);
     // we translate the translatable fields
     $admin->translateOrNew('fr')->name = 'Administrateur';
     $admin->translateOrNew('en')->name = 'Administrator';
     // we give all permissions to the admin role
     $permissions = [];
     foreach (array_dot(config('permissions')) as $permission => $value) {
         $permissions[$permission] = true;
     }
     $admin->permissions = $permissions;
     // we save the changes
     $admin->save();
     // we create the moderator role
     $mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'moderator', 'position' => 2, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
     // we translate the translatable fields
     $mod->translateOrNew('fr')->name = 'Modérateur';
     $mod->translateOrNew('en')->name = 'Moderator';
     $mod->save();
     // we create the moderator role
     $mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'coach', 'position' => 3, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
     // we translate the translatable fields
     $mod->translateOrNew('fr')->name = 'Coach';
     $mod->translateOrNew('en')->name = 'Coach';
     $mod->save();
     // we create the user role
     $member = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'user', 'position' => 4]);
     // we translate the translatable fields
     $member->translateOrNew('fr')->name = 'Utilisateur';
     $member->translateOrNew('en')->name = 'User';
     $member->save();
 }
 /**
  *  Parse Validation input request data.
  *
  * @param $attribute
  * @param $value
  * @param $parameters
  * @return array
  */
 protected function parseJsRemoteRequest($attribute, $value, $parameters)
 {
     parse_str($value, $attrParts);
     $attrParts = is_null($attrParts) ? [] : $attrParts;
     $newAttr = array_keys(array_dot($attrParts));
     return [$attribute, array_pop($newAttr), $parameters];
 }
Example #17
0
 /**
  * Get a merged array of default and overriden config
  * @return array
  */
 public function all()
 {
     $defaultConfig = $this->getDefaultConfig();
     $userConfig = array_dot($this->config);
     $config = $userConfig + $defaultConfig;
     return array_undot($config);
 }
Example #18
0
 public function testArrayDot()
 {
     $data = array('test' => array('data' => 'I am the data'));
     $dottedData = array_dot($data);
     $this->assertEquals('I am the data', $dottedData['test.data']);
     $dottedData = array_dot($data, 'theprefix.');
     $this->assertEquals('I am the data', $dottedData['theprefix.test.data']);
 }
Example #19
0
 public static function hasRole($role, $user)
 {
     if (strpos($role, '.')) {
         return array_key_exists($role, array_dot($user->roles));
     } else {
         return array_key_exists($role, $user->roles);
     }
 }
Example #20
0
 public function sendResetPasswordInfo(User $user, PasswordResetToken $passwordResetToken)
 {
     Mail::queue('emails.reset_password_info', ['user' => $user, 'passwordResetToken' => $passwordResetToken, 'link' => $passwordResetToken->getResetPasswordLink()], function ($message) use($user, $passwordResetToken) {
         $transParams = array_dot($user->toArray());
         $transParams['app_name'] = trans('base.app.name');
         $message->to($passwordResetToken->email, $user->username)->subject(trans('reset_password.request_code.email.subject', $transParams));
     });
 }
 private function replace()
 {
     $replace = array_merge(array_dot($this->validator->getData()), [$this->attribute => $this->data]);
     if (request()->has($this->attribute)) {
         request()->replace($replace);
     }
     $this->validator->setData($replace);
 }
Example #22
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $masks = array_dot(trans('shop.masks'));
     if (!in_array(ucwords(str_replace('-', ' ', $request->segment(2))), $masks)) {
         abort(404);
     }
     return $next($request);
 }
Example #23
0
 /**
  * Returns a collection of fields that will be encrypted.
  *
  * @return array
  */
 public function getTransAttributes()
 {
     if (property_exists(get_called_class(), 'translate')) {
         $array[$this->table] = array_flip($this->translate);
         return array_dot($array);
     }
     return [];
 }
Example #24
0
 public static function langTexts($file, $key = null, $default = null)
 {
     static $cache = array();
     if (!isset($cache[$file])) {
         $cache[$file] = array_dot(include $file);
     }
     return is_null($key) ? $cache[$file] : array_get($cache[$file], $key, $default);
 }
Example #25
0
 /**
  * Load the config values.
  *
  * @return \Jenky\LaravelEnvLoader\Loader
  */
 public function loadConfigs()
 {
     $this->loadData(config('env.configs'), function ($configs) {
         $configs = array_dot($configs);
         $this->app['config']->set($configs);
     });
     return $this;
 }
Example #26
0
 public function assertArrayFiltered($arr1, $arr2, $ignore_keys = ['created_at', 'updated_at'])
 {
     $dot1 = array_dot($arr1);
     $dot2 = array_dot($arr2);
     $pattern = sprintf('/(.+\\.)*(%s)/', join($ignore_keys, '|'));
     array_forget($arr1, preg_grep($pattern, array_keys($dot1)));
     array_forget($arr2, preg_grep($pattern, array_keys($dot2)));
     $this->assertEquals($arr1, $arr2);
 }
Example #27
0
 /**
  * addConfigComponent
  *
  * @param $package
  * @param $namespace
  * @param $path
  * @return \Laradic\Config\Repository
  */
 public function addConfigComponent($package, $namespace, $path)
 {
     $config = $this->app->make('config');
     if ($config instanceof Repository) {
         $config->package($package, $path, $namespace);
         $config->addPublisher($package, $path);
         return array_dot($config->get($namespace . '::config'));
     }
 }
 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
Example #29
-1
 /**
  * Get locale translations.
  *
  * @return array
  */
 public function getTranslations()
 {
     $translations = array_map(function ($file) {
         return $file['content'];
     }, $this->files);
     return array_dot($translations);
 }
Example #30
-1
 /**
  * Load a locale from a given path.
  *
  * @param  string  $path
  * @param  string  $locale
  * @param  string  $group
  * @return array
  */
 protected function loadPath($path, $locale, $group)
 {
     if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
         return array_dot($this->files->getRequire($full));
     }
     return array();
 }