Inheritance: extends CI_Controller
 /**
  * Converts the response in JSON format to the value object i.e Album
  *
  * @params json
  *            - response in JSON format
  *
  * @return Album object filled with json data
  *
  */
 public function buildResponse($json)
 {
     $albumsJSONObj = $this->getServiceJSONObject("albums", $json);
     $albumJSONObj = $albumsJSONObj->__get("album");
     $albumObj = new Album();
     $albumObj->setStrResponse($json);
     $albumObj->setResponseSuccess($this->isRespponseSuccess($json));
     $this->buildObjectFromJSONTree($albumObj, $albumJSONObj);
     if (!$albumJSONObj->has("photos")) {
         return $albumObj;
     }
     if (!$albumJSONObj->__get("photos")->has("photo")) {
         return $albumObj;
     }
     if ($albumJSONObj->__get("photos")->__get("photo") instanceof JSONObject) {
         // Single Entry
         $photoObj = new Photo($albumObj);
         $this->buildObjectFromJSONTree($photoObj, $albumJSONObj->__get("photos")->__get("photo"));
         $photoObj = $this->setTagList($photoObj, $albumJSONObj->__get("photos")->__get("photo"));
     } else {
         // Multiple Entry
         $photoJSONArray = $albumJSONObj->__get("photos")->getJSONArray("photo");
         for ($i = 0; $i < count($photoJSONArray); $i++) {
             $photoJsonObj = $photoJSONArray[$i];
             $photoJSONObj = new JSONObject($photoJsonObj);
             $photoObj = new Photo($albumObj);
             $this->buildObjectFromJSONTree($photoObj, $photoJSONObj);
             $photoObj = $this->setTagList($photoObj, $photoJSONObj);
         }
     }
     return $albumObj;
 }
 /**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new album entry. For POST request,
  * validate form data and save information to database. Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $albumDAO = AlbumDAO::getInstance();
     $album = null;
     $form_errors = array();
     $form_values = array("title" => "");
     if (!empty($_POST)) {
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_errors)) {
             $album = new Album();
             $album->setTitle($form_values["title"]);
             if ($albumDAO->insert($album)) {
                 $session->setMessage("Album saved");
                 header("Location: edit_album.php?id={$album->id}");
                 return;
             } else {
                 $session->setMessage("Album not saved");
             }
         }
     }
     $this->template->render(array("title" => "Create Album", "session" => $session, "main_page" => "create_album_tpl.php", "album" => $album, "form_values" => $form_values, "form_errors" => $form_errors));
 }
 protected function createAlbum()
 {
     $album = new Album();
     $album->setName('Test Album');
     $album->setArtistId(3);
     return $album;
 }
Beispiel #4
0
function toolbox_crop_image($albumname, $imagename)
{
    $album = new Album(new Gallery(), $albumname);
    if ($album->isMyItem(ALBUM_RIGHTS)) {
        $image = newimage($album, $imagename);
        if (isImagePhoto($image)) {
            ?>
			<li>
			<a href="<?php 
            echo WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER;
            ?>
/crop_image.php?a=<?php 
            echo pathurlencode($albumname);
            ?>
					&amp;i=<?php 
            echo urlencode($imagename);
            ?>
&amp;performcrop=frontend "><?php 
            echo gettext("Crop image");
            ?>
</a>
			</li>
			<?php 
        }
    }
}
Beispiel #5
0
 function action()
 {
     $category = new Category();
     $kdgs = new Kdgs();
     $album = new Album();
     $story_url = new StoryUrl();
     $category_list = $category->get_list("`res_name`='kdgs' and `s_id`='0'");
     foreach ($category_list as $k => $v) {
         $page = 1;
         while (true) {
             $album_list = $kdgs->get_children_category_album_list($v['s_p_id'], $page);
             if (!$album_list) {
                 break;
             }
             foreach ($album_list as $k2 => $v2) {
                 $exists = $album->check_exists("`link_url` = '{$v2['url']}'");
                 if ($exists) {
                     continue;
                 }
                 $album_id = $album->insert(array('title' => $v2['title'], 'min_age' => $v2['min_age'], 'max_age' => $v2['max_age'], 'intro' => '', 's_cover' => $v2['cover'], 'link_url' => $v2['url'], 'add_time' => date('Y-m-d H:i:s')));
                 $story_url->insert(array('res_name' => 'album', 'res_id' => $album_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
             }
             $page++;
         }
     }
 }
Beispiel #6
0
 /**
  * Get model gallery
  * @param Model $Model
  * @return mixed
  */
 public function getGallery(Model $Model, $object_id = null)
 {
     $Album = new Album();
     if (!$object_id) {
         $object_id = $Model->id;
     }
     return $Album->getAttachedAlbum($Model->alias, $object_id);
 }
Beispiel #7
0
 public function invokeHandler(Smarty $viewModel, Header $header, $f, $page, $aid)
 {
     $header->title('PayPic');
     $header->import('picbootstrap', 'mypage');
     $viewModel->assign("pname", "@RTPic");
     $album = new Album($aid);
     $viewModel->assign("images", $album->getImges());
     return "images";
 }
function unpublishSubalbums($album)
{
    global $gallery;
    $albums = $album->getAlbums();
    foreach ($albums as $albumname) {
        $subalbum = new Album($gallery, $albumname);
        $subalbum->setShow(false);
        $subalbum->save();
        unpublishSubalbums($subalbum);
    }
}
Beispiel #9
0
 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();
 }
Beispiel #10
0
	/** 
	 * TC12: Create operation on Albums
	*	Test to verify that the database can save new albums
	*	The test is performed by creating an album object with the required input fields
	*	Once the test is complete no errors will appear and the album will be in the database
	*/
	public function testCreateAlbum() {
		//Create the album
		$album = new Album();

		$album['artist_id'] = $this->artist['artist_id'];
		$album['name'] = 'testalbum2';
		$album['added_by_user_id'] = 1; //SYSTEM user

		$album->save();
		
		//Verify it exist now
		$this->assertTrue($album->exists());
	}
Beispiel #11
0
 public static function read($id)
 {
     global $db;
     if ($db) {
         $q = $db->prepare('SELECT * FROM `album` WHERE id = ?');
         $q->execute(array($id));
         if ($item = $q->fetch()) {
             $album = new Album($item['album_title'], $item['date'], $item['format']);
             $album->setID($item['id']);
             return $item;
         }
     }
     return false;
 }
 public function testCreateAlbum()
 {
     $album = Album::create('My Album');
     $album2 = Album::byId($album->getId());
     $this->assertEquals($album->getId(), $album2->getId());
     $this->assertEquals($album->getName(), $album2->getName());
 }
Beispiel #13
0
 public function testRemoveAlbumFromArtist()
 {
     $artist = Artist::create('id', 'Artist name');
     $artist->addAlbum(Album::create('id', 'Album name'));
     $artist->removeAlbum(Album::create('id', 'Album name'));
     $this->assertCount(0, $artist->getAlbums());
 }
 public function getIndex()
 {
     if (Auth::guest() || Auth::user()->isAdmin == 0) {
         return Redirect::secure('/');
     }
     // layouts variables
     $this->layout->title = 'Админ панел | Нещо Шантаво';
     $this->layout->canonical = 'https://neshto.shantavo.com/admin/';
     $this->layout->robots = 'noindex,nofollow,noodp,noydir';
     $users = count(User::all());
     $admins = count(User::where('isAdmin', ">", 0)->get());
     $categories = count(Category::all());
     $albums = count(Album::all());
     $votes = count(DB::table('votes')->get());
     $pictures = count(Picture::all());
     $pictureSize = 0;
     foreach (Picture::all() as $p) {
         $pictureSize += $p->size;
     }
     // get disqus stats
     include app_path() . '/config/_disqus.php';
     $disqus = new DisqusAPI(getDisqusKey());
     $disqus->setSecure(false);
     $comments = $disqus->posts->list(array('forum' => 'shantavo'));
     // nesting the view into the layout
     $this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments));
 }
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $pAlbumId = $this->getParam('album_id');
     $pDossierId = $this->getParam('dossier_id');
     // $album_dao = _dao("album");
     $dossier_dao = _dao("dossier");
     $photo_dao = _dao("photo");
     if ($pDossierId > 0) {
         $dossier = $dossier_dao->get($pDossierId);
     } else {
         $dossier->dossier_id = 0;
         $dossier->dossier_album = $this->getParam('album_id');
         $dossier->dossier_parent = -1;
         $dossier->dossier_nom = CopixI18N::get('album|album.message.topfolder');
         $dossier->dossier_comment = "";
         $dossier->album_id = $pAlbumId;
     }
     if ($dossier->dossier_album != $pAlbumId) {
         return false;
     }
     $pictures = $photo_dao->findAllByAlbumAndFolder($pAlbumId, $pDossierId);
     $tpl->assign('album_id', $pAlbumId);
     $tpl->assign('dossier_id', $pDossierId);
     $tpl->assign('dossier', $dossier);
     $tpl->assign('pictures', $pictures);
     $tpl->assign('picture_thumbsize', '_s64');
     $dossiers_tree = Album::getFoldersTree($pAlbumId);
     $dossiers_commands = Album::tree2commands($dossiers_tree);
     $tpl->assign('commands_move', $dossiers_commands);
     $toReturn = $tpl->fetch('editphotos.tpl');
     return true;
 }
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $dossiers_tree = $this->getParam('tree');
     $dossiers_commands = Album::tree2commands($dossiers_tree);
     $dossiers_tree_move = Album::tree2move($dossiers_tree, $this->getParam('dossier_id'));
     $dossiers_commands_move = Album::tree2commands($dossiers_tree_move);
     //Kernel::MyDebug( $dossiers_commands_move );
     $tpl->assign('album_id', $this->getParam('album_id'));
     $tpl->assign('dossier_id', $this->getParam('dossier_id'));
     $tpl->assign('dossier', $this->getParam('dossier'));
     $tpl->assign('commands', $dossiers_commands);
     $tpl->assign('commands_move', $dossiers_commands_move);
     $tpl->assign('dossiermenu', $this->getParam('dossiermenu'));
     switch ($this->getParam('mode')) {
         case 'htmllist':
             $toReturn = $tpl->fetch('dossierstree_htmllist.tpl');
             break;
         case 'combo':
         default:
             $toReturn = $tpl->fetch('dossierstree_combo.tpl');
             break;
     }
     return true;
 }
Beispiel #17
0
 function showFiles()
 {
     $path = $this->path;
     if (!$path) {
         return false;
     }
     if (is_dir($path)) {
         $dir = opendir($path);
         while ($file = readdir($dir)) {
             if ($file != '.' && $file != '..' && $file != '.htaccess') {
                 Album::$sobcategory = basename($path);
                 Album::$categories[basename($path)] = array('text' => basename($path), 'parent' => $path);
                 $this->path = "{$path}/{$file}";
                 $this->showFiles();
                 unset($file);
             }
         }
         closedir($dir);
         unset($dir);
     } else {
         if (preg_match('/.+(mp3|wav|wma)$/', $path) && is_file($path)) {
             Album::$musics[Album::$sobcategory][] = array('music' => $path);
         }
     }
     ksort(Album::$musics);
     return Album::$musics;
 }
 static function printAlbumMenuJumpAlbum($albums, $option, $albumpath, $level = 1)
 {
     global $_zp_gallery;
     foreach ($albums as $album) {
         $subalbum = new Album($_zp_gallery, $album, true);
         if ($option === "count" and $subalbum->getNumImages() > 0) {
             $count = " (" . $subalbum->getNumImages() . ")";
         } else {
             $count = "";
         }
         $arrow = str_replace(':', '&raquo; ', str_pad("", $level - 1, ":"));
         $selected = self::checkSelectedAlbum($subalbum->name, "album");
         $link = "<option {$selected} value='" . htmlspecialchars($albumpath . pathurlencode($subalbum->name)) . "'>" . $arrow . strip_tags($subalbum->getTitle()) . $count . "</option>";
         echo $link;
     }
 }
 /**
  * Create new Album
  *
  * Also updates Category modification time
  *
  * @param int $categoryId
  */
 public function create($categoryId)
 {
     $category = $this->getCategoryFinder()->findOneBy('id', $categoryId);
     if ($this->slim->request->isGet()) {
         $this->slim->render('album/create.html.twig', ['category' => $category, 'sessionUser' => $this->getSessionUser()]);
     } elseif ($this->slim->request->isPost()) {
         $name = $_POST['name'];
         $newAlbum = new Album($this->slim->db);
         $newAlbum->setCategoryId($category->getId());
         $newAlbum->setName($name);
         $newAlbum->insert();
         $category->update();
         $this->slim->flash('success', 'Album created');
         $this->slim->redirect('/categories/' . $categoryId . '/albums');
     }
 }
Beispiel #20
0
 public function testRemoveTrackFromAlbum()
 {
     $album = Album::create('id', 'Album name');
     $album->addTrack(Track::create('id', 'Track name'));
     $album->removeTrack(Track::create('id', 'Track name'));
     $this->assertCount(0, $album->getTracks());
 }
 function get_albums()
 {
     $images = Album::load_all($_SESSION['user']['id'], IMAGE_ALBUM);
     $audios = Album::load_all($_SESSION['user']['id'], AUDIO_ALBUM);
     $videos = Album::load_all($_SESSION['user']['id'], VIDEO_ALBUM);
     return array('images' => $images, 'audios' => $audios, 'videos' => $videos);
 }
    public static function show(Inputter $inputter, JSONOutputter $outputter)
    {
        //	Show
        //
        $id = $inputter->additional_uri_arguments[0];
        $error = null;
        UniversallyUniqueIdentifier::propertyIsValid('rawIdentifier', $id, $error);
        if (isset($error)) {
            $outputter->print_error($error);
        }
        //	User ID
        //
        $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
        $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
        $query_string = 'MATCH (object:Album)
						 WHERE object.' . UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION . ' = \'' . $id . '\'
						 RETURN object';
        $query = new Everyman\Neo4j\Cypher\Query($client, $query_string);
        $result = $query->getResultSet();
        if (count($result) > 0) {
            //	Compare sent data is equal to data retrieved
            //
            $object = $result[0]['object'];
            //	Print data
            //
            $outputter->print_data(array(Album::printer_dictionary($object)));
        } else {
            // Throw error, user doesn't exists
            //
            $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'Album with ID does not exist.');
            $outputter->print_error($error);
        }
    }
function getSubalbumImages($folder)
{
    global $imagelist;
    if (hasDyanmicAlbumSuffix($folder)) {
        return;
    }
    $album = new Album($gallery, $folder);
    $images = $album->getImages();
    foreach ($images as $image) {
        $imagelist[] = '/' . $folder . '/' . $image;
    }
    $albums = $album->getSubalbums();
    foreach ($albums as $folder) {
        getSubalbumImages($folder);
    }
}
 /**
  * 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 $id the ID of the model to be loaded
  * @return Album the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Album::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested album does not exist.');
     }
     return $model;
 }
/**
 * Returns the title from the feed's url for latest albums or a specific album rss
 *
 * @return string
 */
function getRSSAlbumTitle()
{
    global $_zp_gallery;
    $rssmode = getRSSAlbumsmode();
    if (isset($_GET['albumtitle'])) {
        $albumname = ' - ' . html_encode(sanitize(urldecode($_GET['albumtitle']))) . ' (' . gettext('latest images') . ')';
    } elseif ($rssmode == "albums" && !isset($_GET['folder'])) {
        $albumname = ' (' . gettext('latest albums') . ')';
    } elseif ($rssmode == 'albums' && isset($_GET['folder'])) {
        $folder = sanitize(urldecode($_GET['folder']));
        $albobj = new Album($_zp_gallery, $folder);
        $albumname = ' - ' . html_encode(strip_tags($albobj->getTitle())) . ' (' . gettext('latest albums') . ')';
    } else {
        $albumname = ' (' . gettext('latest images') . ')';
    }
    return $albumname;
}
 public function run()
 {
     $faker = Faker::create();
     $usersId = DB::table('users')->lists('id');
     for ($i = 0; $i < rand(10, 20); $i++) {
         Album::create(['name' => $faker->word(), 'owner_id' => $usersId[rand(0, sizeof($usersId) - 1)]]);
     }
 }
Beispiel #27
0
 public static function getIdsByNames($names)
 {
     if (!empty($names)) {
         return Album::whereIn('name', $names)->lists('id');
     } else {
         return 0;
     }
 }
Beispiel #28
0
 public function getSearch()
 {
     $key = Input::get('title');
     $data['albums'] = Album::select('*')->where('title', 'like', '%' . $key . '%')->get();
     return View::make('frontend/index')->with('data', $data);
     //         	SELECT * FROM `images` where images.`title` LIKE '%t%' OR images.album_id IN
     // (SELECT id FROM albums WHERE `title` LIKE '%t%')
 }
 protected function unlinkAlbumFromArtist($albumid)
 {
     $sql = "DELETE FROM  artist_album WHERE album_id=:album_id";
     $command = Album::model()->getDbConnection()->createCommand($sql);
     $command->bindValues(array(":album_id" => $albumid));
     $command->execute();
     return true;
 }
Beispiel #30
0
function search($database, $settings, $term)
{
    if (!isset($database, $settings, $term)) {
        return false;
    }
    $return['albums'] = '';
    # Initialize return var
    $return = array('photos' => null, 'albums' => null, 'hash' => '');
    ###
    # Photos
    ###
    // Photos
    if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title LIKE ? OR description LIKE ? OR tags LIKE ?");
    } else {
        if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
            $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title ILIKE ? OR description ILIKE ? OR tags ILIKE ?");
        } else {
            $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title LIKE ? OR description LIKE ? OR tags LIKE ?");
            Log::error($this->database, __METHOD__, __LINE__, 'Unknown database driver: ' . $database->getAttribute(PDO::ATTR_DRIVER_NAME));
        }
    }
    $result = $stmtP->execute(array('%' . $term . '%', '%' . $term . '%', '%' . $term . '%'));
    while ($photo = $stmtP->fetch(PDO::FETCH_ASSOC)) {
        $photo = Photo::prepareData($photo);
        $return['photos'][$photo['id']] = $photo;
    }
    ###
    # Albums
    ###
    if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $stmtA = $database->prepare("SELECT id, title, public, sysstamp, password FROM " . LYCHEE_TABLE_ALBUMS . " WHERE title LIKE ? OR description LIKE ?");
    } else {
        if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
            $stmtA = $database->prepare("SELECT id, title, public, sysstamp, password FROM " . LYCHEE_TABLE_ALBUMS . " WHERE title ILIKE ? OR description ILIKE ?");
        } else {
            Log::error($this->database, __METHOD__, __LINE__, 'Unknown database driver: ' . $database->getAttribute(PDO::ATTR_DRIVER_NAME));
        }
    }
    $result = $stmtA->execute(array('%' . $term . '%', '%' . $term . '%'));
    while ($album = $stmtA->fetch(PDO::FETCH_ASSOC)) {
        # Turn data from the database into a front-end friendly format
        $album = Album::prepareData($album);
        // Thumbs
        $stmtT = $database->prepare("SELECT thumburl FROM " . LYCHEE_TABLE_PHOTOS . " WHERE album = ? " . $settings['sortingPhotos'] . " LIMIT 3 OFFSET 0");
        $result2 = $stmtT->execute(array($album['id']));
        $k = 0;
        while ($thumb = $stmtT->fetchObject()) {
            $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
            $k++;
        }
        # Add to return
        $return['albums'][$album['id']] = $album;
    }
    # Hash
    $return['hash'] = md5(json_encode($return));
    return $return;
}