public function processRequest(User $user = NULL) { // attempt to parse and load the next image id $nextImageId = RequestParser::parseRequestParam($_REQUEST, self::GET_PARAM_NEXT_IMAGE_ID, RequestParser::PARAM_FILTER_TYPE_INT); // if no image was specified, redirect to the start journey view $startJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/StartJourneyView'); if (!$nextImageId) { header("Location: {$startJourneyUrl}"); exit; } $dbConnection = DbConnectionUtil::getDbConnection(); $nextImageData = ImageData::loadImageDataById($dbConnection, $nextImageId); if (!$nextImageData) { header("Location: {$startJourneyUrl}"); exit; } parent::displayHeader($user, 'Journey'); // attempt to parse the chosen attribute, if specified add to its tally if (isset($_GET[self::GET_PARAM_CHOSEN_ATTRIBUTE])) { $chosenAttribute = $_GET[self::GET_PARAM_CHOSEN_ATTRIBUTE]; // verify the specified chosen attribute is actually an attribute of the chosen image if ($nextImageData->hasAttribute($chosenAttribute)) { if (!isset($_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute])) { $_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute] = 1; } else { $_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute]++; } } } // store the current image id, in the journey session array, check for membership incase of a page re-load if (!in_array($nextImageId, $_SESSION['JOURNEY_IMAGE_LIST'])) { $_SESSION['JOURNEY_IMAGE_LIST'][] = $nextImageId; } $commonAttributeImageDataTupleList = NULL; $commonAttributeImageIdList = NULL; $randomImageDataList = NULL; // find NUM_SIMILAR_CHOICES common images if possible $commonAttributeImageIdTupleList = ImageAttribute::loadCommonAttributeImageIdTupleList($dbConnection, $nextImageId, $_SESSION['JOURNEY_IMAGE_LIST']); //print( "<br/>common id list: " ); print_r( $commonAttributeImageIdTupleList ); print("<br/>" ); shuffle($commonAttributeImageIdTupleList); $commonAttributeImageIdList = array(); $commonAttributeImageDataTupleList = array(); while (count($commonAttributeImageDataTupleList) < self::NUM_SIMILAR_CHOICES && count($commonAttributeImageIdTupleList) > 0) { $currentEntry = array(); $commonAttributeImageIdTuple = array_shift($commonAttributeImageIdTupleList); if (!in_array($commonAttributeImageIdTuple['imageId'], $commonAttributeImageDataTupleList) && !in_array($commonAttributeImageIdTuple['imageId'], $_SESSION['JOURNEY_IMAGE_LIST'])) { $imageData = ImageData::loadImageDataById($dbConnection, $commonAttributeImageIdTuple['imageId']); //print( "<br/>Image Data: " ); print_r( $imageData ); print( '<br/>' ); $commonAttributeImageIdList[] = $commonAttributeImageIdTuple['imageId']; $currentEntry['imageData'] = $imageData; $currentEntry['attribute'] = $commonAttributeImageIdTuple['attribute']; $commonAttributeImageDataTupleList[] = $currentEntry; } } //print( "<br/>common map: " ); print_r( $commonAttributeImageDataTupleList ); print("<br/>" ); // add a random image to the choices list, and fill in the gaps if NUM_SIMILAR_CHOICES could not be found, if possible /* print( "<br/>commonAttributeImageDataTupleList: " ); print_r( $commonAttributeImageDataTupleList ); print( "<br/>" ); print( "allImageIdList: " ); print_r( $allImageIdList ); print( "<br/>" ); print( "att_map: " ); print_r( $_SESSION['JOURNEY_IMAGE_LIST'] ); print( "<br/>" ); */ $allImageIdList = ImageData::loadAllImageIdList($dbConnection); shuffle($allImageIdList); $randomImageIdList = array(); while (count($randomImageIdList) + count($commonAttributeImageIdList) < self::NUM_SIMILAR_CHOICES + 1 && count($allImageIdList) > 0) { $imageId = array_shift($allImageIdList); if ($imageId != $nextImageId && !in_array($imageId, $randomImageIdList) && !in_array($imageId, $commonAttributeImageIdList) && !in_array($imageId, $_SESSION['JOURNEY_IMAGE_LIST'])) { $randomImageIdList[] = $imageId; } } if (!empty($randomImageIdList)) { $randomImageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $randomImageIdList); } else { $randomImageDataList = array(); } // If the journey session array size has reached the number of journey steps, then set the is last // step flag to true, otherwise it should be false $IS_LAST_STEP = FALSE; if (count($_SESSION['JOURNEY_IMAGE_LIST']) == self::NUM_JOURNEY_STEPS) { $IS_LAST_STEP = TRUE; } // display the current image ?> <div class="currentJourneyImageSection"> <img src="<?php echo UrlFormatter::formatImageUrl($nextImageData->getContentUri()); ?> "/> </div> <?php // if this is not the last step, display further choices if (!$IS_LAST_STEP) { ?> <p class="imageGridHeader">Choose Your Journey's Next Step</p> <div class="centerWrapper"> <div class="imageGrid"> <?php // list common choices foreach ($commonAttributeImageDataTupleList as $commonAttributeImageDataTuple) { $commonImageId = $commonAttributeImageDataTuple['imageData']->getId(); $commonImageThumbUrl = UrlFormatter::formatImageUrl($commonAttributeImageDataTuple['imageData']->getThumbnailUri()); $commonAttribute = $commonAttributeImageDataTuple['attribute']; $choiceUrl = UrlFormatter::formatRoutingItemUrl('views/JourneyStepView', array(self::GET_PARAM_NEXT_IMAGE_ID => $commonImageId, self::GET_PARAM_CHOSEN_ATTRIBUTE => $commonAttribute)); ?> <a href="<?php echo $choiceUrl; ?> "><img src="<?php echo $commonImageThumbUrl; ?> "/></a> <?php } // list random choices foreach ($randomImageDataList as $randomImageData) { $randomImageId = $randomImageData->getId(); $thumbnailUrl = UrlFormatter::formatImageUrl($randomImageData->getThumbnailUri()); $choiceUrl = UrlFormatter::formatRoutingItemUrl('views/JourneyStepView', array(self::GET_PARAM_NEXT_IMAGE_ID => $randomImageId)); ?> <a href="<?php echo $choiceUrl; ?> "><img src="<?php echo $thumbnailUrl; ?> "/></a> <?php } ?> </div> </div> <?php } else { $finishJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/FinishJourneyView'); ?> <div class="finishJourneyButtonSection"> <a class="button" href="<?php echo $finishJourneyUrl; ?> ">Finish Journey</a> </div> <?php } parent::displayFooter(); }
public function processRequest(User $user = NULL) { parent::displayHeader($user, 'Image Search Results'); // compose and execute query $dbConnection = DbConnectionUtil::getDbConnection(); $queryString = 'SELECT imd.id FROM image_data imd '; $attribute = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_ATTRIBUTE, RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC_WS_ONLY); if ($attribute != NULL) { $queryString .= "INNER JOIN image_attribute ima ON imd.id = ima.image_data_id AND ima.attribute LIKE '%{$attribute}%' "; } $queryString .= ' WHERE 1=1 '; $title = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_TITLE, RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC_WS_ONLY); if ($title != NULL) { $queryString .= "AND imd.title LIKE '%{$title}%' "; } $year = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_YEAR, RequestParser::PARAM_FILTER_TYPE_INT); if ($year != NULL) { $queryString .= "AND imd.year LIKE '%{$year}%' "; } $author = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_AUTHOR, RequestParser::PARAM_FILTER_TYPE_ALPHA_WS_ONLY); if ($author != NULL) { $queryString .= "AND imd.author LIKE '%{$author}%' "; } //print( "<br/>queryString: $queryString<br/><br/>" ); $preparedStatement = $dbConnection->prepare($queryString); $preparedStatement->execute(); $idList = array(); while ($resultRow = $preparedStatement->fetch(PDO::FETCH_ASSOC)) { $idList[] = $resultRow['id']; } $preparedStatement = NULL; if (count($idList) > 0) { $imageDataResultList = ImageData::loadImageDataListByIdSet($dbConnection, $idList); } else { $imageDataResultList = array(); } ?> <h1>Search Results</h1> <br/> <div class="imageDetailsView"> <?php foreach ($imageDataResultList as $imageData) { $viewImageDetailsUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId())); ?> <div class="searchResultItem"> <?php $thumbnailUri = $imageData->getThumbnailUri(); if (!empty($thumbnailUri)) { ?> <div> <a href="<?php echo $viewImageDetailsUrl; ?> "><img id="thumbnail_field" src="<?php echo UrlFormatter::formatImageUrl($imageData->getThumbnailUri()); ?> "/></a> <br/> <a href="<?php echo $viewImageDetailsUrl; ?> ">Details</a> </div> <?php $title = $imageData->getTitle(); if ($title != null) { ?> <label for="title_field">Title</label> <span id="title_field" class="imageDetailsField"><?php echo $title; ?> </span> <br/> <?php } ?> <?php $author = $imageData->getAuthor(); if ($author != null) { ?> <label for="author_field">Author</label> <span id="author_field" class="imageDetailsField"><?php echo $author; ?> </span> <br/> <?php } ?> <br/> <?php } ?> </div> <div style="clear:both"></div> <?php } ?> </div> <?php parent::displayFooter(); }
<?php $friends = FriendData::countFriends(Session::$user->id); $images = ImageData::countByUserId(Session::$user->id); ?> <div class="list-group"> <a href="./?view=myfriends" class="list-group-item">Amigos <span class="label label-default pull-right"><?php echo $friends->c; ?> </span></a> <a href="./?view=myphotos" class="list-group-item">Fotos <span class="label label-default pull-right"><?php echo $images->c; ?> </span></a> <a href="./?view=conversations" class="list-group-item">Mensajes</a> <!-- <a href="#" class="list-group-item">Grupos</a> --> </div>
<?php $image = ImageData::getById($_GET["id"]); $u = null; if (Core::$user != null) { $u = Core::$user; } ?> <div class='row'> <div class="col-md-9"> <?php if ($image != null) { //if($image->privacy_id==1){ echo "<i class='fa fa-globe pull-right'></i>";} //else if($image->privacy_id==2){ echo "<i class='fa fa-lock pull-right'></i>";} ?> <h1><?php echo $image->title; ?> </h1><br> <img class="img-responsive" src='storage/channel/<?php echo $image->channel_id . "/" . $image->name; ?> '> <br><br> <?php $xlike = null; if (Session::getUID() != "") { $xlike = IslikeData::getAllLikeImageUser($_GET['id'], Session::getUID()); } ?>
<?php /** * @author evilnapsis * @brief Descripcion **/ if (Session::exists("user_id") && !empty($_POST)) { $image = null; $image_id = 0; $handle = new Upload($_FILES['image']); if ($handle->uploaded) { $url = "storage/users/{$_SESSION['user_id']}/images/"; $handle->Process($url); // $handle->file_dst_name; $image = new ImageData(); $image->src = $handle->file_dst_name; $image->level_id = $_POST["level_id"]; $image->user_id = $_SESSION["user_id"]; $image_id = $image->add(); } $post_id = 0; if ($_POST["content"] != "") { $post = new PostData(); $post->content = $_POST["content"]; $post->level_id = $_POST["level_id"]; $post->author_ref_id = $_SESSION["user_id"]; $post->receptor_ref_id = $_SESSION["user_id"]; $post_id = $post->add(); if ($handle->uploaded) { $pi = new PostImageData(); $pi->post_id = $post_id[1];
<script type="text/javascript"> function loadcomments(t,r){ $.post("./?action=loadcomments","t="+t+"&r="+r, function(data){ $("#comments-"+t+"-"+r).html(data); }); } </script> <?php $from = $params["from"]; $user = $params["user"]; $posts = ImageData::getAllByUserId($user->id); if (count($posts) > 0) { ?> <div id="statuses"> <table class="table table-bordered"> <?php /* Obtener las imagenes asociadas a un post/status */ foreach ($posts as $p) { //$ps = $p->getPIS(); ?> <tr> <td> <div class="caption" style="padding-bottom:0;"> <?php $authordata = $p->getUser(); $pf = ProfileData::getByUserId($authordata->id); if ($pf->image != "") { ?> <img src="<?php echo "storage/users/" . $authordata->id . "/profile/" . $pf->image; ?>
<?php $comment = new CommentData(); $comment->content = $_POST['content']; $comment->image_id = $_POST['image_id']; $comment->user_id = Session::getUID(); $comment->add(); $not_type = NotificationTypeData::getByName("Nuevo Comentario"); $u = UserData::getById(Session::getUID()); $image = ImageData::getById($_POST['image_id']); $n = new NotificationData(); $n->brief = "<b>{$u->name} {$u->lastname}</b> Te ha agregado un nuevo comentario."; $n->content = ""; $n->channel_id = $image->channel_id; $n->image_id = $_POST['image_id']; $n->comment_id = "NULL"; $n->album_id = "NULL"; $n->notification_type_id = $not_type->id; $n->user_id = Session::getUID(); $n->add(); print "<script>window.location='index.php?view=image&id={$_POST['image_id']}';</script>";
<?php $image = ImageData::getById($_GET['id']); ?> <div style='background:rgba(255,255,255,0.3);'> <div class='row'> <div class='span10'> <a href='index.php?module=viewalbum&alid=<?php echo $image->album_id; ?> ' class='btn pull-right'><i class='fa fa-arrow-left'></i> Regresar</a> <h2 class='roboto'><?php echo $image->title; ?> <small>Editar imagen</small></h2> <form enctype="multipart/form-data" method='post' action='add.php' class='form-horizontal' id='form_upload'> <center> <img id='preview' style='width:50%;' src="<?php echo "storage/images/albums/{$image->album_id}/{$image->image}"; ?> "></center> <div class="control-group"> <label class="control-label" for="inputEmail"></label> <div class="controls"> <input type="file" name='image' id="inputImage" placeholder="Email"> <input type="hidden" name='reference' value='updateimage'> <input type="hidden" name='image_id' value='<?php echo $_GET['id']; ?> '>
$int_obj->setFolderName($content_folder_location); $int_obj->setObjectName($content_folder_file); $set_content_obj->setDocumentParam($int_obj); $set_content_obj->setContentParam($some_random_html); $set_document_response = $instance->execute($set_content_obj); // sample of getDocumentContent $get_content_obj = new getDocumentContent(); $folder_location = $content_folder_location; $object_name = $content_folder_file; $get_content_obj->setDocumentParam($int_obj); $result = $instance->execute($get_content_obj); print_r($result); $set_document_images_obj = new setDocumentImages(); $set_document_images_obj->setDocumentParam($int_obj); $image_1_name = "random_pic1.jpg"; $image_2_name = "random_pic2.jpg"; $image_1 = file_get_contents('pic1.jpg'); $image_2 = file_get_contents('pic2.jpg'); $image_array = array(); $imgData_obj_1 = new ImageData(); $imgData_obj_1->setImage($image_1); $imgData_obj_1->setImageName($image_1_name); $imgData_obj_2 = new ImageData(); $imgData_obj_2->setImage($image_2); $imgData_obj_2->setImageName($image_2_name); $image_array[] = $imgData_obj_1; $image_array[] = $imgData_obj_2; $set_document_images_obj->setImageDataParam($image_array); $set_images_response = $instance->execute($set_document_images_obj); $instance->logout(); }
public function processRequest(User $user = NULL) { $journeyId = RequestParser::parseRequestParam($_GET, self::GET_PARAM_JOURNEY_ID, RequestParser::PARAM_FILTER_TYPE_INT); $baseUrl = Settings::getSetting('APPLICATION_URL'); if (!$journeyId) { header("Location: {$baseUrl}"); exit; } // load the journey data $dbConnection = DbConnectionUtil::getDbConnection(); $journeyData = Journey::loadJourneyById($dbConnection, $journeyId); if (!$journeyData) { header("Location: {$baseUrl}"); exit; } // load the images from the journey $imageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $journeyData->getImageIdList()); parent::displayHeader($user, 'Journey Details'); ?> <div class="imageDetailsView"> <label for="journey_name_field">Journey Name</label> <br/> <span id="journey_name_field" class="imageDetailsViewField"><?php echo $journeyData->getTitle(); ?> </span> <br/> <label for="journey_creation_date_field">Journey Date</label> <br/> <span id="journey_creation_date_field" class="imageDetailsViewField"><?php echo $journeyData->getCreationDate(); ?> </span> <br/> <label for="journey_comments_field">Journey Comments</label> <br/> <p id="journey_comments_field" class="imageDetailsViewField"><?php echo $journeyData->getComments(); ?> </p> </div> <div class="imageGrid"> <?php foreach ($imageDataList as $imageData) { $imageDetailsUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId())); $thumbnailUrl = UrlFormatter::formatImageUrl($imageData->getThumbnailUri()); ?> <a target="_blank" href="<?php echo $imageDetailsUrl; ?> "><img src="<?php echo $thumbnailUrl; ?> "/></a> <?php } ?> </div> <?php parent::displayFooter(); }
/** * This abstract function performs the processing of the user request. * @param User $user The requesting user. If the user is not null, then by convention * actions will assume the user is authenticated, otherwise not. * @throws Exception If an error was encountered while processing this request, an exception * will be thrown. * @return void */ public function processRequest(User $user = NULL) { // if image id was specified, parse it, attempt to load an image data object using the id $imageId = RequestParser::parseRequestParam($_REQUEST, EditImageAction::GET_PARAM_IMAGE_ID, RequestParser::PARAM_FILTER_TYPE_INT); $imageData = NULL; if ($imageId != NULL) { $imageData = ImageData::loadImageDataById(DbConnectionUtil::getDbConnection(), $imageId); } // otherwise create a new image data object if ($imageData == NULL) { $imageData = new ImageData(); $imageData->setSubmitterUserId($user->getId()); } // set the fields in the image data object $author = NULL; if (isset($_POST['author'])) { $author = $_POST['author']; } if ($author != NULL) { $imageData->setAuthor($author); } $title = NULL; if (isset($_POST['title'])) { $title = $_POST['title']; } if ($title != NULL) { $imageData->setTitle($title); } $year = NULL; if (isset($_POST['year'])) { $year = $_POST['year']; } if ($year != NULL) { $imageData->setYear($year); } // update attributes list $attributeString = $_POST[EditImageAction::POST_PARAM_ATTRIBUTE_LIST]; if (!empty($attributeString)) { $attributeStringList = explode(",", $attributeString); } else { $attributeStringList = array(); } // add new attributes foreach ($attributeStringList as $attString) { if ($attString != "") { if (!$imageData->hasAttribute($attString)) { $imageData->addAttributeByString($attString); } } } $dbConnection = DbConnectionUtil::getDbConnection(); // remove deleted ones $attributeList = $imageData->getAttributeList(); foreach ($attributeList as $attribute) { if (!in_array($attribute->getAttribute(), $attributeStringList)) { $imageData->removeAttributeBystring($attribute->getAttribute()); $attribute->delete($dbConnection); } } // save the image data object $imageData->save($dbConnection); // if image data was uploaded, process the image uploads and save again if (!empty($_FILES[EditImageAction::POST_PARAM_THUMBNAIL]['name'])) { $thumbnailUri = $this->processImageUpload('image_data_thumbs', $imageData->getId(), EditImageAction::POST_PARAM_THUMBNAIL); $imageData->setThumbnailUri($thumbnailUri); $imageData->save($dbConnection); } if (!empty($_FILES[EditImageAction::POST_PARAM_FILE]['name'])) { $fileUri = $this->processImageUpload('image_data', $imageData->getId(), EditImageAction::POST_PARAM_FILE); $imageData->setContentUri($fileUri); $imageData->save($dbConnection); } // redirect the user to the image viewing page $getParamMap = array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId()); $imageDetailsViewUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', $getParamMap); header("Location: {$imageDetailsViewUrl}"); }
/** * This function performs the processing of the user request. * @param User $user The requesting user. If the user is not null, then by convention * actions will assume the user is authenticated, otherwise not. * @throws Exception If an error was encountered while processing this request, an exception * will be thrown. * @return void */ public function processRequest(User $user = NULL) { parent::displayHeader($user, 'Image Details'); if (isset($_REQUEST[ImageDetailsView::GET_PARAM_RETURN_URL])) { ?> <a href="<?php echo $_REQUEST[ImageDetailsView::GET_PARAM_RETURN_URL]; ?> ">Return</a> <br/> <?php } if (isset($_REQUEST[ImageDetailsView::GET_PARAM_IMAGE_ID])) { $imageId = $_REQUEST[ImageDetailsView::GET_PARAM_IMAGE_ID]; $imageData = ImageData::loadImageDataById(DbConnectionUtil::getDbConnection(), $imageId); if ($imageData == NULL) { print "Failed to load image data "; } else { $editImageUrl = UrlFormatter::formatRoutingItemUrl('views/EditImageView', array(EditImageView::GET_PARAM_IMAGE_ID => $imageData->getId())); $thumbnailUri = $imageData->getThumbnailUri(); $contentUri = $imageData->getContentUri(); ?> <div class="imageDetailsView"> <label for="title_field">Title</label> <br/> <span id="title_field" class="imageDetailsViewField"><?php echo $imageData->getTitle(); ?> </span> <br/> <label for="author_field">Author</label> <br/> <span id="author_field" class="imageDetailsViewField"><?php echo $imageData->getAuthor(); ?> </span> <br/> <label for="year_field">Year</label> <br/> <span id="year_field" class="imageDetailsViewField"><?php echo $imageData->getYear(); ?> </span> <br/> <label for="attributes_field">Attributes</label> <br/> <table class="attribute_table" id="attributes_field"> <?php foreach ($imageData->getAttributeList() as $attribute) { ?> <tr><td><?php echo $attribute->getAttribute(); ?> </td></tr> <?php } ?> </table> <br/> <br/> <label for="content_uri_field">Image</label> <br/> <span id="content_uri_field" class="imageDetailsViewField"> <image style="max-width: 100%" id="content_uri_field" src="<?php echo UrlFormatter::formatImageUrl($contentUri); ?> "/> </span> <br/><br/> <label for="thumbnail_field">Thumbnail</label> <br/> <img id="thumbnail_field" src="<?php echo UrlFormatter::formatImageUrl($thumbnailUri); ?> "/> <br/><br/> <?php if ($user != NULL) { ?> <a class="button" href="<?php echo $editImageUrl; ?> ">Edit</a> <?php } ?> </div> <?php } } else { print "No image specified"; } parent::displayFooter(); }
<h3>Subida de Imagenes</h3> <?php $users = ImageData::getAllByDay(); if (count($users) > 0) { ?> <table class='table table-bordered table-hover'> <tr> <td>Fecha</td> <td>Total</td> </tr> <?php foreach ($users as $user) { ?> <tr> <td><?php echo $user->created_date; ?> </td> <td><?php echo $user->total; ?> </td> </tr> <?php } ?> </table> <?php }
<div class='row'> <?php $channels = ChannelData::getAll(); $images = ImageData::getAll(); $resultados = ImageViewData::getSearch($_GET['q']); $im = null; $url = null; if (count($resultados) > 0) { $im = $resultados[0]->getImage(); $url = "storage/channel/{$im->channel_id}/" . $im->name; } ?> <div class="col-md-12"> <h1 class='roboto'>Buscar: <?php echo $_GET['q']; ?> </h1> <?php if ($url != null) { ?> <hr><?php foreach ($resultados as $resultado) { $image = $resultado->getImage(); $url = "storage/channel/{$image->channel_id}/" . $image->name; echo <<<AAA \t\t<ul class="row"> <li class="col-md-4"> <img data-src="holder.js/360x270" class='img-responsive' src='{$url}' alt=""> </li> <li class="col-md-8">
<?php $handle = new Upload($_FILES['image']); if ($handle->uploaded) { $url = "storage/channel/" . $_POST['channel_id']; $handle->Process($url); $image = new ImageData(); $image->name = $handle->file_dst_name; $image->title = $_POST['title']; $image->description = $_POST['description']; $image->tags = $_POST['tags']; $image->channel_id = $_POST['channel_id']; $image->privacy_id = $_POST['privacy_id']; $image->add(); print "<script>window.location='index.php?view=mychannel';</script>"; }
<?php $channel = ChannelData::getById($_GET['id']); // aui empieza ... if ($channel != null) { $images = ImageData::getAllByChannel($channel->id); $followers = FollowerData::getByChannelId($_GET['id']); $url = ""; $background = ""; if ($channel->image != "") { $url = "storage/channel/{$channel->id}/profile/{$channel->image}"; } if ($url != "") { $background = "style='background: url({$url}) center;'"; } $f = null; if (Session::getUID() != "") { $f = FollowerData::existFollowerChannel(Session::getUID(), $channel->id); } ?> <br> <div class='row'> <div class="col-md-12"> <h1 class='roboto'><?php echo $channel->title; ?> </h1> <p class="lead"><?php echo $channel->description; ?> </p>
protected static function formatImageDataAutoComplete(PDO $dbConnection, $dbFieldName, $inputDOMId) { $existingFieldValueList = ImageData::loadExistingFieldValues($dbConnection, $dbFieldName); self::generateAutoCompleteScript($existingFieldValueList, $inputDOMId); }
public function getImage() { return ImageData::getById($this->image_id); }
public function processRequest(User $user = NULL) { parent::displayHeader($user, 'Start Journey'); // TODO query for existing journeys // query for distinct image attributes $dbConnection = DbConnectionUtil::getDbConnection(); $distinctAttributeList = ImageAttribute::loadExistingValues($dbConnection); // randomly select attributes, foreach attribute, retrieve the id of a unique image, store in sourceImageList shuffle($distinctAttributeList); $sourceImageIdList = array(); for ($i = 0; $i < self::NUM_START_SELECTION_COUNT && count($distinctAttributeList) > 0; $i++) { $attribute = array_shift($distinctAttributeList); $imageIdList = ImageAttribute::loadImageIdListByAttribute($dbConnection, $attribute); shuffle($imageIdList); while (count($imageIdList) > 0) { $imageId = array_shift($imageIdList); if (!in_array($imageId, $sourceImageIdList)) { $sourceImageIdList[] = $imageId; break; } } } // if the full number of starting images could not be found with distinct attributes, then randomly select more to fill in the gap if (count($sourceImageIdList) < self::NUM_START_SELECTION_COUNT) { $allImageIdList = ImageData::loadAllImageIdList($dbConnection); shuffle($allImageIdList); while (count($sourceImageIdList) < self::NUM_START_SELECTION_COUNT && count($allImageIdList) > 0) { $imageId = array_shift($allImageIdList); if (!in_array($imageId, $sourceImageIdList)) { $sourceImageIdList[] = $imageId; } } } // load the randomly selected images $sourceImageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $sourceImageIdList); shuffle($sourceImageDataList); // reset the journey's session data if (isset($_SESSION['JOURNEY_IMAGE_LIST'])) { unset($_SESSION['JOURNEY_IMAGE_LIST']); } $_SESSION['JOURNEY_IMAGE_LIST'] = array(); if (isset($_SESSION['JOURNEY_ATTRIBUTE_MAP'])) { unset($_SESSION['JOURNEY_ATTRIBUTE_MAP']); } $_SESSION['JOURNEY_ATTRIBUTE_MAP'] = array(); ?> <p class="imageGridHeader">Choose Your Journey's Starting Image</p> <div class="centerWrapper"> <div class="imageGrid"> <?php foreach ($sourceImageDataList as $imageData) { $imageJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/JourneyStepView', array(JourneyStepView::GET_PARAM_NEXT_IMAGE_ID => $imageData->getId())); $imageThumbUrl = UrlFormatter::formatImageUrl($imageData->getThumbnailUri()); ?> <a href="<?php echo $imageJourneyUrl; ?> "> <img src="<?php echo $imageThumbUrl; ?> "></a> <?php } ?> </div> </div> <?php // TODO display a list of existing journeys parent::displayFooter(); }
$h = new HeartData(); $h->ref_id = $_POST["r"]; $h->user_id = $_SESSION["user_id"]; $h->type_id = $_POST["t"]; $h->add(); echo HeartData::countByRT($_POST["r"], $_POST["t"])->c; /////////// send notifications $user_id = null; $author_id = null; if ($_POST["t"] == 1) { $post = PostData::getReceptorId($_POST["r"]); $user_id = $post->receptor_ref_id; $author_id = $post->author_ref_id; } else { if ($_POST["t"] == 2) { $post = ImageData::getUserId($_POST["r"]); $user_id = $post->user_id; $author_id = $post->user_id; } } if ($author_id != $_SESSION["user_id"] && $user_id != $_SESSION["user_id"]) { // si es el mismo autor del post, entonces no le notificamos $notification = new NotificationData(); $notification->not_type_id = 1; // like $notification->type_id = $_POST["t"]; // al mismo que nos referenciamos en al crear el comentario $notification->ref_id = $_POST["r"]; // = $notification->receptor_id = $user_id; // en este caso nos referimos a quien va dirigida la notificacion
<div class='row'> <?php $channel_populars = ChannelData::getAll(); $image_populars = ImageData::getAll(); $im = null; $url = null; if ($image_populars != null) { $im = $image_populars[0]; $url = "storage/channel/{$im->channel_id}/" . $im->name; } // RecentWidget::renderChannels($channel_populars); ?> <div class="col-md-12"> <h2 class='roboto'>Recientes <small>Las mas nuevas</small></h2> <?php if ($url != null) { ?> <?php RecentWidget::renderImages($image_populars); } else { ?> <div class='hero-unit'> <h2 class='roboto'>No hay imagenes</h2> <p class='roboto'>No se ha cargado imagenes al sistema</p> </div> <?php } ?> </div>
foreach (['name', 'email', 'given_name', 'family_name', 'email_verified', 'gender'] as $field) { $builder->set($field, $user[$field]); } $builder->sign(new JWT\Signer\Rsa\Sha256(), $privateKey); $token = $builder->getToken(); return new Response($token, 200, ['Access-Control-Allow-Origin' => '*', 'Content-Type' => 'application/jwt']); }); $app->get('/images', function(Request $request) use($app, $images) { $image = $images->find()->sort(['date' => -1]); $images = []; while ($next = $image->getNext()) { $images[] = ImageData::fromDb($request, $next); } return new JsonResponse($images, 200, ['Access-Control-Allow-Origin' => '*']); }); $app->get('/files/{id}', function($id) use($app, $images, $gridfs) { $file = $gridfs->findOne(['_id' => new MongoId($id)]); if ($file === null) { throw new NotFoundHttpException('File not found'); } return new Response($file->getBytes(), 200, ['Content-type' => $file->file['contentType']]); });
/** * This function performs the processing of the user request. * @param User $user The requesting user. If the user is not null, then by convention * actions will assume the user is authenticated, otherwise not. * @throws Exception If an error was encountered while processing this request, an exception * will be thrown. * @return void */ public function processRequest(User $user = NULL) { // if an image id was specified, assuming editting an existing image, otherwise assume it's a new image $imageId = NULL; if (isset($_GET[EditImageView::GET_PARAM_IMAGE_ID])) { $imageId = $_GET[EditImageView::GET_PARAM_IMAGE_ID]; } $pageHeader = $imageId == NULL ? 'Add New Image' : 'Edit Image'; parent::displayHeader($user, $pageHeader); $editImageActionUrl = NULL; $getParamMap = NULL; $imageData = NULL; if ($imageId != NULL) { $getParamMap = array(); $getParamMap[EditImageAction::GET_PARAM_IMAGE_ID] = $imageId; $imageData = ImageData::loadImageDataById(DbConnectionUtil::getDbConnection(), $imageId); } $author = ''; $title = ''; $year = ''; $attributeList = NULL; $attributeListString = ""; $thumbnailUri = NULL; $contentUri = NULL; if ($imageData != NULL) { $contentUri = $imageData->getContentUri(); $thumbnailUri = $imageData->getThumbnailUri(); $title = $imageData->getTitle(); $year = $imageData->getYear(); $author = $imageData->getAuthor(); $attributeList = $imageData->getAttributeList(); foreach ($attributeList as $attribute) { $attributeListString .= "," . $attribute->getAttribute(); } } $editImageActionUrl = UrlFormatter::formatRoutingItemUrl('actions/EditImageAction', $getParamMap); $submitLabel = $imageId == NULL ? 'Create' : 'Save'; ?> <script type="text/javascript" > function replaceThumbnail( ) { $("#thumbnail_div").html( "<input type=\"file\" id=\"thumbnail_field\" name=\"<?php echo EditImageAction::POST_PARAM_THUMBNAIL; ?> \">" ); } function replaceFile( ) { $("#file_div").html( "<input type=\"file\" id=\"file_field\" name=\"<?php echo EditImageAction::POST_PARAM_FILE; ?> \">" ); } function cancel( ) { var previousPageUrl = "<?php echo $_SERVER['HTTP_REFERER']; ?> "; window.location.href = previousPageUrl; } function removeAttributeAtIndex( index ) { var rowList = $("#attribute_list_table tr"); for( i = 0; i < rowList.length; i++ ) { if ( i == index ) { var removedAttString = $( rowList[i] ).children( ).first( ).text( ); var attList = $( "#attribute_list").val( ).split( "," ); attList.splice( attList.indexOf( removedAttString ), 1 ); $( "#attribute_list").val( attList.join( ) ); $( rowList[i] ).remove( ); } } } function addAttribute( ) { var attributeValue = prompt( "Specify New Attribute" ); var attList = $( "#attribute_list").val( ).split( "," ); if ( attributeValue != null && attributeValue != "" && attList.indexOf( attributeValue ) == -1 ) { var newIndex = $( "#attribute_list_table tr" ).length; $( "#attribute_list_table" ).append( "<tr><td>" + attributeValue + "</td><td><a onclick=\"removeAttributeAtIndex( " + newIndex + " );\">Remove</a></td></tr>" ); attList.push( attributeValue ); $( "#attribute_list").val( attList.join( ) ); } } function validate( ) { var result = true; $("#errorSection").html("" ); <?php if ($imageData == NULL) { ?> var thumbnailVal = $("#thumbnail_field").val( ); if ( thumbnailVal == null || thumbnailVal == "" ) { $("#errorSection").append( "<span class=\"errorMessage\">Thumbnail Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#thumbnail_field_label").css( "color", " #EE3124" ); result = false; } var fileVal = $("#file_field").val( ); if ( fileVal == null || fileVal == "" ) { $("#errorSection").append( "<span class=\"errorMessage\">File Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#file_field_label").css( "color", " #EE3124" ); result = false; } <?php } ?> var authorVal = $("#author_field").val( ); if ( authorVal == null || authorVal == "" ) { $("#errorSection").append( "<span class=\"errorMessage\">Author Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#author_field_label").css( "color", " #EE3124" ); result = false; } var titleVal = $("#title_field").val( ); if ( titleVal == null || titleVal == "" ) { $("#errorSection").append( "<span class=\"errorMessage\">Title Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#title_field_label").css( "color", " #EE3124" ); result = false; } var yearVal = $("#year_field").val( ); if ( yearVal == null || yearVal == "" ) { $("#errorSection").append( "<span class=\"errorMessage\">Year Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#year_field_label").css( "color", " #EE3124" ); result = false; } return result; } </script> <form class="imageForm" method="POST" action="<?php echo $editImageActionUrl; ?> " enctype="multipart/form-data" onsubmit="return validate( )"> <div class="errorSection" id="errorSection"></div> <br/> <label id="author_field_label" for="author_field">Author</label> <br/> <input id="author_field" type="text" name="<?php echo EditImageAction::POST_PARAM_AUTHOR; ?> " value="<?php echo $author; ?> "/> <?php parent::formatImageDataAutoComplete(DbConnectionUtil::getDbConnection(), 'author', 'author_field'); ?> <br/> <label id="title_field_label" for="title_field">Title</label> <br/> <input id="title_field" type="text" name="<?php echo EditImageAction::POST_PARAM_TITLE; ?> " value="<?php echo $title; ?> "/> <br/> <label id="year_field_label" for="year_field">Year</label> <br/> <input id="year_field" name="<?php echo EditImageAction::POST_PARAM_YEAR; ?> " value="<?php echo $year; ?> "/> <br/><br/> <input id="attribute_list" type="hidden" name="<?php echo EditImageAction::POST_PARAM_ATTRIBUTE_LIST; ?> " value="<?php echo $attributeListString; ?> "/> <label for="attribute_table">Attributes</label> <table class="attribute_table" id="attribute_list_table"> <?php if ($attributeList != NULL) { for ($i = 0; $i < count($attributeList); $i++) { ?> <tr> <td><?php echo $attributeList[$i]->getAttribute(); ?> </td> <td><a onclick="removeAttributeAtIndex(<?php echo $i; ?> );">Remove</a> </tr> <?php } } ?> </table> <br/> <a class="button" onclick="addAttribute( );">Add Attribute</a> <br/><br/> <label id="thumbnail_field_label" for="thumbnail_field">Thumbnail</label> <br/> <div id="thumbnail_div"> <?php if ($thumbnailUri == NULL) { ?> <input type="file" id="thumbnail_field" name="<?php echo EditImageAction::POST_PARAM_THUMBNAIL; ?> "/> <?php } else { ?> <img src="<?php echo UrlFormatter::formatImageUrl($thumbnailUri); ?> "/> <br/> <input type="button" onclick="replaceThumbnail( )" value="Replace"/> <?php } ?> </div> <label id="file_field_label" for="file_field">File</label> <br/> <div id="file_div"> <?php if ($contentUri == NULL) { ?> <input type="file" id="file_field" name="<?php echo EditImageAction::POST_PARAM_FILE; ?> "/> <?php } else { ?> <img style="max-width: 100%" src="<?php echo UrlFormatter::formatImageUrl($contentUri); ?> "/> <br/> <input type="button" onclick="replaceFile( )" value="Replace"/> <br/> <?php } ?> </div> <input class="button" type="submit" value="<?php echo $submitLabel; ?> "/> <input class="button" type="button" onclick="cancel( )" value="Cancel"/> </form> <?php parent::displayFooter(); }
public function processRequest(User $user = NULL) { // if no journey exists, then redirect to the start journey page $startJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/StartJourneyView'); if (!isset($_SESSION['JOURNEY_IMAGE_LIST']) || empty($_SESSION['JOURNEY_IMAGE_LIST'])) { header("Location: {$startJourneyUrl}"); exit; } parent::displayHeader($user, 'Finish Journey'); //print( "JOURNEY IMAGE LIST: " ); print_r( $_SESSION['JOURNEY_IMAGE_LIST'] ); print( "<br/>" ); // load the image data for images encountered on the journey $dbConnection = DbConnectionUtil::getDbConnection(); $imageDataList = NULL; if (!empty($_SESSION['JOURNEY_IMAGE_LIST'])) { $imageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $_SESSION['JOURNEY_IMAGE_LIST']); } //print( "JOURNEY ATTRIBUTE MAP: " ); print_r( $_SESSION['JOURNEY_ATTRIBUTE_MAP'] ); print( "<br/>" ); // if possible, load image data for images with common attributes $commonImageDataList = NULL; $commonAttribute = NULL; //print( "<br/>att map: " ); print_r( $_SESSION['JOURNEY_ATTRIBUTE_MAP'] ); print("<br/>" ); if (isset($_SESSION['JOURNEY_ATTRIBUTE_MAP']) && !empty($_SESSION['JOURNEY_ATTRIBUTE_MAP'])) { // find the attribute with the maximum number of entries $maxAttribute = NULL; $maxAttributeCount = 0; foreach ($_SESSION['JOURNEY_ATTRIBUTE_MAP'] as $attribute => $count) { if ($maxAttribute == NULL || $maxAttributeCount < $count) { $maxAttribute = $attribute; $maxAttributeCount = $count; } } $commonAttribute = $maxAttribute; // find images with common attributes $tempCommonImageIdList = ImageAttribute::loadCommonAttributeImageIdList($dbConnection, $commonAttribute, $_SESSION['JOURNEY_IMAGE_LIST']); $commonImageIdList = array(); foreach ($tempCommonImageIdList as $imageId) { if (!in_array($imageId, $_SESSION['JOURNEY_IMAGE_LIST'])) { $commonImageIdList[] = $imageId; } } if (!empty($commonImageIdList)) { $commonImageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $commonImageIdList); } } // display the journey in an image grid ?> <p class="imageGridHeader">Your Journey Through Art</p> <div class="centerWrapper"> <div class="imageGrid"> <?php foreach ($imageDataList as $imageData) { $this->displayImageDetailLink($imageData); } ?> </div> </div> <?php if ($commonImageDataList != NULL) { ?> <p class="imageGridHeader">Suggested Art</p> <div class="centerWrapper"> <p>Based upon your choices here is a selection of other art pieces to examine</p> <div class="imageGrid"> <?php foreach ($commonImageDataList as $imageData) { $this->displayImageDetailLink($imageData); } ?> </div> </div> <?php } $saveJourneyUrl = UrlFormatter::formatRoutingItemUrl('actions/SaveJourneyAction'); ?> <script type="text/javascript"> function validate( ) { var result = true; $("#errorSection").html(""); var nameVal = $("#journey_name_field").val( ); if( nameVal == null || nameVal == "" ) { $("#errorSection").append( "<span clas=\"errorMessage\">Journey Name Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#journey_name_field_label").css( "color", "#EE3124" ); result = false; } var commentsVal = $("#journey_comments_field").val( ); if( commentsVal == null || commentsVal == "" ) { $("#errorSection").append( "<span clas=\"errorMessage\">Comments Required</span><br/>" ); $("#errorSection").css( "display", "inline-block"); $("#journey_comments_field_label").css( "color", "#EE3124" ); result = false; } return result; } </script> <p class="imageGridHeader">Journey Feedback</p> <p style="width:50%"> You are now encouraged to take a moment to reflect on your journey through art. Consider the feelings which were illicited during the experience. Also think about how each piece might have had an affect on your perception of subsequent pieces. Please share your thoughts in the comments field. </p> <form class="imageForm" method="POST" action="<?php echo $saveJourneyUrl; ?> " onsubmit="return validate( )"> <div class="errorSection" id="errorSection"></div> <br/> <label id="journey_name_field_label" for="journey_name_field">Journey Name</label> <br/> <input id="journey_name_field" type="text" name="<?php echo SaveJourneyAction::POST_PARAM_JOURNEY_NAME; ?> "/> <br/> <label id="journey_comments_field_label" for="journey_comments_field">Comments</label> <br/> <textarea id="journey_comments_field" rows="10" cols="100" name="<?php echo SaveJourneyAction::POST_PARAM_JOURNEY_COMMENTS; ?> " value=""></textarea> <br/> <input class="button" type="submit" value="Save"/> </form> <?php parent::displayFooter(); }
public static function loadImageDataListByIdSet(PDO $dbConnection, array $imageIdSet) { // TODO filter image id set to protect against SQL injection $dbQueryString = 'SELECT * FROM image_data WHERE id IN ('; $imageIdSetSize = count($imageIdSet); for ($i = 0; $i < $imageIdSetSize; $i++) { $dbQueryString .= $imageIdSet[$i]; if ($i < $imageIdSetSize - 1) { $dbQueryString .= ','; } } $dbQueryString .= ')'; $preparedStatement = $dbConnection->prepare($dbQueryString); $preparedStatement->execute(); $imageDataResultList = array(); $resultRow = NULL; while ($resultRow = $preparedStatement->fetch(PDO::FETCH_ASSOC)) { $imageDataResultList[] = ImageData::populateImageDataByDbResultRow($resultRow, $dbConnection); } $preparedStatement = NULL; return $imageDataResultList; }