/** * Look up all media belonging to this gallery and organize it * into the pertinent object collections. * * @uses JaxpMySqlHandler * @uses JaxpMySqlConditions * @uses JaxpJournalMediaPhoto * @uses JaxpJournalMediaVideo * @uses JaxpJournalMediaAudio * * @param string $source_table_name Table which contains media data. * * @access public * @return void * @since 1.0 */ function LoadMedia($source_table_name) { # Shortcut to the database object. $db = $this->MySqlHandler->Database; # Instantiate the Media table. $journal_media = $db->LoadTable($source_table_name); # Create a filter to locate media that belongs to this gallery. # The filter uses the gallery id as a relation key. $media_match = new JaxpMySqlConditions(); $media_match->AddCondition($journal_media->Columns["gallery_id"], $this->ElementId, JAXP_MYSQL_MATCH_EQUAL); # Execute the filter. $gallery_media = $this->MySqlHandler->Filter($journal_media, $media_match); # If there are any media contents found... if (count($gallery_media->Rows)) { # ...iterate through them... foreach ($gallery_media->Rows as $r) { # ...get current media's id... $rId = $r->Columns["id"]->Value; # ...determine the media type... switch ($r->Columns["media_type"]->Value) { # Is it a photo? case JAXP_MEDIA_TYPE_PHOTO: # Add it to the Photo collection. $this->Photo[$rId] = new JaxpMediaPhoto($rId, $r->Columns["title"]->Value, $r->Columns["description"]->Value, $r->Columns["source_file_name"]->Value, $this->ElementId); break; # Is it a video? # Is it a video? case JAXP_MEDIA_TYPE_VIDEO: # Add it to the Video collection. $this->Video[$rId] = new JaxpMediaVideo($rId, $r->Columns["title"]->Value, $r->Columns["description"]->Value, $r->Columns["source_file_name"]->Value, $this->ElementId); break; # Is it audio? # Is it audio? case JAXP_MEDIA_TYPE_AUDIO: # Add it to the Audio collection. $this->Audio[$rId] = new JaxpMediaAudio($rId, $r->Columns["title"]->Value, $r->Columns["description"]->Value, $r->Columns["source_file_name"]->Value, $this->ElementId); break; } } } }
/** * Locates a note using permalink data. * * @uses JaxpDate * @uses JaxpMySqlHandler * @uses JaxpMySqlConditions * * @access public * @return JaxpJournalNote An object representing the note. * @since 1.2.1 */ function GetNoteFromPermalink() { # Parse the URL address and take the last two parts # (i.e. from "/uri/a/b/c/", take 'b' and 'c', unslashed. list($date, $title) = array_slice(explode("/", $_SERVER["REQUEST_URI"]), 2, 2); # Convert date string to an usable object. $datePosted = new JaxpDate(JAXP_DATE_FROM_STRING, $date); # Reformat the title passed by GET. # Punctuation characters mutate to wildcards for LIKE-comparison. $title = str_replace("-", " ", $title); $title = str_replace("_", "%", $title); # Instantiate the Notes table. $journal_notes = $this->MySqlHandler->Database->Tables["journal_notes"]; # Create a dual-condition filter, to locate by title and by date. $filter = new JaxpMySqlConditions(); $filter->AddCondition($journal_notes->Columns["title"], $title, JAXP_MYSQL_MATCH_CONTAINS); $filter->AddCondition($journal_notes->Columns["date_posted"], $datePosted->ToTimestamp(), JAXP_MYSQL_MATCH_GREATER_OR_EQUAL_THAN); # Apply the filter. $note = $this->MySqlHandler->Select("SELECT * FROM journal_notes WHERE " . $filter->ParseToStringList()); # Since the filter ensures only one entry will be retrieved, # return the first element of the resulting array. return $this->Notes[$note->Rows[0]->Columns["id"]->Value]; }