The followings are the available columns in table 'potato_Photo':
Inheritance: extends CActiveRecord
 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;
     }
 }
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();
}
 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);
 }
Example #4
0
 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;
 }
 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();
     }
 }
Example #6
0
 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('*****@*****.**', '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();
         }
     }
 }
 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'));
 }
Example #8
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);
 }
Example #9
0
 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;
 }
 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');
     }
 }
Example #11
0
 /**
  * @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);
     }
 }
 /**
  * @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;
 }
Example #13
0
 /**
  *新的的话就要新建一个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();
         }
     }
 }
Example #14
0
 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;
 }
Example #15
0
 /**
  * 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;
 }
Example #16
0
 static function photo($database, $plugins, $settings, $path, $albumID = 0, $description = '', $tags = '')
 {
     $info = getimagesize($path);
     $size = filesize($path);
     $photo = new Photo($database, $plugins, $settings, null);
     $nameFile = array(array());
     $nameFile[0]['name'] = $path;
     $nameFile[0]['type'] = $info['mime'];
     $nameFile[0]['tmp_name'] = $path;
     $nameFile[0]['error'] = 0;
     $nameFile[0]['size'] = $size;
     if (!$photo->add($nameFile, $albumID, $description, $tags)) {
         return false;
     }
     return true;
 }
 public function postNewAdmin()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Identity_No' => 'required', 'Email' => 'required|email', 'Phone_Number' => 'required', 'First_Name' => 'required', 'Last_Name' => 'required', 'Photo_1' => 'image|required', 'Photo_2' => 'image|required', 'Photo_3' => 'image|required'));
     if ($validator->fails()) {
         return Redirect::route('super-admin-new-admin-get')->withErrors($validator)->withInput()->with('globalerror', 'Sorry!! The Data was not Saved, please retry');
     } else {
         $identitynumber = Input::get('Identity_No');
         $email = Input::get('Email');
         $phonenumber = Input::get('Phone Numer');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $photo_1 = Input::file('Photo_1');
         $photo_2 = Input::file('Photo_2');
         $photo_3 = Input::file('Photo_3');
         //register the new user
         $newuser = User::create(array('Identity_No' => $identitynumber, 'First_Name' => $firstname, 'Last_Name' => $lastname, 'Password' => Hash::make($identitynumber), 'Active' => TRUE));
         //register the new user contact
         $newcontact = Contact::create(array('Email' => $email, 'Phone_Number' => $phonenumber));
         //Save the three Photos
         $photo1 = $this->postPhoto($photo_1);
         $photo2 = $this->postPhoto($photo_2);
         $photo3 = $this->postPhoto($photo_3);
         $newphotos = Photo::create(array('photo_1' => $photo1, 'photo_2' => $photo2, 'photo_3' => $photo3));
         //save the details to the students table
         $newadmin = Admin::create(array('Users_Id' => $newuser->id, 'Contacts_Id' => $newcontact->id, 'Photos_Id' => $newphotos->id));
         if ($newuser && $newcontact && $newphotos && $newadmin) {
             return Redirect::route('super-admin-new-admin-get')->with('globalsuccess', 'New Admin Details Have been Added');
         }
     }
 }
 public function actionPhoto()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 25;
     $model = Photo::model()->is_publish()->findAll($criteria);
     $this->setRss($model, 'photo', 'Photo', 'Rss Feed Photo', $this->createUrl('photo'));
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Photo::create([]);
     }
 }
    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:Photo)
						 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(Photo::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, 'Photo with ID does not exist.');
            $outputter->print_error($error);
        }
    }
 public function actionIndex()
 {
     echo "================================================================================\n\r";
     echo "ATMOSPHERA console command: Batch resizing of uploaded photos\n\r";
     echo "================================================================================\n\r";
     $fileform = new PhotoFileForm();
     //get instance of model
     $fileform->setImageSize();
     //set sizes from params-local
     $path = UrlHelper::getImageDir();
     //get dir for upload
     $criteia = new CDbCriteria();
     $countTotal = Photo::model()->count($criteia);
     echo "total count of photo: " . $countTotal . "\n\r";
     echo "start process... please wait\n\r";
     $offset = 0;
     //DebugBreak();
     $step = floor($countTotal / 10);
     $criteia->limit = $step;
     $criteia->offset = $offset;
     $countTotal = 0;
     while (($count = count($aPhotos = Photo::model()->findAll($criteia))) > 0) {
         foreach ($aPhotos as $oPhoto) {
             $fileform->createImages($path, $oPhoto->filename, $oPhoto->thumb_filename);
         }
         $offset += $step;
         $criteia = new CDbCriteria();
         $criteia->limit = $step;
         $criteia->offset = $offset;
         $countTotal += $count;
         echo ".";
     }
     echo "\n\r";
     echo "total count of processed files: " . $countTotal . "\n\r";
 }
 public function actionList()
 {
     $request = Yii::app()->getRequest();
     $page = $request->getParam("page");
     if (!$page) {
         $page = 1;
     }
     $pagenum = $request->getParam("pagenum");
     if (!$pagenum) {
         $pagenum = 12;
     }
     $winner = new Winner();
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->limit = $pagenum;
     $criteria->offset = ($page - 1) * $pagenum;
     $criteria->order = 'month DESC';
     $winners = $winner->findAll($criteria);
     $res = array();
     foreach ($winners as $winner) {
         $res[] = $winner->attributes;
     }
     $topPhoto = Photo::model()->findByAttributes(array('weibo_id' => $winners[0]->mid));
     if ($topPhoto) {
         $res[0]['detail'] = $topPhoto->attributes;
     }
     $this->responseJSON($res, "success");
 }
Example #23
0
function create_user_photos($user_id)
{
    foreach (range(0, 10) as $i) {
        $p = Photo::_create(array('user_id' => $user_id, 'title' => 'title' . $i));
        create_comment($p->id);
    }
}
Example #24
0
 public function detail($id)
 {
     $photo = Photo::getPhoto($id);
     $previous = Photo::getPreviousPhoto($id);
     $next = Photo::getNextPhoto($id);
     return View::make('pages.photo.detail')->with('photo', $photo)->with('previous', $previous ? $previous->id : null)->with('next', $next ? $next->id : null);
 }
Example #25
0
 public function actionPicture()
 {
     $user = Yii::app()->getUser()->getModel();
     if ($user->profile === null) {
         $this->redirect(array('/editprofile/basic'));
     }
     $photoUploadForm = new PhotoUploadForm();
     if (($post = Yii::app()->getRequest()->getPost('PhotoUploadForm')) !== null) {
         $file = $photoUploadForm->file = CUploadedFile::getInstance($photoUploadForm, 'file');
         if ($photoUploadForm->validate()) {
             if ($user->getProfilePhotoAlbum() === null) {
                 if (!$user->addProfilePhotoAlbum()) {
                     throw new CException(Yii::t('application', 'You do not have a "Profile Picture" album and the system was unable to create one for you.'));
                 }
             }
             $photoAlbum = $user->getProfilePhotoAlbum();
             $filePath = $photoAlbum->getDir() . '/' . Photo::generateName($file->getName(), $file->getExtensionName(), $user->id);
             $savePath = $filePath;
             if ($file->saveAs($savePath) === true && ($photo = $photoAlbum->addPhoto($user->id, $filePath)) !== null) {
                 $user->profile->saveAttributes(array('photo_id' => $photo->id));
                 Yii::app()->getUser()->setFlash('success', Yii::t('application', 'Your changes have been saved.'));
             } else {
                 throw new CException(Yii::t('application', 'Unable to save your profile picture.'));
             }
         }
     }
     $this->render('picture', array('form' => $photoUploadForm, 'user' => $user));
 }
Example #26
0
 function __construct()
 {
     if (!isset(self::$database)) {
         //Connection à la BDD si pas déjà connecté
         self::$database = BaseDeDonnees::getInstance();
     }
 }
Example #27
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 500) as $index) {
         Photo::create(array('title' => $faker->sentence($nbwords = 5), 'image' => $faker->imageUrl($width = 640, $height = 480), 'gallery_id' => $faker->numberBetween(1, 50)));
     }
 }
Example #28
0
 public function addPhoto($foto)
 {
     $picasa = new Neo_Gdata_Photo();
     $resultPhoto = $picasa->insertPhoto($this->album_id, $foto);
     $this->Photos[] = Photo::setPhoto($resultPhoto);
     $this->save();
 }
Example #29
0
 function testPhotoPng()
 {
     $a = new Activite();
     $a->slug = 'imagick-png';
     $a->debut = new Zend_Db_Expr('CURRENT_TIMESTAMP');
     $a->fin = new Zend_Db_Expr('CURRENT_TIMESTAMP');
     $a->save();
     $c = new Commentaire();
     $c->message = '';
     $c->save();
     $o = new Photo();
     $o->activite = $a->id;
     $o->commentaires = $c->id;
     $o->slug = 'photo-png';
     $o->storeFile(dirname(__FILE__) . '/images/transparente.png');
 }
 /**
  * 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 Photo the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Photo::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }