/** * @param int $id_media */ public function get_thumb($id_media) { // Pictures data from database $picture = $id_media ? $this->media_model->get($id_media) : FALSE; // Path to the picture if ($picture && file_exists($picture_path = DOCPATH . $picture['path'])) { $thumb_path = DOCPATH . Settings::get('files_path') . str_replace(Settings::get('files_path') . '/', '/.thumbs/', $picture['base_path']); $return_thumb_path = $thumb_path . $picture['file_name']; // If no thumb, try to create it if (!file_exists($thumb_path . $picture['file_name'])) { $settings = array('size' => Settings::get('media_thumb_size') != '' ? Settings::get('media_thumb_size') : 120, 'unsharpmask' => false); try { $return_thumb_path = $this->medias->create_thumb(DOCPATH . $picture['path'], $thumb_path . $picture['file_name'], $settings); } catch (Exception $e) { $return_thumb_path = FCPATH . 'themes/' . Settings::get('theme_admin') . '/styles/' . Settings::get('backend_ui_style') . '/images/icon_48_no_folder_rights.png'; } } $mime = get_mime_by_extension($return_thumb_path); $content = read_file($return_thumb_path); self::push_thumb($content, $mime, 0); } else { $mime = 'image/png'; $content = read_file(FCPATH . 'themes/' . Settings::get('theme_admin') . '/styles/' . Settings::get('backend_ui_style') . '/images/icon_48_no_source_picture.png'); self::push_thumb($content, $mime, 0); } }
public static function saveMedia($id_user, $id_album, $name, $format, $ext = null) { // check if the user has the edit access on the album $access = UsersAlbumsAccess::getAlbumAccess($id_user, $id_album); if ($access && $access->edit_access) { if (isset(self::$_image_formats[$format])) { $media = new Medias(); $media->name = $name; $media->format = $ext == null ? self::$_image_formats[$format] : $ext; $media->id_album = $id_album; // if($media->save() == false) { // foreach ($media->getMessages() as $message) { // echo $message, "\n"; // } // } return $media->save(); } } return false; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $mesg = ""; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); //prepare tags most used $tags_most_used = TagsPosts::mostTagsUsed(); //paging media $medias_paging = Medias::getUserMedias(); $list = $medias_paging[0]; $pages = $medias_paging[1]; if (isset($_POST['Posts'])) { $model->attributes = $_POST['Posts']; $model->modified = date('Y-m-d h:i:s'); if (isset($_POST['featured_image_name'])) { $model->featured_image = $_POST['featured_image_name']; } if ($model->save()) { //add category to posts CategoriesPosts::deleteCategory($model->id); if (isset($_POST['Categories'])) { foreach ($_POST['Categories'] as $key => $value) { $category_post = new CategoriesPosts(); $category_post->post_id = $model->id; $category_post->category_id = $key; $category_post->save(); } } //add tags to posts TagsPosts::deleteTagsPost($model->id); if (isset($_POST['Tags'])) { TagsPosts::insertTagsPost($_POST['Tags'], $model->id); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess, 'tags_most_used' => $tags_most_used, 'mesg' => $mesg, 'list' => $list, 'pages' => $pages)); }
<?php session_start(); if (!isset($_SESSION['connecte']) || ($_SESSION['connecte'] = false)) { header("Location: connexion.php"); echo 'Test modif fvf blablabla'; } require_once 'class/medias.class.php'; $suppression = Medias::deleteMedia($_POST['nom'], $_POST['urlVideo'], $_POST['urlImage']); if (isset($_POST['image'])) { header("Location: images.php"); } else { header("Location: videos.php"); }
public function actionImageupload() { $model = new Medias('create'); $uploadedFile = CUploadedFile::getInstanceByName('uploadedfile'); if ($uploadedFile != null) { $model->real_name = $uploadedFile; $fileName = $model->getImageName($uploadedFile); $model->url = $fileName; $model->type = 'image-upload'; $model->title = substr($fileName, 25); } else { return; } if ($model->save()) { $model->saveImage($fileName, $uploadedFile); $this->layout = ""; $this->render('imageupload', array('model' => $model)); } }