HomeHelpTrac

Changeset 15957


Ignore:
Timestamp:
02/07/12 01:41:17 (4 months ago)
Author:
Anton Lesnikov
Message:

Designer -> Manage Logo updated.

Location:
trunk
Files:
7 edited

Legend:

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

    r15953 r15957  
    19941994    <string name="_adm_lmi_cpt_logo"><![CDATA[Logo]]></string> 
    19951995    <string name="_adm_lmi_cpt_icon"><![CDATA[Site Icon]]></string> 
    1996     <string name="_adm_dsg_txt_upload_photo"><![CDATA[Upload Photo]]></string> 
    1997     <string name="_adm_dsg_txt_alt_text"><![CDATA[ALT Text]]></string> 
     1996    <string name="_adm_dsg_txt_current_photo"><![CDATA[Current Logo Image]]></string> 
     1997    <string name="_adm_dsg_dsc_current_photo"><![CDATA[No image uploaded. Logo text is used instead.]]></string> 
     1998    <string name="_adm_dsg_txt_current_photo_delete"><![CDATA[Delete]]></string> 
     1999    <string name="_adm_dsg_txt_upload_photo"><![CDATA[Upload New Logo Image]]></string> 
     2000    <string name="_adm_dsg_txt_alt_text"><![CDATA[Logo Text]]></string> 
     2001    <string name="_adm_dsg_dsc_alt_text"><![CDATA[Serves as "ALT" text for logo image. Used as a logo when no logo image is uploaded.]]></string> 
    19982002    <string name="_adm_btn_designer_submit"><![CDATA[Submit]]></string> 
    19992003    <string name="_adm_dsg_txt_icon_apple"><![CDATA[Apple Touch Devices (129x129)]]></string> 
    20002004    <string name="_adm_dsg_txt_icon_facebook"><![CDATA[Facebook Share (100x100)]]></string> 
    20012005    <string name="_adm_dsg_txt_icon_favicon"><![CDATA[Favicon (16x16)]]></string> 
    2002     <string name="_adm_dsg_err_remove_old_icon"><![CDATA[Cannot remove an old icon.]]></string> 
    2003     <string name="_adm_dsg_err_remove_old_logo"><![CDATA[Cannot remove an old logo.]]></string> 
     2006    <string name="_adm_dsg_err_remove_old_icon"><![CDATA[Cannot remove current icon.]]></string> 
     2007    <string name="_adm_dsg_err_remove_old_logo"><![CDATA[Cannot remove current logo image.]]></string> 
    20042008    <string name="_adm_dsg_err_cannot_process_action"><![CDATA[Cannot process action. It does not have an associated handler.]]></string> 
    20052009    <string name="_adm_dsg_err_save"><![CDATA[Cannot save: ]]></string> 
  • trunk/studio/classes/BxDolStudioDesigner.php

    r15690 r15957  
    3131 
    3232        //--- Check actions ---// 
    33         if(($sAction = bx_get('pgt_action')) !== false) { 
     33        if(($sAction = bx_get('dsg_action')) !== false) { 
    3434            $sAction = bx_process_input($sAction); 
    3535 
    3636            $aResult = array('code' => 1, 'message' => _t('_adm_dsg_err_cannot_process_action')); 
    3737            switch($sAction) { 
     38                case 'delete_logo': 
     39                    $aResult = array('code' => 0, 'message' => ''); 
     40                    if(!$this->deleteLogo()) 
     41                        $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo')); 
     42                    break; 
     43 
    3844                case 'get-page-by-type': 
    39                     $sValue = bx_process_input(bx_get('pgt_value')); 
     45                    $sValue = bx_process_input(bx_get('dsg_value')); 
    4046                    if(empty($sValue)) 
    4147                        break; 
     
    5965            $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); 
    6066 
    61             $iId = (int)$this->oDb->getParam('sys_site_logo'); 
    62             if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId)) 
     67            if(!$this->deleteLogo()) 
    6368                return $this->getJsResult('_adm_dsg_err_remove_old_logo'); 
    6469 
     
    7580        $this->oDb->setParam('sys_site_logo_alt', $oForm->getCleanValue('alt')); 
    7681        return $this->getJsResult('_adm_dsg_scs_save', true, true, BX_DOL_URL_STUDIO . 'designer.php?page=' . BX_DOL_STUDIO_DSG_TYPE_LOGO); 
     82    } 
     83     
     84    function deleteLogo() { 
     85        $iProfileId = getLoggedId(); 
     86 
     87        bx_import('BxDolStorage'); 
     88        $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); 
     89 
     90        $iId = (int)$this->oDb->getParam('sys_site_logo'); 
     91        if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId)) 
     92            return false; 
     93 
     94        return true; 
    7795    } 
    7896 
  • trunk/studio/js/designer.js

    r15639 r15957  
    1212    this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed; 
    1313} 
     14 
     15BxDolStudioDesigner.prototype.deleteLogo = function() { 
     16    var $this = this; 
     17    var oDate = new Date(); 
     18 
     19    $.post( 
     20        this.sActionsUrl, 
     21        { 
     22            dsg_action: 'delete_logo', 
     23            _t: oDate.getTime() 
     24        }, 
     25        function(oData) { 
     26            if(oData.code != 0 && oData.message.length > 0) { 
     27                alert(oData.message); 
     28                return; 
     29            } 
     30 
     31            document.location.href = document.location.href;  
     32        }, 
     33        'json' 
     34    ); 
     35}; 
    1436/** @} */ 
  • trunk/studio/templates/base/css/designer.css

    r15635 r15957  
    11div.adm-dsg-logo-preview {} 
     2div.adm-dsg-logo-preview-empty {} 
  • trunk/studio/templates/base/dsr_logo_preview.html

    r15639 r15957  
    1 <div class="adm-dsg-logo-preview"> 
    2     <img src="__url__" alt="__alt__" /> 
    3 </div> 
     1<bx_if:show_empty> 
     2    <div class="adm-dsg-logo-preview-empty bx-def-font-small bx-def-color-ft-gray-l3">__content__</div> 
     3</bx_if:show_empty> 
     4<bx_if:show_image> 
     5    <div class="adm-dsg-logo-preview"> 
     6        <img src="__url__" alt="__alt__" /> 
     7        <p> 
     8            <button class="bx_btn" onclick="javascript:__js_object__.deleteLogo()"> 
     9                <bx_text:_adm_dsg_txt_current_photo_delete /> 
     10            </button> 
     11        </p> 
     12    </div> 
     13</bx_if:show_image> 
  • trunk/studio/templates/base/scripts/BxBaseStudioBuilderPage.php

    r15954 r15957  
    10201020 
    10211021                    $iImageId = $oStorage->storeFileFromForm($_FILES['image_file'], false); 
     1022                    $oStorage->afterUploadCleanup($iImageId, 0); 
    10221023                } 
    10231024 
  • trunk/studio/templates/base/scripts/BxBaseStudioDesigner.php

    r15754 r15957  
    8484        $oTemplate = BxDolStudioTemplate::getInstance(); 
    8585 
    86         $sPreview = ""; 
    8786        $sAlt = $this->oDb->getParam('sys_site_logo_alt'); 
     87 
     88        $aTmplVarsPreview = array( 
     89            'bx_if:show_empty' => array( 
     90                'condition' => true, 
     91                'content' => array( 
     92                    'content' => _t("_adm_dsg_dsc_current_photo") 
     93                ) 
     94            ), 
     95            'bx_if:show_image' => array( 
     96                'condition' => false, 
     97                'content' => array() 
     98            ) 
     99        ); 
    88100 
    89101        if(($iId = (int)$this->oDb->getParam('sys_site_logo')) != 0) { 
     
    93105            $sFileUrl = $oStorage->getFileUrlById($iId); 
    94106            if($sFileUrl !== false) { 
    95                 $aTmplVars = array( 
    96                     'url' => $sFileUrl,  
    97                     'alt' => $sAlt 
     107                $aTmplVarsPreview['bx_if:show_empty']['condition'] = false; 
     108                $aTmplVarsPreview['bx_if:show_image'] = array( 
     109                    'condition' => true, 
     110                    'content' => array( 
     111                        'js_object' => $this->getPageJsObject(), 
     112                        'url' => $sFileUrl,  
     113                        'alt' => $sAlt 
     114                    ) 
    98115                ); 
    99                 $sPreview = $oTemplate->parseHtmlByName('dsr_logo_preview.html', $aTmplVars); 
    100116            } 
    101117            else 
    102118                $this->oDb->setParam('sys_site_logo', 0); 
    103119        } 
     120        $sPreview = $oTemplate->parseHtmlByName('dsr_logo_preview.html', $aTmplVarsPreview); 
    104121 
    105122        $aForm = array( 
     
    111128                'enctype' => 'multipart/form-data', 
    112129                'target' => $this->sLogoIframeId 
     130            ), 
     131            'params' => array( 
     132                'db' => array( 
     133                    'table' => '', 
     134                    'key' => '', 
     135                    'uri' => '', 
     136                    'uri_title' => '', 
     137                    'submit_name' => 'save' 
     138                ), 
     139            ), 
     140            'inputs' => array( 
     141                'page' => array( 
     142                    'type' => 'hidden', 
     143                    'name' => 'page', 
     144                    'value' => $this->sPage 
     145                ), 
     146                'preview' => array( 
     147                    'type' => 'custom', 
     148                    'name' => 'preview', 
     149                    'caption' => _t('_adm_dsg_txt_current_photo'), 
     150                    'content' => $sPreview 
     151                ), 
     152                'image' => array( 
     153                    'type' => 'file', 
     154                    'name' => 'image', 
     155                    'caption' => _t('_adm_dsg_txt_upload_photo') 
     156                ), 
     157                'alt' => array( 
     158                    'type' => 'text', 
     159                    'name' => 'alt', 
     160                    'caption' => _t('_adm_dsg_txt_alt_text'), 
     161                    'info' => _t('_adm_dsg_dsc_alt_text'), 
     162                    'value' => $sAlt, 
     163                    'checker' => array( 
     164                        'func' => '', 
     165                        'params' => array(), 
     166                        'error' => '' 
     167                    ), 
     168                    'db' => array ( 
     169                        'pass' => 'Xss', 
     170                    ), 
     171                ), 
     172                'save' => array( 
     173                    'type' => 'submit', 
     174                    'name' => 'save', 
     175                    'value' => _t('_adm_btn_designer_submit'), 
     176                ) 
     177            ) 
     178        ); 
     179 
     180        $oForm = new BxBaseStudioFormView($aForm); 
     181        $oForm->initChecker(); 
     182 
     183        if($oForm->isSubmittedAndValid()) { 
     184            echo $this->submitLogo($oForm); 
     185            exit; 
     186        } 
     187 
     188        $aTmplVars = array( 
     189            'js_object' => $this->getPageJsObject(), 
     190            'bx_repeat:blocks' => array( 
     191                array( 
     192                    'caption' => '', 
     193                    'panel_top' => '', 
     194                    'items' => $oTemplate->parseHtmlByName('dsr_logo.html', array('logo_iframe_id' => $this->sLogoIframeId, 'form' => $oForm->getCode())), 
     195                    'panel_bottom' => '' 
     196                ) 
     197            ) 
     198        ); 
     199 
     200        return $oTemplate->parseHtmlByName('designer.html', $aTmplVars); 
     201    } 
     202 
     203    protected function getIcon() { 
     204        $oTemplate = BxDolStudioTemplate::getInstance(); 
     205 
     206        $sPreview = ""; 
     207        $aTmplVars = array('bx_repeat:images' => array()); 
     208 
     209        if(($iId = (int)$this->oDb->getParam('sys_site_icon')) != 0) { 
     210            $aTranscoders = array( 
     211                BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple', 
     212                BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook', 
     213                BX_DOL_TRANSCODER_OBJ_ICON_FAVICON => '_adm_dsg_txt_icon_favicon' 
     214            ); 
     215 
     216            bx_import('BxDolImageTranscoder'); 
     217            foreach($aTranscoders as $sTranscoder => $sTitle) { 
     218                $oTranscoder = BxDolImageTranscoder::getObjectInstance($sTranscoder); 
     219 
     220                $sImageUrl = $oTranscoder->getImageUrl($iId); 
     221                if($sImageUrl === false) { 
     222                    $this->oDb->setParam('sys_site_icon', 0); 
     223                    break; 
     224                } 
     225 
     226                $aTmplVars['bx_repeat:images'][] = array( 
     227                    'caption' => _t($sTitle), 
     228                    'url' => $sImageUrl 
     229                ); 
     230            } 
     231 
     232            $sPreview = $oTemplate->parseHtmlByName('dsr_icon_preview.html', $aTmplVars); 
     233        } 
     234 
     235        $aForm = array( 
     236            'form_attrs' => array( 
     237                'id' => $this->sIconFormId, 
     238                'name' => $this->sIconFormId, 
     239                'action' => BX_DOL_URL_STUDIO . 'designer.php', 
     240                'method' => 'post', 
     241                'enctype' => 'multipart/form-data', 
     242                'target' => $this->sIconIframeId 
    113243            ), 
    114244            'params' => array( 
     
    137267                    'caption' => _t('_adm_dsg_txt_upload_photo') 
    138268                ), 
    139                 'alt' => array( 
    140                     'type' => 'text', 
    141                     'name' => 'alt', 
    142                     'value' => $sAlt, 
    143                     'caption' => _t('_adm_dsg_txt_alt_text'), 
    144                     'checker' => array( 
    145                         'func' => '', 
    146                         'params' => array(), 
    147                         'error' => '' 
    148                     ), 
    149                     'db' => array ( 
    150                         'pass' => 'Xss', 
    151                     ), 
    152                 ), 
    153                 'save' => array( 
    154                     'type' => 'submit', 
    155                     'name' => 'save', 
    156                     'value' => _t('_adm_btn_designer_submit'), 
    157                 ) 
    158             ) 
    159         ); 
    160  
    161         $oForm = new BxBaseStudioFormView($aForm); 
    162         $oForm->initChecker(); 
    163  
    164         if($oForm->isSubmittedAndValid()) { 
    165             echo $this->submitLogo($oForm); 
    166             exit; 
    167         } 
    168  
    169         $aTmplVars = array( 
    170             'js_object' => $this->getPageJsObject(), 
    171             'bx_repeat:blocks' => array( 
    172                 array( 
    173                     'caption' => '', 
    174                     'panel_top' => '', 
    175                     'items' => $oTemplate->parseHtmlByName('dsr_logo.html', array('logo_iframe_id' => $this->sLogoIframeId, 'form' => $oForm->getCode())), 
    176                     'panel_bottom' => '' 
    177                 ) 
    178             ) 
    179         ); 
    180  
    181         return $oTemplate->parseHtmlByName('designer.html', $aTmplVars); 
    182     } 
    183  
    184     protected function getIcon() { 
    185         $oTemplate = BxDolStudioTemplate::getInstance(); 
    186  
    187         $sPreview = ""; 
    188         $aTmplVars = array('bx_repeat:images' => array()); 
    189  
    190         if(($iId = (int)$this->oDb->getParam('sys_site_icon')) != 0) { 
    191             $aTranscoders = array( 
    192                 BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple', 
    193                 BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook', 
    194                 BX_DOL_TRANSCODER_OBJ_ICON_FAVICON => '_adm_dsg_txt_icon_favicon' 
    195             ); 
    196  
    197             bx_import('BxDolImageTranscoder'); 
    198             foreach($aTranscoders as $sTranscoder => $sTitle) { 
    199                 $oTranscoder = BxDolImageTranscoder::getObjectInstance($sTranscoder); 
    200  
    201                 $sImageUrl = $oTranscoder->getImageUrl($iId); 
    202                 if($sImageUrl === false) { 
    203                     $this->oDb->setParam('sys_site_icon', 0); 
    204                     break; 
    205                 } 
    206  
    207                 $aTmplVars['bx_repeat:images'][] = array( 
    208                     'caption' => _t($sTitle), 
    209                     'url' => $sImageUrl 
    210                 ); 
    211             } 
    212  
    213             $sPreview = $oTemplate->parseHtmlByName('dsr_icon_preview.html', $aTmplVars); 
    214         } 
    215  
    216         $aForm = array( 
    217             'form_attrs' => array( 
    218                 'id' => $this->sIconFormId, 
    219                 'name' => $this->sIconFormId, 
    220                 'action' => BX_DOL_URL_STUDIO . 'designer.php', 
    221                 'method' => 'post', 
    222                 'enctype' => 'multipart/form-data', 
    223                 'target' => $this->sIconIframeId 
    224             ), 
    225             'params' => array( 
    226                 'db' => array( 
    227                     'table' => '', 
    228                     'key' => '', 
    229                     'uri' => '', 
    230                     'uri_title' => '', 
    231                     'submit_name' => 'save' 
    232                 ), 
    233             ), 
    234             'inputs' => array( 
    235                 'page' => array( 
    236                     'type' => 'hidden', 
    237                     'name' => 'page', 
    238                     'value' => $this->sPage 
    239                 ), 
    240                 'preview' => array( 
    241                     'type' => 'custom', 
    242                     'name' => 'preview', 
    243                     'content' => $sPreview 
    244                 ),  
    245                 'image' => array( 
    246                     'type' => 'file', 
    247                     'name' => 'image', 
    248                     'caption' => _t('_adm_dsg_txt_upload_photo') 
    249                 ), 
    250269                'save' => array( 
    251270                    'type' => 'submit', 
Note: See TracChangeset for help on using the changeset viewer.