Revize 647
Přidáno uživatelem Michal Kliment před více než 14 roky(ů)
freenetis/trunk/kohana/media/css/style.css | ||
---|---|---|
#htaccess {
|
||
width: 250px;
|
||
height: 200px;
|
||
}
|
||
|
||
.popup {
|
||
border: 1px solid black;
|
||
padding: 20px;
|
||
margin: 20px;
|
||
}
|
||
|
||
.ico_add {
|
||
margin-left: 5px;
|
||
}
|
freenetis/trunk/kohana/application/helpers/network.php | ||
---|---|---|
<?php defined('SYSPATH') or die('No direct script access.');
|
||
/**
|
||
* Network helper.
|
||
*
|
||
* @author Michal Kliment
|
||
* @copyright (c) 2010 Kliment Michal
|
||
* @license GNU GPLv3
|
||
* @license http://www.gnu.org/licenses/gpl.txt
|
||
*/
|
||
|
||
class network_Core {
|
||
|
||
/**
|
||
* Convert netmask in classic format (eg. 255.255.255.0] in CIDR format (/24)
|
||
* @author Michal Kliment
|
||
* @param string
|
||
* @return string
|
||
*/
|
||
public static function netmask2cidr($netmask)
|
||
{
|
||
return 32 - log(~ip2long($netmask) + 1, 2);
|
||
}
|
||
|
||
}
|
freenetis/trunk/kohana/application/helpers/form.php | ||
---|---|---|
// Inner key should always be a string
|
||
$inner_key = (string) $inner_key;
|
||
|
||
$sel = ($selected === $inner_key) ? ' selected="selected"' : '';
|
||
$sel = ($selected === $inner_key) ? ' selected' : '';
|
||
$input .= '<option value="'.$inner_key.'"'.$sel.'>'.$inner_val.'</option>'."\n";
|
||
}
|
||
$input .= '</optgroup>'."\n";
|
||
}
|
||
else
|
||
{
|
||
$sel = ($selected === $key) ? ' selected="selected"' : '';
|
||
$sel = ($selected === $key) ? ' selected' : '';
|
||
$input .= '<option value="'.$key.'"'.$sel.'>'.$val.'</option>'."\n";
|
||
}
|
||
}
|
freenetis/trunk/kohana/application/helpers/server.php | ||
---|---|---|
// mod_rewrite is
|
||
return in_array('mod_rewrite', apache_get_modules());
|
||
}
|
||
|
||
/**
|
||
* @author Michal Kliment
|
||
* Return request uri
|
||
* @return string
|
||
*/
|
||
public static function request_uri()
|
||
{
|
||
return $_SERVER['REQUEST_URI'];
|
||
}
|
||
}
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
asort($arr_towns, SORT_LOCALE_STRING);
|
||
|
||
// form
|
||
$form = new Forge(url_lang::base().'members/add', '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Basic information'));
|
||
... | ... | |
$form->password('confirm_password')->label(url_lang::lang('texts.confirm password').':')->rules('required|length[3,50]')->matches($form->passwd);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Address'));
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->rules('required')->options($arr_streets);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->rules('required')->options($arr_streets)->add_button('streets');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]|valid_numeric');
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->add_button('towns');
|
||
$form->group('')->label(url_lang::lang('texts.Contact information'));
|
||
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[9,40]')->callback(array($this, 'valid_phone'));
|
||
$form->input('email')->label(url_lang::lang('texts.email').':')
|
||
... | ... | |
$form->group('')->label(url_lang::lang('texts.Address'));
|
||
if ($this->acl_check_edit(get_class($this),'address',$member_id))
|
||
{
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->rules('required')->options($arr_streets)->selected($address_point->street_id);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->rules('required')->options($arr_streets)->selected($address_point->street_id)->add_button('streets');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]|valid_numeric')->value($address_point->street_number);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($address_point->town_id);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($address_point->town_id)->add_button('towns');
|
||
}
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Account information'));
|
freenetis/trunk/kohana/application/controllers/ifaces.php | ||
---|---|---|
foreach ($devices as $device) {
|
||
$arr_devices[$device->id] = $device->id.' - '.$device->name;
|
||
}
|
||
$form->dropdown('device_id')->label(url_lang::lang('texts.Device name'))->options($arr_devices)->rules('required');
|
||
$form->dropdown('device_id')->label(url_lang::lang('texts.Device name'))->options($arr_devices)->rules('required')->add_button('devices');
|
||
}
|
||
if (!$this->acl_check_new('Devices_Controller','iface',$member_id))
|
||
Controller::error(ACCESS);
|
||
... | ... | |
{
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
}
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name'))->options($arr_segments)->rules('required');
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name'))->options($arr_segments)->rules('required')->add_button('segments');
|
||
$form->input('mac')->label(url_lang::lang('texts.MAC').':')->rules('required|length[3,250]');
|
||
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]')->cols('20')->rows('5');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
... | ... | |
{
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
}
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name'))->options($arr_segments)->rules('required')->selected($iface->segment_id);
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name'))->options($arr_segments)->rules('required')->selected($iface->segment_id)->add_button('segments');
|
||
$form->input('mac')->label(url_lang::lang('texts.MAC').':')->rules('required|length[3,250]')->value($iface->mac);
|
||
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]')->value($iface->comment)->cols('20')->rows('5');
|
||
$form->submit('submit')->value(url_lang::lang('texts.update'));
|
freenetis/trunk/kohana/application/controllers/users.php | ||
---|---|---|
if ($this->acl_check_edit(get_class($this),'phone',$user_model->member_id))
|
||
$form->input('phone')
|
||
->label(url_lang::lang('texts.phone').':')
|
||
->rules('required|length[3,40]')->callback(array($this, 'valid_phone'))->value($user_model->phone);
|
||
->rules('required|length[9,14]|valid_numeric')->callback(array($this, 'valid_phone'))->value($user_model->phone);
|
||
if ($this->acl_check_edit(get_class($this),'email',$user_model->member_id))
|
||
$form->input('email')->label(url_lang::lang('texts.email').':')
|
||
->rules('length[3,50]|valid_email')
|
freenetis/trunk/kohana/application/controllers/vlan_ifaces.php | ||
---|---|---|
foreach ($vlans as $vlan) {
|
||
$arr_vlans[$vlan->id] = $vlan->name;
|
||
}
|
||
$form->dropdown('vlan_id')->label(url_lang::lang('texts.VLAN name'))->options($arr_vlans)->rules('required');
|
||
$form->dropdown('vlan_id')->label(url_lang::lang('texts.VLAN name'))->options($arr_vlans)->rules('required')->add_button('vlans');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
if($form->validate())
|
||
... | ... | |
foreach ($vlans as $vlan) {
|
||
$arr_vlans[$vlan->id] = $vlan->name;
|
||
}
|
||
$form->dropdown('vlan_id')->label(url_lang::lang('texts.VLAN name'))->options($arr_vlans)->rules('required')->selected($vlan_iface->vlan_id);
|
||
$form->dropdown('vlan_id')->label(url_lang::lang('texts.VLAN name'))->options($arr_vlans)->rules('required')->selected($vlan_iface->vlan_id)->add_button('vlans');
|
||
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.update'));
|
freenetis/trunk/kohana/application/controllers/towns.php | ||
---|---|---|
Controller::error(ACCESS);
|
||
|
||
// creates new form
|
||
$form = new Forge(url_lang::base().'towns/add', '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->input('town')->label(url_lang::lang('texts.Town').':')->rules('required|length[1,50]')->callback(array($this,'check_town'));
|
||
... | ... | |
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Town has been successfully added.'));
|
||
}
|
||
url::redirect(url_lang::base().'towns/show_all');
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
$name = $town->town;
|
||
$name .= ($town->quarter) ? '-'.$town->quarter : '';
|
||
$name .= ', '.$town->zip_code;
|
||
|
||
echo "<script type=text/javascript>";
|
||
echo "var town = opener.document.getElementById('town_id');";
|
||
echo "town.options[town.options.length] = new Option('".$name."', '".$town->id."', true);";
|
||
echo "town.selectedIndex = town.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
else
|
||
// classic adding
|
||
url::redirect(url_lang::base().'towns/show_all');
|
||
}
|
||
|
||
$view = new View('main');
|
freenetis/trunk/kohana/application/controllers/vlans.php | ||
---|---|---|
|
||
$vlan = new vlan_Model();
|
||
|
||
$form = new Forge(url_lang::base()."vlans/add", '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
... | ... | |
|
||
unset($form_data);
|
||
|
||
if ($vlan->save()) {
|
||
if ($vlan->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Vlan has been successfully saved.'));
|
||
url::redirect(url_lang::base().'vlans/show/'.$vlan->id);
|
||
exit;
|
||
}
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
echo "<script type=text/javascript>";
|
||
echo "var vlan = opener.document.getElementById('vlan_id');";
|
||
echo "vlan.options[vlan.options.length] = new Option('".$vlan->name."', '".$vlan->id."', true);";
|
||
echo "vlan.selectedIndex = vlan.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
else
|
||
// classic adding
|
||
url::redirect(url_lang::base().'vlans/show/'.$vlan->id);
|
||
|
||
}
|
||
//----- end validate --------------------------------------------------
|
freenetis/trunk/kohana/application/controllers/subnets.php | ||
---|---|---|
|
||
$redirect[0] = url_lang::lang('texts.No');
|
||
$redirect[1] = url_lang::lang('texts.Yes');
|
||
$form = new Forge(url_lang::base()."subnets/add/", '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
$form->input('name')->label(url_lang::lang('texts.Subnet name').':')->rules('required|length[3,250]');
|
||
... | ... | |
if ($subnet->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Subnet has been successfully saved.'));
|
||
url::redirect(url_lang::base().'subnets/show/'.$subnet->id);
|
||
}
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
$name = $subnet->network_address.'/'.network::netmask2cidr($subnet->netmask);
|
||
echo "<script type=text/javascript>";
|
||
echo "var subnet = opener.document.getElementById('subnet_id');";
|
||
echo "subnet.options[subnet.options.length] = new Option('".$name."', '".$subnet->id."', true);";
|
||
echo "subnet.selectedIndex = subnet.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
// classic addijng
|
||
else
|
||
url::redirect(url_lang::base().'subnets/show/'.$subnet->id);
|
||
|
||
}
|
||
$headline = url_lang::lang('texts.Add new subnet');
|
freenetis/trunk/kohana/application/controllers/streets.php | ||
---|---|---|
Controller::error(ACCESS);
|
||
|
||
// creates new form
|
||
$form = new Forge(url_lang::base().'streets/add', '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->input('street')->label(url_lang::lang('texts.Street').':')->rules('required|length[1,50]')->callback(array($this,'check_street'));
|
||
... | ... | |
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Street has been successfully added.'));
|
||
}
|
||
url::redirect(url_lang::base().'streets/show_all');
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
echo "<script type=text/javascript>";
|
||
echo "var street = opener.document.getElementById('street_id');";
|
||
echo "street.options[street.options.length] = new Option('".$street->street."', '".$street->id."', true);";
|
||
echo "street.selectedIndex = street.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
else
|
||
// classic adding
|
||
url::redirect(url_lang::base().'streets/show_all');
|
||
}
|
||
|
||
$view = new View('main');
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
->callback(array($this, 'valid_ip'));
|
||
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
->rules('required')->add_button('subnets');
|
||
//->class('ajax')->onchange('ajax_get_subnet(this.value)');
|
||
|
||
$this->form->dropdown('gateway')->label(url_lang::lang('texts.Gateway'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected('0');
|
||
... | ... | |
|
||
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
->rules('required')->add_button('subnets');
|
||
|
||
$this->form->dropdown('gateway')->label(url_lang::lang('texts.Gateway'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected('0');
|
||
$this->form->dropdown('service')->label(url_lang::lang('texts.Service'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected('0');
|
||
... | ... | |
|
||
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)
|
||
->rules('required');
|
||
->rules('required')->add_button('subnets');
|
||
|
||
$this->form->dropdown('gateway')->label(url_lang::lang('texts.Gateway'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected('0');
|
||
$this->form->dropdown('service')->label(url_lang::lang('texts.Service'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected('0');
|
||
... | ... | |
|
||
$this->form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')
|
||
->options($arr_subnets)->selected($ip_address->subnet_id)
|
||
->rules('required');
|
||
->rules('required')->add_button('subnets');
|
||
|
||
$this->form->dropdown('gateway')->label(url_lang::lang('texts.Gateway'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected($ip_address->gateway);
|
||
$this->form->dropdown('service')->label(url_lang::lang('texts.Service'))->options(array('0'=> url_lang::lang('texts.No'), '1'=> url_lang::lang('texts.Yes')))->selected($ip_address->service);
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
asort($arr_towns);
|
||
|
||
// forge form
|
||
$form = new Forge(url_lang::base()."devices/add/".$user_id, '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE),'', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required')->selected($selected);
|
||
... | ... | |
if ($this->acl_check_new(get_class($this),'password'))
|
||
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
|
||
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($selected_GPS);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id)->add_button('streets');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($selected_street_number);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id)->add_button('towns');
|
||
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]');
|
||
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($selected_engineer);
|
||
$form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
... | ... | |
if ($device_saved && $device_engineer_saved)
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Device has been successfully saved.'));
|
||
url::redirect(url_lang::base().'devices/show/'.$device_model->id);
|
||
}
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
echo "<script type=text/javascript>";
|
||
echo "var device = opener.document.getElementById('device_id');";
|
||
echo "device.options[device.options.length] = new Option('".$device_model->id." - ".$device_model->name."', '".$device_model->id."', true);";
|
||
echo "device.selectedIndex = device.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
else
|
||
// classic adding
|
||
url::redirect(url_lang::base().'devices/show/'.$device_model->id);
|
||
}
|
||
|
||
$view = new View('main');
|
||
... | ... | |
if ($this->acl_check_new(get_class($this),'password'))
|
||
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
|
||
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($selected_GPS);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id)->add_button('streets');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($selected_street_number);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id)->add_button('towns');
|
||
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]');
|
||
|
||
// list of engineers
|
||
... | ... | |
// adding interface
|
||
$form->group('')->label(url_lang::lang('texts.Interface'));
|
||
$form->input('mac')->label(url_lang::lang('texts.MAC').':')->rules('required|valid_mac_address');
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name').':')->options($arr_segments)->rules('required')->selected($selected_segment);
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name').':')->options($arr_segments)->rules('required')->selected($selected_segment)->add_button('segments');
|
||
|
||
// adding ip address
|
||
$form->group('')->label(url_lang::lang('texts.IP address'));
|
||
$form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required|valid_ip_address')
|
||
->callback(array($this, 'valid_ip'));
|
||
$form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')->rules('required')
|
||
->options($arr_subnets_names)->selected($selected_subnet);
|
||
->options($arr_subnets_names)->selected($selected_subnet)->add_button('subnets');
|
||
|
||
// submit button
|
||
$form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
... | ... | |
if ($this->acl_check_edit(get_class($this),'password'))
|
||
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]')->value($device->password);
|
||
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($device->address_point->GPS);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($device->address_point->street_id);
|
||
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($device->address_point->street_id)->add_button('streets');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($device->address_point->street_number);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($device->address_point->town_id);
|
||
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($device->address_point->town_id)->add_button('towns');
|
||
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]')->value($device->comment);
|
||
$form->submit('submit')->value(url_lang::lang('texts.update'));
|
||
special::required_forge_style($form, ' *', 'required');
|
freenetis/trunk/kohana/application/controllers/segments.php | ||
---|---|---|
$enum_type_model = new Enum_type_Model();
|
||
$arr_media = $enum_type_model->get_values(Enum_type_Model::$medium_type_id);
|
||
|
||
$form = new Forge(url_lang::base()."segments/add", '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
... | ... | |
if ($segment->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Segment has been successfully saved.'));
|
||
url::redirect(url_lang::base().'segments/show/'.$segment->id);
|
||
}
|
||
// for popup adding
|
||
if ($this->popup)
|
||
{
|
||
echo "<script type=text/javascript>";
|
||
echo "var segment = opener.document.getElementById('segment_id');";
|
||
echo "segment.options[segment.options.length] = new Option('".$segment->name."', '".$segment->id."', true);";
|
||
echo "segment.selectedIndex = segment.options.length-1;";
|
||
echo "self.close();";
|
||
echo "</script>";
|
||
}
|
||
else
|
||
// classic adding
|
||
url::redirect(url_lang::base().'segments/show/'.$segment->id);
|
||
|
||
}
|
||
$headline = url_lang::lang('texts.Add new segment');
|
freenetis/trunk/kohana/application/libraries/Form_Dropdown.php | ||
---|---|---|
|
||
protected $data = array
|
||
(
|
||
'type' => 'dropdown',
|
||
'class' => 'dropdown',
|
||
'name' => '',
|
||
'class' => 'dropdown',
|
||
);
|
||
|
||
protected $protect = array('type');
|
||
protected $protec = array('type');
|
||
|
||
public function __get($key)
|
||
{
|
||
... | ... | |
// Get the options and default selection
|
||
$options = arr::remove('options', $base_data);
|
||
$selected = arr::remove('selected', $base_data);
|
||
arr::remove('label', $base_data);
|
||
arr::remove('add_button', $base_data);
|
||
|
||
return form::dropdown($base_data, $options, $selected);
|
||
}
|
||
|
||
public function add_button($controller = NULL)
|
||
{
|
||
if ($controller === NULL)
|
||
{
|
||
if (!isset($this->data['add_button']))
|
||
return false;
|
||
|
||
echo "<a href='".url_lang::base().$this->data['add_button']."/add?popup=1' class='ico_add'><img src='".url::base()."media/images/ico_add.gif'></a>";
|
||
}
|
||
else
|
||
$this->data['add_button'] = $controller;
|
||
}
|
||
|
||
protected function load_value()
|
||
{
|
||
if (is_bool($this->valid))
|
freenetis/trunk/kohana/application/libraries/Form_Input.php | ||
---|---|---|
unset($data['message']);
|
||
unset($data['help']);
|
||
|
||
// array with aliases of validation function
|
||
$alias = array('numeric' => 'number');
|
||
|
||
// convert to array
|
||
$data['class'] = array($data['class']);
|
||
|
||
foreach ($this->rules as $rule)
|
||
{
|
||
switch ($rule)
|
||
if (substr($rule,0,6)=='valid_')
|
||
{
|
||
case 'valid_numeric':
|
||
$data['class'][] = 'number';
|
||
break;
|
||
case 'valid_email':
|
||
$data['class'][] = 'email';
|
||
break;
|
||
case 'valid_mac_address':
|
||
$data['class'][] = 'mac_address';
|
||
break;
|
||
case 'valid_ip_address':
|
||
$data['class'][] = 'ip_address';
|
||
break;
|
||
case 'valid_suffix':
|
||
$data['class'][] = 'suffix';
|
||
break;
|
||
default:
|
||
if (preg_match ("/length\[([0-9]+),([0-9]+)\]/", $rule, $matches))
|
||
{
|
||
$arr = explode('_',$rule);
|
||
array_shift($arr);
|
||
$rule = implode('_',$arr);
|
||
|
||
$rule = (isset($alias[$rule])) ? $alias[$rule] : $rule;
|
||
|
||
$data['class'][] = $rule;
|
||
}
|
||
else
|
||
{
|
||
if (preg_match ("/length\[([0-9]+),([0-9]+)\]/", $rule, $matches))
|
||
{
|
||
$data['minlength'] = $matches[1];
|
||
$data['maxlength'] = $matches[2];
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach ($this->callbacks as $callback)
|
||
{
|
||
$callback = $callback[1];
|
||
if (substr($callback,0,6)=='valid_')
|
||
{
|
||
$arr = explode('_',$callback);
|
||
array_shift($arr);
|
||
$callback = implode('_',$arr);
|
||
|
||
$callback = (isset($alias[$callback])) ? $alias[$callback] : $callback;
|
||
|
||
$data['class'][] = $callback;
|
||
}
|
||
}
|
||
|
||
$data['class'] = implode (' ',$data['class']);
|
||
|
||
return form::input($data);
|
freenetis/trunk/kohana/application/libraries/MY_Controller.php | ||
---|---|---|
public $settings = NULL;
|
||
public $upgrade_sql = array();
|
||
public $current_svn_db_schema_version = 0;
|
||
public $popup = 0;
|
||
|
||
private $ICON_ERROR = 1;
|
||
private $ICON_GOOD = 2;
|
||
... | ... | |
$this->session = Session::instance();
|
||
$this->settings = new Settings();
|
||
|
||
// if true, freenetis will run in popup mode (without header and menu)
|
||
$this->popup = (isset($_GET['popup']) && $_GET['popup']) ? 1 : 0;
|
||
|
||
// database upgrade goes here
|
||
$this->get_current_svn_db_schema_info();
|
||
|
freenetis/trunk/kohana/application/views/forge_template.php | ||
---|---|---|
<?php
|
||
endif;
|
||
echo $input->html();
|
||
if ($input->type == 'dropdown')
|
||
echo $input->add_button();
|
||
if (strstr($input->class, 'ajax')) echo html::image(array('src'=>'media/images/ajax-loader.gif', 'id'=>'ajax_'.$input->name, 'class'=>'ajax-loader', 'style'=>'display:none;'));
|
||
if ($message = $input->message()):
|
||
|
freenetis/trunk/kohana/application/views/main.php | ||
---|---|---|
<?php echo html::script('media/js/highslide/highslide-with-html.js', FALSE) ?>
|
||
<script type="text/javascript">
|
||
$(document).ready(function(){
|
||
|
||
$('.ico_add').click(function(){
|
||
var win = window.open(this.href, 'formpopup', 'width=930,height=500,resizeable,scrollbars');
|
||
win.focus();
|
||
|
||
if (window.opener == null) window.opener = self;
|
||
|
||
return false;
|
||
})
|
||
|
||
$.validator.addMethod('ip_address', function(value) {
|
||
return value.match(/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])$/);
|
||
}, '<?php echo url_lang::lang('texts.Invalid IP address') ?>');
|
||
... | ... | |
return value.match(/^\/([^\/]+\/)*$/);
|
||
}, '<?php echo url_lang::lang('texts.suffix has to start with slash character and has to end with slash character')?>');
|
||
|
||
$.validator.addMethod('var_sym', function(value) {
|
||
return value.match(/^[0-9]{1,10}$/);
|
||
}, '<?php echo url_lang::lang('texts.Bad variable symbol format.') ?>');
|
||
|
||
$("form").validate();
|
||
});
|
||
|
||
... | ... | |
<?php echo isset($other_styles) ? $other_styles : '' ?>
|
||
</head>
|
||
<body <?php echo isset($onload) ? 'onload="'.$onload.'"' : '' ?> >
|
||
<?php if (!$this->popup): ?>
|
||
<div id="main">
|
||
<div id="header">
|
||
<h1 id="logo"><span>FreeNetIS</span></h1>
|
||
... | ... | |
</div>
|
||
</div>
|
||
</div>
|
||
<?php else: ?>
|
||
<div id="content" class="popup">
|
||
<div id="content-padd">
|
||
<?php echo $content ?>
|
||
</div>
|
||
</div>
|
||
<?php endif ?>
|
||
|
||
|
||
</body>
|
||
</html>
|
||
|
freenetis/trunk/kohana/application/views/form.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<?php echo (isset($message)) ? '<div class="message">'.$message.'</div>' : '' ?>
|
||
<?php echo $link_back ?>
|
||
<?php echo (!$this->popup) ? $link_back : '' ?>
|
||
<br /><br />
|
||
<?php echo $form ?>
|
||
<br />
|
Také k dispozici: Unified diff
Pridano dynamicke pridavani zaznamu do select boxu bez nutnosti reloadu stranek - typicky pripad byl, kdyz uzivatel chtel pridat clena, jenz byval ve meste, ktere jeste nebylo v systemu evidovano, musel otevrit novy panel s adresnimi body, do nej pridat mesto a puvodni odeslat nezvalidovany - po znovubnacteni formulare se ve vyberu jiz objevilo. No uznejte - celkem pakarna. To ale ted neplati - stacilo k tomu popup okno a trochu javascriptu...