Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1254

Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)

Novinky:

- Link_field a Order_link_Field elementy gridu pro zobrazovani okazu na data
- navazani ulic na mesta

Opravy:

- zmena rozhrani ulic
- zmeneno pridavani/editace adresnich bodu
- upravy v grid_template

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'whitelist setting has been successfully set' => 'Bílá listina byla úspěšně nastavena.',
'whole d' => 'Celé z.',
'without change' => 'Beze změny',
'without street' => 'Bez ulice',
'wireless' => 'bezdrátové',
'wireless interfaces' => 'Bezdrátová rozhraní',
'work' => 'Práce',
freenetis/branches/testing/application/models/town.php
/**
* @package Model
*
* @property string $town
* @property string $quarter
* @property integer $zip_code
* @property blob $gps
* @property ORM $address_points
* @property ORM $streets
*/
class Town_Model extends ORM
{
protected $has_many = array('address_points');
protected $has_many = array('address_points', 'streets');
/**
* @author Ondrej Fibich
* @return string reprezentation of town
*/
public function __toString()
{
if (!$this->id)
return '';
return (
$this->town . ($this->quarter ? ' - ' . $this->quarter : '') .
', ' . $this->zip_code
);
}
/**
* Check if town exists
......
LIMIT ".intval($limit_from).", ".intval($limit_results)."
");
}
/**
* Gets count of all towns
*
* @return integer
*/
public function count_all_towns()
{
return $this->db->query("
SELECT COUNT(id) AS count
FROM towns t
")->current()->count;
}
/**
* Gets loist of towns for select box
......
*/
public function select_list_with_quater()
{
$towns = $this->db->query("
SELECT
id, quarter, town, zip_code
FROM towns
ORDER BY town, quarter, zip_code
");
$concat = "CONCAT(
COALESCE(town, ''),
COALESCE(IF(
quarter IS NULL OR quarter LIKE '',
NULL, CONCAT(' - ', quarter)
), ''), ', ', zip_code
)";
$arr_towns = array();
foreach ($towns as $town)
{
$index = '' . $town->id . '';
$arr_towns[$index] = $town->town;
if (!empty($town->quarter))
{
$arr_towns[$index] .= ', ' . $town->quarter;
}
$arr_towns[$index] .= ', ' . $town->zip_code;
}
return $arr_towns;
return $this->select_list('id', $concat);
}
}
freenetis/branches/testing/application/models/address_point.php
*/
class Address_point_Model extends ORM
{
protected $has_many = array('members', 'devices', 'item_locations');
protected $has_many = array('members', 'devices');
protected $belongs_to = array('town', 'street', 'country');
/**
freenetis/branches/testing/application/models/street.php
/**
* @author Michal Kliment
* @package Model
*
* @property integer $town_id
* @property Town_Model $town
* @property string $street
* @property blob $gps
* @property ORM $address_points
*/
class Street_Model extends ORM
{
protected $has_many = array('address_points');
protected $belongs_to = array('town', 'street');
/**
* Check if street exists
......
*
* @author Michal Kliment
* @param $street name of street
* @param $town_id ID of town which owns street
* @return street object
*/
public function get_street($street = NULL)
public function get_street($street = NULL, $town_id = NULL)
{
$streets = $this->where('street', $street)->find_all();
$streets = $this->where(array
(
'street' => $street,
'town_id' => $town_id
))->find_all();
if (count($streets)==0)
if (count($streets) == 0)
{
$this->clear();
$this->street = $street;
$this->town_id = $town_id;
$this->save();
return $this;
}
else if (count($streets)==1)
else if (count($streets) == 1)
{
return $streets->current();
}
......
* @param array $filter_values
* @return unknown_type
*/
public function get_all_streets($limit_from = 0, $limit_results = 50, $order_by = 'id',
public function get_all_streets(
$limit_from = 0, $limit_results = 50, $order_by = 'id',
$order_by_direction = 'asc', $filter_values = array())
{
// order by check
if (!$this->has_column($order_by))
{
$order_by = 'id';
}
// order by direction check
if (strtolower($order_by_direction) != 'desc')
{
......
}
// query
return $this->db->query("
SELECT s.id, s.street FROM streets s
ORDER BY $order_by $order_by_direction
SELECT s.id, s.street, s.town_id, CONCAT(
COALESCE(town, ''),
COALESCE(IF(
quarter IS NULL OR quarter LIKE '',
NULL, CONCAT(' - ', quarter)
), ''), ', ', zip_code
) AS town
FROM streets s
LEFT JOIN towns t ON t.id = s.town_id
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
LIMIT ".intval($limit_from).", ".intval($limit_results)."
");
}
/**
* Count all streets
*
* @return integer
*/
public function count_all_streets()
{
return count($this->db->query("SELECT id FROM streets s"));
}
}
?>
freenetis/branches/testing/application/models/country.php
* @property string $country_name
* @property string $country_iso
* @property string $country_code
* @property unknown_type $contacts
* @property unknown_type $address_points
* @property ORM $contacts
* @property ORM $address_points
*/
class Country_Model extends ORM
{
freenetis/branches/testing/application/controllers/installation.php
$form_data["quarter"]
);
$street = $street_model->get_street($form_data["street"]);
$street = $street_model->get_street($form_data["street"], $town->id);
$address_point_model = new Address_point_Model();
freenetis/branches/testing/application/controllers/towns.php
$order_by_direction = 'asc';
$town_model = new Town_Model();
$total_towns = $town_model->count_all_towns();
$total_towns = $town_model->count_all();
if (($sql_offset = ($page - 1) * $limit_results) > $total_towns)
$sql_offset = 0;
......
if (!$this->acl_check_view('Address_points_Controller', 'town'))
Controller::error(ACCESS);
$name = $town->town;
$name .= ( $town->quarter != '') ? ' - ' . $town->quarter : '';
$name .= ', ' . $town->zip_code;
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('towns/show_all', 'Towns',
$this->acl_check_view('Address_points_Controller', 'town'))
->disable_translation()
->text($name);
->text($town->__toString());
$view = new View('main');
$view->breadcrumbs = $breadcrumbs->html();
$view->title = __('Town detail');
$view->content = new View('towns_show');
$view->content->town = $town;
$view->content->count_address_points = count($town->address_points);
$view->content->count_address_points = $town->address_points->count();
$view->render(TRUE);
}
freenetis/branches/testing/application/controllers/address_points.php
// streets
$street_model = new Street_Model();
$streets_first = array(NULL => '----- '.__('select street').' -----');
$streets_first = array(NULL => '----- '.__('without street').' -----');
$arr_streets = $streets_first + $street_model->select_list('id', 'street');
// towns
......
);
$form->set_attr('class', 'form_class')
->set_attr('method', 'post');
$form->dropdown('country_id')
->label(__('country').':')
->label(__('Country').':')
->rules('required')
->options($arr_countries)
->selected(Settings::get('default_country'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns);
$form->dropdown('street_id')
->label(__('street').':')
->label(__('Street').':')
->options($arr_streets);
$form->input('street_number')
->label(__('street number').':')
->label(__('Street number').':')
->rules('length[1,50]|valid_numeric');
$form->dropdown('town_id')
->label(__('town').':')
->rules('required')->options($arr_towns);
$form->input('gpsx')
->label(__('gps').' X: '.help::hint('gps_coordinates'))
->label(__('GPS').' X: '.help::hint('gps_coordinates'))
->rules('gps');
$form->input('gpsy')
->label(__('gps').' Y: '.help::hint('gps_coordinates'))
->label(__('GPS').' Y: '.help::hint('gps_coordinates'))
->rules('gps');
$form->submit('submit')->value(__('Add'));
......
if (!$data)
return;
echo num::decimal_point($data->results[0]->geometry->location->lat)." ".num::decimal_point($data->results[0]->geometry->location->lng);
echo gps::real2degrees(num::decimal_point($data->results[0]->geometry->location->lat), FALSE)." ".
gps::real2degrees(num::decimal_point($data->results[0]->geometry->location->lng), FALSE);
}
/**
freenetis/branches/testing/application/controllers/streets.php
* @var integer
*/
private $street_id = 0;
/**
* Form var for callbacks
*
* @var Forge
*/
private $_form;
/**
* Index redirects to show all
......
* @param integer $page
*/
public function show_all(
$limit_results = 500, $order_by = 'id', $order_by_direction = 'ASC',
$page_word = null, $page = 1)
$limit_results = 500, $order_by = 'street',
$order_by_direction = 'ASC', $page_word = null, $page = 1)
{
// access control
if (!$this->acl_check_view('Address_points_Controller','street'))
......
$limit_results = (int) $this->input->get('record_per_page');
// parameters control
$allowed_order_type = array('id', 'street');
$allowed_order_type = array('id', 'street', 'town_id');
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'id';
$order_by = 'street';
if (strtolower($order_by_direction) != 'desc')
$order_by_direction = 'asc';
$street_model = new Street_Model();
$total_streets = $street_model->count_all_streets();
$total_streets = $street_model->count_all();
if (($sql_offset = ($page - 1) * $limit_results) > $total_streets)
$sql_offset = 0;
......
$grid->order_field('id')
->label('ID');
$grid->order_field('street')
->label(__('Street'));
$grid->order_field('street');
$grid->order_link_field('town_id')
->link('towns/show', 'town');
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Address_points_Controller', 'street'))
......
Controller::error(ACCESS);
// creates new form
$form = new Forge(
$this->_form = $form = new Forge(
url::base(TRUE).url::current(TRUE), '',
'POST', array('id' => 'article_form')
);
......
$form->input('street')
->label(__('Street').':')
->rules('required|length[1,50]')
->callback(array($this,'check_street'));
->callback(array($this, 'check_street'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options(ORM::factory('town')->select_list_with_quater());
$form->submit('submit')
->value(__('Add'));
......
$street = new Street_Model();
$street->street = htmlspecialchars($form_data['street']);
$street->town_id = $form_data['town_id'];
if ($street->save())
{
......
*/
public function edit($street_id = NULL)
{
// no parameter
if (!$street_id)
Controller::warning(PARAMETER);
......
$this->street_id = $street->id;
// creates new form
$form = new Forge(
$this->_form = $form = new Forge(
url_lang::base().'streets/edit/'.$street->id, '',
'POST', array('id' => 'article_form')
);
......
->value($street->street)
->callback(array($this, 'check_street'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options(ORM::factory('town')->select_list_with_quater())
->selected($street->town_id);
$form->submit('submit')
->value(__('Edit'));
......
if ($form->validate())
{
$form_data = $form->as_array();
$street = new Street_Model($street_id);
$street->street = htmlspecialchars($form_data['street']);
$street->town_id = $form_data['town_id'];
if ($street->save())
{
status::success('Street has been successfully updated.');
}
url::redirect(url_lang::base().'streets/show_all');
}
......
// record doesn't exist
if (!$street->id)
{
Controller::error(RECORD);
}
// access control
if (!$this->acl_check_delete('Address_points_Controller', 'street'))
{
Controller::error(ACCESS);
}
$address_points = $street->address_points;
if (count($address_points)==0)
if ($street->address_points->count() == 0)
{
if ($street->delete())
{
......
/**
* Function checks if street already exist.
*
* @author Michal Kliment
* @author Michal Kliment, Ondřej fibich
* @param object $input
*/
public function check_street($input)
{
$street = $input->value;
$town_id = $this->_form->town_id->value;
$street_model = new Street_Model();
$streets_count = $street_model->where(array
(
'street' => $street,
'id <>' => $this->street_id
'street' => $street,
'town_id' => $town_id,
'id <>' => $this->street_id
))->count_all();
if ($streets_count)
freenetis/branches/testing/application/controllers/registration.php
if (!$this->settings->get('self_registration'))
url::redirect(url_lang::base() . 'login');
// countries
$country_model = new Country_Model();
$arr_countries = $country_model->select_list('id', 'country_name');
// streets
$street_model = new Street_Model();
$arr_streets = $street_model->select_list('id', 'street');
asort($arr_streets, SORT_LOCALE_STRING);
$arr_streets = array
(
NULL => '--- ' . __('Without street') . ' ---'
) + ORM::factory('street')->select_list('id', 'street');
// towns with zip code and quarter
$town_model = new Town_Model();
$arr_towns = $town_model->select_list_with_quater();
$arr_towns = array
(
NULL => '--- ' . __('Select town') . ' ---'
) + ORM::factory('town')->select_list_with_quater();
// countries fro address point
$country_model = new Country_Model();
$arr_countries = $country_model->select_list('id', 'country_name');
// list for phone prefixes
$phone_prefixes = $country_model->select_country_list();
freenetis/branches/testing/application/controllers/bank_templates.php
$grid->order_field('template_name')
->label(__('Template name'));
$grid->action_field('id')
->label(__('Show'))
->url(url_lang::base().'bank_templates/show')
->action(__('Show'));
$actions = $grid->grouped_action_field();
$grid->action_field('id')
->label(__('Edit'))
->url(url_lang::base().'bank_templates/edit')
->action(__('Edit'));
$actions->add_action()
->icon_action('show')
->url('bank_templates/show');
$actions->add_action()
->icon_action('edit')
->url('bank_templates/edit');
$grid->datasource($templates);
$breadcrumbs = breadcrumbs::add()
freenetis/branches/testing/application/controllers/members.php
$entrance_fee = 0;
// countries
$country_model = new Country_Model();
$arr_countries = $country_model->select_list('id', 'country_name');
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
// streets
$street_model = new Street_Model();
$arr_streets = $street_model->select_list('id', 'street');
asort($arr_streets, SORT_LOCALE_STRING);
$arr_streets = array
(
NULL => '--- ' . __('Without street') . ' ---'
) + ORM::factory('street')->select_list('id', 'street');
// towns with zip code and quarter
$town_model = new Town_Model();
$arr_towns = $town_model->select_list_with_quater();
$arr_towns = array
(
NULL => '--- ' . __('Select town') . ' ---'
) + ORM::factory('town')->select_list_with_quater();
// phone prefixes
$country_model = new Country_Model();
......
$form->group('')
->label(__('Address of connecting place'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('street_id')
->label(__('Street').':')
->rules('required')
->options($arr_streets)
->add_button('streets', '{street}');
......
->label(__('street number').':')
->rules('length[1,50]|valid_numeric');
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('country_id')
->label(__('Country').':')
->rules('required')
......
'Address of connecting place is different than address of domicile'
));
$form->dropdown('domicile_town_id')
->label(__('Town').':')
->options($arr_towns)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('domicile_street_id')
->label(__('Street').':')
->options($arr_streets)
......
->rules('length[1,50]|valid_numeric')
->callback(array($this, 'valid_docimile_street_number'));
$form->dropdown('domicile_town_id')
->label(__('Town').':')
->options($arr_towns)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('domicile_country_id')
->label(__('Country').':')
->options($arr_countries)
......
$this->_member_id = $member->id;
// countries
$country_model = new Country_Model();
$arr_countries = $country_model->select_list('id', 'country_name');
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
// streets
$street_model = new Street_Model();
$arr_streets = $street_model->select_list('id', 'street');
asort($arr_streets, SORT_LOCALE_STRING);
$arr_streets = array
(
NULL => '--- ' . __('Without street') . ' ---'
) + $member->address_point->town->streets->select_list('id', 'street');
// streets
$arr_domicile_streets = array
(
NULL => '--- ' . __('Without street') . ' ---'
) + $member->members_domicile->address_point->town->streets->select_list('id', 'street');
// towns with zip code and quarter
$arr_towns = array
(
NULL => '--- ' . __('Select town') . ' ---'
) + ORM::factory('town')->select_list_with_quater();
// towns
$town_model = new Town_Model();
$arr_towns = $town_model->select_list_with_quater();
// engineers
$member = new Member_Model($member_id);
......
$form->group('')
->label(__('Address of connecting place'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns)
->selected($member->address_point->town_id)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('street_id')
->label(__('street').':')
->rules('required')
->label(__('Street').':')
->options($arr_streets)
->selected($member->address_point->street_id)
->add_button('streets', '{street}');
$form->input('street_number')
->label(__('street number').':')
->label(__('Street number').':')
->rules('length[1,50]|valid_numeric')
->value($member->address_point->street_number);
$form->dropdown('town_id')
->label(__('town').':')
->rules('required')
->options($arr_towns)
->selected($member->address_point->town_id)
->add_button('towns', '{town} - {quarter}, {zip_code}');
$form->dropdown('country_id')
->label(__('country').':')
->label(__('Country').':')
->rules('required')
->options($arr_countries)
->selected($member->address_point->country_id);
......
)
)
->checked((bool) $member->members_domicile->id);
$form->dropdown('domicile_town_id')
->label(__('town').':')
->options($arr_towns)
->selected($member->members_domicile->address_point->town_id)
->add_button('towns');
$form->dropdown('domicile_street_id')
->label(__('street').':')
->options($arr_streets)
->options($arr_domicile_streets)
->selected($member->members_domicile->address_point->street_id)
->add_button('streets');
->add_button('streets', '{street}');
$form->input('domicile_street_number')
->label(__('street number').':')
......
->value($member->members_domicile->address_point->street_number)
->callback(array($this, 'valid_docimile_street_number'));
$form->dropdown('domicile_town_id')
->label(__('town').':')
->options($arr_towns)
->selected($member->members_domicile->address_point->town_id)
->add_button('towns');
$form->dropdown('domicile_country_id')
->label(__('country').':')
->rules('required')
freenetis/branches/testing/application/controllers/json.php
echo json_encode($arr_devices);
}
/**
* Callback AJAX function to get only streets of choosen town to dropdown
*
* @author Ondřej Fibich
*/
public function get_streets_by_town()
{
$town_id = $this->input->get('town_id');
$street = new Street_Model();
$streets = $street->where('town_id', $town_id)->select_list('id', 'street');
echo json_encode($streets);
}
}
freenetis/branches/testing/application/controllers/js.php
private function _js_address_points_add()
{
$this->address_point_streets();
$this->address_point_gps();
}
private function _js_devices_add()
{
$this->address_point_streets();
$this->address_point_gps();
$this->segment_iface();
......
private function _js_devices_edit()
{
$this->address_point_streets();
$this->address_point_gps();
}
......
private function _js_members_add()
{
$this->address_point_streets();
$this->address_point_gps();
$this->domicile_toogle();
}
private function _js_members_edit()
{
$this->address_point_streets();
$this->address_point_gps();
$this->domicile_toogle();
}
......
private function _js_registration()
{
$this->address_point_streets();
$this->address_point_gps();
}
......
}
/**
* Adds javascript for town streets interaction
*/
private function address_point_streets()
{
$this->views['__pieces_address_point_street'] =
View::factory('js/__pieces/address_point_street')->render();
}
/**
* Adds javascript for toogling domicicles
*/
private function domicile_toogle()
freenetis/branches/testing/application/controllers/devices.php
// streets
$street_model = new Street_Model();
$streets_first = array
$arr_streets = array
(
NULL => '----- '.__('select street').' -----'
);
$arr_streets = $streets_first + $street_model->select_list('id', 'street');
NULL => '----- '.__('without street').' -----'
) + $street_model->select_list('id', 'street');
// towns
$town_model = new Town_Model();
$towns_first = array
$arr_towns = array
(
NULL => '----- '.__('select town').' -----'
);
$arr_towns = $towns_first + $town_model->select_list_with_quater();
) + $town_model->select_list_with_quater();
// list of engineers
if ($this->acl_check_edit('Devices_Controller', 'main_engineer'))
......
$form->group('')
->label(__('Address'));
$form->dropdown('town_id')
->label(__('town').':')
->rules('required')
->options($arr_towns)
->selected($selected_town_id)
->add_button('towns');
$form->dropdown('street_id')
->label(__('street').':')
->options($arr_streets)
......
->rules('length[1,50]|valid_numeric')
->value($selected_street_number);
$form->dropdown('town_id')
->label(__('town').':')
->rules('required')
->options($arr_towns)
->selected($selected_town_id)
->add_button('towns');
$form->dropdown('country_id')
->label(__('country').':')
->rules('required')
......
// streets
$street_model = new Street_Model();
$streets_first = array
$arr_streets = array
(
NULL => '----- '.__('select street').' -----'
);
$arr_streets = $streets_first + $street_model->select_list('id', 'street');
NULL => '----- '.__('without street').' -----'
) + $device->address_point->town->streets->select_list('id', 'street');
// towns
$town_model = new Town_Model();
$towns_first = array
$arr_towns = array
(
NULL => '----- '.__('select town').' -----'
);
$arr_towns = $towns_first + $town_model->select_list_with_quater();
) + $town_model->select_list_with_quater();
$form = new Forge(
url_lang::base()."devices/edit/".$device_id, '',
......
$form->group('')
->label(__('Address'));
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns)
->selected($device->address_point->town_id)
->add_button('towns');
$form->dropdown('street_id')
->label(__('Street').':')
->options($arr_streets)
......
->rules('length[1,50]|valid_numeric')
->value($device->address_point->street_number);
$form->dropdown('town_id')
->label(__('Town').':')
->rules('required')
->options($arr_towns)
->selected($device->address_point->town_id)
->add_button('towns');
$form->dropdown('country_id')
->label(__('country').':')
->rules('required')
freenetis/branches/testing/application/upgrade_sql/upgrade_sql.php
return $svnid;
}
/**
* Upgrates streets
*
* @author Ondřej Fibich
* @throws Exception
* @return bool
*/
function upgrade_sql_after()
{
// My servant
$ap_model = new Address_point_Model();
// My map
$aps = $ap_model->find_all();
// My notebook
$street_id_cache = array();
// My connection to my kingdom
$db = Database::instance();
try
{
// My journey begins!
$ap_model->transaction_start();
// One day I'd like to walk throught all streets in my kingdom.
/* @var $ap Address_point_Model */
foreach ($aps as $ap)
{
// Some streets didn't exists in my map.
if (!$ap->street_id)
{
continue;
}
// Sometimes I get lost and I went to street with same name.
if (array_key_exists($ap->street_id, $street_id_cache))
{
// But sometimes the street was in the different town.
// Than I had to mark it to my map and notebook.
if ($ap->town_id != $street_id_cache[$ap->street_id])
{
$street = new Street_Model();
$street = $street->get_street($ap->street->street, $ap->town_id);
$ap->street_id = $street->id;
$ap->save_throwable();
$street_id_cache[$ap->street_id] = $ap->town_id;
}
// Street belongs to town which I knew.
else
{
$ap->street->town_id = $ap->town_id;
$ap->street->save_throwable();
}
}
// When I get to streets I had never been before,
// I marked it to my note.
else
{
$ap->street->town_id = $ap->town_id;
$ap->street->save_throwable();
$street_id_cache[$ap->street_id] = $ap->town_id;
}
}
// My journey ends!
$ap_model->transaction_commit();
}
catch (Exception $e)
{
// Something terrible happends!
$ap_model->transaction_rollback();
// I'am dying :-(
throw $e;
}
// I'm back home with cup of tea :-)
return TRUE;
}
/**
* Column for transfer key in phone invoice users
* Column for town key in streets
*
* @author Ondřej Fibich
*/
$upgrade_sql[get_SVN_rev()] = array
(
"ALTER TABLE `phone_invoice_users` ADD `transfer_id` INT( 11 ) NULL AFTER `phone_invoice_id`;",
"ALTER TABLE `streets` ADD `town_id` INT( 11 ) NULL AFTER `id`;",
"ALTER TABLE `phone_invoice_users` ADD INDEX ( `transfer_id` );",
"ALTER TABLE `streets` ADD INDEX ( `town_id` );",
"ALTER TABLE `phone_invoice_users` ADD FOREIGN KEY ( `transfer_id` ) REFERENCES `transfers` ( `id` ) ON DELETE SET NULL;",
"ALTER TABLE `streets` ADD FOREIGN KEY ( `town_id` ) REFERENCES `towns` ( `id` ) ON DELETE SET NULL;",
);
freenetis/branches/testing/application/upgrade_sql/upgrade_sql_1252.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Column for transfer key in phone invoice users
*
* @author Ondřej Fibich
*/
$upgrade_sql[1252] = array
(
"ALTER TABLE `phone_invoice_users` ADD `transfer_id` INT( 11 ) NULL AFTER `phone_invoice_id`;",
"ALTER TABLE `phone_invoice_users` ADD INDEX ( `transfer_id` );",
"ALTER TABLE `phone_invoice_users` ADD FOREIGN KEY ( `transfer_id` ) REFERENCES `transfers` ( `id` ) ON DELETE SET NULL;",
);
freenetis/branches/testing/application/libraries/grid/Order_link_field.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Link order grid field for displaying link with data item.
*
* @author Ondřej Fibich
* @method Order_Link_Field name(string $name)
* @method Order_Link_Field data_name(string $name)
* @method Order_Link_Field script(string $script)
* @method Order_Link_Field url(string $url)
*/
class Order_Link_Field extends Order_Field
{
/**
* Name of column
*
* @var string
*/
public $name = 'id';
/**
* Name of data column
*
* @var string
*/
public $data_name = 'id';
/**
* URL to action
*
* @var string
*/
public $url;
/**
* Extra script
*
* @var string
*/
public $script = null;
/**
* Link of field, label is set and internacionalized from data name
*
* @param string $url
* @param string $data_name Name of data field, if empty name is set as data name
*/
public function link($url, $data_name = NULL)
{
if (!text::starts_with($url, url::base()))
{
$this->url = url_lang::base() . $url;
}
else
{
$this->url = $url;
}
if (empty($data_name))
{
$data_name = $this->name;
}
$this->data_name = $data_name;
if (!empty($data_name))
{
$this->label = __(utf8::ucfirst(inflector::humanize($data_name)));
}
return $this;
}
/**
* Renders field
*
* @return string
*/
public function render()
{
return $this->label;
}
}
freenetis/branches/testing/application/libraries/grid/Link_field.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Action link grid field for displaying link with data item.
*
* @author Ondřej Fibich
* @method Link_Field name(string $name)
* @method Link_Field data_name(string $name)
* @method Link_Field script(string $script)
* @method Link_Field url(string $url)
*/
class Link_Field extends Field
{
/**
* Name of column
*
* @var string
*/
public $name = 'id';
/**
* Name of data column
*
* @var string
*/
public $data_name = 'id';
/**
* URL to action
*
* @var string
*/
public $url;
/**
* Extra script
*
* @var string
*/
public $script = null;
/**
* Contruct of field, label is set and internacionalized from name
*
* @param string $name Name of field
*/
public function __construct($name)
{
$this->name = $name;
$this->label = __(utf8::ucfirst(inflector::humanize($name)));
}
/**
* Link of field, label is set and internacionalized from data name
*
* @param string $url
* @param string $data_name Name of data field, if empty name is set as data name
*/
public function link($url, $data_name = NULL)
{
if (!text::starts_with($url, url::base()))
{
$this->url = url_lang::base() . $url;
}
else
{
$this->url = $url;
}
if (empty($data_name))
{
$data_name = $this->name;
}
$this->data_name = $data_name;
if (!empty($data_name))
{
$this->label = __(utf8::ucfirst(inflector::humanize($data_name)));
}
return $this;
}
/**
* Renders field
*
* @return string
*/
public function render()
{
return $this->label;
}
}
freenetis/branches/testing/application/libraries/Grid.php
require_once dirname(__FILE__) . '/grid/Grouped_action_field.php';
require_once dirname(__FILE__) . '/grid/Order_field.php';
require_once dirname(__FILE__) . '/grid/Order_callback_field.php';
require_once dirname(__FILE__) . '/grid/Link_field.php';
require_once dirname(__FILE__) . '/grid/Order_link_field.php';
require_once dirname(__FILE__) . '/grid/Form_field.php';
require_once dirname(__FILE__) . '/grid/Order_form_field.php';
......
*
* @method Field Field(string $column)
* @method Action_Field action_field(string $column)
* @method Link_Field link_field(string $column, string $column2)
* @method Order_Link_Field order_link_field(string $column, string $column2)
* @method Order_Field order_field(string $column)
* @method Order_callback_Field order_callback_field(string $column)
* @method Callback_Field callback_field(string $column)
......
// Class name
$field = ucfirst($method);
// Create the input
if ($field == 'Order_field')
if ($field == 'Order_field' || $field == 'Order_callback_field' ||
$field == 'Order_form_field' || $field == 'Order_link_field')
{
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1]))
{
$args[1] = NULL;
}
$field = new Order_field($args[0], $args[1], $arguments);
$field = new $field($args[0], $args[1], $arguments);
}
elseif ($field == 'Order_callback_field')
else if ($field == 'Grouped_action_field')
{
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1]))
$args[1] = NULL;
$field = new Order_callback_field($args[0], $args[1], $arguments);
$field = new Grouped_action_field(isset($args[0]) ? $args[0] : NULL);
}
elseif ($field == 'Order_form_field')
else if ($field == 'Link_field')
{
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1]))
$args[1] = NULL;
$field = new Order_form_field($args[0], $args[1], $arguments);
$field = new $field($args[0], @$args[1]);
}
else if ($field == 'Grouped_action_field')
{
$field = new Grouped_action_field(isset($args[0]) ? $args[0] : NULL);
}
else
{
$field = new $field($args[0]);
freenetis/branches/testing/application/libraries/MY_Controller.php
*/
private static $login_not_required = array
(
/* login, scheduler, instalation */
'login',
'forgotten_password',
'scheduler/run',
'installation',
/* registration */
'registration',
'registration/complete',
'registration/complete',
'js/registration',
'address_points/get_gps_by_street_street_number_town_country',
'scheduler/run',
'installation'
'address_points/get_gps_by_address_from_google',
'json/get_streets_by_town',
);
/** @var unknown_type */
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff