Пример #1
0
 private function generate_form_filter_contents()
 {
     $args = array('posts_per_page' => -1, 'post_type' => 'publication', 'post_status' => 'publish');
     $type_ids_arr = array();
     if (isset($this->base_type)) {
         $type = $this->base_type;
         if (is_array($type)) {
             $type_arr = $type;
         } else {
             $type_arr = explode(',', $type);
         }
         foreach ($type_arr as $val) {
             if (is_numeric($val)) {
                 //id
                 $type_ids_arr[] = $val;
             } else {
                 //slug
                 $cur_term = get_term_by('slug', $val, 'knowledge_type');
                 //return object
                 if ($cur_term === false) {
                     return FALSE;
                 }
                 $type_ids_arr[] = $cur_term->term_id;
             }
         }
         $args['tax_query'] = array(array('taxonomy' => 'knowledge_type', 'field' => 'term_id', 'terms' => $type_ids_arr));
     }
     //  var_dump($args ) ;
     if ($this->hide_filter_area === false) {
         //only need to set the filter area value when the value == false
         $all_docs_query = new WP_Query($args);
         // loop documents and get all fund ids, manager ids and topic ids into arrays
         if ($all_docs_query->have_posts()) {
             $posts_arr = $all_docs_query->posts;
             $filter_ids_arr = $this->get_posts_filter_info($posts_arr);
         }
         // re-run the all Query with fund ids, manager ids and topic ids filter
         $possible_filter_check = $this->set_possible_filter_ids();
     }
     $request_args = $this->format_request_posts_args($args);
     //           var_dump($request_args ) ;
     $request_all_docs_query = new WP_Query($request_args);
     $possible_filter_ids_arr = $this->get_posts_filter_info($request_all_docs_query->posts);
     // $cur_page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
     $orderby = "title";
     //or post_date
     if (isset($_REQUEST['orderby'])) {
         $orderby = $_REQUEST['orderby'];
     }
     $order = "ASC";
     if (isset($_REQUEST['order'])) {
         $order = $_REQUEST['order'];
     }
     $request_args['orderby'] = $orderby;
     $request_args['order'] = $order;
     $cur_page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
     //$limit    = KNOWLEDGE_PAGE_NUM;
     global $numposts;
     $request_args['posts_per_page'] = $numposts;
     $request_args['paged'] = $cur_page;
     //                  var_dump($request_args ) ;
     $shown_docs_query = new WP_Query($request_args);
     $shown_docs_posts = $shown_docs_query->posts;
     //	if(!isset($filter_ids_arr) or count($filter_ids_arr)==0) return FALSE;
     ob_start();
     if ($this->hide_filter_area === false) {
         echo '<div id="bh_pubication_loader" style="display:none;"><img class="bh_filter_loading" src="' . get_stylesheet_directory_uri() . '/css/images/bh_loader.gif" /></div>';
     }
     echo ' <form id="bh_pubication_filter" method="post" action="">';
     if (isset($_REQUEST['bh_display'])) {
         $display = $_REQUEST['bh_display'];
     } else {
         $display = 0;
     }
     printf('<input id="bh_display" name="bh_display"   type="hidden" value="%s" /><span></span>', $display);
     printf('<input type="hidden"  id="hide_filter" name="hide_filter" value="%s" />', $this->hide_filter_area === 'true' ? "true" : "false");
     printf('<input type="hidden"  id="hide_section" name="hide_section" value="%s" />', $this->hide_section);
     if (isset($type)) {
         echo '<input type="hidden" name="bh_ori_type" value="' . implode(",", $type_ids_arr) . '" />';
     }
     if ($this->hide_filter_area === false) {
         if ($display == 0) {
             echo '<div id="bh_filter_area" class="bh_closed">';
             //filter_area;
         } else {
             echo '<div id="bh_filter_area" class="">';
             //filter_area;
         }
         $hide_secion_tag_arr = $this->get_filter_hide_area_tag();
         // list all funds in documant set as checkbox
         printf('<div class="ledged"><span class="not">%s</span><span class="remove">%s</span><span class="add">%s</span><span>%s</span></div>', __('Not Applicable', 'bridgehouse'), __('Remove Filter', 'bridgehouse'), __('Add Filter', 'bridgehouse'), __('Select all that apply', 'bridgehouse'));
         if (!isset($type) and (!isset($this->hide_section) or !in_array('fund_type', $hide_secion_tag_arr))) {
             $this->show_knowledge_type_filter($possible_filter_ids_arr['type_ids'], $type_ids_arr);
         }
         // list all manager in documant set as checkbox
         if (!isset($this->hide_section) or !in_array('investment_manager', $hide_secion_tag_arr)) {
             if (is_array($filter_ids_arr['manager_ids']) and count($filter_ids_arr['manager_ids'] > 0)) {
                 printf('<h3>%s</h3>', __('Investment Manager', 'bridgehouse'));
                 foreach ($filter_ids_arr['manager_ids'] as $value) {
                     $checked_class = $checked = '';
                     if (is_array($this->possible_manager_ids) and in_array($value, $this->possible_manager_ids)) {
                         $checked = 'checked';
                         $checked_class = "block_checked";
                     } else {
                         if (!in_array($value, $possible_filter_ids_arr['manager_ids'])) {
                             $checked = 'disabled';
                             $checked_class = "block_disabled";
                         }
                     }
                     printf('<div class="check_box_block %s"><input type="checkbox" %s name="bh_manager[]" value="%s" id="topics_%s"/><label for="topics_%s">%s</label></div>', $checked_class, $checked, $value, $value, $value, get_the_title($value));
                     # code...
                 }
             }
         }
         if (!isset($this->hide_section) or !in_array('mutual_fund', $hide_secion_tag_arr)) {
             if (is_array($filter_ids_arr['fund_ids']) and count($filter_ids_arr['fund_ids'] > 0)) {
                 printf('<h3>%s</h3>', __('Mutual Fund', 'bridgehouse'));
                 // the all posiable list
                 foreach ($filter_ids_arr['fund_ids'] as $value) {
                     //    var_dump($value);
                     $checked_class = $checked = '';
                     //           var_dump($this->possible_fund_ids);
                     if (is_array($this->possible_fund_ids) and in_array($value, $this->possible_fund_ids)) {
                         $checked = 'checked';
                         $checked_class = "block_checked";
                     } else {
                         if (!in_array($value, $possible_filter_ids_arr['fund_ids'])) {
                             $checked = 'disabled';
                             $checked_class = "block_disabled";
                         }
                     }
                     printf('<div class="check_box_block %s"><input type="checkbox" %s name="bh_fund[]" value="%s" id="topics_%s"/><label for="topics_%s">%s</label></div>', $checked_class, $checked, $value, $value, $value, get_the_title($value));
                 }
             }
         }
         // list all in documant set topics
         echo '<div style="clear:both;">';
         if (!isset($this->hide_section) or !in_array('region', $hide_secion_tag_arr)) {
             if (is_array($filter_ids_arr['location_ids']) and count($filter_ids_arr['location_ids'] > 0)) {
                 printf('<div class="filter_third "><h3>%s</h3>', __('Region', 'bridgehouse'));
                 foreach ($filter_ids_arr['location_ids'] as $value) {
                     $checked_class = $checked = '';
                     if (is_array($this->possible_location_ids) and in_array($value['term_id'], $this->possible_location_ids)) {
                         $checked = 'checked';
                         $checked_class = "block_checked";
                     } else {
                         if (!in_array($value, $possible_filter_ids_arr['location_ids'])) {
                             $checked = 'disabled';
                             $checked_class = "block_disabled";
                         }
                     }
                     printf('<div class="check_box_block %s"><input type="checkbox" %s name="bh_location[]" value="%s" id="topics_%s"/><label for="topics_%s">%s</label></div>', $checked_class, $checked, $value['term_id'], $value['term_id'], $value['term_id'], $value['name']);
                     foreach ($all_manager_ids as $value) {
                         //  var_dump($value);
                         printf('<input type="checkbox" name="bh_manager" value="%s" id="topics_%s"/><label for="topics_%s">%s</label> ', $value, $value, $value, get_the_title($value));
                         # code...
                     }
                 }
                 echo '</div>';
             }
         }
         if (!isset($this->hide_section) or !in_array('theme', $hide_secion_tag_arr)) {
             if (is_array($filter_ids_arr['topic_ids']) and count($filter_ids_arr['topic_ids'] > 0)) {
                 printf('<div class="filter_third" ><h3>%s</h3>', __('Theme', 'bridgehouse'));
                 foreach ($filter_ids_arr['topic_ids'] as $value) {
                     $checked_class = $checked = '';
                     if (is_array($this->possible_topic_ids) and in_array($value['term_id'], $this->possible_topic_ids)) {
                         $checked = 'checked';
                         $checked_class = "block_checked";
                     } else {
                         if (!in_array($value, $possible_filter_ids_arr['topic_ids'])) {
                             $checked = 'disabled';
                             $checked_class = "block_disabled";
                         }
                     }
                     printf('<div class="check_box_block %s"><input type="checkbox" %s name="bh_topics[]" value="%s" id="topics_%s"/><label for="topics_%s">%s</label></div> ', $checked_class, $checked, $value['term_id'], $value['term_id'], $value['term_id'], $value['name']);
                     # code...
                 }
                 echo '</div>';
             }
         }
         // list all in documant set topics
         if (!isset($this->hide_section) or !in_array('asset_class', $hide_secion_tag_arr)) {
             if (is_array($filter_ids_arr['class_ids']) and count($filter_ids_arr['class_ids'] > 0)) {
                 printf('<div class="filter_third filter_col_last"><h3>%s</h3>', __('Asset Class', 'bridgehouse'));
                 foreach ($filter_ids_arr['class_ids'] as $value) {
                     $checked_class = $checked = '';
                     if (is_array($this->possible_class_ids) and in_array($value['term_id'], $this->possible_class_ids)) {
                         $checked = 'checked';
                         $checked_class = "block_checked";
                     } else {
                         if (!in_array($value, $possible_filter_ids_arr['class_ids'])) {
                             $checked = 'disabled';
                             $checked_class = "block_disabled";
                         }
                     }
                     printf('<div class="check_box_block %s"><input type="checkbox" %s name="bh_class[]" value="%s" id="topics_%s"/><label for="topics_%s">%s</label></div>', $checked_class, $checked, $value['term_id'], $value['term_id'], $value['term_id'], $value['name']);
                     foreach ($all_fund_ids as $value) {
                         //	var_dump($value);
                         printf('<input type="checkbox" name="bh_fund" value="%s" id="topics_%s"/><label for="topics_%s">%s</label> ', $value, $value, $value, get_the_title($value));
                         # code...
                     }
                 }
                 echo '</div>';
             }
         }
         echo '</div>';
         if ($display == 0) {
             printf('<div class="submit_block"><input class="hb_button" type="reset" value="%s" /><span></span><input type="button" class="bh_closed toggle_point bh_button" value="%s" /><span></span></div>', __("Reset Filters", "bridgehouse"), __('"Show Filters"', 'bridgehouse'));
         } else {
             printf('<div class="submit_block"><input class="hb_button" type="reset" value="%s" /><span></span><input type="button" class="toggle_point bh_button" value="%s" /><span></span></div>', __("Reset Filters", "bridgehouse"), __('"Hide Filters"', 'bridgehouse'));
         }
         echo '</div>';
         //filter_area;
         echo '<div class="filter_footer_items"></div>';
         //filer footer
     }
     printf('<input name="orderby" type="hidden" value="%s" /><span></span>', $orderby);
     printf('<input name="order"   type="hidden" value="%s" /><span></span>', $order);
     printf('<input name="paged"   type="hidden" value="%s" /><span></span>', $cur_page);
     echo '<div class="sort_block">';
     printf('<h4>%s', __('Sort By: ', 'bridgehouse'));
     if ("date" == $orderby) {
         printf('<a class="sort_by %s" id="title_order" href="#">%s</a>', "", __('Title', 'bridgehouse'));
         printf(' <a class="sort_by date_order %s" id="date_order" href="#">%s</a>', $order, __('Date', 'bridgehouse'));
     } else {
         printf('<a class="sort_by %s" id="title_order" href="#">%s</a>', $order, __('Title', 'bridgehouse'));
         printf(' <a class="sort_by date_order %s" id="date_order" href="#">%s</a>', '', __('Date', 'bridgehouse'));
     }
     echo '</h4>';
     echo '</div>';
     echo '</form>';
     echo '<div class="bh_search_results">';
     if (count($shown_docs_posts) > 0) {
         foreach ($shown_docs_posts as $post_item) {
             $pub = new WP_Publication_Archive_Item($post_item->ID, $post_item->post_title, $post_item->post_date);
             $cur_knowledge_type_arr = get_the_terms($post_item->ID, 'knowledge_type');
             $cur_knowledge_type = array_pop($cur_knowledge_type_arr);
             //get the firt one
             // TODO: this what work with french
             echo '<div class="publication_download"><div class="share_links">';
             if (isset($cur_knowledge_type) and $cur_knowledge_type->slug == BH_KNOWLEDGE_VIDEO_TYPE_SLUG) {
                 $video_url = get_post_meta($post_item->ID, BH_KNOWLEDGE_VIDEO_META_KEY);
                 //  echo '<div class="bh_video_contents" style="float:left">';
                 //   global $wp_embed;
                 //   $wp_embed->usecache = false;
                 //    var_dump($wp_embed);
                 //   $v = $wp_embed->run_shortcode('[embed width="246" ]'.$video_url[0].'[/embed]');
                 //var_dump($v);
                 // echo $v;
                 // if(!empty($video_url[0])) {
                 //      $url = $video_url[0];
                 //      $matches = null;
                 //      preg_match('/[\\?\\&]v=([^\\?\\&]+)/',$url,$matches);
                 //      $id = $matches[1];
                 //      $width  = BH_KNOWLEDGE_VIDEO_WIDTH;
                 //      $height = BH_KNOWLEDGE_VIDEO_HEIGHT;
                 //      echo '<div class="bh_video_body">';
                 //      echo '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param>
                 //           <param name="allowFullScreen" value="true"></param>
                 //           <param name="allowscriptaccess" value="always"></param>
                 //           <embed src="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash"
                 //               allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed>
                 //           </object>';
                 //       echo '</div>';
                 //}
                 echo '<a class="addthis_button_email" addthis:url="' . $video_url[0] . '"></a>';
                 echo '<a class="addthis_button_compact" addthis:url="' . $video_url[0] . '"></a></div>';
                 echo ucfirst(date_i18n(_x('F j, Y', 'Inception date format', 'bridgehouse'), strtotime($pub->get_the_date())));
                 printf('<a href="%s" target="_blank" class="lbp_secondary"  rel="lightbox[knowledge]">%s</a>', $video_url[0], $pub->get_the_title());
                 echo str_replace("Summary:", "", $pub->get_the_summary());
                 //  echo '</div>';
                 // echo '<div class="publication_download"">';
                 //   printf('<span><a href="%s" target="_blank" rel=lightbox[knowledge_link]">%s</a></span>',$video_url[0],__("View Video","bridgehouse"));
                 // echo '</div>';
             } else {
                 echo '<a class="addthis_button_email" addthis:url="' . $pub->get_the_link() . '"></a>';
                 echo '<a class="addthis_button_compact" addthis:url="' . $pub->get_the_link() . '"></a></div>';
                 echo ucfirst(date_i18n(_x('F j, Y', 'Inception date format', 'bridgehouse'), strtotime($pub->get_the_date())));
                 printf('<a href="%s" target="_blank">%s</a>', $pub->get_the_link(), $pub->get_the_title());
                 // $pub->the_title();
                 echo str_replace("Summary:", "", $pub->get_the_summary());
                 //   echo str_replace("Download:", "", $pub->get_the_uri());
             }
             echo '</div>';
         }
     }
     if (function_exists('wp_pagenavi')) {
         wp_pagenavi(array('query' => $shown_docs_query));
     } else {
         next_posts_link();
         previous_posts_link();
     }
     echo '</div>';
     $output_string = ob_get_contents();
     ob_end_clean();
     wp_reset_postdata();
     return $output_string;
 }
Пример #2
0
 public function list_related_docs_for_manager($manager_id)
 {
     //	var_dump($fund_id);
     // TODO: add cache return here
     $docs_arrgs = array('post_type' => 'publication', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'meta_value_num title', 'order' => 'ASC', 'meta_key' => 'BH_manager_list_order', 'limit' => 4, 'suppress_filters' => 0, 'meta_query' => array('relation' => 'AND', array('key' => 'BH_manager_id', 'value' => $manager_id, 'compare' => 'like'), array('key' => 'BH_manager_list_order', 'value' => null, 'compare' => 'EXISTS')));
     $docs_posts = get_posts($docs_arrgs);
     ob_start();
     foreach ($docs_posts as $docs) {
         //	var_dump($docs);
         $pub = new WP_Publication_Archive_Item($docs->ID, $docs->post_title, $docs->post_date);
         $cur_knowledge_type_arr = get_the_terms($docs->ID, 'knowledge_type');
         $cur_knowledge_type = array_pop($cur_knowledge_type_arr);
         //get the firt one
         // TODO: this what work with french
         if (isset($cur_knowledge_type) and $cur_knowledge_type->slug == BH_KNOWLEDGE_VIDEO_TYPE_SLUG) {
             //$video_url = get_post_meta($post_item->ID, BH_KNOWLEDGE_VIDEO_META_KEY);
             $video_url = get_post_meta($docs->ID, BH_KNOWLEDGE_VIDEO_META_KEY);
             printf('<a href="%s" target="_blank" class="lbp_secondary"  rel="lightbox[knowledge]"><div class="publication_title">%s</div></a>', $video_url[0], $pub->get_the_title());
         } else {
             printf('<a href="%s" target="_blank">%s</a>', $pub->get_the_link(), $pub->get_the_title());
         }
     }
     $output_string = ob_get_contents();
     //	var_dump($output_string );
     ob_end_clean();
     wp_reset_postdata();
     return $output_string;
 }
 *
 * @var array  $publications Array of publications to display.
 * @var number $total_pubs   Number of publications in the database.
 * @var number $limit        Number of publications to display per page.
 * @var number $offset       Number of publications to skip.
 * @var number $paged        Current page number
 * @var object $post         Global Post object representing the page the shortcode is used on.
 */
extract($wppa_container);
?>
<div class="publication-archive">
<?php 
foreach ($publications as $publication) {
    ?>
	<?php 
    $pub = new WP_Publication_Archive_Item($publication->ID, $publication->post_title, $publication->post_date);
    ?>
	<div class="single-publication">
		<?php 
    $pub->the_thumbnail();
    ?>
		<?php 
    $pub->the_title();
    ?>
		<?php 
    $pub->the_authors();
    ?>
		<?php 
    $pub->the_uri();
    ?>
		<?php