Пример #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 
        }
    }
Пример #2
0
function get_pf_nom_class_tags($array = array())
{
    foreach ($array as $class) {
        if ($class == '' || empty($class) || !isset($class)) {
            //Do nothing.
            $tags = '';
        } elseif (is_array($class)) {
            foreach ($class as $subclass) {
                $tags = ' ';
                $tags = pf_slugger($class, true, false, true);
            }
        } else {
            $tags = ' ';
            $tags = pf_slugger($class, true, false, true);
        }
    }
    return $tags;
}
Пример #3
0
 } else {
     foreach ($getTheTags as $tag) {
         $wp_nom_tags .= ', ';
         $wp_nom_tags .= $tag->name;
     }
     $wp_nom_slugs = array();
     foreach ($getTheTags as $tag) {
         $wp_nom_slugs[] = $tag->slug;
     }
 }
 $metadata['nom_tags'] = $nomed_tag_slugs = $wp_nom_slugs;
 $metadata['all_tags'] = $nom_tags .= $wp_nom_tags;
 $nomTagsArray = explode(",", $item_nom_tags);
 $nomTagClassesString = '';
 foreach ($nomTagsArray as $nomTag) {
     $nomTagClassesString .= pf_slugger($nomTag, true, false, true);
     $nomTagClassesString .= ' ';
 }
 //RSS-passed tags as slugs.
 $metadata['item_tags'] = $nom_tag_slugs = $nomTagClassesString;
 //All users who nominated.
 $metadata['nominators'] = $nominators = get_post_meta($nom_id, 'nominator_array', true);
 //Number of times repeated in source.
 $metadata['source_repeat'] = $source_repeat = get_post_meta($nom_id, 'source_repeat', true);
 //Post-object tags
 $metadata['item_title'] = $item_title = get_the_title();
 $metadata['item_content'] = get_the_content();
 //UNIX datetime last modified.
 $metadata['timestamp_nom_last_modified'] = $timestamp_nom_last_modified = get_the_modified_date('U');
 //UNIX datetime added to nominations.
 $metadata['timestamp_unix_date_nomed'] = $timestamp_unix_date_nomed = strtotime($date_nomed);