function test_pf_get_relationship_value_no_relationship_by_this_type_with_integers() { $user_id = $this->factory->user->create(); $item_id = $this->factory->post->create(); $type = 2; $relationship_id = $this->factory->relationship->create(array('user_id' => $user_id, 'item_id' => $item_id, 'type' => $type, 'value' => 1)); // Try a different type of relationship. Should return false $value = pf_get_relationship_value(1, $item_id, $user_id); $this->assertSame(false, $value); }
/** * 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 } }
$metadata['timestamp_unix_date_nomed'] = $timestamp_unix_date_nomed = strtotime($date_nomed); //UNIX datetime item was posted to its home RSS. $metadata['timestamp_item_posted'] = $timestamp_item_posted = strtotime($date_posted); $metadata['archived_status'] = $archived_status = get_post_meta($nom_id, 'archived_by_user_status'); $userObj = wp_get_current_user(); $user_id = $userObj->ID; if (!empty($metadata['archived_status'])) { $archived_status_string = ''; $archived_user_string_match = 'archived_' . $current_user_id; foreach ($archived_status as $user_archived_status) { if ($user_archived_status == $archived_user_string_match) { $archived_status_string = 'archived'; $dependent_style = 'display:none;'; } } } elseif (1 == pf_get_relationship_value('archive', $nom_id, $user_id)) { $archived_status_string = 'archived'; $dependent_style = 'display:none;'; } else { $dependent_style = ''; $archived_status_string = ''; } $item = pf_feed_object(get_the_title(), get_post_meta($nom_id, 'source_title', true), $date_posted, $item_authorship, get_the_content(), $nom_permalink, get_the_post_thumbnail($nom_id), $rss_item_id, get_post_meta($nom_id, 'item_wp_date', true), $nom_tags, $date_nomed, $source_repeat, $nom_id, '1'); $this->form_of_an_item($item, $c, 'nomination', $metadata); /** echo '<article class="feed-item entry nom-container ' . $archived_status_string . pf_nom_class_tagger(array($submitter_slug, $nom_id, $item_authorship, $nom_tag_slugs, $nominators, $nomed_tag_slugs, $rss_item_id )) . '" id="' . get_the_ID() . '" style="' . $dependent_style . '" tabindex="' . $c . '">'; ?> <header> <?php echo '<h1 class="item_title"><a href="#modal-' . get_the_ID() . '" class="item-expander" role="button" data-toggle="modal" data-backdrop="false">' . get_the_title() . '</a></h1>'; ?> <div class="sortable-hidden-meta" style="display:none;"> <?php _e('UNIX timestamp from source RSS', 'pf');
function pf_ajax_relate() { pf_log('Invoked: pf_ajax_relate()'); $item_id = $_POST['post_id']; $relationship_type = $_POST['schema']; $switch = $_POST['isSwitch']; $userObj = wp_get_current_user(); $user_id = $userObj->ID; $result = 'nada'; pf_log('pf_ajax_relate - received: ID = ' . $item_id . ', Schema = ' . $relationship_type . ', isSwitch = ' . $switch . ', userID = ' . $user_id . '.'); if (1 != pf_get_relationship_value($relationship_type, $item_id, $user_id)) { $result = pf_set_relationship($relationship_type, $item_id, $user_id, '1'); pf_log('pf_ajax_relate - set: relationship on'); } else { if ($switch == 'on') { $result = pf_delete_relationship($relationship_type, $item_id, $user_id); pf_log('pf_ajax_relate - set: relationship off'); } else { $result = 'unswitchable'; pf_log('pf_ajax_relate - set: relationship unswitchable'); } } ob_start(); $response = array('what' => 'relationships', 'action' => 'pf_ajax_relate', 'id' => $item_id, 'data' => $result, 'supplemental' => array('user' => $user_id, 'buffered' => ob_get_contents())); $xmlResponse = new WP_Ajax_Response($response); $xmlResponse->send(); ob_end_flush(); die; }