You are here

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in book_prev() (line 775 of /home/blackh31/public_html/BLACKHILL/modules/book/book.module).

Single Mouse Class (Second Method)

As an example of the second method, the following Mouse Object occupies a single file, but has several methods which are called by the respective Page class in order to render the respective view. When the constructor is called, a basic Mouse Object is instantiated. 

class MessageDB extends DB {
    function __construct() {
        parent::__construct();

        $this->has(array(
             message_id => array(isa => 'int'),
                subject => array(name => 'Subject',
                                  isa => 'Str32'),
                message => array(isa => 'Text'),
           from_user_id => array(name => 'From',
                                  isa => 'int'),
             to_user_id => array(name => 'To',
                                  isa => 'int'),
         sent_date_time => array(name => 'Time Sent',
                                  isa => 'DateTime',
                                order => 'desc'),
         read_date_time => array(isa => 'DateTime')
        ));
    }

When the Viewer page class calls the set_view_options() method, the Mouse Object is modified to reflect the needs of the Viewer page.

function set_view_options() {
    //modify the join option of the message_id attribute
    $message_id->join = array(where => "lms_message.message_id = " . $this->get_message_id());
    $this->modify_message_id($message_id);

    $subject->name = "";
    $this->modify_subject($subject);

    $message->row = 2;
    $message->col = 1;
    $message->name = "Message";
    $this->modify_message($message);

    $from_user_id->join = array(table => 'lms_user lu_from',
                               column => 'lu_from.username',
                                where => 'lu_from.user_id = lms_message.from_user_id');
    $from_user_id->row = 1;
    $from_user_id->col = 1;
    $this->modify_from_user_id($from_user_id);

    $to_user_id->join = array(table => 'lms_user lu_to',
                             column => 'lu_to.username',
                              where => 'lu_to.user_id = lms_message.to_user_id');
    $to_user_id->row = 1;
    $to_user_id->col = 2;
    $this->modify_to_user_id($to_user_id);

    $sent_date_time->row = 3;
    $sent_date_time->col = 1;
    $this->modify_sent_date_time($sent_date_time);

    $read_date_time->row = 3;
    $read_date_time->col = 2;
    $read_date_time->name = "Time Read";
    $this->modify_read_date_time($read_date_time);
}

function set_list_options() {
    // modify the Mouse Attribute "subject" to properly render the list
    //message_id is in the 0th array position of this MOUSE object
    $subject->link = function($data) {return('default.php?appname=message-view&message_id=' . $data[0]);};
    $this->modify_subject($subject);

    // modify the Mouse user_id Attributes in order to render the user lists
    $from_user_id->join = array(table => 'lms_user lu_from',
                               column => 'lu_from.username',
                                where => 'lu_from.user_id = lms_message.from_user_id');
    $this->modify_from_user_id($from_user_id);

    $to_user_id->join = array(table => 'lms_user lu_to',
                             column => 'lu_to.username',
                              where => 'lu_to.user_id = lms_message.to_user_id');
    $this->modify_to_user_id($to_user_id);
}

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer