static function getActivityContentHTML($act) { // Ok, the activity could be an upload OR a wall comment. In the future, the content should // indicate which is which $html = ''; $param = new JParameter($act->params); $action = $param->get('action', false); $photoid = $param->get('photoid', 0); CFactory::load('models', 'photos'); $url = $param->get('url', false); CFactory::load('helpers', 'albums'); if ($action == 'wall') { // unfortunately, wall post can also have 'photo' as its $act->apps. If the photo id is availble // for (newer activity stream, inside the param), we will show the photo snippet as well. Otherwise // just print out the wall content // Version 1.6 onwards, $params will contain photoid information // older version would have #photoid in the $title, since we link it to the photo $photoid = $param->get('photoid', false); if ($photoid) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($act->cid); $helper = new CAlbumsHelper($photo->albumid); if ($helper->showActivity()) { $tmpl = new CTemplate(); $tmpl->set('url', $url); $tmpl->set('photo', $photo); $tmpl->set('param', $param); $tmpl->set('act', $act); return $tmpl->fetch('activity.photos.wall'); } } return ''; } elseif ($action == 'upload' && $photoid > 0) { $albumsHelper = new CAlbumsHelper($act->cid); if ($albumsHelper->isPublic()) { // If content has link to image, we could assume it is "upload photo" action // since old content add this automatically. // The $act->cid will be the album id, Retrive the recent photos uploaded // If $act->activities has data, that means this is an aggregated content // display some of them $photoModel = CFactory::getModel('photos'); $album = JTable::getInstance('Album', 'CTable'); $album->load($act->cid); if (empty($act->activities)) { $acts[] = $act; } else { $acts = $act->activities; } $tmpl = new CTemplate(); $tmpl->set('album', $album); $tmpl->set('acts', $acts); return $tmpl->fetch('activity.photos.upload'); } } return $html; }
/** * Return HTML for acitivity stream * @param JTableActiities $act activity object * @return string html formatted output */ public static function getActivityContentHTML($act) { // Ok, the activity could be an upload OR a wall comment. In the future, the content should // indicate which is which $html = ''; //$param = new CParameter( $act->params ); $action = $act->params->get('action', false); $photoid = $act->params->get('photoid', 0); $url = $act->params->get('url', false); $act->title = CActivities::format($act->title, $act->params->get('mood', null)); if ($action == 'wall') { // unfortunately, wall post can also have 'photo' as its $act->apps. If the photo id is availble // for (newer activity stream, inside the param), we will show the photo snippet as well. Otherwise // just print out the wall content // Version 1.6 onwards, $params will contain photoid information // older version would have #photoid in the $title, since we link it to the photo $photoid = $param->get('photoid', false); if ($photoid) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($act->cid); $helper = new CAlbumsHelper($photo->albumid); if ($helper->showActivity()) { $tmpl = new CTemplate(); return $tmpl->set('url', $url)->set('photo', $photo)->set('param', $param)->set('act', $act)->fetch('activity.photos.wall'); } } return ''; } elseif ($action == 'upload' && $photoid > 0) { $photoModel = CFactory::getModel('photos'); // Album object should have been created in the activities library $album = $act->album; $albumsHelper = new CAlbumsHelper($album); if ($albumsHelper->isPublic()) { // If content has link to image, we could assume it is "upload photo" action // since old content add this automatically. // The $act->cid will be the album id, Retrive the recent photos uploaded // If $act->activities has data, that means this is an aggregated content // display some of them $db = JFactory::getDBO(); // If count is more than 1, get the last few photos, otherwise // the photo might have a custom message along with it. Show that single photo $count = $act->params->get('count', 1); $photosId = $act->params->get('photosId', null); $batchCount = $act->params->get('batchcount', $count); if (is_null($photosId)) { if ($count == 1) { $album->id = empty($album->id) ? 0 : $album->id; $sql = "SELECT * FROM #__community_photos WHERE `albumid`=" . $album->id . " AND `id`=" . $photoid . " AND `status` != 'temp'"; $db->setQuery($sql); $result = $db->loadObjectList(); } else { $album->id = empty($album->id) ? 0 : $album->id; $sql = "SELECT * FROM #__community_photos WHERE `albumid`=" . $album->id . " AND `status` != 'temp'" . " ORDER BY `id` DESC LIMIT 0, 5"; $db->setQuery($sql); $result = $db->loadObjectList(); } } else { $result = explode(',', $photosId); } $photos = array(); if (is_array($result) && count($result) > 0) { foreach ($result as $row) { $photo = JTable::getInstance('Photo', 'CTable'); if (is_null($photosId)) { $photo->bind($row); } else { $photo->load($row); } if ($photo->status != 'delete' && $photo->id) { $photos[] = $photo; } if ($photo->status == 'delete') { $batchCount--; } } foreach ($photos as $key => $data) { if ($data->id == $photoid) { unset($photos[$key]); /* remove this photo */ array_unshift($photos, $data); /* move it to beginning of array */ } } $photos = array_slice($photos, 0, 5); // limit to 5 photos only if (empty($act->activities)) { $acts[] = $act; } else { $acts = $act->activities; } $tmpl = new CTemplate(); if ($batchCount == 0) { $batchCount = 1; } return $tmpl->set('album', $album)->set('acts', $acts)->set('photos', $photos)->set('count', $count)->set('batchCount', $batchCount)->set('stream', $act->params->get('stream', false))->fetch('stream/photo-upload'); } } } return $html; }