当前位置: 首页>>代码示例>>PHP>>正文


PHP Album::add方法代码示例

本文整理汇总了PHP中Album::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::add方法的具体用法?PHP Album::add怎么用?PHP Album::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Album的用法示例。


在下文中一共展示了Album::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_add_album

 public function action_add_album()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $album = new Album();
         if ($_POST['name'] != "") {
             $album->set_name_album($_POST['name']);
         } else {
             $this->_error_msg = "Il y a une erreur dans le nom de l'album.";
             $this->_error_form = true;
         }
         if (is_numeric($_POST['anneeF']) and preg_match("/^[0-2][0-9]{3}+\$/", $_POST['anneeF']) == 1) {
             $album->set_date_prod_album($_POST['anneeF']);
         } else {
             $this->_error_msg .= "<br>Il y a une erreur dans l\\'année de production (Format : AAAA).";
             $this->_error_form = true;
         }
         if ($this->_error_form == false) {
             $album->set_id_user_lif($user->get_id_user_lif());
             $album->set_id_band($_POST['band']);
             $album->add();
             return Redirect::to_action('album');
         } else {
             return Redirect::to_action('album@add')->with('error', true)->with('form', $_POST)->with('error_msg', $this->_error_msg);
         }
     }
 }
开发者ID:laiello,项目名称:atm-music,代码行数:29,代码来源:album.php

示例2: explode

list($url, $params) = explode('?', $url, 2);
$method = $_SERVER['REQUEST_METHOD'];
list($script, $section, $id, $action) = explode('/', $url, 4);
//Находим объект и тип действия
try {
    switch ($section) {
        case 'files':
            //Создаем и инициализируем экземпляр класса для работы с файлами
            $sql = new Sql('fotorama');
            $album = new Album($_REQUEST, array('tableName' => 'fotorama', 'files' => array(array('field' => 'full', 'dir' => 'files_original/', 'fit' => true, 'width' => 1200, 'height' => 1200, 'ext' => 'jpg'), array('field' => 'img', 'dir' => 'files_image/', 'fit' => 'contain', 'width' => 800, 'height' => 800, 'ext' => 'jpg'), array('field' => 'thumb', 'dir' => 'files_thumb/', 'fit' => 'cover', 'width' => 160, 'height' => 160, 'ext' => 'png')), 'maxSize' => '4M', 'maxSpace' => '100M', 'maxNumberOfFiles' => 100, 'allowedType' => array('jpeg', 'jpg', 'png', 'gif', 'bmp', 'psd', 'psp', 'ai', 'eps', 'cdr', 'mp3', 'mp4', 'wav', 'aac', 'aiff', 'midi', 'avi', 'mov', 'mpg', 'flv', 'mpa', 'pdf', 'txt', 'rtf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'djvu', 'djv', 'bat', 'cmd', 'dll', 'inf', 'ini', 'ocx', 'sys', 'htm', 'html', 'write', 'none', 'zip', 'rar', 'dmg', 'sitx')));
            switch ($method) {
                case 'GET':
                    $res = isset($id) ? $album->getOne($id) : $album->get();
                    break;
                case 'PUT':
                    $res = $album->add();
                    break;
                case 'POST':
                    $res = isset($id) ? $album->update($id, $r) : $sql->savesort($r['sort']);
                    break;
                case 'DELETE':
                    $res = $album->delete($id);
                    break;
            }
            break;
        default:
            throw new Exception('Не получен тип действия', 15);
    }
    if (isset($res)) {
        echo json_encode($res);
    }
开发者ID:nikhiln,项目名称:ap.fotorama,代码行数:31,代码来源:action.php

示例3: addAlbum

 private function addAlbum()
 {
     Module::dependencies(isset($_POST['title']));
     $album = new Album($this->database, $this->plugins, $this->settings, null);
     echo $album->add($_POST['title']);
 }
开发者ID:fredrikcarno,项目名称:Lychee,代码行数:6,代码来源:Admin.php

示例4: server

 public function server($path, $albumID = 0)
 {
     # Check dependencies
     self::dependencies(isset($this->database, $this->plugins, $this->settings));
     # Parse path
     if (!isset($path)) {
         $path = LYCHEE_UPLOADS_IMPORT;
     }
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     if (is_dir($path) === false) {
         Log::error($this->database, __METHOD__, __LINE__, 'Given path is not a directory (' . $path . ')');
         return 'Error: Given path is not a directory!';
     }
     # Skip folders of Lychee
     if ($path === LYCHEE_UPLOADS_BIG || $path . '/' === LYCHEE_UPLOADS_BIG || $path === LYCHEE_UPLOADS_MEDIUM || $path . '/' === LYCHEE_UPLOADS_MEDIUM || $path === LYCHEE_UPLOADS_THUMB || $path . '/' === LYCHEE_UPLOADS_THUMB) {
         Log::error($this->database, __METHOD__, __LINE__, 'The given path is a reserved path of Lychee (' . $path . ')');
         return 'Error: Given path is a reserved path of Lychee!';
     }
     $error = false;
     $contains['photos'] = false;
     $contains['albums'] = false;
     # Call plugins
     # Note that updated albumId and path explicitly passed, rather
     # than using func_get_args() which will only return original ones
     $this->plugins(__METHOD__, 0, array($albumID, $path));
     # Get all files
     $files = glob($path . '/*');
     foreach ($files as $file) {
         # It is possible to move a file because of directory permissions but
         # the file may still be unreadable by the user
         if (!is_readable($file)) {
             $error = true;
             Log::error($this->database, __METHOD__, __LINE__, 'Could not read file or directory: ' . $file);
             continue;
         }
         if (@exif_imagetype($file) !== false) {
             # Photo
             $contains['photos'] = true;
             if (!$this->photo($file, $albumID)) {
                 $error = true;
                 Log::error($this->database, __METHOD__, __LINE__, 'Could not import file: ' . $file);
                 continue;
             }
         } else {
             if (is_dir($file)) {
                 # Folder
                 $album = new Album($this->database, $this->plugins, $this->settings, null);
                 $newAlbumID = $album->add('[Import] ' . basename($file));
                 $contains['albums'] = true;
                 if ($newAlbumID === false) {
                     $error = true;
                     Log::error($this->database, __METHOD__, __LINE__, 'Could not create album in Lychee (' . $newAlbumID . ')');
                     continue;
                 }
                 $import = $this->server($file . '/', $newAlbumID);
                 if ($import !== true && $import !== 'Notice: Import only contains albums!') {
                     $error = true;
                     Log::error($this->database, __METHOD__, __LINE__, 'Could not import folder. Function returned warning.');
                     continue;
                 }
             }
         }
     }
     # Call plugins
     # Note that updated albumId and path explicitly passed, rather
     # than using func_get_args() which will only return original ones
     $this->plugins(__METHOD__, 1, array($albumID, $path));
     # The following returns will be caught in the front-end
     if ($contains['photos'] === false && $contains['albums'] === false) {
         return 'Warning: Folder empty or no readable files to process!';
     }
     if ($contains['photos'] === false && $contains['albums'] === true) {
         return 'Notice: Import only contained albums!';
     }
     if ($error === true) {
         return false;
     }
     return true;
 }
开发者ID:gautamkrishnar,项目名称:Lychee,代码行数:81,代码来源:Import.php

示例5: server

 public function server($path, $albumID = 0)
 {
     # Check dependencies
     self::dependencies(isset($this->settings));
     # Parse path
     if (!isset($path)) {
         $path = LYCHEE_UPLOADS_IMPORT;
     }
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     if (is_dir($path) === false) {
         return 'Error: Given path is not a directory!';
     }
     # Skip folders of Lychee
     if ($path === LYCHEE_UPLOADS_BIG || $path . '/' === LYCHEE_UPLOADS_BIG || $path === LYCHEE_UPLOADS_MEDIUM || $path . '/' === LYCHEE_UPLOADS_MEDIUM || $path === LYCHEE_UPLOADS_THUMB || $path . '/' === LYCHEE_UPLOADS_THUMB) {
         return 'Error: Given path is a reserved path of Lychee!';
     }
     $error = false;
     $contains['photos'] = false;
     $contains['albums'] = false;
     # Get all files
     $files = glob($path . '/*');
     foreach ($files as $file) {
         # It is possible to move a file because of directory permissions but
         # the file may still be unreadable by the user
         if (!is_readable($file)) {
             $error = true;
             continue;
         }
         if (@exif_imagetype($file) !== false) {
             # Photo
             $contains['photos'] = true;
             if (!$this->photo($file, $albumID)) {
                 $error = true;
                 continue;
             }
         } else {
             if (is_dir($file)) {
                 # Folder
                 $album = new Album($this->settings, null);
                 $newAlbumID = $album->add('[Import] ' . basename($file));
                 $contains['albums'] = true;
                 if ($newAlbumID === false) {
                     $error = true;
                     continue;
                 }
                 $import = $this->server($file . '/', $newAlbumID);
                 if ($import !== true && $import !== 'Notice: Import only contains albums!') {
                     $error = true;
                     continue;
                 }
             }
         }
     }
     # The following returns will be caught in the front-end
     if ($contains['photos'] === false && $contains['albums'] === false) {
         return 'Warning: Folder empty or no readable files to process!';
     }
     if ($contains['photos'] === false && $contains['albums'] === true) {
         return 'Notice: Import only contained albums!';
     }
     if ($error === true) {
         return false;
     }
     return true;
 }
开发者ID:waitman,项目名称:Lychee,代码行数:67,代码来源:Import.php

示例6: for_song

 public function for_song()
 {
     $error = array();
     $song_clem = DB::connection('clem')->query('SELECT title, album, artist, albumartist, year, genre, filename,track FROM songs');
     foreach ($song_clem as $value) {
         /* AJOUT D'ARTISTES */
         if (trim($value->artist) != '') {
             $band = new Band(null, 1, utf8_encode($value->artist), null, null);
             try {
                 $band->add();
             } catch (Exception $e) {
                 $this->_error_msg .= 'artiste :' . $e->getMessage() . '<br>';
                 break;
             }
         }
         /* AJOUT D'ALBUM */
         if (trim($value->album) != '') {
             $name_band = Band::from_name_band(utf8_encode($value->artist));
             $album = new Album(null, $name_band[0]->id_band, 1, utf8_encode($value->album), $value->year);
             try {
                 $album->add();
             } catch (Exception $e) {
                 $this->_error_msg .= 'album: ' . $e->getMessage() . '<br>';
                 break;
             }
         }
         if (trim($value->title) != '') {
             $album = Album::from_name_album(utf8_encode($value->album));
             $song = new song(null, 1, utf8_encode($value->title), $value->year, null, $value->filename, $value->track);
             $song->set_id_kind(explode(';', $value->genre));
             $song->id_album = $album[0]->id_album;
             try {
                 $song->add();
             } catch (Exception $e) {
                 $this->_error_msg .= 'chanson: ' . $e->getMessage() . '<br>';
                 break;
             }
         }
     }
     // var_dump($song_clem);
 }
开发者ID:laiello,项目名称:atm-music,代码行数:41,代码来源:upload.php

示例7: server

 static function server($albumID = 0, $path)
 {
     global $database, $plugins, $settings;
     # Parse path
     if (!isset($path)) {
         $path = LYCHEE_UPLOADS_IMPORT;
     }
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     if (is_dir($path) === false) {
         Log::error($database, __METHOD__, __LINE__, 'Given path is not a directory (' . $path . ')');
         return 'Error: Given path is not a directory!';
     }
     # Skip folders of Lychee
     if ($path === LYCHEE_UPLOADS_BIG || $path . '/' === LYCHEE_UPLOADS_BIG || $path === LYCHEE_UPLOADS_MEDIUM || $path . '/' === LYCHEE_UPLOADS_MEDIUM || $path === LYCHEE_UPLOADS_THUMB || $path . '/' === LYCHEE_UPLOADS_THUMB) {
         Log::error($database, __METHOD__, __LINE__, 'The given path is a reserved path of Lychee (' . $path . ')');
         return 'Error: Given path is a reserved path of Lychee!';
     }
     $error = false;
     $contains['photos'] = false;
     $contains['albums'] = false;
     # Invoke plugins directly, as instance method not valid here
     # Note that updated albumId and path explicitly passed, rather
     # than using func_get_args() which will only return original ones
     $plugins->activate(__METHOD__ . ":before", array($albumID, $path));
     # Get all files
     $files = glob($path . '/*');
     foreach ($files as $file) {
         # It is possible to move a file because of directory permissions but
         # the file may still be unreadable by the user
         if (!is_readable($file)) {
             $error = true;
             Log::error($database, __METHOD__, __LINE__, 'Could not read file or directory: ' . $file);
             continue;
         }
         if (@exif_imagetype($file) !== false) {
             # Photo
             if (!Import::photo($database, $plugins, $settings, $file, $albumID)) {
                 $error = true;
                 Log::error($database, __METHOD__, __LINE__, 'Could not import file: ' . $file);
                 continue;
             }
             $contains['photos'] = true;
         } else {
             if (is_dir($file)) {
                 # Folder
                 $name = mysqli_real_escape_string($database, basename($file));
                 $album = new Album($database, null, null, null);
                 $newAlbumID = $album->add('[Import] ' . $name);
                 $contains['albums'] = true;
                 if ($newAlbumID === false) {
                     $error = true;
                     Log::error($database, __METHOD__, __LINE__, 'Could not create album in Lychee (' . $newAlbumID . ')');
                     continue;
                 }
                 $import = Import::server($newAlbumID, $file . '/');
                 if ($import !== true && $import !== 'Notice: Import only contains albums!') {
                     $error = true;
                     Log::error($database, __METHOD__, __LINE__, 'Could not import folder. Function returned warning');
                     continue;
                 }
             }
         }
     }
     # Invoke plugins directly, as instance method not valid here
     # Note that updated albumId and path explicitly passed, rather
     # than using func_get_args() which will only return original ones
     $plugins->activate(__METHOD__ . ":after", array($albumID, $path));
     if ($contains['photos'] === false && $contains['albums'] === false) {
         return 'Warning: Folder empty or no readable files to process!';
     }
     if ($contains['photos'] === false && $contains['albums'] === true) {
         return 'Notice: Import only contains albums!';
     }
     return true;
 }
开发者ID:neynah,项目名称:Lychee,代码行数:77,代码来源:Import.php

示例8: server

 static function server($albumID = 0, $path, $useTemp = false)
 {
     global $database, $plugins, $settings;
     # Parse path
     if (!isset($path)) {
         $path = LYCHEE_UPLOADS_IMPORT;
     }
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     if (is_dir($path) === false) {
         Log::error($database, __METHOD__, __LINE__, 'Given path is not a directory (' . $path . ')');
         return 'Error: Given path is not a directory!';
     }
     # Skip folders of Lychee
     if ($path === LYCHEE_UPLOADS_BIG || $path . '/' === LYCHEE_UPLOADS_BIG || $path === LYCHEE_UPLOADS_THUMB || $path . '/' === LYCHEE_UPLOADS_THUMB) {
         Log::error($database, __METHOD__, __LINE__, 'Given path is a reserved path of Lychee (' . $path . ')');
         return 'Error: Given path is a reserved path of Lychee!';
     }
     /*if ($useTemp===true) {
     			$path = Import::move($database, $path);
     			if ($path===false) {
     				Log::error($database, __METHOD__, __LINE__, 'Failed to move import to temporary directory');
     				return false;
     			}
     		}*/
     $error = false;
     $contains['photos'] = false;
     $contains['albums'] = false;
     # Get all files
     $files = glob($path . '/*');
     foreach ($files as $file) {
         # It is possible to move a file because of directory permissions but
         # the file may still be unreadable by the user
         if (!is_readable($file)) {
             $error = true;
             Log::error($database, __METHOD__, __LINE__, 'Could not read file or directory: ' . $file);
             continue;
         }
         if (@exif_imagetype($file) !== false) {
             # Photo
             if (!Import::photo($database, $plugins, $settings, $file, $albumID)) {
                 $error = true;
                 Log::error($database, __METHOD__, __LINE__, 'Could not import file: ' . $file);
                 continue;
             }
             $contains['photos'] = true;
         } else {
             if (is_dir($file)) {
                 # Folder
                 $name = mysqli_real_escape_string($database, basename($file));
                 $album = new Album($database, null, null, null);
                 $newAlbumID = $album->add('[Import] ' . $name);
                 $contains['albums'] = true;
                 if ($newAlbumID === false) {
                     $error = true;
                     Log::error($database, __METHOD__, __LINE__, 'Could not create album in Lychee (' . $newAlbumID . ')');
                     continue;
                 }
                 $import = Import::server($newAlbumID, $file . '/', false);
                 if ($import !== true && $import !== 'Notice: Import only contains albums!') {
                     $error = true;
                     Log::error($database, __METHOD__, __LINE__, 'Could not import folder. Function returned warning');
                     continue;
                 }
             }
         }
     }
     # Delete tmpdir if import was successful
     /*if ($error===false&&$useTemp===true&&file_exists(LYCHEE_DATA . $tmpdirname)) {
     			if (@rmdir(LYCHEE_DATA . $tmpdirname)===false) Log::error($database, __METHOD__, __LINE__, 'Could not delete temp-folder (' . LYCHEE_DATA . $tmpdirname . ') after successful import');
     		}*/
     if ($contains['photos'] === false && $contains['albums'] === false) {
         return 'Warning: Folder empty or no readable files to process!';
     }
     if ($contains['photos'] === false && $contains['albums'] === true) {
         return 'Notice: Import only contains albums!';
     }
     return true;
 }
开发者ID:fredrikcarno,项目名称:Lychee,代码行数:80,代码来源:Import.php


注:本文中的Album::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。