HomeHelpTrac

Changeset 15949


Ignore:
Timestamp:
02/06/12 05:29:14 (4 months ago)
Author:
Anton Lesnikov
Message:

Studio -> Page Builder -> Edit block functionality.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/boonex/english/install/data/langs/en.xml

    r15945 r15949  
    24402440    <string name="_adm_form_btn_pre_values_cancel"><![CDATA[Cancel]]></string> 
    24412441   
     2442    <string name="_adm_txt_module_skeletons"><![CDATA[Skeletons]]></string> 
    24422443    <string name="_adm_page_cpt_builder_pages"><![CDATA[Pages Builder]]></string> 
    24432444    <string name="_adm_wgt_cpt_builder_pages"><![CDATA[Pages]]></string> 
     
    24512452    <string name="_adm_bp_btn_settings"><![CDATA[Settings]]></string> 
    24522453    <string name="_adm_bp_btn_add_block"><![CDATA[Add Blocks]]></string> 
    2453     <string name="_adm_bp_txt_create_popup"><![CDATA[Create New Page]]></string> 
    2454     <string name="_adm_bp_txt_settings_popup"><![CDATA[Settings]]></string> 
    2455     <string name="_adm_bp_txt_new_block_popup"><![CDATA[Add New Block]]></string> 
    24562454    <string name="_adm_bp_err_cannot_process_action"><![CDATA[Cannot process action. It does not have an associated handler.]]></string> 
    24572455    <string name="_adm_bp_err_nothing_changed"><![CDATA[Nothing was changed or an error occured.]]></string> 
    24582456    <string name="_adm_bp_err_save"><![CDATA[Cannot save]]></string> 
    24592457    <string name="_adm_bp_scs_save"><![CDATA[The changes were successfully saved]]></string> 
     2458    <string name="_adm_bp_txt_new_block_popup"><![CDATA[Add New Block]]></string> 
     2459    <string name="_adm_bp_btn_block_add"><![CDATA[Add to Page]]></string> 
     2460    <string name="_adm_bp_btn_block_cancel"><![CDATA[Cancel]]></string> 
     2461    <string name="_adm_bp_txt_block_selected"><![CDATA[blocks selected]]></string> 
     2462    <string name="_adm_bp_scs_block_added"><![CDATA[The blocks were successfully added.]]></string>     
     2463    <string name="_adm_bp_err_block_added"><![CDATA[Cannot add blocks.]]></string> 
     2464    <string name="_adm_bp_txt_edit_block_popup"><![CDATA[Edit "{0}" Block]]></string> 
     2465    <string name="_adm_bp_err_block_edit"><![CDATA[Cannot update block]]></string> 
     2466    <string name="_adm_bp_err_block_not_found"><![CDATA[The requested block cannot be found.]]></string> 
     2467    <string name="_adm_bp_err_block_remove_old_image"><![CDATA[Cannot remove an old image]]></string> 
     2468    <string name="_adm_bp_txt_block_title"><![CDATA[Title]]></string> 
     2469    <string name="_adm_bp_dsc_block_title"><![CDATA[You need to enter field title]]></string> 
     2470    <string name="_adm_bp_err_block_title"><![CDATA[Enter title, more then 3 characters]]></string> 
     2471    <string name="_adm_bp_txt_block_designbox"><![CDATA[Design Box]]></string> 
     2472    <string name="_adm_bp_err_block_designbox"><![CDATA[Select a design box for the block]]></string> 
     2473    <string name="_adm_bp_txt_block_designbox_empty"><![CDATA[Select Design Box...]]></string> 
     2474    <string name="_adm_bp_txt_block_visible_for_levels"><![CDATA[User Levels]]></string> 
     2475    <string name="_adm_bp_dsc_block_visible_for_levels"><![CDATA[Select user levels that can see this block]]></string> 
     2476    <string name="_adm_bp_btn_block_save"><![CDATA[Save]]></string> 
     2477    <string name="_adm_bp_btn_block_cancel"><![CDATA[Cancel]]></string> 
     2478    <string name="_adm_bp_txt_block_content_raw"><![CDATA[Content]]></string> 
     2479    <string name="_adm_bp_dsc_block_content_raw"><![CDATA[Enter HTML content here]]></string> 
     2480    <string name="_adm_bp_txt_block_content_html"><![CDATA[Content]]></string> 
     2481    <string name="_adm_bp_dsc_block_content_html"><![CDATA[Enter HTML content here]]></string> 
     2482    <string name="_adm_bp_txt_block_content_lang"><![CDATA[Content]]></string> 
     2483    <string name="_adm_bp_dsc_block_content_lang"><![CDATA[Enter language key here]]></string> 
     2484    <string name="_adm_bp_txt_block_content_image_file"><![CDATA[Content]]></string> 
     2485    <string name="_adm_bp_dsc_block_content_image_file"><![CDATA[Upload an image to be displayed in block]]></string> 
     2486    <string name="_adm_bp_txt_block_content_image_align"><![CDATA[Alignment]]></string> 
     2487    <string name="_adm_bp_txt_block_content_image_align_empty"><![CDATA[Select alignment...]]></string> 
     2488    <string name="_adm_bp_txt_block_content_image_align_left"><![CDATA[left]]></string> 
     2489    <string name="_adm_bp_txt_block_content_image_align_center"><![CDATA[center]]></string> 
     2490    <string name="_adm_bp_txt_block_content_image_align_right"><![CDATA[right]]></string> 
     2491    <string name="_adm_bp_txt_block_content_rss_url"><![CDATA[URL]]></string> 
     2492    <string name="_adm_bp_dsc_block_content_rss_url"><![CDATA[Enter URL to RSS resource here]]></string> 
     2493    <string name="_adm_bp_txt_block_content_rss_length"><![CDATA[Length]]></string> 
     2494    <string name="_adm_bp_dsc_block_content_rss_length"><![CDATA[Enter a number of displayed items here]]></string> 
     2495    <string name="_adm_bp_txt_block_content_menu"><![CDATA[Content]]></string> 
     2496    <string name="_adm_bp_txt_block_content_menu_empty"><![CDATA[Select menu...]]></string> 
     2497    <string name="_adm_bp_txt_block_content_service_module"><![CDATA[Module]]></string> 
     2498    <string name="_adm_bp_txt_block_content_service_method"><![CDATA[Method]]></string> 
     2499     
     2500    <string name=""><![CDATA[]]></string> 
     2501    <string name=""><![CDATA[]]></string> 
     2502    <string name=""><![CDATA[]]></string> 
     2503     
     2504     
     2505     
     2506    <string name="_adm_bp_txt_create_popup"><![CDATA[Create New Page]]></string> 
     2507    <string name="_adm_bp_txt_settings_popup"><![CDATA[Settings]]></string> 
    24602508    <string name="_adm_bp_txt_page_title"><![CDATA[Title]]></string> 
    24612509    <string name="_adm_bp_dsc_page_title"><![CDATA[Page title displayed in page header. Use at least 3 characters.]]></string> 
     
    25062554    <string name="_adm_bp_btn_page_apply"><![CDATA[Apply]]></string> 
    25072555    <string name="_adm_bp_btn_page_cancel"><![CDATA[Cancel]]></string> 
    2508     <string name=""><![CDATA[]]></string> 
    2509     <string name=""><![CDATA[]]></string> 
    2510     <string name=""><![CDATA[]]></string> 
    2511     <string name=""><![CDATA[]]></string> 
    2512      
    2513     <string name="_adm_bp_btn_block_add"><![CDATA[Add to Page]]></string> 
    2514     <string name="_adm_bp_btn_block_cancel"><![CDATA[Cancel]]></string> 
    2515     <string name="_adm_bp_txt_blocks_selected"><![CDATA[blocks selected]]></string> 
    2516     <string name="_adm_bp_scs_blocks_added"><![CDATA[The blocks were successfully added.]]></string>     
    2517     <string name="_adm_bp_err_blocks_added"><![CDATA[Cannot add blocks.]]></string> 
    25182556     
    25192557     
  • trunk/studio/classes/BxDolStudioBuilderPage.php

    r15936 r15949  
    7676        } 
    7777    } 
     78 
     79    protected function addInArray($aInput, $sKey, $aValues) { 
     80        return stdAddInArray($aInput, $sKey, $aValues); 
     81    } 
    7882} 
    7983/** @} */ 
  • trunk/studio/classes/BxDolStudioBuilderPageQuery.php

    r15945 r15949  
    117117                `tpl`.`icon` AS `icon`, 
    118118                `tpl`.`title` AS `title`, 
    119                 `tpl`.`title` AS `title`, 
    120119                `tpl`.`template` AS `template`, 
    121120                `tpl`.`cells_number` AS `cells_number`" . $sSelectClause . " 
     
    129128        return (int)$this->getOne("SELECT FOUND_ROWS()"); 
    130129    } 
    131      
     130 
     131    function getDesignBoxes($aParams, &$aItems, $bReturnCount = true) { 
     132        $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query')); 
     133        $sSelectClause = $sJoinClause = $sWhereClause = $sGroupClause = $sOrderClause = $sLimitClause = ""; 
     134 
     135        if(!isset($aParams['order']) || empty($aParams['order'])) 
     136           $sOrderClause = "ORDER BY `tpd`.`id` ASC"; 
     137 
     138        switch($aParams['type']) { 
     139            case 'by_id': 
     140                $aMethod['name'] = 'getRow'; 
     141                $sWhereClause = $this->prepare("AND `tpd`.`id`=? ", $aParams['value']); 
     142                break; 
     143            case 'all': 
     144                break; 
     145        } 
     146 
     147        $aMethod['params'][0] = "SELECT SQL_CALC_FOUND_ROWS 
     148                `tpd`.`id` AS `id`, 
     149                `tpd`.`title` AS `title`, 
     150                `tpd`.`template` AS `template`" . $sSelectClause . " 
     151            FROM `sys_pages_design_boxes` AS `tpd` " . $sJoinClause . " 
     152            WHERE 1 " . $sWhereClause . " " . $sGroupClause . " " . $sOrderClause . " " . $sLimitClause; 
     153        $aItems = call_user_func_array(array($this, $aMethod['name']), $aMethod['params']); 
     154 
     155        if(!$bReturnCount) 
     156            return count($aItems) > 0; 
     157 
     158        return (int)$this->getOne("SELECT FOUND_ROWS()"); 
     159    } 
     160 
    132161    function getBlocks($aParams, &$aItems, $bReturnCount = true) { 
    133162        $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query')); 
     
    226255        return (int)$this->getOne($sSql); 
    227256    } 
     257 
     258    function getMenus() { 
     259        $sSql = "SELECT `object`, `title` FROM `sys_objects_menu` WHERE 1"; 
     260        return $this->getPairs($sSql, 'object', 'title'); 
     261    } 
    228262} 
    229263/** @} */ 
  • trunk/studio/classes/BxDolStudioFormsField.php

    r15906 r15949  
    5757    } 
    5858 
    59     /* 
    60      * Adds $aValues in $aArray after $sKey key. 
    61      */ 
    6259    protected function addInArray($aInput, $sKey, $aValues) { 
    63         reset($aInput); 
    64         $iInput = count($aInput); 
    65         for($i = 0; $i < $iInput; $i++, next($aInput)) 
    66             if(key($aInput) == $sKey) 
    67                 break; 
    68  
    69         $aOutput = array_slice($aInput, 0, $i + 1); 
    70         $aOutput = array_merge($aOutput, $aValues); 
    71         $aOutput = array_merge($aOutput, array_slice($aInput, $i + 1)); 
    72  
    73         return $aOutput; 
     60        return stdAddInArray($aInput, $sKey, $aValues); 
    7461    } 
    7562} 
  • trunk/studio/inc/utils.inc.php

    r15936 r15949  
    6464} 
    6565 
     66function stdAddInArray($aInput, $sKey, $aValues) { 
     67    reset($aInput); 
     68    $iInput = count($aInput); 
     69    for($i = 0; $i < $iInput; $i++, next($aInput)) 
     70        if(key($aInput) == $sKey) 
     71            break; 
     72 
     73    $aOutput = array_slice($aInput, 0, $i + 1); 
     74    $aOutput = array_merge($aOutput, $aValues); 
     75    $aOutput = array_merge($aOutput, array_slice($aInput, $i + 1)); 
     76 
     77    return $aOutput; 
     78} 
    6679/** @} */ 
  • trunk/studio/js/builder_page.js

    r15945 r15949  
    131131}; 
    132132 
     133BxDolStudioBuilderPage.prototype.onEditBlock = function(oData) { 
     134    window.location.href = this.sActionsUrl + '?type=' + this.sType + '&page=' + this.sPage; 
     135}; 
    133136 
    134137/** 
     
    159162 * General methods. 
    160163 */ 
    161 BxDolStudioBuilderPage.prototype.performAction = function(sAction) { 
     164BxDolStudioBuilderPage.prototype.performAction = function(sAction, aParams) { 
    162165    var $this = this; 
    163166    var oDate = new Date(); 
    164167 
     168    if(aParams == undefined) 
     169        aParams = {}; 
     170 
     171    aParams.bp_action = sAction; 
     172    aParams.bp_type = $this.sType; 
     173    aParams.bp_page = $this.sPage; 
     174    aParams._t = oDate.getTime(); 
     175 
    165176    $.post( 
    166177        this.sActionsUrl, 
    167         { 
    168             bp_action: sAction, 
    169             bp_type: $this.sType, 
    170             bp_page: $this.sPage, 
    171             _t:oDate.getTime() 
    172         }, 
     178        aParams, 
    173179        function(oData) { 
    174180            oBxDolStudioPage.processJson(oData); 
  • trunk/studio/templates/base/bp_add_block_form.html

    r15945 r15949  
    1313    <button class="bx-btn bx-btn-primary" name="do_submit" value="<bx_text:_adm_bp_btn_block_add />" type="submit"><bx_text:_adm_bp_btn_block_add /></button> 
    1414    <button class="bx-btn bx-def-margin-sec-left" name="do_cancel" value="<bx_text:_adm_bp_btn_block_cancel />" type="button" onclick="$('.bx-popup-applied:visible').dolPopupHide()"><bx_text:_adm_bp_btn_block_cancel /></button> 
    15     <div class="adm-bp-cbf-counter bx-def-font-h3"><span id="adm-bp-cbf-counter">0</span> <bx_text:_adm_bp_txt_blocks_selected /></div> 
     15    <div class="adm-bp-cbf-counter bx-def-font-h3"><span id="adm-bp-cbf-counter">0</span> <bx_text:_adm_bp_txt_block_selected /></div> 
    1616    <div class="bx-std-cb"></div> 
    1717</div> 
  • trunk/studio/templates/base/scripts/BxBaseStudioBuilderPage.php

    r15945 r15949  
    1616 
    1717class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage { 
     18    private $sParamsDivider = '#'; 
     19 
    1820    private $sActionPageCreate = 'page_create'; 
    1921    private $sActionPageDelete = 'page_delete'; 
    2022    private $sActionPageEdit = 'page_edit'; 
    2123    private $sActionBlockCreate = 'block_create'; 
     24    private $sActionBlockEdit = 'block_edit'; 
    2225 
    2326    protected $aHtmlIds = array( 
     
    136139                    $aTmplVarsCell['bx_repeat:blocks'][] = array( 
    137140                        'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'], 
    138                         'onclick' => $sJsObject . ".showEditBlockPopup(" . $aBlock['id'] . ")", 
     141                        'onclick' => $sJsObject . ".performAction('block_edit', {id: " . $aBlock['id'] . "})", 
    139142                        'title' => _t($aBlock['title']), 
    140143                        'icon' => stdGetModuleIcon($aBlock['module']), 
     
    664667                $aBlock['object'] = $this->sPage; 
    665668                $aBlock['cell_id'] = 1; 
     669                $aBlock['module'] = $aBlock['module'] != BX_DOL_STUDIO_BP_SKELETONS ? $aBlock['module'] : BX_DOL_STUDIO_MODULE_CUSTOM; 
    666670                $aBlock['title'] = $sTitleKey; 
    667671                $aBlock['deletable'] = 1; 
     
    675679            } 
    676680 
    677             if($bResult)  
    678                 return array('msg' => _t('_adm_bp_scs_blocks_added'), 'eval' => $sJsObject . '.onCreateBlock(oData)'); 
     681            if($bResult) 
     682                return array('eval' => $sJsObject . '.onCreateBlock(oData)'); 
    679683            else 
    680                 return array('msg' => _t('_adm_bp_err_blocks_added')); 
     684                return array('msg' => _t('_adm_bp_err_block_added')); 
    681685        } 
    682686 
    683687        bx_import('BxTemplStudioFunctions'); 
    684688        $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_block_popup_id'], _t('_adm_bp_txt_new_block_popup'), $oTemplate->parseHtmlByName('bp_add_block.html', array( 
     689            'form_id' => $aForm['form_attrs']['id'], 
     690            'form' => $oForm->getCode() 
     691        ))); 
     692 
     693        return array('popup' => $sContent); 
     694    } 
     695 
     696    protected function actionBlockEdit() { 
     697        $sJsObject = $this->getPageJsObject(); 
     698        $oTemplate = BxDolStudioTemplate::getInstance(); 
     699 
     700        $iId = (int)bx_get('id'); 
     701        if(!$iId) 
     702            return array(); 
     703 
     704        $aBlock = array(); 
     705        $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false); 
     706        if(empty($aBlock) || !is_array($aBlock)) 
     707            return array('msg' => _t('_adm_bp_err_block_not_found')); 
     708 
     709        $aForm = array( 
     710            'form_attrs' => array( 
     711                'id' => 'adm-bp-block-edit', 
     712                'action' => BX_DOL_URL_STUDIO . 'builder_page.php?bp_action=' . $this->sActionBlockEdit . '&type=' . $this->sType . '&page=' . $this->sPage, 
     713                'method' => 'post' 
     714            ), 
     715            'params' => array ( 
     716                'db' => array( 
     717                    'table' => 'sys_pages_blocks', 
     718                    'key' => 'id', 
     719                    'uri' => '', 
     720                    'uri_title' => '', 
     721                    'submit_name' => 'do_submit' 
     722                ), 
     723            ), 
     724            'inputs' => array ( 
     725                'id' => array( 
     726                    'type' => 'hidden', 
     727                    'name' => 'id', 
     728                    'value' => $iId, 
     729                    'db' => array ( 
     730                        'pass' => 'Int', 
     731                    ), 
     732                ), 
     733                'title' => array( 
     734                    'type' => 'text', 
     735                    'name' => 'title', 
     736                    'caption' => _t('_adm_bp_txt_block_title'), 
     737                    'info' => _t('_adm_bp_dsc_block_title'), 
     738                    'value' => _t($aBlock['title']), 
     739                    'required' => '1', 
     740                    'db' => array ( 
     741                        'pass' => 'Xss', 
     742                    ), 
     743                    'checker' => array ( 
     744                        'func' => 'length', 
     745                        'params' => array(3,100), 
     746                        'error' => _t('_adm_bp_err_block_title'), 
     747                    ), 
     748                ), 
     749                'designbox_id' => array( 
     750                    'type' => 'select', 
     751                    'name' => 'designbox_id', 
     752                    'caption' => _t('_adm_bp_txt_block_designbox'), 
     753                    'info' => '', 
     754                    'value' => $aBlock['designbox_id'], 
     755                    'values' => array( 
     756                        array('key' => '', 'value' => _t('_adm_bp_txt_block_designbox_empty')), 
     757                    ), 
     758                    'required' => '1', 
     759                    'db' => array ( 
     760                        'pass' => 'Int', 
     761                    ), 
     762                    'checker' => array ( 
     763                        'func' => 'avail', 
     764                        'params' => array(), 
     765                        'error' => _t('_adm_bp_err_block_designbox'), 
     766                    ), 
     767                ), 
     768                'visible_for_levels' => array( 
     769                    'type' => 'checkbox_set', 
     770                    'name' => 'visible_for_levels', 
     771                    'caption' => _t('_adm_bp_txt_block_visible_for_levels'), 
     772                    'info' => _t('_adm_bp_dsc_block_visible_for_levels'), 
     773                    'value' => '', 
     774                    'values' => array(), 
     775                    'db' => array ( 
     776                        'pass' => 'Int', 
     777                    ) 
     778                ), 
     779                'controls' => array( 
     780                    'name' => 'controls',  
     781                    'type' => 'input_set', 
     782                    array( 
     783                        'type' => 'submit', 
     784                        'name' => 'do_submit', 
     785                        'value' => _t('_adm_bp_btn_block_save'), 
     786                    ), 
     787                    array ( 
     788                        'type' => 'reset', 
     789                        'name' => 'close', 
     790                        'value' => _t('_adm_bp_btn_block_cancel'), 
     791                        'attrs' => array( 
     792                            'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()", 
     793                            'class' => 'bx-def-margin-sec-left', 
     794                        ), 
     795                    ) 
     796                ) 
     797            ) 
     798        ); 
     799 
     800        $aDBoxes = array(); 
     801        $this->oDb->getDesignBoxes(array('type' => 'all'), $aDBoxes, false); 
     802        foreach($aDBoxes as $aDBox) 
     803            $aForm['inputs']['designbox_id']['values'][] = array('key' => $aDBox['id'], 'value' => _t($aDBox['title'])); 
     804 
     805        bx_import('BxDolAcl'); 
     806        $aLevels = BxDolAcl::getInstance()->getMemberships(); 
     807        foreach($aLevels as $iKey => $sValue) { 
     808            if(((int)$aBlock['visible_for_levels'] & pow(2, (int)$iKey - 1)) != 0) 
     809                $aForm['inputs']['visible_for_levels']['value'][] = $iKey; 
     810             
     811            $aForm['inputs']['visible_for_levels']['values'][$iKey] = _t($sValue); 
     812        } 
     813 
     814        switch($aBlock['type']) { 
     815            case 'raw': 
     816                $aFields = array( 
     817                    'content' => array( 
     818                        'type' => 'textarea', 
     819                        'name' => 'content', 
     820                        'caption' => _t('_adm_bp_txt_block_content_raw'), 
     821                        'info' => _t('_adm_bp_dsc_block_content_raw'), 
     822                        'value' => $aBlock['content'], 
     823                        'required' => '0', 
     824                        'db' => array ( 
     825                            'pass' => 'Xss', 
     826                        ), 
     827                    ), 
     828                ); 
     829                break; 
     830 
     831            case 'html': 
     832                $aFields = array( 
     833                    'content' => array( 
     834                        'type' => 'textarea', 
     835                        'name' => 'content', 
     836                        'caption' => _t('_adm_bp_txt_block_content_raw'), 
     837                        'info' => _t('_adm_bp_dsc_block_content_raw'), 
     838                        'value' => $aBlock['content'], 
     839                        'required' => '0', 
     840                        'html' => 1, 
     841                        'db' => array ( 
     842                            'pass' => 'XssHtml', 
     843                        ), 
     844                    ), 
     845                ); 
     846                break; 
     847 
     848            case 'lang': 
     849                $aFields = array( 
     850                    'content' => array( 
     851                        'type' => 'text', 
     852                        'name' => 'content', 
     853                        'caption' => _t('_adm_bp_txt_block_content_lang'), 
     854                        'info' => _t('_adm_bp_dsc_block_content_lang'), 
     855                        'value' => $aBlock['content'], 
     856                        'required' => '0', 
     857                        'db' => array ( 
     858                            'pass' => 'Xss', 
     859                        ), 
     860                    ), 
     861                ); 
     862                break; 
     863 
     864            case 'image': 
     865                $aForm['form_attrs']['enctype'] = 'multipart/form-data'; 
     866 
     867                $iImageId = $sImageAlign = ''; 
     868                if($aBlock['content'] != '') 
     869                    list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']); 
     870 
     871                $aFields = array( 
     872                    'content' => array( 
     873                        'type' => 'hidden', 
     874                        'name' => 'content', 
     875                        'value' => '', 
     876                        'db' => array ( 
     877                            'pass' => 'Xss', 
     878                        ), 
     879                    ), 
     880                    'image_file' => array( 
     881                        'type' => 'file', 
     882                        'name' => 'image_file', 
     883                        'caption' => _t('_adm_bp_txt_block_content_image_file'), 
     884                        'info' => _t('_adm_bp_dsc_block_content_image_file'), 
     885                        'value' => '', 
     886                        'required' => '0' 
     887                    ), 
     888                    'image_align' => array( 
     889                        'type' => 'select', 
     890                        'name' => 'image_align', 
     891                        'caption' => _t('_adm_bp_txt_block_content_image_align'), 
     892                        'info' => '', 
     893                        'value' => $sImageAlign, 
     894                        'values' => array( 
     895                            array('key' => '', 'value' => _t('_adm_bp_txt_block_content_image_align_empty')), 
     896                            array('key' => 'left', 'value' => _t('_adm_bp_txt_block_content_image_align_left')), 
     897                            array('key' => 'center', 'value' => _t('_adm_bp_txt_block_content_image_align_center')), 
     898                            array('key' => 'right', 'value' => _t('_adm_bp_txt_block_content_image_align_right')), 
     899                        ), 
     900                        'required' => '0', 
     901                        'db' => array ( 
     902                            'pass' => 'Xss', 
     903                        ), 
     904                    ), 
     905                ); 
     906                break; 
     907 
     908            case 'rss': 
     909                $sRssUrl = $sRssLength = ''; 
     910                if($aBlock['content'] != '') 
     911                    list($sRssUrl, $sRssLength) = explode($this->sParamsDivider, $aBlock['content']); 
     912 
     913                $aFields = array( 
     914                    'content' => array( 
     915                        'type' => 'hidden', 
     916                        'name' => 'content', 
     917                        'value' => '', 
     918                        'db' => array ( 
     919                            'pass' => 'Xss', 
     920                        ), 
     921                    ), 
     922                    'rss_url' => array( 
     923                        'type' => 'text', 
     924                        'name' => 'rss_url', 
     925                        'caption' => _t('_adm_bp_txt_block_content_rss_url'), 
     926                        'info' => _t('_adm_bp_dsc_block_content_rss_url'), 
     927                        'value' => $sRssUrl, 
     928                        'required' => '0', 
     929                        'db' => array ( 
     930                            'pass' => 'Xss', 
     931                        ), 
     932                    ), 
     933                    'rss_length' => array( 
     934                        'type' => 'text', 
     935                        'name' => 'rss_length', 
     936                        'caption' => _t('_adm_bp_txt_block_content_rss_length'), 
     937                        'info' => _t('_adm_bp_dsc_block_content_rss_length'), 
     938                        'value' => $sRssLength, 
     939                        'required' => '0', 
     940                        'db' => array ( 
     941                            'pass' => 'Int', 
     942                        ), 
     943                    ), 
     944                ); 
     945                break; 
     946 
     947            case 'menu': 
     948                $aFields = array( 
     949                    'content' => array( 
     950                        'type' => 'select', 
     951                        'name' => 'content', 
     952                        'caption' => _t('_adm_bp_txt_block_content_menu'), 
     953                        'info' => '', 
     954                        'value' => $aBlock['content'], 
     955                        'values' => array( 
     956                            array('key' => '', 'value' => _t('_adm_bp_txt_block_content_menu_empty')), 
     957                        ), 
     958                        'required' => '0', 
     959                        'db' => array ( 
     960                            'pass' => 'Xss', 
     961                        ), 
     962                    ) 
     963                ); 
     964                 
     965                $aMenus = $this->oDb->getMenus(); 
     966                foreach($aMenus as $sKey => $sValue) 
     967                    $aFields['content']['values'][] = array('key' => $sKey, 'value' => _t($sValue)); 
     968                break; 
     969 
     970            case 'service': 
     971                $aService = array('module' => '', 'method' => ''); 
     972                if($aBlock['content'] != '') 
     973                    $aService = unserialize($aBlock['content']); 
     974 
     975                $aFields = array( 
     976                    'service_module' => array( 
     977                        'type' => 'value', 
     978                        'name' => 'service_module', 
     979                        'caption' => _t('_adm_bp_txt_block_content_service_module'), 
     980                        'value' => $aService['module'] 
     981                    ), 
     982                    'service_method' => array( 
     983                        'type' => 'value', 
     984                        'name' => 'service_method', 
     985                        'caption' => _t('_adm_bp_txt_block_content_service_method'), 
     986                        'value' => $aService['method'] 
     987                    ) 
     988                ); 
     989                break; 
     990        } 
     991 
     992        $aForm['inputs'] = $this->addInArray($aForm['inputs'], 'visible_for_levels', $aFields); 
     993 
     994        $oForm = new BxTemplStudioFormView($aForm); 
     995        $oForm->initChecker(); 
     996 
     997        if($oForm->isSubmittedAndValid()) { 
     998            $sTitleValue = $oForm->getCleanValue('title'); 
     999            BxDolForm::setSubmittedValue('title', $aBlock['title'], $aForm['form_attrs']['method']); 
     1000 
     1001            $iHideFrom = 0; 
     1002            $aLevelIds = $oForm->getCleanValue('visible_for_levels'); 
     1003            foreach($aLevelIds as $iLevelId) 
     1004                $iHideFrom += pow(2, (int)$iLevelId - 1); 
     1005            BxDolForm::setSubmittedValue('visible_for_levels', $iHideFrom, $aForm['form_attrs']['method']); 
     1006 
     1007            //--- Process Image fields 
     1008            if($aBlock['type'] == 'image' && isset($oForm->aInputs['image_file'], $oForm->aInputs['image_align'])) { 
     1009                $iImageId = 0; 
     1010                if($aBlock['content'] != '') 
     1011                    list($iImageId) = explode($this->sParamsDivider, $aBlock['content']); 
     1012 
     1013                if(!empty($_FILES['image_file']['tmp_name'])) { 
     1014                    bx_import('BxDolStorage'); 
     1015                    $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); 
     1016 
     1017                    if((int)$iImageId != 0 && !$oStorage->deleteFile($iImageId)) 
     1018                        return array('msg' => _t('_adm_bp_err_block_remove_old_image')); 
     1019 
     1020                    $iImageId = $oStorage->storeFileFromForm($_FILES['image_file'], false); 
     1021                } 
     1022 
     1023                $sImageAlign = $oForm->getCleanValue('image_align'); 
     1024 
     1025                unset($oForm->aInputs['image_file'], $oForm->aInputs['image_align']); 
     1026                BxDolForm::setSubmittedValue('content', implode($this->sParamsDivider, array($iImageId, $sImageAlign)), $oForm->aFormAttrs['method']); 
     1027            } 
     1028 
     1029            //--- Process RSS fields 
     1030            if($aBlock['type'] == 'rss' && isset($oForm->aInputs['rss_url'], $oForm->aInputs['rss_length'])) { 
     1031                $aRss = array( 
     1032                    $oForm->getCleanValue('rss_url'), 
     1033                    $oForm->getCleanValue('rss_length') 
     1034                ); 
     1035 
     1036                unset($oForm->aInputs['rss_url'], $oForm->aInputs['rss_length']); 
     1037                BxDolForm::setSubmittedValue('content', implode($this->sParamsDivider, $aRss), $oForm->aFormAttrs['method']); 
     1038            } 
     1039             
     1040 
     1041            if($oForm->update($iId) !== false) { 
     1042                bx_import('BxDolStudioLanguagesUtils'); 
     1043                BxDolStudioLanguagesUtils::getInstance()->updateLanguageString($aBlock['title'], $sTitleValue); 
     1044 
     1045                return array('eval' => $sJsObject . '.onEditBlock(oData)'); 
     1046            } 
     1047            else 
     1048                return array('msg' => _t('_adm_bp_err_block_edit')); 
     1049        } 
     1050 
     1051        bx_import('BxTemplStudioFunctions'); 
     1052        $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_block_popup_id'], _t('_adm_bp_txt_edit_block_popup', _t($aBlock['title'])), $oTemplate->parseHtmlByName('bp_add_block.html', array( 
    6851053            'form_id' => $aForm['form_attrs']['id'], 
    6861054            'form' => $oForm->getCode() 
Note: See TracChangeset for help on using the changeset viewer.