/** * Return the url to a photo * * @param Zend_Db_Table_Row $photo * @return string */ public function photoUrl($photo, $variant = '') { require_once APPLICATION_PATH . '/models/PhotoModel.php'; $model = new PhotoModel(); $path = $model->getImageFileName($photo, $variant); return substr($path, stripos($path, 'public') + 6); }
/** * Renders a photo stream * * @param Zend_Db_Table_Row $photo * @return string */ public function photoStream($photo, $partial = null) { require_once APPLICATION_PATH . '/models/PhotoModel.php'; $model = new PhotoModel(); $neighbours = $model->fetchNeighbours($photo); $params = array('previous' => $neighbours['previous'], 'next' => $neighbours['next']); $partial = is_null($partial) ? '_stream.phtml' : $partial; return $this->view->partial($partial, $params); }
function index() { $photo_model = new PhotoModel(); $photo = $photo_model->get_photo(); // var_dump($photo);die; $view = new View(); $view->set_file_name('photo'); $params = array('photo' => $photo); $view->show($params); }
/** * Renders a photo stream * * @param Zend_Db_Table_Row $photo * @return string */ public function photoTags($photo) { require_once APPLICATION_PATH . '/models/PhotoModel.php'; $model = new PhotoModel(); $tags = $model->fetchTags($photo); if (count($tags) > 0) { $params = array('tags' => $tags); return $this->view->partial('_tags.phtml', $params); } return ''; }
public function detail() { $vars = $_REQUEST; $album_id = intval($vars['id']); $photo_id = intval($vars['pid']); $album = M('PhotoA')->detail($album_id); if ($photo_id) { $photo = PhotoModel::detail($photo_id); } else { $photo = PhotoAModel::first_photo($album_id); } M('PhotoA')->updateReadCount($album_id); $photo = model('User')->formatForApi($photo, $photo['userId']); $photo['album'] = $album; $photo['is_favour'] = M('Favour')->is_favour($album_id, $this->mid, 'photo'); $this->assign('photo', $photo); $album_photos = PhotoModel::album_photos($album_id, $photo['id']); $this->assign('album_photos', self::format_photo_savepath($album_photos)); $comments = PhotoAModel::comments($album_id, 20); //$this->ajaxReturn($comments); $this->assign('comments', $this->format_comments($comments)); $hot_photos = PhotoModel::hot_photos(12); $this->assign('hot_photos', self::format_photo_savepath($hot_photos)); $this->display(); }
public function DeletePhoto($param) { $param['member_id'] = $this->decrypt($param['member_id']); $image = parent::GetPhotoProcess($param); // Delete Photo File unlink($image['im_link_thumbnail']); unlink($image['im_link_mini']); unlink($image['im_link_normal']); unlink($image['im_link_large']); return parent::DeletePhotoProcess($param); }
function LastListAction($info = array()) { $this->BaseSiteData(); $info['tab_list'] = TabController::getMainAlbumTabs(false, true, false); $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; $album_id = isset($album_id) && (int) $album_id > 0 ? $album_id : (int) Project::getRequest()->getKeyByNumber(0); $this->BaseAlbumData($info, $album_id); $photo_model = new PhotoModel(); $pager = new DbPager(Project::getRequest()->getValueByNumber(1), $this->getParam('last_photo_per_page', self::DEFAULT_PHOTO_PER_PAGE)); $photo_model->setPager($pager); $list = $photo_model->loadAll($request_user_id, $album_id); $this->checkImages($list); $info['photo_list'] = $list; $info['list_pager'] = $photo_model->getPager(); $info['list_controller'] = 'Photo'; $info['list_action'] = 'Album'; $info['list_user'] = null; $this->_view->LastList($info); $this->_view->parse(); }
public function ListSaveAction() { $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; $login = Project::getUser()->getDbUser()->login; $request = Project::getRequest(); if ($user_id !== $request_user_id) { // Can't save somebody's album $this->ListAction(); return; } $album = USER_UPLOAD_DIR . DIRECTORY_SEPARATOR . $login . DIRECTORY_SEPARATOR . 'album' . DIRECTORY_SEPARATOR; $thumbs = $album . 'thumbs' . DIRECTORY_SEPARATOR; $images = $album . 'images' . DIRECTORY_SEPARATOR; clearstatcache(); if (is_array($request->album_id)) { foreach ($request->album_id as $album_id) { $album_model = new AlbumModel(); $album_model->load($album_id); // Проверка, является ли пользователем владельцем альбома if ((int) $album_model->id > 0 && (int) $album_model->user_id === $user_id) { if (isset($request->delete[$album_id])) { // Delete album $photo_model = new PhotoModel(); $list = $photo_model->loadByAlbum($album_id); foreach ($list as $item) { $f = $thumbs . $item['path']; if (file_exists($f) && is_file($f)) { unlink($f); } $f = $images . $item['thumbnail']; if (file_exists($f) && is_file($f)) { unlink($f); } $photo_model->delete($item['id']); } $album_model->delete($album_id); } else { $album_model->is_onmain = isset($request->is_onmain[$album_id]) ? 1 : 0; $album_model->access = isset($request->album_access[$album_id]) ? $request->album_access[$album_id] : ACCESS::MYSELF; $album_model->name = isset($request->album_name[$album_id]) ? $request->album_name[$album_id] : $album_model->name; $album_model->save(); } } } } Project::getResponse()->redirect($request->createUrl('Album', 'List')); }
<?php if (!isset($argv[1]) or !isset($argv[2])) { echo "Usage: migrate.php <include path> <environment> \n"; exit; } set_include_path($argv[1]); define('ENVIRONMENT', $argv[2]); require_once dirname(__FILE__) . '/../../../application/bootstrap.php'; require_once APPLICATION_PATH . '/models/PhotoModel.php'; $photoModel = new PhotoModel(); foreach ($photoModel->fetchEntries() as $entry) { echo "Migrating [{$entry->id}] {$entry->title} \n"; $photoModel->update($entry->toArray(), $entry->id); }