/** * DOCUMENT ME * @return mixed */ public function getSearchText() { // Convert from HTML to plaintext before indexing by Lucene // However first add line breaks after certain tags for better formatting // (this method is also used for generating informational diffs between versions). // This is a noncritical feature so it doesn't have to be as precise // as strip_tags and shouldn't try to substitute for it in the matter of // actually removing the tags $value = preg_replace("/(<p>|<br.*?>|<blockquote>|<li>|<dt>|<dd>|<nl>|<ol>)/i", "\$1\n", $this->value); return aHtml::toPlaintext($value); }
public function executeIcalFeed(sfWebRequest $request) { $this->buildParams(); $this->dateRange = ''; $this->aEvent = $this->getRoute()->getObject(); $this->categories = aCategoryTable::getCategoriesForPage($this->page); $this->forward404Unless($this->aEvent); $this->forward404Unless($this->aEvent['status'] == 'published' || $this->getUser()->isAuthenticated()); aBlogItemTable::populatePages(array($this->aEvent)); header("Content-type: text/calendar"); header('Content-disposition: attachment; filename=' . str_replace('.', '-', $this->getRequest()->getHost() . '-' . $this->aEvent->id) . '.ics'); $start = $this->aEvent->getVcalStartDateTime(); $end = $this->aEvent->getVcalEndDateTime(); $title = aString::toVcal(aHtml::toPlaintext($this->aEvent->getTitle())); $body = aString::toVcal(aHtml::toPlaintext($this->aEvent->Page->getAreaText('blog-body'))); echo <<<EOM BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT CATEGORIES:MEETING DTSTART:{$start} DTEND:{$end} SUMMARY:{$title} DESCRIPTION:{$body} CLASS:PRIVATE END:VEVENT END:VCALENDAR EOM; exit(0); }
<?php // Google says they accept HTML in descriptions but they seem not to use it for anything. // You never see descriptions anyway except when editing them. So send the plaintext. // The byte limit was chosen to avoid creating a URL that the browser won't accept, // even when Google double-encodes it in some situations $aEvent = $sf_data->getRaw('aEvent'); echo a_button(a_('Add to Google Calendar'), url_for('http://www.google.com/calendar/event?' . http_build_query(array('action' => 'TEMPLATE', 'text' => $aEvent->getTitle(), 'dates' => $aEvent->getUTCDateRange(), 'location' => preg_replace('/\\s+/', ' ', $aEvent['location']), 'sprop' => 'website:' . $sf_request->getHost(), 'details' => aHtml::toPlaintext($aEvent->getTextForArea('blog-body', 500, array('characters' => true, 'append_ellipsis' => a_('...'))))))), array('icon', 'no-bg', 'alt', 'a-events'));