source-function-tcecodeEditorTagButtons

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_functions_tcecode_editor.php
  4: // Begin       : 2002-02-20
  5: // Last Update : 2013-12-24
  6: //
  7: // Description : TCExam Code Editor (editor for special mark-up
  8: //               code used to add some text formatting)
  9: //
 10: // Author: Nicola Asuni
 11: //
 12: // (c) Copyright:
 13: //               Nicola Asuni
 14: //               Tecnick.com LTD
 15: //               www.tecnick.com
 16: //               info@tecnick.com
 17: //
 18: // License:
 19: //    Copyright (C) 2004-2013 Nicola Asuni - Tecnick.com LTD
 20: //    See LICENSE.TXT file for more information.
 21: //============================================================+
 22: 
 23: /**
 24:  * @file
 25:  * Functions for custom mark-up language editor.
 26:  * @package com.tecnick.tcexam.admin
 27:  * @author Nicola Asuni
 28:  * @since 2002-02-20
 29:  */
 30: 
 31: /**
 32:  * Display TCExam Code EDITOR Tag Buttons
 33:  * @author Nicola Asuni
 34:  * @since 2006-03-07
 35:  * @param $callingform (string) name of calling xhtml form
 36:  * @param $callingfield (string) name of calling form field (textarea where output code will be sent)
 37:  * @return XHTML string
 38:  */
 39: function tcecodeEditorTagButtons($callingform, $callingfield)
 40: {
 41:     global $l, $db;
 42:     global $uploadedfile;
 43:     require_once('../config/tce_config.php');
 44: 
 45:     // sanitize input parameters
 46:     $callingform = preg_replace('/[^a-z0-9_]/', '', $callingform);
 47:     $callingfield = preg_replace('/[^a-z0-9_]/', '', $callingfield);
 48: 
 49:     $buttons = '';
 50: 
 51:     // --- buttons
 52: 
 53:     $onclick = 'FJ_undo(document.getElementById(\''.$callingform.'\').'.$callingfield.')';
 54:     $buttons .= getImageButton($l['w_undo'], '', K_PATH_IMAGES.'buttons/undo.gif', $onclick, 'z');
 55: 
 56:     $onclick = 'FJ_redo(document.getElementById(\''.$callingform.'\').'.$callingfield.')';
 57:     $buttons .= getImageButton($l['w_redo'], '', K_PATH_IMAGES.'buttons/redo.gif', $onclick, 'y');
 58: 
 59:     $onclick = 'FJ_insert_tag(document.getElementById(\''.$callingform.'\').'.$callingfield.'';
 60:     $buttons .= getImageButton('bold', '[b]', K_PATH_IMAGES.'buttons/bold.gif', $onclick, 'b');
 61:     $buttons .= getImageButton('italic', '[i]', K_PATH_IMAGES.'buttons/italic.gif', $onclick, 'i');
 62:     $buttons .= getImageButton('underline', '[u]', K_PATH_IMAGES.'buttons/under.gif', $onclick, 'u');
 63:     $buttons .= getImageButton('strikethrough', '[s]', K_PATH_IMAGES.'buttons/strike.gif', $onclick, 'd');
 64:     $buttons .= getImageButton('small', '[small]', K_PATH_IMAGES.'buttons/small.gif', $onclick, 's');
 65:     $buttons .= getImageButton('subscript', '[sub]', K_PATH_IMAGES.'buttons/subscr.gif', $onclick, 'v');
 66:     $buttons .= getImageButton('superscript', '[sup]', K_PATH_IMAGES.'buttons/superscr.gif', $onclick, 'a');
 67:     $buttons .= getImageButton('link', '[url]', K_PATH_IMAGES.'buttons/link.gif', $onclick, 'k');
 68:     $buttons .= getImageButton('unordered list', '[ulist]', K_PATH_IMAGES.'buttons/bullist.gif', $onclick, 'l');
 69:     $buttons .= getImageButton('ordered list', '[olist]', K_PATH_IMAGES.'buttons/numlist.gif', $onclick, 'o');
 70:     $buttons .= getImageButton('list item', '[li]', K_PATH_IMAGES.'buttons/li.gif', $onclick, 't');
 71:     $buttons .= getImageButton('LRT', '[dir=ltr]', K_PATH_IMAGES.'buttons/ltrdir.gif', $onclick, '');
 72:     $buttons .= getImageButton('RTL', '[dir=rtl]', K_PATH_IMAGES.'buttons/rtldir.gif', $onclick, '');
 73: 
 74:     $onclick = 'window.open(\'tce_colorpicker.php?frm='.$callingform.'&amp;fld='.$callingfield.'&amp;tag=bgcolor\',\'colorpicker\',\'height=550,width=330,resizable=yes,menubar=no,scrollbars=no,toolbar=no,directories=no,status=no,modal=yes\');';
 75:     $buttons .= getImageButton('background-color', '', K_PATH_IMAGES.'buttons/bgcolor.gif', $onclick, '');
 76: 
 77:     $onclick = 'window.open(\'tce_colorpicker.php?frm='.$callingform.'&amp;fld='.$callingfield.'&amp;tag=color\',\'colorpicker\',\'height=550,width=330,resizable=yes,menubar=no,scrollbars=no,toolbar=no,directories=no,status=no,modal=yes\');';
 78:     $buttons .= getImageButton('color', '', K_PATH_IMAGES.'buttons/color.gif', $onclick, '');
 79: 
 80:     $onclick = 'FJ_insert_tag(document.getElementById(\''.$callingform.'\').'.$callingfield.'';
 81:     $buttons .= getImageButton('code', '[code]', K_PATH_IMAGES.'buttons/code.gif', $onclick, 'c');
 82:     $buttons .= getImageButton('latex', '[tex]', K_PATH_IMAGES.'buttons/latex.gif', $onclick, 'm');
 83:     
 84:     $buttons .= getImageButton('mathml', '[mathml]', K_PATH_IMAGES.'buttons/mathml.gif', $onclick, 'h');
 85: 
 86:     $onclick = 'window.open(\'tce_select_mediafile.php?frm='.$callingform.'&amp;fld='.$callingfield.'\',\'mediaselect\',\'height=600,width=680,resizable=yes,menubar=no,scrollbars=yes,toolbar=no,directories=no,status=no,modal=yes\');';
 87:     $buttons .= getImageButton('object', '', K_PATH_IMAGES.'buttons/image.gif', $onclick, '');
 88: 
 89:     $buttons .= '<br />'.K_NEWLINE;
 90: 
 91:     // font size
 92:     $onselect = 'FJ_insert_tag(document.getElementById(\''.$callingform.'\').'.$callingfield.', ';
 93:     $onselect .= 'document.getElementById(\'font_size_'.$callingfield.'\').options[document.getElementById(\'font_size_'.$callingfield.'\').selectedIndex].value';
 94:     $onselect .= ')';
 95:     $buttons .= '<select name="font_size_'.$callingfield.'" id="font_size_'.$callingfield.'" size="0" title="'.$l['w_font_size'].'" style="margin:0;padding:0;" onchange="'.$onselect.'">';
 96:     $buttons .= '<option value="" selected="selected" style="background-color:gray;color:white;">'.$l['w_font_size'].'</option>';
 97:     $buttons .= '<option value="[size=xx-small]">xx-small</option>';
 98:     $buttons .= '<option value="[size=x-small]">x-small</option>';
 99:     $buttons .= '<option value="[size=small]">small</option>';
100:     $buttons .= '<option value="[size=medium]">medium</option>';
101:     $buttons .= '<option value="[size=large]">large</option>';
102:     $buttons .= '<option value="[size=x-large]">x-large</option>';
103:     $buttons .= '<option value="[size=xx-large]">xx-large</option>';
104:     for ($i=10; $i<=400; $i+=10) {
105:         $buttons .= '<option value="[size='.$i.'%]">'.$i.'%</option>';
106:     }
107:     $buttons .= '</select>'.K_NEWLINE;
108: 
109:     // font
110:     $tce_fonts = unserialize(K_AVAILABLE_FONTS);
111:     if (!empty($tce_fonts)) {
112:         $onselect = 'FJ_insert_tag(document.getElementById(\''.$callingform.'\').'.$callingfield.', ';
113:         $onselect .= 'document.getElementById(\'font_'.$callingfield.'\').options[document.getElementById(\'font_'.$callingfield.'\').selectedIndex].value';
114:         $onselect .= ')';
115:         $buttons .= '<select name="font_'.$callingfield.'" id="font_'.$callingfield.'" size="0" title="'.$l['w_font'].'" style="margin:0;padding:0;" onchange="'.$onselect.'">';
116:         $buttons .= '<option value="" selected="selected" style="background-color:gray;color:white;">'.$l['w_font'].'</option>';
117:         foreach ($tce_fonts as $fname => $font) {
118:             $buttons .= '<option value="[font='.$font.']">'.$fname.'</option>';
119:         }
120:         $buttons .= '</select>'.K_NEWLINE;
121:     }
122: 
123:     return $buttons;
124: }
125: 
126: /**
127:  * Display one tag button
128:  * @param $name (string) name of the button
129:  * @param $tag (string) tag value
130:  * @param $image (string) image file of button
131:  * @param $onclick (string) default onclick action
132:  * @param $accesskey (string) accesskey: character for keyboard shortcut
133:  * @return XHTML string
134:  * @author Nicola Asuni
135:  * @since 2006-03-07
136:  */
137: function getImageButton($name, $tag, $image, $onclick = '', $accesskey = '')
138: {
139:     if (strlen($tag) > 0) {
140:         $onclick = $onclick.', \''.$tag.'\')';
141:     }
142:     $str = '<a href="#" onclick="'.$onclick.'" title="'.$name.' ['.$accesskey.']" accesskey="'.$accesskey.'">';
143:     $str .= '<img src="'.$image.'" alt="'.$name.' ['.$accesskey.']" class="button" width="23" height="22" />';
144:     $str .= '</a>';
145:     return $str;
146: }
147: 
148: //============================================================+
149: // END OF FILE
150: //============================================================+
151: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy