HomeHelpTrac

Changeset 15973 for trunk/templates


Ignore:
Timestamp:
02/10/12 22:38:54 (4 months ago)
Author:
Alexander Trofimov
Message:

Editor object + new WYSIWYG editor

Location:
trunk/templates
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/templates/base/scripts/BxBaseConfig.php

    r15338 r15973  
    5454    var $iTagsMaxFontSize                        = 30; //Maximal font size of tag 
    5555 
    56     var $sTinyMceEditorJS; 
    5756    //var $sCalendarCss; 
    5857 
     
    6160    var $bAllowUnicodeInPreg = false; // allow unicode in regular expressions 
    6261 
    63     var $aTinyMceSelectors = array(); 
    6462 
    6563 
     
    6765        parent::BxDol(); 
    6866 
    69         $anon_mode = getParam('anon_mode'); 
    70  
    71         $this -> bAnonymousMode = $anon_mode; 
    72  
    73         $this -> aTinyMceSelectors = array('group_edit_html', 'story_edit_area', 'classfiedsTextArea', 'blogText', 'comment_textarea', 'form_input_html'); 
    74         $sSelectors = implode('|', $this -> aTinyMceSelectors); 
    75  
    76         $this -> iTinyMceEditorWidthJS = '630px'; 
    77         $this -> sTinyMceEditorJS = ' 
    78 <!-- tinyMCE gz --> 
    79 <script type="text/javascript" src="' . BX_DOL_URL_PLUGINS . 'tiny_mce/tiny_mce_gzip.js"></script> 
    80 <script type="text/javascript"> 
    81     tinyMCE_GZ.init({ 
    82         plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,directionality,fullscreen", 
    83         themes : "advanced", 
    84         languages : "en", 
    85         disk_cache : true, 
    86         debug : false 
    87     }); 
    88  
    89     if (window.attachEvent) 
    90         window.attachEvent( "onload", InitTiny ); 
    91     else 
    92         window.addEventListener( "load", InitTiny, false); 
    93  
    94     function InitTiny() { 
    95         // Notice: The simple theme does not use all options some of them are limited to the advanced theme 
    96         tinyMCE.init({ 
    97             convert_urls : false, 
    98             mode : "specific_textareas", 
    99             theme : "advanced", 
    100  
    101             editor_selector : /(' . $sSelectors . ')/, 
    102  
    103             plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,directionality,fullscreen", 
    104  
    105             theme_advanced_buttons1_add : "fontselect,fontsizeselect", 
    106             theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,image,separator,search,replace,separator", 
    107             theme_advanced_buttons2_add : "separator,insertdate,inserttime,separator,forecolor,backcolor", 
    108             theme_advanced_buttons3_add : "emotions", 
    109             theme_advanced_toolbar_location : "top", 
    110             theme_advanced_toolbar_align : "left", 
    111             theme_advanced_statusbar_location : "bottom", 
    112  
    113             plugi2n_insertdate_dateFormat : "%Y-%m-%d", 
    114             plugi2n_insertdate_timeFormat : "%H:%M:%S", 
    115             theme_advanced_resizing : false, 
    116             theme_advanced_resize_horizontal : false, 
    117  
    118             entity_encoding : "raw", 
    119  
    120             paste_use_dialog : false, 
    121             paste_auto_cleanup_on_paste : true, 
    122             paste_convert_headers_to_strong : false, 
    123             paste_strip_class_attributes : "all", 
    124             paste_remove_spans : false, 
    125             paste_remove_styles : false 
    126         }); 
    127     } 
    128 </script> 
    129 <!-- /tinyMCE -->'; 
    130  
    131         $this -> sTinyMceEditorCompactJS = ' 
    132 <!-- tinyMCE gz --> 
    133 <script type="text/javascript" src="' . BX_DOL_URL_PLUGINS . 'tiny_mce/tiny_mce_gzip.js"></script> 
    134 <script type="text/javascript"> 
    135     tinyMCE_GZ.init({ 
    136         themes : "advanced", 
    137         plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras", 
    138         languages : "en", 
    139         disk_cache : true, 
    140         debug : false 
    141     }); 
    142  
    143     if (window.attachEvent) 
    144         window.attachEvent( "onload", InitTiny ); 
    145     else 
    146         window.addEventListener( "load", InitTiny, false); 
    147  
    148     function InitTiny() { 
    149         tinyMCE.init({ 
    150             convert_urls : false, 
    151             mode : "specific_textareas", 
    152             theme : "advanced", 
    153             plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras", 
    154  
    155             delta_height: -9, // just for correct sizing 
    156  
    157             editor_selector : /(' . $sSelectors . ')/, 
    158  
    159             theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect", 
    160             theme_advanced_buttons2 : "forecolor,backcolor,|,bullist,numlist,|,outdent,indent,|,link,unlink,image,hr,|,sub,sup,|,insertdate,inserttime,|,styleprops", 
    161             theme_advanced_buttons3 : "charmap,emotions,|,cite,abbr,acronym,attribs,|,preview,removeformat", 
    162             theme_advanced_toolbar_location : "top", 
    163             theme_advanced_toolbar_align : "center", 
    164             extended_valid_elements : "a[name|href|title],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", 
    165  
    166             entity_encoding : "raw", 
    167  
    168             paste_use_dialog : false, 
    169             paste_auto_cleanup_on_paste : true, 
    170             paste_convert_headers_to_strong : false, 
    171             paste_strip_class_attributes : "all", 
    172             paste_remove_spans : false, 
    173             paste_remove_styles : false 
    174         }); 
    175     } 
    176 </script>'; 
    177  
    178         $this -> iTinyMceEditorWidthMiniJS = '270px'; 
    179         $this -> sTinyMceEditorMiniJS = ' 
    180 <!-- tinyMCE gz --> 
    181 <script type="text/javascript" src="' . BX_DOL_URL_PLUGINS . 'tiny_mce/tiny_mce_gzip.js"></script> 
    182 <script type="text/javascript"> 
    183     tinyMCE_GZ.init({ 
    184         plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras", 
    185         themes : "advanced", 
    186         languages : "en", 
    187         disk_cache : true, 
    188         debug : false 
    189     }); 
    190  
    191     if (window.attachEvent) 
    192         window.attachEvent( "onload", InitTiny ); 
    193     else 
    194         window.addEventListener( "load", InitTiny, false); 
    195  
    196     function InitTiny() { 
    197         // Notice: The simple theme does not use all options some of them are limited to the advanced theme 
    198         tinyMCE.init({ 
    199             convert_urls : false, 
    200             mode : "specific_textareas", 
    201             theme : "advanced", 
    202  
    203             editor_selector : /(' . $sSelectors . ')/, 
    204  
    205             plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,directionality,fullscreen,visualchars,xhtmlxtras", 
    206  
    207             theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor", 
    208             theme_advanced_buttons2 : "link,unlink,image,hr,insertdate,inserttime,|,charmap,emotions,|,cite,preview,removeformat", 
    209             theme_advanced_buttons3 : "", 
    210             theme_advanced_toolbar_location : "top", 
    211             theme_advanced_toolbar_align : "left", 
    212             theme_advanced_statusbar_location : "bottom", 
    213             theme_advanced_disable : "insertanchor,image,help,anchor,code,styleselect", 
    214             plugi2n_insertdate_dateFormat : "%Y-%m-%d", 
    215             plugi2n_insertdate_timeFormat : "%H:%M:%S", 
    216             theme_advanced_resizing : false, 
    217             theme_advanced_resize_horizontal : false, 
    218  
    219             entity_encoding : "raw", 
    220  
    221             paste_use_dialog : false, 
    222             paste_auto_cleanup_on_paste : true, 
    223             paste_convert_headers_to_strong : false, 
    224             paste_strip_class_attributes : "all", 
    225             paste_remove_spans : false, 
    226             paste_remove_styles : false 
    227         }); 
    228     } 
    229 </script> 
    230 <!-- /tinyMCE -->'; 
    231  
    232         $this -> sTinyMceEditorMicroJS = ' 
    233 <!-- tinyMCE gz --> 
    234 <script type="text/javascript" src="' . BX_DOL_URL_PLUGINS . 'tiny_mce/tiny_mce_gzip.js"></script> 
    235 <script type="text/javascript"> 
    236     tinyMCE_GZ.init({ 
    237         themes : "advanced", 
    238         plugins: "emotions", 
    239         languages : "en", 
    240         disk_cache : true, 
    241         debug : false 
    242         /* , suffix: "_src" //for development only */ 
    243     }); 
    244  
    245     if (window.attachEvent) 
    246         window.attachEvent( "onload", InitTiny ); 
    247     else 
    248         window.addEventListener( "load", InitTiny, false); 
    249  
    250     function InitTiny() { 
    251         tinyMCE.init({ 
    252             convert_urls : false, 
    253             mode : "specific_textareas", 
    254             theme : "advanced", 
    255             plugins: "emotions", 
    256  
    257             delta_height: -9, // just for correct sizing 
    258  
    259             editor_selector : /(' . $sSelectors . ')/, 
    260  
    261             theme_advanced_buttons1 : "bold,italic,underline,strikethrough,link,unlink", 
    262             theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,justifyfull,emotions", 
    263             theme_advanced_buttons3 : "", 
    264             theme_advanced_toolbar_location : "top", 
    265             theme_advanced_toolbar_align : "center", 
    266  
    267             entity_encoding : "raw", 
    268  
    269             paste_use_dialog : false, 
    270             paste_auto_cleanup_on_paste : true, 
    271             paste_convert_headers_to_strong : false, 
    272             paste_strip_class_attributes : "all", 
    273             paste_remove_spans : false, 
    274             paste_remove_styles : false 
    275         }); 
    276     } 
    277 </script> 
    278 <!-- /tinyMCE -->'; 
     67        $this -> bAnonymousMode = getParam('anon_mode');; 
    27968    } 
    28069 
  • trunk/templates/base/scripts/BxBaseFormView.php

    r15947 r15973  
    6060 
    6161    /** 
     62     * Form is added dynamically. 
     63     * @var boolean 
     64     */ 
     65    var $_bDynamicMode = false; 
     66 
     67    /** 
    6268     * Constructor 
    6369     * 
     
    7985     * @return string 
    8086     */ 
    81     function getCode() { 
     87    function getCode($bDynamicMode = false) { 
     88        $this->_bDynamicMode = $bDynamicMode; 
    8289        $this->addCssJs (); 
    8390        return ($this->sCode = $this->genForm()); 
     
    642649    } 
    643650 
    644     function addHtmlEditor($iTinyNum, &$aInput) { 
    645         bx_import('BxTemplConfig'); 
    646         $oTemplConfig = BxTemplConfig::getInstance(); 
    647  
    648         //--- Add TinyMCE initialization code 
    649         if (!$this->_bHtmlEditorAdded && $iTinyNum) { 
    650             switch($iTinyNum) { 
    651                 case 3: 
    652                     $this->_sCodeAdd .= $oTemplConfig->sTinyMceEditorMiniJS; 
    653                     break; 
    654                 case 2: 
    655                     $this->_sCodeAdd .= $oTemplConfig->sTinyMceEditorJS; 
    656                     break; 
    657                 case 1: 
    658                 case true: 
    659                     $this->_sCodeAdd .= $oTemplConfig->sTinyMceEditorMicroJS; 
    660                     break; 
    661             } 
    662             $this->_bHtmlEditorAdded = true; 
    663         } 
    664  
    665         //--- Update HTML wrapper width 
    666         if (is_int($iTinyNum)) 
    667             switch($iTinyNum) { 
    668                 case 2: 
    669                     $aInput['attrs_wrapper']['style'] = 'width:' . $oTemplConfig->iTinyMceEditorWidthJS . ';'; 
    670                 break; 
    671                 case 3: 
    672                     $aInput['attrs_wrapper']['style'] = 'width:' . $oTemplConfig->iTinyMceEditorWidthMiniJS . ';'; 
    673                 break; 
    674             } 
     651    function addHtmlEditor($iViewMode, &$aInput) { 
     652 
     653        bx_import('BxDolEditor'); 
     654        $oEditor = BxDolEditor::getObjectInstance(); 
     655        if (!$oEditor) 
     656            return false;   
     657 
     658        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode); 
    675659 
    676660        return true; 
     
    10421026        $aUiLangs = array ('af' => 1, 'ar-DZ' => 1, 'ar' => 1, 'az' => 1, 'bg' => 1, 'bs' => 1, 'ca' => 1, 'cs' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'en-AU' => 1, 'en-GB' => 1, 'en-NZ' => 1, 'eo' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fo' => 1, 'fr-CH' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hr' => 1, 'hu' => 1, 'hy' => 1, 'id' => 1, 'is' => 1, 'it' => 1, 'ja' => 1, 'ko' => 1, 'kz' => 1, 'lt' => 1, 'lv' => 1, 'ml' => 1, 'ms' => 1, 'nl' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'rm' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sq' => 1, 'sr-SR' => 1, 'sr' => 1, 'sv' => 1, 'ta' => 1, 'th' => 1, 'tj' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-HK' => 1, 'zh-TW' => 1); 
    10431027 
    1044         $sCalendarLang = isset($aCalendarLangs[$GLOBALS['sCurrentLanguage']]) ? $GLOBALS['sCurrentLanguage'] : 'en'; 
    1045         $sUiLang = isset($aUiLangs[$GLOBALS['sCurrentLanguage']]) ? $GLOBALS['sCurrentLanguage'] : 'en'; 
     1028        bx_import('BxDolLanguages'); 
     1029        $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aCalendarLangs); 
     1030        $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aUiLangs); 
    10461031 
    10471032        $aJs = array( 
Note: See TracChangeset for help on using the changeset viewer.