/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndexing() { ini_set('max_execution_time', 0); ob_start(); $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true); $criteria = new CDbCriteria(); $criteria->compare('t.publish', 1); $criteria->order = 'album_id DESC'; //$criteria->limit = 10; $model = Albums::model()->findAll($criteria); foreach ($model as $key => $item) { if ($item->media_id != 0) { $images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media; } else { $images = ''; } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8')); $index->addDocument($doc); } echo 'Album Lucene index created'; $index->commit(); $this->redirect(Yii::app()->createUrl('article/search/indexing')); ob_end_flush(); }
function sidebar() { $return .= "\n\t<h4>Music Library</h4>\n\t<dl>\n\t\t<dt>Tracks</dt>\n\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\n\t\t<dt>Artists</dt>\n\t\t<dd>" . number_format(Artists::count()) . "</dd>\n\t\t<dt>Albums</dt>\n\t\t<dd>" . number_format(Albums::count()) . "</dd>\n\t</dl>"; function bytes($a) { $unim = array("B", "KB", "MB", "GB", "TB", "PB"); $c = 0; while ($a >= 1024) { $c++; $a = $a / 1024; } return number_format($a, $c ? 2 : 0, ".", ",") . " " . $unim[$c]; } $return .= "\n\t<h4>Archive Storage</h4>\n\t<dl>"; foreach (Archives::get_all() as $archive) { $pc = (int) (100 - $archive->get_free_space() / $archive->get_total_space() * 100); if ($archive->get_free_space() > 536870912000.0) { $colour = "success"; } else { if ($archive->get_free_space() > 214748364800.0) { $colour = "warning"; } else { $colour = "danger"; } } $return .= "\n\t\t<dt>" . $archive->get_name() . "</dt>\n\t\t<dd><div class=\"progress\" style=\"margin: 3px 0px; \"><div class=\"progress-bar progress-bar-" . $colour . "\" style=\"width: " . $pc . "%;\"></div></div></dd>\n\t\t<dd>" . bytes($archive->get_free_space()) . " free of " . bytes($archive->get_total_space()) . "</dd>"; } $return .= "</dl>"; return $return; }
public function processLoginWithFacebook($facebook_id, $age, $gender, $facebook_access_token, $photo, $username, $device_id) { $check = User::model()->findByAttributes(array('facebook_id' => $facebook_id)); if ($check) { $check->updated_at = time(); if ($check->save(FALSE)) { Yii::app()->session['user_id'] = $check->id; Yii::app()->session['user_avatar'] = $check->photo; ResponseHelper::JsonReturnSuccess($check, "Success"); } else { ResponseHelper::JsonReturnError("", "Server Error"); } } else { $model = new User(); $model->facebook_id = $facebook_id; $model->age = $age; $model->gender = $gender; $model->facebook_access_token = $facebook_access_token; $model->photo = $photo; $model->username = $username; $model->device_id = $device_id; $model->created_at = time(); $model->updated_at = time(); $model->status = 1; if ($model->save(FALSE)) { Yii::app()->session['user_id'] = $model->id; Yii::app()->session['user_avatar'] = $model->photo; $album = new Albums(); $album->user_id = $model->id; $album->album_name = 'Album chưa phân loại'; $album->created_at = time(); $album->updated_at = time(); $album->status = 1; if ($album->save(FALSE)) { ResponseHelper::JsonReturnSuccess($model, "Success"); } else { ResponseHelper::JsonReturnError("", "Server Error"); } } else { ResponseHelper::JsonReturnError("", "Server Error"); } } }
public function set_album($album_str) { if (!Albums::get_by_name($album_str)) { $album = new Album(); $album->set_name($album_str); $album->save(); } else { $album = Albums::get_by_name($album_str); } $this->music_album = $album->get_id(); }
protected function renderContent() { $controller = strtolower(Yii::app()->controller->id); //import model Yii::import('application.modules.album.models.AlbumPhoto'); Yii::import('application.modules.album.models.Albums'); $criteria = new CDbCriteria(); $criteria->condition = 'publish = :publish'; $criteria->params = array(':publish' => 1); $criteria->order = 'creation_date DESC'; $criteria->limit = 3; $model = Albums::model()->findAll($criteria); $this->render('album_recents', array('model' => $model)); }
public function actionShow($id, $mid) { Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . $id . ';', CClientScript::POS_HEAD); $user = UserProfile::model()->getUserProfile($id); $myPage = Yii::app()->user->id == $id; if ($album = Albums::model()->find('user_id=:user_id AND id = :album_id', array('user_id' => $id, 'album_id' => $mid))) { $model = Photos::model(); $photos = $model->LoadLimited($mid, 0); $list = $this->renderPartial('//profile/aphotos/photos_list', array('photos' => $photos, 'user_id' => $id), true); $this->render('photos', array('model' => $model, 'profile' => $user, 'myPage' => $myPage, 'album' => $album, 'photos_count' => count($photos), 'list' => $list)); } else { echo 'Альбом не существует.'; } }
public function getDetailAlbumByUser($user_id) { $returnArr = array(); $data = Albums::model()->findAllByAttributes(array('user_id' => $user_id)); foreach ($data as $item) { $itemArr = array(); $itemArr['album_id'] = $item->album_id; $itemArr['album_name'] = $item->album_name; $itemArr['updated_at'] = date('d/m/Y', $item->created_at); $itemArr['number_posts'] = $this->countNumberPostAlbum($item->album_id); $itemArr['images_preview'] = $this->getRandomPostOfAlbum($item->album_id); $itemArr['description'] = $item->description; $returnArr[] = $itemArr; } return $returnArr; }
public function actionIndex() { if (!empty($_POST)) { $images = CUploadedFile::getInstancesByName('images'); if (isset($images) && count($images) > 0) { // go through each uploaded image foreach ($images as $image => $pic) { $model = new Images(); $model->scenario = 'image'; $imageName = $this->getFileName($pic); $model->image = $imageName; if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) { $model->link = $imageName; $model->name = $pic->name; $model->created = time(); $model->album_id = Images::$IMAGE_PHOTO; //dump($model); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Thêm thành công.')); } else { dump($model->errors); } } // handle the errors here, if you want } } $this->redirect(PIUrl::createUrl('admin/images/index')); } $criteria = new CDbCriteria(); $criteria->condition = 'album_id=:album_id'; $criteria->order = 'id DESC'; $criteria->params = array(':album_id' => Images::$IMAGE_PHOTO); $count = Images::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = 18; $pages->applyLimit($criteria); $listImage = Images::model()->findAll($criteria); //dump($model); $dataAlbums = Albums::model()->getAlbums(); $this->render('index', compact('pages', 'dataAlbums', 'listImage')); }
protected function renderContent() { $controller = strtolower(Yii::app()->controller->id); //import model Yii::import('application.modules.album.models.AlbumPhoto'); Yii::import('application.modules.album.models.Albums'); Yii::import('application.modules.album.models.AlbumTag'); $criteria = new CDbCriteria(); if ($this->hastag != null) { $criteria->with = array('tag_ONE' => array('alias' => 'a'), 'tag_ONE.tag_TO' => array('alias' => 'b')); $criteria->condition = 't.publish = :publish AND b.body = :body'; $criteria->params = array(':publish' => 1, ':body' => $this->hastag); } else { $criteria->condition = 't.ublish = :publish'; $criteria->params = array(':publish' => 1); } $criteria->order = 't.creation_date DESC'; $criteria->limit = 6; $model = Albums::model()->findAll($criteria); $this->render('album_main_recents', array('model' => $model)); }
public function renderEdit($albumId) { $this->bag->album = $this->albums->findFirst()->where($albumId); }
public function deleteFormSubmitted(AppForm $form) { if ($form['delete']->isSubmittedBy()) { $album = new Albums(); $album->delete($this->getParam('id')); $this->flashMessage('Album has been deleted.'); } $this->redirect('default'); }
public function Photo($user) { $this_user = Users::where('account', $user)->first(); $album = Albums::where('user_id', $this_user['id'])->orderBy('created_at', 'desc')->get(); if ($this_user) { return View::make('frontend/profile/photo')->with('user', $this_user)->with('albums', $album); } else { return 'ko có user ' . $user; } }
* Copyright (C) 2007-2010, Ualink. All Rights Reserved. * * Licensed under The Languages Packages Licenses. * Support : phpb2b@hotmail.com * * @version $Revision: 1393 $ */ require "../libraries/common.inc.php"; require "room.share.php"; require LIB_PATH . 'page.class.php'; require CACHE_PATH . "cache_type.php"; uses("attachment", "album"); check_permission("album"); $attachment_controller = new Attachment('pic'); $attachment = new Attachments(); $album = new Albums(); $tpl_file = "album"; $page = new Pages(); if (empty($companyinfo)) { flash("pls_complete_company_info", "company.php", 0); } if (isset($_POST['do'])) { pb_submit_check('album'); $vals = $_POST['album']; $vals['title'] = $title = trim($vals['title']); $vals['description'] = $description = trim($vals['description']); $now_album_amount = $attachment->findCount(null, "created>" . $today_start . " AND member_id=" . $_SESSION['MemberID']); if (!empty($_FILES['pic']['name'])) { $type_id = 1; $attach_id = empty($id) ? "album-" . $_SESSION['MemberID'] . "-" . ($album->getMaxId() + 1) : "album-" . $_SESSION['MemberID'] . "-" . $id; $attachment_controller->title = $title;
public function actionUpdate($id = null) { $model = Albums::model()->findByPk($id); $flag = 0; $image_old = $model->attributes['image']; if (!empty($_POST['Albums'])) { if (!empty(CUploadedFile::getInstance($model, 'image')->name)) { $image_old = $model->attributes['image']; $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old); if (file_exists($path) && !empty($image_old)) { unlink($path); } $model->attributes = $_POST['Albums']; $model->image = CUploadedFile::getInstance($model, 'image'); $image = $model->image; $imageType = explode('.', $model->image->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; $model->image = $imageName; $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName; $flag = 1; } else { $model->attributes = $_POST['Albums']; $model->image = $image_old; } $model->created = time(); $model->alias = alias($_POST['Albums']['name']); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); if ($flag == 1) { $image->saveAs($images_path); } $this->redirect(PIUrl::createUrl('/admin/albums/')); } } $this->render('update', array('model' => $model)); }
} if ($query) { $search = Search::artists($query, 5); } $artists = $search["results"]; $artists_array = array(); if ($artists) { foreach ($artists as $artist) { $artist_object = Artists::get_by_id($artist); if ($artist_object) { $artist = array('id' => $artist_object->get_id(), 'title' => $artist_object->get_name(), 'href' => LINK_ABS . "music/search/?q=%22" . urlencode($artist_object->get_name()) . "%22&i=artist"); array_push($artists_array, $artist); } } } if ($query) { $search = Search::albums($query, 5); } $albums = $search["results"]; $albums_array = array(); if ($albums) { foreach ($albums as $album) { $album_object = Albums::get_by_id($album); if ($album_object) { $album = array('id' => $album_object->get_id(), 'title' => $album_object->get_name(), 'href' => LINK_ABS . "music/search/?q=%22" . urlencode($album_object->get_name()) . "%22&i=album"); array_push($albums_array, $album); } } } $array = array(array("title" => "Tracks", "href" => LINK_ABS . "music/search/?i=title&q=" . $query, "data" => $tracks_array), array("title" => "Artists", "href" => LINK_ABS . "music/search/?i=artist&q=" . $query, "data" => $artists_array), array("title" => "Albums", "href" => LINK_ABS . "music/search/?i=album&q=" . $query, "data" => $albums_array)); echo json_encode($array);
<?php $albumTitle = Albums::getTitleById($model->album_id); $this->breadcrumbs = array('Альбомы' => array('albums/index', 'id' => Yii::app()->user->id), $albumTitle->title => array('albums/view', 'id' => $model->album_id), 'Управление альбомом' => array('images/admin', 'id' => $model->album_id)); $this->renderPartial('_update', array('model' => $model));
<?php $albums = new Albums(); $list = $albums->getList()[0]; ?> <?php foreach ($list as $key => $value) { if (!empty($value)) { ?> <div class="album"> <header> <div class="left"> <?php echo $value['name']; ?> </div> <div class="right"> <form action="{SELECT}" method="GET"> <input type="hidden" name="id" value="<?php echo $value['id']; ?> "> <button class="btn-title"><i class="fa fa-eye"></i> Ver</button> </form> </div> </header> <div> <img src="../resources/images/zona.jpg" /> </div> </div> <?php
public static function getCategoryByUser($user_id) { $albums = Albums::model()->findAllByAttributes(array('user_id' => $user_id)); return $albums; }
<?php $albums = new Albums(); if (isset($_GET['id']) && !empty($_GET['id'])) { $list = $albums->getImages($_GET['id'])[0]; ?> <?php foreach ($list as $key => $value) { if (!empty($value)) { ?> <div class="img-album"> <img src="../../resources/images/images_albums/<?php echo $value['link']; ?> " /> <div> <?php $id = $value['id']; ?> <a data-toggle="modal" data-target="#modal" data-value="<?php echo $id; ?> " class="openModalDelete"><i class="fa fa-trash-o"></i></a> </div> </div> <?php } } } ?>
public function actionSet_poster_photo($mid) { $photo = Photos::model()->findByPk($mid); if ($album = Albums::model()->find('user_id = :my_id AND id = :album_id', array(':my_id' => Yii::app()->user->id, ':album_id' => $photo['album_id']))) { $album->current_photo = $mid; $album->save(); $status = 'ok'; } else { $status = 'no_album'; } echo json_encode(array('status' => $status)); }
function handleAlbumTitle($dom) { $album_class = new Albums(); $album = $album_class->fetchRow('id = ' . $this->album_id); $title = $dom->createElement('title'); $title->appendChild($dom->createTextNode($album->title)); return $title; }
public static function isCover($album_id, $photo_id) { $album = Albums::getById($album_id, 0); if ($album->thumb_id == $photo_id) return true; else return false; }
if (empty($_POST)) { ?> <form enctype="multipart/form-data" action="photo.php?action=move&aid=<?php echo $_GET['aid']; ?> &id=<?php echo $_GET['id']; ?> " method="post"> <div id = "content_2_row"> <div id = "content_2_row_name" style = "margin-top: 2px;"> Выберите альбом: </div> <select name = "album"> <option disabled >Альбомов нет</option> <? $albums = Albums::getAlbums(UID, 0); foreach ($albums as $value) { echo "<option value = '".$value->id."'>".$value->title."</option>"; } ?> </select> <input id = "button15" type="submit" value="Переместить"/> </div> </form> <? } else { echo Photos::move(UID, $_POST['album'], $_GET['id']);
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Albums::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.')); } return $model; }
<body> <?php // id пользователя (константа) define('USER', '81002130'); // подключение классов require_once '../../classes/vk/App.php'; require_once '../../classes/vk/User.php'; require_once '../../classes/vk/Post.php'; require_once '../../classes/vk/Photos.php'; require_once '../../classes/vk/Comment.php'; require_once '../../classes/vk/Group.php'; require_once '../../classes/vk/Format.php'; // получение инфы о пользователе $user = User::getUser(USER); // получение массива всех альбомов (кроме системных) $albums = Albums::getAlbums(USER, 0); ?> <header class="container"> <div class="row"> <div class="col-md-12"> <h1> <?php print $user->first_name; ?> <?php print $user->last_name; ?> </h1> <img class="userImage" src="<?php print $user->photo_100; ?>
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2133 $ */ require "../libraries/common.inc.php"; require "room.share.php"; require LIB_PATH . 'page.class.php'; require CACHE_PATH . "cache_type.php"; uses("attachment", "album"); check_permission("album"); $attachment_controller = new Attachment('pic'); $attachment = new Attachments(); $album = new Albums(); $tpl_file = "album"; $page = new Pages(); if (!$company->Validate($companyinfo)) { flash("pls_complete_company_info", "company.php", 0); } if (isset($_POST['do'])) { pb_submit_check('album'); $vals = $_POST['album']; $vals['title'] = $title = trim($vals['title']); $vals['description'] = $description = trim($vals['description']); $now_album_amount = $attachment->findCount(null, "created>" . $today_start . " AND member_id=" . $the_memberid); $id = intval($_POST['id']); if (!empty($_FILES['pic']['name'])) { $type_id = 1; $attach_id = empty($id) ? "album-" . $the_memberid . "-" . ($album->getMaxId() + 1) : "album-" . $the_memberid . "-" . $id;
public function saveAlbums($nCoolType) { $record = new AlbumsRecord(); $albums = new Albums(); $albums->setRecord(); $result = $record->saveRecord($nCoolType, $albums); if (!$result) { Log::write('RecordTask::saveAlbums():saveRecord() failed', 'log'); // return false; } $record->close(); $queue = new QueueTask(); $queue->push('albums', $nCoolType, json_encode($albums), 'coolshow_albums_count'); return true; }
public function deletePhotosInAlbum($album_id, $album = null) { $photos = $this->findAll(array('select' => 'file', 'condition' => 'album_id = :album_id', 'params' => array(':album_id' => $album_id))); if ($album == null) { $album = Albums::model()->findByPk($album_id); } foreach ($photos as $photo) { $this->deleteItem($photo, $album, null, false); } }
<?php // Get an existing artist $artist = Artists::findFirst('name = "Shinichi Osawa"'); // Create an album $album = new Albums(); $album->name = 'The One'; $album->artist = $artist; $songs = array(); // Create a first song $songs[0] = new Songs(); $songs[0]->name = 'Star Guitar'; $songs[0]->duration = '5:54'; // Create a second song $songs[1] = new Songs(); $songs[1]->name = 'Last Days'; $songs[1]->duration = '4:29'; // Assign the songs array $album->songs = $songs; // Save the album + its songs $album->save();
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionAjaxAdd($id) { $albumPhoto = CUploadedFile::getInstanceByName('namaFile'); $album_path = "public/album/" . $id; $fileName = time() . '_' . $id . '_' . Utility::getUrlTitle(Albums::getInfo($id, 'title')) . '.' . strtolower($albumPhoto->extensionName); if ($albumPhoto->saveAs($album_path . '/' . $fileName)) { $model = new AlbumPhoto(); $model->album_id = $id; $model->media = $fileName; if ($model->save()) { $url = Yii::app()->controller->createUrl('ajaxmanage', array('id' => $model->album_id)); echo CJSON::encode(array('id' => 'media-render', 'get' => $url)); } } }