echo $language_id; ?> &pid='+pid); } } //--> </script> <table width="99%" border="0" cellspacing="0" cellpadding="2" class="main_text"> <tr> <td align="<?php echo Application::Get('defined_right'); ?> "> <?php draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $language_id, '', 'onchange="appGoTo(\'admin=pages_trash&language_id=\'+this.value)"'); ?> </td> </tr> </table> <?php draw_content_start(); if ($all_pages[1] > 0) { ?> <table width="100%" border="0" cellspacing="0" cellpadding="2" class="main_text"> <tr><td colspan="6" height="3px" nowrap></td></tr> <tr> <th align="<?php echo Application::Get('defined_left'); ?>
public function DrawViewMode() { $this->IncludeJSFunctions(); $this->BeforeViewRecords(); $sorting_fields = self::GetParameter('sorting_fields'); $sorting_types = self::GetParameter('sorting_types'); $page = self::GetParameter('page'); $total_pages = $page; $rid = self::GetParameter('rid'); $action = self::GetParameter('action'); $operation = self::GetParameter('operation'); $operation_type = self::GetParameter('operation_type'); $operation_field = self::GetParameter('operation_field'); $search_status = self::GetParameter('search_status'); $concat_sign = preg_match('/\\?/', $this->formActionURL) ? '&' : '?'; $colspan = count($this->arrViewModeFields) + 1; $start_row = 0; $total_records = 0; $sort_by = ''; $export_content = array(); $calendar_fields = array(); $nl = "\n"; // prepare changing of language //---------------------------------------------------------------------- if ($operation == 'change_language' && $operation_type != '' && strlen($operation_type) == 2) { $this->languageId = $operation_type; // added to prevent search with entered word on changing language $search_status = ''; } // prepare sorting data //---------------------------------------------------------------------- if ($this->isSortingAllowed) { if ($operation == 'sorting') { if ($sorting_fields != '') { if ($action == 'delete') { // $sorting_types } else { if (strtolower($sorting_types) == 'asc') { $sorting_types = 'DESC'; } else { $sorting_types = 'ASC'; } } $sort_type = isset($this->arrViewModeFields[$sorting_fields]['sort_type']) ? $this->arrViewModeFields[$sorting_fields]['sort_type'] : 'string'; $sort_by = isset($this->arrViewModeFields[$sorting_fields]['sort_by']) ? $this->arrViewModeFields[$sorting_fields]['sort_by'] : $sorting_fields; if ($sort_type == 'numeric') { $this->ORDER_CLAUSE = ' ORDER BY ABS(' . $sort_by . ') ' . $sorting_types . ' '; } else { $this->ORDER_CLAUSE = ' ORDER BY ' . $sort_by . ' ' . $sorting_types . ' '; } } else { $sorting_types = 'ASC'; } } else { if ($sorting_fields != '' && $sorting_types != '') { $this->ORDER_CLAUSE = ' ORDER BY ' . $sorting_fields . ' ' . $sorting_types . ' '; } } } // prepare filtering data //---------------------------------------------------------------------- if ($this->isFilteringAllowed) { if ($search_status == 'active') { if ($this->WHERE_CLAUSE == '') { $this->WHERE_CLAUSE .= ' WHERE 1=1 '; } $count = 0; foreach ($this->arrFilteringFields as $key => $val) { $custom_handler = isset($val['custom_handler']) ? $val['custom_handler'] : false; if (!$custom_handler && self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) !== '') { $sign = '='; $sign_start = ''; $sign_end = ''; if ($val['sign'] == '=') { $sign = '='; } else { if ($val['sign'] == '>=') { $sign = '>='; } else { if ($val['sign'] == '<=') { $sign = '<='; } else { if ($val['sign'] == 'like%') { $sign = 'LIKE'; $sign_end = '%'; } else { if ($val['sign'] == '%like') { $sign = 'LIKE'; $sign_start = '%'; } else { if ($val['sign'] == '%like%') { $sign = 'LIKE'; $sign_start = '%'; $sign_end = '%'; } } } } } } $key_value = self::GetParameter('filter_by_' . $val['table'] . $val['field'], false); if (isset($val['table']) && $val['table'] != '') { $field_name = $val['table'] . '.' . $val['field']; } else { $field_name = $val['field']; } $date_format = isset($val['date_format']) ? $val['date_format'] : ''; $type = isset($val['type']) ? $val['type'] : ''; if ($type == 'calendar') { $key_value = $this->PrepareDateTime($key_value, $date_format); } if ($this->IsSecureField($key, $val)) { $field_name = $this->UncryptValue($field_name, $val, false); } $this->WHERE_CLAUSE .= ' AND ' . $field_name . ' ' . $sign . ' \'' . $sign_start . mysql_real_escape_string($key_value) . $sign_end . '\' '; } } } } // prepare paging data //---------------------------------------------------------------------- if ($this->isPagingAllowed) { if (!is_numeric($page) || (int) $page <= 0) { $page = 1; } // set sql_mode to empty if you have Mixing of GROUP columns SQL issue - in connection.php file /// database_void_query('SET sql_mode = ""'); $sql = preg_replace('/SELECT\\b/i', 'SELECT COUNT(*) as mg_total_records, ', $this->VIEW_MODE_SQL, 1) . ' ' . $this->WHERE_CLAUSE . ' LIMIT 0, 1'; if ($this->debug) { $start_time = $this->GetFormattedMicrotime(); } $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($this->debug) { $finish_time = $this->GetFormattedMicrotime(); } $total_records = isset($result[0]['mg_total_records']) ? (int) $result[0]['mg_total_records'] : '1'; if ($this->debug) { if (!mysql_error()) { $this->arrSQLs['total_records_sql'] = '<i>Total Records</i> | T: ' . round((double) $finish_time - (double) $start_time, 4) . ' sec. <br>' . $sql; } else { $this->arrErrors['total_records_sql'] = $sql . '<br>' . mysql_error(); } } if ($this->pageSize == 0) { $this->pageSize = '10'; } $total_pages = (int) ($total_records / $this->pageSize); // when you back from other languages where more pages than on current if ($page > $total_pages + 1) { $page = 1; } if ($total_records % $this->pageSize != 0) { $total_pages++; } $start_row = ($page - 1) * $this->pageSize; } // check if there is move operation and perform it //---------------------------------------------------------------------- if ($operation == 'move') { // block if this is a demo mode if (strtolower(SITE_MODE) == 'demo') { $this->error = _OPERATION_BLOCKED; } else { $operation_field_p = explode('#', $operation_field); $operation_field_p0 = explode('-', $operation_field_p[0]); $operation_field_p1 = explode('-', $operation_field_p[2]); $of_first = isset($operation_field_p0[0]) ? $operation_field_p0[0] : ''; $of_second = isset($operation_field_p0[1]) ? $operation_field_p0[1] : ''; $of_name = $operation_field_p[1]; $of_first_value = isset($operation_field_p1[0]) ? $operation_field_p1[0] : ''; $of_second_value = isset($operation_field_p1[1]) ? $operation_field_p1[1] : ''; if ($of_first_value != '' && $of_second_value != '') { $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_second_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_first . '\''; database_void_query($sql); if ($this->debug) { $this->arrSQLs['select_move_1'] = $sql; } $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_first_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_second . '\''; database_void_query($sql); if ($this->debug) { $this->arrSQLs['select_move_2'] = $sql; } } } } $arrRecords = $this->GetAll($this->ORDER_CLAUSE, 'LIMIT ' . $start_row . ', ' . (int) $this->pageSize); if ($this->allowLanguages) { $arrLanguages = Languages::GetAllActive(); } if (!$this->isPagingAllowed) { $total_records = $arrRecords[1]; } echo '<form name="frmMicroGrid_' . $this->tableName . '" id="frmMicroGrid_' . $this->tableName . '" action="' . $this->formActionURL . '" method="post">' . $nl; draw_hidden_field('mg_prefix', $this->uPrefix); echo $nl; draw_hidden_field('mg_action', 'view'); echo $nl; draw_hidden_field('mg_rid', ''); echo $nl; draw_hidden_field('mg_sorting_fields', $sorting_fields); echo $nl; draw_hidden_field('mg_sorting_types', $sorting_types); echo $nl; draw_hidden_field('mg_page', $page); echo $nl; draw_hidden_field('mg_operation', $operation); echo $nl; draw_hidden_field('mg_operation_type', $operation_type); echo $nl; draw_hidden_field('mg_operation_field', $operation_field); echo $nl; draw_hidden_field('mg_search_status', $search_status); echo $nl; draw_hidden_field('mg_language_id', $this->languageId); echo $nl; draw_hidden_field('mg_operation_code', self::GetRandomString(20)); echo $nl; draw_token_field(); echo $nl; if ($this->actions['add'] || $this->allowLanguages || $this->allowRefresh || $this->isExportingAllowed) { echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table"> <tr>'; echo '<td align="' . Application::Get('defined_left') . '" valign="middle">'; if ($this->actions['add']) { echo '<input class="mgrid_button" type="button" name="btnAddNew" value="' . _ADD_NEW . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'add\');"> '; } if ($this->operationLinks != '') { echo $this->operationLinks; } echo '</td>'; echo '<td align="' . Application::Get('defined_right') . '" valign="middle">'; if ($this->isExportingAllowed) { if (strtolower(SITE_MODE) == 'demo' || !$arrRecords[1]) { echo '<span class="gray">[ ' . _EXPORT . ' ]</span> '; } else { if ($operation == 'switch_to_export') { echo '[ <a href="javascript:void(\'export|cancel\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_normal\');" title="' . _SWITCH_TO_NORMAL . '">' . _BUTTON_CANCEL . '</a> | ' . _DOWNLOAD . ' - <a href="javascript:void(\'csv\');" onclick="javascript:appGoToPage(\'index.php?admin=export&file=export.csv\')"><img src="images/microgrid_icons/csv.gif" alt="' . _DOWNLOAD . ' CSV"></a> ] '; } else { echo '<a href="javascript:void(\'export\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_export\');" title="' . _SWITCH_TO_EXPORT . '">[ ' . _EXPORT . ' ]</a> '; } } } if ($this->allowRefresh) { echo '<a href="javascript:void(\'refresh\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\');" title="' . _REFRESH . '"><img src="images/microgrid_icons/refresh.gif" alt="' . _REFRESH . '"></a>'; } echo '</td>'; if ($this->allowLanguages) { echo '<td align="' . Application::Get('defined_right') . '" width="80px">'; $this->allowLanguages ? draw_languages_box('mg_language_id', $arrLanguages[0], 'abbreviation', 'lang_name', $this->languageId, '', 'onchange="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'change_language\', this.value, \'language_id\');"') : ''; echo '</td>'; } echo ' </tr> <tr><td nowrap height="10px"></td></tr> </table>'; } if ($this->isFilteringAllowed) { echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table"> <tr> <td align="' . Application::Get('defined_left') . '">'; echo '<b>' . _FILTER_BY . '</b>: '; foreach ($this->arrFilteringFields as $key => $val) { if (!$this->IsVisible($val)) { continue; } $filter_field_value = $search_status == 'active' ? self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) : ''; if ($val['type'] == 'text') { echo $key . ': <input type="text" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="125"> '; } else { if ($val['type'] == 'dropdownlist') { if (is_array($val['source'])) { echo $key . ': <select class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" style="width:' . $val['width'] . '">'; echo '<option value="">-- ' . _SELECT . ' --</option>'; foreach ($val['source'] as $key => $val) { echo '<option ' . ($filter_field_value !== '' && $filter_field_value == $key ? ' selected="selected"' : '') . ' value="' . $this->GetDataDecoded($key) . '">' . $val . '</option>'; } echo '</select> '; } } else { if ($val['type'] == 'calendar') { $date_format = isset($val['date_format']) ? $val['date_format'] : ''; if ($date_format == 'mm/dd/yyyy') { $calendar_date_format = '%m-%d-%Y'; $placeholder_date_format = 'mm-dd-yyyy'; } else { if ($date_format == 'dd/mm/yyyy') { $calendar_date_format = '%d-%m-%Y'; $placeholder_date_format = 'dd-mm-yyyy'; } else { $calendar_date_format = '%Y-%m-%d'; $placeholder_date_format = 'yyyy-dd-mm'; } } echo $key . ': <input type="text" id="filter_cal' . $val['field'] . '" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="19" placeholder="' . $placeholder_date_format . '"> '; echo '<img id="filter_cal' . $val['field'] . '_img" src="images/microgrid_icons/cal.gif" alt="" title="' . _SET_TIME . '" style="cursor:pointer;">'; echo ' '; $calendar_fields[] = array('field' => 'filter_cal' . $val['field'], 'format' => $calendar_date_format); } } } } if (count($this->arrFilteringFields) > 0) { echo ' '; if ($search_status == 'active') { echo ' <input type="button" class="mgrid_button" name="btnReset" value="' . _BUTTON_RESET . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'reset_filtering\');">'; } echo ' <input type="button" class="mgrid_button" name="btnSearch" value="' . _SEARCH . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'filtering\')">'; } echo ' </td> </tr> <tr><td nowrap height="10px"></td></tr> </table>'; } // draw rows if ($arrRecords[1] > 0) { echo '<table width="100%" border="' . ($this->debug ? '1' : '0') . '" cellspacing="0" cellpadding="2" class="mgrid_table">'; // draw column headers echo '<tr>'; foreach ($this->arrViewModeFields as $key => $val) { $width = isset($val['width']) ? ' width="' . $val['width'] . '"' : ''; if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') { $align = ' align="right"'; } else { if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') { $align = ' align="left"'; } else { if (isset($val['align'])) { $align = ' align="' . $val['align'] . '"'; } else { $align = ''; } } } $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; $sortable = isset($val['sortable']) && $val['sortable'] !== '' ? $val['sortable'] : true; $th_class = $key == $sort_by ? ' class="th_sorted"' : ''; $title = isset($val['title']) ? $val['title'] : ''; if ($visible) { echo '<th' . $width . $align . $th_class . '>'; if ($this->isSortingAllowed && $sortable) { $field_sorting = 'DESC'; $sort_icon = ''; if ($key == $sorting_fields) { if (strtolower($sorting_types) == 'asc') { $sort_icon = ' <img src="images/microgrid_icons/up.png" alt="" title="asc">'; } else { if (strtolower($sorting_types) == 'desc') { $sort_icon = ' <img src="images/microgrid_icons/down.png" alt="" title="desc">'; } } $field_sorting = $sorting_types; } echo '<a href="javascript:void(\'sort\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'' . $key . '\', \'' . $field_sorting . '\', \'' . $page . '\', \'sorting\')"><b>' . $title . '</b></a>' . $sort_icon; $this->DrawHeaderTooltip($val); } else { echo '<label>' . $title . '</label>'; } echo '</th>'; if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') { $export_content[0][] = $val['title']; } } } if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) { echo '<th width="8%">' . _ACTIONS . '</th>'; } echo '</tr>'; echo '<tr><td colspan="' . $colspan . '" height="3px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; for ($i = 0; $i < $arrRecords[1]; $i++) { echo '<tr ' . ($this->isAlterColorsAllowed ? highlight(0) : '') . '>'; foreach ($this->arrViewModeFields as $key => $val) { if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') { $align = ' align="right"'; } else { if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') { $align = ' align="left"'; } else { if (isset($val['align'])) { $align = ' align="' . $val['align'] . '"'; } else { $align = ''; } } } $wrap = isset($val['nowrap']) && $val['nowrap'] == 'nowrap' ? ' nowrap="' . $val['nowrap'] . '"' : ' wrap'; $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; $movable = isset($val['movable']) && $val['movable'] !== '' ? $val['movable'] : false; if (isset($arrRecords[0][$i][$key])) { $field_value = $this->DrawFieldByType('view', $key, $val, $arrRecords[0][$i], false); if ($this->isAggregateAllowed && isset($this->arrAggregateFields[$key])) { $key_agreg = isset($this->arrAggregateFields[$key]['aggregate_by']) && $this->arrAggregateFields[$key]['aggregate_by'] !== '' ? $this->arrAggregateFields[$key]['aggregate_by'] : $key; if (!isset($this->arrAggregateFieldsTemp[$key])) { $this->arrAggregateFieldsTemp[$key] = array('sum' => $arrRecords[0][$i][$key_agreg], 'count' => 1); } else { $this->arrAggregateFieldsTemp[$key]['sum'] += $arrRecords[0][$i][$key_agreg]; $this->arrAggregateFieldsTemp[$key]['count']++; } } } else { if ($this->debug) { $this->arrWarnings['wrong_' . $key] = 'Field <b>' . $key . '</b>: wrong definition in View mode or at least one field has no value in SQL! Please check currefully your code.'; } $field_value = ''; } if ($visible) { $move_link = ''; if ($movable) { $move_prev_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i - 1]['id']) ? $arrRecords[0][$i - 1]['id'] : '') . '#'; $move_prev_id .= $key . '#'; $move_prev_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i - 1][$key]) ? $arrRecords[0][$i - 1][$key] : ''); $move_next_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i + 1]['id']) ? $arrRecords[0][$i + 1]['id'] : '') . '#'; $move_next_id .= $key . '#'; $move_next_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i + 1][$key]) ? $arrRecords[0][$i + 1][$key] : ''); if (isset($arrRecords[0][$i - 1]['id'])) { $move_link .= ' <a href="javascript:void(\'move|up\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'up\', \'' . $move_prev_id . '\')">'; $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/up.png" style="margin-bottom:2px" alt="" title="' . _UP . '">' : _UP; $move_link .= '</a>'; } else { $move_link .= ' <span style="width:11px;height:11px;"></span>'; } if (isset($arrRecords[0][$i + 1]['id'])) { $move_link .= '<a href="javascript:void(\'move|down\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'down\', \'' . $move_next_id . '\')">'; $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/down.png" style="margin-top:2px" alt="" title="' . _DOWN . '">' : (isset($arrRecords[0][$i - 1]['id']) ? '/' : '') . _DOWN; $move_link .= '</a>'; } else { $move_link .= '<span style="width:11px;height:11px;"></span>'; } } echo '<td' . $align . $wrap . '>' . $field_value . $move_link . '</td>'; if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') { $export_content[$i + 1][] = str_replace(',', '', strip_tags($field_value)); } } } if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) { echo '<td align="center" nowrap="nowrap">'; if ($this->actions['details']) { echo '<a href="javascript:void(\'details|' . $arrRecords[0][$i][$this->primaryKey] . '\');" title="' . _VIEW_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'details\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/details.gif" title="' . _VIEW_WORD . '" alt="" border="0" style="margin:0px; padding:0px;" height="16px">' : _VIEW_WORD) . '</a>'; } if ($this->actions['edit']) { if ($this->actions['details']) { echo ' ' . ($this->actionIcons ? ' ' : '') . draw_divider(false) . ' '; } echo '<a href="javascript:void(\'edit|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _EDIT_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'edit\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/edit.gif" title="' . _EDIT_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _EDIT_WORD) . '</a>'; } if ($this->actions['delete']) { if ($this->actions['edit'] || $this->actions['details']) { echo ' ' . ($this->actionIcons ? ' ' : '') . draw_divider(false) . ' '; } echo '<a href="javascript:void(\'delete|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _DELETE_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'delete\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/delete.gif" title="' . _DELETE_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _DELETE_WORD) . '</a>'; } echo ' </td>'; } echo '</tr>'; } // for // draw aggregate fields row if ($this->isAggregateAllowed) { echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; echo '<tr>'; foreach ($this->arrViewModeFields as $key => $val) { $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; if ($visible) { $ag_field_total = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['sum'] : 0; $ag_field_count = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['count'] : 0; $ag_field_function = strtoupper(isset($this->arrAggregateFields[$key]['function']) ? $this->arrAggregateFields[$key]['function'] : ''); $ag_field_align = strtoupper(isset($this->arrAggregateFields[$key]['align']) ? $this->arrAggregateFields[$key]['align'] : 'center'); $ag_decimal_place = isset($this->arrAggregateFields[$key]['decimal_place']) ? (int) $this->arrAggregateFields[$key]['decimal_place'] : 2; $ag_field_value = ''; if ($ag_field_function == 'SUM') { $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total, $ag_decimal_place) : ''; } else { if ($ag_field_function == 'AVG') { $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total / $ag_field_count, $ag_decimal_place) : ''; } } echo '<td align="' . $ag_field_align . '">' . ($ag_field_function != '' ? $ag_field_function . '=' : '') . $ag_field_value . '</td>'; } } echo '</tr>'; echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; } else { echo '<tr><td colspan="' . $colspan . '" height="15px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; } echo '</table>'; echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table">'; echo '<tr valign="top">'; echo '<td>'; if ($this->isPagingAllowed) { echo '<b>' . _PAGES . ':</b> '; for ($i = 1; $i <= $total_pages; $i++) { echo '<a class="paging_link" href="javascript:void(\'paging\')" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'' . $i . '\', \'\')">' . ($i == $page ? '<b>[' . $i . ']</b>' : $i) . '</a> '; } } echo '</td>'; echo '<td align="' . Application::Get('defined_right') . '">'; $row_from = $start_row + 1; $row_to = $start_row + $this->pageSize < $total_records ? $start_row + $this->pageSize : $total_records; echo '<b>' . _TOTAL . '</b>: ' . ($row_from < $row_to ? $row_from . ' - ' . $row_to : $row_from) . ' / ' . $total_records; echo '</td>'; echo '</tr>'; echo '</table>'; // prepare export file //---------------------------------------------------------------------- if ($operation == 'switch_to_export') { if (strtolower(SITE_MODE) == 'demo') { $this->error = _OPERATION_BLOCKED; } else { $export_content_count = count($export_content); $fe = @fopen('tmp/export/export.csv', 'w+'); @fwrite($fe, ""); for ($i = 0; $i < $export_content_count; $i++) { @fputcsv($fe, $export_content[$i]); } @fclose($fe); } } } else { draw_message(_NO_RECORDS_FOUND, true, true, false, 'width:100%'); //if($this->debug) $this->arrSQLs['select'] = $this->VIEW_MODE_SQL.' '.$this->WHERE_CLAUSE.' '.$this->ORDER_CLAUSE.' LIMIT '.$start_row.', '.(int)$this->pageSize; } echo '</form>'; $this->CalendarSetupFields($calendar_fields); $this->AfterViewRecords(); $this->DrawVersionInfo(); $this->DrawRunningTime(); $this->DrawErrors(); $this->DrawWarnings(); $this->DrawSQLs(); $this->DrawPostInfo(); }
/** * Draws Edit Form * @param $key * @param $draw */ public function DrawEditForm($key = '0', $draw = true) { $total_languages = Languages::GetAllLanguages(); $key_value = $key_text = ''; $default_lang_name = 'English'; $default_lang_abbr = 'en'; $lang_to_dir = Languages::GetLanguageDirection($this->languageId); $default_lang_text = ''; $align_left = Application::Get('lang_dir') == 'ltr' ? 'left' : 'right'; $align_right = Application::Get('lang_dir') == 'ltr' ? 'right' : 'left'; $output = ''; $sql = 'SELECT * FROM ' . TABLE_VOCABULARY . ' WHERE id = ' . (int) $key; if ($row = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY)) { $key_value = $row['key_value']; $key_text = $row['key_text']; $this->currentKey = $key_value; } $sql = 'SELECT * FROM ' . TABLE_LANGUAGES . ' WHERE is_default = 1'; if ($row = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY)) { $default_lang_name = $row['lang_name']; $default_lang_abbr = $row['abbreviation']; $sql = 'SELECT * FROM ' . TABLE_VOCABULARY . ' WHERE key_value = \'' . $this->currentKey . '\' AND language_id = \'' . $default_lang_abbr . '\''; if ($row = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY)) { $default_lang_text = strip_tags($row['key_text'], '<b><i><u><br>'); } } if ($default_lang_abbr != $this->languageId) { $output .= '<script type="text/javascript"> google.load("language", "1"); function TranslateText(response){ if(response.data){ jQuery("#txt_message").html("' . _COMPLETED . '!"); jQuery("#txt_key_value").val(response.data.translations[0].translatedText); jQuery("#btnTranslate").attr("disabled", false); }else{ //response.error.message jQuery("#txt_message").html("This feature is only available for Google paid accounts! Please check you have a valid API Key."); } } function GoAndTranslate(){'; // Block all operations in demo mode if (strtolower(SITE_MODE) == 'demo') { $output .= 'alert(\'' . _OPERATION_BLOCKED . '\'); return false; '; } else { $output .= '// grabbing the text to translate var YOUR_API_KEY = ""; var text = jQuery("#txt_key_value").val(); if(text.indexOf(" ") <= 0) text = text.toLowerCase(); jQuery("#btnTranslate").attr("disabled", true); jQuery("#txt_message").html(""); var newScript = document.createElement("script"); newScript.type = "text/javascript"; // WARNING: be aware that YOUR-API-KEY inside html is viewable by all your users. // Restrict your key to designated domains or use a proxy to hide your key // to avoid misuage by other party. var source = "https://www.googleapis.com/language/translate/v2?key="+YOUR_API_KEY+"&source=' . $default_lang_abbr . '&target=' . $this->languageId . '&callback=TranslateText&q=" + text; newScript.src = source; // When we add this script to the head, the request is sent off. document.getElementsByTagName("head")[0].appendChild(newScript);'; } $output .= '} </script>'; } $output .= '<form action="index.php?admin=vocabulary" method="post">'; $output .= draw_hidden_field('submition_type', '1', false); $output .= draw_hidden_field('key', $key, false); $output .= draw_hidden_field('filter_by', $this->filterBy, false); $output .= draw_hidden_field('language_id', $this->languageId, false); $output .= draw_token_field(false); $output .= '<table align="center" width="99%" border="0" cellspacing="0" cellpadding="3" class="main_text"> <tr valign="top"> <td><b>' . _EDIT_WORD . '</b></td> <td><div id="txt_message" style="color:#00a600"></div></td> <td width="20px" nowrap="nowrap"></td> <td align="' . $align_right . '">' . draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $this->languageId, '', 'disabled="disabled"', false) . '</td> </tr> <tr valign="top"> <td align="' . $align_right . '" width="90px">' . _KEY . ':</td> <td align="' . $align_left . '" colspan="2"> ' . $key_value . ' ' . draw_hidden_field('txt_key', $key_value, false) . ' </td> <td></td> </tr>'; $output .= '<tr valign="top"> <td align="' . $align_right . '">' . _VALUE . ' <span style="color:#c13a3a">*</span>:</td> <td align="' . $align_left . '"> <textarea dir="' . $lang_to_dir . '" style="width:100%;height:60px;overflow:auto;padding:3px;" name="txt_key_value" id="txt_key_value" maxlength="4096">' . decode_text($key_text) . '</textarea> </td> <td></td> <td align="right" width="240px">'; if ($default_lang_abbr != $this->languageId) { $output .= '<nobr> ' . $default_lang_name . ' » ' . strtoupper($this->languageId) . ' <input class="form_button" type="button" id="btnTranslate" name="submit" style="width:150px" onclick="GoAndTranslate()" value="' . _TRANSLATE_VIA_GOOGLE . '" /> <input class="form_button" type="reset" name="btnReset" title="' . _RESET . '" value="R" /> </nobr><br /><br />'; } $output .= '<input class="form_button" type="submit" name="submit" value="' . decode_text(_BUTTON_UPDATE) . '"> <input class="form_button" type="button" onclick="appGoTo(\'admin=vocabulary' . $this->langIdByUrl . $this->filterByUrl . '\')" value="' . decode_text(_BUTTON_CANCEL) . '"> </td> </tr>'; if ($default_lang_abbr != $this->languageId) { $output .= '<tr valign="top"> <td align="' . $align_right . '" width="110px">' . $default_lang_name . ':</td> <td align="' . $align_left . '">' . $default_lang_text . '</td> <td colspan="2"></td> </tr>'; } $output .= '<tr align="right"><td colspan="4"></td></tr> </table> </form>'; if ($draw) { echo $output; } else { return $output; } }
:</td> <td><?php echo $arr_account_types[$objAdmin->GetParameter('account_type')]; ?> </td> </tr> <tr> <td width="150px"> <?php echo _PREFERRED_LANGUAGE; ?> <span class="required">*</span>:</td> <td> <?php // display language $total_languages = Languages::GetAllActive(); draw_languages_box('preferred_language', $total_languages[0], 'abbreviation', 'lang_name', $objAdmin->GetParameter('preferred_language')); ?> </td> </tr> <tr> <td width="150px"> <?php echo _USERNAME; ?> :</td> <td><?php echo $objAdmin->account_name; ?> </td> </tr> <tr><td colspan="2"> </td></tr> <tr>
<td style="padding-left:5px;" colspan="3"><input class="form_button" type="submit" name="btnSubmit" value="' . _BUTTON_CHANGE . '"></td> </tr> </table> </form>'; } else { if ($tabid == '1_2') { $tab_content_2 = '<form name="frmSettings" id="frmSettings" action="index.php?admin=settings" method="post"> ' . draw_hidden_field('tabid', $tabid, false) . ' ' . draw_token_field(false) . ' <table width="99%" border="0" cellspacing="5" cellpadding="5" class="main_text"> <tr valign="top"> <td width="150px">' . _LANGUAGE . ':</td> <td>'; $all_languages = Languages::GetAllActive(); $tab_content_2 .= draw_languages_box('sel_language_id', $all_languages[0], 'abbreviation', 'lang_name', $language_id, '', 'onchange="javascript:appFormSubmit(\'frmSettings\');"', false); $tab_content_2 .= '</td> </tr> </table> </form> <fieldset style="margin:10px;"> <legend>' . _HEADERS_AND_FOOTERS . '</legend> <form action="index.php?admin=settings" method="post"> ' . draw_hidden_field('submition_type', 'visual_settings', false) . ' ' . draw_hidden_field('tabid', $tabid, false) . ' ' . draw_hidden_field('sel_language_id', $language_id, false) . ' ' . draw_token_field(false) . ' <table width="99%" border="0" cellspacing="5" cellpadding="5" class="main_text"> <tr valign="top">
?> <tr><td colspan="3" nowrap="nowrap" height="3px"></td></tr> <tr> <td><?php echo _LANGUAGE; ?> <span class="required">*</span>:</td> <td colspan="2"> <?php // display language $total_languages = Languages::GetAllActive(); if (Application::Get('page_id') != 'home') { draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $objPage->GetParameter('language_id'), '', 'disabled="disabled"'); } else { draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $language_id, '', 'onchange="Language_OnChange(this.value)"'); } ?> </td> </tr> <?php if (Application::Get('page_id') != 'home') { ?> <tr> <td><?php echo _CONTENT_TYPE; ?> :</td> <td colspan="2"> <?php
<td> <?php echo Menu::DrawMenuAccessSelectBox(); ?> </td> </tr> <tr> <td><?php echo _LANGUAGE; ?> <span class="required">*</span>:</td> <td> <?php // display language $total_languages = Languages::GetAllActive(); draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $language_id); ?> </td> </tr> <tr><td height="10px" nowrap="nowrap"></td></tr> <tr> <td colspan="2"> <input class="form_button" type="submit" name="subAddMenu" value="<?php echo _BUTTON_CREATE; ?> "> <input class="form_button" type="button" onclick="javascript:appGoTo('admin=menus')" value="<?php echo _BUTTON_CANCEL; ?> "> </td>