Example #1
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $data['track'] = $data['title'];
     $data['title'] = $data['description'];
     return $data;
 }
Example #2
0
 function yield_many($row, $url, $key)
 {
     $events = array();
     $string = '<a href="' . $this->get_public_url() . '">' . $this->get_option('username') . '</a> ';
     $description = $this->lifestream->html_entity_decode($row->get_description());
     if (lifestream_str_startswith(strtolower($description), strtolower($string))) {
         $description = substr($description, strlen($string));
     }
     if (lifestream_str_startswith(strtolower($description), 'unlocked')) {
         preg_match_all($this->achievement_regexp, str_replace('</li>', "</li>\n", $description), $matches, PREG_SET_ORDER);
         foreach ($matches as $match) {
             $data = parent::yield($row, $url, $key);
             $data['title'] = $match[1] . ' in ' . $match[3];
             $data['link'] = $match[2];
             $data['key'] = 'achievement';
             unset($data['description']);
             $events[] = $data;
         }
     } elseif (preg_match($this->status_regexp, $description, $match)) {
         $data = parent::yield($row, $url, $key);
         $data['title'] = $match[1];
         $data['link'] = $this->get_public_url();
         $data['key'] = 'status';
         unset($data['description']);
         $events[] = $data;
     } elseif (preg_match($this->played_regexp, $description, $match) || preg_match($this->played_alt_regexp, $description, $match)) {
         $data = parent::yield($row, $url, $key);
         $data['title'] = $match[2];
         $data['link'] = $match[1];
         $data['key'] = 'played';
         unset($data['description']);
         $events[] = $data;
     }
     return $events;
 }
Example #3
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $title = $this->lifestream->html_entity_decode($row->get_title());
     if (lifestream_str_startswith($title, 'Comment on: ')) {
         if (!$this->get_option('show_comments')) {
             return;
         }
         $key = 'comment';
         $title = substr($title, 12);
     } elseif (lifestream_str_startswith($title, 'Submitted: ')) {
         if (!$this->get_option('show_submissions')) {
             return;
         }
         $key = 'submit';
         $title = substr($title, 11);
     } elseif (lifestream_str_startswith($title, 'Favorite: ')) {
         if (!$this->get_option('show_favorites')) {
             return;
         }
         $key = 'favorite';
         $title = substr($title, 10);
     } else {
         return;
     }
     $data['title'] = $title;
     $data['key'] = $key;
     return $data;
 }
Example #4
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $author = $row->get_author();
     $data['author'] = $this->clear_name($author->get_name());
     return $data;
 }
Example #5
0
 function yield($row, $url, $key)
 {
     $TAXONOMY_NS = 'http://purl.org/rss/1.0/modules/taxonomy/';
     $RDF_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
     // <taxo:topics>
     //       <rdf:Bag>
     //       	<rdf:li rdf:resource="http://pinboard.in/u:zeeg/t:mysql"/>
     // 	<rdf:li rdf:resource="http://pinboard.in/u:zeeg/t:optimization"/>
     //
     // 	<rdf:li rdf:resource="http://pinboard.in/u:zeeg/t:performance"/>
     //         </rdf:Bag>
     //       </taxo:topics>
     $data = parent::yield($row, $url, $key);
     $topics =& $row->get_item_tags($TAXONOMY_NS, 'topics');
     $topics = $topics[0]['child'][$RDF_NS]['Bag'][0]['child'][$RDF_NS]['li'];
     $tags = array();
     foreach ($topics as $t) {
         $t = $t['attribs'][$RDF_NS]['resource'];
         if (!empty($t)) {
             $tags[] = $row->sanitize(substr(strstr($t, '/t:'), 3), SIMPLEPIE_CONSTRUCT_TEXT);
         }
     }
     $data['tags'] = $tags;
     return $data;
 }
Example #6
0
 function yield($row, $url, $key)
 {
     if (lifestream_str_endswith($row->get_title(), 'QuickMix')) {
         return false;
     }
     return parent::yield($row, $url, $key);
 }
 function yield($row, $url, $key)
 {
     //<gr:annotation><content type="html">Just testing some stuff in Lifestream</content>
     $data = parent::yield($row, $url, $key);
     $annotation =& $row->get_item_tags(self::NS, 'annotation');
     $data['comment'] = $this->lifestream->html_entity_decode($annotation[0]['child']['http://www.w3.org/2005/Atom']['content'][0]['data']);
     return $data;
 }
Example #8
0
 function render_item($row, $item)
 {
     if ($row->key == 'message') {
         return $this->parse_urls(htmlspecialchars($item['title'])) . ' [' . $this->lifestream->get_anchor_html(htmlspecialchars($this->get_option('username')), $item['link']) . ']';
     } else {
         return parent::render_item($row, $item);
     }
 }
Example #9
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $subject =& $row->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject');
     $tags = explode(' ', $row->sanitize($subject[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
     $data['tags'] = $tags;
     return $data;
 }
 function yield($row, $url, $key)
 {
     //<gr:annotation><content type="html">Just testing some stuff in Lifestream</content>
     $data = parent::yield($row, $url, $key);
     $annotation =& $row->get_item_tags(self::NS, 'annotation');
     $data['comment'] = $this->lifestream->html_entity_decode($annotation[0]['child']['http://www.w3.org/2005/Atom']['content'][0]['data']);
     $data['date'] = $row->data['attribs']['http://www.google.com/schemas/reader/atom/']['crawl-timestamp-msec'] / 1000;
     return $data;
 }
Example #11
0
 function save_options()
 {
     if (preg_match('/\\/userid=([0-9]+)\\//i', $this->get_option('url'), $match)) {
         $this->update_option('user_id', $match[1]);
     } else {
         throw new Lifestream_Error("Invalid feed URL.");
     }
     parent::save_options();
 }
Example #12
0
 function render_item($event, $item)
 {
     if ($event->key == 'image') {
         return Lifestream_PhotoFeed::render_item($event, $item);
     } elseif ($event->key == 'note') {
         return Lifestream_TumblrFeed::parse_users($this->parse_urls(htmlspecialchars($item['title']))) . ' [' . $this->lifestream->get_anchor_html($this->get_option('username') . htmlspecialchars($item['link'])) . ']';
     } else {
         return parent::render_item($event, $item);
     }
 }
Example #13
0
 function yield($row, $url, $key)
 {
     //I don't know what this is for, would not fetch when running
     //if (!lifestream_str_startswith($row->get_link(), 'http://'.$this->get_option('username').'.jaiku.com/presence/')) return;
     $data = parent::yield($row, $url, $key);
     //preg_match('|<p>([^<]+)</p>|i', $row->get_title(), $matches);
     //$data['title'] = $matches[1];
     $data['title'] = $row->get_title();
     return $data;
 }
Example #14
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     if ($data['title'] == 'Your Queue is empty.') {
         return;
     }
     if ($key == 'queue') {
         $data['title'] = substr($data['title'], 5);
     }
     return $data;
 }
Example #15
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     // Comments have URL fragment identifiers while posts do not
     if ($this->get_option('hide_comments') && strpos($data['guid'], '#') !== false) {
         return false;
     }
     $data['title'] = $this->lifestream->html_entity_decode($row->get_title());
     $data['description'] = $row->get_description();
     return $data;
 }
Example #16
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $title = $row->get_title();
     $on_part = ' on Yelp.com';
     if (substr($title, strlen($title) - strlen($on_part)) == $on_part) {
         $title = substr($title, 0, strlen($title) - strlen($on_part));
     }
     $data['title'] = $title;
     return $data;
 }
Example #17
0
 function yield($row, $url, $key)
 {
     if ($row->data['child']['http://www.w3.org/2005/Atom']['title']['data']) {
         return null;
     } else {
         $data = parent::yield($row, $url, $key);
         // echo '<pre>'; print_r($row->data['child']['http://www.w3.org/2005/Atom']); die;
         $data['title'] = $row->data['child']['http://www.w3.org/2005/Atom']['title'][0]['data'];
         $data['description'] = $row->data['child']['http://www.w3.org/2005/Atom']['id'][0]['data'];
         // echo '<pre>'; print_r($data); die;
         return $data;
     }
 }
Example #18
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $string = $this->get_option('username') . ': ';
     $description = $this->lifestream->html_entity_decode($row->get_description());
     if (lifestream_str_startswith(strtolower($description), strtolower($string))) {
         $description = substr($description, strlen($string));
     }
     if ($this->get_option('hide_replies') && lifestream_str_startswith($description, '@')) {
         return false;
     }
     $data['description'] = $description;
     return $data;
 }
Example #19
0
function lifestream_opml_feed()
{
    /**
     * Outputs an OPML feed which can be used to backup your lifestream settings.
     * @todo
     */
    global $wpdb, $lifestream;
    $date = $lifestream->date_format(DATE_RFC822);
    $lines = array('<?xml version="1.0" encoding="UTF-8"?>');
    $lines[] = '<!-- OPML generated by Lifestream ' . LIFESTREAM_VERSION . ' on ' . $date . ' -->';
    $lines[] = '<opml version="1.1">';
    $lines[] = '	<head>';
    $lines[] = '		<title>lifestream.feeds</title>';
    $lines[] = '		<dateCreated>' . $date . '</dateCreated>';
    $lines[] = '		<dateModified>' . $date . '</dateModified>';
    $lines[] = '	</head>';
    $lines[] = '	<body>';
    $list_of_feeds = array();
    foreach ($lifestream->feeds as $key => $class) {
        if (method_exists($class, 'get_url')) {
            $list_of_feeds[] = $key;
        }
    }
    if (count($list_of_feeds)) {
        $results =& $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "lifestream_feeds` WHERE `feed` IN ('" . implode("', '", $list_of_feeds) . "')");
        foreach ($results as $result) {
            $instance = Lifestream_Feed::construct_from_query_result($lifestream, $result);
            if (method_exists($instance, 'get_url')) {
                $urls = $instance->get_url();
                if (!is_array($urls)) {
                    $urls = array($urls);
                }
                $items = array();
                foreach ($urls as $url_data) {
                    if (is_array($url_data)) {
                        // url, key
                        list($url, $key) = $url_data;
                    } else {
                        $url = $url_data;
                        $key = '';
                    }
                    $lines[] = '		<outline text="' . htmlspecialchars($instance->get_feed_display()) . '" xmlUrl="' . $url . '" type="' . $instance->get_constant('ID') . '"/>';
                }
            }
        }
    }
    $lines[] = '	</body>';
    $lines[] = '</opml>';
    echo implode("\n", $lines);
}
Example #20
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $filters = explode(",", $this->get_option('filter'));
     foreach ($filters as $filter) {
         if (strtolower($filter) == strtolower(strip_tags($row->get_title()))) {
             return false;
             exit;
         }
     }
     $description = strip_tags(str_replace('<p><a href="http://www.backtype.com/' . strtolower($this->get_option('username')) . '">Read more comments by ' . strtolower($this->get_option('username')) . '</a></p>', '', $this->lifestream->html_entity_decode($row->get_description())));
     $data['description'] = $description;
     return $data;
 }
Example #21
0
 function yield($row, $url, $key)
 {
     if (strpos($row->get_id(), "PushEvent") === false) {
         return null;
     } else {
         $data = parent::yield($row, $url, $key);
         $description = $this->lifestream->html_entity_decode($row->get_description());
         $message = $this->parse_message($description);
         $data['title'] = $message;
         $repo = $this->parse_repo($row->get_title());
         $data['branch'] = $repo[0];
         $data['repository'] = $repo[1];
         $data['group_key'] = $data['repository'];
         return $data;
     }
 }
Example #22
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $title = $row->get_title();
     $chunk = sprintf('%s on', $this->get_option('username'));
     if (lifestream_str_startswith($title, $chunk)) {
         $title = substr($title, strlen($chunk));
     }
     $data['title'] = $this->lifestream->html_entity_decode($title);
     $data['description'] = $this->lifestream->html_entity_decode($row->get_description());
     // Submissions are automatically liked, so we'll omit the redundant "liked" entry for posts submitted by the owner
     if ($key == 'liked' && $this->parse_post_author($data['description']) == $this->get_option('username')) {
         return null;
     } else {
         return $data;
     }
 }
Example #23
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     /*
      * Removing the "Posted by" mention
      */
     $data['description'] = preg_replace('#<p><strong>Posted by.+</p>#sU', '', $data['description']);
     /*
      * Extracting tags
      */
     preg_match_all('#http://(www.)?diigo.com/user/[^\\/]+/([^"\' ]+)#', $data['description'], $matches);
     if (isset($matches[2]) && !empty($matches[2])) {
         $data['tags'] = array_map(array($row, 'sanitize'), $matches[2], array(SIMPLEPIE_CONSTRUCT_TEXT));
         $data['description'] = preg_replace('#<p><strong>Tags:</strong>.+$#sU', '', $data['description']);
     }
     return $data;
 }
Example #24
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     $type = $row->get_item_tags(self::NS_BRIGHTKITE, 'eventType');
     $type = $type[0]['data'];
     $placelink = $row->get_item_tags(self::NS_BRIGHTKITE, 'placeLink');
     $data['placelink'] = $placelink[0]['data'];
     $placename = $row->get_item_tags(self::NS_BRIGHTKITE, 'placeName');
     $data['placename'] = $placename[0]['data'];
     $placeaddress = $row->get_item_tags(self::NS_BRIGHTKITE, 'placeAddress');
     $data['placeaddress'] = $placeaddress[0]['data'];
     if ($enclosure = $row->get_enclosure()) {
         $data['thumbnail'] = $enclosure->get_thumbnail();
         $data['image'] = $enclosure->get_medium();
     }
     return $data;
 }
Example #25
0
function lifestream_widget_control($widget_args = 1)
{
    global $wp_registered_widgets, $wpdb, $lifestream;
    // Whether or not we have already updated the data after a POST submit
    static $updated = false;
    if (is_numeric($widget_args)) {
        $widget_args = array('number' => $widget_args);
    }
    $widget_args = wp_parse_args($widget_args, array('number' => -1));
    extract($widget_args, EXTR_SKIP);
    // Data should be stored as array:  array( number => data for that instance of the widget, ... )
    $options = (array) $lifestream->get_option('widget');
    // We need to update the data
    if (!$updated && !empty($_POST['sidebar'])) {
        // Tells us what sidebar to put the data in
        $sidebar = (string) $_POST['sidebar'];
        $sidebars_widgets = wp_get_sidebars_widgets();
        if (isset($sidebars_widgets[$sidebar])) {
            $this_sidebar =& $sidebars_widgets[$sidebar];
        } else {
            $this_sidebar = array();
        }
        foreach ($this_sidebar as $_widget_id) {
            // Remove all widgets of this type from the sidebar.  We'll add the new data in a second.  This makes sure we don't get any duplicate data
            // since widget ids aren't necessarily persistent across multiple updates
            if ('lifestream_widget' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number'])) {
                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
                if (!in_array("lifestream-{$widget_number}", $_POST['widget-id'])) {
                    // the widget has been removed. "many-$widget_number" is "{id_base}-{widget_number}
                    unset($options[$widget_number]);
                }
            }
        }
        foreach ((array) $_POST['lifestream'] as $widget_number => $widget_options) {
            // user clicked cancel
            if (!isset($widget_options['submit']) && isset($options[$widget_number])) {
                continue;
            }
            $options[$widget_number] = $widget_options;
        }
        $lifestream->update_option('widget', $options);
        // So that we don't go through this more than once
        $updated = true;
    }
    // Here we echo out the form
    if (-1 == $number) {
        $current_options = array('amount' => 10, 'title' => 'Lifestream', 'break_groups' => false, 'feeds' => array(), 'hide_metadata' => false);
        $number = '%i%';
    } else {
        $current_options = (array) $options[$number];
        foreach ($current_options as $key => $value) {
            $current_options[$key] = attribute_escape($value);
        }
    }
    $results =& $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "lifestream_feeds` ORDER BY `id`");
    $feeds = array();
    foreach ($results as &$result) {
        $feeds[] = Lifestream_Feed::construct_from_query_result($lifestream, $result);
    }
    // The form has inputs with names like widget-many[$number][something] so that all data for that instance of
    // the widget are stored in one $_POST variable: $_POST['widget-many'][$number]
    ?>
	<script type="text/javascript">
	// TODO: move this out of the recursive wrapper
	function lifestreamClearSelection(obj)  {
		for (var i=0; i<obj.options.length; i++) {
			obj.options[i].selected = false;
		}
	}
	</script>
	<p>
		<label>
			<?php 
    $lifestream->_e('Title:');
    ?>
			<input class="widefat" name="lifestream[<?php 
    echo $number;
    ?>
][title]" type="text" value="<?php 
    echo $current_options['title'];
    ?>
" />
		</label>
	</p>
	<p>
		<label>
			<?php 
    $lifestream->_e('Number of events to show:');
    ?>
			<input style="width: 35px; text-align: center;" name="lifestream[<?php 
    echo $number;
    ?>
][amount]" type="text" value="<?php 
    echo $current_options['amount'];
    ?>
" />
		</label>
	</p>
	<p>
		<label>
			<input type="checkbox" name="lifestream[<?php 
    echo $number;
    ?>
][break_groups]" value="1"<?php 
    if (@$current_options['break_groups']) {
        echo ' checked = "checked"';
    }
    ?>
/>
			<?php 
    $lifestream->_e('Break up grouped events.');
    ?>
		</label><br />
	</p>
	<p>
		<label>
			<input type="checkbox" name="lifestream[<?php 
    echo $number;
    ?>
][hide_metadata]" value="1"<?php 
    if (@$current_options['hide_metadata']) {
        echo ' checked = "checked"';
    }
    ?>
/>
			<?php 
    $lifestream->_e('Hide meta data, such as the time.');
    ?>
		</label><br />
	</p>
	<p>
		<?php 
    $lifestream->_e('Feeds to show (optional):');
    ?>
 <small>(<a href="javascript:void(0);" onclick="lifestreamClearSelection(this.parentNode.parentNode.getElementsByTagName('select')[0]);"><?php 
    $lifestream->_e('Clear Selection');
    ?>
</a>)</small><br />
		<select multiple="multiple" style="width: 92%; height: 80px;" name="lifestream[<?php 
    echo $number;
    ?>
][feeds][]">
			<?php 
    foreach ($feeds as &$feed) {
        ?>
				<option value="<?php 
        echo $feed->id;
        ?>
"<?php 
        if (in_array((string) $feed->id, @(array) $current_options['feeds'])) {
            echo ' selected="selected"';
        }
        ?>
><?php 
        echo $feed->get_public_name();
        ?>
 (<?php 
        echo $feed->get_feed_display();
        ?>
)</option>
			<?php 
    }
    ?>
		</select>
	</p>
	<input type="hidden" name="lifestream[<?php 
    echo $number;
    ?>
][submit]" value="1" />
<?php 
}
Example #26
0
            echo $lifestream->get_icon_media_url($result->feed . '.png');
            ?>
"/></td>
							<td><?php 
        } else {
            ?>
<td colspan="2"><?php 
        }
        if ($result->has_viewed) {
            ?>
<strong><?php 
            echo Lifestream_Feed::parse_urls(htmlspecialchars($result->message));
            ?>
</strong><?php 
        } else {
            echo Lifestream_Feed::parse_urls(htmlspecialchars($result->message));
        }
        ?>
					</td>
					<td><?php 
        echo date($date_format, $result->timestamp);
        ?>
</td>
				</tr>
			<?php 
    }
    ?>
		</tbody>
	</table>
	<div class="tablenav">
		<?php 
Example #27
0
 function update_all($user_id = null)
 {
     // $user_id is not implemented yet
     global $wpdb;
     $this->update_option('_last_update', time());
     $events = array();
     $results =& $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "lifestream_feeds` WHERE `active` = 1");
     foreach ($results as $result) {
         $instance = Lifestream_Feed::construct_from_query_result($this, $result);
         try {
             $feed_msg = $instance->refresh();
             $events[$instance->id] = $feed_msg[1];
         } catch (Lifestream_FeedFetchError $ex) {
             $this->log_error($ex, $instance->id);
             $events[$instance->id] = $ex;
         }
     }
     return $events;
 }
Example #28
0
 function yield($row, $url, $key)
 {
     $data = parent::yield($row, $url, $key);
     return $data;
 }