home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / xoopsform / formdhtmltextarea.php < prev    next >
Encoding:
PHP Script  |  2008-01-26  |  10.8 KB  |  201 lines

  1. <?php
  2. // $Id: formdhtmltextarea.php 1276 2008-01-26 06:31:31Z phppp $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27. // Author: Kazumi Ono (AKA onokazu)                                          //
  28. // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
  29. // Project: The XOOPS Project                                                //
  30. // ------------------------------------------------------------------------- //
  31. if (!defined('XOOPS_ROOT_PATH')) {
  32.     die("XOOPS root path not defined");
  33. }
  34. /**
  35.  *
  36.  *
  37.  * @package     kernel
  38.  * @subpackage  form
  39.  *
  40.  * @author        Kazumi Ono    <onokazu@xoops.org>
  41.  * @copyright    copyright (c) 2000-2003 XOOPS.org
  42.  */
  43. /**
  44.  * base class
  45.  */
  46. include_once XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php";
  47.  
  48. // Make sure you have included /include/xoopscodes.php, otherwise DHTML will not work properly!
  49.  
  50. /**
  51.  * A textarea with xoopsish formatting and smilie buttons
  52.  *
  53.  * @author    Kazumi Ono    <onokazu@xoops.org>
  54.  * @copyright    copyright (c) 2000-2003 XOOPS.org
  55.  *
  56.  * @package     kernel
  57.  * @subpackage  form
  58.  */
  59. class XoopsFormDhtmlTextArea extends XoopsFormTextArea {
  60.     /**
  61.     * Extended HTML editor definition
  62.     *
  63.     * Set this property value if you want the editor to delegate rendering to an external class.
  64.     * 
  65.     * Note: this functionality is experimental, but feedback is welcome.
  66.     * Note: the PM window doesn't use XoopsFormDhtmlTextArea, so no need to report it doesn't work here
  67.     * 
  68.     * array( 'bundleId' ): For XOS components (2.3+)
  69.     * array( 'className', 'classPath' ):  To create an instance of "className", declared in the file XOOPS_ROOT_PATH . $classPath
  70.     * 
  71.     * Example:
  72.     * $htmlEditor = array( 'XoopsFormTinyeditorTextArea', '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' );
  73.     */
  74.     var $htmlEditor = array();
  75.  
  76.     /**
  77.      * Hidden text
  78.      * @var    string
  79.      * @access    private
  80.      */
  81.     var $_hiddenText;
  82.  
  83.     /**
  84.      * Constructor
  85.      *
  86.      * @param    string  $caption    Caption
  87.      * @param    string  $name       "name" attribute
  88.      * @param    string  $value      Initial text
  89.      * @param    int     $rows       Number of rows
  90.      * @param    int     $cols       Number of columns
  91.      * @param    string  $hiddentext Hidden Text
  92.      */
  93.     function XoopsFormDhtmlTextArea($caption, $name, $value, $rows=5, $cols=50, $hiddentext="xoopsHiddenText", $options = array() )
  94.     {
  95.         $this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
  96.         $this->_hiddenText = $hiddentext;
  97.         
  98.         if ( !empty( $this->htmlEditor ) ) {
  99.             $options['name'] = $this->_name;
  100.             $options['value'] = $this->_value;
  101.             
  102.             if ( count( $this->htmlEditor ) == 1 ) {
  103.                 $this->htmlEditor = XOS::create( $this->htmlEditor[0] );
  104.             } else {
  105.                 list( $class, $path ) = $this->htmlEditor;
  106.                 include_once XOOPS_ROOT_PATH . $path;
  107.                 if ( class_exists( $class ) ) {
  108.                     $this->htmlEditor = new $class( $options );
  109.                 } else {
  110.                     $this->htmlEditor = false;
  111.                 }
  112.             }
  113.         }
  114.     }
  115.  
  116.     /**
  117.      * Prepare HTML for output
  118.      *
  119.      * @return    string  HTML
  120.      */
  121.     function render()
  122.     {
  123.         $editor = false;
  124.         if ( $this->htmlEditor && is_object( $this->htmlEditor ) ) {
  125.             if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) {
  126.                 $editor = true;
  127.             }
  128.         }
  129.         if ( $editor ) {
  130.             return $this->htmlEditor->render();
  131.         }
  132.         
  133.         $ele_name = $this->getName();
  134.         $ret = "<a name='moresmiley'></a>".
  135.                 "<img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/url.gif' alt='url' onclick='xoopsCodeUrl(\"".$ele_name."\", \"".htmlspecialchars(_ENTERURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."\");' /> ".
  136.                 "<img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/email.gif' alt='email' onclick='javascript:xoopsCodeEmail(\"".$ele_name."\", \"".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."\");' /> ".
  137.                 "<img onclick='javascript:xoopsCodeImg(\"".$ele_name."\", \"".htmlspecialchars(_ENTERIMGURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES)."\", \"".htmlspecialchars(_IMGPOSRORL, ENT_QUOTES)."\", \"".htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/imgsrc.gif' alt='imgsrc' /> ".
  138.                 "<img onmouseover='style.cursor=\"hand\"' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/imagemanager.php?target=".$ele_name."\",\"imgmanager\",400,430);' src='".XOOPS_URL."/images/image.gif' alt='image' /> ".
  139.                 "<img src='".XOOPS_URL."/images/code.gif' onmouseover='style.cursor=\"hand\"' alt='code' onclick='javascript:xoopsCodeCode(\"".$ele_name."\", \"".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."\");' /> ".
  140.                 "<img onclick='javascript:xoopsCodeQuote(\"".$ele_name."\", \"".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/quote.gif' alt='quote' /><br />\n";
  141.  
  142.         $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
  143.         $ret .= "<select id='".$ele_name."Size' onchange='setVisible(\"".$this->_hiddenText."\");setElementSize(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
  144.         $ret .= "<option value='SIZE'>"._SIZE."</option>\n";
  145.         foreach ( $sizearray as $size ) {
  146.             $ret .=  "<option value='$size'>$size</option>\n";
  147.         }
  148.         $ret .= "</select>\n";
  149.         $fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
  150.         $ret .= "<select id='".$ele_name."Font' onchange='setVisible(\"".$this->_hiddenText."\");setElementFont(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
  151.         $ret .= "<option value='FONT'>"._FONT."</option>\n";
  152.         foreach ( $fontarray as $font ) {
  153.             $ret .= "<option value='$font'>$font</option>\n";
  154.         }
  155.         $ret .= "</select>\n";
  156.         $colorarray = array("00", "33", "66", "99", "CC", "FF");
  157.         $ret .= "<select id='".$ele_name."Color' onchange='setVisible(\"".$this->_hiddenText."\");setElementColor(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
  158.         $ret .= "<option value='COLOR'>"._COLOR."</option>\n";
  159.         foreach ( $colorarray as $color1 ) {
  160.             foreach ( $colorarray as $color2 ) {
  161.                 foreach ( $colorarray as $color3 ) {
  162.                     $ret .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>\n";
  163.                 }
  164.             }
  165.         }
  166.         $ret .= "</select><span id='".$this->_hiddenText."'>"._EXAMPLE."</span>\n";
  167.         $ret .= "<br />\n";
  168.         $ret .= "<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeBold(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/bold.gif' alt='bold' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeItalic(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/italic.gif' alt='italic' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeUnderline(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/underline.gif' alt='underline' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeLineThrough(\"".$this->_hiddenText."\");' src='".XOOPS_URL."/images/linethrough.gif' alt='linethrough' onmouseover='style.cursor=\"hand\"' />  <input type='text' id='".$ele_name."Addtext' size='20' /> <input type='button' onclick='xoopsCodeText(\"".$ele_name."\", \"".$this->_hiddenText."\", \"".htmlspecialchars(_ENTERTEXTBOX, ENT_QUOTES)."\")' class='formButton' value='"._ADD."' /><br /><br /><textarea id='".$ele_name."' name='".$ele_name."' onselect=\"xoopsSavePosition('".$ele_name."');\" onclick=\"xoopsSavePosition('".$ele_name."');\" onkeyup=\"xoopsSavePosition('".$ele_name."');\" cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea><br />\n";
  169.         $ret .= $this->_renderSmileys();
  170.         return $ret;
  171.     }
  172.  
  173.     function renderValidationJS() {
  174.         if ( $this->htmlEditor && is_object( $this->htmlEditor ) && method_exists( $this->htmlEditor, "renderValidationJS" ) ) {
  175.             if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) {
  176.                 return $this->htmlEditor->renderValidationJS();
  177.             }
  178.         }
  179.         return '';        
  180.     }
  181.  
  182.     /**
  183.      * prepare HTML for output of the smiley list.
  184.      *
  185.      * @return    string HTML
  186.      */
  187.     function _renderSmileys()
  188.     {
  189.         $myts =& MyTextSanitizer::getInstance();
  190.         $smiles = $myts->getSmileys( false );
  191.         $ret = '';
  192.         $count = count($smiles);
  193.         $ele_name = $this->getName();
  194.         for ($i = 0; $i < $count; $i++) {
  195.             $ret .= "<img onclick='xoopsCodeSmilie(\"".$ele_name."\", \" ".$smiles[$i]['code']." \");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles[$i]['smile_url'], ENT_QUOTES)."' border='0' alt='' />";
  196.         }
  197.         $ret .= " [<a href='#moresmiley' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&type=smilies&target=".$ele_name."\",\"smilies\",300,475);'>"._MORE."</a>]";
  198.         return $ret;
  199.     }
  200. }
  201. ?>