本文整理匯總了PHP中models\User::artist方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::artist方法的具體用法?PHP User::artist怎麽用?PHP User::artist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::artist方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
public function edit($param)
{
$song_id = $param[0];
$songModel = new \Models\Song();
$this->data['title'] = 'Edit Song';
$this->data['albums'] = $this->albumModel->all();
$this->data['artist'] = User::artist();
$this->data['genre'] = $this->categoryModel->get(array('category_slug' => 'genre'));
$this->data['tags'] = $this->categoryModel->get(array('category_slug' => 'tag'));
$this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
if (isset($_POST) && !empty($_POST)) {
$songArray = array('song_album_id' => $_POST['album_id'], 'song_user_id' => Session::get('user_id'), 'song_artist_id' => $_POST['artist_id'], 'song_genre_id' => $_POST['genre_id'], 'song_status_id' => $_POST['status_id'], 'song_title' => $_POST['title'], 'song_description' => $_POST['description'], 'song_modified' => time(), 'song_slug' => Url::generateSafeSlug($_POST['title']));
$songArray = Gump::xss_clean($songArray);
$songArray = Gump::sanitize($songArray);
$update = $songModel->updateId($songArray, $song_id);
if ($update > 0) {
$message = 'ok';
} else {
$message = 'no';
}
if ($_FILES["mp3"]["tmp_name"] != '') {
//resize youtube image into uploads folder
Upload::setName(time());
Upload::upload_file($_FILES["mp3"], UPLOAD_PATH);
$filepath = UPLOAD_PATH . Upload::getName();
$outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName();
//check bitrate
$bitRate = Audio::bitRateSampleRate($filepath, 'bitrate');
$duration = Audio::duration($filepath);
if ($bitRate > 128) {
$convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3);
}
if (is_file($outputMp3)) {
$updateArray = array('song_file' => 'images/encoded_' . Upload::getName(), 'song_duration' => $duration);
unlink($filepath);
} else {
$updateArray = array('song_file' => Upload::getFileName('images'), 'song_duration' => $duration);
}
$saveMp3 = $songModel->updateId($updateArray, $song_id);
}
//UPLOAD SONG COVER
if ($_FILES["image"]["tmp_name"] != '') {
//upload file into uploads folder
Upload::setName(time());
Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
$update_data = array('song_image' => Upload::getFileName('images'));
$songModel->updateId($update_data, $song_id);
}
}
if ($message == 'ok') {
Session::set('success', 'record edited');
Url::redirect('song/item/' . $_POST['album_id']);
} else {
if ($message == 'no') {
$this->data['error'] = 'Operation Fails!';
}
}
$this->data['song'] = \Models\Song::item($song_id);
View::rendertemplate('header', $this->data);
View::rendertemplate('sidebar', $this->data);
View::render('song/song.edit', $this->data);
View::rendertemplate('footer', $this->data);
}
示例2: media
public function media($param)
{
$album_id = $param[0];
$this->data['album_id'] = $album_id;
if (isset($param[1]) && !empty($param[1])) {
$user_id = $param[1];
}
$this->data['artist'] = User::artist();
$album_detail = $this->albumModel->find($album_id);
$this->data['title'] = ucfirst($album_detail->album_name) . ' Album';
$albumitems = $this->mediaModel->getAlbumItems($album_id);
$this->data['category'] = $this->categoryModel->get(array('category_slug' => 'album'));
$this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
if (isset($_POST) && !empty($_POST)) {
$title = $_POST['title'];
$description = $_POST['description'];
$youtubelink = $_POST['youtubelink'];
$category_id = $_POST['category'];
$status_id = $_POST['status_id'];
$slug = Url::generateSafeSlug($title);
$mediaArray = array('media_album_id' => $album_id, 'media_category_id' => $category_id, 'media_status_id' => $status_id, 'media_title' => $title, 'media_description' => $description, 'media_youtubelink' => $youtubelink, 'media_created' => time(), 'media_slug' => $slug);
$mediaArray = Gump::xss_clean($mediaArray);
$mediaArray = Gump::sanitize($mediaArray);
$media_id = $this->mediaModel->create($mediaArray);
if ($media_id > 0) {
$message = 'ok';
} else {
$message = 'no';
}
//check if item is a video
$category_type = $this->categoryModel->find($_POST['category']);
if ($category_type->category_title == 'video' && isset($youtubelink) && $youtubelink != '') {
//item is a video
$youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/maxresdefault.jpg";
if (!file_exists($youtube_url)) {
$youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/hqdefault.jpg";
}
//resize youtube image into uploads folder
Upload::setName(time());
Upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px');
$image_name = Upload::getFileName('images');
$update_data = array('media_file' => $image_name);
$this->mediaModel->updateId($update_data, $media_id);
}
if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'audio') {
//resize youtube image into uploads folder
Upload::setName(time());
Upload::upload_file($_FILES["image"], UPLOAD_PATH);
$filepath = UPLOAD_PATH . Upload::getName();
$outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName();
//check bitrate
$bitRate = Audio::bitRateSampleRate($filepath, 'bitrate');
if ($bitRate > 128) {
$convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3);
}
if (is_file($outputMp3)) {
$updateArray = array('media_file' => 'images/encoded_' . Upload::getName());
unlink($filepath);
} else {
$updateArray = array('media_file' => Upload::getFileName('images'));
}
$saveMp3 = $this->mediaModel->updateId($updateArray, $media_id);
}
//UPLOAD ATTACHMENT
if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'image') {
//upload file into uploads folder
Upload::setName(uniqid());
Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
$image_name = Upload::getFileName('images');
$update_data = array('media_file' => $image_name);
$this->mediaModel->update($update_data, $media_id);
}
}
if ($message == 'ok') {
$this->data['success'] = 'Record Added!';
} else {
if ($message == 'no') {
$this->data['error'] = 'Operation Fails!';
}
}
$total = count($this->mediaModel->albumItems($album_id));
$pages = new Paginator('6', 'p');
$this->data['albumitems'] = $this->mediaModel->albumItems($album_id, $pages->getLimit());
$pages->setTotal($total);
$path = DIR . 'album/media/' . $album_id . '?';
$this->data['page_links'] = $pages->pageLinks($path, null);
View::rendertemplate('header', $this->data);
View::rendertemplate('sidebar', $this->data);
View::render('album/album.add_item', $this->data);
View::rendertemplate('footer', $this->data);
}