Object Node presents the main data object of Smereka CMS the node. It provides basic methods of processing nodes and acts as protoclass for other more specialized classes of nodes.
protected $Attrs associative array of attributes, independent of language.
protected $AttrsL associative array of attributes that are dependent on language.
protected $Id; store the node id.
protected $LangVer array of language versions of the node, for example array('uk', 'en').
public $LastAccess store time when object was last accessed. Used only by the objects buffer to implement the algorithm LRU.
public function __construct($NodeID)
Very simple constructor. Store passed as parameter $NodeID id and loads static attributes by LoadStaticAttrs() method.
public function AncestorList($StopClass = 0, $IncludeStopNode = False, $FromRoot = False)
Returns an array of nodes (objects Node) from the current to the last forefather. If $StopClass = 0, the last forefather id the root node of hierarchy, and if $StopClass set, the last forefather considered the first of the forefathers of given class(a typical example search for the domain root node, which owns the current node).
Parameter $IncludeStopNode determines whether to include to the list the latest forefather (True), or not to include it (False).
Parameter $FromRoot determine whether the array is built from the root node to the current (True), or from the current to the root (False).
public function AncestorListEx($MatchFunc, $MatchArg, $IncludeStopNode = False, $FromRoot = False, &$Result)
Generalization of the functions AncestorList. Last forefathers node is determined by calculating a given function $MatchFunc which has the prototype:
Here $TestNode node which should be checked; $MatchArg additional optional parameter that is passed during an AncestorListEx function call.
Function $MatchFunc should return True, if the search should continue or False, if this node is a last forefathers node, which we are looking for.
Performance of parameters $IncludeStopNode, $FromRoot is the same as for function AncestorList.
Variable $Result after a call can take values: Matched if the process stopped at the node, which match the search criteria; Root if the corresponding node is not found and the process stopped at the root node; Cycle if the list of nodes-forefathers contain cyclic references (accident!).
public function DocTitle($Lang = NULL)
Returns a string that serves as the title of the document(not to be confused with the function WinTitle that returns the title of the window). Title calculated for the language version, explicitly given by $Lang parameter or for the current language version, if this parameter is not set.
Basic implementation of the method is very simple: it sequentially checks for attributes DocTitle, Title, symbname for a given language version and returns the first value, which is not empty. Since attribute symbname is language-independent and required, method in the worst case return it (not empty string).
This method is often overrided in derivated classes (for example, when document title is formed from other attributes).
public function ExternalURL($Mode = NULL, $Lng = NULL, $Query = NULL)
This important and frequently used function generates an URL for a given node. Parameter $Mode can be one of the following:
ById the address generated identifies the node by using the Node=[id] parameter, used mainly in edit mode;
ByPath the address generated identifies the node by using the Path=[symbolic-path] parameter; rarely used;
Virtual the address generated identifies the node using the full path from the site root, including, if necessary, language version, for example http://www.example.com/en/a/b/c.html. If required by specific language version, the function in this mode always generates the appropriate URL, regardless of whether this language version of node exists.
VirtLang like Virtual mode, but if certain language version required, the function in this mode verifies the presence the desired language version in the node. If this version is not exists, the function tries to find the closest one among existing language versions. For example, if required the Russian version of the page (which is not exist), then it will attempt to find a Ukrainian, and more English language version (see function SelectNearestLang).
Parameter $Lng specifies the desired language version, if not specified, uses the current language.
Parameter $Query define string that should be appended to the URL, such as $Query='Skip=30'.
public function GetAttr($AttrName, $Lang = NULL)
The function returns the attribute specified by $AttrName name for the language version, defined by $Lang parameter (or for the current language, if the parameter is not specified). Function should be used if it is not known whether $AttrName language-dependent or not. If this is known, better to use more efficient function GetAttrLA / GetAttrLN. All three functions return the default value if an attribute with that name exists.
public function GetAttrLA($AttrName, $Lang)
The function returns the language-dependent attribute specified by $AttrName name for the language version, defined by $Lang parameter (or for the current language, if the parameter is not specified).
public function GetAttrLN($AttrName)
The function returns the language-independent attribute specified by $AttrName name.
public function GetDefaultAttr($AttrName, $Lang = NULL)
The function returns the default value for the attribute specified by $AttrName name for the language version, defined by $Lang parameter (or for the current language, if the option is not specified). To provide some default values for certain attributes, you should override this method in the class.
public function GetDomName($Subst = True)
The function returns the domain name, which owns the node. If the node is not in a domain, then if $Subst = True it returns the current domain name, with $Subst = False it returns False.
public function GetDomNode()
The function returns the domain root node, which owns the node, or False, if the node does not belong to the domain.
public function GetIcon()
In Node class the function returns an empty string; the NodeDef class override it and returns the URL of the class icon. This icon used in editor to visualize the node class.
public function GetId()
Returns the node id.
public function GetMetaData()
Returns the meta object for a given node (typically is the metaclass object).
public function GetParentNode()
Returns the parent node object or False, if this node has no ancestor.
public function LangVerDefined($Reset = False)
Returns array of available language versions of the node (see $LangVer field). If the parameter $Reset = True, buffered array of language versions discarded and is calculated from scratch.
public function LangVerExist($Lang)
Checks if the node have a given language version, and returns the appropriate boolean.
protected function LoadStaticAttrs()
Downloads static node attributes stored in table nodes.
public function Reset()
Discard all attributes loaded into memory and reloads static attributes from the database.
public function ResetLinks()
Cancels buffered in memory ids of other objects associated with this node.
public function SelectNearestLang($Lng = NULL)
The function returns the requested language version (if present), or choose language version, most similar to the required (if the latter is absent).
public function SelfLink($Mode = NULL, $Attrs = NULL)
Returns the HTML code of the link to the node, using the function DocTitle() as link text. Parameter $Mode sets the mode of URL (as in the function ExternalURL); parameter $Attrs specifies the string that should be attached to a tag a, for example $Attrs='class="LinkClass"'.
public function SetMetaData($Value)
Sets the meta information for this object.
public function Sibling($Pos, $User = NULL)
Returns object of equal hierarchical position (its id defined by SiblingId function).
public function SiblingId($Pos, $User = NULL)
Returns object id for the sibling of this object. Parameter (string) $Pos may be one of the following: prev, next, first, last. Parameter $User typically means the current user if it is given. If $User not set, only nodes with public access level are searched. The function returns False, if the appropriate object does not exists.
public function WinTitle($Lang = NULL)
Returns a string that serves as the window title (not to be confused with the function DocTitle that returns the title of the document). Title calculated for the language version, explicitly given by $Lang parameter or for the current language version, if this parameter is not set.
Basic implementation of the method is very simple: it sequentially checks for attributes Title, symbname for a given language version and returns the first value, which is not empty. Since attribute symbname is language-independent and required, method in the worst case return it (not empty string).
This method is often overrided in derivated classed (for example, when window title is formed from other attributes).
Previous section | Table of content | Next section