Ejemplo n.º 1
0
 /**
  * Cleans up text for special output.
  *
  * Namely for use inside 'title' attributes. Strips HTML, removes double-quotes (since 
  * that's what this demo uses for attributes), reduces all linebreaks and multiple 
  * spaces into a single space, and can shorten a string to a number of characters.
  *
  * @access public
  * @param string $s The string of text to clean up.
  * @param integer $length The number of characters to return in the description.
  * @return string The cleaned up string.
  */
 function cleanup($s, $length = 0)
 {
     // Convert all HTML entities to their character counterparts.
     $s = html_entity_decode($s, ENT_QUOTES, 'UTF-8');
     // Strip out HTML tags.
     $s = strip_tags($s);
     // Get rid of double quotes so they don't interfere with the title tag.
     $s = str_replace('"', '', $s);
     // Strip out superfluous whitespace and line breaks.
     $s = preg_replace('/(\\s+)/', ' ', $s);
     // Shorten the string to the number of characters requested (multibyte safe), and strip wrapping whitespace.
     if ($length > 0 && strlen($s) > $length) {
         $s = trim(newsblocks::substr($s, 0, $length, 'UTF-8')) . '…';
     }
     // Return the value.
     return $s;
 }
Ejemplo n.º 2
0
				<div class="container thirds">
					<div class="section">
						<?php 
echo newsblocks::listing('http://blog.japan.cnet.com/lessig/index.rdf');
?>
					</div>

					<div class="section">
						<?php 
echo newsblocks::listing('http://newsrss.bbc.co.uk/rss/russian/news/rss.xml');
?>
					</div>

					<div class="section">
						<?php 
echo newsblocks::listing('http://hagada.org.il/hagada/html/backend.php', array('direction' => 'rtl'));
?>
					</div>
				</div>

			</div>

			<div id="footer">
				<p>NewsBlocks Demo 2.0 by <a href="http://ryanparman.com">Ryan Parman</a>. Made possible by <a href="http://mootools.net/">MooTools</a>, <a href="http://simplepie.org">SimplePie</a>, and a sponsorship from <a href="http://level5studio.com">Level 5 Studio</a>.</p>
			</div>

		</div>

		<script src="./scripts/newsblocks.js" type="text/javascript" charset="utf-8"></script>

	</body>