function LoadFromArray($items, $link_template) { foreach ($items as $item) { $date = new JaxpDate(JAXP_DATE_FROM_TIMESTAMP, $item["date"]); $link = str_replace("%DOMAIN%", $this->PlatformSettings->BaseUrl, $link); $link = str_replace("%YEAR%", $date->Year, $link); $link = str_replace("%MONTH%", $date->Month, $link); $link = str_replace("%DAY%", $date->Day, $link); $link = str_replace("%TITLE%", ToJaxpString($item["title"])->ToFriendlyUrlText(), $link); $link = str_replace("%ID%", $item["id"], $link); $this->Channel->AddItem(new JaxpRssFeedItem($date->ToFormattedString("d/m/Y H:i") . " - " . $item["title"], $item["description"], $link, $date)); } }
/** * 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]; }