Changeset 1213

Show
Ignore:
Timestamp:
03/30/07 17:29:17 (6 years ago)
Author:
benoitg
Message:

Put the date of the shout before the username.

Location:
trunk/wifidog-auth
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1212 r1213  
    55        Allow choosing the number of shouts displayed. 
    66        Make the size of the shout field configurable from the admin interface 
    7         Put the date of the shout at the end of the shout. 
     7        Put the date of the shout before the username. 
    88        * User.php:  Make the entire "edit profile" link CSS targetable, including the parentesis. 
    99 
  • trunk/wifidog-auth/wifidog/classes/Content/ShoutBox/ShoutBox.php

    r1212 r1213  
    6060     * @return void     */ 
    6161    protected function __construct($content_id) { 
    62         parent :: __construct($content_id); 
     62        parent :: __construct($content_id); 
    6363    } 
    6464 
     
    6767     * 
    6868     * @return Content or null 
    69      
     69 
    7070     */ 
    7171    private function getOnClickContent() { 
    72         $content_id = $this->getKVP('ShoutBox_onclick_content_id'); 
    73         if($content_id) 
    74         { 
    75                 return Content::getObject($content_id); 
    76         } 
    77         else 
    78         { 
    79                 return null; 
    80         } 
     72        $content_id = $this->getKVP('ShoutBox_onclick_content_id'); 
     73        if($content_id) 
     74        { 
     75            return Content::getObject($content_id); 
     76        } 
     77        else 
     78        { 
     79            return null; 
     80        } 
    8181    } 
    8282 
     
    8989     */ 
    9090    private function setOnClickContent($content) { 
    91         if($content) 
    92         { 
    93                 $this->setKVP('ShoutBox_onclick_content_id', $content->getId()); 
    94         } 
    95         else 
    96         { 
    97                 $this->setKVP('ShoutBox_onclick_content_id', null); 
    98         } 
    99         return true; 
     91        if($content) 
     92        { 
     93            $this->setKVP('ShoutBox_onclick_content_id', $content->getId()); 
     94        } 
     95        else 
     96        { 
     97            $this->setKVP('ShoutBox_onclick_content_id', null); 
     98        } 
     99        return true; 
    100100    } 
    101101 
     
    149149        return $retval; 
    150150    } 
    151      
     151 
    152152    /** 
    153153     * Returns the maximum number of character one can shout.  0 means no limit. 
     
    192192        return $displayNumItems; 
    193193    } 
    194      
     194 
    195195    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    196         $html = null; 
    197  
    198         /*display_num_items*/ 
    199         $displayNumItems = $this->getDisplayNumItems(); 
    200         $html .= "<li class='admin_element_item_container'>\n"; 
    201         $html .= "<div class='admin_element_label'>" . ("Number of shouts to display in the list (0 means no limit)") . ": </div>\n"; 
    202         $html .= "<div class='admin_element_data'>\n"; 
    203         $name = "shoutbox_{this->getId()}_display_num_items"; 
    204         $html .= "<input type='text' size='6' value='$displayNumItems' name='$name'>\n"; 
    205         $html .= "</div>\n"; 
    206         $html .= "</li>\n"; 
    207  
    208         /*max_shout_chars*/ 
    209         $maxShoutChars = $this->getMaxShoutChars(); 
    210         $html .= "<li class='admin_element_item_container'>\n"; 
    211         $html .= "<div class='admin_element_label'>" . ("Maximum number of characters for each shouts (0 means no limit)") . ": </div>\n"; 
    212         $html .= "<div class='admin_element_data'>\n"; 
    213         $name = "shoutbox_{this->getId()}_max_num_chars"; 
    214         $html .= "<input type='text' size='6' value='$maxShoutChars' name='$name'>\n"; 
    215         $html .= "</div>\n"; 
    216         $html .= "</li>\n"; 
    217           
    218         /*shout_field_size*/ 
    219         $shoutFieldSize = $this->getShoutFieldSize(); 
    220         $html .= "<li class='admin_element_item_container'>\n"; 
    221         $html .= "<div class='admin_element_label'>" . ("Size (num characters) of the shout field") . ": </div>\n"; 
    222         $html .= "<div class='admin_element_data'>\n"; 
    223         $name = "shoutbox_{this->getId()}_shout_field_size"; 
    224         $html .= "<input type='text' size='6' value='$shoutFieldSize' name='$name'>\n"; 
    225         $html .= "</div>\n"; 
    226         $html .= "</li>\n"; 
    227          
    228         /* OnclickContent */ 
    229         $criteria_array = array ( 
    230         array ('isTextualContent'), 
    231         array ('isSimpleContent') 
    232         ); 
    233  
    234         $onclick_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 
    235  
    236  
    237         $content = $this->getOnClickContent(); 
    238         $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; 
    239         $html .= "<div class='admin_element_data'>\n"; 
    240         $onclick_title = _("Shout button 'onclick=' value (optionnal):"); 
    241         if (!$content) { 
    242                 $name = "shoutbox_" . $this->id . "_onclick_content_new"; 
    243                 $html .= self :: getNewContentUI($name, $onclick_allowed_content_types, $onclick_title); 
    244                 $html .= $hint; 
    245         } else { 
    246                 $html .= $content->getAdminUI(null, $onclick_title); 
    247                 $html .= "<div class='admin_section_hint'>" . sprintf(_("Note that the onclick parameter will appear inside double quotes in html.  They must be properly encoded fot that context.  You can access the shout text in Javascript with: %s"), "document.getElementById('shout_text').value") . "</div>\n"; 
    248                 $html .= "</div>\n"; 
    249                 $html .= "<div class='admin_element_tools'>\n"; 
    250                 $name = "shoutbox_" . $this->id . "_onclick_content_erase"; 
    251                 $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("onclick parameter"), get_class($content)) . "'>"; 
    252  
    253         }                        
    254         $html .= "</div>\n"; 
    255         $html .= "</li>\n"; 
    256         return parent :: getAdminUI($html, $title); 
    257     } 
    258  
    259     /** 
    260     * Processes the input of the administration interface for Picture 
    261     * 
    262     * @return void 
    263     */ 
     196        $html = null; 
     197 
     198        /*display_num_items*/ 
     199        $displayNumItems = $this->getDisplayNumItems(); 
     200        $html .= "<li class='admin_element_item_container'>\n"; 
     201        $html .= "<div class='admin_element_label'>" . ("Number of shouts to display in the list (0 means no limit)") . ": </div>\n"; 
     202        $html .= "<div class='admin_element_data'>\n"; 
     203        $name = "shoutbox_{this->getId()}_display_num_items"; 
     204        $html .= "<input type='text' size='6' value='$displayNumItems' name='$name'>\n"; 
     205        $html .= "</div>\n"; 
     206        $html .= "</li>\n"; 
     207 
     208        /*max_shout_chars*/ 
     209        $maxShoutChars = $this->getMaxShoutChars(); 
     210        $html .= "<li class='admin_element_item_container'>\n"; 
     211        $html .= "<div class='admin_element_label'>" . ("Maximum number of characters for each shouts (0 means no limit)") . ": </div>\n"; 
     212        $html .= "<div class='admin_element_data'>\n"; 
     213        $name = "shoutbox_{this->getId()}_max_num_chars"; 
     214        $html .= "<input type='text' size='6' value='$maxShoutChars' name='$name'>\n"; 
     215        $html .= "</div>\n"; 
     216        $html .= "</li>\n"; 
     217 
     218        /*shout_field_size*/ 
     219        $shoutFieldSize = $this->getShoutFieldSize(); 
     220        $html .= "<li class='admin_element_item_container'>\n"; 
     221        $html .= "<div class='admin_element_label'>" . ("Size (num characters) of the shout field") . ": </div>\n"; 
     222        $html .= "<div class='admin_element_data'>\n"; 
     223        $name = "shoutbox_{this->getId()}_shout_field_size"; 
     224        $html .= "<input type='text' size='6' value='$shoutFieldSize' name='$name'>\n"; 
     225        $html .= "</div>\n"; 
     226        $html .= "</li>\n"; 
     227          
     228        /* OnclickContent */ 
     229        $criteria_array = array ( 
     230        array ('isTextualContent'), 
     231        array ('isSimpleContent') 
     232        ); 
     233 
     234        $onclick_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 
     235 
     236 
     237        $content = $this->getOnClickContent(); 
     238        $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n"; 
     239        $html .= "<div class='admin_element_data'>\n"; 
     240        $onclick_title = _("Shout button 'onclick=' value (optionnal):"); 
     241        if (!$content) { 
     242            $name = "shoutbox_" . $this->id . "_onclick_content_new"; 
     243            $html .= self :: getNewContentUI($name, $onclick_allowed_content_types, $onclick_title); 
     244            $html .= $hint; 
     245        } else { 
     246            $html .= $content->getAdminUI(null, $onclick_title); 
     247            $html .= "<div class='admin_section_hint'>" . sprintf(_("Note that the onclick parameter will appear inside double quotes in html.  They must be properly encoded fot that context.  You can access the shout text in Javascript with: %s"), "document.getElementById('shout_text').value") . "</div>\n"; 
     248            $html .= "</div>\n"; 
     249            $html .= "<div class='admin_element_tools'>\n"; 
     250            $name = "shoutbox_" . $this->id . "_onclick_content_erase"; 
     251            $html .= "<input type='submit' class='submit' name='$name' value='" . sprintf(_("Delete %s (%s)"), _("onclick parameter"), get_class($content)) . "'>"; 
     252 
     253        } 
     254        $html .= "</div>\n"; 
     255        $html .= "</li>\n"; 
     256        return parent :: getAdminUI($html, $title); 
     257    } 
     258 
     259    /** 
     260     * Processes the input of the administration interface for Picture 
     261     * 
     262     * @return void 
     263     */ 
    264264    public function processAdminUI() { 
    265         $db=AbstractDb::getObject(); 
    266         if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    267                 parent :: processAdminUI(); 
    268                  
    269                 /*display_num_items*/ 
    270                 $name = "shoutbox_{this->getId()}_display_num_items"; 
    271                 $this->setDisplayNumItems($_REQUEST[$name]); 
    272  
    273                 /*max_shout_chars*/ 
    274                 $name = "shoutbox_{this->getId()}_max_num_chars"; 
    275                 $this->setMaxShoutChars($_REQUEST[$name]); 
    276                  
    277                 /*shout_field_size*/ 
    278                 $name = "shoutbox_{this->getId()}_shout_field_size"; 
    279                 $this->setShoutFieldSize($_REQUEST[$name]); 
    280                  
    281                 /* OnclickContent */ 
    282                 $content = $this->getOnClickContent(); 
    283                 if (!$content) { 
    284                         $name = "shoutbox_" . $this->id . "_onclick_content_new"; 
    285                         $content = self :: processNewContentUI($name); 
    286                         $this->setOnClickContent($content); 
    287                 } else { 
    288                         $name = "shoutbox_" . $this->id . "_onclick_content_erase"; 
    289      
    290                         if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    291                                 $this->setOnClickContent(null); 
    292                                 $content->delete($errmsg); 
    293                         } else { 
    294                                 $content->processAdminUI(); 
    295                         } 
    296                 } 
    297         } 
    298     } 
    299  
    300        /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing. 
    301       * @return The HTML fragment for this interface */ 
    302        public function getUserUI() { 
     265        $db=AbstractDb::getObject(); 
     266        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
     267            parent :: processAdminUI(); 
     268 
     269            /*display_num_items*/ 
     270            $name = "shoutbox_{this->getId()}_display_num_items"; 
     271            $this->setDisplayNumItems($_REQUEST[$name]); 
     272 
     273            /*max_shout_chars*/ 
     274            $name = "shoutbox_{this->getId()}_max_num_chars"; 
     275            $this->setMaxShoutChars($_REQUEST[$name]); 
     276 
     277            /*shout_field_size*/ 
     278            $name = "shoutbox_{this->getId()}_shout_field_size"; 
     279            $this->setShoutFieldSize($_REQUEST[$name]); 
     280 
     281            /* OnclickContent */ 
     282            $content = $this->getOnClickContent(); 
     283            if (!$content) { 
     284                $name = "shoutbox_" . $this->id . "_onclick_content_new"; 
     285                $content = self :: processNewContentUI($name); 
     286                $this->setOnClickContent($content); 
     287            } else { 
     288                $name = "shoutbox_" . $this->id . "_onclick_content_erase"; 
     289 
     290                if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
     291                    $this->setOnClickContent(null); 
     292                    $content->delete($errmsg); 
     293                } else { 
     294                    $content->processAdminUI(); 
     295                } 
     296            } 
     297        } 
     298    } 
     299 
     300    /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing. 
     301     * @return The HTML fragment for this interface */ 
     302    public function getUserUI() { 
    303303        $real_node = Node::getCurrentRealNode();//For production 
    304304        //$real_node = Node::getCurrentNode();//For testing 
     
    306306        $formHtml = null; 
    307307        if($real_node) { 
    308                 $formHtml .= "<form action='".BASE_URL_PATH."content/ShoutBox/add_message.php'>\n"; 
    309                 $formHtml .= "<input type='hidden' name='shoutbox_id' value='".$this->getId()."'/>\n"; 
    310                 //$html .= "destination_url: ";pretty_print_r($_SERVER); 
    311                 $maxShoutChars = $this->getMaxShoutChars(); 
    312                 $shoutFieldSize = $this->getShoutFieldSize(); 
    313                 if($maxShoutChars>0) { 
    314                     $max_size = "maxlength='$maxShoutChars'"; 
    315                     $maxShoutChars<=$shoutFieldSize?$size="size='$maxShoutChars'":$size="size='$shoutFieldSize'"; 
    316                 } 
    317                 else { 
    318                     $max_size = null; 
    319                     $size = "size='$shoutFieldSize'"; 
    320                 } 
    321                 $formHtml .= "<input type='hidden' name='node_id' value='".$node->getId()."'/>\n"; 
    322                 $formHtml .= "<input type='text' name='shout_text' id='shout_text' $size $max_size value=''/>\n"; 
    323                 $onclick_content = $this->getOnClickContent(); 
    324                 if($onclick_content){ 
    325                         $onclick="onclick=\"".$onclick_content->getString()."\""; 
    326                 } else 
    327                 { 
    328                         $onclick = null; 
    329                 } 
    330                 $formHtml .= "<input type='submit' name='shout_submit' $onclick value='"._("Shout!")."'>\n"; 
    331                 $formHtml .= "</form>\n"; 
     308            $formHtml .= "<form action='".BASE_URL_PATH."content/ShoutBox/add_message.php'>\n"; 
     309            $formHtml .= "<input type='hidden' name='shoutbox_id' value='".$this->getId()."'/>\n"; 
     310            //$html .= "destination_url: ";pretty_print_r($_SERVER); 
     311            $maxShoutChars = $this->getMaxShoutChars(); 
     312            $shoutFieldSize = $this->getShoutFieldSize(); 
     313            if($maxShoutChars>0) { 
     314                $max_size = "maxlength='$maxShoutChars'"; 
     315                $maxShoutChars<=$shoutFieldSize?$size="size='$maxShoutChars'":$size="size='$shoutFieldSize'"; 
     316            } 
     317            else { 
     318                $max_size = null; 
     319                $size = "size='$shoutFieldSize'"; 
     320            } 
     321            $formHtml .= "<input type='hidden' name='node_id' value='".$node->getId()."'/>\n"; 
     322            $formHtml .= "<input type='text' name='shout_text' id='shout_text' $size $max_size value=''/>\n"; 
     323            $onclick_content = $this->getOnClickContent(); 
     324            if($onclick_content){ 
     325                $onclick="onclick=\"".$onclick_content->getString()."\""; 
     326            } else 
     327            { 
     328                $onclick = null; 
     329            } 
     330            $formHtml .= "<input type='submit' name='shout_submit' $onclick value='"._("Shout!")."'>\n"; 
     331            $formHtml .= "</form>\n"; 
    332332        } 
    333333        else 
     
    360360                    $content = Content::getObject($row['message_content_id']); 
    361361                    $html_main .= "<li>"; 
    362                     $html_main .= $user->getListUI().": \n"; 
    363362                    $dateStr = "<span class='date'>".strftime('%x', $row['creation_date_php'])."</span>\n"; 
     363                    $html_main .= $dateStr.' '. $user->getListUI().": \n"; 
    364364                    $html_main .= "<div class='message'>".$content->getListUI()."$dateStr</div>\n"; 
    365365                    $html_main .= "</li>"; 
     
    372372            $html_main .= "<p>"._("Sorry, I am unable to determine your current node")."</p>\n"; 
    373373        } 
    374          
     374 
    375375        $this->setUserUIMainDisplayContent($html_main); 
    376376        //$this->setUserUIMainInteractionArea($formHtml); 
    377377        return Content :: getUserUI(); 
    378        } 
     378    } 
    379379 
    380380    /** 
     
    387387     * 
    388388     * @return void 
    389      
     389 
    390390     */ 
    391391    private function refresh() { 
    392         $this->__construct($this->id); 
     392        $this->__construct($this->id); 
    393393    } 
    394394}