Example #1
0
 function endArea()
 {
     global $CFG;
     $method_name = Form::peLabel($CFG->method_id, 'endArea');
     $method = DB::getRecord('admin_controls_methods', $CFG->method_id);
     if (!$CFG->pm_editor) {
         $HTML = '<div class="clear"></div></div>';
     } else {
         $HTML = "<div class=\"o\">[End Area] {$method_name}</div>";
     }
     $order = $method['order'] > 0 ? $method['order'] : '0';
     $this->areas_e[$order][] = $HTML;
 }
Example #2
0
    function addTable($table, $table_fields = false, $folder_field = false, $url = false, $target_elem_id = false, $link_is_tab = false, $alert_condition1 = false, $alert_condition2 = false)
    {
        global $CFG;
        if (DB::tableExists($table)) {
            $this->tables[$table] = array('table_fields' => $table_fields, 'folder_field' => $folder_field, 'url' => $url, 'target_elem_id' => $target_elem_id, 'method_id' => $CFG->method_id, 'link_is_tab' => $link_is_tab, 'alert_condition1' => $alert_condition1, 'alert_condition2' => $alert_condition2);
        }
        if ($CFG->pm_editor) {
            echo '
			<li>' . $table . ' [addTable] ' . Form::peLabel($CFG->method_id, 'addTable') . '</li>';
        }
        echo '
		<input type="hidden" class="added_table" value="' . $table . '" />
		<input type="hidden" id="table_' . $table . '_fields" value="' . implode('|', $table_fields) . '" />';
    }
Example #3
0
 function display()
 {
     global $CFG;
     if ($this->is_inset && !($CFG->id > 0)) {
         return false;
     }
     $link_prefix = $CFG->backstage_mode ? 'index.php?is_tab=1&current_url=' : '';
     $HTML = "\n\t\t<div class=\"area full_box inset_tabs\">  \n\t\t\t<h2>{$legend}</h2>\n\t\t\t<div class=\"box_bar\"></div>\n\t\t\t<div class=\"box_tl\"></div>\n\t\t\t<div class=\"box_tr\"></div>\n\t\t\t<div class=\"box_bl\"></div>\n\t\t\t<div class=\"box_br\"></div>\n\t\t\t<div class=\"t_shadow\"></div>\n\t\t\t<div class=\"r_shadow\"></div>\n\t\t\t<div class=\"b_shadow\"></div>\n\t\t\t<div class=\"l_shadow\"></div>\n\t\t\t<div class=\"box_b\"></div>\n\t\t\t<div class=\"a_tabs\">";
     if (is_array($this->tabs)) {
         foreach ($this->tabs as $name => $properties) {
             if (User::permission(0, 0, $properties['url'], false, $properties['is_tab']) > 0) {
                 $key = $properties['order'];
                 $link_prefix1 = $CFG->backstage_mode ? 'index.php?inset_id=' . $CFG->id . '&inset_id_field=' . $properties['inset_id_field'] . '&inset_url=' . $properties['url'] . '&is_tab=' . $properties['is_tab'] . '&inset_i=' . $this->i . '&current_url=' : '';
                 $selected = !is_array($first_tab) || $properties['selected'] ? 'visible' : '';
                 $first_tab = !is_array($first_tab) || $properties['selected'] ? $properties : $first_tab;
                 $query_string = Link::parseVariables($properties['variables']);
                 $query_string = $query_string ? '?' . $query_string : '';
                 $identifier = !empty($properties['identifier']) ? $properties['identifier'] : "tabs_{$this->i}_blank";
                 $tab_identifier = $this->is_navigation ? (!strstr($properties['url'], '?') ? '?' : '&') . 'tab_identifier=' . $key : '';
                 $onclick = !empty($properties['url']) ? ' onclick="tabsSelectTab(\'' . $link_prefix1 . $properties['url'] . $query_string . $tab_identifier . '\',\'' . $this->target_elem . '\',this)" ' : '';
                 $pm_method = $CFG->pm_editor ? 'pm_method' : '';
                 //$del_id = ($this->is_navigation) ? "id=\"del_tab_$key\"" : '';
                 if ($CFG->pm_editor) {
                     $method_name = Form::peLabel($properties['method_id'], 'makeTab');
                 }
                 $HTML_ARR[$key] = '<a class="a_tab ' . $selected . ' ' . $pm_method . '" ' . $onclick . ' id="' . $identifier . '"><div class="contain1">' . $name . '</div><div class="l"></div><div class="r"></div><div class="c"></div></a>' . $method_name;
             }
         }
     }
     ksort($HTML_ARR);
     $HTML .= implode($HTML_ARR);
     $HTML .= '</div><div class="contain">';
     echo $HTML;
     if ($this->is_inset) {
         $CFG->inset_id = $CFG->id;
         $CFG->inset_id_field = $first_tab['inset_id_field'];
         $CFG->inset_target_elem = $this->target_elem;
         $CFG->inset_is_tab = $first_tab['is_tab'];
         $CFG->inset_url = $first_tab['url'];
         $CFG->inset_i = $this->i;
         echo '<div class="inset_area" id="inset_area_' . $this->i . '">';
         if (is_array($this->tabs)) {
             $control = new Control($first_tab['url'], false, $first_tab['is_tab']);
         }
         echo '</div>';
     }
     echo '</div></div>';
 }
Example #4
0
 function includePage($url, $is_tab = false)
 {
     global $CFG;
     if ($CFG->pm_editor) {
         $method_name = Form::peLabel($CFG->method_id, 'includePage');
         $this->HTML[] = "[Include: {$url}] {$method_name}";
     } else {
         $was_tab = $CFG->is_tab;
         $CFG->is_tab = $is_tab;
         $CFG->in_include = true;
         $CFG->include_id = $this->row[str_replace('-', '_', $url) . '_include_id'];
         ob_start();
         $control = new Control($url, 'record', $is_tab);
         $this->HTML[] = '<include>' . ob_get_contents();
         ob_end_clean();
         $CFG->in_include = false;
         $CFG->is_tab = $was_tab;
     }
 }
Example #5
0
    function display($use_fckeditor = false, $require_email = false, $ask_website = false, $editor_height = false)
    {
        global $CFG;
        if ($CFG->backstage_mode && !($this->record_id > 0) && !$this->show_all) {
            return false;
        }
        $use_fckeditor = $this->use_fckeditor ? $this->use_fckeditor : $use_fckeditor;
        $require_email = $this->require_email ? $this->require_email : $require_email;
        $ask_website = $this->ask_website ? $this->ask_website : $ask_website;
        $editor_height = $this->editor_height ? $this->editor_height : $editor_height;
        if ($_REQUEST['comments_' . $this->i] && !$this->comments_closed) {
            if (!empty($_REQUEST['comments_' . $this->i]['comments1'])) {
                $_REQUEST['comments_' . $this->i]['comments'] = $_REQUEST['comments_' . $this->i]['comments1'];
                unset($_REQUEST['comments_' . $this->i]['comments1']);
            }
            $CFG->save_called = false;
            $form = new Form('comments_' . $this->i, false, false, $this->class . '_form', 'comments');
            $form->verify();
            if (!$form->errors) {
                $form->save();
                Messages::add($CFG->comments_sent_message);
                Messages::display();
            } else {
                $form->show_errors();
            }
        }
        $comments = Comments::get();
        $c = count(Comments::get(false, true));
        $show = $this->autoshow ? '' : 'style="display:none;"';
        if ($this->label) {
            if ($CFG->pm_editor) {
                $method_name = Form::peLabel($this->label['method_id'], 'label');
            }
            echo '<div class="grid_label"><div class="label">' . $this->label['text'] . ' ' . $method_name . '</div><div class="clear"></div></div>';
        }
        if (!$this->short_version) {
            if ($comments) {
                echo '<div class="expand">' . str_ireplace('[field]', $c, $CFG->comments_there_are) . ' ' . (!$_REQUEST['comments_' . $this->i] ? '<a href="#" onclick="showComments(' . $this->i . ',this);return false;">' . $CFG->comments_expand . '</a>' : '') . '<a style="display:none;" href="#" onclick="hideComments(' . $this->i . ',this);return false;">' . $CFG->comments_hide . '</a></div>';
            } else {
                echo '<div class="expand">' . $CFG->comments_none . ' <a href="#" onclick="showComments(' . $this->i . ',this);return false;">' . $CFG->comments_be_first . '</a><a style="display:none;" href="#" onclick="hideComments(' . $this->i . ',this);return false;">' . $CFG->comments_hide . '</a></div>';
            }
        }
        echo '
		<div id="comments_' . $this->i . '" class="' . $this->class . '" ' . (!$_REQUEST['comments_' . $this->i] ? $show : '') . '>';
        if ($comments) {
            Comments::show($comments);
        }
        echo '
			<div id="movable_form" style="display:none;">';
        if (!$this->comments_closed) {
            Comments::showForm($use_fckeditor, $require_email, $ask_website, 1, $editor_height);
        }
        echo '
			</div>';
        if (!$this->comments_closed) {
            Comments::showForm($use_fckeditor, $require_email, $ask_website, 0, $editor_height);
        }
        echo '
			<div style="clear:both;height:0;"></div>
		</div>';
    }
Example #6
0
    function display($page = 0)
    {
        global $CFG;
        $filters = self::getFilterResults();
        $page = $page > 0 ? $page : $_SESSION['page' . $this->i];
        $_SESSION['page' . $this->i] = $page;
        $page = !($page > 0) || $_REQUEST['submit'] || $this->order_asc_changed || $this->order_by_changed ? 1 : $page;
        $fields = DB::getTableFields($this->table);
        $total_rows = DB::get($this->table, $this->fields, $page, $this->rows_per_page, $this->order_by, $this->order_asc, 1, $filters, $this->inset_id, $this->inset_id_field, false, false, false, false, false, false, false, $this->sql_filter, $this->group_by, $this->no_group_by);
        $data = DB::get($this->table, $this->fields, $page, $this->rows_per_page, $this->order_by, $this->order_asc, 0, $filters, $this->inset_id, $this->inset_id_field, false, false, false, false, false, false, false, $this->sql_filter, $this->group_by, $this->no_group_by);
        $HTML = "";
        if ($CFG->backstage_mode && User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && $this->inset_id === false) {
            $HTML .= '
			<form id="grid_form_' . $this->table . $this->i . '" name="grid_form_' . $this->table . $this->i . '" action="' . $CFG->self . '" method="POST">
				<input type="hidden" name="current_url" value="' . $CFG->url . '" />
				<input type="hidden" name="action" value="" />
				<input type="hidden" name="return_to_self" value="1" />';
            if (is_array($this->fields)) {
                foreach ($this->fields as $properties) {
                    if ($properties['aggregate_function']) {
                        $i_name = $properties['name'];
                        switch ($properties['aggregate_function']) {
                            case 'grand_total':
                                $grand_total[$i_name] = 0;
                                break;
                            case 'page_total':
                                $page_total[$i_name] = 0;
                                break;
                            case 'grand_avg':
                                $grand_avg[$i_name] = array();
                                break;
                            case 'page_avg':
                                $page_avg[$i_name] = array();
                                break;
                            case 'both_total':
                                $page_total[$i_name] = 0;
                                $grand_total[$i_name] = 0;
                                break;
                            case 'both_avg':
                                $page_avg[$i_name] = array();
                                $grand_avg[$i_name] = array();
                                break;
                        }
                    }
                }
            }
            if (is_array($this->fields)) {
                foreach ($this->fields as $properties) {
                    if ($properties['cumulative_function']) {
                        $i_name = $properties['name'];
                        if ($properties['cumulative_function'] == 'sum') {
                            $page_total[$i_name] = 0;
                            if ($grand_total) {
                                $grand_total[$i_name] = 0;
                            }
                        } elseif ($properties['cumulative_function'] == 'avg') {
                            $page_avg[$i_name] = array();
                            if ($grand_avg) {
                                $grand_avg[$i_name] = array();
                            }
                        }
                    }
                }
            }
        }
        if ($this->mode == 'list') {
            $HTML .= "<ul class=\"grid_list\">";
            if (is_array($data)) {
                $j = 0;
                foreach ($data as $row) {
                    $HTML .= "<li><ul>";
                    if (is_array($this->fields)) {
                        foreach ($this->fields as $name => $properties) {
                            $key = $name;
                            if (strstr($name, 'lll')) {
                                $name_parts = explode('lll', $name);
                                $name = $name_parts[0];
                            }
                            if ($this->inset_id > 0 && $name == $this->inset_id_field) {
                                continue;
                            }
                            $value = $row[$key];
                            $link_id = $row[$name . '_id'] ? $row[$name . '_id'] : $value;
                            $class = $properties['class'] ? "class=\"{$properties['class']}\"" : '';
                            if ($CFG->pm_editor) {
                                $method_name = Form::peLabel($properties['method_id'], 'field');
                            }
                            $HTML .= "<li {$class}>" . $method_name . "";
                            if (!empty($properties['is_media'])) {
                                reset($CFG->image_sizes);
                                $m_values = explode('|||', $value);
                                $m_size = !empty($properties['media_size']) ? $properties['media_size'] : key($CFG->image_sizes);
                                $m_limit = !empty($properties['media_amount']) ? $properties['media_amount'] : 1;
                                $HTML .= Gallery::multiple($properties['subtable'], $row['id'], $properties['name'], $properties['media_size'], 0, false, $properties['media_amount'], false, false, true);
                                $HTML .= '<div class="clear"></div>';
                            } else {
                                if ($fields[$name]['Type'] == 'datetime' || @in_array($name, $foreign_dates)) {
                                    $value = date($CFG->default_date_format, strtotime($value));
                                } elseif ($fields[$name]['Type'] == "enum('Y','N')") {
                                    $value = $value == 'Y' ? '<div class="y_icon"></div>' : '<div class="n_icon"></div>';
                                }
                                if ($value['filter']) {
                                    $order_asc = $this->order_asc ? false : true;
                                    if ($this->order_by == $name) {
                                        $dir_img = $this->order_asc ? $CFG->up : $CFG->down;
                                    } else {
                                        $dir_img = false;
                                    }
                                    $HTML .= '<b>' . Link::url($this->link_url, $properties['header_caption'] . $dir_img, "filter{$this->i}={$name}&order_by{$this->i}={$this->order_by}&order_asc{$this->i}={$order_asc}&is_tab={$this->is_tab}", $this->filter_results, false, 'content') . ':</b> ';
                                } else {
                                    $HTML .= $this->show_list_captions ? '<b>' . $properties['header_caption'] . ':</b> ' : '';
                                }
                                if (empty($properties['link_url'])) {
                                    $HTML .= str_ireplace('|||', ' ', $value);
                                } else {
                                    $action = $CFG->backstage_mode ? '&action=record' : '';
                                    $value = str_replace('|||', ' ', $value);
                                    if (!empty($value)) {
                                        $HTML .= Link::url($properties['link_url'], $value, "id={$link_id}&is_tab={$properties['link_is_tab']}{$action}", false, false, $this->target_elem_id);
                                    }
                                }
                                if (is_array($page_total)) {
                                    if (array_key_exists($name, $page_total)) {
                                        $page_total[$name] += $value;
                                    }
                                }
                                if (is_array($page_avg)) {
                                    if (array_key_exists($name, $page_avg)) {
                                        $page_avg[$name][] = $value;
                                    }
                                }
                            }
                            $HTML .= "</li>";
                        }
                    }
                    if ($this->show_buttons) {
                        $HTML .= '<li><nobr>' . ($CFG->backstage_mode ? "<span><label for=\"{$row['id']}\">Select:</label><input id=\"{$row['id']}\" type=\"checkbox\" value=\"{$row['id']}\" class=\"grid_select checkbox_input\"/></span>" : '');
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 0) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=record&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'view', false, false, false, false, $CFG->view_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'edit', false, false, false, false, $CFG->edit_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= '<a href="#" class="delete" title="' . $CFG->delete_hover_caption . '" onclick="gridDelete(' . $row['id'] . ',\'' . $this->table . '\',this)"></a></li>';
                        }
                    }
                    $HTML .= '</nobr></li></ul>';
                    $j++;
                }
            } else {
                $HTML .= '<li>' . $CFG->grid_no_results . '</li>';
            }
            $HTML .= "</ul>";
        } elseif ($this->mode == 'graph' || $this->mode == 'graph_line' || $this->mode == 'graph_pie') {
            $name_column = $this->graph_name_column;
            $y_axis = $this->graph_value_column;
            $x_axis = $this->graph_x_axis;
            if (is_array($this->fields)) {
                foreach ($this->fields as $name => $properties) {
                    if (strstr($fields[$name]['Type'], 'varchar') || !$properties['is_op'] && !empty($properties['subtable'])) {
                        if (!$name_column) {
                            $name_column = $name;
                        }
                        $this->name_columns[$name] = $properties['header_caption'];
                    } elseif (strstr($fields[$name]['Type'], 'date')) {
                        if (!$x_axis) {
                            $x_axis = $name;
                        }
                        $this->x_columns[$name] = $properties['header_caption'];
                    } elseif (($properties['is_op'] || strstr($fields[$name]['Type'], 'int') || strstr($fields[$name]['Type'], 'double')) && $name != 'id' && empty($properties['subtable'])) {
                        if (!$y_axis) {
                            $y_axis = $name;
                        }
                        $this->value_columns[$name] = $properties['header_caption'];
                    }
                }
            }
            if ($data) {
                foreach ($data as $row) {
                    $x_values[] = strtotime($row[$x_axis]);
                    $y_values[] = $row[$y_axis];
                }
                $days = (max($x_values) - min($x_values)) / 86400;
                $max_x = max($x_values);
                $min_x = min($x_values);
                $timestamp = $min_x;
                if ($days <= 30) {
                    $time_unit = 'days';
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp += 86400;
                    }
                } elseif ($days > 30 && $days <= 183) {
                    $time_unit = 'weeks';
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp += 86400 * 7;
                    }
                } elseif ($days > 183 && $days <= 910) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 1 month')));
                    }
                } elseif ($days > 910 && $days <= 1820) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 2 months')));
                    }
                } elseif ($days > 1820 && $days <= 3640) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 4 months')));
                    }
                } elseif ($days > 3640 && $days <= 7280) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 6 months')));
                    }
                } elseif ($days > 7280 && $days <= 14560) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 8 months')));
                    }
                } elseif ($days > 14560 && $days <= 29120) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 10 months')));
                    }
                } elseif ($days > 29120 && $days <= 58240) {
                    $time_unit = 'years';
                    $timestamp = strtotime(date('1/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('1/1/Y', strtotime($p_name . ' + 1 year')));
                    }
                }
                $reps = 0;
                foreach ($data as $row) {
                    if (is_array($this->fields)) {
                        $name_value = $this->graph_combine != 'Y' ? $row[$name_column] : 'All';
                        $c_units = count($time_units);
                        $x_val = strtotime($row[$x_axis]);
                        for ($i = 0; $i < $c_units; $i++) {
                            if ($x_val >= $time_units[$i] && ($x_val < $time_units[$i + 1] || !$time_units[$i + 1])) {
                                $x_current = $time_units[$i];
                                break;
                            }
                        }
                        $key = $x_current;
                        if ($x_prev != $x_current) {
                            $y_current = false;
                            $reps = 0;
                        }
                        if ($this->fields[$y_axis]['is_op'] && !$this->fields[$y_axis]['run_in_sql']) {
                            $y_current = self::doOperation($y_axis, $this->fields[$y_axis], $row, $name_value);
                        } else {
                            $y_current = $y_current + $row[$y_axis];
                        }
                        $x_prev = $x_current;
                        if ($this->mode != 'graph_pie') {
                            if (!$graph_data[$name_value][$key]) {
                                $graph_data[$name_value][$key] = $y_current;
                            } else {
                                if ($this->fields[$y_axis]['cumulative_function'] == 'avg') {
                                    $graph_data[$name_value][$key] = ($graph_data[$name_value][$key] + $y_current) / $reps;
                                } else {
                                    $graph_data[$name_value][$key] += $y_current;
                                }
                            }
                        } else {
                            if (!$graph_data[1][$name_value]) {
                                $graph_data[1][$name_value] = $y_current;
                            } else {
                                if ($this->fields[$y_axis]['cumulative_function'] == 'avg') {
                                    $graph_data[1][$name_value] = ($graph_data[1][$name_value] + $y_current) / $reps;
                                } else {
                                    $graph_data[1][$name_value] += $y_current;
                                }
                            }
                        }
                        $titles[$name_value] = $name_value;
                        $reps++;
                    }
                }
                if ($this->mode != 'graph_pie') {
                    foreach ($graph_data as $name_value => $val) {
                        $last_value = 0;
                        foreach ($time_units as $unit) {
                            $key = $unit;
                            if (!array_key_exists($key, $graph_data[$name_value])) {
                                if (!empty($this->fields[$y_axis]['cumulative_function'])) {
                                    $graph_data[$name_value][$key] = $last_value;
                                } else {
                                    $graph_data[$name_value][$key] = 0;
                                }
                            } else {
                                $last_value = $graph_data[$name_value][$key];
                            }
                        }
                    }
                    foreach ($graph_data as $name_value => $val) {
                        ksort($graph_data[$name_value]);
                        $last_value = 0;
                        foreach ($graph_data[$name_value] as $key => $val) {
                            if ($time_unit == 'days' || $time_unit == 'weeks') {
                                $key1 = date('M j', $key);
                            } elseif ($time_unit == 'months') {
                                $key1 = date('M', $key);
                            } elseif ($time_unit == 'years') {
                                $key1 = date('Y', $key);
                            }
                            $graph_data1[$name_value][$key1] = $val;
                        }
                    }
                } else {
                    $graph_data1 = $graph_data;
                }
            }
            $HTML .= '<img class="graph" src="includes/graph.php?graph_data=' . urlencode(serialize($graph_data1)) . '&titles=' . urlencode(serialize($titles)) . '&mode=' . $this->mode . '">';
        } else {
            $HTML .= "<table><tr class=\"grid_header\">";
            if ($CFG->backstage_mode && !$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                $HTML .= "<th><label for=\"grid_select{$this->i}\"/><input id=\"grid_select{$this->i}\" type=\"checkbox\" class=\"grid_select checkbox_input\" onclick=\"gridSelectAll(this)\"/></th>";
            }
            if (is_array($this->fields)) {
                foreach ($this->fields as $name => $value) {
                    $key = $name;
                    if (strstr($name, 'lll')) {
                        $name_parts = explode('lll', $name);
                        $name = $name_parts[0];
                    }
                    if ($this->inset_id > 0) {
                        if ($value['name'] == $this->inset_id_field) {
                            continue;
                        }
                        if (strstr($this->inset_id_field, '.')) {
                            $inset_field_parts = explode('.', $this->inset_id_field);
                            if ($value['subtable'] == $inset_field_parts[0] && (in_array($inset_field_parts[1], $value['subtable_fields']) || $inset_field_parts[1] == 'id')) {
                                continue;
                            }
                        }
                    }
                    if ($value['is_op'] && !$value['run_in_sql']) {
                        if ($CFG->pm_editor) {
                            $method_name = Form::peLabel($value['method_id'], 'aggregate');
                        }
                        $HTML .= "<th>" . $value['header_caption'] . $method_name . '</th>';
                        continue;
                    } elseif ($value['is_form']) {
                        if ($CFG->pm_editor) {
                            $method_name = Form::peLabel($value['method_id'], 'inlineForm');
                        }
                        if ($value['header_caption']) {
                            $HTML .= "<th class=\"multiple_input\">" . $value['header_caption'] . $method_name . '</th>';
                        }
                        continue;
                    }
                    if ($CFG->pm_editor) {
                        $method_name = !$value['run_in_sql'] ? Form::peLabel($value['method_id'], 'field') : Form::peLabel($value['method_id'], 'aggregate');
                    }
                    if ($value['filter']) {
                        $order_asc = $this->order_asc ? false : true;
                        if ($this->order_by == $name) {
                            $dir_img = $this->order_asc ? $CFG->up : $CFG->down;
                        } else {
                            $dir_img = false;
                        }
                        $filter_results = $_REQUEST['form_filters' . $this->i];
                        $HTML .= "<th>" . Link::url($CFG->url, $value['header_caption'] . $dir_img, false, array('filter' . $this->i => $name, 'order_by' . $this->i => $this->order_by, 'order_asc' . $this->i => $order_asc, 'is_tab' => $this->is_tab, 'inset_id' => $this->inset_id, 'inset_id_field' => $this->inset_id_field, 'inset_i' => $this->inset_i, 'form_filters' . $this->i => $filter_results, 'search_fields' . $this->i => $_REQUEST['search_fields' . $this->i]), false, false, $this->inset_i > 0 ? 'inset_area_' . $this->inset_i : 'content') . $method_name . "</th>";
                    } else {
                        $HTML .= "<th>" . $value['header_caption'] . $method_name . '</th>';
                    }
                }
            }
            $HTML .= $this->show_buttons ? "<th>&nbsp;</th>" : '';
            $HTML .= '</tr>';
            if (is_array($data)) {
                $alt = false;
                foreach ($data as $row) {
                    $alt = $alt ? false : 'alt';
                    if ($this->alert_condition1) {
                        $condition = String::doFormulaReplacements($this->alert_condition1, $row, 1);
                        $alert_class1 = eval("if ({$condition}) { return 1;} else { return 0;}") ? 'alert1' : '';
                    }
                    if ($this->alert_condition2) {
                        $condition = String::doFormulaReplacements($this->alert_condition2, $row, 1);
                        $alert_class2 = eval("if ({$condition}) { return 1;} else { return 0;}") ? 'alert2' : '';
                    }
                    $HTML .= '<tr class="' . $alt . ' ' . $alert_class1 . ' ' . $alert_class2 . '">';
                    if (!is_array($this->fields)) {
                        continue;
                    }
                    if ($CFG->backstage_mode && !$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                        $HTML .= "<td><label for=\"checkbox{$row['id']}\"/><input id=\"checkbox{$row['id']}\" type=\"checkbox\" value=\"{$row['id']}\" class=\"grid_select checkbox_input\"/></td>";
                    }
                    foreach ($this->fields as $name => $properties) {
                        $key = $name;
                        if (strstr($name, 'lll')) {
                            $name_parts = explode('lll', $name);
                            $name = $name_parts[0];
                        }
                        if ($this->inset_id > 0) {
                            if ($properties['name'] == $this->inset_id_field) {
                                continue;
                            }
                            if (strstr($this->inset_id_field, '.')) {
                                $inset_field_parts = explode('.', $this->inset_id_field);
                                if ($properties['subtable'] == $inset_field_parts[0] && (in_array($inset_field_parts[1], $properties['subtable_fields']) || $inset_field_parts[1] == 'id')) {
                                    continue;
                                }
                            }
                        }
                        $value = $row[$key];
                        $link_id = $row[$name . '_id'] ? $row[$name . '_id'] : $value;
                        $class = $properties['class'] ? "class=\"{$properties['class']}\"" : '';
                        $HTML .= "<td {$class}>";
                        if (!empty($properties['is_media'])) {
                            reset($CFG->image_sizes);
                            $m_values = explode('|||', $value);
                            $m_size = !empty($properties['media_size']) ? $properties['media_size'] : key($CFG->image_sizes);
                            $m_limit = !empty($properties['media_amount']) ? $properties['media_amount'] : 1;
                            $HTML .= Gallery::multiple($properties['subtable'], $row['id'], $properties['name'], $properties['media_size'], 0, false, $properties['media_amount'], false, false, true);
                        } elseif ($properties['is_op'] && !$properties['run_in_sql']) {
                            $value1 = number_format(self::doOperation($key, $properties, $row), 2);
                            if (is_array($page_total)) {
                                if (array_key_exists($name, $page_total)) {
                                    $page_total[$key] += $value1;
                                }
                            }
                            if (is_array($page_avg)) {
                                if (array_key_exists($name, $page_avg)) {
                                    $page_avg[$key][] = $value1;
                                }
                            }
                            $HTML .= $value1;
                        } elseif ($properties['is_form']) {
                            if (!$properties['header_caption']) {
                                continue;
                            }
                            $HTML .= '<div>';
                            if (!$ref) {
                                $ref = new ReflectionClass('Form');
                                if (is_array($properties['inputs_array'])) {
                                    foreach ($properties['inputs_array'] as $method => $args) {
                                        $method_parts = explode('|', $method);
                                        $method1 = $method_parts[0];
                                        $params = $ref->getMethod($method1)->getParameters();
                                        if (is_array($params)) {
                                            $i = 0;
                                            foreach ($params as $param) {
                                                $param_name = $param->getName();
                                                if ($param_name == 'value') {
                                                    $i_methods[$method]['value'] = $i;
                                                } elseif ($param_name == 'static') {
                                                    $i_methods[$method]['static'] = $i;
                                                } elseif ($param_name == 'j') {
                                                    $i_methods[$method]['j'] = $i;
                                                } elseif ($param_name == 'checked') {
                                                    $i_methods[$method]['checked'] = $i;
                                                } elseif ($param_name == 'grid_input') {
                                                    $i_methods[$method]['grid_input'] = $i;
                                                } elseif ($param_name == 'is_current_timestamp') {
                                                    $i_methods[$method]['is_current_timestamp'] = $i;
                                                }
                                                $i++;
                                            }
                                        }
                                    }
                                }
                            }
                            if (!empty($properties['insert_new_record_when'])) {
                                $properties['insert_new_record_when'] = String::replaceConditionals('(' . $properties['insert_new_record_when'] . ')', $row, $properties['f_id_field']);
                                $result = eval("if ({$properties['insert_new_record_when']}) { return 0;} else { return 1;}");
                            }
                            $i_table = !empty($properties['table']) ? $properties['table'] : $this->table;
                            $i_f_id = $properties['f_id'] ? $row[str_replace('[', '', str_replace(']', '', $properties['f_id']))] : $row['id'];
                            if (!$result) {
                                $i_row = DB::getRecord($i_table, 0, $row['id'], 1, $properties['f_id_field'], $properties['order_by'], $properties['order_asc']);
                            } else {
                                $i_row = false;
                            }
                            $HTML .= '
							<input type="hidden" name="iform_table' . $this->i . '[' . $row['id'] . ']" value="' . $i_table . '" />
							<input type="hidden" name="iform_id' . $this->i . '[' . $row['id'] . ']" value="' . $i_row['id'] . '" />';
                            if ($i_row) {
                                $HTML .= '<input type="hidden" name="iform_action' . $this->i . '[' . $row['id'] . ']" value="edit" />';
                            } else {
                                $HTML .= '<input type="hidden" name="iform_action' . $this->i . '[' . $row['id'] . ']" value="new" />';
                            }
                            if (is_array($properties['inputs_array'])) {
                                foreach ($properties['inputs_array'] as $method => $args) {
                                    $method_parts = explode('|', $method);
                                    $method1 = $method_parts[0];
                                    $CFG->method_id = $args['pm_method_id'];
                                    unset($args['pm_method_id']);
                                    unset($args['show_total']);
                                    $args1 = $args;
                                    $args = array_values($args);
                                    $i_value = $i_methods[$method]['value'];
                                    $i_checked = $i_methods[$method]['checked'];
                                    $i_static = $i_methods[$method]['static'];
                                    $i_j = $i_methods[$method]['j'];
                                    $i_is_current_timestamp = $i_methods[$method]['is_current_timestamp'];
                                    $input_name = $args[0];
                                    $args[$i_static] = 1;
                                    $args[$i_j] = $input_name;
                                    $args[0] = $row['id'];
                                    if ($method1 == 'textInput') {
                                        $args[13] = '';
                                        ksort($args);
                                    }
                                    if ($method1 == 'hiddenInput') {
                                        $args[8] = '';
                                        $args[$i_is_current_timestamp] = $args1['is_current_timestamp'];
                                        ksort($args);
                                    }
                                    if ($args1['show_total']) {
                                        $totals[$input_name][] = $row[$input_name];
                                    }
                                    if ($method1 == 'checkBox') {
                                        $args[$i_checked] = $i_row[$input_name];
                                    } else {
                                        $args[$i_value] = $i_row[$input_name];
                                    }
                                    if (!$class_instance) {
                                        $CFG->form_output_started = true;
                                        $class_instance = $ref->newInstanceArgs(array('grid_form_' . $this->table . $this->i));
                                    }
                                    $method_instance = $ref->getMethod($method1);
                                    $HTML .= '<div class="col" id="' . $properties['method_id'] . '">' . $method_instance->invokeArgs($class_instance, $args) . '</div>';
                                }
                            }
                            if ($class_instance) {
                                $CFG->o_method_suppress = true;
                                $method_instance = $ref->getMethod('hiddenInput');
                                $HTML .= $method_instance->invokeArgs($class_instance, array($row['id'], 0, $i_f_id, false, false, false, 1, $properties['f_id_field']));
                                $CFG->o_method_suppress = false;
                            }
                            $HTML .= '<div class="clear"></div>';
                            $HTML .= '</div>';
                        } else {
                            $value = self::detectData($key, $value, $fields, $foreign_dates);
                            if (!empty($properties['link_url'])) {
                                $action = $CFG->backstage_mode ? '&action=record' : '';
                                $value = str_replace('|||', ' ', $value);
                                if (!empty($value)) {
                                    $HTML .= Link::url($properties['link_url'], $value, "id={$link_id}&is_tab={$properties['link_is_tab']}{$action}", false, false, 'content');
                                }
                            } else {
                                $HTML .= str_ireplace('|||', ' ', $value);
                            }
                            if (is_array($page_total)) {
                                if (array_key_exists($name, $page_total)) {
                                    $page_total[$key] += $value;
                                }
                            }
                            if (is_array($page_avg)) {
                                if (array_key_exists($name, $page_avg)) {
                                    $page_avg[$key][] = $value;
                                }
                            }
                        }
                        $HTML .= "</td>";
                    }
                    if ($this->show_buttons) {
                        $HTML .= '<td><nobr>';
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 0) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=record&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'view', false, false, false, false, $CFG->view_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'edit', false, false, false, false, $CFG->edit_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && !$this->links_out) {
                            $HTML .= '<a href="#" title="' . $CFG->delete_hover_caption . '" onclick="gridDelete(' . $row['id'] . ',\'' . $this->table . '\',this)" class="delete"></a></nobr></td>';
                        }
                    }
                    $HTML .= '</tr>';
                }
            } else {
                $HTML .= '<tr><td colspan="' . (count($this->fields) + 2) . '">' . $CFG->grid_no_results . '</td></tr>';
            }
            if ($page_total || $page_avg) {
                $HTML .= '<tr>';
                if ($this->show_buttons) {
                    $HTML .= '<td></td>';
                }
                foreach ($this->fields as $name => $properties) {
                    if ($page_total[$name]) {
                        $subtotal = $page_total[$name];
                        $subtotal = stristr($fields[$name]['Type'], 'double') ? number_format($subtotal, 2) : $subtotal;
                        $subtotals[$name] = $subtotal;
                    } else {
                        $subtotal = false;
                    }
                    if ($page_avg[$name]) {
                        $subavg = array_sum($page_avg[$name]) / count($page_avg[$name]);
                        $subavg = stristr($fields[$name]['Type'], 'double') ? number_format($subavg, 2) : $subavg;
                        $subavgs[$name] = $subavg;
                    } else {
                        $subavg = false;
                    }
                }
                $subtotals = $subtotals ? $subtotals : array();
                $subavgs = $subavgs ? $subavgs : array();
                $subs = array_merge($subtotals, $subavgs);
                foreach ($this->fields as $name => $properties) {
                    $sub = $subs[$name] ? $subs[$name] : false;
                    $HTML .= '<td class="subtotal">' . (is_numeric($sub) ? number_format($sub, 2) : $sub) . '</td>';
                }
                if ($this->show_buttons) {
                    $HTML .= '<td class="subtotal"><em>' . ($page_total ? $CFG->subtotal_label : '') . ($page_total && $page_avg ? '/' : '') . ($page_avg ? $CFG->subavg_label : '') . '</em></td>';
                }
                $HTML .= '</tr>';
            }
            if ($grand_total || $grand_avg) {
                $HTML .= '<tr>';
                if ($this->show_buttons) {
                    $HTML .= '<td class="total"></td>';
                }
                foreach ($this->fields as $name => $properties) {
                    if ($properties['is_op'] && !$properties['run_in_sql']) {
                        continue;
                    }
                    if (is_array($grand_total)) {
                        if (array_key_exists($name, $grand_total)) {
                            $total = array_key_exists($name, $grand_total) ? number_format(DB::getTotal($properties, $this->table), 2) : false;
                            $totals[$name] = $total;
                        }
                    }
                    if (is_array($grand_avg)) {
                        if (array_key_exists($name, $grand_avg)) {
                            //$avg = (array_key_exists($name,$grand_avg)) ? number_format(DB::get($this->table,array($this->table.'.'.$name),$page,$this->rows_per_page,$this->order_by,$this->order_asc,0,$this->filter_results,$this->inset_id,$this->inset_id_field,0,1),2) : false;
                            $avg = array_key_exists($name, $grand_avg) ? number_format(DB::getAverage($properties, $this->table), 2) : false;
                            $totals[$name] = $avg;
                        }
                    }
                }
                foreach ($this->fields as $name => $properties) {
                    if ($properties['is_op'] && !$properties['run_in_sql']) {
                        /*
                        $formula = $properties['formula'];
                        foreach ($totals as $o_name => $o_value) {
                        	$formula = str_replace($o_name,str_replace(',','',$o_value),$formula);
                        }
                        $total = eval("return $formula ;");
                        */
                        $total = false;
                    } else {
                        if ($totals[$name]) {
                            $total = $totals[$name];
                        } else {
                            $total = false;
                        }
                    }
                    $HTML .= '<td class="total">' . (is_numeric($total) ? number_format($total, 2) : $total) . '</td>';
                }
                if ($this->show_buttons) {
                    $HTML .= '<td class="total"><em>' . ($grand_total ? $CFG->total_label : '') . ($grand_total && $grand_avg ? '/' : '') . ($grand_avg ? $CFG->avg_label : '') . '</em></td>';
                }
                $HTML .= '</tr>';
            }
            $HTML .= '</table>';
        }
        $pagination = Grid::pagination($page, $total_rows);
        if ($this->grid_label) {
            if ($CFG->pm_editor) {
                $method_name = Form::peLabel($this->grid_label['method_id'], 'gridLabel');
            }
            $grid_label = $this->grid_label['text'] . ' ' . $method_name;
        } else {
            $grid_label = Ops::getPageTitle();
        }
        Grid::show_filters();
        Grid::show_errors();
        $amount = $total_rows > 0 ? '(' . $total_rows . ')' : false;
        if (!($this->inset_id > 0 || $CFG->is_form_inset)) {
            echo '
			<div class="area full_box" id="grid_' . $this->i . '">
				<h2>' . $grid_label . ' ' . $amount . '</h2>
				<div class="box_bar"></div>
				<div class="box_tl"></div>
				<div class="box_tr"></div>
				<div class="box_bl"></div>
				<div class="box_br"></div>
				<div class="t_shadow"></div>
				<div class="r_shadow"></div>
				<div class="b_shadow"></div>
				<div class="l_shadow"></div>
				<div class="box_b"></div>
				<div class="grid_buttons">
				' . $pagination . '';
            if (is_array($this->modes)) {
                if (count($this->modes) > 1) {
                    echo '<div class="modes">';
                    foreach ($this->modes as $mode => $enabled) {
                        $class1 = $mode == $this->mode ? 'active_view' : false;
                        if ($mode == 'table') {
                            $class = 'switch_table';
                            $caption = $CFG->switch_to_table;
                        } elseif ($mode == 'list') {
                            $class = 'switch_list';
                            $label = $CFG->switch_to_list;
                        } elseif ($mode == 'graph') {
                            $class = 'switch_graph';
                            $label = $CFG->switch_to_graph;
                        } elseif ($mode == 'graph_line') {
                            $class = 'switch_graph_line';
                            $label = $CFG->switch_to_graph_line;
                        } elseif ($mode == 'graph_pie') {
                            $class = 'switch_graph_pie';
                            $label = $CFG->switch_to_graph_pie;
                        }
                        echo Link::url($CFG->url, false, false, array('page' . $this->i => $page, 'p_bypass' . $this->i => 1, 'mode' . $this->i => $mode), true, 'content', $class . ' ' . $class1, false, false, false, false, $label) . ' ';
                    }
                    echo '</div>';
                }
            }
            if (!$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                echo '<div class="button before"></div>';
                if (is_array($this->fields)) {
                    foreach ($this->fields as $properties) {
                        if ($properties['is_form']) {
                            $i_name = !$properties['button_submit_all'] ? $properties['name'] : 'all';
                            echo '<a href="#" onclick="gridSubmitForm(\'' . $this->table . $this->i . '\')" class="button"><div class="save"></div>' . $properties['save_button_caption'] . '</a>';
                            if ($properties['button_submit_all']) {
                                break;
                            }
                        }
                    }
                }
                if (array_key_exists('is_active', $fields)) {
                    echo '<a class="button" href="#" onclick="gridSetActive(\'' . $this->table . '\',1)">' . $CFG->grid_activate_button . '</a>';
                    echo '<a class="button" href="#" onclick="gridSetActive(\'' . $this->table . '\')">' . $CFG->grid_deactivate_button . '</a>';
                }
                echo Link::url($this->link_url, '<div class="add_new"></div>' . $CFG->add_new_caption, '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'button') . '<a class="button last" href="#" onclick="gridDeleteSelection(\'' . $this->table . '\')"><div class="delete"></div> ' . $CFG->delete_button_label . '</a>';
                echo '<div class="button after"></div>';
            }
            echo '
				</div>
				<div class="contain">';
        }
        $HTML .= '
		<script type="text/javascript">
			$(document).ready(function() {
				$("#grid_' . $this->i . '").find("th").mouseover(function() {
					gridHighlightTH(this);
				});
				$("#grid_' . $this->i . '").find("th").mouseout(function() {
					gridUnHighlightTH(this);
				});
				$("#grid_' . $this->i . '").find("td").mouseover(function() {
					gridHighlightTD(this);
				});
				$("#grid_' . $this->i . '").find("td").mouseout(function() {
					gridUnHighlightTD(this);
				});
			';
        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) < 1) {
            $HTML .= '
				$("input").attr("disabled","disabled");
				$("select").attr("disabled","disabled");
			';
        }
        $HTML .= '
			});
		</script>';
        echo $HTML;
        if ($this->rows_per_page > 30) {
            echo $pagination;
        }
        if ($CFG->backstage_mode && User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && $this->inset_id === false) {
            echo "</form>";
        }
        if (!($this->inset_id > 0 || $CFG->is_form_inset)) {
            echo '</div></div>';
        }
    }
Example #7
0
 function placeholder($table, $value, $in_title = false, $link_url = false, $class = false, $link_is_tab = false, $target_elem_id = false, $link_id_field = false, $print_only = false, $print_caption = false)
 {
     global $CFG;
     if ($CFG->pm_editor) {
         $method_name = Form::peLabel($CFG->method_id, 'placeholder');
         echo '<li>' . $table . ' [placeholder] ' . $method_name . '</li>';
     }
     $this->fields[$table][] = array('is_placeholder' => true, 'value' => $value, 'in_title' => $in_title, 'link_url' => $link_url, 'class' => $class, 'link_is_tab' => $link_is_tab, 'target_elem_id' => $target_elem_id, 'link_id_field' => $link_id_field, 'print_only' => $print_only, 'print_caption' => $print_caption);
 }
Example #8
0
 private function displayItems($tables, $rows = false, $f_id = 0, $level = 1, $p_id = 0)
 {
     global $CFG;
     $pm_method = $CFG->pm_editor ? ' class="pm_method"' : '';
     if ($tables) {
         $parent_id = $rows ? $p_id : $f_id;
         $this->levels[$level][$parent_id] = $parent_id;
         $HTML = '';
         foreach ($tables as $name => $properties) {
             $HTML .= "<ul id=\"mlist_{$this->i}_level_{$level}_{$parent_id}\" class=\"mlist_{$this->i}_level_{$level}\">";
             $properties['url'] = empty($properties['url']) ? $CFG->url : $properties['url'];
             $properties['url_is_tab'] = empty($properties['url_is_tab']) ? $CFG->is_tab : $properties['url_is_tab'];
             if (!empty($properties['parent']) && $f_id == 0) {
                 continue;
             }
             $HTML .= "<input id=\"table\" type=\"hidden\" name=\"table\" value=\"{$name}\" />";
             $HTML .= "<input id=\"enabled\" type=\"hidden\" name=\"enabled\" value=\"{$this->dragdrop}\" />";
             $HTML .= "<input id=\"p_id\" type=\"hidden\" name=\"p_id\" value=\"{$p_id}\" />";
             $HTML .= "<input id=\"f_id\" type=\"hidden\" name=\"f_id\" value=\"{$f_id}\" />";
             if ($CFG->pm_editor) {
                 $HTML .= Form::peLabel($properties['method_id'], 'addTable');
             }
             $table = $rows ? $rows : DB::getCats($name, $f_id);
             if ($table) {
                 foreach ($table as $id => $row) {
                     $hidden = $row['row']['hidden'] == 'Y' ? 'hidden' : '';
                     $HTML .= "<li id=\"{$row['row']['id']}\" class=\"li_{$level} ml_li {$hidden}\">";
                     $HTML .= !empty($row['children']) ? '<div onclick="ml_expand(this)" class="more"></div><div onclick="ml_collapse(this)" class="less"></div>' : '';
                     $HTML .= "<div class=\"ml_item\">";
                     if ($CFG->url == 'edit_tabs' && !empty($row['row']['url'])) {
                         $is_tab = $name == 'admin_tabs' ? '1' : '0';
                         if (User::permission(0, 0, $properties['url'], false, $properties['url_is_tab']) > 1) {
                             $HTML .= '<a class="edit_page" href="index.php?current_url=edit_page&table=' . $name . '&id=' . $row['row']['id'] . '&is_tab=' . $is_tab . '"></a>';
                         }
                     }
                     if (is_array($properties['table_fields'])) {
                         foreach ($properties['table_fields'] as $field) {
                             $value = Grid::detectData($field, $row['row'][$field], $this->fields[$name]);
                             $HTML .= !empty($properties['url']) ? Link::url($properties['url'], $row['row'][$field], "table={$name}&id={$row['row']['id']}&f_id={$row['row']['f_id']}&p_id={$row['row']['p_id']}&action=record&is_tab=" . $properties['url_is_tab'], false, false, $properties['target_elem_id']) : $value;
                         }
                         $del_function = $CFG->url == 'edit_tabs' ? 'deletePage(this)' : 'ml_delete(this)';
                         if (User::permission(0, 0, $properties['url'], false, $properties['url_is_tab']) > 1) {
                             $HTML .= Link::url($properties['url'], false, "table={$name}&id={$row['row']['id']}&f_id={$row['row']['f_id']}&p_id={$row['row']['p_id']}&action=record&is_tab=" . $properties['url_is_tab'], false, false, $properties['target_elem_id'], 'view', false, false, false, false, $CFG->view_hover_caption) . Link::url($properties['url'], false, "table={$name}&id={$row['row']['id']}&f_id={$row['row']['f_id']}&p_id={$row['row']['p_id']}&action=form&is_tab=" . $properties['url_is_tab'], false, false, $properties['target_elem_id'], 'edit', false, false, false, false, $CFG->edit_hover_caption) . "<a href=\"#\" class=\"delete\" title=\"{$CFG->delete_hover_caption}\" onclick=\"{$del_function}\" class=\"button\"></a>";
                         }
                     } else {
                         foreach ($row['row'] as $field) {
                             $HTML .= '<span>' . $field . '</span>';
                         }
                     }
                     $HTML .= $this->row_end_button ? $this->row_end_button : '';
                     if (User::permission(0, 0, $properties['url'], false, $properties['url_is_tab']) > 1 && $accepts_children) {
                         $HTML .= $properties['accept_children'] ? Link::url($properties['url'], '<div class="add_new"></div>' . $CFG->add_new_caption, "table={$name}&f_id={$f_id}&p_id={$p_id}&action=form&is_tab=" . $properties['url_is_tab'], false, false, $properties['target_elem_id']) : '';
                     }
                     $HTML .= '</div>';
                     if (!empty($row['children'])) {
                         $HTML .= MultiList::displayItems(array($name => $properties), $row['children'], false, $level + 1, $id);
                     }
                     foreach ($this->tables as $name1 => $properties1) {
                         if ($properties1['parent'] == $name) {
                             $HTML .= MultiList::displayItems(array($name1 => $properties1), false, $id, $level + 1);
                         }
                     }
                     $HTML .= '</li>';
                 }
             }
             $HTML .= '</ul>';
             $HTML .= "<div class=\"add_elem\">" . Link::url($properties['url'], '<div class="add_new"></div>' . $CFG->add_new_caption, "table={$name}&f_id={$f_id}&p_id={$p_id}&action=form&is_tab=" . $CFG->is_tab, false, false, $properties['target_elem_id']) . "</div>";
         }
         return $HTML;
     }
 }