4 * Return all page actions
10 function page_actions() {
11 return PageActions
::instance()->getActions();
15 * Add single page action
17 * You can use set of two params where first param is title and second one
18 * is URL (the default set) and you can use array of actions as first
19 * parram mapped like $title => $url
22 * @param string $title
26 function add_page_action() {
28 $args = func_get_args();
29 if(!is_array($args) ||
!count($args)) return;
31 // Array of data as first param mapped like $title => $url
32 if(is_array(array_var($args, 0))) {
34 foreach(array_var($args, 0) as $title => $url) {
35 if(!empty($title) && !empty($url)) {
36 PageActions
::instance()->addAction( new PageAction($title, $url) );
40 // Two string params, title and URL
43 $title = array_var($args, 0);
44 $url = array_var($args, 1);
46 if(!empty($title) && !empty($url)) {
47 PageActions
::instance()->addAction( new PageAction($title, $url) );
58 * @http://www.projectpier.org/
77 * Construct the PageAction
83 function __construct($title, $url) {
84 $this->setTitle($title);
88 // ---------------------------------------------------
89 // Getters and setters
90 // ---------------------------------------------------
107 * @param string $value
110 function setTitle($value) {
111 $this->title
= $value;
129 * @param string $value
132 function setURL($value) {
139 * Page actions container that can be accessed globaly
142 * @http://www.projectpier.org/
147 * Array of PageAction objects
151 private $actions = array();
154 * Return all actions that are in this container
160 function getActions() {
161 return count($this->actions
) ?
$this->actions
: null;
168 * @param PageAction $action
171 function addAction(PageAction
$action) {
172 $this->actions
[] = $action;
177 * Return single PageActions instance
181 * @return PageActions
183 function instance() {
187 if(!($instance instanceof PageActions
)) {
188 $instance = new PageActions();