| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|---|
| 4 | |
|---|
| 5 | // +-------------------------------------------------------------------+ |
|---|
| 6 | // | WiFiDog Authentication Server | |
|---|
| 7 | // | ============================= | |
|---|
| 8 | // | | |
|---|
| 9 | // | The WiFiDog Authentication Server is part of the WiFiDog captive | |
|---|
| 10 | // | portal suite. | |
|---|
| 11 | // +-------------------------------------------------------------------+ |
|---|
| 12 | // | PHP version 5 required. | |
|---|
| 13 | // +-------------------------------------------------------------------+ |
|---|
| 14 | // | Homepage: http://www.wifidog.org/ | |
|---|
| 15 | // | Source Forge: http://sourceforge.net/projects/wifidog/ | |
|---|
| 16 | // +-------------------------------------------------------------------+ |
|---|
| 17 | // | This program is free software; you can redistribute it and/or | |
|---|
| 18 | // | modify it under the terms of the GNU General Public License as | |
|---|
| 19 | // | published by the Free Software Foundation; either version 2 of | |
|---|
| 20 | // | the License, or (at your option) any later version. | |
|---|
| 21 | // | | |
|---|
| 22 | // | This program is distributed in the hope that it will be useful, | |
|---|
| 23 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 24 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|---|
| 25 | // | GNU General Public License for more details. | |
|---|
| 26 | // | | |
|---|
| 27 | // | You should have received a copy of the GNU General Public License | |
|---|
| 28 | // | along with this program; if not, contact: | |
|---|
| 29 | // | | |
|---|
| 30 | // | Free Software Foundation Voice: +1-617-542-5942 | |
|---|
| 31 | // | 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
|---|
| 32 | // | Boston, MA 02111-1307, USA gnu@gnu.org | |
|---|
| 33 | // | | |
|---|
| 34 | // +-------------------------------------------------------------------+ |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * @package WiFiDogAuthServer |
|---|
| 38 | * @subpackage ContentClasses |
|---|
| 39 | * @author Max Horvath <max.horvath@maxspot.de> |
|---|
| 40 | * @copyright 2005-2006 Max Horvath, maxspot GmbH |
|---|
| 41 | * @version Subversion $Id$ |
|---|
| 42 | * @link http://www.wifidog.org/ |
|---|
| 43 | * @todo Add CSS styles for editors. |
|---|
| 44 | */ |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * Load required classes |
|---|
| 48 | */ |
|---|
| 49 | require_once('classes/Content/Langstring/Langstring.php'); |
|---|
| 50 | |
|---|
| 51 | /** |
|---|
| 52 | * FCKeditor implementation |
|---|
| 53 | * |
|---|
| 54 | * @package WiFiDogAuthServer |
|---|
| 55 | * @subpackage ContentClasses |
|---|
| 56 | * @author Max Horvath <max.horvath@maxspot.de> |
|---|
| 57 | * @copyright 2005-2006 Max Horvath, maxspot GmbH |
|---|
| 58 | */ |
|---|
| 59 | class HTMLeditor extends Langstring |
|---|
| 60 | { |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * HTML allowed to be used |
|---|
| 64 | */ |
|---|
| 65 | const ALLOWED_HTML_TAGS = "<p><div><pre><address><h1><h2><h3><h4><h5><h6><br><b><strong><i><em><u><span><ol><ul><li><a><img><embed><table><tbody><thead><th><tr><td><hr>"; |
|---|
| 66 | |
|---|
| 67 | /** |
|---|
| 68 | * Defines if the FCKeditor library has been installed |
|---|
| 69 | * |
|---|
| 70 | * @var bool |
|---|
| 71 | * @access private |
|---|
| 72 | */ |
|---|
| 73 | private $_FCKeditorAvailable = false; |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * Constructor. |
|---|
| 77 | * |
|---|
| 78 | * @param int $content_id ID of content. |
|---|
| 79 | * |
|---|
| 80 | * @return void |
|---|
| 81 | * |
|---|
| 82 | * @access protected |
|---|
| 83 | */ |
|---|
| 84 | protected function __construct($content_id) |
|---|
| 85 | { |
|---|
| 86 | parent::__construct($content_id); |
|---|
| 87 | |
|---|
| 88 | // Check FCKeditor support |
|---|
| 89 | if (Dependencies::check("FCKeditor")) { |
|---|
| 90 | // Define globals |
|---|
| 91 | global $db; |
|---|
| 92 | |
|---|
| 93 | // Load FCKeditor class |
|---|
| 94 | require_once('lib/FCKeditor/fckeditor.php'); |
|---|
| 95 | |
|---|
| 96 | $this->mBd = &$db; |
|---|
| 97 | |
|---|
| 98 | $this->_FCKeditorAvailable = true; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * Shows the administration interface for HTMLeditor. |
|---|
| 104 | * |
|---|
| 105 | * @param string $type_interface SIMPLE for a small HTML editor, LARGE |
|---|
| 106 | * for a larger HTML editor (default). |
|---|
| 107 | * @param int $num_nouveau Number of new HTML editors to be created. |
|---|
| 108 | * |
|---|
| 109 | * @return string HTML code for the administration interface. |
|---|
| 110 | * |
|---|
| 111 | * @access public |
|---|
| 112 | */ |
|---|
| 113 | public function getAdminUI($type_interface = 'LARGE') |
|---|
| 114 | { |
|---|
| 115 | if ($this->_FCKeditorAvailable) { |
|---|
| 116 | // Init values |
|---|
| 117 | $_result = null; |
|---|
| 118 | $_html = ''; |
|---|
| 119 | $_languages = new LocaleList(); |
|---|
| 120 | $html .= "<ul class='admin_element_list'>\n"; |
|---|
| 121 | |
|---|
| 122 | $_html .= "<li class='admin_element_item_container content_html_editor'>\n"; |
|---|
| 123 | |
|---|
| 124 | $_html .= "<ul class='admin_element_list'>\n"; |
|---|
| 125 | |
|---|
| 126 | $_sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '$this->id' ORDER BY locales_id"; |
|---|
| 127 | $this->mBd->execSql($_sql, $_result, FALSE); |
|---|
| 128 | |
|---|
| 129 | // Show existing content |
|---|
| 130 | if ($_result != null) { |
|---|
| 131 | while (list($_key, $_value) = each($_result)) { |
|---|
| 132 | $_html .= "<li class='admin_element_item_container'>\n"; |
|---|
| 133 | $_html .= "<div class='admin_element_data'>\n"; |
|---|
| 134 | $_html .= _("Language") . ": " . $_languages->GenererFormSelect($_value["locales_id"], "langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_language", 'Langstring::AfficherInterfaceAdmin', TRUE); |
|---|
| 135 | |
|---|
| 136 | $_FCKeditor = new FCKeditor('langstrings_' . $this->id . '_substring_' . $_value["langstring_entries_id"] . '_string'); |
|---|
| 137 | $_FCKeditor->BasePath = SYSTEM_PATH . "lib/FCKeditor/"; |
|---|
| 138 | $_FCKeditor->Config["CustomConfigurationsPath"] = BASE_URL_PATH . "js/HTMLeditor.js"; |
|---|
| 139 | $_FCKeditor->Config["AutoDetectLanguage"] = false; |
|---|
| 140 | $_FCKeditor->Config["DefaultLanguage"] = substr(Locale::getCurrentLocale()->getId(), 0, 2); |
|---|
| 141 | $_FCKeditor->Config["StylesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/css/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; |
|---|
| 142 | $_FCKeditor->Config["TemplatesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/templates/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; |
|---|
| 143 | |
|---|
| 144 | $_FCKeditor->ToolbarSet = "WiFiDOG"; |
|---|
| 145 | |
|---|
| 146 | $_FCKeditor->Value = $_value['value']; |
|---|
| 147 | |
|---|
| 148 | if ($type_interface == 'LARGE') { |
|---|
| 149 | $_FCKeditor->Height = 400; |
|---|
| 150 | } else { |
|---|
| 151 | $_FCKeditor->Height = 200; |
|---|
| 152 | } |
|---|
| 153 | $_FCKeditor->Width = 386; |
|---|
| 154 | |
|---|
| 155 | $_html .= $_FCKeditor->CreateHtml(); |
|---|
| 156 | |
|---|
| 157 | $_html .= "</div>\n"; |
|---|
| 158 | $_html .= "<div class='admin_element_tools'>\n"; |
|---|
| 159 | |
|---|
| 160 | $_name = "langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_erase"; |
|---|
| 161 | $_html .= "<input type='submit' class='submit' name='$_name' value='" . _("Delete string") . "'>"; |
|---|
| 162 | |
|---|
| 163 | $_html .= "</div>\n"; |
|---|
| 164 | $_html .= "</li>\n"; |
|---|
| 165 | } |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | // Editor for new content |
|---|
| 169 | $_locale = LocaleList::GetDefault(); |
|---|
| 170 | |
|---|
| 171 | $_html .= "<li class='admin_element_item_container'>\n"; |
|---|
| 172 | $_html .= "<div class='admin_element_data'>\n"; |
|---|
| 173 | |
|---|
| 174 | $_html .= _("Language") . ": " . $_languages->GenererFormSelect($_locale, "langstrings_" . $this->id . "_substring_new_language", 'Langstring::AfficherInterfaceAdmin', TRUE); |
|---|
| 175 | |
|---|
| 176 | $_FCKeditor = new FCKeditor('langstrings_' . $this->id . '_substring_new_string'); |
|---|
| 177 | $_FCKeditor->BasePath = SYSTEM_PATH . "lib/FCKeditor/"; |
|---|
| 178 | $_FCKeditor->Config["CustomConfigurationsPath"] = BASE_URL_PATH . "js/HTMLeditor.js"; |
|---|
| 179 | $_FCKeditor->Config["AutoDetectLanguage"] = false; |
|---|
| 180 | $_FCKeditor->Config["DefaultLanguage"] = substr(Locale::getCurrentLocale()->getId(), 0, 2); |
|---|
| 181 | $_FCKeditor->Config["StylesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/css/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; |
|---|
| 182 | $_FCKeditor->Config["TemplatesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/templates/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; |
|---|
| 183 | $_FCKeditor->ToolbarSet = "WiFiDOG"; |
|---|
| 184 | |
|---|
| 185 | $_FCKeditor->Value = ""; |
|---|
| 186 | |
|---|
| 187 | if ($type_interface == 'LARGE') { |
|---|
| 188 | $_FCKeditor->Height = 400; |
|---|
| 189 | } else { |
|---|
| 190 | $_FCKeditor->Height = 200; |
|---|
| 191 | } |
|---|
| 192 | $_FCKeditor->Width = 386; |
|---|
| 193 | |
|---|
| 194 | $_html .= $_FCKeditor->CreateHtml(); |
|---|
| 195 | |
|---|
| 196 | $_html .= "</div>\n"; |
|---|
| 197 | $_html .= "<div class='admin_element_tools'>\n"; |
|---|
| 198 | |
|---|
| 199 | $_html .= "<input type='submit' class='submit' name='langstrings_" . $this->id . "_add_new_entry' value='" . _("Add new string") . "'>"; |
|---|
| 200 | $_html .= "</div>\n"; |
|---|
| 201 | $_html .= "</li>\n"; |
|---|
| 202 | |
|---|
| 203 | $_html .= "</ul>\n"; |
|---|
| 204 | $_html .= "</li>\n"; |
|---|
| 205 | $_html .= "</ul>\n"; |
|---|
| 206 | } else { |
|---|
| 207 | $_html = ''; |
|---|
| 208 | $_html .= _("FCKeditor is not installed"); |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | return parent :: getAdminUI($_html); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | /** |
|---|
| 215 | * Processes the input of the administration interface for HTMLeditor |
|---|
| 216 | * |
|---|
| 217 | * @return void |
|---|
| 218 | * |
|---|
| 219 | * @access public |
|---|
| 220 | */ |
|---|
| 221 | public function processAdminUI() |
|---|
| 222 | { |
|---|
| 223 | // Check FCKeditor support |
|---|
| 224 | if ($this->_FCKeditorAvailable) { |
|---|
| 225 | return parent::processAdminUI(); |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | /* |
|---|
| 231 | * Local variables: |
|---|
| 232 | * tab-width: 4 |
|---|
| 233 | * c-basic-offset: 4 |
|---|
| 234 | * c-hanging-comment-ender-p: nil |
|---|
| 235 | * End: |
|---|
| 236 | */ |
|---|
| 237 | |
|---|
| 238 | |
|---|