/** * [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; } }
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; }
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; } }
/** * [language description] * @param [type] $lang [description] * @return [type] [description] */ public function language($lang) { $languages = \Pongo::settings('languages'); return $languages[$lang]['lang']; }
/** * [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'); } } }
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; }
/** * 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); }
/** * 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); }
public function isEnabled() { return \Pongo::settings('cache_enabled'); }