Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezpathelement.php
Go to the documentation of this file.
1 <?php
22 class eZPathElement extends eZPersistentObject
23 {
24 public $Path;
25 public $PathArray;
26 public $LangMask;
27 public $Action;
28 public $Text;
29 public $Parent;
30 public $TextMD5;
31 public $ActionType;
32 public $Link;
33 public $IsAlias;
34 public $IsOriginal;
35 public $AliasRedirects;
36
37 public function __construct( $row )
38 {
39 $this->Path = null;
40 $this->PathArray = null;
41 if ( array_key_exists( 'always_available', $row ) )
42 {
43 $this->AlwaysAvailable = $row['always_available'];
44 }
45 parent::__construct( $row );
46 }
47
48 static public function definition()
49 {
50 static $definition = array( "fields" => array( "id" => array( 'name' => 'ID',
51 'datatype' => 'integer',
52 'default' => 0,
53 'required' => true ),
54 "parent" => array( 'name' => 'Parent',
55 'datatype' => 'integer',
56 'default' => 0,
57 'required' => true ),
58 "lang_mask" => array( 'name' => 'LangMask',
59 'datatype' => 'integer',
60 'default' => 0,
61 'required' => true ),
62 "text" => array( 'name' => 'Text',
63 'datatype' => 'string',
64 'default' => '',
65 'required' => true ),
66 "text_md5" => array( 'name' => 'TextMD5',
67 'datatype' => 'string',
68 'default' => '',
69 'required' => true ),
70 "action" => array( 'name' => 'Action',
71 'datatype' => 'string',
72 'default' => '',
73 'required' => true ),
74 "action_type" => array( 'name' => 'ActionType',
75 'datatype' => 'string',
76 'default' => '',
77 'required' => true ),
78 "link" => array( 'name' => 'Link',
79 'datatype' => 'integer',
80 'default' => 0,
81 'required' => true ),
82 "is_alias" => array( 'name' => 'IsAlias',
83 'datatype' => 'integer',
84 'default' => 0,
85 'required' => true ),
86 "is_original" => array( 'name' => 'IsOriginal',
87 'datatype' => 'integer',
88 'default' => 0,
89 'required' => true ),
90 "alias_redirects" => array( 'name' => 'AliasRedirects',
91 'datatype' => 'integer',
92 'default' => 1,
93 'required' => true ) ),
94 "keys" => array( "parent", "text" ),
95 "function_attributes" => array( "language_object" => "getLanguage",
96 "action_url" => "actionURL",
97 "path" => "getPath",
98 "always_available" => "alwaysAvailable",
99 "path_array" => "getPathArray" ),
100 "class_name" => "eZURLAliasML",
101 "name" => "ezurlalias_ml" );
102 return $definition;
103 }
104
108 function store( $fieldFilters = null )
109 {
110 eZDebug::writeError( "Cannot store objects of eZPathElement, use eZURLAliasML instead" );
111 return;
112 }
113
117 function removeThis()
118 {
119 eZDebug::writeError( "Cannot remove objects of eZPathElement, use eZURLAliasML instead" );
120 return;
121 }
122
126 function getLanguage()
127 {
128 return eZContentLanguage::fetch( $this->LangMask );
129 }
130
135 function actionURL()
136 {
137 return eZURLAliasML::actionToUrl( $this->Action );
138 }
139
144 static public function fetchNamedByParentID( $parentID, $name )
145 {
146 $filter = new eZURLAliasQuery();
147 $filter->paren = $parentID;
148 $filter->text = $name;
149 $filter->limit = false;
150 return $filter->fetchAll();
151 }
152
159 function getPath()
160 {
161 if ( $this->Path !== null )
162 return $this->Path;
163
164 // Fetch path 'text' elements of correct parent path
165 $path = array( $this->Text );
166 $id = (int)$this->Parent;
167 $db = eZDB::instance();
168 while ( $id != 0 )
169 {
170 $query = "SELECT parent, lang_mask, text FROM ezurlalias_ml WHERE id={$id}";
171 $rows = $db->arrayQuery( $query );
172 if ( count( $rows ) == 0 )
173 {
174 break;
175 }
176 $result = eZURLAliasML::choosePrioritizedRow( $rows );
177 if ( !$result )
178 {
179 $result = $rows[0];
180 }
181 $id = (int)$result['parent'];
182 array_unshift( $path, $result['text'] );
183 }
184 $this->Path = implode( '/', $path );
185 return $this->Path;
186 }
187
188 function getPathArray()
189 {
190 if ( $this->PathArray !== null )
191 return $this->PathArray;
192
193 // Fetch path 'text' elements of correct parent path
194 $path = array( $this );
195 $id = (int)$this->Parent;
196 $db = eZDB::instance();
197 while ( $id != 0 )
198 {
199 $query = "SELECT * FROM ezurlalias_ml WHERE id={$id}";
200 $rows = $db->arrayQuery( $query );
201 if ( count( $rows ) == 0 )
202 {
203 break;
204 }
205 $result = eZURLAliasML::choosePrioritizedRow( $rows );
206 if ( !$result )
207 {
208 $result = $rows[0];
209 }
210 $id = (int)$result['parent'];
211 array_unshift( $path, new eZPathElement( $result ) );
212 }
213 $this->PathArray = $path;
214 return $this->PathArray;
215 }
216
217 // Calculates always_available attribute from language mask
218 function alwaysAvailable()
219 {
220 return $this->AlwaysAvailable;
221 }
222
223 public $AlwaysAvailable;
224 }
225
226 ?>
eZContentLanguage\fetch
static fetch( $id)
Definition: ezcontentlanguage.php:251
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZPathElement
Handles singular path elements in URL aliases.
Definition: ezpathelement.php:23
eZPathElement\getPath
getPath()
Definition: ezpathelement.php:159
eZPathElement\$AliasRedirects
$AliasRedirects
Definition: ezpathelement.php:35
eZPathElement\store
store( $fieldFilters=null)
Definition: ezpathelement.php:108
eZPathElement\$IsOriginal
$IsOriginal
Definition: ezpathelement.php:34
eZPathElement\$TextMD5
$TextMD5
Definition: ezpathelement.php:30
eZPathElement\$Parent
$Parent
Definition: ezpathelement.php:29
eZPathElement\fetchNamedByParentID
static fetchNamedByParentID( $parentID, $name)
Definition: ezpathelement.php:144
eZPathElement\$Path
$Path
Definition: ezpathelement.php:24
eZPathElement\$Text
$Text
Definition: ezpathelement.php:28
eZPathElement\$AlwaysAvailable
$AlwaysAvailable
Definition: ezpathelement.php:223
eZPathElement\getPathArray
getPathArray()
Definition: ezpathelement.php:188
eZPathElement\removeThis
removeThis()
Definition: ezpathelement.php:117
eZPathElement\$Action
$Action
Definition: ezpathelement.php:27
eZPathElement\$Link
$Link
Definition: ezpathelement.php:32
eZPathElement\alwaysAvailable
alwaysAvailable()
Definition: ezpathelement.php:218
eZPathElement\__construct
__construct( $row)
Definition: ezpathelement.php:37
eZPathElement\definition
static definition()
Definition: ezpathelement.php:48
eZPathElement\$PathArray
$PathArray
Definition: ezpathelement.php:25
eZPathElement\getLanguage
getLanguage()
Definition: ezpathelement.php:126
eZPathElement\actionURL
actionURL()
Definition: ezpathelement.php:135
eZPathElement\$IsAlias
$IsAlias
Definition: ezpathelement.php:33
eZPathElement\$ActionType
$ActionType
Definition: ezpathelement.php:31
eZPathElement\$LangMask
$LangMask
Definition: ezpathelement.php:26
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\count
static count( $def, $conds=null, $field=null)
Definition: ezpersistentobject.php:187
eZURLAliasML\choosePrioritizedRow
static choosePrioritizedRow( $rows)
Definition: ezurlaliasml.php:2003
eZURLAliasML\actionToUrl
static actionToUrl( $action)
Definition: ezurlaliasml.php:2111
eZURLAliasQuery
Handles querying of URL aliases with different filters.
Definition: ezurlaliasquery.php:34
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.