コード例 #1
0
ファイル: splashscreen.php プロジェクト: juaniiie/mwi
 public function put_update()
 {
     $post_data = Input::get('order');
     if (isset($post_data) and !empty($post_data)) {
         $order_items = explode(',', $post_data);
         foreach ($order_items as $order_position => $slug) {
             $affected = Settings\Model\Setting::where_slug($slug)->update(array('order' => $order_position));
         }
         return;
     }
     $settings = Input::all();
     foreach ($settings as $slug => $value) {
         // Update runtime configurations.
         $setting = Config::get('settings::core.' . $slug);
         if ($setting != null) {
             Config::set('settings::core.' . $slug, $value);
         }
         // Update database configurations
         $affected = Settings\Model\Setting::where_slug($slug)->update(array('value' => $value));
     }
     $this->data['message'] = Lang::line('splashscreen::lang.Settings were successfully updated')->get(ADM_LANG);
     $this->data['message_type'] = 'success';
     // redirect back to the module
     return Redirect::back()->with($this->data);
 }
コード例 #2
0
ファイル: auth.php プロジェクト: juaniiie/mwi
 public function post_login()
 {
     $messages = array('check_login' => Lang::line('auth::lang.Invalid credentials')->get(APP_LANG), 'check_user_status' => Lang::line('auth::lang.This account is inactive. Please contact support')->get(APP_LANG));
     Validator::register('check_login', function ($attribute, $value, $parameters) {
         $credentials = array('username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => Input::get('remember'));
         return Auth::attempt($credentials) ? true : false;
     });
     Validator::register('check_user_status', function ($attribute, $value, $parameters) {
         if (isset(Auth::user()->status) and Auth::user()->status != 'active') {
             Auth::logout();
             return false;
         }
         return true;
     });
     $rules = array('username' => 'required', 'password' => 'required|check_login|check_user_status');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::to('login')->with_input()->with_errors($validation);
     } else {
         if (Session::has('last_page')) {
             $url = Session::get('last_page');
             Session::forget('last_page');
             return Redirect::to($url);
         } else {
             return Redirect::to('/');
         }
     }
     return $this->theme->render('auth::frontend.login', $this->data);
 }
コード例 #3
0
ファイル: lang.php プロジェクト: 469306621/Languages
 /**
  * Test for Lang::set()
  * 
  * @test
  */
 public function test_set()
 {
     Lang::set('testing_set_valid', 'Ahoy :name!');
     $output = Lang::line('testing_set_valid', array('name' => 'Bob'));
     $expected = 'Ahoy Bob!';
     $this->assertEquals($expected, $output);
 }
コード例 #4
0
ファイル: metadata.php プロジェクト: nathggns/anchor-cms
 public static function update()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page', 'auto_published_comments', 'posts_per_page'));
     $errors = array();
     if (empty($post['sitename'])) {
         $errors[] = Lang::line('metadata.missing_sitename', 'You need a site sitename');
     }
     if (empty($post['description'])) {
         $errors[] = Lang::line('metadata.missing_sitedescription', 'You need a site description');
     }
     if (empty($post['theme'])) {
         $errors[] = Lang::line('metadata.missing_theme', 'You need a theme');
     }
     // auto publish comments
     $post['auto_published_comments'] = $post['auto_published_comments'] ? 1 : 0;
     // format posts per page, must be a whole number above 1 defaults to 10 if a invalid number is entered
     $post['posts_per_page'] = ($posts_per_page = intval($post['posts_per_page'])) > 0 ? $posts_per_page : 10;
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     foreach ($post as $key => $value) {
         Db::update('meta', array('value' => $value), array('key' => $key));
     }
     Notifications::set('success', Lang::line('metadata.meta_success_updated', 'Your metadata has been updated'));
     return true;
 }
コード例 #5
0
ファイル: Current.php プロジェクト: SerdarSanri/VaneMart
 static function lang($name, $default = null)
 {
     if ($name instanceof \Lang) {
         return $name;
     } else {
         return \Lang::line(static::expand($name))->get(null, $default);
     }
 }
コード例 #6
0
ファイル: opensim.php プロジェクト: juaniiie/mwi
 public function get_index()
 {
     $db_is_ready = Config::get('settings::core.passes_db_settings');
     if (!(bool) $db_is_ready) {
         Session::flash('message_type', 'error');
         Session::flash('message', Lang::line('opensim::lang.Your opensim database needs to be configured!')->get(ADM_LANG));
     }
     $this->data['settings'] = Settings\Model\Setting::where_section('opensim_settings')->get();
     $this->data['section_bar_active'] = Lang::line('opensim::lang.Settings')->get(ADM_LANG);
     return $this->theme->render('opensim::backend.opensim.index', $this->data);
 }
コード例 #7
0
ファイル: regions.php プロジェクト: juaniiie/mwi
 public function get_edit($region_uuid)
 {
     $this->data['section_bar'] = array(Lang::line('opensim::lang.Settings')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/opensim/settings', Lang::line('opensim::lang.Database Settings')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/opensim/settings/database', Lang::line('opensim::lang.Regions')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/opensim/regions', Lang::line('opensim::lang.View Region Details')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/opensim/regions/' . $region_uuid . '/edit');
     $this->data['section_bar_active'] = Lang::line('opensim::lang.View Region Details')->get(ADM_LANG);
     if (\Opensim\UUID::is_valid($region_uuid)) {
         $this->data['region'] = DB::connection('opensim')->table('regions')->where_uuid($region_uuid)->first();
         return $this->theme->render('opensim::backend.regions.view', $this->data);
     } else {
         $this->data['message'] = __('opensim::lang.Invalid region uuid')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/opensim/regions')->with($this->data);
     }
 }
コード例 #8
0
ファイル: data.php プロジェクト: farhan4648gul/developer-side
 public function post_deleteGroup()
 {
     $groupid = Input::get('groupid');
     $name = Input::get('name');
     Group::getDataModel($groupid);
     $existed = Group::checkData();
     if (!$existed) {
         Group::find($groupid)->delete();
         Log::write('Data', 'Data Group<b>' . $name . '</b> Remove by ' . Auth::user()->username);
         return json_encode(Group::listData());
     } else {
         return json_encode(array('fail' => Str::title(Lang::line('admin.deletegroupfail')->get())));
     }
 }
コード例 #9
0
ファイル: paginator.php プロジェクト: manishnakar/critterapp
 /**
  * Create a chronological pagination element, such as a "previous" or "next" link.
  *
  * @param  string   $element
  * @param  int      $page
  * @param  string   $text
  * @param  Closure  $disabled
  * @return string
  */
 protected function element($element, $page, $text, $disabled)
 {
     $class = $this->pager_aligned ? "{$element}" : "";
     if (is_null($text)) {
         $text = \Lang::line("pagination.{$element}")->get($this->language);
     }
     // Each consumer of this method provides a "disabled" Closure which can
     // be used to determine if the element should be a span element or an
     // actual link. For example, if the current page is the first page,
     // the "first" element should be a span instead of a link.
     if ($disabled($this->page, $this->last)) {
         $class .= " disabled";
         return '<li' . HTML::attributes(compact("class")) . '><a href="#">' . HTML::entities($text) . '</a></li>';
     } else {
         return '<li' . HTML::attributes(compact("class")) . '>' . $this->link($page, $text, null) . '</li>';
     }
 }
コード例 #10
0
ファイル: flashnews.php プロジェクト: juaniiie/mwi
 public function get_edit($news_id)
 {
     $this->data['section_bar'] = array(Lang::line('splashscreen::lang.Settings')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/splashscreen', Lang::line('splashscreen::lang.Logo And Backgrounds')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/splashscreen/images_backgrounds', Lang::line('splashscreen::lang.Flash News')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/splashscreen/flash_news', Lang::line('splashscreen::lang.Edit Flash News')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/splashscreen/flash_news/' . $news_id . '/edit', Lang::line('splashscreen::lang.New Flash News')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/splashscreen/flash_news/new');
     $this->data['section_bar_active'] = Lang::line('splashscreen::lang.Edit Flash News')->get(ADM_LANG);
     if (!ctype_digit($news_id)) {
         $this->data['message'] = __('splashscreen::flashnews.Invalid flash news id')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/splashscreen/flash_news')->with($this->data);
     }
     $news = Splashscreen\Model\News::find($news_id);
     if (!isset($news) or empty($news)) {
         $this->data['message'] = __('splashscreen::flashnews.Could not find flash news to edit')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/splashscreen/flash_news')->with($this->data);
     }
     $this->data['news'] = $news;
     return $this->theme->render('splashscreen::backend.flashnews.edit', $this->data);
 }
コード例 #11
0
ファイル: groups.php プロジェクト: juaniiie/mwi
 public function delete_destroy($group_id)
 {
     if (ctype_digit($group_id)) {
         $group = Navigation\Model\Group::find($group_id);
         if (isset($group) and !empty($group)) {
             if (!$group->is_core) {
                 $group->links()->delete();
                 $group->delete();
                 Event::fire('mwi.navigation_group_deleted', array($group));
                 $this->data['message'] = Lang::line('navigation::lang.Navigation group was successfully deleted')->get(ADM_LANG);
                 $this->data['message_type'] = 'success';
                 if (Request::ajax()) {
                     return 'success';
                 } else {
                     return Redirect::to(ADM_URI . '/navigation')->with($this->data);
                 }
             } else {
                 $this->data['message'] = Lang::line('navigation::lang.Not authorized to delete a core navigation group')->get(ADM_LANG);
                 $this->data['message_type'] = 'error';
                 if (Request::ajax()) {
                     return 'error';
                 } else {
                     return Redirect::to(ADM_URI . '/navigation')->with($this->data);
                 }
             }
         } else {
             $this->data['message'] = Lang::line('navigation::lang.Could not delete navigation group The navigation group was not found')->get(ADM_LANG);
             $this->data['message_type'] = 'error';
             if (Request::ajax()) {
                 return 'error';
             } else {
                 return Redirect::to(ADM_URI . '/navigation')->with($this->data);
             }
         }
     } else {
         $this->data['message'] = Lang::line('navigation::lang.Invalid navigation group id')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         if (Request::ajax()) {
             return 'error';
         } else {
             return Redirect::to(ADM_URI . '/navigation')->with($this->data);
         }
     }
 }
コード例 #12
0
ファイル: settings.php プロジェクト: juaniiie/mwi
 public function put_update()
 {
     $post_data = Input::get('order');
     if (isset($post_data) and !empty($post_data)) {
         $order_items = explode(',', $post_data);
         foreach ($order_items as $order_position => $slug) {
             $affected = Settings\Model\Setting::where_slug($slug)->update(array('order' => $order_position));
         }
         return;
     }
     $settings = Input::all();
     // If we are saving settings for other module
     // other then settings module this value will
     // not be sent
     $adm_uri = Input::get('administration_uri');
     if (isset($adm_uri) and !empty($adm_uri)) {
         Session::put('ADM_URI', Input::get('administration_uri'));
     } else {
         Session::put('ADM_URI', ADM_URI);
     }
     foreach ($settings as $slug => $value) {
         // Update runtime configurations.
         $setting = Config::get('settings::core.' . $slug);
         if ($setting != null) {
             Config::set('settings::core.' . $slug, $value);
         }
         // Update database configurations
         $affected = Settings\Model\Setting::where_slug($slug)->update(array('value' => $value));
     }
     $this->data['message'] = Lang::line('settings::lang.Settings were successfully updated')->get(ADM_LANG);
     $this->data['message_type'] = 'success';
     // if we are changing the administration
     // uri it must be from settings module
     // redirect there with the new uri
     $redirect = Input::get('administration_uri');
     if (isset($redirect) and !empty($redirect)) {
         return Redirect::to(URL::base() . '/' . Session::get('ADM_URI') . '/settings')->with($this->data);
     }
     // we are not changing the administration
     // uri, it must be from another module
     // redirect back to the module
     return Redirect::back()->with($this->data);
 }
コード例 #13
0
 /**
  * Submenu creation
  *     
  * @param  string $type Which set of submenu to return
  * @return string       Submenu HTML
  */
 public static function submenu($type = 'inventory')
 {
     $submenu = array();
     switch ($type) {
         case 'inventory':
             $submenu = array(Lang::line('site.items')->get() => 'item@list', Lang::line('site.categories')->get() => 'category@list', Lang::line('site.documents')->get() => 'document@list', Lang::line('site.contacts')->get() => 'contact@list');
             break;
         case 'transactions':
             $submenu = array(Lang::line('site.overview')->get() => 'transaction@list/overview', Lang::line('site.advanced_view')->get() => 'transaction@list/advanced');
             break;
         case 'report':
             $submenu = array(Lang::line('site.volume')->get() => 'report@volume', Lang::line('site.value')->get() => 'report@value');
             break;
         default:
             $submenu = array();
             break;
     }
     return $submenu;
 }
コード例 #14
0
ファイル: validation.php プロジェクト: quickpacket/noclayer
 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   Fieldset|null
  * @return  Fieldset
  */
 public static function set_fields($obj, $fieldset = null)
 {
     static $_generated = array();
     $class = is_object($obj) ? get_class($obj) : $obj;
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::forge($class);
         }
     }
     !array_key_exists($class, $_generated) and $_generated[$class] = array();
     if (in_array($fieldset, $_generated[$class], true)) {
         return $fieldset;
     }
     $_generated[$class][] = $fieldset;
     $primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
     $properties = is_object($obj) ? $obj->properties() : $class::properties();
     foreach ($properties as $p => $settings) {
         if (in_array($p, $primary_keys)) {
             continue;
         }
         if (isset($settings['form']['options'])) {
             foreach ($settings['form']['options'] as $key => $value) {
                 $settings['form']['options'][$key] = \Lang::line($value) ?: $value;
             }
         }
         $label = isset($settings['label']) ? $settings['label'] : $p;
         $attributes = isset($settings['form']) ? $settings['form'] : array();
         $field = $fieldset->add($p, $label, $attributes);
         if (!empty($settings['validation'])) {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_user_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     return $fieldset;
 }
コード例 #15
0
ファイル: imagesbackgrounds.php プロジェクト: juaniiie/mwi
 public function get_index()
 {
     $this->data['section_bar_active'] = Lang::line('splashscreen::lang.Logo And Backgrounds')->get(ADM_LANG);
     //
     //Get switch background images
     //
     $background_images_path = path('public') . 'bundles/splashscreen/img/backgrounds/';
     $background_images = array();
     foreach (glob($background_images_path . "*") as $filename) {
         $path = '/bundles/splashscreen/img/backgrounds/';
         $name = explode('/', $filename);
         $background_images[$path . $name[count($name) - 1]] = $name[count($name) - 1];
     }
     $this->data['images'] = $background_images;
     //
     //Get day time background images
     //
     $day_time_background_images_path = path('public') . 'bundles/splashscreen/img/day_time_bkgs/';
     $day_time_background_images = array();
     foreach (glob($day_time_background_images_path . "*") as $filename) {
         $path = '/bundles/splashscreen/img/day_time_bkgs/';
         $name = explode('/', $filename);
         $day_time_background_images[$path . $name[count($name) - 1]] = $name[count($name) - 1];
     }
     $this->data['day_time_images'] = $day_time_background_images;
     //
     // Find logo image
     //
     $logo_path = path('public') . 'bundles/splashscreen/img/logo/';
     $logo = array();
     foreach (glob($logo_path . "logo.*") as $filename) {
         $path = '/bundles/splashscreen/img/logo/';
         $name = explode('/', $filename);
         $logo[$path . $name[count($name) - 1]] = $name[count($name) - 1];
     }
     $this->data['logo'] = $logo;
     return $this->theme->render('splashscreen::backend.imagesbackgrounds.index', $this->data);
 }
コード例 #16
0
ファイル: validator.php プロジェクト: hpaul/Google-short
 /**
  * Replace all error message place-holders with actual values.
  *
  * @param  string  $message
  * @param  string  $attribute
  * @param  string  $rule
  * @param  array   $parameters
  * @return string
  */
 protected function format_message($message, $attribute, $rule, $parameters)
 {
     $display = Lang::line('attributes.' . $attribute)->get($this->language, str_replace('_', ' ', $attribute));
     $message = str_replace(':attribute', $display, $message);
     if (in_array($rule, $this->size_rules)) {
         $max = $rule == 'between' ? $parameters[1] : $parameters[0];
         $message = str_replace(array(':size', ':min', ':max'), array($parameters[0], $parameters[0], $max), $message);
     } elseif (in_array($rule, array('in', 'not_in', 'mimes'))) {
         $message = str_replace(':values', implode(', ', $parameters), $message);
     }
     return $message;
 }
コード例 #17
0
ファイル: pages.php プロジェクト: juaniiie/mwi
 public function delete_destroy($page_id)
 {
     $page = Pages\Model\Page::find($page_id);
     // If there is childen set children to the actual page parent
     Pages\Model\Page::where('parent_id', '=', $page->id)->update(array('parent_id' => $page->parent_id));
     // This page has links?? If so lets delete them
     $link = Navigation\Model\Link::where('page_id', '=', $page->id)->get();
     //This page has links?
     if (isset($link) and !empty($link)) {
         foreach ($link as $delete_link) {
             // If there is childen set children to the actual link parent
             Navigation\Model\Link::where('parent', '=', $delete_link->id)->update(array('parent' => $delete_link->parent));
             $delete_link->delete();
             Event::fire('mwi.navigation_link_deleted', array($delete_link));
         }
     }
     $page->delete();
     Event::fire('mwi.pages_page_deleted', array($page));
     Session::flash('message', Lang::line('pages::lang.Page was successfully deleted')->get(ADM_LANG));
     Session::flash('message_type', 'success');
     if (Request::ajax()) {
         $data = array('success' => 'true', 'url' => URL::base() . '/' . ADM_URI . '/pages');
         return json_encode($data);
     } else {
         return Redirect::to(ADM_URI . '/pages')->with($this->data);
     }
 }
コード例 #18
0
ファイル: date.php プロジェクト: novius/core
	/**
	 * Returns the time ago
	 *
	 * @param	int		UNIX timestamp from current server
	 * @return	string	Time ago
	 */
	public static function time_ago($timestamp, $from_timestamp = null)
	{
		if ($timestamp === null)
		{
			return;
		}

		! is_numeric($timestamp) and $timestamp = static::create_from_string($timestamp);

		$from_timestamp == null and $from_timestamp = time();
		
		\Lang::load('date', true);
		
		$difference = $from_timestamp - $timestamp;
		$periods	= array('second', 'minute', 'hour', 'day', 'week', 'month', 'years', 'decade');
		$lengths	= array(60, 60, 24, 7, 4.35, 12, 10);

		for ($j = 0; $difference >= $lengths[$j]; $j++)
		{
			$difference /= $lengths[$j];
		}

        $difference = round($difference);

		if ($difference != 1)
		{
			$periods[$j] = \Inflector::pluralize($periods[$j]);
		}
		
		$text = \Lang::line('date.text', array(
			'time' => \Lang::line('date.'.$periods[$j], array('t' => $difference))
		));
		
		return $text;
	}
コード例 #19
0
ファイル: pages.php プロジェクト: nathggns/anchor-cms
 public static function add()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('slug', 'name', 'title', 'content', 'redirect', 'status'));
     $errors = array();
     if (empty($post['name'])) {
         $errors[] = Lang::line('pages.missing_name', 'Please enter a name');
     }
     if (empty($post['title'])) {
         $errors[] = Lang::line('pages.missing_title', 'Please enter a title');
     }
     // check for duplicate slug
     $sql = "select id from pages where slug = ?";
     if (Db::row($sql, array($post['slug']))) {
         $errors[] = Lang::line('pages.duplicate_slug', 'A pages with the same slug already exists, please change your page slug.');
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     if (empty($post['slug'])) {
         $post['slug'] = $post['name'];
     }
     $post['slug'] = Str::slug($post['slug']);
     Db::insert('pages', $post);
     Notifications::set('success', Lang::line('pages.page_success_created', 'Your new page has been added'));
     return true;
 }
コード例 #20
0
ファイル: base.php プロジェクト: hymns/fuel
 function __($string, $params = array())
 {
     return \Lang::line($string, $params);
 }
コード例 #21
0
ファイル: links.php プロジェクト: juaniiie/mwi
 public function delete_destroy($link_id)
 {
     if (ctype_digit($link_id)) {
         $link = Navigation\Model\Link::find($link_id);
         if (isset($link) and !empty($link)) {
             // if this is a parent link lets update the children to its parent
             Navigation\Model\Link::where('parent', '=', $link->id)->update(array('parent' => $link->parent));
             $link->delete();
             Event::fire('mwi.navigation_link_deleted', array($link));
             $this->data['message'] = Lang::line('navigation::lang.Link was successfully deleted')->get(ADM_LANG);
             $this->data['message_type'] = 'success';
             return Redirect::to(ADM_URI . '/navigation')->with($this->data);
         } else {
             $this->data['message'] = Lang::line('Could not delete link The link was not found')->get(ADM_LANG);
             $this->data['message_type'] = 'error';
             return Redirect::to(ADM_URI . '/navigation')->with($this->data);
         }
     } else {
         $this->data['message'] = Lang::line('Invalid link id')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/navigation')->with($this->data);
     }
 }
コード例 #22
0
ファイル: functions.php プロジェクト: nathggns/anchor-cms
/**
	Lang helper
*/
function __($line, $default = 'No language replacement')
{
    return Lang::line($line, $default);
}
コード例 #23
0
ファイル: settings.php プロジェクト: juaniiie/mwi
 public function put_update()
 {
     $settings = Input::all();
     $raw_rules = Settings\Model\Setting::where_in('slug', array_keys($settings))->where_module_slug('opensim')->get();
     $rules = array();
     foreach ($raw_rules as $setting) {
         if (isset($setting->validation) and !empty($setting->validation)) {
             $rules[$setting->slug] = $setting->validation;
         }
     }
     $validation = \Opensim\Validator::make($settings, $rules)->speaks(ADM_LANG);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation->errors);
     }
     if (isset($settings['database_driver'])) {
         $credentials = array('driver' => $settings['database_driver'], 'host' => $settings['database_host'], 'database' => $settings['database_name'], 'username' => $settings['database_user'], 'password' => $settings['database_password'], 'charset' => 'utf8', 'prefix' => $settings['database_table_prefix'], 'port' => $settings['database_port']);
         $db = null;
         switch ($credentials['driver']) {
             case 'sqlite':
                 $db = new \Laravel\Database\Connectors\SQLite();
                 break;
             case 'mysql':
                 $db = new \Laravel\Database\Connectors\MySQL();
                 break;
             case 'pgsql':
                 $db = new \Laravel\Database\Connectors\Postgres();
                 break;
             case 'sqlsrv':
                 $db = new \Laravel\Database\Connectors\SQLServer();
                 break;
         }
         \Config::set('error.detail', false);
         \Event::listen('500', function ($message) {
             \Settings\Config::set('settings::core.passes_db_settings', 0, true);
             $this->data['message'] = $message;
             $this->data['message_type'] = 'error';
             $this->data['settings'] = Settings\Model\Setting::where_module_slug('opensim')->where_section('opensim_db_settings')->get();
             $this->data['section_bar_active'] = Lang::line('opensim::lang.Database Settings')->get(ADM_LANG);
             $content = $this->theme->render('opensim::backend.settings.index', $this->data);
             echo $content;
             die;
         });
         // If we get an exception when
         // trying to connect to the db
         // the event above will catch it
         // and return our view with the
         // error message
         $db->connect($credentials);
         // Set database flag
         Settings\Config::set('settings::core.passes_db_settings', 1, true);
         foreach ($settings as $slug => $value) {
             // Update database configurations
             if (!empty($value)) {
                 $affected = Settings\Model\Setting::where_slug($slug)->where_module_slug('opensim')->update(array('value' => $value));
             }
         }
         $this->data['message'] = Lang::line('opensim::lang.Opensim settings were successfully updated')->get(ADM_LANG);
         $this->data['message_type'] = 'success';
         return Redirect::back()->with($this->data);
     } else {
         $db_is_ready = Config::get('settings::core.passes_db_settings');
         if ((bool) $db_is_ready) {
             foreach ($settings as $slug => $value) {
                 // Update database configurations
                 if (strlen($value) > 0) {
                     $affected = Settings\Model\Setting::where_slug($slug)->where_module_slug('opensim')->update(array('value' => $value));
                 }
             }
             $this->data['message'] = Lang::line('opensim::lang.Opensim settings were successfully updated')->get(ADM_LANG);
             $this->data['message_type'] = 'success';
             return Redirect::back()->with($this->data);
         } else {
             Session::flash('message_type', 'error');
             Session::flash('message', Lang::line('opensim::lang.Your opensim database needs to be configured!')->get(ADM_LANG));
             return Redirect::back()->with($this->data);
         }
     }
 }
コード例 #24
0
 /**
  * Fetch transactions for Datatables
  * @param  string $table    Table to be fetched from
  * @param  int $id          Item id (optional)
  * @param  string $iid      Item id column name in target table
  * @param  array $columns   Columns to be fetched
  * @param  array  $joins    2D array wih 3 join parametes each array
  * @param  array $input     All the environmental inputs
  * @return string           JSON data of query
  */
 private function fetch_transactions($table = null, $id = null, $iid = null, $columns = null, $joins = array(), $input)
 {
     if (empty($input)) {
         return false;
     }
     $limit = null;
     $offset = null;
     $order = array();
     $where = array();
     $id = !is_null($id) ? trim(filter_var($id, FILTER_SANITIZE_NUMBER_INT)) : null;
     foreach ($input as $key => $value) {
         $input[$key] = trim(filter_var($value, FILTER_SANITIZE_STRING));
     }
     // Column name without the as aliases
     // needed in this form for Filters and Column search
     $columns_no_as = array();
     foreach ($columns as $value) {
         $columns_no_as[] = preg_replace('/\\sas\\s[a-z]+/', '', $value);
     }
     // Limit and offset
     if (!is_null($input['iDisplayStart']) && $input['iDisplayLength'] != '-1') {
         $offset = (int) $input['iDisplayStart'];
         $limit = (int) $input['iDisplayLength'];
     }
     // Order
     if (isset($input['iSortCol_0'])) {
         for ($i = 0; $i < $input['iSortingCols']; $i++) {
             if ($input['bSortable_' . intval($input['iSortCol_' . $i])] == "true") {
                 $order[] = array('col' => $columns_no_as[$input['iSortCol_' . $i]], 'dir' => $input['sSortDir_' . $i] === 'asc' ? 'asc' : 'desc');
             }
         }
     }
     // Id
     if (!is_null($id)) {
         $where[] = array('col' => $iid, 'comp' => '=', 'val' => $id);
     }
     //Filters
     if (isset($input['sSearch']) && $input['sSearch'] != "") {
         for ($i = 0; $i < count($columns); $i++) {
             $where[] = array('col' => $columns_no_as[$i], 'comp' => 'LIKE', 'val' => '%' . $input['sSearch'] . '%');
         }
     }
     // Column search
     for ($i = 0; $i < count($columns); $i++) {
         if (isset($input['bSearchable_' . $i]) && $input['bSearchable_' . $i] == "true" && $input['sSearch_' . $i] != '') {
             $where[] = array('col' => $columns_no_as[$i], 'comp' => 'LIKE', 'val' => '%' . $input['sSearch_' . $i] . '%');
         }
     }
     try {
         // Putting together the query
         $db = DB::table($table);
         $total = $db->count();
         foreach ($where as $value) {
             $db->or_where($value['col'], $value['comp'], $value['val']);
         }
         foreach ($order as $value) {
             $db->order_by($value['col'], $value['dir']);
         }
         foreach ($joins as $join) {
             $db->left_join($join['table'], $join['tcolumn'], '=', $join['fcolumn']);
         }
         $filtered_total = $db->count();
         $db->take($limit);
         $db->skip($offset);
         $results = $db->get($columns);
     } catch (Exception $e) {
         return null;
     }
     $output = array("sEcho" => $input['sEcho'], "iTotalRecords" => $total, "iTotalDisplayRecords" => $filtered_total, "aaData" => array());
     $result = array();
     for ($i = 0; $i < count($results); $i++) {
         $id = null;
         foreach ($results[$i] as $key => $value) {
             if ($key == 'iid') {
                 continue;
             } elseif ($key == 'type') {
                 $value = Lang::line('site.' . $value)->get();
             } elseif ($key == 'item') {
                 $image = array();
                 $image = glob('uploads/images/items/' . $results[$i]->iid . '.*');
                 $image = !empty($image) && file_exists($image[0]) ? ' &nbsp;&nbsp;<a class="screenshot" href="' . URL::base() . '/' . $image[0] . '"><i class="icon-picture opacity50"></i></a>' : '';
                 $value = '<a href="' . action('item@edit') . '/' . $results[$i]->iid . '">' . $value . '</a>' . $image;
             }
             $result[$i][] = $value;
         }
         $result[$i][] = '<a href="' . action('transaction/delete/' . $results[$i]->id) . '" class="delete">' . Lang::line('site.delete')->get() . '</a>';
     }
     $output['aaData'] = $result;
     return json_encode($output);
 }
コード例 #25
0
 /**
  * returns the day full name or shorting version
  * @param Integer $day the day number
  * @param Boolean $shorten defualt false
  * @return String Day name
  */
 private static function getTimeOfDay($time, $shorten = false)
 {
     $time = strcasecmp($time, "am") == 0 ? 1 : 2;
     return $shorten ? Lang::line('hijri::hijri.time.short.' . $time)->get() : Lang::line('hijri::hijri.time.short.' . $time)->get();
 }
コード例 #26
0
ファイル: upload.php プロジェクト: 469306621/Languages
 /**
  * Normalize the $_FILES array and store the result in $files
  *
  * @return	void
  */
 public static function process($config = array())
 {
     // process runtime config
     if (is_array($config)) {
         static::$config = array_merge(static::$config, $config);
     }
     // processed files array
     static::$files = $files = array();
     // normalize the $_FILES array
     foreach ($_FILES as $name => $value) {
         // if the variable is an array, flatten it
         if (is_array($value['name'])) {
             $keys = array_keys($value['name']);
             foreach ($keys as $key) {
                 // skip this entry if no file was uploaded
                 if ($value['error'][$key] == static::UPLOAD_ERR_NO_FILE) {
                     continue;
                 }
                 // store the file data
                 $file = array('field' => $name, 'key' => $key);
                 $file['name'] = $value['name'][$key];
                 $file['type'] = $value['type'][$key];
                 $file['file'] = $value['tmp_name'][$key];
                 $file['error'] = $value['error'][$key];
                 $file['size'] = $value['size'][$key];
                 $files[] = $file;
             }
         } else {
             // skip this entry if no file was uploaded
             if ($value['error'] == static::UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             // store the file data
             $file = array('field' => $name, 'key' => false, 'file' => $value['tmp_name']);
             unset($value['tmp_name']);
             $files[] = array_merge($value, $file);
         }
     }
     // verify and augment the files data
     foreach ($files as $key => $value) {
         // add some filename details (pathinfo can't be trusted with utf-8 filenames!)
         $files[$key]['extension'] = ltrim(strrchr(ltrim($files[$key]['name'], '.'), '.'), '.');
         if (empty($files[$key]['extension'])) {
             $files[$key]['filename'] = $files[$key]['name'];
         } else {
             $files[$key]['filename'] = substr($files[$key]['name'], 0, strlen($files[$key]['name']) - (strlen($files[$key]['extension']) + 1));
         }
         // does this upload exceed the maximum size?
         if (!empty(static::$config['max_size']) and $files[$key]['size'] > static::$config['max_size']) {
             $files[$key]['error'] = static::UPLOAD_ERR_MAX_SIZE;
         }
         // add mimetype information
         if ($files[$key]['error'] == UPLOAD_ERR_OK) {
             $handle = finfo_open(FILEINFO_MIME_TYPE);
             $files[$key]['mimetype'] = finfo_file($handle, $value['file']);
             finfo_close($handle);
             if ($files[$key]['mimetype'] == 'application/octet-stream' and $files[$key]['type'] != $files[$key]['mimetype']) {
                 $files[$key]['mimetype'] = $files[$key]['type'];
             }
             // make sure it contains something valid
             if (empty($files[$key]['mimetype'])) {
                 $files[$key]['mimetype'] = 'application/octet-stream';
             }
         }
         // check the file extension black- and whitelists
         if ($files[$key]['error'] == UPLOAD_ERR_OK) {
             if (in_array($files[$key]['extension'], (array) static::$config['ext_blacklist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_EXT_BLACKLISTED;
             } elseif (!empty(static::$config['ext_whitelist']) and !in_array($files[$key]['extension'], (array) static::$config['ext_whitelist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_EXT_NOT_WHITELISTED;
             }
         }
         // check the file type black- and whitelists
         if ($files[$key]['error'] == UPLOAD_ERR_OK) {
             // split the mimetype info so we can run some tests
             preg_match('|^(.*)/(.*)|', $files[$key]['mimetype'], $mimeinfo);
             if (in_array($mimeinfo[1], (array) static::$config['type_blacklist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_TYPE_BLACKLISTED;
             }
             if (!empty(static::$config['type_whitelist']) and !in_array($mimeinfo[1], (array) static::$config['type_whitelist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_TYPE_NOT_WHITELISTED;
             }
         }
         // check the file mimetype black- and whitelists
         if ($files[$key]['error'] == UPLOAD_ERR_OK) {
             if (in_array($files[$key]['mimetype'], (array) static::$config['mime_blacklist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_MIME_BLACKLISTED;
             } elseif (!empty(static::$config['mime_whitelist']) and !in_array($files[$key]['mimetype'], (array) static::$config['mime_whitelist'])) {
                 $files[$key]['error'] = static::UPLOAD_ERR_MIME_NOT_WHITELISTED;
             }
         }
         // store the normalized and validated result
         static::$files[$key] = $files[$key];
         // validation callback defined?
         if (array_key_exists('validate', static::$callbacks) and !is_null(static::$callbacks['validate'])) {
             // get the callback method
             $callback = static::$callbacks['validate'][0];
             // call the callback
             if (is_callable($callback)) {
                 $result = call_user_func_array($callback, array(&static::$files[$key]));
                 if (is_numeric($result)) {
                     static::$files[$key]['error'] = $result;
                 }
             }
         }
         // update the valid flag
         static::$valid = (static::$valid or $files[$key]['error'] === 0);
         // and add the message text
         static::$files[$key]['message'] = \Lang::line('upload.' . static::$files[$key]['error']);
     }
 }
コード例 #27
0
 /**
  * Create a chronological pagination element, such as a "previous" or "next" link.
  *
  * @param  string   $element
  * @param  int      $page
  * @param  string   $text
  * @param  Closure  $disabled
  * @return string
  */
 protected function element($element, $page, $text, $disabled)
 {
     $class = "{$element}_page";
     if (is_null($text)) {
         $text = Lang::line("pagination.{$element}")->get($this->language);
     }
     // Each consumer of this method provides a "disabled" Closure which can
     // be used to determine if the element should be a span element or an
     // actual link. For example, if the current page is the first page,
     // the "first" element should be a span instead of a link.
     if ($disabled($this->page, $this->last)) {
         return HTML::span($text, array('class' => "{$class} disabled"));
     } else {
         return $this->link($page, $text, $class);
     }
 }
コード例 #28
0
ファイル: paginator.php プロジェクト: hpaul/Google-short
 /**
  * Generate the "next" HTML link.
  *
  * @return string
  */
 public function next()
 {
     $text = Lang::line('pagination.next')->get($this->language);
     if ($this->page < $this->last_page) {
         return $this->link($this->page + 1, $text, 'next_page');
     }
     return HTML::span($text, array('class' => 'disabled next_page'));
 }
コード例 #29
0
/**
 * Retrieve a language line.
 *
 * @param  string  $key
 * @param  array   $replacements
 * @param  string  $language
 * @return string
 */
function __($key, $replacements = array(), $language = null)
{
    return Lang::line($key, $replacements, $language);
}
コード例 #30
0
ファイル: modules.php プロジェクト: juaniiie/mwi
 public function __construct()
 {
     parent::__construct();
     $this->data['bar'] = array('title' => __('modules::lang.Modules')->get(ADM_LANG), 'url' => URL::base() . '/' . ADM_URI . '/modules', 'description' => __('modules::lang.Allow admin to see a list of currently installed modules')->get(ADM_LANG));
     $this->data['section_bar'] = array(Lang::line('modules::lang.Modules')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/modules', Lang::line('modules::lang.Core Modules')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/modules/core', Lang::line('modules::lang.Upload New Module')->get(ADM_LANG) => URL::base() . '/' . ADM_URI . '/modules/upload');
 }