t('Transform an RSS feed'), 'description' => t('Grab a remote RSS feed and transform it into HTML.'), 'page callback' => 'querypath_examples_show_rss', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/sticky'] = array( 'title' => t('Show sticky nodes'), 'description' => t('Grab a list of sticky nodes and display it.'), 'page callback' => 'querypath_examples_show_sticky_nodes', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/twitter'] = array( 'title' => t('Show Twitters'), 'description' => t('Show public timeline from Twitter3.'), 'page callback' => 'querypath_examples_show_twitter', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/musicbrainz'] = array( 'title' => t('Show MusicBrainz data'), 'description' => t('Query the MusicBrainz library.'), 'page callback' => 'querypath_examples_show_musicbrainz', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/sparql'] = array( 'title' => t('Run SPARQL query'), 'description' => t('Query a SPARQL endpoint and display the results.'), 'page callback' => 'querypath_examples_show_sparql', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/ld'] = array( 'title' => t('Related References'), 'description' => t('View linked data for a particular path.'), 'page callback' => 'querypath_examples_show_ld', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); $items['qp/multiplerss'] = array( 'title' => t('Show Multiple RSS Feeds'), 'description' => t('Show multiple RSS feeds.'), 'page callback' => 'querypath_examples_show_multiplerss', 'page arguments' => array(), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('access content'), ); return $items; } /** * Display the titles of each item in the RSS feed. */ function querypath_examples_show_rss() { $out = '

' . t('Items in the RSS Feed') . '

'; $out .= '

' . t('Display a linked title to each item in the RSS feed') . '

'; $out .= '

' . t('Behind the scenes, this is fetching the RSS feed over HTTP, parsing it, and then creating a list of linked items.') . '

'; $url = url('rss.xml', array('absolute' => TRUE)); foreach (qp($url, 'item') as $item) { $title = $item->find('title')->text(); $link = $item->next('link')->text(); $out .= '

' . l($title, $link) . '

'; } $code = ' TRUE)); foreach (qp($url, \'item\') as $item) { $title = $item->find(\'title\')->text(); $link = $item->next(\'link\')->text(); $out .= \'

\' . l($title, $link) . \'

\'; } ?>'; $out .= '

' . t('The Code:') . '

'; $out .= highlight_string($code, TRUE); $out .= '

' . t('References:') . '

'; $out .= l('The QueryPath API', 'http://querypath.org'); return $out; } function querypath_examples_show_sticky_nodes() { $out = '

' . t('List of nodes marked sticky') . '

'; $out .= '

' . t('Display a list of sticky nodes. This combines a database query with some basic HTML generation.') . '

'; $sql = 'SELECT title FROM {node} WHERE sticky = 1'; $ul = qp('') ->query($sql) ->withEachRow() ->appendColumn('title', '
  • ') ->top() ->html(); $code = '\') ->query($sql) ->withEachRow() ->appendColumn(\'title\', \'
  • \') ->top() ->html(); ?>'; $out .= $ul; $out .= '

    ' . t('The Code:') . '

    '; $out .= highlight_string($code, TRUE); $out .= '

    ' . t('References:') . '

    '; $out .= l('The QueryPath API', 'http://querypath.org'); return $out; } function querypath_examples_show_twitter() { $out = '

    ' . t('Fetch and display the public twitter feed.') . '

    '; $out .= '

    ' . t('Display the most recent entries on the Twitter public timeline.') . '

    '; try { $ul = qp('