source: temp/test-xoops.ec-cube.net/html/include/xoopscodes.php @ 405

Revision 405, 8.3 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: xoopscodes.php,v 1.5 2006/05/01 02:37:26 onokazu Exp $
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.xoops.org/ http://jp.xoops.org/  http://www.myweb.ne.jp/  //
29// Project: The XOOPS Project (http://www.xoops.org/)                        //
30// ------------------------------------------------------------------------- //
31
32/*
33*  displayes xoopsCode buttons and target textarea to which xoopscodes are inserted
34*  $textarea_id is a unique id of the target textarea
35*/
36function xoopsCodeTarea($textarea_id, $cols=60, $rows=15, $suffix=null)
37{
38    $hiddentext = isset($suffix) ? 'xoopsHiddenText'.trim($suffix) : 'xoopsHiddenText';
39    //Hack for url, email ...., the anchor is for having a link on [_More...]
40    echo "<a name='moresmiley'></a><img src='".XOOPS_URL."/images/url.gif' alt='url' onmouseover='style.cursor=\"hand\"' onclick='xoopsCodeUrl(\"$textarea_id\", \"".htmlspecialchars(_ENTERURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."\");'/>&nbsp;<img src='".XOOPS_URL."/images/email.gif' alt='email' onmouseover='style.cursor=\"hand\"' onclick='xoopsCodeEmail(\"$textarea_id\", \"".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."\");' />&nbsp;<img src='".XOOPS_URL."/images/imgsrc.gif' alt='imgsrc' onmouseover='style.cursor=\"hand\"' onclick='xoopsCodeImg(\"$textarea_id\", \"".htmlspecialchars(_ENTERIMGURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES)."\", \"".htmlspecialchars(_IMGPOSRORL, ENT_QUOTES)."\", \"".htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES)."\");' />&nbsp;<img src='".XOOPS_URL."/images/image.gif' alt='image' onmouseover='style.cursor=\"hand\"' onclick='openWithSelfMain(\"".XOOPS_URL."/imagemanager.php?target=".$textarea_id."\",\"imgmanager\",400,430);' />&nbsp;<img src='".XOOPS_URL."/images/code.gif' alt='code' onmouseover='style.cursor=\"hand\"' onclick='xoopsCodeCode(\"$textarea_id\", \"".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."\");' />&nbsp;<img src='".XOOPS_URL."/images/quote.gif' alt='quote' onmouseover='style.cursor=\"hand\"' onclick='xoopsCodeQuote(\"$textarea_id\");'/><br />\n";
41
42    $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
43    echo "<select id='".$textarea_id."Size' onchange='setVisible(\"xoopsHiddenText\");setElementSize(\"".$hiddentext."\",this.options[this.selectedIndex].value);'>\n";
44    echo "<option value='SIZE'>"._SIZE."</option>\n";
45    foreach ( $sizearray as $size ) {
46        echo "<option value='$size'>$size</option>\n";
47    }
48    echo "</select>\n";
49
50    $fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
51    echo "<select id='".$textarea_id."Font' onchange='setVisible(\"xoopsHiddenText\");setElementFont(\"".$hiddentext."\",this.options[this.selectedIndex].value);'>\n";
52    echo "<option value='FONT'>"._FONT."</option>\n";
53    foreach ( $fontarray as $font ) {
54        echo "<option value='$font'>$font</option>\n";
55    }
56    echo "</select>\n";
57
58    $colorarray = array("00", "33", "66", "99", "CC", "FF");
59    echo "<select id='".$textarea_id."Color' onchange='setVisible(\"xoopsHiddenText\");setElementColor(\"".$hiddentext."\",this.options[this.selectedIndex].value);'>\n";
60    echo "<option value='COLOR'>"._COLOR."</option>\n";
61    foreach ( $colorarray as $color1 ) {
62        foreach ( $colorarray as $color2 ) {
63            foreach ( $colorarray as $color3 ) {
64                echo "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>\n";
65            }
66        }
67    }
68    echo "</select><span id='".$hiddentext."'>"._EXAMPLE."</span>\n";
69
70    echo "<br />\n";
71    //Hack smilies move for bold, italic ...
72    $areacontent = isset( $GLOBALS[$textarea_id] ) ? $GLOBALS[$textarea_id] : '';
73    echo "<img src='".XOOPS_URL."/images/bold.gif' alt='bold' onmouseover='style.cursor=\"hand\"' onclick='setVisible(\"".$hiddentext."\");makeBold(\"".$hiddentext."\");' />&nbsp;<img src='".XOOPS_URL."/images/italic.gif' alt='italic' onmouseover='style.cursor=\"hand\"' onclick='setVisible(\"".$hiddentext."\");makeItalic(\"".$hiddentext."\");' />&nbsp;<img src='".XOOPS_URL."/images/underline.gif' alt='underline' onmouseover='style.cursor=\"hand\"' onclick='setVisible(\"".$hiddentext."\");makeUnderline(\"".$hiddentext."\");'/>&nbsp;<img src='".XOOPS_URL."/images/linethrough.gif' alt='linethrough' onmouseover='style.cursor=\"hand\"' onclick='setVisible(\"".$hiddentext."\");makeLineThrough(\"".$hiddentext."\");' />&nbsp;<input type='text' id='".$textarea_id."Addtext' size='20' />&nbsp;<input type='button' onclick='xoopsCodeText(\"$textarea_id\", \"".$hiddentext."\", \"".htmlspecialchars(_ENTERTEXTBOX, ENT_QUOTES)."\")' value='"._ADD."' /><br /><br /><textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows'>".$areacontent."</textarea><br />\n";
74    //Fin du hack
75}
76
77/*
78*  Displays smilie image buttons used to insert smilie codes to a target textarea in a form
79* $textarea_id is a unique of the target textarea
80*/
81function xoopsSmilies($textarea_id)
82{
83    $myts =& MyTextSanitizer::getInstance();
84    $smiles = $myts->getSmileys();
85    if (empty($smileys)) {
86        $db =& Database::getInstance();
87        if ($result = $db->query('SELECT * FROM '.$db->prefix('smiles').' WHERE display=1')) {
88            while ($smiles = $db->fetchArray($result)) {
89            //hack smilies move for the smilies !!
90                echo "<img src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles['smile_url'])."' border='0' onmouseover='style.cursor=\"hand\"' alt='' onclick='xoopsCodeSmilie(\"".$textarea_id."\", \" ".$smiles['code']." \");' />";
91            //fin du hack
92            }
93        }
94    } else {
95        $count = count($smiles);
96        for ($i = 0; $i < $count; $i++) {
97            if ($smiles[$i]['display'] == 1) {
98            //hack bis
99                echo "<img src='".XOOPS_UPLOAD_URL."/".$myts->oopsHtmlSpecialChars($smiles['smile_url'])."' border='0' alt='' onclick='xoopsCodeSmilie(\"".$textarea_id."\", \" ".$smiles[$i]['code']." \");' onmouseover='style.cursor=\"hand\"' />";
100            //fin du hack
101            }
102        }
103    }
104    //hack for more
105    echo "&nbsp;[<a href='#moresmiley' onmouseover='style.cursor=\"hand\"' alt='' onclick='openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&amp;type=smilies&amp;target=".$textarea_id."\",\"smilies\",300,475);'>"._MORE."</a>]";
106}  //fin du hack
107?>
Note: See TracBrowser for help on using the repository browser.