You are here

class Notifications_Content_Node_View in Notifications 7

Template for a list of nodes, built with a View

As we cannot store a View object, because we get a serialization error (PDOException) we need to store only some parts of the view (content, title, etc...)

Hierarchy

Expanded class hierarchy of Notifications_Content_Node_View

1 string reference to 'Notifications_Content_Node_View'
notifications_content_notifications in notifications_content/notifications_content.module
Implementation of hook_notifications()

File

notifications_content/notifications_content.inc, line 413
Drupal Notifications Framework - Default class file

View source
class Notifications_Content_Node_View extends Notifications_Content_Node_List {
  protected $view_name = 'notifications_content_node_list';
  protected $view_content;

  /**
   * Set event and view name
   */
  public function set_event($event) {
    parent::set_event($event);

    // View may be set into action parameters, or we may get it from template info
    if ($view_name = $event
      ->get_action_context('view')) {
      $this->view_name = $view_name;
    }
    elseif (isset($this->info['view'])) {
      $this->view_name = $this->info['view'];
    }
    return $this;
  }

  /**
   * Content text.
   *
   * @todo Better way to render view
   */
  function text_content($options) {
    if (!isset($this->view_content)) {
      $view = $this
        ->get_view();

      // Weird: if we pass same objects, the view alters some of them, causing it to reference to PDO Object
      // Which causes an exception if trying to serialize. So we need to unlink the view from the node after render()
      $node_list = $this
        ->node_list();
      $view->result = $node_list;
      $view->executed = TRUE;
      $this->view_content = $view
        ->render();
      foreach ($node_list as $node) {
        unset($node->view);
      }
    }
    return $this->view_content;
  }

  /**
   * Get view
   */
  function get_view() {
    return views_get_view($this->view_name);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Messaging_Message_Template::$method public property
Messaging_Message_Template::element_defaults protected function Overrides Messaging_Template::element_defaults
Messaging_Message_Template::get_parts protected function Set message elements Overrides Messaging_Template::get_parts
Messaging_Message_Template::set_destination function Set destination (and reset built elements) Overrides Messaging_Message_Render::set_destination
Messaging_Message_Template::set_format public function Set text format Overrides Messaging_Message_Render::set_format
Messaging_Message_Template::set_method public function Set sending method Overrides Messaging_Message_Render::set_method
Messaging_Template::$elements public property
Messaging_Template::$format public property
Messaging_Template::$objects protected property
Messaging_Template::$options protected property
Messaging_Template::$parent protected property
Messaging_Template::$text public property
Messaging_Template::$tokens protected property
Messaging_Template::add_element function Add element ready for drupal_render()
Messaging_Template::add_item function Add item of unknown type
Messaging_Template::add_object function Add object to the list
Messaging_Template::add_string function Add string
Messaging_Template::add_text function Add text object
Messaging_Template::build public function Build all elements, return array
Messaging_Template::build_element public function Build a named element
Messaging_Template::build_parts public function Build template parts
Messaging_Template::build_text protected function Build a message text element
Messaging_Template::default_elements protected function Get default elements
Messaging_Template::element_build protected function Build a message element with optional text replacement
Messaging_Template::element_replace protected function Perform token replace within an element
Messaging_Template::get_element function Get element from elements or default texts
Messaging_Template::get_options function Get options for texts, translations, etc
Messaging_Template::get_text public function Get text element from this template
Messaging_Template::get_tokens function Get tokens for templates
Messaging_Template::render public function Render elements, return string
Messaging_Template::reset public function Reset built elements
Messaging_Template::set_language function Set language
Messaging_Template::set_option function Set options
Messaging_Template::set_options function Set array of options
Messaging_Template::set_parent function Set parent text
Messaging_Template::token_replace public function Do token replacement with this template's objects
Notifications_Content_Node_List::node_list function Get node list
Notifications_Content_Node_List::text_subject protected function Subject text Overrides Notifications_Message_Template::text_subject
Notifications_Content_Node_View::$view_content protected property
Notifications_Content_Node_View::$view_name protected property
Notifications_Content_Node_View::get_view function Get view
Notifications_Content_Node_View::set_event public function Set event and view name Overrides Notifications_Message_Template::set_event
Notifications_Content_Node_View::text_content function Content text. Overrides Notifications_Content_Node_List::text_content
Notifications_Message_Template::$content protected property
Notifications_Message_Template::$events protected property
Notifications_Message_Template::$info protected property
Notifications_Message_Template::$subscriptions protected property
Notifications_Message_Template::add_event function Add event object and its corresponding template
Notifications_Message_Template::build_message public function Get Message_Object with this template linked Overrides Messaging_Message_Template::build_message
Notifications_Message_Template::default_text protected function Default texts for this template, may need token replacement Overrides Messaging_Message_Template::default_text 2
Notifications_Message_Template::get_objects function Get objects as Drupal objects (Removing Notifications object wrapper) Overrides Messaging_Template::get_objects
Notifications_Message_Template::text_footer protected function Footer text
Notifications_Message_Template::text_header protected function Header text
Notifications_Message_Template::token_list public function Declare all tokens used for this template Overrides Messaging_Template::token_list
Notifications_Message_Template::__construct function Construct from template info