Esempio n. 1
0
 /**
  * [edit description]
  * @return [type] [description]
  */
 public function edit($page_id, $block_id)
 {
     \Pongo::viewShare('page_id', $page_id);
     \Pongo::viewShare('block_id', $block_id);
     $block = $this->manager->getBlock($block_id);
     return \Render::view('sections.blocks.edit', array('block' => $block));
 }
Esempio n. 2
0
 /**
  * [createFile description]
  * @return [type] [description]
  */
 public function createFile()
 {
     if ($check = $this->canEdit()) {
         if ($this->validator->fails()) {
             return $this->setError($this->validator->errors());
         } else {
             $id = $this->input['id'];
             $file_name = $this->input['file_name'];
             $file_size = $this->input['file_size'];
             $size_type = $this->input['size_type'];
             $folder_name = \Media::getFolderName($file_name);
             $format_name = \Media::formatFileName($file_name);
             $file_ext = \Media::fileExtension($file_name);
             $file_size = \Media::convertFileSize($file_size, $size_type);
             $http_path = '/' . \Pongo::settings('upload_path') . $folder_name . $format_name;
             $file_arr = array('name' => $format_name, 'original' => $file_name, 'ext' => $file_ext, 'size' => $file_size, 'w' => 0, 'h' => 0, 'path' => $http_path, 'is_image' => 0, 'is_active' => 1);
             // Write file to db
             $new_file = $this->model->create($file_arr);
             // Attach new_file to page in pivot
             $new_file->pages()->attach($id, array('is_active' => 1));
             $response = array('status' => 'success', 'msg' => t('alert.success.file_created'), 'print' => array('text' => t('form.infos.create_file', array('rename' => $format_name, 'upload' => \Media::getFolderPublic(\Pongo::settings('upload_path') . $folder_name . $format_name))), 'item' => array('id' => $new_file->id, 'is_image' => \Media::isImage($new_file->name), 'file_name' => $new_file->name, 'url_link' => \Media::getImgPath($new_file->name), 'ico' => \Media::loadThumb($new_file->path, 'cms'), 'url_edit' => route('file.edit', array('file_id' => $new_file->id)))));
             return $this->setSuccess($response);
         }
     } else {
         return $check;
     }
 }
Esempio n. 3
0
 public function run()
 {
     // Reset table
     DB::table('block_page')->truncate();
     $order_id = Pongo::system('default_order');
     DB::table('block_page')->insert(array(array('page_id' => 1, 'block_id' => 1, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 1, 'block_id' => 2, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 1, 'block_id' => 3, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 2, 'block_id' => 1, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 2, 'block_id' => 2, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 2, 'block_id' => 3, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 3, 'block_id' => 1, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 3, 'block_id' => 3, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 4, 'block_id' => 2, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 5, 'block_id' => 4, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 5, 'block_id' => 5, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 5, 'block_id' => 6, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 6, 'block_id' => 4, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 6, 'block_id' => 5, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 6, 'block_id' => 6, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 7, 'block_id' => 4, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 7, 'block_id' => 6, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1), array('page_id' => 8, 'block_id' => 5, 'zone' => 'ZONE1', 'order_id' => $order_id, 'is_active' => 1)));
 }
Esempio n. 4
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     // Reset table
     DB::table('roles')->truncate();
     $roles = Pongo::system('roles');
     foreach ($roles as $name => $level) {
         $role = array('name' => $name, 'level' => $level);
         DB::table('roles')->insert($role);
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('user_details', function (Blueprint $table) {
         $table->increments('id')->unsigned();
         $table->integer('user_id')->unsigned()->index();
         foreach (Pongo::forms('user_details') as $name => $config) {
             $options = array($name);
             if (is_numeric($config['len'])) {
                 array_push($options, $config['len']);
             }
             call_user_func_array(array($table, $config['type']), $options);
         }
         $table->timestamps();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE')->onUpdate('CASCADE');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('posts', function (Blueprint $table) {
         $table->increments('id')->unsigned();
         $table->integer('author_id')->unsigned()->index();
         $table->string('lang', 5);
         foreach (Pongo::forms('posts') as $name => $config) {
             $options = array($name);
             if (is_numeric($config['len'])) {
                 array_push($options, $config['len']);
             }
             call_user_func_array(array($table, $config['type']), $options);
         }
         $table->integer('edit_level');
         $table->boolean('is_active');
         $table->timestamps();
     });
 }
Esempio n. 7
0
 public function onUpload($model, $file, $page_id)
 {
     $path = \Pongo::settings('upload_path');
     // file name
     $file_name = $file->getClientOriginalName();
     // file size
     $file_size = $file->getSize();
     // file extension
     $file_ext = $file->getClientOriginalExtension();
     // dir type
     $folder_name = \Media::getFolderName($file_name);
     // upload path
     $upload_path = public_path($path . $folder_name);
     // Format file name
     $format_name = \Media::formatFileName($file_name);
     // Save to disk
     $file->move($upload_path, $format_name);
     // file path
     $file_path = $upload_path . $format_name;
     // http path
     $http_path = '/' . $path . $folder_name . $format_name;
     if (\Media::isImage($format_name)) {
         $picture = \App::make('Pongo\\Cms\\Services\\Picture\\PictureInterface');
         $image = $picture->make($file_path);
         $image_w = $image->width();
         $image_h = $image->height();
         $is_image = 1;
         // Create thumb?
         $picture->thumb($image, $format_name, 'cms');
     } else {
         $image_w = 0;
         $image_h = 0;
         $is_image = 0;
     }
     $file_arr = array('name' => $format_name, 'original' => $file_name, 'ext' => $file_ext, 'size' => $file_size, 'w' => $image_w, 'h' => $image_h, 'path' => $http_path, 'is_image' => $is_image, 'is_active' => 1);
     // Create file in 'files'
     $new_file = $model->create($file_arr);
     // Update pivot 'file_page'
     $new_file->pages()->attach($page_id, array('is_active' => 1));
     return $new_file;
 }
Esempio n. 8
0
 public function deleting($user)
 {
     // Admin account
     if ($user->id == \Pongo::settings('admin_account.id')) {
         $this->setFlashError('alert.error.user_admin');
         return false;
     }
     // Account own pages
     if (count($user->pages)) {
         $this->setFlashError('alert.error.user_own_pages');
         return false;
     }
     // Delete itself
     if ($user->id == USERID) {
         $this->setFlashError('alert.error.user_current');
         return false;
     }
     // Level is not enough
     if ($user->role->level > LEVEL) {
         $this->setFlashError('alert.error.user_deleted');
         return false;
     }
 }
Esempio n. 9
0
 /**
  * Shows a page
  * @param  array  $inject [description]
  * @return [type]         [description]
  */
 public function showPage($inject = array())
 {
     if ($this->redirect) {
         // If page empty, redirect to first child page
         return \Redirect::to($this->redirect);
     }
     // Settings :: Site Live: off
     if (!\Pongo::settings('site_live')) {
         $offline_page = $this->theme->service('offline');
         return $this->renderPage($offline_page);
     }
     return $this->renderPage($inject);
 }
Esempio n. 10
0
 /**
  * Change page insert language
  * @return json object
  */
 public function switchLanguage()
 {
     $lang = $this->input['lang'];
     $label = \Pongo::settings('languages.' . $lang . '.lang');
     \Session::put('LANG', $lang);
     $response = array('status' => 'success', 'msg' => t('alert.info.page_lang', array('lang' => $label)), 'lang' => $label);
     return $this->setSuccess($response);
 }
Esempio n. 11
0
 /**
  * [edit description]
  * @return [type] [description]
  */
 public function edit($page_id)
 {
     \Pongo::viewShare('page_id', $page_id);
     $page = $this->manager->getOne($page_id);
     return \Render::view('sections.pages.edit', array('page' => $page));
 }
Esempio n. 12
0
 /**
  * [onCreate description]
  * @param  [type] $block   [description]
  * @param  [type] $page_id [description]
  * @return [type]          [description]
  */
 public function onCreate($block, $page_id, $zone)
 {
     // Add record to pivot table 'block_page'
     $block->pages()->attach($page_id, array('zone' => $zone, 'order_id' => \Pongo::system('default_order'), 'is_active' => 0));
 }
Esempio n. 13
0
 /**
  * Print marker default
  * 
  * @param  string $marker
  * @return string
  */
 public function defaults($marker)
 {
     return \Pongo::markers($marker . '.default');
 }
Esempio n. 14
0
 public function loadThumb($path, $thumb = 'cms', $alt = '')
 {
     $file_name = $this->getFileName($path);
     if ($this->isImage($file_name)) {
         $thumb_name = $this->formatFileThumb($file_name, $thumb);
         $thumb_path = str_replace($file_name, $thumb_name, $path);
         $w = \Pongo::system($thumb . '.width');
         $h = \Pongo::system($thumb . '.height');
         $output = \HTML::image($thumb_path, $alt, array('class' => 'cms-thumb', 'width' => $w, 'height' => $h));
     } else {
         $ext = $this->fileExtension($file_name);
         $ico = \Pongo::settings('mimes.' . $ext);
         $output = '<span class="cms-thumb"><i class="' . $ico . '"></i></span>';
     }
     return $output;
 }
Esempio n. 15
0
 public function isEnabled()
 {
     return \Pongo::settings('cache_enabled');
 }
Esempio n. 16
0
 /**
  * Render PongoCMS main menu
  * Based on config/system.php sections array
  *
  * @param  array $sections
  * @return void
  */
 public function sectionMenu($sections = array())
 {
     $menu_view = $this->view('partials.items.menuitem');
     $menu_view['sections'] = !empty($sections) ? $sections : \Pongo::system('sections');
     return $menu_view;
 }
Esempio n. 17
0
 /**
  * [saveCustomForm description]
  * @param  [type] $form [description]
  * @param  string $msg  [description]
  * @return [type]       [description]
  */
 public function saveCustomForm($name, $form, $msg = 'alert.success.save')
 {
     $form_structure = \Pongo::forms($form);
     extract($this->input);
     $model = $this->model->find($id)->{$name};
     foreach ($form_structure as $field => $value) {
         if ($value['form'] == 'date') {
             $model->{$field} = \Carbon\Carbon::create($birth_year, $birth_month, $birth_day);
         } elseif ($value['form'] == 'datetime') {
             $model->{$field} = \Carbon\Carbon::create($birth_year, $birth_month, $birth_day, $birth_hh, $birth_mm);
         } else {
             $model->{$field} = ${$field};
         }
     }
     $model->save();
     return $this->setSuccess($msg);
 }
Esempio n. 18
0
 /**
  * [roleUser description]
  * @return [type] [description]
  */
 public function roleUser()
 {
     if ($this->input) {
         $role_id = $this->input['item_id'];
         $user_id = $this->input['user_id'];
         if (\Pongo::settings('admin_account.id') == $user_id) {
             return $this->setError('alert.error.user_admin_role');
         } else {
             $user = $this->model->find($user_id);
             $user->role_id = $role_id;
             $user->save();
             $this->events->fire('user.changerole', array($user, $user->role));
             return $this->setSuccess('alert.success.role_modified');
         }
     }
 }