Esempio n. 1
0
 function fetch($annee = NULL)
 {
     if (!$this->activite) {
         return array('activites' => $this->unite->findActivites($annee));
     } else {
         $this->controller->assert(null, $this->activite, 'envoyer-photo', "Vous n'avez pas le droit d'envoyer de photo de " . $this->activite->getIntituleComplet() . ".");
     }
     $m = new Wtk_Form_Model('envoyer');
     $i = $m->addString('titre', 'Titre');
     $m->addConstraintRequired($i);
     $m->addFile('photo', "Photo");
     $m->addString('commentaire', 'Votre commentaire');
     $m->addBool('envoyer', "J'ai d'autres photos à envoyer", true);
     $m->addNewSubmission('envoyer', "Envoyer");
     $t = new Photos();
     if ($m->validate()) {
         $p = new Photo();
         $p->titre = $m->titre;
         $p->slug = $t->createSlug(wtk_strtoid($m->titre));
         $p->activite = $this->activite->id;
         $action = $m->envoyer ? 'envoyer' : 'consulter';
         $c = new Commentaire();
         $c->auteur = Zend_Registry::get('individu')->id;
         $c->message = $m->commentaire;
         $db = $t->getAdapter();
         $db->beginTransaction();
         try {
             $c->save();
             $p->commentaires = $c->id;
             $p->save();
             $i = $m->getInstance('photo');
             if ($i->isUploaded()) {
                 $tmp = $i->getTempFilename();
                 $p->storeFile($tmp);
             }
             $url = $this->controller->_helper->Url('voir', 'photos', null, array('photo' => $p->slug), true);
             $this->controller->logger->info("Photo envoyée", $url);
             foreach ($this->activite->findUnitesParticipantesExplicites() as $u) {
                 $ident = new Identification();
                 $ident->photo = $p->id;
                 $ident->unite = $u->id;
                 $ident->save();
                 $this->controller->logger->info("Unité identifiée sur une photo", $url);
             }
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         $this->controller->_helper->Flash->info("Photo envoyée");
         $this->controller->redirectSimple($action, null, null, array('album' => $this->activite->slug));
     }
     $photos = $this->activite->findPhotos($t->select()->order('date'));
     return array('unite' => $this->unite, 'annee' => $annee, 'model' => $m, 'activite' => $this->activite, 'photos' => $photos);
 }
Esempio n. 2
0
 function consulterAction()
 {
     $this->view->activite = $a = $this->_helper->Album();
     $this->metas(array('DC.Title' => $a->getIntitule(), 'DC.Subject' => 'photos'));
     $photos = new Photos();
     $s = $photos->select()->order('date');
     $this->view->photos = $a->findPhotos($s);
     $this->connexes->append("Chaîne", array('controller' => 'activites', 'action' => 'consulter', 'activite' => $a->slug, 'album' => null));
     $this->actions->append("Éditer la chaîne", array('controller' => 'activites', 'action' => 'editer', 'activite' => $a->slug, 'album' => null));
     $this->actions->append("Envoyer une photo", array('action' => 'envoyer'), array(null, $a, 'envoyer-photo'));
 }
 public function newAction()
 {
     $response = new ApiResponse();
     if ($this->request->isPost()) {
         $question = new Questions();
         $question->id = uniqid();
         $question->tags = $this->request->getPost('tags');
         $question->title = $this->request->getPost('title');
         $question->content = $this->request->getPost('content');
         $question->users_id = $this->request->getPost('users_id');
         if ($this->request->hasFiles() == true) {
             $baseLocation = 'files/';
             foreach ($this->request->getUploadedFiles() as $file) {
                 $photos = new Photos();
                 $unique_filename = $question->id;
                 $photos->size = $file->getSize();
                 $photos->original_name = $file->getName();
                 $photos->file_name = $unique_filename;
                 $photos->extension = $file->getExtension();
                 $location = $baseLocation . $unique_filename . "." . $file->getExtension();
                 $photos->public_link = $location;
                 try {
                     if (!$photos->save()) {
                         $response->setResponseError($photos->getMessages());
                     } else {
                         //Move the file into the application
                         $file->moveTo($location);
                         $question->photo = $photos->public_link;
                     }
                 } catch (PDOException $e) {
                     $response->setResponseError($e->getMessage());
                 }
             }
         }
         try {
             if ($question->save() == false) {
                 $response->setResponseError($question->getMessages());
             } else {
                 $response->setResponseMessage($question->id);
             }
         } catch (PDOException $e) {
             $response->setResponseError($e->getMessage());
         }
     } else {
         $response->setResponseError('Wrong HTTP Method');
     }
     return $response;
 }
Esempio n. 4
0
		public static function getAlbums($owner_id, $need_system) // Џолучение списка альбомов по id пользователЯ, $owner - id user, $need_system - view system albums
		{
			$data = App::api('photos.getAlbums', array ( 'owner_id' => $owner_id, 'need_system' => $need_system));
			$data_parse = array();
			for ($i = 0; $i < $data['count']; $i++)
			{
				if ($data['items'][$i]['thumb_id'] == 0)
				{
					$data['items'][$i]['photo_604'] = "http://vk.com/images/camera_400.gif";
				}
				else
				{
					$data_2 = Photos::get($owner_id, $data['items'][$i]['id'], 0, 0);
					foreach ($data_2 as $value)
					{
						if ($data['items'][$i]['thumb_id'] == $value->id)
						{
							$data['items'][$i]['photo_75'] = $value->photo_75;
							$data['items'][$i]['photo_130'] = $value->photo_130;
							$data['items'][$i]['photo_604'] = $value->photo_604;
							$data['items'][$i]['photo_1280'] = $value->photo_1280;
							$data['items'][$i]['photo_2560'] = $value->photo_2560;
							break;
						}
					}
				}
				$data_parse[$i] = new Albums($data['items'][$i]);
			}
			return $data_parse;
		}
Esempio n. 5
0
 function direct($throw = true)
 {
     $slug = $this->getRequest()->getParam('photo');
     $t = new Photos();
     try {
         $p = $t->findBySlug($slug);
     } catch (Strass_Db_Table_NotFound $e) {
         if ($throw) {
             throw new Strass_Controller_Action_Exception_NotFound("Photo " . $slug . " inconnue");
         } else {
             return null;
         }
     }
     $this->setBranche($p);
     return $p;
 }
Esempio n. 6
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     try {
         $model = $this->loadModel($id);
         $content = $model->content;
         $pattern = '/[{]G[0-9]{3,6}[}]/';
         preg_match_all($pattern, $content, $matches);
         if (!empty($matches)) {
             for ($i = 0; $i < count($matches[0]); $i++) {
                 if (!empty($matches[0][$i])) {
                     $code = $matches[0][$i];
                     $gallery_id = Galleries::model()->find(array('condition' => 'code = "' . $code . '"'))->id;
                     if (!empty($gallery_id)) {
                         $photos = Photos::model()->findAll(array('condition' => 'gallery_id =' . $gallery_id));
                         $htmlReplace = ActiveRecord::getHtmlGalleryBox($photos);
                     }
                 }
                 $content = str_replace($code, $htmlReplace, $content);
             }
         }
         $this->render('view', array('model' => $model, 'content' => $content, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }
Esempio n. 7
0
 public function displayList()
 {
     $id_lang = $this->context->language->id;
     $id_shop = $this->context->shop->id;
     $limit_per_page = intval($this->conf['list_limit_page']);
     $current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 1;
     $start = ($current_page - 1) * $limit_per_page;
     $list = PhotosCategory::getCategories();
     $listCategories = array();
     if (isset($list) && is_array($list) && count($list)) {
         /** pagination * */
         //            $nb_pages = ceil($nb_articles / $limit_per_page);
         //            $next = $current_page > 1 ? true : false; //articles plus recents
         //            $back = $current_page >= 1 && ($current_page < $nb_pages) ? true : false; //articles precedents
         $i = 0;
         foreach ($list as $cat) {
             $photos = Photos::getPhotosByCategory($cat['id_photo_cat']);
             $list_photo = array();
             foreach ($photos as $key => $val) {
                 $photo = $val;
                 $photo['average'] = PhotosRatting::getAverage($val['id_photo']);
                 $list_photo[] = $photo;
             }
             $cat['photos'] = $list_photo;
             $listCategories[] = $cat;
         }
         //            echo '<pre>';
         //            print_r($listCategories);
         //            echo '</pre>';
         $this->context->smarty->assign(array('list_categories' => $listCategories, 'img_photo_dir' => _THEME_PHOTO_DIR_, 'customer' => $this->context->customer->id));
     }
     $this->setTemplate('list.tpl');
 }
Esempio n. 8
0
 public function deleteAlbum($user_id, $album_id)
 {
     if ($album = $this->find('user_id = :my_id AND id = :album_id', array(':my_id' => $user_id, ':album_id' => $album_id))) {
         Photos::model()->deletePhotosInAlbum($album_id);
         $album->delete();
     }
 }
 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 'Альбом не существует.';
     }
 }
Esempio n. 10
0
function display_page_content()
{
    $photo_id = requestIdParam();
    $photo = Photos::FindById($photo_id);
    $next_photo = $photo->get_next_photo();
    $prev_photo = $photo->get_previous_photo();
    if ($prev_photo->id != $photo->id) {
        echo "<a href='" . get_link("/galleries/photo/{$prev_photo->id}") . "'>Previous</a>";
    }
    echo "<img src='{$photo->getPublicUrl()}' />";
    if ($next_photo->id != $photo->id) {
        echo "<a href='" . get_link("/galleries/photo/{$next_photo->id}") . "'>Next</a>";
    }
}
Esempio n. 11
0
 function indexAction()
 {
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     $viewRenderer->setView($this->initView());
     $pages = array(array('uri' => '/'), array('controller' => 'liens'), array('controller' => 'citation'));
     /* Les unités */
     $t = new Unites();
     foreach ($t->findRacines() as $u) {
         $spages = array();
         foreach ($u->findSousUnites(true, true) as $su) {
             array_push($spages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $su->slug)));
             array_push($spages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $su->slug)));
             array_push($spages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $su->slug)));
         }
         array_push($pages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $u->slug), 'pages' => $spages));
         array_push($pages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $u->slug)));
         array_push($pages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $u->slug)));
     }
     /* Journaux */
     $t = new Journaux();
     foreach ($t->fetchAll() as $j) {
         $articles = array();
         foreach ($j->findArticles('article.public IS NOT NULL OR article.public != 0') as $a) {
             array_push($articles, array('controller' => 'journaux', 'action' => 'consulter', 'params' => array('article' => $a->slug)));
         }
         array_push($pages, array('controller' => 'journaux', 'action' => 'lire', 'params' => array('journal' => $j->slug), 'pages' => $articles));
     }
     /* Photos promues */
     $t = new Photos();
     $s = $t->select()->where('promotion > 0');
     foreach ($t->fetchAll($s) as $p) {
         array_push($pages, array('controller' => 'photos', 'action' => 'voir', 'params' => array('photo' => $p->slug)));
     }
     $this->view->nav = new Zend_Navigation($pages);
     $this->getResponse()->setheader('Content-Type', 'text/xml');
     $this->render();
 }
 public function edit($plantID, $photoID, $photo)
 {
     if ($photo == null) {
         $fileName = $photoID . '-plant-' . $plantID . '.jpeg';
         $deleteRow = 'PlantPictures/' . $plantID . '/' . $fileName;
         File::delete(public_path() . '/PlantPictures/' . $plantID . '/' . $fileName);
         $photosRow = Photos::where('photo_url', '=', $deleteRow)->first();
         $photosRow->photo_url = 'null';
         $photosRow->save();
     } else {
         $fileName = $photoID . "-plant-" . $plantID . ".jpeg";
         $photoURL = "PlantPictures" . "/" . $plantID . "/";
         $editPhoto = Photos::where('plant_id', '=', $plantID)->get()[$photoID];
         $editPhoto->photo_url = $photoURL . $fileName;
         $editPhoto->save();
         $photo->move(public_path() . "/" . "PlantPictures" . "/" . $plantID . "/", $fileName);
     }
 }
Esempio n. 13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMrPhotos()
 {
     return $this->hasMany(Photos::className(), ['place_id' => 'id']);
 }
Esempio n. 14
0
 /**
  * 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 = Photos::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
Route::post('testupload', function () {
    $i = Input::all();
    $name = Input::file('file')->getClientOriginalName();
    $name = md5($name . Carbon::now());
    $image = $image2 = Image::make($i['file']->getRealPath());
    $image->save(public_path('upload') . '/' . $name . '.jpg');
    $upload = new Photos();
    $upload->filename = $name . '.jpg';
    $photo = [];
    $photo['image'] = 'image';
    if ($upload->save()) {
        $photo['photo'] = $upload;
        return $photo;
    }
    //	return $image;
});
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
/*DONT DELETE!!!*/
Esempio n. 16
0
function display_page_content()
{
    // Double check that the proper columns exist
    $video_id = find_db_column('photos', 'video_id');
    if (!$video_id) {
        echo '<h2 class="system-warning"><span>HCd&gt;CMS says:</span> The Photos table does not have a column called "video_id"</h2>';
    }
    $add_video = requestIdParam() == "add" ? true : false;
    if ($add_video) {
        $video = $videotitle = $videoservice = $videoembed = $videowidth = $videoheight = $videoposter = $attached_item = null;
    } else {
        $video_id = requestIdParam();
        $video = Videos::FindById($video_id);
        $videotitle = $video->get_title();
        $videoservice = $video->service;
        $videoembed = $video->embed;
        $videowidth = $video->width;
        $videoheight = $video->height;
        if ($video_id) {
            $possibleposter = Photos::FindVideoPoster($video_id);
            $videoposter = !empty($possibleposter) ? $possibleposter : null;
        }
    }
    ?>

	<script type="text/javascript">
		$().ready(function() {
			$("#edit_video").validate({
				rules : {
					title: "required", 
					embed: "required"
				},
				messages: {
					title: "Please enter a title for this video", 
					embed: "Please enter an embed code for this video"
				}
			});
		});
	</script>
	
	<div id="edit-header" class="videonav">
		<h1><?php 
    if ($add_video) {
        echo 'Add';
    } else {
        echo 'Edit';
    }
    ?>
 Video</h1>
	</div>
	
	<form method="POST" id="edit_video" enctype="multipart/form-data">
		
		<p class="display_name">
			<label for="title">Video Display Name:</label>
			<?php 
    textField("title", $videotitle, "required: true");
    ?>
<br />
			<span class="hint">This name should match the name you use on the embedding service source (YouTube or Vimeo), but it does not have to.</span>
		</p>
		
		<div class="column half">
    		<p><label for="service">Hosting Service:</label>
    			<select id="service" name="service">
    				<option value="youtube"<?php 
    if (!empty($video)) {
        if ($video->service == 'youtube') {
            echo ' selected';
        }
    }
    ?>
>YouTube</option>
    				<option value="vimeo"<?php 
    if (!empty($video)) {
        if ($video->service == 'vimeo') {
            echo ' selected';
        }
    }
    ?>
>Vimeo</option>
    			</select><br />
    			<span class="hint">Only two are supported at this time &mdash; YouTube is the default service.</span>
    		</p>
    		<p>
    			<label for="embed">Unique ID:</label>
    			<?php 
    textField("embed", $videoembed, "required: true");
    ?>
<br />
    			<span class="hint">The unique identifier is a random string of numbers and letters associated with the file. <br />
    			YouTube example: http://www.youtube.com/embed/<mark>tVUCsnMK18E</mark> <br />
    			Vimeo example: http://player.vimeo.com/video/<mark>72632269</mark> <br />
    			In both cases, we are only interested in the text highlighted.</span>
    		</p>
		</div>
		
		<div class="column half last">
    		<div class="column half">
        		<p>
        		    <label for="width">Video Width:</label>
        		    <?php 
    textField("width", $videowidth);
    ?>
        		</p>
    		</div>
    		<div class="column half last">
        		<p>
        		    <label for="height">Video Height:</label>
        		    <?php 
    textField("height", $videoheight);
    ?>
        		</p>
    		</div>
    		<div class="clearit"></div>
    		<p class="hint">With responsive design, the width may be set to 100% by the templates, so that number may not always be used</p>
    		
    		<?php 
    if ($video_id) {
        ?>
    		<!-- Video poster image -->
    		<p><label for="new_poster">Add/Edit a Poster image:</label>
				<input type="file" name="new_poster" id="new_poster" value="" />
			</p>
			<p class="hint">A poster image may be used by your site to display a link to a pop up video player. </p>
			<?php 
        if (!is_null($videoposter)) {
            echo '<h3>Existing Poster Image</h3>';
            echo '<p><img src="' . $videoposter->getPublicUrl() . '" style="max-width:100%;" alt=""></p>';
        }
        ?>
			<?php 
    }
    ?>
			
		</div>
		<div class="clearleft"></div>
		
<?php 
    // Show an attached Item if there is one.
    if (is_object($video)) {
        $attached_gallery = $video->getGallery();
        $attached_item = is_object($attached_gallery) ? $attached_gallery->get_item() : null;
    }
    if (is_object($attached_item)) {
        $section = array_shift($attached_item->getSections());
        echo '<h2>This video is attached to this Portfolio Item:</h2>';
        echo '<ol id="video_list" class="managelist">';
        echo '<li><a href="' . get_link("admin/portfolio_edit/" . $section->name . "/" . $attached_item->id) . '">' . $attached_item->get_title() . ' <small>EDIT</small></a></li>';
        echo '</ol>';
    }
    ?>
		
		<div id="edit-footer" class="videonav clearfix">
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Save Video" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Save and Return to List" />
				</p>
				
			</div>
			<div class="column half last">
<?php 
    $user = Users::GetCurrentUser();
    if ($user->has_role() && requestIdParam() != "add") {
        ?>
	
				<p><label for="delete">Delete this video?</label>
					<input name="delete" class="boxes" type="checkbox" value="<?php 
        echo $video->id;
        ?>
" />
					<span class="hint">Check the box and then click &ldquo;Save&rdquo; above to delete this video from the database</span>
				</p>
<?php 
    }
    ?>
			</div>
		</div>
	
	</form>
<?php 
}
Esempio n. 17
0
 public function actionAll()
 {
     $allPhotos = Photos::getAll();
     include __DIR__ . "/../views/photos.php";
 }
Esempio n. 18
0
								case (add):
									if (empty($_FILES))
									{
										?>
										<form enctype="multipart/form-data" action="album.php?action=add&id=<?php 
echo $_GET['id'];
?>
" method="post">
											<input id = "button15" type="file" name="photo"/>
											<input id = "button15" type="submit" value="Загрузить"/>
										</form>
										<?
									}
									else
									{
										$result = Photos::uploadPhoto($_GET['id'], $_FILES);
										if (!$result['error'])
										{
											echo "<h1 id = 'content_header_name'> Фотография успешно добавлена. </h1>";
										}
										else
										{
											echo "<h1 id = 'content_header_name'> При добавлении фотографии произошла ошибка. </h1>";
										}
									}
									break;
							}
						?>
					</div>
				</div>
				<div class = "clear"></div>
Esempio n. 19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPhotos()
 {
     return $this->hasMany(Photos::className(), ['user_id' => 'id']);
 }
Esempio n. 20
0
									<div class="likes">Лайков: <?php 
        print $photo->likes['count'];
        ?>
</div>
									<div class="comments">Комментариев: <?php 
        print $photo->comments['count'];
        ?>
</div>
									<div class="desc">Описание: <?php 
        print strLen($photo->text) > 0 ? $photo->text : '(описания нет)';
        ?>
</div>
									<hr>
									<div class="makeCover">
										<?php 
        if (Photos::isCover($_GET['id'], $photo->id)) {
            ?>
											<input class="form-control text-center" type="text" placeholder="Обложка" disabled>
										<?php 
        } else {
            ?>
											<form action="" method="post">
												<input type="hidden" name="mainPhoto" value="<?php 
            print $photo->id;
            ?>
">
												<button class="btn btn-default" type="submit" name="mainSave">
													<span class="glyphicon glyphicon-star-empty"></span>
													Сделать обложкой
												</button>
											</form>
Esempio n. 21
0
 public function actionDeletePhotoHandler()
 {
     if ($model = Photos::model()->findByPk(getParam('id'))) {
         $model->delete();
         $this->successfulAjaxResponse();
     } else {
         $this->unsuccessfulAjaxResponse();
     }
 }
Esempio n. 22
0
	public function testDelete()
	{
		$photo = Photos::get('Photo 3B');
		$photo->delete();
		
		$photobook = Photos::photobook('B');
		$this->assertEquals(5, count($photobook));
		$this->sanityCheck($photobook);
		$this->assertEquals('Photo 1B', $photobook[0]->name);
		$this->assertEquals('Photo 2B', $photobook[1]->name);
		$this->assertEquals('Photo 4B', $photobook[2]->name);
		$this->assertEquals('Photo 5B', $photobook[3]->name);
		$this->assertEquals('Photo 6B', $photobook[4]->name);
	}
Esempio n. 23
0
													<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']);
										}
									break;
								
							}
						?>
					</div>
				</div>
				<div class = "clear"></div>
			</div>
		</div>
	</body>
</html>
Esempio n. 24
0
function initialize_page()
{
    $post_action = $success = "";
    $gallery = Galleries::FindById(requestIdParam());
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Edit Gallery" || $post_action == "Edit and Return to List" || $post_action == "Add Image to Gallery") {
        if (isset($_POST['delete'])) {
            $photos = $gallery->get_photos();
            if (count($photos) > 0) {
                $success .= "Photos deleted / ";
            }
            foreach ($photos as $thephoto) {
                $thephoto->delete(true);
            }
            $gallery->delete(true);
            $success .= "Gallery deleted / ";
            setFlash("<h3>" . substr($success, 0, -3) . "</h3>");
            redirect("/admin/list_galleries");
        } else {
            // Name has changed.
            if ($gallery->name != $_POST['name']) {
                $gallery->name = $_POST['name'];
                $gallery->slug = slug($_POST['name']);
                $gallery->save();
                $success .= "Gallery name saved / ";
            }
            // Update captions if they are different.
            if (isset($_POST['captions'])) {
                $captions = $_POST['captions'];
                foreach ($captions as $key => $thecaption) {
                    $photo = Photos::FindById($key);
                    if ($photo->caption != $thecaption) {
                        $photo->caption = $thecaption;
                        $photo->save();
                    }
                }
                //$success .= "Captions edited / ";
            }
            // Reset the display order if the photos have been moved.
            if (isset($_POST['photos_display_order'])) {
                $display_orders = $_POST['photos_display_order'];
                foreach ($display_orders as $key => $display_order) {
                    $photo = Photos::FindById($key);
                    if ($photo->display_order != $display_order) {
                        $photo->display_order = $display_order;
                        $photo->save();
                    }
                }
                //$success .= "Photo order saved / ";
            }
            // Upload and save a new file.
            if (isset($_FILES['new_photo']) && $_FILES['new_photo']['error'] == 0) {
                // Updating the record to include the filename stopped working in photos > save_uploaded_file Jan 2013
                $photo = MyActiveRecord::Create('Photos', array('caption' => getPostValue("new_photo_caption"), 'gallery_id' => $gallery->id, 'display_order' => 1));
                $photo->save();
                $photo->save_uploaded_file($_FILES['new_photo']['tmp_name'], $_FILES['new_photo']['name']);
                $photo->setDisplayOrder();
                $success .= "New photo added / ";
            } else {
                // from http://php.net/manual/en/features.file-upload.errors.php
                $upload_errors = array("0. UPLOAD_ERR_OK: No errors.", "1. UPLOAD_ERR_INI_SIZE: Larger than upload_max_filesize.", "2. UPLOAD_ERR_FORM_SIZE: Larger than form MAX_FILE_SIZE.", "3. UPLOAD_ERR_PARTIAL: Partial upload.", "4. UPLOAD_ERR_NO_FILE: No file.", "6. UPLOAD_ERR_NO_TMP_DIR: No temporary directory.", "7. UPLOAD_ERR_CANT_WRITE: Can't write to disk.", "8. UPLOAD_ERR_EXTENSION: File upload stopped by extension.", "UPLOAD_ERR_EMPTY: File is empty.");
                $err_num = $_FILES['new_photo']['error'];
                if ($err_num != 4) {
                    echo "Upload Error! " . $upload_errors[$err_num];
                }
            }
            // Delete photos that were checked off to be removed
            if (isset($_POST['deleted_photos'])) {
                $deleted_ids = $_POST['deleted_photos'];
                foreach ($deleted_ids as $status => $photo_id) {
                    $photo = Photos::FindById($photo_id);
                    $photo->delete(true);
                }
                $success .= "Photo deleted / ";
            }
            setFlash("<h3>" . substr($success, 0, -3) . "</h3>");
            if ($post_action == "Edit and Return to List") {
                redirect("admin/list_galleries");
            }
        }
    }
}
Esempio n. 25
0
 function findPhotosAleatoires($annee = null)
 {
     // Une photos aléatoire d'une activité où l'unité à participé
     $t = new Photos();
     $db = $t->getAdapter();
     $s = $t->select()->setIntegrityCheck(false)->distinct()->from('photo');
     /* Rechercher les albums ou l'unité a participé */
     $s->join('participation', 'participation.activite = photo.activite' . ' AND ' . $db->quoteInto("participation.unite = ?", $this->id), array());
     /* Rechercher si l'unité est identifiée sur la photo */
     $s->joinLeft(array('identification' => 'photo_identification'), $db->quoteInto('identification.photo = photo.id' . ' AND ' . 'identification.unite = ?', $this->id), array());
     /* Préfére les photos où l'unité est identifiée explicitement. */
     $s->order('identification.unite DESC');
     /* Préfère les photo comm. */
     $s->order('photo.promotion DESC');
     /* Mélanger les photos comm. et identifie */
     $s->order('RANDOM()');
     if ($annee) {
         $s->where("strftime('%Y', activite.debut, '-8 months') = ?", strval($annee));
     }
     $s->limit(6);
     // paramétrable ?
     return $t->fetchAll($s);
 }
Esempio n. 26
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Photos $photosModel)
 {
     $num = $photosModel->getById();
     return view('photo.index', ['post' => $num]);
 }
Esempio n. 27
0
         $articleItem = $articles->GetItem($id);
         if ($articleItem) {
             $page["title"] = $articleItem["article_title"] . " - Статьи - " . $config["site_name"];
         }
         $smarty->assign("articleItem", $articleItem);
     } else {
         $page["title"] = "Статьи";
         $smarty->assign("allarticles", $articles->GetItems(false, false, "", "", "", "", true));
     }
 }
 // Gallery
 if ($pageItem[0]["page_module"] == 2) {
     require_once $rootPath . INC_DIR . "class.gallery.php";
     require_once $rootPath . INC_DIR . "class.photos.php";
     $gallery = new Gallery();
     $photos = new Photos();
     if (isset($_GET["gallery"])) {
         $galleryId = intval($_GET["gallery"]);
         $smarty->assign("photos", $photos->GetItems(false, false, "", "", "", " AND {$photos->DbAlias}.gallery_id = {$galleryId} ", true));
         $selectedGallery = $gallery->GetItem($galleryId);
         $page["title"] = $selectedGallery["gallery_name"] . " - Фотогалерея - " . $config["site_name"];
         $smarty->assign("selectedGallery", $selectedGallery);
     } else {
         $galleryItems = $gallery->GetItems(false, false, "", "", "", "", true);
         if ($galleryItems) {
             foreach ($galleryItems as $key => $value) {
                 $galleryItems[$key]["photos"] = $photos->GetItems(1, 7, "", "", "", " AND {$photos->DbAlias}.gallery_id = {$value['gallery_id']} ", true);
             }
             $smarty->assign("galleries", $galleryItems);
         }
     }
 public function actionDelete_photo($mid)
 {
     $photos = Photos::model();
     $photo = $photos->findByPk($mid);
     $album_id = $photo['album_id'];
     $status = $photos->deleteItem($photo);
     $count = $photos->count('album_id = :album_id', array('album_id' => $album_id));
     echo json_encode(array('status' => $status, 'count' => $count));
 }
Esempio n. 29
0
 public function afterDelete()
 {
     Photos::deleteAllByOwnerId($this->id);
 }
Esempio n. 30
0
 $imgtitle = $_REQUEST['imgtitle'];
 $UploadDirectory = 'images/profile/' . $placeId;
 if (!file_exists($UploadDirectory)) {
     mkdir($UploadDirectory, 0777);
 }
 $File_Name = strtolower($_FILES['fileweb']['name']);
 $File_Ext = substr($File_Name, strrpos($File_Name, '.'));
 //get file extention
 $Random_Number = rand();
 //Random number to be added to name.
 $NewFileName = $Random_Number . $File_Ext;
 //new file name
 $path = $UploadDirectory . '/' . $NewFileName;
 if (move_uploaded_file($_FILES['fileweb']['tmp_name'], $UploadDirectory . '/' . $NewFileName)) {
     $img = $UploadDirectory . '/' . $NewFileName;
     $image = new Photos();
     $image->load($img);
     if ($image->getWidth() < 100 || $image->getHeight() < 50) {
         echo 'less';
         unlink($img);
         die;
     }
     echo $img;
     $result = mysql_query("SELECT id,name FROM businessImages WHERE placeId = {$placeId} AND name = '{$name}' LIMIT 1") or die(mysql_error());
     if (mysql_num_rows($result)) {
         $row = mysql_fetch_object($result);
         mysql_query("UPDATE businessImages SET path= '{$path}',title='{$imgtitle}',description='{$imgdesc}' WHERE id = {$row->id}") or die(mysql_error());
     } else {
         mysql_query("INSERT INTO businessImages (placeId,path,title,description,name) VALUES({$placeId},'{$path}','{$imgtitle}','{$imgdesc}','{$name}')") or die(mysql_error());
     }
     /*			if($row->webImg == '')