Example #1
0
 /**
  * Displays a random image from one of the galleries.
  *
  * @access  public
  * @param   int     $albumid    album ID
  * @return  string   XHTML template content
  * @see Phoo_Model::GetRandomImage()
  */
 function Random($albumid = null)
 {
     $model = $this->gadget->model->load('Random');
     $r = $model->GetRandomImage($albumid);
     if (Jaws_Error::IsError($r) || empty($r)) {
         return false;
     }
     $tpl = $this->gadget->template->load('Random.html');
     $tpl->SetBlock('random_image');
     $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $r['thumb']);
     if (!Jaws_Error::IsError($imgData)) {
         $tpl->SetVariable('width', $imgData[0]);
         $tpl->SetVariable('height', $imgData[1]);
     }
     $tpl->SetVariable('title', _t('PHOO_ACTIONS_RANDOM'));
     $tpl->SetVariable('url', $this->gadget->urlMap('ViewImage', array('id' => $r['id'], 'albumid' => $r['phoo_album_id'])));
     $tpl->SetVariable('name', $r['name']);
     $tpl->SetVariable('filename', $r['filename']);
     $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $r['thumb']));
     $tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $r['medium']));
     $tpl->SetVariable('image', $GLOBALS['app']->getDataURL('phoo/' . $r['image']));
     $tpl->SetVariable('img_desc', $r['stripped_description']);
     $tpl->ParseBlock('random_image');
     return $tpl->Get();
 }
Example #2
0
 /**
  * Displays an index of gallerie.
  *
  * @access  public
  * @return  string XHTML template content
  */
 function Album()
 {
     $tpl = $this->gadget->template->load('Albums.html');
     $tpl->SetBlock('albums');
     $tpl->SetVariable('title', _t('PHOO_ALBUMS'));
     $model = $this->gadget->model->load('Albums');
     $albums = $model->GetAlbumList();
     if (!Jaws_Error::IsError($albums)) {
         $date = Jaws_Date::getInstance();
         foreach ($albums as $album) {
             if (!isset($album['qty'])) {
                 continue;
             }
             $tpl->SetBlock('albums/item');
             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $album['thumb']);
             if (!Jaws_Error::IsError($imgData)) {
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
             }
             $url = $this->gadget->urlMap('ViewAlbum', array('id' => $album['id']));
             $tpl->SetVariable('url', $url);
             $tpl->SetVariable('name', $album['name']);
             $tpl->SetVariable('filename', $album['filename']);
             $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $album['thumb']));
             $tpl->SetVariable('howmany', _t('PHOO_NUM_PHOTOS_ALBUM', $album['qty']));
             $tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
             $tpl->SetVariable('createtime', $date->Format($album['createtime']));
             $tpl->ParseBlock('albums/item');
         }
     }
     $tpl->ParseBlock('albums');
     return $tpl->Get();
 }
Example #3
0
 /**
  * Displays a random image from the gallery listed as a Moblog
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Moblog($aid)
 {
     $tpl = $this->gadget->template->load('Moblog.html');
     $tpl->SetBlock('moblog');
     $tpl->SetVariable('title', _t('PHOO_ACTIONS_MOBLOG'));
     $model = $this->gadget->model->load('Moblog');
     $moblog = $model->GetMoblog($aid);
     if (!Jaws_Error::IsError($moblog)) {
         $objDate = Jaws_Date::getInstance();
         include_once JAWS_PATH . 'include/Jaws/Image.php';
         foreach ($moblog as $mb) {
             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $mb['thumb']);
             if (Jaws_Error::IsError($imgData)) {
                 continue;
             }
             $tpl->SetBlock('moblog/item');
             $tpl->SetVariable('url', $this->gadget->urlMap('ViewImage', array('id' => $mb['id'], 'albumid' => $mb['phoo_album_id'])));
             $tpl->SetVariable('name', $mb['name']);
             $tpl->SetVariable('img_desc', $mb['stripped_description']);
             $tpl->SetVariable('filename', $mb['filename']);
             $tpl->SetVariable('width', $imgData[0]);
             $tpl->SetVariable('height', $imgData[1]);
             $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $mb['thumb']));
             $tpl->SetVariable('createtime', $objDate->Format($mb['createtime']));
             $tpl->ParseBlock('moblog/item');
         }
     }
     $tpl->ParseBlock('moblog');
     return $tpl->Get();
 }
Example #4
0
 /**
  * Rotate right a image
  *
  * @access  public
  */
 function RotateRight()
 {
     $post = jaws()->request->fetch(array('image', 'fromalbum'), 'post');
     //FIXME: Ugly, maybe we need to pass just the image id, also we need to create a
     //class to manage image actions(resize, rotate)
     $model = $this->gadget->model->load('Photos');
     $image = $model->GetImageEntry($post['image']);
     if (Jaws_Error::IsError($image)) {
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Phoo&action=EditPhoto&image=' . $post['image'] . '&album=' . $post['fromalbum']);
     }
     include_once JAWS_PATH . 'include/Jaws/Image.php';
     $objImage = Jaws_Image::factory();
     if (Jaws_Error::IsError($objImage)) {
         $GLOBALS['app']->Session->PushLastResponse($objImage->getMessage(), RESPONSE_ERROR);
     } else {
         // thumb
         $objImage->load(JAWS_DATA . 'phoo/' . rawurldecode($image['thumb']));
         $objImage->rotate(90);
         $res = $objImage->save();
         $objImage->free();
         if (Jaws_Error::IsError($res)) {
             $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
         } else {
             // medium
             $objImage->load(JAWS_DATA . 'phoo/' . rawurldecode($image['medium']));
             $objImage->rotate(90);
             $res = $objImage->save();
             $objImage->free();
             if (Jaws_Error::IsError($res)) {
                 $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
             } else {
                 // original image
                 $objImage->load(JAWS_DATA . 'phoo/' . rawurldecode($image['image']));
                 $objImage->rotate(90);
                 $res = $objImage->save();
                 $objImage->free();
                 if (Jaws_Error::IsError($res)) {
                     $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
                 } else {
                     $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_IMAGE_ROTATED_RIGHT'), RESPONSE_NOTICE);
                 }
             }
         }
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Phoo&action=EditPhoto&image=' . $post['image'] . '&album=' . $post['fromalbum']);
 }
Example #5
0
 /**
  * Resize an image on the fly
  * 
  * FIXME: I don't know if is better to get it as a standalone function...
  * 
  * @returns binary Image resized
  */
 function Thumb()
 {
     $image = jaws()->request->fetch('image', 'get');
     $objImage = Jaws_Image::factory();
     if (!Jaws_Error::IsError($objImage)) {
         $result = $objImage->load(JAWS_DATA . 'phoo/import/' . $image);
         if (!Jaws_Error::IsError($result)) {
             $thumbSize = explode('x', $this->gadget->registry->fetch('thumbsize'));
             $objImage->resize($thumbSize[0], $thumbSize[1]);
             $result = $objImage->display();
             if (!Jaws_Error::IsError($result)) {
                 return $result;
             }
         }
     }
     header('Content-type: image/png');
     return file_get_contents('gadgets/Phoo/Resources/images/logo.png');
 }
Example #6
0
 /**
  * Returns avatar as stream data
  *
  * @access  public
  * @return  bool    True on success, false otherwise
  */
 function LoadAvatar()
 {
     $file = jaws()->request->fetch('file', 'get');
     $objImage = Jaws_Image::factory();
     if (!Jaws_Error::IsError($objImage)) {
         if (!empty($file)) {
             $file = preg_replace("/[^[:alnum:]_\\.\\-]*/i", "", $file);
             $result = $objImage->load(Jaws_Utils::upload_tmp_dir() . '/' . $file, true);
             if (!Jaws_Error::IsError($result)) {
                 $result = $objImage->display();
                 if (!Jaws_Error::IsError($result)) {
                     return $result;
                 }
             }
         }
     }
     return false;
 }
Example #7
0
 /**
  * Overrides, Parses the text
  *
  * @access  public
  * @param   string  $html   HTML to be parsed
  * @return  string  Parsed content
  */
 function ParseText($html)
 {
     if (file_exists(JAWS_PATH . 'gadgets/Phoo/Model.php') && Jaws_Gadget::IsGadgetInstalled('Phoo')) {
         $howMany = preg_match_all("#\\[phoo album=\"(.*?)\" picture=\"(.*?)\" title=\"(.*?)\" class=\"(.*?)\" size=\"(.*?)\" linked=\"(.*?)\"\\]#si", $html, $matches);
         $new_html = $html;
         $url = $GLOBALS['app']->getSiteURL();
         $objPhoo = Jaws_Gadget::getInstance('Phoo')->model->load('Photos');
         for ($i = 0; $i < $howMany; $i++) {
             $albumid = $matches[1][$i];
             $imageid = $matches[2][$i];
             $title = $matches[3][$i];
             $clase = $matches[4][$i];
             $size = $matches[5][$i];
             $linked = $matches[6][$i];
             $image = $objPhoo->GetImageEntry($imageid);
             if (!Jaws_Error::IsError($image) && !empty($image)) {
                 if (strtoupper($size) == 'THUMB') {
                     $img_file = JAWS_DATA . 'phoo/' . $image['thumb'];
                     $img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['thumb']);
                 } elseif (strtoupper($size) == 'MEDIUM') {
                     $img_file = JAWS_DATA . 'phoo/' . $image['medium'];
                     $img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['medium']);
                 } else {
                     $img_file = JAWS_DATA . 'phoo/' . $image['image'];
                     $img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['image']);
                 }
                 $imgData = Jaws_Image::getimagesize($img_file);
                 if (strtoupper($linked) == 'YES') {
                     $img_lnk = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewImage', array('id' => $imageid, 'albumid' => $albumid));
                     $new_text = '<a href="' . $img_lnk . '" ><img src="' . $img_url . '" title="' . $title . '"  alt="' . $title . '" class="' . $clase . '" height="' . $imgData['height'] . '" width="' . $imgData['width'] . '"/></a>';
                 } else {
                     $new_text = '<img src="' . $img_url . '" title="' . $title . '" alt="' . $title . '" class="' . $clase . '" height="' . $imgData['height'] . '" width="' . $imgData['width'] . '" />';
                 }
                 $textToReplace = "#\\[phoo album=\"" . $albumid . "\" picture=\"" . $imageid . "\" title=\"" . $title . "\" class=\"" . $clase . "\" size=\"" . $size . "\" linked=\"" . $linked . "\"\\]#";
                 $new_html = preg_replace($textToReplace, $new_text, $new_html);
             }
         }
         return $new_html;
     }
     return $html;
 }
Example #8
0
 /**
  * Returns menu image as stream data
  *
  * @access  public
  * @return  bool    True on successful, False otherwise
  */
 function LoadImage()
 {
     $params = jaws()->request->fetch(array('id', 'file'), 'get');
     $objImage = Jaws_Image::factory();
     if (!Jaws_Error::IsError($objImage)) {
         if (is_null($params['file'])) {
             $model = $this->gadget->model->load('Menu');
             $result = $model->GetMenuImage($params['id']);
             if (!Jaws_Error::IsError($result)) {
                 $result = $objImage->setData($result, true);
             }
         } else {
             $params['file'] = preg_replace("/[^[:alnum:]_\\.\\-]*/i", "", $params['file']);
             $result = $objImage->load(Jaws_Utils::upload_tmp_dir() . '/' . $params['file'], true);
         }
         if (!Jaws_Error::IsError($result)) {
             $result = $objImage->display();
             if (!Jaws_Error::IsError($result)) {
                 return $result;
             }
         }
     }
     return false;
 }
Example #9
0
 /**
  * Main UI to admin photos
  *
  * @access  public
  * @return  string   XHTML template content
  */
 function AdminPhotos()
 {
     $tpl = $this->gadget->template->loadAdmin('Photos.html');
     $tpl->SetBlock('phoo');
     $tpl->SetVariable('menubar', $this->MenuBar('AdminPhotos'));
     $album = jaws()->request->fetch('album', 'get');
     $post = jaws()->request->fetch(array('date', 'album:array', 'group'), 'post');
     $aModel = $this->gadget->model->load('Albums');
     $pModel = $this->gadget->model->loadAdmin('Photos');
     $pnModel = $this->gadget->model->load('Photos');
     $albums = $aModel->GetAlbums('createtime', 'ASC', $post['group']);
     if (!Jaws_Error::IsError($albums) && !empty($albums)) {
         $this->AjaxMe('script.js');
         $objDate = Jaws_Date::getInstance();
         $tpl->SetBlock('phoo/photos');
         $tpl->SetVariable('base_action', BASE_SCRIPT . '?gadget=Phoo');
         $datecombo =& Piwi::CreateWidget('Combo', 'date');
         $datecombo->SetStyle('width: 200px;');
         $datecombo->AddOption('&nbsp;', '');
         $mindate = $pnModel->GetMinDate();
         if ($mindate) {
             $maxdate = $pnModel->GetMaxDate();
             $mindateArray = explode('/', $mindate);
             $maxdateArray = explode('/', $maxdate);
             for ($year = $maxdateArray[2]; $year >= $mindateArray[2]; $year--) {
                 if ($maxdateArray[2] == $mindateArray[2]) {
                     $mstart = $maxdateArray[0];
                     $mend = $mindateArray[0];
                 } else {
                     if ($year == $maxdateArray[2]) {
                         $mstart = $maxdateArray[0];
                     } else {
                         $mstart = 12;
                     }
                     if ($year == $mindateArray[2]) {
                         $mend = $mindateArray[0];
                     } else {
                         $mend = 1;
                     }
                 }
                 for ($m = $mstart; $m >= $mend; $m--) {
                     $month = $objDate->MonthString($m);
                     $datecombo->AddOption($month . ' ' . $year, $m . '/' . $year);
                 }
             }
         }
         $tpl->SetVariable('date', _t('GLOBAL_DATE'));
         $datecombo->SetDefault(isset($post['date']) ? $post['date'] : null);
         $datecombo->AddEvent(ON_CHANGE, 'selectAllAlbums(); this.form.submit();');
         $tpl->SetVariable('date_combo', $datecombo->Get());
         $albumcombo =& Piwi::CreateWidget('Combo', 'album[]');
         $albumcombo->SetID('albums_list');
         $albumcombo->SetStyle('width: 200px;');
         $albumcombo->SetSize(16);
         $albumcombo->SetMultiple(true);
         $free_photos[] = array('id' => 0, 'name' => _t('PHOO_WITHOUT_ALBUM'), 'createtime' => date('Y-m-d H:i:s'), 'howmany' => 0);
         $albums = array_merge($free_photos, $albums);
         foreach ($albums as $a) {
             // FIXME: Ugly hack to add title to albumcombo
             $o =& Piwi::CreateWidget('ComboOption', $a['id'], $a['name']);
             $o->SetTitle(_t('PHOO_NUM_PHOTOS_ALBUM', $a['howmany']) . ' / ' . _t('PHOO_ALBUM_CREATION_DATE', $objDate->Format($a['createtime'])));
             $albumcombo->_options[$a['id']] = $o;
         }
         // r_album = request album
         if (isset($post['album'])) {
             $r_album = $post['album'];
         } else {
             $r_album = isset($album) ? $album : 0;
         }
         $albumcombo->SetDefault($r_album);
         $albumcombo->AddEvent(ON_CHANGE, 'this.form.submit();');
         $tpl->SetVariable('albums', _t('PHOO_ALBUMS'));
         $tpl->SetVariable('albums_combo', $albumcombo->Get());
         if ($this->gadget->GetPermission('ManageAlbums')) {
             $newalbum =& Piwi::CreateWidget('Button', 'newalbum', _t('PHOO_CREATE_NEW_ALBUM'), STOCK_NEW);
             $newalbum->AddEvent(ON_CLICK, "this.form.action.value='NewAlbum'; this.form.submit();");
             $tpl->SetVariable('new_album', $newalbum->Get());
         } else {
             $tpl->SetVariable('new_album', '');
         }
         // Ugly hack to convert $r_album to array...
         if (!is_array($r_album)) {
             $aux = $r_album;
             $r_album = array();
             $r_album[] = $aux;
         }
         // Show albums
         if (!empty($r_album) && is_array($r_album)) {
             if (!empty($post['date'])) {
                 $aux = explode('/', $post['date']);
                 $aux = $objDate->ToBaseDate($aux[1], $aux[0]);
                 $year = $aux['year'];
                 $month = $aux['month'];
                 $day = $aux['day'];
             } else {
                 $day = null;
                 $month = null;
                 $year = null;
             }
             foreach ($r_album as $albumId) {
                 $album = $pnModel->GetAlbumImages($albumId, null, $day, $month, $year);
                 if (!Jaws_Error::IsError($album)) {
                     if (isset($album['images']) && !is_array($album['images']) && count($album['images']) == 0) {
                         continue;
                     }
                     $tpl->SetBlock('phoo/photos/albums');
                     $tpl->SetVariable('title', $album['name']);
                     $tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
                     $tpl->SetVariable('createtime', $objDate->Format($album['createtime']));
                     $upload_url = BASE_SCRIPT . "?gadget=Phoo&amp;action=UploadPhotos&amp;album={$album['id']}";
                     $manageAlbumActions = "<a href=\"{$upload_url}\">" . _t('PHOO_UPLOAD_PHOTOS') . "</a>";
                     $manageAlbumActions .= " | <a href=\"" . BASE_SCRIPT . "?gadget=Phoo&amp;action=EditAlbum&amp;album={$album['id']}\">" . _t('PHOO_EDIT_DESCRIPTION') . "</a>";
                     $manageAlbumActions .= " | <a href=\"javascript:void(0);\" onclick=\"if (confirm('" . _t('PHOO_DELETE_ALBUM_CONFIRM') . "')) { window.location = '" . BASE_SCRIPT . '?gadget=Phoo&amp;action=DeleteAlbum&amp' . ";album={$album['id']}';  }\">" . _t('PHOO_DELETE_ALBUM') . "</a>";
                     if ($album['id'] != 0) {
                         $tpl->SetVariable('actions', $manageAlbumActions);
                     } else {
                         $tpl->SetVariable('actions', '');
                     }
                     if (isset($album['images']) && is_array($album['images']) && count($album['images']) > 0) {
                         // Show photos
                         foreach ($album['images'] as $img) {
                             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $img['image']);
                             $tpl->SetBlock('phoo/photos/albums/item');
                             $tpl->SetVariable('url', BASE_SCRIPT . '?gadget=Phoo&amp;action=EditPhoto&amp;image=' . $img['id'] . '&amp;album=' . $albumId);
                             if (Jaws_Error::IsError($imgData)) {
                                 $tpl->SetVariable('thumb', 'images/unknown.png');
                                 $tpl->SetVariable('width', 60);
                                 $tpl->SetVariable('height', 60);
                                 $tpl->SetBlock('phoo/photos/albums/item/notfound');
                                 $tpl->SetVariable('notfound', _t('PHOO_NOT_FOUND'));
                                 $tpl->ParseBlock('phoo/photos/albums/item/notfound');
                             } else {
                                 $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $img['thumb']));
                                 $tpl->SetVariable('width', $imgData[0]);
                                 $tpl->SetVariable('height', $imgData[1]);
                             }
                             $tpl->SetVariable('name', $img['name']);
                             $tpl->SetVariable('album', $img['albumid']);
                             if ($img['published'] == false) {
                                 $tpl->SetBlock('phoo/photos/albums/item/notpublished');
                                 $tpl->SetVariable('notpublished', _t('PHOO_NOT_PUBLISHED'));
                                 $tpl->ParseBlock('phoo/photos/albums/item/notpublished');
                             }
                             $tpl->ParseBlock('phoo/photos/albums/item');
                         }
                     } else {
                         if ($album['id'] != 0) {
                             $tpl->SetBlock('phoo/photos/albums/nophotos');
                             $tpl->SetVariable('message', "<a href=\"{$upload_url}\">" . _t('PHOO_START_UPLOADING_PHOTOS') . "</a>");
                             $tpl->ParseBlock('phoo/photos/albums/nophotos');
                         }
                     }
                     $tpl->ParseBlock('phoo/photos/albums');
                 } else {
                     $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_INEXISTENT_ALBUM'), RESPONSE_ERROR);
                 }
             }
         }
         //Get failures
         $failures = $GLOBALS['app']->Session->GetAttribute('failures');
         // Failures
         if (is_array($failures) && count($failures) > 0) {
             foreach ($failures as $f) {
                 $tpl->SetBlock('phoo/photos/failures');
                 $tpl->SetVariable('message', $f);
                 $tpl->ParseBlock('phoo/photos/failures');
             }
         }
         //Delete key
         $GLOBALS['app']->Session->DeleteAttribute('failures');
         // Groups
         $gModel = $this->gadget->model->load('Groups');
         $groups = $gModel->GetGroups();
         $tpl->SetVariable('lbl_group', _t('GLOBAL_GROUP'));
         $tpl->SetVariable('lbl_all', _t('GLOBAL_ALL'));
         if (!isset($post['group'])) {
             $post['group'] = 0;
         }
         foreach ($groups as $group) {
             $tpl->SetBlock('phoo/photos/group');
             $tpl->SetVariable('gid', $group['id']);
             $tpl->SetVariable('group', $group['name']);
             if ($post['group'] == $group['id']) {
                 $tpl->SetBlock('phoo/photos/group/selected_group');
                 $tpl->ParseBlock('phoo/photos/group/selected_group');
             }
             $tpl->ParseBlock('phoo/photos/group');
         }
         $tpl->ParseBlock('phoo/photos');
     } else {
         $tpl->SetBlock('phoo/noalbums');
         $tpl->SetVariable('message', _t('PHOO_EMPTY_ALBUMSET'));
         $form =& Piwi::CreateWidget('Form', BASE_SCRIPT, 'post');
         $form->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Phoo'));
         $form->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'NewAlbum'));
         $b =& Piwi::CreateWidget('Button', 'newalbum', _t('PHOO_CREATE_NEW_ALBUM'), STOCK_NEW);
         $b->SetSubmit(true);
         $form->Add($b);
         $tpl->SetVariable('form', $form->Get());
         $tpl->ParseBlock('phoo/noalbums');
     }
     $tpl->ParseBlock('phoo');
     return $tpl->Get();
 }
Example #10
0
 /**
  * Browse across albums and images from Phoo
  *
  * @access  public
  * @return  string   XHTML with the list of albums and images appropiate for navigation
  */
 function BrowsePhoo()
 {
     $pModel = $this->gadget->model->load('Photos');
     $aModel = $this->gadget->model->load('Albums');
     $tpl = $this->gadget->template->loadAdmin('PhooBrowse.html');
     $tpl->SetBlock('phoo_browse');
     $GLOBALS['app']->LoadPlugin('PhooInsert');
     $tpl->SetVariable('page-title', _t('PLUGINS_PHOOINSERT_PHOTO_GALLERY'));
     $dir = _t('GLOBAL_LANG_DIRECTION');
     $tpl->SetVariable('.dir', $dir == 'rtl' ? '.' . $dir : '');
     $album = jaws()->request->fetch('album', 'get');
     $post = jaws()->request->fetch(array('date', 'album:array'), 'post');
     $albums = $aModel->GetAlbums('createtime', 'ASC');
     // TODO set default value for change page address to correct location after uploading image
     $extraParams = '&amp;';
     $editor = $GLOBALS['app']->GetEditor();
     if ($editor === 'CKEditor') {
         $extraParams = jaws()->request->fetch('extra_params');
         if (empty($extraParams)) {
             $getParams = jaws()->request->fetch(array('CKEditor', 'CKEditorFuncNum', 'langCode'), 'get');
             $extraParams = '&amp;CKEditor=' . $getParams['CKEditor'] . '&amp;CKEditorFuncNum=' . $getParams['CKEditorFuncNum'] . '&amp;langCode=' . $getParams['langCode'];
         }
     }
     if ($this->gadget->GetPermission('AddPhotos') && count($albums) > 0) {
         $tpl->SetBlock("phoo_browse/upload_photo");
         $tpl->SetVariable('base_script', BASE_SCRIPT);
         $tpl->SetVariable('extra_params', $extraParams);
         $tpl->SetVariable('lbl_file_upload', _t('PHOO_UPLOAD_PHOTO'));
         $uploadfile =& Piwi::CreateWidget('FileEntry', 'photo1', '');
         $uploadfile->SetID('photo1');
         $tpl->SetVariable('lbl_filename', _t('PHOO_IMAGE_LABEL'));
         $tpl->SetVariable('uploadfile', $uploadfile->Get());
         $btnSave =& Piwi::CreateWidget('Button', 'btn_upload_file', _t('PHOO_UPLOAD_PHOTOS'), STOCK_SAVE);
         $btnSave->AddEvent(ON_CLICK, "javascript: uploadPhoto();");
         $tpl->SetVariable('btn_upload_file', $btnSave->Get());
         $tpl->ParseBlock("phoo_browse/upload_photo");
     }
     if (!Jaws_Error::IsError($albums) && !empty($albums)) {
         $objDate = Jaws_Date::getInstance();
         $tpl->SetBlock("phoo_browse/photos");
         $tpl->SetVariable('extra_params', $extraParams);
         $datecombo =& Piwi::CreateWidget('Combo', 'date');
         $datecombo->SetStyle('width: 200px;');
         $datecombo->AddOption('&nbsp;', '');
         $mindate = $pModel->GetMinDate();
         if ($mindate) {
             $maxdate = $pModel->GetMaxDate();
             $mindateArray = explode('/', $mindate);
             $maxdateArray = explode('/', $maxdate);
             for ($year = $maxdateArray[2]; $year >= $mindateArray[2]; $year--) {
                 if ($maxdateArray[2] == $mindateArray[2]) {
                     $mstart = $maxdateArray[0];
                     $mend = $mindateArray[0];
                 } else {
                     if ($year == $maxdateArray[2]) {
                         $mstart = $maxdateArray[0];
                     } else {
                         $mstart = 12;
                     }
                     if ($year == $mindateArray[2]) {
                         $mend = $mindateArray[0];
                     } else {
                         $mend = 1;
                     }
                 }
                 for ($m = $mstart; $m >= $mend; $m--) {
                     $month = $objDate->MonthString($m);
                     $datecombo->AddOption("{$month} {$year}", "{$m}/{$year}");
                 }
             }
         }
         $tpl->SetVariable("date", _t("GLOBAL_DATE"));
         $datecombo->SetDefault(isset($post['date']) ? $post['date'] : null);
         $datecombo->AddEvent(new JSEvent(ON_CHANGE, "selectAllAlbums(); this.form.submit();"));
         $tpl->SetVariable("date_combo", $datecombo->Get());
         $albumcombo =& Piwi::CreateWidget('Combo', 'album[]');
         $albumcombo->SetID('albums');
         $albumcombo->SetStyle('width: 200px;');
         $albumcombo->SetSize(12);
         $albumcombo->SetMultiple(true);
         $firstAlbum = null;
         foreach ($albums as $a) {
             if (is_null($firstAlbum)) {
                 $firstAlbum = $a['id'];
             }
             // FIXME: Ugly hack to add title to albumcombo
             $o =& Piwi::CreateWidget('ComboOption', $a['id'], $a['name']);
             $o->SetTitle(_t('PHOO_NUM_PHOTOS_ALBUM', $a['howmany']) . ' / ' . _t('PHOO_ALBUM_CREATION_DATE') . ' ' . $objDate->Format($a['createtime']));
             $albumcombo->_options[$a['id']] = $o;
         }
         // r_album = request album
         if (isset($post['album'])) {
             $r_album = $post['album'];
         } else {
             $r_album = isset($album) ? $album : $firstAlbum;
         }
         $tpl->SetVariable('incompleteFields', _t('GLOBAL_ERROR_INCOMPLETE_FIELDS'));
         // Use for uploading image
         if (is_array($r_album)) {
             $tpl->SetVariable('defaultAlbum', $r_album[0]);
         } else {
             $tpl->SetVariable('defaultAlbum', $r_album);
         }
         $albumcombo->SetDefault($r_album);
         $albumcombo->AddEvent(new JSEvent(ON_CHANGE, "document.album_form.submit();"));
         $tpl->SetVariable('albums', _t('PHOO_ALBUMS'));
         $tpl->SetVariable('albums_combo', $albumcombo->Get());
         // Ugly hack to convert $r_album to array...
         if (!empty($r_album) && !is_array($r_album)) {
             $aux = $r_album;
             $r_album = array();
             $r_album[] = $aux;
         }
         // Show albums
         if (!empty($r_album) && is_array($r_album)) {
             if (!empty($post['date'])) {
                 $aux = explode('/', $post['date']);
                 $aux = $objDate->ToBaseDate($aux[1], $aux[0]);
                 $year = $aux['year'];
                 $month = $aux['month'];
                 $day = $aux['day'];
             } else {
                 $day = null;
                 $month = null;
                 $year = null;
             }
             foreach ($r_album as $albumId) {
                 $album = $pModel->GetAlbumImages($albumId, null, $day, $month, $year);
                 if (!Jaws_Error::IsError($album) && !empty($album)) {
                     if (isset($album['images']) && !is_array($album['images']) && count($album['images']) == 0 && checkdate($month, 1, $year)) {
                         continue;
                     }
                     $tpl->SetBlock('phoo_browse/photos/albums');
                     $tpl->SetVariable('title', $album['name']);
                     $tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
                     $tpl->SetVariable('createtime', $objDate->Format($album['createtime']));
                     if (isset($album['images']) && is_array($album['images']) && count($album['images']) > 0) {
                         // Show photos
                         foreach ($album['images'] as $img) {
                             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $img['thumb']);
                             $tpl->SetBlock('phoo_browse/photos/albums/item');
                             $tpl->SetVariable('url', "admin.php?gadget=Phoo&amp;action=SelectImage&amp;" . "image={$img["id"]}&amp;album={$albumId}" . $extraParams);
                             if (Jaws_Error::IsError($imgData)) {
                                 $tpl->SetVariable('thumb', 'images/unknown.png');
                                 $tpl->SetVariable('width', 60);
                                 $tpl->SetVariable('height', 60);
                                 $tpl->SetBlock('phoo_browse/photos/albums/item/notfound');
                                 $tpl->SetVariable('notfound', _t('PHOO_NOT_FOUND'));
                                 $tpl->ParseBlock('phoo_browse/photos/albums/item/notfound');
                             } else {
                                 $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $img['thumb']));
                                 $tpl->SetVariable('width', $imgData[0]);
                                 $tpl->SetVariable('height', $imgData[1]);
                             }
                             $tpl->SetVariable('name', $img['name']);
                             $tpl->SetVariable('album', $img['albumid']);
                             if ($img['published'] == false) {
                                 $tpl->SetBlock('phoo_browse/photos/albums/item/notpublished');
                                 $tpl->SetVariable('notpublished', _t('PHOO_NOT_PUBLISHED'));
                                 $tpl->ParseBlock('phoo_browse/photos/albums/item/notpublished');
                             }
                             $tpl->ParseBlock('phoo_browse/photos/albums/item');
                         }
                     } else {
                         $tpl->SetBlock('phoo_browse/photos/albums/nophotos');
                         $tpl->SetVariable('message', _t('PHOO_ALBUM_EMPTY'));
                         $tpl->ParseBlock('phoo_browse/photos/albums/nophotos');
                     }
                     $tpl->ParseBlock('phoo_browse/photos/albums');
                 }
             }
         }
         // Get failures
         $failures = $GLOBALS['app']->Session->GetAttribute('failures');
         if (is_array($failures) && count($failures) > 0) {
             foreach ($failures as $f) {
                 $tpl->SetBlock('phoo_browse/photos/failures');
                 $tpl->SetVariable('message', $f);
                 $tpl->ParseBlock('phoo_browse/photos/failures');
             }
         }
         // Delete key
         $GLOBALS['app']->Session->DeleteAttribute('failures');
         $tpl->ParseBlock('phoo_browse/photos');
     } else {
         $tpl->SetBlock('phoo_browse/noalbums');
         $tpl->SetVariable('message', _t('PHOO_EMPTY_ALBUMSET'));
         $tpl->ParseBlock('phoo_browse/noalbums');
     }
     // clear pushed message
     $GLOBALS['app']->Session->PopLastResponse();
     $tpl->ParseBlock('phoo_browse');
     return $tpl->Get();
 }
Example #11
0
 /**
  * Returns menu image as stream data
  *
  * @access  public
  * @return  bool    True on successful, False otherwise
  */
 function LoadImage()
 {
     $id = (int) jaws()->request->fetch('id', 'get');
     $model = $this->gadget->model->load('Menu');
     $image = $model->GetMenuImage($id);
     if (!Jaws_Error::IsError($image)) {
         $objImage = Jaws_Image::factory();
         if (!Jaws_Error::IsError($objImage)) {
             $objImage->setData($image, true);
             $res = $objImage->display('', null, 315360000);
             // cached for 10 years!
             if (!Jaws_Error::IsError($res)) {
                 return $res;
             }
         }
     }
     return false;
 }
Example #12
0
 /**
  * Add a new entry
  *
  * @access  public
  * @param   string  $user             User who is adding the photo
  * @param   array   $files            info like original name, tmp name and size
  * @param   string  $title            Title of the image
  * @param   string  $description      Description of the image
  * @param   bool    $fromControlPanel Is it called from ControlPanel?
  * @param   array   $album            Array containing the required info about the album
  * @return  mixed   Returns the ID of the new entry and Jaws_Error on error
  */
 function NewEntry($user, $files, $title, $description, $fromControlPanel = true, $album)
 {
     // check if it's really a uploaded file.
     /*if (is_uploaded_file($files['tmp_name'])) {
           $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
           return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
       }*/
     if (!preg_match("/\\.png\$|\\.jpg\$|\\.jpeg\$|\\.gif\$/i", $files['name'])) {
         $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO_EXT'), RESPONSE_ERROR);
         return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO_EXT'));
     }
     // Create directories
     $uploaddir = JAWS_DATA . 'phoo/' . date('Y_m_d') . '/';
     if (!is_dir($uploaddir)) {
         if (!Jaws_Utils::is_writable(JAWS_DATA . 'phoo/')) {
             $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
             return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
         }
         $new_dirs = array();
         $new_dirs[] = $uploaddir;
         $new_dirs[] = $uploaddir . 'thumb';
         $new_dirs[] = $uploaddir . 'medium';
         foreach ($new_dirs as $new_dir) {
             if (!Jaws_Utils::mkdir($new_dir)) {
                 $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
                 return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
             }
         }
     }
     $filename = $files['name'];
     if (file_exists($uploaddir . $files['name'])) {
         $filename = time() . '_' . $files['name'];
     }
     $res = Jaws_Utils::UploadFiles($files, $uploaddir, 'jpg,gif,png,jpeg', false, !$fromControlPanel);
     if (Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
         return new Jaws_Error($res->getMessage());
     } elseif (empty($res)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_UPLOAD_4'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_4'));
     }
     $filename = $res[0][0]['host_filename'];
     $uploadfile = $uploaddir . $filename;
     // Resize Image
     include_once JAWS_PATH . 'include/Jaws/Image.php';
     $objImage = Jaws_Image::factory();
     if (Jaws_Error::IsError($objImage)) {
         return Jaws_Error::raiseError($objImage->getMessage());
     }
     $thumbSize = explode('x', $this->gadget->registry->fetch('thumbsize'));
     $mediumSize = explode('x', $this->gadget->registry->fetch('mediumsize'));
     $objImage->load($uploadfile);
     $objImage->resize($thumbSize[0], $thumbSize[1]);
     $res = $objImage->save($this->GetThumbPath($uploadfile));
     $objImage->free();
     if (Jaws_Error::IsError($res)) {
         // Return an error if image can't be resized
         $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_RESIZE_TO_THUMB'), RESPONSE_ERROR);
         return new Jaws_Error($res->getMessage());
     }
     $objImage->load($uploadfile);
     $objImage->resize($mediumSize[0], $mediumSize[1]);
     $res = $objImage->save($this->GetMediumPath($uploadfile));
     $objImage->free();
     if (Jaws_Error::IsError($res)) {
         // Return an error if image can't be resized
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
         return new Jaws_Error(_t('PHOO_ERROR_CANT_RESIZE_TO_MEDIUM'));
     }
     $data = array();
     $data['user_id'] = $user;
     $data['filename'] = date('Y_m_d') . '/' . $filename;
     $data['title'] = $title;
     $data['description'] = $description;
     if ($this->gadget->registry->fetch('allow_comments') === 'true' && $album['allow_comments']) {
         $data['allow_comments'] = true;
     } else {
         $data['allow_comments'] = false;
     }
     if ($this->gadget->registry->fetch('published') === 'true' && $this->gadget->GetPermission('ManageAlbums')) {
         $data['published'] = true;
     } else {
         $data['published'] = false;
     }
     $jDate = Jaws_Date::getInstance();
     $createtime = Jaws_DB::getInstance()->date();
     if (function_exists('exif_read_data') && preg_match("/\\.jpg\$|\\.jpeg\$/i", $files['name']) && ($exifData = @exif_read_data($uploadfile, 1, true)) && !empty($exifData['IFD0']['DateTime']) && $jDate->ValidDBDate($exifData['IFD0']['DateTime'])) {
         $aux = explode(' ', $exifData['IFD0']['DateTime']);
         $auxdate = str_replace(':', '-', $aux[0]);
         $auxtime = $aux[1];
         $createtime = $auxdate . ' ' . $auxtime;
     }
     $data['createtime'] = $createtime;
     $table = Jaws_ORM::getInstance()->table('phoo_image');
     $result = $table->insert($data)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
         return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
     }
     // Lets remove the original if keep_original = false
     if ($this->gadget->registry->fetch('keep_original') == 'false') {
         if (!empty($data['filename'])) {
             Jaws_Utils::delete(JAWS_DATA . 'phoo/' . $data['filename']);
         }
     }
     // shout SiteActivity event
     $saParams = array();
     $saParams['action'] = 'Photo';
     $this->gadget->event->shout('SiteActivity', $saParams);
     $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_PHOTO_ADDED'), RESPONSE_NOTICE);
     return $result;
 }
Example #13
0
 /**
  * Displays an individual image.
  *
  * @access  public
  * @param   int     $id                 image ID
  * @param   int     $albumid            album ID
  * @return  string   XHTML template content
  */
 function ViewImage($id = null, $albumid = null)
 {
     $tpl = $this->gadget->template->load('ViewImage.html');
     $get = jaws()->request->fetch(array('id', 'albumid'), 'get');
     $id = !is_null($id) ? $id : (!empty($get['id']) ? $get['id'] : '0');
     $albumid = !is_null($albumid) ? $albumid : (!empty($get['albumid']) ? $get['albumid'] : '0');
     $pModel = $this->gadget->model->load('Photos');
     $sModel = $this->gadget->model->load('Settings');
     $image = $pModel->GetImage($id, $albumid);
     if (Jaws_Error::IsError($image) || empty($image)) {
         return Jaws_HTTPError::Get(404);
     }
     $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $image['medium']);
     if (Jaws_Error::IsError($imgData)) {
         return Jaws_HTTPError::Get(404);
     }
     $this->SetTitle($image['name']);
     $tpl->SetBlock('ViewImage');
     $tpl->SetVariable('title', $image['name']);
     $tpl->SetVariable('posted_by', _t('PHOO_POSTED_BY'));
     $tpl->SetVariable('img_author', $image['author']);
     $tpl->SetVariable('name', $image['name']);
     $tpl->SetVariable('filename', $image['filename']);
     $tpl->SetVariable('img_desc', $image['stripped_description']);
     $tpl->SetVariable('albumid', $albumid);
     $tpl->SetVariable('description', $this->gadget->ParseText($image['description']));
     $tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $image['medium']));
     $tpl->SetVariable('image', $GLOBALS['app']->getDataURL('phoo/' . $image['image']));
     $tpl->SetVariable('width', $imgData[0]);
     $tpl->SetVariable('height', $imgData[1]);
     // show if the original was kept
     $settings = $sModel->GetSettings();
     if ($settings['keep_original'] == 'true') {
         $tpl->SetVariable('url', $GLOBALS['app']->getDataURL('phoo/' . $image['image']));
     } else {
         $tpl->SetVariable('url', 'javascript: void();');
     }
     if (Jaws_Gadget::IsGadgetInstalled('Comments')) {
         $allow_comments_config = $this->gadget->registry->fetch('allow_comments', 'Comments');
         switch ($allow_comments_config) {
             case 'restricted':
                 $allow_comments_config = $GLOBALS['app']->Session->Logged();
                 $restricted = !$allow_comments_config;
                 break;
             default:
                 $restricted = false;
                 $allow_comments_config = $allow_comments_config == 'true';
         }
         $allow_comments = $image['allow_comments'] == true && $image['album_allow_comments'] == true && $this->gadget->registry->fetch('allow_comments') == 'true' && $allow_comments_config;
         $redirect_to = $this->gadget->urlMap('ViewImage', array('id' => $image['id'], 'albumid' => $albumid));
         $cHTML = Jaws_Gadget::getInstance('Comments')->action->load('Comments');
         $tpl->SetVariable('comments', $cHTML->ShowComments('Phoo', 'Image', $image['id'], array('action' => 'ViewImage', 'params' => array('albumid' => $albumid, 'id' => $image['id']))));
         if ($allow_comments) {
             $tpl->SetVariable('comment-form', $cHTML->ShowCommentsForm('Phoo', 'Image', $image['id'], $redirect_to));
         } elseif ($restricted) {
             $login_url = $GLOBALS['app']->Map->GetURLFor('Users', 'LoginBox');
             $register_url = $GLOBALS['app']->Map->GetURLFor('Users', 'Registration');
             $tpl->SetVariable('comment-form', _t('COMMENTS_COMMENTS_RESTRICTED', $login_url, $register_url));
         }
     }
     // Pager
     $tpl->SetBlock('ViewImage/navigation');
     $tpl->SetVariable('lbl_page_counter', _t('PHOO_PHOTO_COUNTER', $image['pos'], $image['total']));
     $tpl->SetVariable('lbl_thumbs', _t('PHOO_THUMBS'));
     $url = $this->gadget->urlMap('ViewAlbum', array('id' => $albumid));
     $tpl->SetVariable('url_thumbs', $url);
     if ($image['first'] != $image['id']) {
         $tpl->SetBlock('ViewImage/navigation/no-first-photo');
         $tpl->SetVariable('lbl_first', _t('PHOO_FIRST'));
         $url = $this->gadget->urlMap('ViewImage', array('id' => $image['first'], 'albumid' => $albumid));
         $tpl->SetVariable('url_first', $url);
         $tpl->SetVariable('lbl_prev', _t('PHOO_PREVIOUS'));
         $url = $this->gadget->urlMap('ViewImage', array('id' => $image['previous'], 'albumid' => $albumid));
         $tpl->SetVariable('url_prev', $url);
         $tpl->ParseBlock('ViewImage/navigation/no-first-photo');
     } else {
         $tpl->SetBlock('ViewImage/navigation/first-photo');
         $tpl->SetVariable('lbl_first', _t('PHOO_FIRST'));
         $tpl->SetVariable('lbl_prev', _t('PHOO_PREVIOUS'));
         $tpl->ParseBlock('ViewImage/navigation/first-photo');
     }
     if ($image['last'] != $image['id']) {
         $tpl->SetBlock('ViewImage/navigation/no-last-photo');
         $tpl->SetVariable('lbl_next', _t('PHOO_NEXT'));
         $url = $this->gadget->urlMap('ViewImage', array('id' => $image['next'], 'albumid' => $albumid));
         $tpl->SetVariable('url_next', $url);
         $tpl->SetVariable('lbl_last', _t('PHOO_LAST'));
         $url = $this->gadget->urlMap('ViewImage', array('id' => $image['last'], 'albumid' => $albumid));
         $tpl->SetVariable('url_last', $url);
         $tpl->ParseBlock('ViewImage/navigation/no-last-photo');
     } else {
         $tpl->SetBlock('ViewImage/navigation/last-photo');
         $tpl->SetVariable('lbl_next', _t('PHOO_NEXT'));
         $tpl->SetVariable('lbl_last', _t('PHOO_LAST'));
         $tpl->ParseBlock('ViewImage/navigation/last-photo');
     }
     $tpl->ParseBlock('ViewImage/navigation');
     // EXIF STUFF
     if ($settings['show_exif_info'] == 'true' && isset($image['exif']) && count($image['exif']) > 0) {
         $datatext = '';
         if (!empty($image['exif']['width'])) {
             $datatext .= _t('PHOO_WIDTH') . ': ' . $image['exif']['width'] . 'px<br />';
             $datatext .= _t('PHOO_HEIGHT') . ': ' . $image['exif']['height'] . 'px<br />';
         }
         if (!empty($image['exif']['filesize'])) {
             $datatext .= _t('PHOO_SIZE') . ': ' . $image['exif']['filesize'] . '<br />';
         }
         if (!empty($image['exif']['datetime'])) {
             $date = Jaws_Date::getInstance();
             $datatext .= _t('GLOBAL_DATE') . ': ' . $date->Format($image['exif']['datetime']) . '<br />';
         }
         if (!empty($image['exif']['aperture'])) {
             $datatext .= _t('PHOO_APERTURE') . ': ' . $image['exif']['aperture'] . '<br />';
         }
         if (!empty($image['exif']['exposure'])) {
             $datatext .= _t('PHOO_EXPOSURE_TIME') . ': ' . $image['exif']['exposure'] . '<br />';
         }
         if (!empty($image['exif']['focallength'])) {
             $datatext .= _t('PHOO_FOCAL_LENGTH') . ': ' . $image['exif']['focallength'];
         }
         $tpl->SetBlock('ViewImage/exif');
         $tpl->SetVariable('exif_info', _t('PHOO_EXIF_INFO'));
         $tpl->SetVariable('cameraimg', $image['exif']['cameraimg']);
         if (!empty($image['exif']['camera'])) {
             $tpl->SetVariable('camera', $image['exif']['camera']);
         } else {
             $tpl->SetVariable('camera', _t('PHOO_UNKNOWN_CAM'));
         }
         $tpl->SetVariable('data', $datatext);
         $tpl->ParseBlock('ViewImage/exif');
     }
     $tpl->ParseBlock('ViewImage');
     return $tpl->Get();
 }
Example #14
0
 /**
  * Destroys image handle
  *
  * @access  public
  * @return  void
  */
 function free()
 {
     if (isset($this->_hImage)) {
         $this->_hImage->destroy();
     }
     parent::free();
 }
Example #15
0
 /**
  * Destroys image handle
  *
  * @access  public
  * @return  void
  */
 function free()
 {
     if (is_resource($this->_hImage)) {
         imagedestroy($this->_hImage);
     }
     parent::free();
 }
Example #16
0
 /**
  * Displays an index of galleries.
  *
  * @access  public
  * @param   int      $gid         Group ID
  * @return  string XHTML template content
  */
 function AlbumList($gid = null)
 {
     $tpl = $this->gadget->template->load('Albums.html');
     $tpl->SetBlock('albums');
     $tpl->SetVariable('title', _t('PHOO_ALBUMS'));
     $model = $this->gadget->model->load('Albums');
     if (empty($gid)) {
         $gid = $this->gadget->request->fetch('group', 'get');
     }
     if (is_null($gid)) {
         $group = (int) $this->gadget->request->fetch('group');
         if (!empty($group) && $group != 0) {
             $gid = $group;
         }
     }
     $albums = $model->GetAlbumList($gid);
     if (!Jaws_Error::IsError($albums)) {
         $date = Jaws_Date::getInstance();
         $agModel = $this->gadget->model->load('AlbumGroup');
         foreach ($albums as $album) {
             if (!isset($album['qty'])) {
                 continue;
             }
             $tpl->SetBlock('albums/item');
             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $album['thumb']);
             if (!Jaws_Error::IsError($imgData)) {
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
             }
             $url = $this->gadget->urlMap('ViewAlbum', array('id' => $album['id']));
             $tpl->SetVariable('url', $url);
             $tpl->SetVariable('name', $album['name']);
             $tpl->SetVariable('filename', $album['filename']);
             $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $album['thumb']));
             $tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $album['medium']));
             $tpl->SetVariable('howmany', _t('PHOO_NUM_PHOTOS_ALBUM', $album['qty']));
             $tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
             $tpl->SetVariable('createtime', $date->Format($album['createtime']));
             $pos = 1;
             $groups = $agModel->GetAlbumGroupsInfo($album['id']);
             if (is_array($groups)) {
                 foreach ($groups as $group) {
                     $url = $this->gadget->urlMap('AlbumList', array('group' => $group['fast_url']));
                     $tpl->SetBlock('albums/item/group');
                     $tpl->SetVariable('url', $url);
                     $tpl->SetVariable('name', $group['name']);
                     if ($pos == count($groups)) {
                         $tpl->SetVariable('separator', '');
                     } else {
                         $tpl->SetVariable('separator', ',');
                     }
                     $pos++;
                     $tpl->ParseBlock('albums/item/group');
                 }
             }
             $tpl->ParseBlock('albums/item');
         }
     }
     $tpl->ParseBlock('albums');
     return $tpl->Get();
 }
Example #17
0
 /**
  * I'm not sure what this does... gets the authors photo maybe?
  *
  * @access  public
  * @see Phoo_Model::GetAsPortrait()
  * @return  string   XHTML template content
  * @todo Better docblock
  */
 function PhotoblogPortrait()
 {
     $photoid = jaws()->request->fetch('photoid', 'get');
     $model = $this->gadget->model->load('Photoblog');
     $entries = $model->GetAsPortrait($photoid);
     if (Jaws_Error::IsError($entries)) {
         return '';
     }
     if (count($entries) <= 0) {
         return '';
     }
     $this->SetTitle(_t('PHOO_PHOTOBLOG'));
     $tpl = $this->gadget->template->load('Photoblog.html');
     $tpl->SetBlock('photoblog_portrait');
     $first = true;
     include_once JAWS_PATH . 'include/Jaws/Image.php';
     $date = Jaws_Date::getInstance();
     foreach ($entries as $entry) {
         if (empty($photoid)) {
             if (!$first) {
                 $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $entry['thumb']);
                 if (Jaws_Error::IsError($imgData)) {
                     continue;
                 }
                 $tpl->SetBlock('photoblog_portrait/item');
                 $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $entry['thumb']));
                 $url = $this->gadget->urlMap('PhotoblogPortrait', array('photoid' => $entry['id']));
                 $tpl->SetVariable('url', $url);
                 $tpl->SetVariable('title', $entry['name']);
                 $tpl->SetVariable('description', $this->gadget->ParseText($entry['description']));
                 $tpl->SetVariable('createtime', $date->Format($entry['createtime']));
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
                 $tpl->ParseBlock('photoblog_portrait/item');
             } else {
                 $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $entry['medium']);
                 if (Jaws_Error::IsError($imgData)) {
                     continue;
                 }
                 $tpl->SetBlock('photoblog_portrait/main');
                 $tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $entry['medium']));
                 $tpl->SetVariable('url', $GLOBALS['app']->getDataURL('phoo/' . $entry['image']));
                 $tpl->SetVariable('title', $entry['name']);
                 $tpl->SetVariable('description', $this->gadget->ParseText($entry['description']));
                 $tpl->SetVariable('createtime', $date->Format($entry['createtime']));
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
                 $tpl->ParseBlock('photoblog_portrait/main');
             }
             $first = false;
         } else {
             if ($photoid == $entry['id']) {
                 $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $entry['medium']);
                 if (Jaws_Error::IsError($imgData)) {
                     continue;
                 }
                 $tpl->SetBlock('photoblog_portrait/main');
                 $tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $entry['medium']));
                 $tpl->SetVariable('url', $GLOBALS['app']->getDataURL('phoo/' . $entry['image']));
                 $tpl->SetVariable('title', $entry['name']);
                 $tpl->SetVariable('description', $this->gadget->ParseText($entry['description']));
                 $tpl->SetVariable('createtime', $date->Format($entry['createtime']));
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
                 $tpl->ParseBlock('photoblog_portrait/main');
             } else {
                 $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $entry['thumb']);
                 if (Jaws_Error::IsError($imgData)) {
                     continue;
                 }
                 $tpl->SetBlock('photoblog_portrait/item');
                 $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $entry['thumb']));
                 $url = $this->gadget->urlMap('PhotoblogPortrait', array('photoid' => $entry['id']));
                 $tpl->SetVariable('url', $url);
                 $tpl->SetVariable('title', $entry['name']);
                 $tpl->SetVariable('description', $this->gadget->ParseText($entry['description']));
                 $tpl->SetVariable('createtime', $date->Format($entry['createtime']));
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
                 $tpl->ParseBlock('photoblog_portrait/item');
             }
         }
     }
     $tpl->ParseBlock('photoblog_portrait');
     return $tpl->Get();
 }