示例#1
0
				<div class="clear"></div>
			</div>';
        }
    }
} elseif ($action == 'drop') {
    if ($_REQUEST['rows']) {
        foreach ($_REQUEST['rows'] as $id => $row) {
            DB::update($row['table'], array($row['folder_field'] => $row['p_id']), $id);
        }
        Messages::add($CFG->ajax_save_message);
        Messages::display();
    }
} elseif ($action == 'download') {
    if ($_REQUEST['download']) {
        $page_id = Control::getPageId($_REQUEST['current_url'], $_REQUEST['is_tab']);
        $controls = Control::getControls($page_id, 'form', $_REQUEST['is_tab']);
        $key = key($controls);
        $methods = $controls[$key]['methods'];
        if ($methods) {
            foreach ($methods as $method) {
                if ($method['method'] == 'fileInput' || $method['method'] == 'fileMultiple') {
                    $args = Control::parseArguments($method['arguments'], 'Form', $method['method']);
                    $field_names[] = $args['name'];
                    $image_sizes = DB::getImageSizes($args['name']);
                    end($image_sizes);
                    $suffixes[$args['name']] = key($image_sizes);
                }
            }
        }
        $filename = $CFG->dirroot . $CFG->temp_file_location . 'archivos_' . date('Y-m-d') . '.zip';
        $zip = new ZipArchive();
示例#2
0
 function grid($name, $caption = false, $link_url = false, $link_is_tab = false, $concat_char = false)
 {
     global $CFG;
     $form = Control::getControls($CFG->editor_page_id, 'form', $CFG->editor_is_tab);
     if (!$form) {
         Errors::add('No form action created yet.');
         return false;
     }
     foreach ($form as $id => $control) {
         if (is_array($control['methods'])) {
             foreach ($control['methods'] as $method) {
                 $args = unserialize($method['arguments']);
                 if ($method['method'] == 'grid' && $args['name'] == $name) {
                     $grid_id = $id;
                     $grid_method = $method;
                     $grid_control = $control;
                     break 2;
                 }
             }
         }
     }
     if (!($grid_id > 0)) {
         Errors::add('No grid input called ' . $name . ' exists. Create it on the form action first.');
         return false;
     }
     if ($CFG->pm_editor) {
         $method_name = Form::peLabel($CFG->method_id, 'grid');
     }
     $this->in_grid = true;
     $this->grid_table = $this->table . '_grid_' . $name;
     $inputs_array = Control::getSubMethods($method['id'], $control['params']['class']);
     $HTML .= '<div class="record_grid"><div class="caption">' . $caption . $method_name . '</div><table>';
     if ($inputs_array) {
         $HTML .= '<tr>';
         foreach ($inputs_array as $args) {
             $HTML .= '<th>' . $args['caption'] . '</th>';
         }
         $HTML .= '</tr>';
         $values = DB::getGridValues($this->table . '_grid_' . $name, $subtable_fields, $this->record_id);
         if ($values) {
             foreach ($values as $row) {
                 $num_empty = 0;
                 $c1 = count($inputs_array);
                 if (is_array($inputs_array)) {
                     foreach ($inputs_array as $k => $v) {
                         if (stristr($k, 'checkBox')) {
                             $c1--;
                         }
                     }
                 }
                 foreach ($row as $key => $row1) {
                     if ($key != 'id' && empty($row1)) {
                         $num_empty++;
                     }
                 }
                 if ($num_empty >= $c1) {
                     continue;
                 }
                 $this->grid_values = $row;
                 $HTML .= '<tr>';
                 foreach ($inputs_array as $args) {
                     $HTML .= '<td>' . self::field($args['name'], $args['caption'], $args['subtable'], $args['subtable_fields'], $link_url, $concat_char, true, $args['f_id_field'], false, false, false, $link_is_tab) . '</td>';
                 }
                 $HTML .= '</tr>';
             }
         }
     }
     $HTML .= '</table></div>';
     $this->in_grid = false;
     $this->grid_table = false;
     $this->HTML[] = $HTML;
 }
示例#3
0
    function __construct($url, $action, $is_tab = false, $editor_mode = false)
    {
        global $CFG;
        if ($url && !User::permission(false, false, $url)) {
            return false;
        }
        date_default_timezone_set($CFG->default_timezone);
        String::magicQuotesOff();
        $page_id = is_numeric($url) ? $url : Control::getPageId($url, $is_tab);
        if (!($page_id > 0)) {
            return false;
        }
        $page_info = $is_tab ? DB::getRecord('admin_tabs', $page_id, 0, 1) : DB::getRecord('admin_pages', $page_id, 0, 1);
        if ($page_info['one_record'] == 'Y' && !$editor_mode) {
            $action = 'form';
            $_REQUEST['id'] = 1;
            $CFG->control_one_record = 1;
        }
        $controls = Control::getControls($page_id, $action, $is_tab);
        $CFG->editor_page_id = $page_id;
        $CFG->editor_is_tab = $is_tab;
        $CFG->is_ctrl_panel = $page_info['is_ctrl_panel'];
        if ($controls) {
            foreach ($controls as $c_id => $control) {
                $params = $control['params'];
                $is_static = $params['is_static'] == 'Y';
                $class = $params['class'];
                $CFG->control_pass_id = $params['id'];
                if ($_REQUEST['cal_bypass'] && $class != 'Calendar') {
                    continue;
                }
                if ($editor_mode) {
                    $pm_methods = array();
                    echo '<div class="pm_class_container" id="control_' . $params['id'] . '">
							<div class="control_label">' . $params['class'] . ' ' . $params['id'] . '
								<a href="#" title="' . $CFG->move_hover_caption . '" class="move_handle dont_disable"></a>
								<a class="edit dont_disable" title="' . $CFG->edit_hover_caption . '" onclick="pmControlEdit(\'control_' . $params['id'] . '\');"></a>
								<a class="delete dont_disable" title="' . $CFG->delete_hover_caption . '" onclick="pmControlDelete(\'control_' . $params['id'] . '\');"></a>
							</div>
							<input type="hidden" class="this_class" id="control_' . $params['id'] . '_class" value="' . $params['class'] . '"/>
							<input type="hidden" class="this_page_id" id="control_' . $params['id'] . '_page_id" value="' . $params['page_id'] . '"/>
							<input type="hidden" class="this_action" id="control_' . $params['id'] . '_action" value="' . $params['action'] . '"/>
							<input type="hidden" class="this_id" id="control_' . $params['id'] . '_id" value="' . $params['id'] . '"/>';
                }
                if (!$is_static) {
                    $ref = new ReflectionClass($class);
                    $args = Control::parseArguments($params['arguments'], $class, '__construct');
                    $this->class = $ref->newInstanceArgs($args);
                    if ($class == 'Form') {
                        if (!$CFG->in_include) {
                            $this->class->verify();
                            $this->class->save();
                            $this->class->show_errors();
                            $this->class->show_messages();
                            $this->class->get($page_info['url'] == 'my-account' || $url == 'my-account' ? User::$info['id'] : $_REQUEST['id']);
                        } else {
                            $this->class->get($CFG->include_id);
                        }
                        $this->class->info['p_id'] = $_REQUEST['p_id'];
                        $this->class->info['f_id'] = $_REQUEST['f_id'];
                        if ($page_info['url'] == 'my-account' || $url == 'my-account') {
                            $CFG->o_method_suppress = true;
                            $this->class->passiveField('id', 'ID');
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('user', $CFG->user_username, true, false, false, false, false, false, false, false, 1, $CFG->user_unique_error);
                            $CFG->o_method_suppress = true;
                            $this->class->passwordInput('pass', $CFG->user_password, true);
                            $CFG->o_method_suppress = true;
                            $this->class->passwordInput('pass1', $CFG->user_password, true, false, false, false, false, false, 'pass');
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('first_name', $CFG->user_first_name, true);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('last_name', $CFG->user_last_name, true);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('phone', $CFG->user_phone);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('email', $CFG->user_email);
                            if (User::$info['is_admin'] == 'Y') {
                                $CFG->o_method_suppress = true;
                                $this->class->selectInput('f_id', $CFG->user_group, false, $_REQUEST['f_id'], false, 'admin_groups', array('name'));
                                $CFG->o_method_suppress = true;
                                $this->class->checkBox('is_admin', $CFG->user_is_admin);
                            }
                        }
                    }
                    echo '<input type="hidden" id="control_' . $params['id'] . '_table" value="' . $args['table'] . '"/>';
                }
                if (is_array($control['methods'])) {
                    foreach ($control['methods'] as $method) {
                        if ($method['p_id'] > 0) {
                            continue;
                        }
                        //$method['method'] = ($method['method'] == 'selectInput') ? 'fauxSelect' : $method['method'];
                        $CFG->method_id = $method['id'];
                        $args = Control::parseArguments($method['arguments'], $class, $method['method']);
                        $inputs_array = self::getSubMethods($method['id'], $class);
                        if (is_array($inputs_array)) {
                            $args['inputs_array'] = $inputs_array;
                        }
                        if ($is_static) {
                            call_user_func_array("{$class}::{$method['method']}", $args);
                        } else {
                            $method_instance = $ref->getMethod($method['method']);
                            $method_instance->invokeArgs($this->class, $args);
                        }
                    }
                }
                $CFG->method_id = false;
                if ($class == 'Form' && !$CFG->pm_decouple_cancel) {
                    $this->class->cancelButton($CFG->cancel_button);
                }
                if ($class == 'Record' && !$CFG->pm_decouple_cancel) {
                    $d = new Form('dummy');
                    $d->cancelButton($CFG->ok_button);
                    $d->display();
                }
                if (!$is_static) {
                    if ($class == 'Grid') {
                        $this->class->display($_REQUEST['page' . $this->class->i]);
                    } else {
                        $this->class->display();
                    }
                }
                if ($editor_mode) {
                    echo '
					<div class="clear">&nbsp;</div></div>';
                }
                $this->class = false;
            }
        }
        if ($editor_mode) {
            echo '
			<script type="text/javascript">
				$(document).ready(function(){
					startEditor();
				});
			</script>';
        }
    }