Beispiel #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();
 }
Beispiel #2
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();
 }
Beispiel #3
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();
 }
Beispiel #4
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;
 }
Beispiel #5
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();
 }
Beispiel #6
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();
 }
Beispiel #7
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();
 }
Beispiel #8
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();
 }
Beispiel #9
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();
 }