Fixes
This commit is contained in:
parent
3dea8a32aa
commit
8cda38ec01
3 changed files with 17 additions and 236 deletions
|
|
@ -1,143 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Antonio de la Rosa <webmaster@web-t-sys.com>
|
||||
* @file
|
||||
* @package Core/ModelExtraMethods
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A method for create forms for edit models
|
||||
*
|
||||
* @deprecated Use GenerateAdminClass for this tasks
|
||||
*/
|
||||
|
||||
function generate_edit_model_method_class($class, $idrow, $arr_fields, $url_admin, $url_back, $yes_insert=1, $where_sql='')
|
||||
{
|
||||
|
||||
//global $lang, PhangoVar::$base_url;
|
||||
|
||||
settype($_GET['op_update'], 'integer');
|
||||
settype($_GET['success'], 'integer');
|
||||
settype($idrow, 'integer');
|
||||
|
||||
$url_post=add_extra_fancy_url($url_admin, array('op_update' =>1));
|
||||
|
||||
$label=PhangoVar::$l_['common']->lang('add_new_item', 'Add new element').' - '.$class->label;
|
||||
|
||||
$update_method='insert';
|
||||
|
||||
if($where_sql!='')
|
||||
{
|
||||
|
||||
$where_sql=str_replace('WHERE', ' and', $where_sql);
|
||||
|
||||
$where_sql=str_replace('where', ' and', $where_sql);
|
||||
|
||||
}
|
||||
|
||||
if($class->element_exists($idrow))
|
||||
{
|
||||
|
||||
$query=$class->select('where '.$class->idmodel.'='.$_GET[$class->idmodel], $arr_fields, true);
|
||||
|
||||
$post=webtsys_fetch_array($query);
|
||||
|
||||
ModelForm::set_values_form($post, $class->forms, 0);
|
||||
|
||||
$update_method='update';
|
||||
|
||||
$label=PhangoVar::$l_['common']->lang('edit', 'Edit').' - '.$class->label;
|
||||
|
||||
}
|
||||
else
|
||||
if($yes_insert==0)
|
||||
{
|
||||
|
||||
echo PhangoVar::$l_['common']->lang('cannot_update_insert_in_model', 'Cannot insert or update this item in the database');
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
switch($_GET['op_update'])
|
||||
{
|
||||
|
||||
default:
|
||||
|
||||
ob_start();
|
||||
|
||||
echo load_view(array($class->forms, $arr_fields, $url_post, $class->enctype, '_generate_admin_'.$class->name), 'common/forms/updatemodelform');
|
||||
|
||||
$cont_index=ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
echo load_view(array($label, $cont_index), 'content');
|
||||
|
||||
?>
|
||||
<p><a href="<?php echo $url_back; ?>"><?php echo PhangoVar::$l_['common']->lang('go_back', 'Go back'); ?></a></p>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
$post=filter_fields_array($arr_fields, $_POST);
|
||||
|
||||
if($class->$update_method($post, 'where '.$class->idmodel.'='.$idrow.$where_sql))
|
||||
{
|
||||
|
||||
load_libraries(array('redirect'));
|
||||
simple_redirect( $url_back, PhangoVar::$l_['common']->lang('redirect', 'Redirect'), PhangoVar::$l_['common']->lang('success', 'Success'), PhangoVar::$l_['common']->lang('press_here_redirecting', 'Press here for redirecting'));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ob_start();
|
||||
|
||||
echo '<p class="error">'.PhangoVar::$l_['common']->lang('cannot_update_insert_in_model', 'Cannot insert or update this item in the database').' '.$class->name.': '.$class->std_error.'</p>';
|
||||
|
||||
$post=filter_fields_array($arr_fields, $_POST);
|
||||
|
||||
set_values_form($post, $class->forms);
|
||||
|
||||
echo load_view(array($class->forms, $arr_fields, $url_post, $class->enctype), 'common/forms/updatemodelform');
|
||||
|
||||
$cont_index=ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
echo load_view(array($label, $cont_index), 'content');
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
if($yes_insert==1)
|
||||
{
|
||||
|
||||
if($class->delete('where `'.$class->name.'`.'.$class->idmodel.'='.$idrow.$where_sql))
|
||||
{
|
||||
|
||||
load_libraries(array('redirect'));
|
||||
simple_redirect( $url_back , PhangoVar::$l_['common']->lang('redirect', 'Redirect'), PhangoVar::$l_['common']->lang('success', 'Success'), PhangoVar::$l_['common']->lang('press_here_redirecting', 'Press here for redirecting'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Antonio de la Rosa <webmaster@web-t-sys.com>
|
||||
* @file
|
||||
* @package Core/ModelExtraMethods
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A utility for create paginated lists.
|
||||
*
|
||||
* @deprecated use SimpleList class instead.
|
||||
*/
|
||||
|
||||
function generate_paginator_method_class($class, $where, $arr_fields, $arr_extra_fields, $url_paginament,$num_elements, $initial_num_pages=20, $begin_page_var='begin_page', $raw_query=0)
|
||||
{
|
||||
|
||||
//global $lang;
|
||||
|
||||
load_libraries(array('table_config', 'pages', 'generate_admin_ng'));
|
||||
|
||||
if(count($class->forms)==0)
|
||||
{
|
||||
|
||||
$class->create_form();
|
||||
|
||||
}
|
||||
|
||||
if(!in_array($class->idmodel, $arr_fields['fields']))
|
||||
{
|
||||
|
||||
array_unshift($arr_fields['fields'], $class->idmodel);
|
||||
|
||||
}
|
||||
|
||||
$arr_heads=array();
|
||||
|
||||
foreach($arr_fields['fields'] as $field)
|
||||
{
|
||||
|
||||
$arr_heads[]=$class->forms[$field]->label;
|
||||
|
||||
}
|
||||
|
||||
foreach($arr_extra_fields['fields'] as $field)
|
||||
{
|
||||
|
||||
$arr_heads[]=$field;
|
||||
|
||||
}
|
||||
|
||||
up_table_config($arr_heads, $arr_fields['widths']);
|
||||
|
||||
$total_elements=$class->select_count($where, $class->idmodel);
|
||||
|
||||
$query=$class->select($where, $arr_fields['fields'], $raw_query);
|
||||
|
||||
while($arr_content=webtsys_fetch_array($query))
|
||||
{
|
||||
|
||||
$arr_new_list=array();
|
||||
|
||||
foreach($arr_fields['fields'] as $field)
|
||||
{
|
||||
|
||||
$arr_new_list[$field]=$class->components[$field]->show_formatted($arr_content[$field]);
|
||||
|
||||
}
|
||||
|
||||
//Add callbacks
|
||||
|
||||
foreach($arr_extra_fields['func'] as $extra_field_func)
|
||||
{
|
||||
|
||||
$arr_new_list[$extra_field_func]=implode('<br />', $extra_field_func($url_paginament, $class->name, $arr_content[$class->idmodel], $arr_content));
|
||||
|
||||
}
|
||||
|
||||
|
||||
middle_table_config($arr_new_list);
|
||||
|
||||
}
|
||||
|
||||
down_table_config();
|
||||
|
||||
echo '<p class="paginator">'.PhangoVar::$l_['common']->lang('pages', 'Pages').': '.pages( $_GET['begin_page'], $total_elements, $num_elements, $url_paginament ,$initial_num_pages, $begin_page_var).'</p>';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue