Revize 1420
Přidáno uživatelem David Raška před asi 12 roky(ů)
freenetis/branches/testing/application/helpers/html.php | ||
---|---|---|
{
|
||
if ($uri === '')
|
||
{
|
||
$site_url = url::base(FALSE);
|
||
$site_url2 = $site_url = url::base(FALSE);
|
||
}
|
||
elseif (strpos($uri, '://') === FALSE)
|
||
{
|
||
$site_url = url_lang::site($uri, FALSE, $protocol);
|
||
}
|
||
else
|
||
{
|
||
$site_url = $uri;
|
||
if (strpos($uri, '://') === FALSE)
|
||
{
|
||
$site_url = url_lang::site($uri, FALSE, $protocol);
|
||
}
|
||
else
|
||
{
|
||
$site_url = $uri;
|
||
}
|
||
$site_url2 = $site_url;
|
||
|
||
$url = '__url__=' . urlencode(url_lang::current());
|
||
if (strpos($uri, '__url__') === FALSE)
|
||
{
|
||
if (strpos($uri, '?') !== FALSE)
|
||
{
|
||
list ($uri, $qs) = explode('?', $uri, 2);
|
||
$queries = explode('&', $qs);
|
||
array_push($queries, $url);
|
||
$url = implode('&', $queries);
|
||
}
|
||
$site_url2 = $site_url2 . '?' . $url;
|
||
}
|
||
}
|
||
|
||
|
||
return
|
||
// Parsed URL
|
||
'<a href="'.html::specialchars($site_url, FALSE).'"'
|
||
'<a href="'.html::specialchars($site_url2, FALSE).'"'
|
||
// Attributes empty? Use an empty string
|
||
.(empty($attributes) ? '' : html::attributes($attributes)).'>'
|
||
// Title empty? Use the parsed URL
|
freenetis/branches/testing/application/hooks/site_lang.php | ||
---|---|---|
{
|
||
// Array of allowed languages
|
||
$locales = Config::get('allowed_locales');
|
||
|
||
|
||
// Extract language from URL
|
||
$segments = explode('/', url::current());
|
||
$lang = strtolower($segments[0]);
|
||
... | ... | |
break;
|
||
}
|
||
}
|
||
|
||
|
||
// Redirect to URL with valid language
|
||
$index_page = (Settings::get('index_page')) ? 'index.php/' : '';
|
||
url::redirect(url::base() . $index_page . $lang . url_lang::current());
|
freenetis/branches/testing/application/controllers/ifaces.php | ||
---|---|---|
else
|
||
$name = $iface->mac;
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->current()), 0, 1) != 'ifaces')
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()), 0, 1) != 'ifaces')
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link(
|
||
... | ... | |
{
|
||
status::success('Interface has been successfully updated.');
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
url::redirect('devices/show_iface/'.$iface->id);
|
||
else
|
||
url::redirect('ifaces/show/'.$iface->id);
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
}
|
||
|
||
if ($iface->name != '')
|
||
$name = "$iface->name ($iface->mac)";
|
||
else
|
||
$name = $iface->mac;
|
||
{
|
||
if ($iface->name != '')
|
||
$name = "$iface->name ($iface->mac)";
|
||
else
|
||
$name = $iface->mac;
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()),0,1) != 'ifaces')
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link(
|
||
'members/show_all',
|
||
'Members',
|
||
$this->acl_check_view('Members_Controller','members')
|
||
)
|
||
->link(
|
||
'members/show/'.$iface->device->user->member_id,
|
||
'ID '.$iface->device->user->member->id.
|
||
' - '.$iface->device->user->member->name,
|
||
$this->acl_check_view(
|
||
'Members_Controller',
|
||
'members',
|
||
$iface->device->user->member_id
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()),0,1) != 'ifaces')
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link(
|
||
'members/show_all',
|
||
'Members',
|
||
$this->acl_check_view('Members_Controller','members')
|
||
)
|
||
)
|
||
->link(
|
||
'users/show_by_member/'.$iface->device->user->member_id,
|
||
"Users",
|
||
$this->acl_check_view(
|
||
'Users_Controller',
|
||
'users',$iface->device->user->member_id
|
||
->link(
|
||
'members/show/'.$iface->device->user->member_id,
|
||
'ID '.$iface->device->user->member->id.
|
||
' - '.$iface->device->user->member->name,
|
||
$this->acl_check_view(
|
||
'Members_Controller',
|
||
'members',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
)
|
||
->link(
|
||
'users/show/'.$iface->device->user_id,
|
||
$iface->device->user->name.' '.$iface->device->user->surname.
|
||
' ('.$iface->device->user->login.')',
|
||
$this->acl_check_view(
|
||
'Users_Controller',
|
||
'users',
|
||
$iface->device->user->member_id
|
||
->link(
|
||
'users/show_by_member/'.$iface->device->user->member_id,
|
||
"Users",
|
||
$this->acl_check_view(
|
||
'Users_Controller',
|
||
'users',$iface->device->user->member_id
|
||
)
|
||
)
|
||
)
|
||
->link(
|
||
'devices/show_by_user/'.$iface->device->user_id,
|
||
'Devices',
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'devices',
|
||
$iface->device->user->member_id
|
||
->link(
|
||
'users/show/'.$iface->device->user_id,
|
||
$iface->device->user->name.' '.$iface->device->user->surname.
|
||
' ('.$iface->device->user->login.')',
|
||
$this->acl_check_view(
|
||
'Users_Controller',
|
||
'users',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
)
|
||
->link(
|
||
'devices/show/'.$iface->device_id,
|
||
$iface->device->name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'devices',
|
||
$iface->device->user->member_id
|
||
->link(
|
||
'devices/show_by_user/'.$iface->device->user_id,
|
||
'Devices',
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'devices',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
)
|
||
->link(
|
||
'devices/show_iface/'.$iface->id,
|
||
$name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'iface',
|
||
$iface->device->user->member->id
|
||
->link(
|
||
'devices/show/'.$iface->device_id,
|
||
$iface->device->name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'devices',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
)
|
||
->text('Edit')
|
||
->html();
|
||
}
|
||
else
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link(
|
||
'ifaces/show_all',
|
||
'Interfaces',
|
||
$this->acl_check_view('Devices_Controller','iface')
|
||
)
|
||
->link(
|
||
'ifaces/show/'.$iface->id,
|
||
$name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'iface',
|
||
$iface->device->user->member->id
|
||
->link(
|
||
'devices/show_iface/'.$iface->id,
|
||
$name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'iface',
|
||
$iface->device->user->member->id
|
||
)
|
||
)
|
||
)
|
||
->text('Edit')
|
||
->html();
|
||
->text('Edit')
|
||
->html();
|
||
}
|
||
else
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link(
|
||
'ifaces/show_all',
|
||
'Interfaces',
|
||
$this->acl_check_view('Devices_Controller','iface')
|
||
)
|
||
->link(
|
||
'ifaces/show/'.$iface->id,
|
||
$name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'iface',
|
||
$iface->device->user->member->id
|
||
)
|
||
)
|
||
->text('Edit')
|
||
->html();
|
||
}
|
||
|
||
$headline = __('Edit interface');
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs;
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
$headline = __('Edit interface');
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs;
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
} // end of edit
|
||
|
||
/**
|
||
... | ... | |
status::warning('Interface still has at least one wireless setting.');
|
||
}
|
||
}
|
||
url::redirect(Path::instance()->previous()->current());
|
||
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/device_engineers.php | ||
---|---|---|
status::error('Error - it is not possible to remove engineer.');
|
||
}
|
||
|
||
url::redirect(Path::instance()->previous()->current());
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
|
||
}
|
freenetis/branches/testing/application/controllers/transfers.php | ||
---|---|---|
$db->transaction_rollback();
|
||
status::error('Error - cant add new transfer.');
|
||
}
|
||
$this->redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
else
|
||
{
|
freenetis/branches/testing/application/controllers/vlan_ifaces.php | ||
---|---|---|
else
|
||
$name = $iface->mac;
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) != 'devices')
|
||
if (Path::instance()->previous(0,1) != 'devices')
|
||
{
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
... | ... | |
{
|
||
status::success('Vlan interface has been successfully updated.');
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
url::redirect('devices/show_vlan_iface/'.$vlan_iface->id);
|
||
else
|
||
url::redirect('vlan_ifaces/show/' . $vlan_iface->id);
|
||
$this->redirect(Path::instance()->previous());
|
||
|
||
exit;
|
||
}
|
||
}
|
||
// end validate
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
if (Path::instance()->previous(0,1) == 'devices')
|
||
{
|
||
if ($vlan_iface->iface->name != '')
|
||
$iface_name = $vlan_iface->iface->name." (".$vlan_iface->iface->mac.")";
|
freenetis/branches/testing/application/controllers/device_admins.php | ||
---|---|---|
status::success('Device admin has been successfully removed.');
|
||
}
|
||
|
||
url::redirect(Path::instance()->previous()->current());
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
|
||
}
|
freenetis/branches/testing/application/controllers/ip_addresses.php | ||
---|---|---|
$iface->device->user->member_id, array($ip->subnet_id)
|
||
);
|
||
}
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
url::redirect('devices/show_ip_address/' . $ip->id);
|
||
else
|
||
url::redirect('ip_addresses/show/' . $ip->id);
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
if (Path::instance()->previous(0,1) == 'devices')
|
||
{
|
||
if ($iface->name != '')
|
||
$iface_name = $iface->name." (".$iface->mac.")";
|
||
... | ... | |
array($ip->subnet_id)
|
||
);
|
||
}
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
url::redirect('devices/show_ip_address/' . $ip->id);
|
||
else
|
||
url::redirect('ip_addresses/show/' . $ip->id);
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
if (Path::instance()->previous(0,1) == 'devices')
|
||
{
|
||
if ($vlan_iface->iface->name != '')
|
||
$iface_name = $vlan_iface->iface->name." (".$vlan_iface->iface->mac.")";
|
||
... | ... | |
status::error('Error - cant delete ip address.');
|
||
}
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()),0,2) == 'ip_addresses/show')
|
||
url::redirect(Path::instance()->previous()->previous()->current());
|
||
else
|
||
url::redirect(Path::instance()->previous()->current());
|
||
$linkback = Path::instance()->previous();
|
||
if (url::slice(url_lang::uri($linkback),1,1) == 'show')
|
||
{
|
||
$linkback = 'ip_addresses/show_all';
|
||
}
|
||
|
||
$this->redirect($linkback);
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/segments.php | ||
---|---|---|
if (count($segment->ifaces) + count($segment->ports))
|
||
{
|
||
status::warning('At least one interface or port still uses this segment.');
|
||
url::redirect(Path::instance()->previous()->current());
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
|
||
// successfully deleted
|
||
... | ... | |
status::success('Segment has been successfully deleted.');
|
||
}
|
||
|
||
url::redirect(Path::instance()->previous()->current());
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/allowed_subnets.php | ||
---|---|---|
self::update_enabled($member_id);
|
||
}
|
||
|
||
$this->redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
/**
|
||
... | ... | |
self::update_enabled($allowed_subnet->member_id, NULL, array($allowed_subnet->subnet_id));
|
||
}
|
||
|
||
url::redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/json.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Updates session paths
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public function update_paths()
|
||
{
|
||
$url = $this->input->post('url');
|
||
|
||
$paths = $this->session->get('paths');
|
||
|
||
if (!is_array($paths))
|
||
{
|
||
return;
|
||
}
|
||
|
||
$path = $paths[$this->session->get('last_path_id')];
|
||
|
||
if (count($path) && ($path[count($path) - 1] == $url))
|
||
{
|
||
$paths[] = $path;
|
||
unset($paths[$this->session->get('last_path_id')][count($path) - 1]);
|
||
$this->session->set('last_path_id', count($paths) - 1);
|
||
}
|
||
else
|
||
{
|
||
foreach ($paths as $id => $path)
|
||
{
|
||
if (count($path) && ($path[count($path) - 1] == $url))
|
||
{
|
||
$paths[] = $path;
|
||
unset($paths[$id][count($path) - 1]);
|
||
$this->session->set('last_path_id', count($paths) - 1);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
$this->session->set('paths', $paths);
|
||
}
|
||
|
||
/**
|
||
* Inserts new session paths
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public function insert_path()
|
||
{
|
||
$url = $this->input->post('url');
|
||
|
||
$paths = $this->session->get('paths');
|
||
|
||
if (!is_array($paths))
|
||
{
|
||
return;
|
||
}
|
||
|
||
$path = $paths[$this->session->get('last_path_id')];
|
||
|
||
$paths[][] = $paths[$this->session->get('last_path_id')][count($path) - 1];
|
||
unset($paths[$this->session->get('last_path_id')][count($path) - 1]);
|
||
$this->session->set('last_path_id', count($paths) - 1);
|
||
|
||
$this->session->set('paths', $paths);
|
||
}
|
||
|
||
/**
|
||
* Callback AJAX function to filter's whisper for member name
|
||
*
|
||
* @author Michal Kliment
|
freenetis/branches/testing/application/controllers/monitoring.php | ||
---|---|---|
$result = $monitor_host_model->delete_hosts(array_keys($_POST['host_id']), 'id');
|
||
status::success('Monitoring has been successfully deactivated.');
|
||
|
||
$this->redirect(Path::instance()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
$title = __('Monitoring');
|
||
... | ... | |
status::error('Error - Cannot update monitoring.');
|
||
}
|
||
|
||
$this->redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
else
|
||
{
|
||
... | ... | |
status::error('Error - Cannot update monitoring.');
|
||
}
|
||
|
||
$this->redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
/**
|
||
... | ... | |
status::error('Error - Cannot update monitoring.');
|
||
}
|
||
|
||
$this->redirect(Path::instance()->previous()->current());
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
else
|
||
{
|
freenetis/branches/testing/application/controllers/work_reports.php | ||
---|---|---|
status::success('Work report has been successfully deleted');
|
||
}
|
||
|
||
$linkback = Path::instance()->previous()->current();
|
||
|
||
if (url::slice(url_lang::uri($linkback), 0, 2) == 'work_reports/show_by_user' ||
|
||
!$this->acl_check_view('Users_Controller', 'work'))
|
||
$linkback = Path::instance()->previous();
|
||
if (url::slice(url_lang::uri($linkback),1,1) == 'show')
|
||
{
|
||
url::redirect( 'work_reports/show_by_user/' . $work_report->user_id);
|
||
$linkback = 'work_reports/pending';
|
||
}
|
||
else
|
||
{
|
||
url::redirect( 'work_reports/pending');
|
||
}
|
||
|
||
$this->redirect($linkback);
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/redirect.php | ||
---|---|---|
// set flash message
|
||
status::success('Redirection has been successfully set.');
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
url::redirect('devices/show_ip_address/' . $ip_address_id);
|
||
else
|
||
url::redirect('ip_addresses/show/' . $ip_address_id);
|
||
$this->redirect(Path::instance()->previous());
|
||
}
|
||
|
||
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
|
||
if (Path::instance()->previous(0,1) == 'devices')
|
||
{
|
||
if ($ip->iface_id)
|
||
$iface = $ip->iface;
|
freenetis/branches/testing/application/controllers/works.php | ||
---|---|---|
}
|
||
else
|
||
{
|
||
if (url::slice(url_lang::uri(path::previous()),1,1) == 'show_by_user')
|
||
if (url::slice(url_lang::uri(Path::instance->previous()),1,1) == 'show_by_user')
|
||
{
|
||
$this->breadcrumbs->link('members/show_all', 'Members',
|
||
$this->acl_check_view('Members_Controller', 'members'))
|
freenetis/branches/testing/application/controllers/devices.php | ||
---|---|---|
Controller::error(ACCESS);
|
||
}
|
||
|
||
$linkback = Path::instance()->previous()->current();
|
||
$linkback = Path::instance()->previous();
|
||
|
||
if (url::slice(url_lang::uri($linkback),1,1) == 'show')
|
||
{
|
||
$linkback = Path::instance()->previous()->current();
|
||
$linkback = 'devices/show_all';
|
||
}
|
||
|
||
// count of deleted interfaces
|
freenetis/branches/testing/application/controllers/comments.php | ||
---|---|---|
if (!$this->acl_check_view('Members_Controller', 'comment', $parent->member_id))
|
||
Controller::error(ACCESS);
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()), 0, 1) == 'comments_threads')
|
||
Path::instance()->previous();
|
||
$link_back_url = Path::instance()->previous();
|
||
|
||
$link_back_url = Path::instance()->current();
|
||
|
||
$breadcrumbs->link('members/show_all', 'Members')
|
||
->disable_translation()
|
||
->link('members/show/' . $parent->member_id,
|
||
... | ... | |
if (!$this->acl_check_new(get_class($this), 'works', $parent->user->member_id))
|
||
Controller::error(ACCESS);
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()), 0, 1) == 'comments_threads')
|
||
Path::instance()->previous();
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->current()), 1, 1) == 'show_work')
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()), 1, 1) == 'show_work')
|
||
{
|
||
$link_back_url = 'users/show_work/' . $parent->id;
|
||
|
||
... | ... | |
if (!$this->acl_check_edit(get_class($this), 'works', $comment->user->member_id))
|
||
Controller::error(ACCESS);
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()), 1, 1) == 'show_work')
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()), 1, 1) == 'show_work')
|
||
{
|
||
$link_back_url = 'users/show_work/' . $parent->id;
|
||
|
||
... | ... | |
// access control
|
||
if (!$this->acl_check_delete(get_class($this), 'works', $comment->user->member_id))
|
||
Controller::error(ACCESS);
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()->current()), 1, 1) == 'show_work')
|
||
{
|
||
$link_back_url = 'users/show_work/' . $parent->id;
|
||
}
|
||
else
|
||
{
|
||
$link_back_url = 'works/show/' . $parent->id;
|
||
}
|
||
|
||
$link_back_url = $this->redirect(Path::instance()->previous());
|
||
|
||
break;
|
||
|
||
default:
|
freenetis/branches/testing/application/libraries/Path.php | ||
---|---|---|
private $path = NULL;
|
||
|
||
/**
|
||
* Id of current position in pathl
|
||
* @var integer
|
||
*/
|
||
private $id = NULL;
|
||
|
||
/**
|
||
* Array of all paths
|
||
* @var array
|
||
*/
|
||
private $paths = NULL;
|
||
|
||
/**
|
||
* Returns path as only URI
|
||
* @var boolean
|
||
*/
|
||
... | ... | |
*/
|
||
public function clear()
|
||
{
|
||
$this->paths = Session::instance()->get('paths');
|
||
$this->set_path (Session::instance()->get('last_path_id'));
|
||
if (isset($_GET['__url__']))
|
||
$this->path = url::base().Config::get('lang').'/'.urldecode($_GET['__url__']);
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Sets path to given id
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $path_id
|
||
* @return boolean
|
||
*/
|
||
public function set_path ($path_id = NULL)
|
||
{
|
||
if (isset($this->paths[$path_id]))
|
||
{
|
||
$this->path = $this->paths[$path_id];
|
||
$this->last();
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Returns URL of current position in object
|
||
*
|
||
* @author Michal Kliment
|
||
... | ... | |
* @param integer $length
|
||
* @return string
|
||
*/
|
||
public function current($offset = 0, $length = NULL)
|
||
public function previous($offset = 0, $length = NULL)
|
||
{
|
||
// returns only uri
|
||
if ($this->uri)
|
||
{
|
||
$path = url::uri($this->path[$this->id]);
|
||
$path = url::uri($this->path);
|
||
|
||
// returns without lang
|
||
if (!$this->lang)
|
||
$offset++;
|
||
}
|
||
else
|
||
$path = $this->path[$this->id];
|
||
$path = $this->path;
|
||
|
||
// returns rest of string
|
||
if (!$length)
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Goes to previous position
|
||
*
|
||
* @author Michal Kliment
|
||
* @return Path object
|
||
*/
|
||
public function previous()
|
||
{
|
||
if ($this->id > 0)
|
||
{
|
||
$this->id--;
|
||
}
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Goes to next position
|
||
*
|
||
* @author Michal Kliment
|
||
* @return Path object
|
||
*/
|
||
public function next()
|
||
{
|
||
if ($this->id < (count($this->path)-1))
|
||
{
|
||
$this->id++;
|
||
}
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Goes to first position
|
||
*
|
||
* @author Michal Kliment
|
||
* @return Path object
|
||
*/
|
||
public function first()
|
||
{
|
||
$this->id = 0;
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Goes to last position
|
||
*
|
||
* @author Michal Kliment
|
||
* @return Path object
|
||
*/
|
||
public function last()
|
||
{
|
||
$this->id = count($this->path)-1;
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Sets boolean values for URI and lang
|
||
*
|
||
* @author Michal Kliment
|
freenetis/branches/testing/application/libraries/Forge.php | ||
---|---|---|
$action = url_lang::base() . $action;
|
||
}
|
||
|
||
if (isset($_GET['__url__']))
|
||
{
|
||
$action = $action.'?__url__='.urldecode($_GET['__url__']);
|
||
}
|
||
|
||
// Set form attributes
|
||
$this->attr['action'] = $action;
|
||
$this->attr['method'] = empty($method) ? 'post' : $method;
|
freenetis/branches/testing/application/libraries/MY_Controller.php | ||
---|---|---|
}
|
||
}
|
||
|
||
// updates paths
|
||
$this->update_paths();
|
||
}
|
||
|
||
/**
|
||
* Function to update paths
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
private function update_paths()
|
||
{
|
||
if (!is_array($this->session->get('paths')))
|
||
$this->session->set('paths', array());
|
||
|
||
$paths = $this->session->get('paths');
|
||
|
||
if (url_lang::current(TRUE) != 'login' &&
|
||
url_lang::current(TRUE) != 'json' &&
|
||
url_lang::current(TRUE) != 'js')
|
||
{
|
||
if (isset($paths[$this->session->get('last_path_id')]))
|
||
{
|
||
$path = $paths[$this->session->get('last_path_id')];
|
||
|
||
if ($path[count($path) - 1] != url::base(TRUE) . url::current())
|
||
{
|
||
if (url::base() . url::previous() != $path[count($path) - 1])
|
||
{
|
||
foreach ($paths as $id => $path)
|
||
{
|
||
if (isset($path[count($path) - 1]) &&
|
||
url::base() . url::previous() == $path[count($path) - 1])
|
||
{
|
||
$this->session->set('last_path_id', $id);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
$path = NULL;
|
||
foreach ($paths[$this->session->get('last_path_id')] as $i => $url)
|
||
{
|
||
if (url::base(TRUE) . url::current() == $url)
|
||
{
|
||
$path = array_slice($paths[$this->session->get('last_path_id')], 0, $i + 1);
|
||
break;
|
||
}
|
||
}
|
||
if (!$path)
|
||
$paths[$this->session->get('last_path_id')][] = url::base(TRUE) . url::current();
|
||
else
|
||
$paths[$this->session->get('last_path_id')] = $path;
|
||
}
|
||
}
|
||
else
|
||
$paths[$this->session->get('last_path_id')][] = url::base(TRUE) . url::current();
|
||
}
|
||
|
||
$this->session->set('paths', $paths);
|
||
}
|
||
|
||
/**
|
||
* Return URL for controller and method
|
freenetis/branches/testing/application/views/js/base.php | ||
---|---|---|
|
||
return false;
|
||
});
|
||
|
||
// sends change of path to session
|
||
if (history.length == 1 && document.referrer != "")
|
||
{
|
||
$.post("<?php echo url_lang::base() ?>json/update_paths/", {
|
||
url: "<?php echo url::base(TRUE) . url::current() ?>"
|
||
});
|
||
}
|
||
// sends change of path to session
|
||
if ((history.length == 1 || history.length == 2) && document.referrer == "")
|
||
{
|
||
$.post("<?php echo url_lang::base() ?>json/insert_path/");
|
||
}
|
||
|
||
/* AJAX fulltext search */
|
||
|
freenetis/branches/testing/system/libraries/Router.php | ||
---|---|---|
}
|
||
}
|
||
}
|
||
elseif (count($_GET) === 1 AND current($_GET) == '' AND substr($_SERVER['QUERY_STRING'], -1) !== '=')
|
||
{
|
||
// The URI is the array key, eg: ?this/is/the/uri
|
||
self::$current_uri = key($_GET);
|
||
|
||
// Fixes really strange handling of a suffix in a GET string
|
||
if ($suffix = Config::get('core.url_suffix') AND substr(self::$current_uri, -(strlen($suffix))) === '_'.substr($suffix, 1))
|
||
{
|
||
self::$current_uri = substr(self::$current_uri, 0, -(strlen($suffix)));
|
||
}
|
||
|
||
// Destroy GET
|
||
$_GET = array();
|
||
$_SERVER['QUERY_STRING'] = '';
|
||
}
|
||
elseif (isset($_SERVER['PATH_INFO']) AND $_SERVER['PATH_INFO'])
|
||
{
|
||
self::$current_uri = $_SERVER['PATH_INFO'];
|
Také k dispozici: Unified diff
Opravy:
- #138: Cesty se neukladaji v session, ale predavaji se pomoci GET v adrese
- #187: Chyba nakonec nebyla v mod_rewrite, ale v Kohane...opraveno