/** * Default view helper. * @param string $section_name */ protected static function beginSection($section_name) { self::$__last_section_name__ = $section_name; ob_start(); }
/** * Renders an RSS feed from an array of data. Note that this is not an all in one cure all solution for RSS, it is merely a way to quickly create an RSS feed that fits most basic uses. $feed should contain the following keys: * * - string "title" * - string "link" * - timestamp "date" * - optional string "description" * - optional string "language" * - array "items" * * Each item in "items" should contain: * * - string "title" * - string "link" * - optional string "description" * - optional timestamp "date" * - optional string "guid" * * @param string $feed Array of RSS data. * @param boolean $print Defaults to true. Print the feed complete with the appropriate header. * @return string RSS feed, or null if $print is true. */ protected static final function renderRSS($feed, $print = true) { $tab = chr(9); $nl = chr(10); if (!isset($feed['description'])) { $feed['description'] = ''; } $output = '<?xml version="1.0" encoding="UTF-8"?>' . $nl; $output .= '<rss version="2.0">' . $nl . $tab . '<channel>' . $nl . $tab . $tab . PicoraView::tag('title', $feed['title']) . $nl . $tab . $tab . PicoraView::tag('link', $feed['link']) . $nl . $tab . $tab . PicoraView::tag('lastBuildDate', gmdate(DATE_RFC822, $feed['date'])) . $nl . $tab . $tab . PicoraView::tag('description', $feed['description']) . $nl . (isset($feed['language']) ? $tab . $tab . PicoraView::tag('language', $feed['language']) . $nl : ''); foreach ($feed['items'] as $item) { if (!isset($item['guid'])) { $item['guid'] = md5($item['title'] . $item['link']); } $output .= $tab . '<item>' . $nl . $tab . $tab . $tab . PicoraView::tag('title', $item['title']) . $nl . $tab . $tab . $tab . PicoraView::tag('link', $item['link']) . $nl . (isset($item['description']) ? $tab . $tab . $tab . PicoraView::tag('description', '<![CDATA[' . $item['description'] . ']]>') . $nl : '') . (isset($item['date']) ? $tab . $tab . $tab . PicoraView::tag('pubDate', gmdate(DATE_RFC822, $item['date'])) . $nl : '') . $tab . $tab . $tab . '<guid isPermaLink="false">' . $item['guid'] . '</guid>' . $nl . $tab . $tab . '</item>' . $nl; } $output .= $tab . '</channel>' . $nl . '</rss>'; if ($print) { header('Content-type: application/rss+xml'); print $output; } else { return $output; } }
public function display() { foreach (PicoraEvent::getObserverList('PicoraInput.beforeDisplay') as $callback) { call_user_func($callback, $this); } $output = ''; switch ($this->params['type']) { case 'text': case 'hidden': case 'button': case 'file': case 'image': case 'password': case 'reset': case 'submit': $output = PicoraView::tag('input', array_merge($this->params, array('value' => htmlspecialchars($this->params['value'], ENT_COMPAT, 'utf-8')))); break; case 'textarea': $output = '<textarea' . self::htmlAttributes($this->params, array('type', 'value')) . '>' . htmlspecialchars($this->params['value'], ENT_COMPAT, 'utf-8') . '</textarea>'; break; case 'radio': $output = '<input type="radio"' . self::htmlAttributes($this->params, array('checked', 'type')) . (isset($this->params['checked']) && ($this->params['checked'] == true || $this->params['checked'] == 1 || $this->params['checked'] == 'true') ? ' checked="checked"' : '') . '/>'; break; case 'checkbox': $output = '<input type="hidden" name="' . $this->params['name'] . '" value="0"/><input type="checkbox" value="1"' . self::htmlAttributes($this->params, array('checked', 'value')) . (isset($this->params['checked']) && ($this->params['checked'] == true || $this->params['checked'] == 1 || $this->params['checked'] == 'true') ? ' checked="checked"' : '') . '/>'; break; case 'select': $output = '<select'; $output .= self::htmlAttributes($this->params, array('options', 'selected', 'value')) . '>'; if (isset($this->params['options']) && is_array($this->params['options'])) { foreach ($this->params['options'] as $value => $name) { $outut .= '<option value="' . htmlspecialchars($value, ENT_COMPAT, 'utf-8') . '"'; if (isset($this->params['selected']) && (is_array($this->params['selected']) && in_array($value, $this->params['selected']) || !is_array($this->params['selected']) && $this->params['selected'] == $value)) { $output .= ' selected="selected"'; } $output .= '>' . htmlspecialchars($name, ENT_COMPAT, 'utf-8') . '</option>'; } } $output .= '</select>'; break; } foreach (PicoraEvent::getObserverList('PicoraInput.afterDisplay') as $callback) { call_user_func($callback, $outut); } return $output; }