本文整理汇总了PHP中Photo类的典型用法代码示例。如果您正苦于以下问题:PHP Photo类的具体用法?PHP Photo怎么用?PHP Photo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Photo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afficherListePhotos
function afficherListePhotos()
{
//requete sql
if ($this->numpara) {
$result = mysql_query("SELECT numphoto,legende,numparaphoto FROM if_para_photo WHERE numpara='{$this->numpara}' ORDER BY ordre");
while ($row = mysql_fetch_row($result)) {
$unePhoto = new Photo();
$unePhoto->numphoto = $row[0];
$unePhoto->legendePhoto = $row[1];
$unePhoto->numparaphoto = $row[2];
$unePhoto->infosPhoto();
$this->photos[] = $unePhoto;
}
} else {
$result = mysql_query("SELECT numphoto FROM if_photo ORDER BY nom_photo");
while ($row = mysql_fetch_row($result)) {
$unePhoto = new Photo();
$unePhoto->numphoto = $row[0];
$unePhoto->infosPhoto();
$this->photos[] = $unePhoto;
}
}
if (count($this->photos) >= 1) {
return true;
}
}
示例2: privacy_image_cache_init
function privacy_image_cache_init()
{
$urlhash = 'pic:' . sha1($_REQUEST['url']);
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (count($r)) {
$img_str = $r[0]['data'];
$mime = $r[0]["desc"];
if ($mime == "") {
$mime = "image/jpeg";
}
} else {
require_once "Photo.php";
$img_str = fetch_url($_REQUEST['url'], true);
if (substr($img_str, 0, 6) == "GIF89a") {
$mime = "image/gif";
$image = @imagecreatefromstring($img_str);
if ($image === FALSE) {
die;
}
q("INSERT INTO `photo`\n\t\t\t( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `desc`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )\n\t\t\tVALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )", 0, 0, get_guid(), dbesc($urlhash), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(basename(dbesc($_REQUEST["url"]))), dbesc(''), intval(imagesy($image)), intval(imagesx($image)), 'image/gif', dbesc($img_str), 100, intval(0), dbesc(''), dbesc(''), dbesc(''), dbesc(''));
} else {
$img = new Photo($img_str);
if ($img->is_valid()) {
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
$img_str = $img->imageString();
}
$mime = "image/jpeg";
}
}
header("Content-type: {$mime}");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600 * 24) . " GMT");
header("Cache-Control: max-age=" . 3600 * 24);
echo $img_str;
killme();
}
示例3: __construct
public function __construct()
{
gateKeeper();
$user = getLoggedInUser();
$user->createAvatar();
if (isEnabledPlugin("photos")) {
$album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "Profile Avatars"))));
$photo = new Photo();
$photo->owner_guid = getLoggedInUserGuid();
$photo_guid = $photo->save();
Image::copyAvatar($user, $photo);
$photo = getEntity($photo_guid);
if (!$album) {
$album = new Photoalbum();
$album->owner_guid = getLoggedInUserGuid();
$album->title = "Profile Avatars";
$album_guid = $album->save();
$album = getEntity($album_guid);
Image::copyAvatar($photo, $album);
}
$photo->container_guid = $album->guid;
$photo->save();
}
runHook("action:edit_avatar:after", array("user" => $user));
new Activity(getLoggedInUserGuid(), "activity:avatar:updated", array($user->getURL(), $user->full_name));
new SystemMessage("Your avatar has been uploaded.");
forward("profile/" . $user->guid);
}
示例4: homepageimageeditAction
public function homepageimageeditAction()
{
global $mySession;
$db = new Db();
$id = $this->getRequest()->getParam('id');
$sql = "SELECT image_text FROM " . HOMEPAGEIMG . " WHERE id = {$id}";
// prd($sql);
$record = $db->runQuery($sql);
$this->view->id = $id;
$myform = new Form_Photo(1, $id);
$myform->populate($record[0]);
$this->view->pageHeading = "Edit image";
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
if ($myform->isValid($request->getPost())) {
$dataForm = $myform->getValues();
$myObj = new Photo();
$Result = $myObj->Savehpi($dataForm, $id);
if ($Result == 1) {
$mySession->sucessMsg = "Image Updated updated successfully.";
$this->_redirect('photo/homepageimage');
} else {
$mySession->errorMsg = "Image name you entered is already exists.";
}
}
}
$this->view->myform = $myform;
}
示例5: __construct
public function __construct()
{
$editor = getInput("editor_id");
if (file_exists($_FILES['avatar']['tmp_name'])) {
// Check if General album exists
$album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General"))));
$photo = new Photo();
$photo->owner_guid = getLoggedInUserGuid();
$photo->save();
$photo->createAvatar();
if (!$album) {
$album = new Photoalbum();
$album->title = "General";
$album->owner_guid = getLoggedInUserGuid();
$album->access_id = "public";
Image::copyAvatar($photo, $album);
$album->save();
}
$photo->container_guid = $album->guid;
if (!$album->title != "Profile Avatars" && $album->title != "General") {
new Activity(getLoggedInUserGuid(), "activity:add:photo", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $album->getURL(), $album->title, "<a href='" . $album->getURL() . "'>" . $photo->icon(EXTRALARGE, "img-responsive") . "</a>"), $album->access_id);
}
$photo->save();
forward(false, array("insertphoto" => $photo->guid, "editor" => $editor));
} else {
forward();
}
}
示例6: post_new
public function post_new()
{
$rules = array('title' => 'required|min:5|max:128', 'street' => 'required', 'postalcode' => 'required|match:#^[1-9][0-9]{3}\\h*[A-Z]{2}$#i', 'city' => 'required', 'type' => 'required', 'surface' => 'required|integer', 'price' => 'required|numeric|max:1500|min:100', 'date' => 'required|after:' . date('d-m-Y'), 'pictures' => 'required|image|max:3000', 'register' => 'required', 'email' => 'required|email|same:email2', 'description' => 'required|min:30', 'captchatest' => 'laracaptcha|required', 'terms' => 'accepted');
$v = Validator::make(Input::all(), $rules, Room::$messages);
if ($v->fails()) {
return Redirect::to('kamer-verhuren')->with_errors($v)->with('msg', '<div class="alert alert-error"><strong>Verplichte velden zijn niet volledig ingevuld</strong><br />Loop het formulier nogmaals na.</div>')->with_input();
} else {
if (Auth::check()) {
$status = 'publish';
} else {
$status = 'pending';
}
$new_room = array('title' => ucfirst(Input::get('title')), 'street' => ucwords(Input::get('street')), 'housenr' => Input::get('housenr'), 'postalcode' => Input::get('postalcode'), 'city' => ucwords(Input::get('city')), 'type' => Input::get('type'), 'surface' => Input::get('surface'), 'price' => Input::get('price'), 'available' => date("Y-m-d", strtotime(Input::get('date'))), 'gender' => Input::get('gender'), 'pets' => Input::get('pets'), 'smoking' => Input::get('smoking'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'register' => Input::get('register'), 'social' => Input::get('social'), 'email' => strtolower(Input::get('email')), 'description' => ucfirst(Input::get('description')), 'status' => $status, 'url' => Str::slug(Input::get('city')), 'delkey' => Str::random(32, 'alpha'), 'del_date' => date('y-m-d', strtotime('+2 months')));
$room = new Room($new_room);
if ($room->save()) {
$upload_path = path('public') . Photo::$upload_path_room . $room->id;
if (!File::exists($upload_path)) {
File::mkdir($upload_path);
chmod($upload_path, 0777);
}
$photos = Photo::getNormalizedFiles(Input::file('pictures'));
foreach ($photos as $photo) {
$filename = md5(rand()) . '.jpg';
$path_to_file = $upload_path . '/' . $filename;
$dynamic_path = '/' . Photo::$upload_path_room . $room->id . '/' . $filename;
$success = Resizer::open($photo)->resize(800, 533, 'auto')->save($path_to_file, 80);
chmod($path_to_file, 0777);
if ($success) {
$new_photo = new Photo();
$new_photo->location = $dynamic_path;
$new_photo->room_id = $room->id;
$new_photo->save();
}
}
Message::send(function ($message) use($room) {
$message->to($room->email);
$message->from('kamers@kamergenood.nl', 'Kamergenood');
$message->subject('In afwachting op acceptatie: "' . $room->title . '"');
$message->body('view: emails.submit');
$message->body->id = $room->id;
$message->body->title = $room->title;
$message->body->price = $room->price;
$message->body->type = $room->type;
$message->body->surface = $room->surface;
$message->body->available = $room->available;
$message->body->description = $room->description;
$message->body->url = $room->url;
$message->body->delkey = $room->delkey;
$message->html(true);
});
if (Message::was_sent()) {
return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-success"><strong>Hartelijk dank voor het vertrouwen in Kamergenood!</strong> De kameradvertentie zal binnen 24 uur worden gecontroleerd en geplaatst.</div>');
}
} else {
return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong> Probeer het later nog eens.</div>')->with_input();
}
}
}
示例7: actionPhoto
public function actionPhoto()
{
$model = new Photo('search');
$model->unsetAttributes();
// clear any default values
if (isset($_GET['Photo'])) {
$model->attributes = $_GET['Photo'];
}
$this->render('photo', compact('model'));
}
示例8: fetch
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);
}
示例9: getPhotos
public static function getPhotos($object, $idalbum)
{
$sql = "SELECT * FROM photos WHERE idalbum=" . $idalbum;
$rs = DataBase::ExecuteQuery($sql, "ARRAY");
foreach ($rs as $key => $value) {
$photo = new Photo();
$photo->setPhoto($value['idphoto'], $value['name'], $value['src'], $value['title'], $value['idalbum'], $value['fecha']);
array_push($object, $photo);
}
return $object;
}
示例10: supprimerphotoAction
public function supprimerphotoAction()
{
if (isset($_GET['id'])) {
$photo = new Photo();
$selectlaphoto = $photo->selectOne($_GET['id']);
$photoname = $selectlaphoto['nomPhoto'];
exec('rm ' . APPLICATION_PATH . '/../public/imgNao/' . $selectlaphoto['nomPhoto'], $output, $return);
$laphoto = $photo->find($_GET['id'])->current();
$laphoto->delete();
$this->_redirect('/photovideo/photo');
}
}
示例11: addPhoto
/**
* @brief Function addPhoto
* insere no banco uma nova foto, sendo o endereço novo ou o passado como parametro.
* @param id_adm do usuario logado
* @return mensagem indicador de erro ou sucesso
*/
public function addPhoto($id_adm)
{
$name = Photo::getSendName();
/* Guarda diretorio com novo nome e envia a imagem */
if (is_array($name) && array_key_exists('ERRO', $name)) {
/* Verificando se eh o nome da imagem ou a mensagem de erro */
return $name['ERRO'];
} else {
$morephoto = new Photo();
$morephoto->albumName = $this->name;
return $morephoto->set($id_adm, Dbcommand::getServer() . $name);
}
}
示例12: getPhotos
/**
* @param String $url
* @param int $id
* @return Photo[]
*/
public static function getPhotos($url)
{
$xh = new XMLHandler($url);
$photoItems = $xh->getNodes("photo");
$photoList = array();
foreach ($photoItems as $photoNode) {
$p = new Photo();
$p->setId($photoNode->getElementsByTagName("id")->item(0)->textContent);
$p->setAlt($photoNode->getElementsByTagName("htmlAlt")->item(0)->textContent);
$p->setOrientation($photoNode->getElementsByTagName("orientation")->item(0)->textContent);
//set thumbnail pic and large pic
$photoInstancesNode = $photoNode->getElementsByTagName("instance");
foreach ($photoInstancesNode as $pi) {
$type = $pi->getElementsByTagName("type")->item(0)->textContent;
/* @var $pi DomElement */
if ($type == "Thumbnail") {
$p->getThumb()->parsePhotoInstance($pi);
} elseif ($type == "Large") {
$p->getLarge()->parsePhotoInstance($pi);
} elseif ($type == "HighRes") {
$p->getHiRes()->parsePhotoInstance($pi);
} elseif ($type == "Custom") {
$p->getCustom()->parsePhotoInstance($pi);
}
}
$photoList[] = $p;
}
return $photoList;
}
示例13: savePhoto
/**
*新的的话就要新建一个guide,旧的的话就是要将photo直接保存即可
*/
public function savePhoto(Photo &$photo)
{
if ($this->isNewRecord) {
$this->title = Scenic::model()->findByPk($photo->scenicId);
$this->userId = Yii::app()->user->userId;
$this->save();
$photo->guideId = $this->guideId;
$photo->save();
} else {
if ($photo->save()) {
$this->save();
}
}
}
示例14: addPhoto
public function addPhoto($userId, $filePath)
{
$photo = new Photo();
$photo->user_id = $userId;
$photo->photo_album_id = $this->id;
$photo->file_path = $filePath;
$saved = $photo->save();
if ($saved) {
if (count($this->photos) === 1) {
$this->saveAttributes(array('cover_photo_id' => $photo->id));
}
return $photo;
}
return null;
}
示例15: converseToModel
/**
* Añade datos de la ultima foto cargda (Zend_Gdata_Photos_PhotoFeed)
* al modelo Photo.
*
* @return Photo
*/
public static function converseToModel()
{
$picasa = new Neo_Gdata_Photo();
$photo = $picasa->getLastPhotoUpload();
$foto = new Photo();
$foto->photo_id = $photo->getGphotoId();
$foto->titulo = $photo->getTitle();
$foto->descripcion = $photo->getMediaGroup()->getDescription();
$thumbnail = $photo->getMediaGroup()->getThumbnail();
$foto->thumbnail_1 = $thumbnail[0]->getUrl();
$foto->thumbnail_2 = $thumbnail[1]->getUrl();
$foto->thumbnail_3 = $thumbnail[2]->getUrl();
$foto->save();
return $foto;
}