C_Taxonomy_Controller

Class C_Taxonomy_Controller.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_basic_tagcloud/package.module.nextgen_basic_tagcloud.php  
  1. class C_Taxonomy_Controller extends C_MVC_Controller 
  2. static $_instances = array(); 
  3. protected $ngg_tag_detection_has_run = FALSE; 
  4. /** 
  5. * Returns an instance of this class 
  6. * @param string $context 
  7. * @return C_Taxonomy_Controller 
  8. */ 
  9. static function get_instance($context = FALSE) 
  10. if (!isset(self::$_instances[$context])) { 
  11. $klass = get_class(); 
  12. self::$_instances[$context] = new $klass($context); 
  13. return self::$_instances[$context]; 
  14. function define($context = FALSE) 
  15. parent::define($context); 
  16. $this->implement('I_Taxonomy_Controller'); 
  17. /** 
  18. * Returns the rendered HTML of a gallery based on the provided tag 
  19. * @param string $tag 
  20. * @return string 
  21. */ 
  22. function index_action($tag) 
  23. $mapper = C_Display_Type_Mapper::get_instance(); 
  24. // Respect the global display type setting 
  25. $display_type = $mapper->find_by_name(NGG_BASIC_TAGCLOUD, TRUE); 
  26. $display_type = !empty($display_type->settings['gallery_display_type']) ? $display_type->settings['gallery_display_type'] : NGG_BASIC_THUMBNAILS; 
  27. return "[ngg_images source='tags' container_ids='{$tag}' slug='{$tag}' display_type='{$display_type}']"; 
  28. /** 
  29. * Determines if the current page is /ngg_tag/{*} 
  30. * @param $posts Wordpress post objects 
  31. * @return array Wordpress post objects 
  32. */ 
  33. function detect_ngg_tag($posts, $wp_query_local) 
  34. global $wp; 
  35. global $wp_query; 
  36. $wp_query_orig = false; 
  37. if ($wp_query_local != null && $wp_query_local != $wp_query) { 
  38. $wp_query_orig = $wp_query; 
  39. $wp_query = $wp_query_local; 
  40. // This appears to be necessary for multisite installations, but I can't imagine why. More hackery.. 
  41. $tag = urldecode(get_query_var('ngg_tag') ? get_query_var('ngg_tag') : get_query_var('name')); 
  42. if (!$this->ngg_tag_detection_has_run && !is_admin() && !empty($tag) && (stripos($wp->request, 'ngg_tag') === 0 || isset($wp_query->query_vars['page_id']) && $wp_query->query_vars['page_id'] === 'ngg_tag')) { 
  43. $this->ngg_tag_detection_has_run = TRUE; 
  44. // Wordpress somewhat-correctly generates several notices, so silence them as they're really unnecessary 
  45. if (!defined('WP_DEBUG') || !WP_DEBUG) { 
  46. error_reporting(0); 
  47. // Without this all url generated from this page lacks the /ngg_tag/(slug) section of the URL 
  48. add_filter('ngg_wprouting_add_post_permalink', '__return_false'); 
  49. // create in-code a fake post; we feed it back to Wordpress as the sole result of the "the_posts" filter 
  50. $posts = NULL; 
  51. $posts[] = $this->create_ngg_tag_post($tag); 
  52. $wp_query->is_404 = FALSE; 
  53. $wp_query->is_page = TRUE; 
  54. $wp_query->is_singular = TRUE; 
  55. $wp_query->is_home = FALSE; 
  56. $wp_query->is_archive = FALSE; 
  57. $wp_query->is_category = FALSE; 
  58. unset($wp_query->query['error']); 
  59. $wp_query->query_vars['error'] = ''; 
  60. if ($wp_query_orig !== false) { 
  61. $wp_query = $wp_query_orig; 
  62. return $posts; 
  63. function create_ngg_tag_post($tag) 
  64. $title = sprintf(__('Images tagged "%s"', 'nggallery'), $tag); 
  65. $title = apply_filters('ngg_basic_tagcloud_title', $title, $tag); 
  66. $post = new stdClass(); 
  67. $post->post_author = FALSE; 
  68. $post->post_name = 'ngg_tag'; 
  69. $post->guid = get_bloginfo('wpurl') . '/' . 'ngg_tag'; 
  70. $post->post_title = $title; 
  71. $post->post_content = $this->index_action($tag); 
  72. $post->ID = FALSE; 
  73. $post->post_type = 'page'; 
  74. $post->post_status = 'publish'; 
  75. $post->comment_status = 'closed'; 
  76. $post->ping_status = 'closed'; 
  77. $post->comment_count = 0; 
  78. $post->post_date = current_time('mysql'); 
  79. $post->post_date_gmt = current_time('mysql', 1); 
  80. return $post;