[ Index ] |
|
Code source de Claroline 188 |
1 <?php // $Id: class.wiki2xhtmlarea.php,v 1.18 2006/10/16 07:12:19 moosh Exp $ 2 if ( count( get_included_files() ) == 1 ) die( '---' ); 3 // vim: expandtab sw=4 ts=4 sts=4: 4 5 /** 6 * CLAROLINE 7 * 8 * @version 1.8 $Revision: 1.18 $ 9 * 10 * @copyright 2001-2006 Universite catholique de Louvain (UCL) 11 * 12 * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE 13 * This program is under the terms of the GENERAL PUBLIC LICENSE (GPL) 14 * as published by the FREE SOFTWARE FOUNDATION. The GPL is available 15 * through the world-wide-web at http://www.gnu.org/copyleft/gpl.html 16 * 17 * @author Frederic Minne <zefredz@gmail.com> 18 * 19 * @package Wiki2xhtmlArea 20 */ 21 22 require_once dirname(__FILE__) . "/lib.javascript.php"; 23 24 /** 25 * Wiki2xhtml editor textarea 26 */ 27 class Wiki2xhtmlArea 28 { 29 var $content; 30 var $attributeList; 31 32 /** 33 * Constructor 34 * @param string content of the area 35 * @param string name name of the area 36 * @param int cols number of cols 37 * @param int rows number of rows 38 * @param array extraAttributes extra html attributes for the area 39 */ 40 function Wiki2xhtmlArea( 41 $content = '' 42 , $name = 'content' 43 , $cols = 80 44 , $rows = 30 45 , $extraAttributes = null ) 46 { 47 $this->setContent( $content ); 48 49 $attributeList = array(); 50 $attributeList['name'] = $name; 51 $attributeList['id' ] = $name; 52 $attributeList['cols'] = $cols; 53 $attributeList['rows'] = $rows; 54 55 $this->attributeList = ( is_array( $extraAttributes ) ) 56 ? array_merge( $attributeList, $extraAttributes ) 57 : $attributeList 58 ; 59 } 60 61 /** 62 * Set area content 63 * @param string content 64 */ 65 function setContent( $content ) 66 { 67 $this->content = $content; 68 } 69 70 /** 71 * Get area content 72 * @return string area content 73 */ 74 function getContent() 75 { 76 return $this->content; 77 } 78 79 /** 80 * Get area wiki syntax toolbar 81 * @return string toolbar javascript code 82 */ 83 function getToolbar() 84 { 85 $toolbar = ''; 86 87 88 $toolbar .= '<script type="text/javascript" src="' 89 .document_web_path().'/lib/javascript/toolbar.js"></script>' 90 . "\n" 91 ; 92 $toolbar .= "<script type=\"text/javascript\">if (document.getElementById) { 93 var tb = new dcToolBar(document.getElementById('".$this->attributeList['id']."'), 94 'wiki','".document_web_path()."/toolbar/'); 95 96 tb.btStrong('".get_lang('Bold')."'); 97 tb.btEm('".get_lang('Italic')."'); 98 tb.btIns('".get_lang('Underline')."'); 99 tb.btDel('".get_lang('Strike')."'); 100 tb.btQ('".get_lang('Inline quote')."'); 101 tb.btCode('".get_lang('Code')."'); 102 tb.addSpace(10); 103 tb.btBr('".get_lang('Line break')."'); 104 tb.addSpace(10); 105 tb.btBquote('".get_lang('Blockquote')."'); 106 tb.btPre('".get_lang('Preformated text')."'); 107 tb.btList('".get_lang('Unordered list')."','ul'); 108 tb.btList('".get_lang('Ordered list')."','ol'); 109 tb.addSpace(10); 110 tb.btLink('".get_lang('External link')."','".get_lang('URL?') 111 . "','".get_lang('Language')."','" . $GLOBALS['iso639_1_code']."'); 112 tb.btImgLink('".get_lang('External image')."','".get_lang('URL')."'); 113 tb.draw(''); 114 } 115 </script>\n"; 116 117 return $toolbar; 118 } 119 120 /** 121 * paint (ie echo) area 122 */ 123 function paint() 124 { 125 echo $this->toHTML(); 126 } 127 128 /** 129 * get area html code for string inclusion 130 * @return string area html code 131 */ 132 function toHTML() 133 { 134 $wikiarea = ''; 135 136 $attr = ''; 137 138 foreach( $this->attributeList as $attribute => $value ) 139 { 140 $attr .= ' ' . $attribute . '="' . $value . '"'; 141 } 142 143 $wikiarea .= '<textarea'.$attr.'>'.$this->getContent().'</textarea>' . "\n"; 144 145 $wikiarea .= $this->getToolbar(); 146 147 return $wikiarea; 148 } 149 } 150 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 14:38:42 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |