Esempio n. 1
0
    /**
     * Essentially the PF 'loop' template. 
     * $item = the each of the foreach
     * $c = count.
     * $format = format changes, to be used later or by plugins. 
     **/
    public function form_of_an_item($item, $c, $format = 'standard', $metadata = array())
    {
        global $current_user;
        get_currentuserinfo();
        if ('' !== get_option('timezone_string')) {
            //Allows plugins to introduce their own item format output.
            date_default_timezone_set(get_option('timezone_string'));
        }
        if (has_action('pf_output_items')) {
            do_action('pf_output_items', $item, $c, $format);
            return;
        }
        $itemTagsArray = explode(",", $item['item_tags']);
        $itemTagClassesString = '';
        $user_id = $current_user->ID;
        foreach ($itemTagsArray as $itemTag) {
            $itemTagClassesString .= pf_slugger($itemTag, true, false, true);
            $itemTagClassesString .= ' ';
        }
        if ($format === 'nomination') {
            $feed_ited_id = $metadata['item_id'];
            $id_for_comments = $metadata['item_feed_post_id'];
            $id_for_comments = $metadata['item_feed_post_id'];
            $readStat = pf_get_relationship_value('read', $id_for_comments, $user_id);
            if (!$readStat) {
                $readClass = '';
            } else {
                $readClass = 'article-read';
            }
            if (!isset($metadata['nom_id']) || empty($metadata['nom_id'])) {
                $metadata['nom_id'] = md5($item['item_title']);
            }
            if (empty($id_for_comments)) {
                $id_for_comments = $metadata['nom_id'];
            }
            if (empty($metadata['item_id'])) {
                $metadata['item_id'] = md5($item['item_title']);
            }
        } else {
            $feed_ited_id = $item['item_id'];
            $id_for_comments = $item['post_id'];
        }
        $archive_status = pf_get_relationship_value('archive', $id_for_comments, wp_get_current_user()->ID);
        if (isset($_GET['pf-see'])) {
        } else {
            $_GET['pf-see'] = false;
        }
        if ($archive_status == 1 && 'archive-only' != $_GET['pf-see']) {
            $archived_status_string = 'archived';
            $dependent_style = 'display:none;';
        } elseif ($format === 'nomination' && 1 == pf_get_relationship_value('archive', $metadata['nom_id'], $user_id) && 'archive-only' != $_GET['pf-see']) {
            $archived_status_string = 'archived';
            $dependent_style = 'display:none;';
        } else {
            $dependent_style = '';
            $archived_status_string = '';
        }
        if ($format === 'nomination') {
            #$item = array_merge($metadata, $item);
            #var_dump($item);
            echo '<article class="feed-item entry nom-container ' . $archived_status_string . ' ' . get_pf_nom_class_tags(array($metadata['submitters'], $metadata['nom_id'], $metadata['authors'], $metadata['nom_tags'], $metadata['item_tags'], $metadata['item_id'])) . ' ' . $readClass . '" id="' . $metadata['nom_id'] . '" style="' . $dependent_style . '" tabindex="' . $c . '" pf-post-id="' . $metadata['nom_id'] . '" pf-item-post-id="' . $id_for_comments . '" pf-feed-item-id="' . $metadata['item_id'] . '" pf-schema="read" pf-schema-class="article-read">';
        } else {
            $id_for_comments = $item['post_id'];
            $readStat = pf_get_relationship_value('read', $id_for_comments, $user_id);
            if (!$readStat) {
                $readClass = '';
            } else {
                $readClass = 'article-read';
            }
            echo '<article class="feed-item entry ' . pf_slugger($item['source_title'], true, false, true) . ' ' . $itemTagClassesString . ' ' . $readClass . '" id="' . $item['item_id'] . '" tabindex="' . $c . '" pf-post-id="' . $item['post_id'] . '" pf-feed-item-id="' . $item['item_id'] . '" pf-item-post-id="' . $id_for_comments . '" >';
        }
        $readStat = pf_get_relationship_value('read', $id_for_comments, $user_id);
        echo '<div class="box-controls">';
        if (current_user_can('manage_options')) {
            echo '<i class="icon-remove-sign pf-item-remove" pf-item-post-id="' . $id_for_comments . '" title="Delete"></i>';
        }
        echo '<i class="icon-eye-close hide-item pf-item-archive schema-archive schema-actor" pf-item-post-id="' . $id_for_comments . '" title="Hide" pf-schema="archive"></i>';
        if (!$readStat) {
            $readClass = '';
        } else {
            $readClass = 'marked-read';
        }
        echo '<i class="icon-ok-sign schema-read schema-actor schema-switchable ' . $readClass . '" pf-item-post-id="' . $id_for_comments . '" pf-schema="read" pf-schema-class="marked-read" title="Mark as Read"></i>';
        echo '</div>';
        ?>
 
			<header> <?php 
        echo '<h1 class="item_title"><a href="#modal-' . $item['item_id'] . '" class="item-expander schema-actor" role="button" data-toggle="modal" data-backdrop="false" pf-schema="read" pf-schema-targets="schema-read">' . self::display_a($item['item_title'], 'title') . '</a></h1>';
        echo '<p class="source_title">' . self::display_a($item['source_title'], 'source') . '</p>';
        if ($format === 'nomination') {
            ?>
		
						<div class="sortable-hidden-meta" style="display:none;">
							<?php 
            _e('UNIX timestamp from source RSS', 'pf');
            echo ': <span class="sortable_source_timestamp sortableitemdate">' . $metadata['timestamp_item_posted'] . '</span><br />';
            _e('UNIX timestamp last modified', 'pf');
            echo ': <span class="sortable_mod_timestamp">' . $metadata['timestamp_nom_last_modified'] . '</span><br />';
            _e('UNIX timestamp date nominated', 'pf');
            echo ': <span class="sortable_nom_timestamp">' . $metadata['timestamp_unix_date_nomed'] . '</span><br />';
            _e('Slug for origin site', 'pf');
            echo ': <span class="sortable_origin_link_slug">' . $metadata['source_slug'] . '</span><br />';
            //Add an action here for others to provide additional sortables.
            echo '</div>';
        }
        # Let's build an info box!
        //http://nicolasgallagher.com/pure-css-speech-bubbles/
        $urlArray = parse_url($item['item_link']);
        $sourceLink = 'http://' . $urlArray['host'];
        //http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
        $ibox = '<div class="feed-item-info-box" id="info-box-' . $item['item_id'] . '">';
        $ibox .= '
										' . __('Feed', 'pf') . ': <span class="feed_title">' . $item['source_title'] . '</span><br />
										' . __('Posted', 'pf') . ': <span class="feed_posted">' . date('M j, Y; g:ia', strtotime($item['item_date'])) . '</span><br />
										' . __('Retrieved', 'pf') . ': <span class="item_meta item_meta_added_date">' . date('M j, Y; g:ia', strtotime($item['item_added_date'])) . '</span><br />
										' . __('Authors', 'pf') . ': <span class="item_authors">' . $item['item_author'] . '</span><br />
										' . __('Origin', 'pf') . ': <span class="source_name"><a target ="_blank" href="' . $sourceLink . '">' . $sourceLink . '</a></span><br />
										' . __('Original Item', 'pf') . ': <span class="source_link"><a href="' . $item['item_link'] . '" class="item_url" target ="_blank">' . $item['item_title'] . '</a></span><br />
										' . __('Tags', 'pf') . ': <span class="item_tags">' . $item['item_tags'] . '</span><br />
										' . __('Times repeated in source', 'pf') . ': <span class="feed_repeat sortable_sources_repeat">' . $item['source_repeat'] . '</span><br />
										';
        if ($format === 'nomination') {
            $ibox .= __('Number of nominations received', 'pf') . ': <span class="sortable_nom_count">' . $metadata['nom_count'] . '</span><br />' . __('First submitted by', 'pf') . ': <span class="first_submitter">' . $metadata['submitters'] . '</span><br />' . __('Nominated on', 'pf') . ': <span class="nominated_on">' . date('M j, Y; g:ia', strtotime($metadata['date_nominated'])) . '</span><br />';
        }
        $ibox .= '</div>';
        echo $ibox;
        ?>
									<script type="text/javascript">
										
											var pop_title_<?php 
        echo $item['item_id'];
        ?>
 = '';
											var pop_html_<?php 
        echo $item['item_id'];
        ?>
 = jQuery('#<?php 
        echo 'info-box-' . $item['item_id'];
        ?>
');
											
										
									</script>
									<?php 
        $this->form_of_actions_btns($item, $c, false, $format, $metadata, $id_for_comments);
        ?>
			</header>
			<?php 
        //echo '<a name="' . $c . '" style="display:none;"></a>';
        /**
        			echo '<script type="text/javascript">
        					jQuery(window).load(function() {
        						jQuery("#' . $item['item_id'] . '").on("show", function () {
        							jQuery("#excerpt' . $c . '").hide("slow");
        						});
        
        						jQuery("#' . $item['item_id'] . '").on("hide", function () {
        							jQuery("#excerpt' . $c . '").show("slow");
        						});
        					});
        				</script>';
        **/
        ?>
			<div class="content">
				<?php 
        if ($item['item_feat_img'] != '' && $format != 'nomination') {
            echo '<div style="float:left; margin-right: 10px; margin-bottom: 10px;"><img src="' . $item['item_feat_img'] . '"></div>';
        }
        ?>
 <div style="display:none;"> <?php 
        echo '<div class="item_meta item_meta_date">Published on ' . $item['item_date'] . ' by <span class="item-authorship">' . $item['item_author'] . '</span>.</div>';
        echo 'Unix timestamp for item date:<span class="sortableitemdate">' . strtotime($item['item_date']) . '</span> and for added to feed date <span class="sortablerssdate">' . strtotime($item['item_added_date']) . '</span>.';
        ?>
 </div> <?php 
        echo '<div class="item_excerpt" id="excerpt' . $c . '">';
        if ($format === 'nomination') {
            echo '<p>' . pf_noms_excerpt($item['item_content']) . '</p>';
        } else {
            echo '<p>' . self::display_a(pf_feed_excerpt($item['item_content']), 'graf') . '</p>';
        }
        echo '</div>';
        /**
        						echo '<div id="collapse' . $c . '" class="accordion-body collapse">';
        						echo '<div class="accordion-inner">';
        						echo '<div class="row-fluid">';
        							echo '<div class="span12 item_content">';
        								echo '<div>' . $item['item_content'] . '</div>';
        								echo '<br />';
        								echo '<a target="_blank" href="' . $item['item_link'] . '">' . __('Read More', 'pf') . '</a>';
        								echo '<br />';
        								echo '<strong class="item-tags">' . __('Item Tags', 'pf') . '</strong>: ' . $item['item_tags'] . '.';
        								echo '<br />';
        							echo '</div><!-- end item_content span12 -->';
        						echo '</div><!-- End row-fluid -->';
        						echo '</div>';
        						echo '</div>';
        						//print_r($item);
        						//print_r($ent = htmlentities($item['item_content']));
        						//print_r(html_entity_decode($ent));
        **/
        ?>
			</div><!-- End content -->
			<footer>
				<p class="pubdate"><?php 
        echo date('F j, Y; g:i a', strtotime($item['item_date']));
        ?>
</p>
			</footer>
			<?php 
        //Allows plugins to introduce their own item format output.
        if (has_action('pf_output_modal')) {
            do_action('pf_output_modal', $item, $c, $format);
        } else {
            ?>
		
			<!-- Begin Modal -->
			<div id="modal-<?php 
            echo $item['item_id'];
            ?>
" class="modal hide fade pfmodal" tabindex="-1" role="dialog" aria-labelledby="modal-<?php 
            echo $item['item_id'];
            ?>
-label" aria-hidden="true" pf-item-id="<?php 
            echo $item['item_id'];
            ?>
" pf-post-id="<?php 
            echo $item['post_id'];
            ?>
" pf-readability-status="<?php 
            echo $item['readable_status'];
            ?>
"> 
			  <div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>				
				<div class="modal-mobile-nav pull-right hidden-desktop">
					<div class="mobile-goPrev pull-left">
					
					</div>
					<div class="mobile-goNext pull-right">
					
					</div>					
				</div>
				<h3 id="modal-<?php 
            echo $item['item_id'];
            ?>
-label" class="modal_item_title source_title"><?php 
            echo $item['item_title'];
            ?>
</h3>
			  </div>
			  <div class="row-fluid modal-body-row">
				  <div class="modal-body span9" id="modal-body-<?php 
            echo $item['item_id'];
            ?>
">
					<?php 
            $contentObj = new pf_htmlchecker($item['item_content']);
            $text = $contentObj->closetags($item['item_content']);
            echo $text;
            ?>
				  </div>
				  <div class="modal-sidebar span3">
					<div class="goPrev modal-side-item row-fluid">
					
					</div>
					<div class="modal-comments modal-side-item row-fluid">

					</div>
					<div class="goNext modal-side-item row-fluid">
					
					</div>
				  </div>
			  </div>
			  <div class="modal-footer">
				<div class="row-fluid">
				<div class="pull-left original-link">
					<a target="_blank" href="<?php 
            echo $item['item_link'];
            ?>
"><?php 
            _e('Read Original', 'pf');
            ?>
</a> 
					<?php 
            if ($format != 'nomination') {
                ?>
						| <a class="modal-readability-reset" target="#readable" href="<?php 
                echo $item['item_link'];
                ?>
" pf-item-id="<?php 
                echo $item['item_id'];
                ?>
" pf-post-id="<?php 
                echo $item['post_id'];
                ?>
" pf-modal-id="#modal-<?php 
                echo $item['item_id'];
                ?>
"><?php 
                _e('Reset Readability', 'pf');
                ?>
</a>
						<?php 
            }
            ?>
				</div>
				<div class="pull-right"><?php 
            $this->form_of_actions_btns($item, $c, true, $format, $metadata, $id_for_comments);
            ?>
</div><?php 
            ?>
	
				</div>
				<div class="item-tags pull-left row-fluid">
				<?php 
            echo '<em>' . __('Source', 'pf') . ': ' . $item['source_title'] . '</em> | ';
            echo '<strong>' . __('Item Tags', 'pf') . '</strong>: ' . $item['item_tags'];
            ?>
				</div>
			  </div>				
			</div>
			<!-- End Modal -->
		</article><!-- End article -->
		<?php 
        }
    }
Esempio n. 2
0
    function all_feed_assembler()
    {
        ob_start();
        if (isset($_GET['from'])) {
            $fromUT = $_GET['from'];
        } else {
            $fromUT = 0;
        }
        if (isset($_GET['limitless']) && $_GET['limitless'] == 'true') {
            $limitless = true;
        } else {
            $limitless = false;
        }
        if ($fromUT < 100 || $fromUT > date('U')) {
            $fromUT = false;
        }
        #var_dump($fromUT); die();
        header('Content-Type: application/rss+xml; charset=' . get_option('blog_charset'), true);
        echo '<?xml version="1.0" encoding="utf-8"?>';
        echo "<!-- RSS Generated by PressForward plugin on " . get_site_url() . " on " . date('m/d/Y; h:i:s A T') . " -->\n";
        ?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:freebase="http://rdf.freebase.com/ns/internet/website_category" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
			<channel>
				<title><?php 
        bloginfo('name');
        ?>
 - PressForward Unfiltered Feed</title>
				<link><?php 
        echo home_url('/?feed=feedforward');
        ?>
</link>
				<description>The aggregation of all feeds collected with PressForward at <?php 
        bloginfo('name');
        ?>
</description>
				<language><?php 
        bloginfo('language');
        ?>
</language>
				<?php 
        #<blogChannel:blogRoll></blogChannel:blogRoll>
        #<blogChannel:mySubscriptions></blogChannel:mySubscriptions>
        ?>
				<blogChannel:blink>http://pressforward.org/news/</blogChannel:blink>
				<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
				<lastBuildDate><?php 
        echo date('D, d M Y H:i:s O');
        ?>
</lastBuildDate>
				<atom:link href="<?php 
        echo home_url('/?feed=feedforward');
        ?>
" rel="self" type="application/rss+xml" />
				<docs>http://feed2.w3.org/docs/rss2.html</docs>
				<generator>PressForward</generator>
				<?php 
        #Built based on MQL spec (http://wiki.freebase.com/wiki/MQL) for queries in style of [{  "type": "/internet/website_category", "id": null, "name": "Aggregator" }]
        ?>
				<category domain="Freebase">Aggregator</category>
				<category domain="Freebase">/m/075x5v</category>
				<category domain="Freebase">/en/aggregator</category>
				<freebase:name>Aggregator</freebase:name>
				<freebase:mid>/m/075x5v</freebase:mid>
				<freebase:id>/en/aggregator</freebase:id>
				<?php 
        $admin_email = get_bloginfo('admin_email');
        $userObj = get_user_by('email', $admin_email);
        if (!$userObj) {
            $firstAdmin = get_users(array('role' => 'administrator', 'number' => 1));
            foreach ($firstAdmin as $admin) {
                $admin_email = $admin->user_email;
            }
            $userObj = get_user_by('email', $admin_email);
        }
        #var_dump($admin_email); echo '2'; die();
        ?>
				<managingEditor><?php 
        bloginfo('admin_email');
        ?>
 (<?php 
        echo $userObj->display_name;
        ?>
)</managingEditor>
				<webMaster><?php 
        bloginfo('admin_email');
        ?>
 (<?php 
        echo $userObj->display_name;
        ?>
)</webMaster>
				<ttl>30</ttl>
				<?php 
        $c = 0;
        foreach (pressforward()->pf_feed_items->archive_feed_to_display(0, 50, $fromUT, $limitless) as $item) {
            echo '<item>';
            ?>
							<title><![CDATA[<?php 
            echo strip_tags($item['item_title']);
            ?>
]]></title>
							<?php 
            # <link> should send users to published nominations when available.
            ?>
						
							<link><?php 
            echo $item['item_link'];
            ?>
</link>
							<guid isPermaLink="true"><?php 
            echo $item['item_link'];
            ?>
</guid>
							<?php 
            if (!empty($item['item_tags'])) {
                $items = explode(',', $item['item_tags']);
                if (!empty($items)) {
                    foreach ($items as $tag) {
                        echo '<category><![CDATA[' . $tag . ']]></category>';
                    }
                }
            }
            ?>
							<dc:creator><?php 
            echo $item['item_author'];
            ?>
</dc:creator>
							<?php 
            $content = $item['item_content'];
            $excerpt = pf_feed_excerpt($content);
            ?>
							<description><![CDATA[<?php 
            echo strip_tags($excerpt);
            ?>
]]></description>
							<content:encoded><![CDATA[<?php 
            echo strip_tags($content);
            ?>
]]></content:encoded>
							<pubDate><?php 
            echo date('D, d M Y H:i:s O', strtotime($item['item_date']));
            ?>
</pubDate>
							
							<?php 
            # Should use <source>, but not passing along RSS link, something to change.
            # <guid></guid>
            echo '</item>';
            if ($c++ == 50) {
                break;
            }
        }
        ?>
			</channel>
		</rss>
	<?php 
        ob_end_flush();
    }