This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
/
Url.php
144 lines (122 loc) · 3.03 KB
/
Url.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Clip
*
* @copyright (c) Clip Team
* @link http://github.com/zikula-modules/clip/
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Clip
* @subpackage Lib
*/
namespace Matheo\Clip;
use ZLanguage;
use DataUtil;
use ModUtil;
class Url extends \Zikula_ModUrl
{
protected $application;
protected $controller;
protected $action;
protected $args;
protected $language;
protected $fragment;
public function __construct(
$module,
$type,
$func,
$args = array(),
$language = null,
$fragment = null
) {
$this->application = $module;
$this->controller = $type;
$this->action = $func;
$this->args = $args;
$this->language = $language ? $language : ZLanguage::getLanguageCode();
$this->fragment = $fragment;
}
public function __toString()
{
return DataUtil::formatForDisplay($this->getUrl());
}
public function getUrl(
$ssl = null,
$fqurl = null,
$forcelongurl = false,
$forcelang = false
) {
return ModUtil::url($this->application, $this->controller, $this->action, $this->args, $ssl, $this->fragment, $fqurl, $forcelongurl, $forcelang);
}
public function modFunc()
{
return ModUtil::func($this->application, $this->controller, $this->action, $this->args);
}
public function clipArray()
{
return array('module' => $this->application, 'type' => $this->controller, 'func' => $this->action, 'args' => $this->args, 'language' => $this->language, 'fragment' => $this->fragment);
}
public function serialize()
{
return serialize($this->toArray());
}
// getters
public function getApplication()
{
return $this->application;
}
public function getController()
{
return $this->controller;
}
public function getAction()
{
return $this->action;
}
public function getArgs()
{
return $this->args;
}
public function getArg($name)
{
return isset($this->args[$name]) ? $this->args[$name] : null;
}
public function getLanguage()
{
return $this->language;
}
public function getFragment()
{
return $this->fragment;
}
// setters
public function setApplication($module)
{
$this->application = $module;
return $this;
}
public function setController($type)
{
$this->controller = $type;
return $this;
}
public function setAction($func)
{
$this->action = $func;
return $this;
}
public function setArgs($args)
{
$this->args = $args;
return $this;
}
public function setLanguage($lang)
{
$this->language = $lang;
return $this;
}
public function setFragment($fragment)
{
$this->fragment = $fragment;
return $this;
}
}