示例#1
0
function compilePreValues()
{
    $GLOBALS['MySQL']->cleanCache('sys_prevalues_keys');
    $aPreValues = array();
    $aKeys = getPreKeys();
    foreach ($aKeys as $aKey) {
        $sKey = $aKey['Key'];
        $aPreValues[$sKey] = array();
        $aRows = getPreValues($sKey);
        foreach ($aRows as $aRow) {
            $aPreValues[$sKey][$aRow['Value']] = array();
            foreach ($aRow as $sValKey => $sValue) {
                if ($sValKey == 'Key' or $sValKey == 'Value' or $sValKey == 'Order') {
                    continue;
                }
                //skip key, value and order. they already used
                if (!strlen($sValue)) {
                    continue;
                }
                //skip empty values
                $aPreValues[$sKey][$aRow['Value']][$sValKey] = $sValue;
            }
        }
    }
    $oCache = $GLOBALS['MySQL']->getDbCacheObject();
    $oCache->setData($GLOBALS['MySQL']->genDbCacheKey('sys_pre_values'), $aPreValues);
    $GLOBALS['aPreValues'] = $aPreValues;
}
示例#2
0
function PageCompPageMainCode()
{
    global $iAmInPopup;
    global $aFields;
    $sPopupAdd = $iAmInPopup ? '&popup=1' : '';
    $sResultMsg = '';
    if (isset($_POST['action']) and $_POST['action'] == 'Save' and isset($_POST['PreList']) and is_array($_POST['PreList'])) {
        if (true === saveList($_POST['list'], $_POST['PreList'])) {
            $sResultMsg = _t('_Success');
        } else {
            $sResultMsg = _t('_Failed to apply changes');
        }
    }
    //get lists
    $aLists = array();
    $aKeys = getPreKeys();
    foreach ($aKeys as $aList) {
        $aLists[$aList['Key']] = $aList['Key'];
    }
    $sListIn = bx_get('list');
    if ($sListIn !== false) {
        $sList_db = process_db_input($sListIn);
        $sList = process_pass_data($sListIn);
        $iCount = getPreValuesCount($sListIn);
        if (!$iCount) {
            //if no rows returned...
            $aLists[$sList] = $sList;
        }
        //create new list
    } else {
        $sList = '';
    }
    ob_start();
    if ($sResultMsg) {
        echo MsgBox($sResultMsg);
    }
    ?>
    <script type="text/javascript">
        function createNewList()
        {
            var sNewList = prompt( '<?php 
    echo bx_js_string(_t('_adm_pvalues_msg_enter_list_name'));
    ?>
' );

            if( sNewList == null )
                return false;

            sNewList = $.trim( sNewList );

            if( !sNewList.length ) {
                alert( '<?php 
    echo bx_js_string(_t('_adm_pvalues_msg_enter_correct_name'));
    ?>
' );
                return false;
            }

            window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
?list=' + encodeURIComponent( sNewList ) + '<?php 
    echo $sPopupAdd;
    ?>
';
        }

        function addRow( eImg )
        {
            $( eImg ).parent().parent().before(
                '<tr>' +
                <?php 
    foreach ($aFields as $sField => $sHelp) {
        ?>
                    '<td><input type="text" class="value_input" name="PreList[' + iNextInd + '][<?php 
        echo $sField;
        ?>
]" value="" /></td>' +
                    <?php 
    }
    ?>
                    '<th class="row_controls">' +
                    	'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:delRow(this);" title="<?php 
    echo bx_html_attribute(_t('_Delete'));
    ?>
"><i class="sys-icon times"></i></a>' +
                		'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:moveUpRow(this);" title="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_move_up'));
    ?>
"><i class="sys-icon arrow-up"></i></a>' +
                		'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:moveDownRow(this);" title="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_move_down'));
    ?>
"><i class="sys-icon arrow-down"></i></a>' +
                    '</th>' +
                '</tr>'
            );

            iNextInd ++;

            sortZebra();
        }

        function delRow( eImg )
        {
            $( eImg ).parent().parent().remove();
            sortZebra();
        }

        function moveUpRow( eImg )
        {
            var oCur = $( eImg ).parent().parent();
            var oPrev = oCur.prev( ':not(.headers)' );
            if( !oPrev.length )
                return;

            // swap elements values
            var oCurElems  = $('input', oCur.get(0));
            var oPrevElems = $('input', oPrev.get(0));

            oCurElems.each( function(iInd) {
                var oCurElem  = $( this );
                var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );

                // swap them
                var sCurValue = oCurElem.val();
                oCurElem.val( oPrevElem.val() );
                oPrevElem.val( sCurValue );
            } );
        }

        function moveDownRow( eImg )
        {
            var oCur = $( eImg ).parent().parent();
            var oPrev = oCur.next( ':not(.headers)' );
            if( !oPrev.length )
                return;

            // swap elements values
            var oCurElems  = $('input', oCur.get(0));
            var oPrevElems = $('input', oPrev.get(0));

            oCurElems.each( function(iInd) {
                var oCurElem  = $( this );
                var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );

                // swap them
                var sCurValue = oCurElem.val();
                oCurElem.val( oPrevElem.val() );
                oPrevElem.val( sCurValue );
            } );
        }

        function sortZebra()
        {
            $( '#listEdit tr:even' ).removeClass( 'even odd' ).addClass( 'even' );
            $( '#listEdit tr:odd'  ).removeClass( 'even odd' ).addClass( 'odd'  );
        }

        //just a design
        $( document ).ready( sortZebra );
    </script>

    <form action="<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
" method="post" enctype="multipart/form-data">
    	<div class="adm-pv-cp-selector bx-def-margin-bottom">
			<div class="adm-pv-cp-item">
				<span><?php 
    echo _t('_adm_pvalues_txt_select_list');
    ?>
:</span>
				<div class="input_wrapper input_wrapper_select bx-def-margin-sec-leftright clearfix">
					<select class="form_input_select bx-def-font-inputs" name="list" onchange="if( this.value != '' ) window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
' + '?list=' + encodeURIComponent( this.value ) + '<?php 
    echo $sPopupAdd;
    ?>
';"><?php 
    echo genListOptions($aLists, $sList);
    ?>
</select>
				</div>
			</div>
			<div class="input_wrapper input_wrapper_submit clearfix">
				<input  class="form_input_submit bx-btn" type="button" value="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_create_new'));
    ?>
" onclick="createNewList();" />
			</div>
		</div>
        <table class="bx-def-table" id="listEdit" cellpadding="0" cellspacing="1"><?php 
    $iNextInd = $sList !== '' ? genListRows($sList_db) : 0;
    ?>
</table>
		<div class="adm-pv-submit bx-def-margin-top">
			<input type="hidden" name="popup" value="<?php 
    echo $iAmInPopup;
    ?>
" />
			<input type="hidden" name="action" value="Save" />
			<div class="input_wrapper input_wrapper_submit clearfix">
				<input class="form_input_submit bx-btn" type="submit" name="submit" value="<?php 
    echo bx_html_attribute(_t('_Save'));
    ?>
" />
			</div>
		</div>
        <script type="text/javascript">
            iNextInd = <?php 
    echo $iNextInd;
    ?>
;
        </script>
    </form>
    <?php 
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => ob_get_clean()));
}
示例#3
0
function PageCompPageMainCode()
{
    global $iAmInPopup;
    global $aFields;
    $sDeleteIcon = $GLOBALS['oAdmTemplate']->getImageUrl('minus1.gif');
    $sUpIcon = $GLOBALS['oAdmTemplate']->getImageUrl('arrow_up.gif');
    $sDownIcon = $GLOBALS['oAdmTemplate']->getImageUrl('arrow_down.gif');
    $sPopupAdd = $iAmInPopup ? '&popup=1' : '';
    $sResultMsg = '';
    if (isset($_POST['action']) and $_POST['action'] == 'Save' and isset($_POST['PreList']) and is_array($_POST['PreList'])) {
        if (true === saveList($_POST['list'], $_POST['PreList'])) {
            $sResultMsg = _t('_Success');
        } else {
            $sResultMsg = _t('_Failed to apply changes');
        }
    }
    //get lists
    $aLists = array('' => '- Select -');
    $aKeys = getPreKeys();
    foreach ($aKeys as $aList) {
        $aLists[$aList['Key']] = $aList['Key'];
    }
    $sListIn = bx_get('list');
    if ($sListIn !== false) {
        $sList_db = process_db_input($sListIn);
        $sList = process_pass_data($sListIn);
        $iCount = getPreValuesCount($sListIn);
        if (!$iCount) {
            //if no rows returned...
            $aLists[$sList] = $sList;
        }
        //create new list
    } else {
        $sList = '';
    }
    ob_start();
    if ($sResultMsg) {
        echo MsgBox($sResultMsg);
    }
    ?>
	
	<script type="text/javascript">
		function createNewList() {
			var sNewList = prompt( 'Please enter name of new list' );
			
			if( sNewList == null )
				return false;
			
			sNewList = $.trim( sNewList );
			
			if( !sNewList.length ) {
				alert( 'You should enter correct name' );
				return false;
			}
			
			window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
?list=' + encodeURIComponent( sNewList ) + '<?php 
    echo $sPopupAdd;
    ?>
';
		}
		
		function addRow( eImg ) {

			$( eImg ).parent().parent().before(
				'<tr>' +
				<?php 
    foreach ($aFields as $sField => $sHelp) {
        ?>
					'<td><input type="text" class="value_input" name="PreList[' + iNextInd + '][<?php 
        echo $sField;
        ?>
]" value="" /></td>' +
					<?php 
    }
    ?>
					'<th>' +
						'<img src="<?php 
    echo $sDeleteIcon;
    ?>
"     class="row_control" title="Delete"    alt="Delete" onclick="delRow( this );" />' +
						'<img src="<?php 
    echo $sUpIcon;
    ?>
"   class="row_control" title="Move up"   alt="Move up" onclick="moveUpRow( this );" />' +
						'<img src="<?php 
    echo $sDownIcon;
    ?>
" class="row_control" title="Move down" alt="Move down" onclick="moveDownRow( this );" />' +
					'</th>' +
				'</tr>'
			);
			
			iNextInd ++;
			
			sortZebra();
		}
		
		function delRow( eImg ) {
			$( eImg ).parent().parent().remove();
			sortZebra();
		}
		
		function moveUpRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.prev( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function moveDownRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.next( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function sortZebra() {
			$( '#listEdit tr:even' ).removeClass( 'even odd' ).addClass( 'even' );
			$( '#listEdit tr:odd'  ).removeClass( 'even odd' ).addClass( 'odd'  );
		}
		
		//just a design
		$( document ).ready( sortZebra );
	</script>
	
	<form action="<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
" method="post">
		<table id="listEdit" cellpadding="0" cellspacing="0">
			<tr>
				<th colspan="<?php 
    echo count($aFields) + 1;
    ?>
">
					Select a list:
					<select name="list"
					  onchange="if( this.value != '' ) window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
' + '?list=' + encodeURIComponent( this.value ) + '<?php 
    echo $sPopupAdd;
    ?>
';">
						<?php 
    echo genListOptions($aLists, $sList);
    ?>
					</select>
					<input type="button" value="Create New" onclick="createNewList();" />
				</th>
			</tr>
	<?php 
    if ($sList !== '') {
        $iNextInd = genListRows($sList_db);
        ?>
			<tr>
				<th colspan="8">
					<input type="hidden" name="popup" value="<?php 
        echo $iAmInPopup;
        ?>
" />
					<input type="submit" name="action" value="Save" />
				</th>
			</tr>
		<?php 
    } else {
        $iNextInd = 0;
    }
    ?>
		</table>
		
		<script type="text/javascript">
			iNextInd = <?php 
    echo $iNextInd;
    ?>
;
		</script>
	</form>
	<?php 
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => ob_get_clean()));
}