Show
Ignore:
Timestamp:
12/28/05 19:42:26 (7 years ago)
Author:
max-horvath
Message:

2005-12-28 Max Horvath <max.horvath@…>

  • Removed BASEPATH define from source - resulting in a better require-overview
  • speed improvement of 7% by optimizing Dependencies class
  • improved documentation of content classes
  • added WiFiDog skin to HTMLeditor
  • updated PhpDocumentor? documentation
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php

    r868 r874  
    3838 * @subpackage ContentClasses 
    3939 * @author     Francois Proulx <francois.proulx@gmail.com> 
    40  * @copyright  2005 Francois Proulx <francois.proulx@gmail.com> - Technologies 
    41  * Coeus inc. 
     40 * @copyright  2005 Francois Proulx, Technologies Coeus inc. 
    4241 * @version    CVS: $Id$ 
    4342 * @link       http://sourceforge.net/projects/wifidog/ 
    4443 */ 
    4544 
    46 require_once BASEPATH.'classes/Content.php'; 
    47  
    4845/** 
    4946 * A generic embedded content container 
     47 * 
    5048 * This object supports backward compatiblity fallback 
    5149 * 
     
    5553 * And Macromedia recommendations for backward compatibility 
    5654 * http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701 
    57  * */ 
     55 * 
     56 * @package    WiFiDogAuthServer 
     57 * @subpackage ContentClasses 
     58 * @author     Francois Proulx <francois.proulx@gmail.com> 
     59 * @copyright  2005 Francois Proulx, Technologies Coeus inc. 
     60 */ 
    5861class EmbeddedContent extends Content 
    5962{ 
     63    /** 
     64     * Constructor 
     65     * 
     66     * @param string $content_id Content Id 
     67     * 
     68     * @return void 
     69     * 
     70     * @access protected 
     71     */ 
    6072    protected function __construct($content_id) 
    6173    { 
    62         parent :: __construct($content_id); 
     74        // Define globals 
    6375        global $db; 
     76 
     77        // Init values 
     78        $row = null; 
     79 
     80        parent::__construct($content_id); 
     81 
    6482        $content_id = $db->EscapeString($content_id); 
    6583 
     
    86104    } 
    87105 
     106    /** 
     107     * Returns the attributes of embedded content 
     108     * 
     109     * @return string Attributes of the embedded content 
     110     * 
     111     * @access private 
     112     */ 
     113    private function getAttributes() 
     114    { 
     115        return $this->embedded_content_row['attributes']; 
     116    } 
     117 
     118    /** 
     119     * Sets the attributes of embedded content 
     120     * 
     121     * @param string $attributes_str Attributes of the embedded content 
     122     * 
     123     * @return void 
     124     * 
     125     * @access private 
     126     */ 
     127    private function setAttributes($attributes_str) 
     128    { 
     129        $attributes_str = $this->mBd->EscapeString($attributes_str); 
     130        $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET attributes ='".$attributes_str."' WHERE embedded_content_id='".$this->getId()."'", false); 
     131        $this->refresh(); 
     132    } 
     133 
     134    /** 
     135     * Returns parameters of embedded content 
     136     * 
     137     * @return string Parameters of the embedded content 
     138     * 
     139     * @access private 
     140     */ 
     141    private function getParameters() 
     142    { 
     143        return $this->embedded_content_row['parameters']; 
     144    } 
     145 
     146    /** 
     147     * Sets the parameters of embedded content 
     148     * 
     149     * @param string $paramters_str Parameters of the embedded content 
     150     * 
     151     * @return void 
     152     * 
     153     * @access private 
     154     */ 
     155    private function setParameters($paramters_str) 
     156    { 
     157        $paramters_str = $this->mBd->EscapeString($paramters_str); 
     158        $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET parameters ='".$paramters_str."' WHERE embedded_content_id='".$this->getId()."'", false); 
     159        $this->refresh(); 
     160    } 
     161 
     162    /** 
     163     * Shows the administration interface for embedded content. 
     164     * 
     165     * @param string $subclass_admin_interface HTML code to be added after the 
     166     *                                         administration interface 
     167     * 
     168     * @return string HTML code for the administration interface 
     169     * 
     170     * @access public 
     171     */ 
    88172    public function getAdminUI($subclass_admin_interface = null) 
    89173    { 
     
    95179        $html .= "<div class='admin_section_title'>"._("Embedded content")." : <br></div>\n"; 
    96180        $html .= "<div class='admin_section_data'>\n"; 
    97         if (empty ($this->embedded_content_row['embedded_file_id'])) 
    98         { 
     181 
     182        if (empty ($this->embedded_content_row['embedded_file_id'])) { 
    99183            // Mandate File 
    100184            $html .= self :: getNewContentUI("embedded_file_{$this->id}_new", "File"); 
    101185            $html .= "</div>\n"; 
    102         } 
    103         else 
    104         { 
    105             $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 
     186        } else { 
     187            $embedded_content_file = self::getObject($this->embedded_content_row['embedded_file_id']); 
     188 
    106189            $html .= $embedded_content_file->getAdminUI(); 
     190 
    107191            $html .= "</div>\n"; 
    108192            $html .= "<div class='admin_section_tools'>\n"; 
     
    127211            $html .= "</div>\n"; 
    128212        } 
     213 
    129214        $html .= "</div>\n"; 
    130215 
     
    133218        $html .= "<div class='admin_section_title'>"._("Fallback content (Can be another embedded content to create a fallback hierarchy)")." : <br></div>\n"; 
    134219        $html .= "<div class='admin_section_data'>\n"; 
    135         if (empty ($this->embedded_content_row['fallback_content_id'])) 
    136         { 
    137             $html .= self :: getNewContentUI("fallback_content_{$this->id}_new"); 
    138             $html .= "</div>\n"; 
    139         } 
    140         else 
    141         { 
    142             $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 
     220 
     221        if (empty ($this->embedded_content_row['fallback_content_id'])) { 
     222            $html .= self::getNewContentUI("fallback_content_{$this->id}_new"); 
     223            $html .= "</div>\n"; 
     224        } else { 
     225            $fallback_content = self::getObject($this->embedded_content_row['fallback_content_id']); 
     226 
    143227            $html .= $fallback_content->getAdminUI(); 
     228 
    144229            $html .= "</div>\n"; 
    145230            $html .= "<div class='admin_section_tools'>\n"; 
     
    148233            $html .= "</div>\n"; 
    149234        } 
     235 
    150236        $html .= "</div>\n"; 
    151237 
    152238        $html .= $subclass_admin_interface; 
    153         return parent :: getAdminUI($html); 
    154     } 
    155  
    156     function processAdminUI() 
    157     { 
    158         if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) 
    159         { 
    160             parent :: processAdminUI(); 
    161  
     239 
     240        return parent::getAdminUI($html); 
     241    } 
     242 
     243    /** 
     244     * Processes the input of the administration interface for embedded content 
     245     * 
     246     * @return void 
     247     * 
     248     * @access public 
     249     */ 
     250    public function processAdminUI() 
     251    { 
     252        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
     253            // Define globals 
    162254            global $db; 
    163             if (empty ($this->embedded_content_row['embedded_file_id'])) 
    164             { 
     255 
     256            // Init values 
     257            $errmsg = null; 
     258 
     259            parent::processAdminUI(); 
     260 
     261            if (empty ($this->embedded_content_row['embedded_file_id'])) { 
    165262                $embedded_content_file = self :: processNewContentUI("embedded_file_{$this->id}_new"); 
    166                 if ($embedded_content_file != null) 
    167                 { 
     263 
     264                if ($embedded_content_file != null) { 
    168265                    $embedded_content_file_id = $embedded_content_file->GetId(); 
    169266                    $db->ExecSqlUpdate("UPDATE embedded_content SET embedded_file_id = '$embedded_content_file_id' WHERE embedded_content_id = '$this->id'", FALSE); 
    170                 } 
    171                 else 
    172                 { 
     267                } else { 
    173268                    echo _("You MUST choose a File object or any of its siblings."); 
    174269                    $embedded_content_file->delete($errmsg); 
    175270                } 
    176             } 
    177             else 
    178             { 
     271            } else { 
    179272                $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 
    180273                $name = "embeddedcontent_".$this->id."_embedded_file_erase"; 
    181                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) 
    182                 { 
     274 
     275                if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    183276                    $db->ExecSqlUpdate("UPDATE embedded_content SET embedded_file_id = NULL WHERE embedded_content_id = '$this->id'", FALSE); 
    184277                    $embedded_content_file->delete($errmsg); 
    185                 } 
    186                 else 
    187                 { 
     278                } else { 
    188279                    $embedded_content_file->processAdminUI(); 
    189280 
     
    196287            } 
    197288 
    198             if (empty ($this->embedded_content_row['fallback_content_id'])) 
    199             { 
     289            if (empty ($this->embedded_content_row['fallback_content_id'])) { 
    200290                $fallback_content = self :: processNewContentUI("fallback_content_{$this->id}_new"); 
    201                 if ($fallback_content != null) 
    202                 { 
     291 
     292                if ($fallback_content != null) { 
    203293                    $fallback_content_id = $fallback_content->GetId(); 
    204294                    $db->ExecSqlUpdate("UPDATE embedded_content SET fallback_content_id = '$fallback_content_id' WHERE embedded_content_id = '$this->id'", FALSE); 
    205295                } 
    206             } 
    207             else 
    208             { 
     296            } else { 
    209297                $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 
    210298                $name = "fallback_content_".$this->id."_fallback_content_erase"; 
    211                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) 
    212                 { 
     299 
     300                if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    213301                    $db->ExecSqlUpdate("UPDATE embedded_content SET fallback_content_id = NULL WHERE embedded_content_id = '$this->id'", FALSE); 
    214302                    $fallback_content->delete($errmsg); 
    215                 } 
    216                 else 
    217                 { 
     303                } else { 
    218304                    $fallback_content->processAdminUI(); 
    219305                } 
     
    224310    } 
    225311 
    226     /** 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. 
    227      * @param $subclass_admin_interface Html content of the interface element of a children 
    228      * @return The HTML fragment for this interface */ 
     312    /** 
     313     * Retreives the user interface of this object. 
     314     * 
     315     * @return string The HTML fragment for this interface 
     316     * 
     317     * @access public 
     318     */ 
    229319    public function getUserUI() 
    230320    { 
     321        // Init values 
    231322        $html = ''; 
     323        $embedded_content_file = null; 
     324        $fallback_content = null; 
     325 
    232326        $html .= "<div class='user_ui_container'>\n"; 
    233327        $html .= "<div class='user_ui_object_class'>EmbeddedContent (".get_class($this)." instance)</div>\n"; 
    234328 
    235         $embedded_content_file = null; 
    236         $fallback_content = null; 
    237  
    238329        /* Get both objects if they exist */ 
    239         if (!empty ($this->embedded_content_row['embedded_file_id'])) 
     330        if (!empty ($this->embedded_content_row['embedded_file_id'])) { 
    240331            $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 
    241         if (!empty ($this->embedded_content_row['fallback_content_id'])) 
     332        } 
     333 
     334        if (!empty ($this->embedded_content_row['fallback_content_id'])) { 
    242335            $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 
    243  
    244         /* 
    245          * Example 
    246          * <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="316" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> 
    247             <param name="SRC" value="/sponsors/airborne/400.mov"> 
    248  
    249             <param name="QTNEXT1" value="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>"> 
    250             <param name="AUTOPLAY" value="true"> 
    251             <param name="CONTROLLER" value="true"> 
    252             <embed src="/sponsors/airborne/400.mov" qtnext1="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>" width="400" height="316" align="left" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> 
    253             </embed> 
    254             </object> 
     336        } 
     337 
     338        /** 
     339         * @internal Example: 
    255340         * 
     341         * <samp> 
     342         *     <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="316" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> 
     343         *         <param name="SRC" value="/sponsors/airborne/400.mov"> 
     344         *         <param name="QTNEXT1" value="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>"> 
     345         *         <param name="AUTOPLAY" value="true"> 
     346         *         <param name="CONTROLLER" value="true"> 
     347         *         <embed src="/sponsors/airborne/400.mov" qtnext1="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>" width="400" height="316" align="left" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> 
     348         *         </embed> 
     349         *     </object> 
     350         * </samp> 
    256351         */ 
    257         if ($embedded_content_file != null) 
    258         { 
     352        if ($embedded_content_file != null) { 
    259353            $url = htmlentities($embedded_content_file->getFileUrl()); 
    260354            $mime_type = $embedded_content_file->getMimeType(); 
     
    263357            $html .= "<param name='AUTOPLAY' value='0'>\n"; 
    264358            $html .= "{$this->getParameters()}\n"; 
     359 
    265360            // Spit fallback content between inside the <object> tag 
    266             if ($fallback_content != null) 
     361            if ($fallback_content != null) { 
    267362                $html .= $fallback_content->getUserUI(); 
     363            } 
     364 
    268365            $html .= "<embed autoplay=FALSE src='$url'>\n"; 
    269366            $html .= "<nobembed>\n"; 
     
    274371 
    275372        $html .= "</div>\n"; 
    276         return parent :: getUserUI($html); 
    277     } 
    278  
    279     public function getAttributes() 
    280     { 
    281         return $this->embedded_content_row['attributes']; 
    282     } 
    283  
    284     public function setAttributes($attributes_str) 
    285     { 
    286         $attributes_str = $this->mBd->EscapeString($attributes_str); 
    287         $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET attributes ='".$attributes_str."' WHERE embedded_content_id='".$this->getId()."'", false); 
    288         $this->refresh(); 
    289     } 
    290  
    291     public function getParameters() 
    292     { 
    293         return $this->embedded_content_row['parameters']; 
    294     } 
    295  
    296     public function setParameters($paramters_str) 
    297     { 
    298         $paramters_str = $this->mBd->EscapeString($paramters_str); 
    299         $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET parameters ='".$paramters_str."' WHERE embedded_content_id='".$this->getId()."'", false); 
    300         $this->refresh(); 
    301     } 
    302  
    303     /** Delete this Content from the database 
    304     */ 
    305     public function delete(& $errmsg) 
    306     { 
    307         if ($this->isPersistent() == false) 
    308         { 
    309             if (!empty ($this->embedded_content_row['embedded_file_id'])) 
    310             { 
     373 
     374        return parent::getUserUI($html); 
     375    } 
     376 
     377    /** 
     378     * Reloads the object from the database. Should normally be called after 
     379     * a set operation. This function is private because calling it from a 
     380     * subclass will call the constructor from the wrong scope. 
     381     * 
     382     * @return void 
     383     * 
     384     * @access private 
     385     */ 
     386    private function refresh() 
     387    { 
     388        $this->__construct($this->id); 
     389    } 
     390 
     391    /** 
     392     * Deletes a embedded content object 
     393     * 
     394     * @param string $errmsg Reference to error message 
     395     * 
     396     * @return bool True if deletion was successful 
     397     * 
     398     * @access public 
     399     * @internal Persistent content will not be deleted 
     400     */ 
     401    public function delete(&$errmsg) 
     402    { 
     403        if ($this->isPersistent() == false) { 
     404            if (!empty ($this->embedded_content_row['embedded_file_id'])) { 
    311405                $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 
    312406                $embedded_content_file->delete($errmsg); 
    313407            } 
    314             if (!empty ($this->embedded_content_row['fallback_content_id'])) 
    315             { 
     408 
     409            if (!empty ($this->embedded_content_row['fallback_content_id'])) { 
    316410                $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 
    317411                $fallback_content->delete($errmsg); 
    318412            } 
    319         } 
     413        } else { 
     414            $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 
     415        } 
     416 
    320417        return parent :: delete($errmsg); 
    321418    } 
    322     /** Reloads the object from the database.  Should normally be called after a set operation. 
    323      * This function is private because calling it from a subclass will call the 
    324      * constructor from the wrong scope */ 
    325     private function refresh() 
    326     { 
    327         $this->__construct($this->id); 
    328     } 
     419 
    329420} 
    330421