aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Library/Helper')
-rwxr-xr-xh-source/Library/Helper/Array.php2
-rwxr-xr-xh-source/Library/Helper/Html.php2
-rwxr-xr-xh-source/Library/Helper/List.php288
-rwxr-xr-xh-source/Library/Helper/Menu.php40
-rwxr-xr-xh-source/Library/Helper/Pages.php15
-rwxr-xr-xh-source/Library/Helper/Popup.php46
6 files changed, 72 insertions, 321 deletions
diff --git a/h-source/Library/Helper/Array.php b/h-source/Library/Helper/Array.php
index dbdda4f..329463f 100755
--- a/h-source/Library/Helper/Array.php
+++ b/h-source/Library/Helper/Array.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Helper/Html.php b/h-source/Library/Helper/Html.php
index 9e25bb4..81a9bdd 100755
--- a/h-source/Library/Helper/Html.php
+++ b/h-source/Library/Helper/Html.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php
index 81b5345..ba59643 100755
--- a/h-source/Library/Helper/List.php
+++ b/h-source/Library/Helper/List.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,9 +25,6 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to create the HTML of a list of records
class Helper_List extends Helper_Html {
- //table attributes
- static public $tableAttributes = array('class'=>'listTable','cellspacing'=>'0');
-
private $__rowArray = array(); //the current associative array representing the database record
protected $_itemsList = array(); //2-dimensional associative array containing the list items
@@ -37,7 +34,7 @@ class Helper_List extends Helper_Html {
protected $_recordNumber = null; //number of records from the table
- protected $_allowedItems = array('simpleLink','simpleText','delForm','editForm','associateForm','moveupForm','movedownForm','Form','ledit','link','text','checkbox','input'); //type of items allowed
+ protected $_allowedItems = array('simpleLink','simpleText','delForm','editForm','associateForm','moveupForm','movedownForm','Form','ledit','link','text'); //type of items allowed
//it can be: both, top, bottom, none
protected $_boundaries = 'none';
@@ -45,12 +42,6 @@ class Helper_List extends Helper_Html {
//array of filters
protected $_filters = array();
- //array of bulk actions
- protected $_bulkActions = array();
-
- //set to false if you don't want that the filters are created inside the table
- public $showFilters = true;
-
//set if the submit buttons have to be images or not (it can be yse or not)
public $submitImageType = 'yes';
@@ -63,6 +54,9 @@ class Helper_List extends Helper_Html {
//properties of columns
public $colProperties = array();
+ //table attributes
+ public $tableAttributes = array('class'=>'listTable','cellspacing'=>'0');
+
//$position: array. First element: page number, second element: number of pages
public $position = array();
@@ -74,15 +68,12 @@ class Helper_List extends Helper_Html {
public $pageArg = null; //the key of the viewArgs array representing the page number. $this->viewArgs[$this->pageArg] is set to 1 if $this->pageArg !== null
- //if the filter forms have to be aggregated in a unique form or if they have to be left separated
- public $aggregateFilters = false;
-
public function __construct() {
//get the generic language class
$this->strings = Factory_Strings::generic(Params::$language);
- $baseUrl = Url::getRoot().'Public/Img/Icons/elementary_2_5/';
+ $baseUrl = 'http://'.DOMAIN_NAME.'/Public/Img/Icons/elementary_2_5/';
//set the files of the images
$this->submitImages = array(
@@ -156,39 +147,17 @@ class Helper_List extends Helper_Html {
//set the filters
//$filters: array whose elements are the viewArgs to be used for the filters forms
- //or null
public function setFilters($filters)
{
$this->_filters = $filters;
}
-
- //set $this->aggregateFilters equal to true
- public function aggregateFilters()
- {
- $this->aggregateFilters = true;
- }
-
- //set the bulk actions
- //$bulkActions: associative array.
- //key: class of the inputs whose elements have to be selected and serialized by javascript in the following way: data-primary-key:value_attribute|data-primary-key:value_attribute|data-primary-key:value_attribute|...
- //value: array with two elements whose first element is the bulk action to be sent as a key of $_POST, second element is the human readable name of the action, third element can be the string "confirm" (if the user has to confirm the action) or undefined
- //example:
- // $bulkActions = array(
- // "input_category_id_order" => array("sortAction","Sort elements"),
- // "checkbox_category_id" => array("deleteAction","Delete elements","confirm"),
- // );
- public function setBulkActions($bulkActions)
- {
- $this->_bulkActions = $bulkActions;
- }
//check that the ViewArgs array is complete
public function checkViewArgs()
{
foreach ($this->_filters as $field)
{
- $key = !is_array($field) ? $field : $field[0];
- if (!array_key_exists($key,$this->viewArgs) and strcmp($key,null) !== 0) return false;
+ if (!array_key_exists($field,$this->viewArgs) and strcmp($field,null) !== 0) return false;
}
return true;
}
@@ -203,48 +172,47 @@ class Helper_List extends Helper_Html {
public function replaceFields($string,$rowArray) {
$this->__rowArray = $rowArray; //used by the replaceField method
- $string = preg_replace_callback('/(\;)(.*?)(\;)/', array($this, 'replaceField') ,$string);
+ $string = preg_replace_callback('/(\;)(.*?)(\;)/', 'Helper_List::replaceField' ,$string);
return $string;
}
- //get : or . as char used to separate table and field
- public function getChar($string)
- {
- return strstr($string,':') ? ':' : '.';
- }
-
//replace a single string wrapped by ; with its correspondent value taken by the $recordArray associative array (a row of the select query)
public function replaceField($match)
{
$string = $match[2];
- //check if a function has been indicated
- if (strstr($string,'|'))
- {
- //get the function
- $firstArray = explode('|',$string);
- if (strstr($firstArray[1],':') or strstr($firstArray[1],'.'))
+ if (strstr($string,':') or strstr($string,'.')) {
+ if (strstr($string,':'))
+ {
+ $char = ':';
+ }
+ else
{
+ $char = '.';
+ }
+ //check if a function has been indicated
+ if (strstr($string,'|'))
+ {
+ //get the function
+ $firstArray = explode('|',$string);
$func = $firstArray[0];
//replace the fields
- $char = $this->getChar($firstArray[1]);
$temp = explode($char,$firstArray[1]);
$string = $this->__rowArray[$temp[0]][$temp[1]];
- $string = callFunction($func,$string,__METHOD__);
+ if (!function_exists($func)) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$func.'</b> does not exists..');
+ }
+ //apply the function
+ $string = call_user_func($func,$string);
}
- }
- else
- {
- if (strstr($string,':') or strstr($string,'.'))
+ else
{
- $char = $this->getChar($string);
$temp = explode($char,$string);
$string = $this->__rowArray[$temp[0]][$temp[1]];
}
}
-
return $string;
}
@@ -259,8 +227,8 @@ class Helper_List extends Helper_Html {
}
//wrap the column with the tag td
- public function wrapColumn($string, $className = null, $tag = "td") {
- return wrap($string,array($tag=>$className));
+ public function wrapColumn($string, $className = null) {
+ return wrap($string,array('td'=>$className));
}
//wrap the row with the tag tr
@@ -269,7 +237,7 @@ class Helper_List extends Helper_Html {
}
public function wrapList($string) {
- return wrap($string,array('table'=>self::$tableAttributes));
+ return wrap($string,array('table'=>$this->tableAttributes));
}
//method to create the HTML of the head of the table
@@ -280,18 +248,13 @@ class Helper_List extends Helper_Html {
foreach ($this->_head as $item) {
$temp = $item['action'];
- if (preg_match('/\[\[bulkselect:(.*?)\]\]/',$temp,$matches))
- {
- $temp = Html_Form::checkbox("bulkselect_".$matches[1],"","BS","bulk_select_checkbox",null,"data-class='".$matches[1]."'");
- }
-
$prop = $item['type'];
if (isset($this->colProperties[$count]))
{
$prop = $this->colProperties[$count];
}
- $htmlHead .= $this->wrapColumn($temp, $prop, "th");
+ $htmlHead .= $this->wrapColumn($temp,$prop);
$count++;
}
@@ -299,27 +262,7 @@ class Helper_List extends Helper_Html {
return $htmlHead;
}
- //return an array with all the filters in a 1-dimensional array
- public function getFiltersList()
- {
- $filterList = array();
-
- foreach ($this->_filters as $f)
- {
- if (is_array($f))
- {
- $filterList[] = $f[0];
- }
- else
- {
- $filterList[] = $f;
- }
- }
-
- return $filterList;
- }
-
- //method to create the HTML of the filters input
+ //method to create the HTML of the head of the table
public function createFilters() {
$htmlFilters = null;
@@ -339,91 +282,18 @@ class Helper_List extends Helper_Html {
$html = '&nbsp';
if (isset($this->_filters[$count]))
{
- if (!is_array($this->_filters[$count]))
- {
- $html = $this->filterForm($this->_filters[$count]);
- }
- else
- {
- $html = call_user_func_array(array($this,"filterForm"),$this->_filters[$count]);
-// $html = $this->filterForm($this->_filters[$count][0],$this->_filters[$count][1]);
- }
- }
-
- //wrap single cell if filters doesn't have to be aggregate
- if (!$this->aggregateFilters)
- {
- $htmlFilters .= !$this->showFilters ? $html : $this->wrapColumn($html,$prop);
+ $html = $this->filterForm($this->_filters[$count]);
}
- else
- {
- $htmlFilters .= $html;
- }
-
+ $htmlFilters .= $this->wrapColumn($html,$prop);
+
$count++;
}
-
- //wrap an aggregate cell if filters have to be aggregate
- if ($this->aggregateFilters)
- {
- $colspan = count($this->_itemsList);
- $formTop = "<form class='list_filter_form' action='".Url::getRoot($this->url)."' method='GET'>\n";
- $imgSrc = Url::getRoot('Public/Img/Icons/elementary_2_5/find.png');
-
- $formBottom = "";
- $emptyFilterStatusArray = array();
- $filtersList = $this->getFiltersList();
- foreach ($this->viewArgs as $k => $v)
- {
- if (!in_array($k,$filtersList))
- {
- $emptyFilterStatusArray[] = "$k=$v";
- $formBottom .= "<input type='hidden' name='".$k."' value='$v' />";
- }
- }
- $emptyFilterStatus = implode("&",$emptyFilterStatusArray);
-
- $formBottom .= "<a class='list_filter_clear_link' title='".$this->strings->gtext('clear the filter')."' href='".Url::getRoot($this->url)."?".$emptyFilterStatus."'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
-
- $formBottom .= "<input class='list_filter_submit' type='image' title='".$this->strings->gtext('filter')."' src='".$imgSrc."' value='trova'>\n";
-
- $formBottom .= "</form>";
-
- $htmlFilters = !$this->showFilters ? $formTop.$htmlFilters.$formBottom : $this->wrapColumn($formTop.$htmlFilters.$formBottom,array("class"=>"aggregate_filters_td","colspan"=>$colspan));
-
- }
}
}
return $htmlFilters;
}
- //create the HTML of the select of the bulk actions
- public function createBulkActionsSelect()
- {
- $htmlBulkSelect = null;
- $colspan = count($this->_itemsList);
-
- if (count($this->_bulkActions) > 0)
- {
- $htmlBulkSelect .= "<span class='bulk_actions_select_label'>".$this->strings->gtext('Actions')."</span>: <select data-url='".Url::getRoot(null).$this->url.$this->viewStatus."' class='bulk_actions_select' name='bulk_select'>";
-
- $htmlBulkSelect .= "<option data-class='0' value='0'>".$this->strings->gtext('-- Select bulk action --')."</option>";
-
- foreach ($this->_bulkActions as $class => $action)
- {
- $class = str_replace("+","",$class);
- $confirm = isset($action[2]) ? "data-confirm='Y'" : "data-confirm='N'";
- $htmlBulkSelect .= "<option $confirm data-class='$class' value='".$action[0]."'>".$action[1]."</option>";
- }
-
- $htmlBulkSelect .= "</select>";
- $htmlBulkSelect = $this->wrapColumn($htmlBulkSelect,array("class"=>"bulk_actions_td","colspan"=>$colspan));
- }
-
- return $htmlBulkSelect;
- }
-
//create the HTML of a single row (values taken from the associative array $rowArray)
public function getRowList($rowArray) {
$htmlList = null;
@@ -482,32 +352,16 @@ class Helper_List extends Helper_Html {
$this->_recordNumber = count($queryResult);
$htmlList = null;
//create the HTML of the head of the record list
- $htmlList .= "<thead>\n".$this->wrapRow($this->createHead(),'listHead')."</thead>\n";
+ $htmlList .= $this->wrapRow($this->createHead(),'listHead');
//create the HTML of the filters
- $htmlList .= "<tbody>\n";
-
- $bulkActionsHtml = $this->createBulkActionsSelect();
- if (isset($bulkActionsHtml))
- {
- $htmlList .= $this->wrapRow($bulkActionsHtml,'bulk_actions_tr');
- }
-
- if ($this->showFilters)
- {
- $filtersHtml = $this->createFilters();
- if (isset($filtersHtml))
- {
- $htmlList .= $this->wrapRow($filtersHtml,'listFilters');
- }
- }
-
+ $htmlList .= $this->wrapRow($this->createFilters(),'listFilters');
for ($i = 0; $i < count($queryResult); $i++)
{
$this->ifInBoundaries($i);
$temp = $this->getRowList($queryResult[$i]);
$htmlList .= $this->wrapRow($temp,'listRow');
}
- return $this->wrapList($htmlList."</tbody>\n");
+ return $this->wrapList($htmlList);
}
public function generalForm($itemArray, $submitName, $submitValue)
@@ -604,20 +458,8 @@ class Helper_List extends Helper_Html {
return $string;
}
- //create the HTML of a checkbox
- public function checkbox($itemArray)
- {
- return Html_Form::checkbox($itemArray['action'],$itemArray['field'],$itemArray['name'],"checkbox_".encode($itemArray['action']),null,"data-primary-key='".$itemArray['value']."'");
- }
-
- //create the HTML of an input text
- public function input($itemArray)
- {
- return Html_Form::input($itemArray['action'],$itemArray['field'],"input_".encode($itemArray['action']),null,"data-primary-key='".$itemArray['name']."'");
- }
-
//create the HTML of the filter
- public function filterForm($viewArgsName, $filterString = null, $filterValues = null)
+ public function filterForm($viewArgsName)
{
$cleanName = str_replace('n!',null,$viewArgsName);
$cleanName = str_replace('-',null,$cleanName);
@@ -632,15 +474,8 @@ class Helper_List extends Helper_Html {
if (Params::$nullQueryValue)
{
$this->viewArgs[$viewArgsName] = Params::$nullQueryValue;
- $viewStatus = Url::createUrl($this->viewArgs);
- if (strcmp($value,Params::$nullQueryValue) === 0 and !isset($filterValues))
- {
- $value = '';
- }
- }
- else
- {
- $viewStatus = $this->viewStatus;
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
+ if (strcmp($value,Params::$nullQueryValue) === 0) $value = '';
}
$this->viewArgs[$viewArgsName] = $temp;
@@ -649,42 +484,11 @@ class Helper_List extends Helper_Html {
$title = $this->strings->gtext('filter');
$clearLinkTitle = $this->strings->gtext('clear the filter');
- $html = null;
-
- if (!$this->aggregateFilters)
- {
- $html .= "<form class='list_filter_form list_filter_form_$cleanName' action='".$action."' method='GET'>\n";
- }
-
- $html .= isset($filterString) ? " <span class='list_filter_span list_filter_span_$cleanName'>".$filterString."</span> " : null;
-
- if (!isset($filterValues))
- {
- $html .= "<input class='list_filter_input list_filter_input_$cleanName' type='text' name='$viewArgsName' value='".$value."'>";
- }
- else
- {
- $filterValues = array_merge(array(Params::$nullQueryValue => $this->strings->gtext('All')),$filterValues);
- $html .= Html_Form::select($viewArgsName,$value,$filterValues,"list_filter_input list_filter_input_$cleanName",null,"yes");
- }
-
- if (!$this->aggregateFilters)
- {
- $html .= "<a class='list_filter_clear_link list_filter_clear_link_$cleanName' title='$clearLinkTitle' href='$action'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
- $html .= "<input class='list_filter_submit list_filter_submit_$cleanName' type='image' title='$title' src='".$imgSrc."' value='trova'>\n";
-
- if (!Params::$rewriteStatusVariables)
- {
- foreach ($this->viewArgs as $k => $v)
- {
- if (strcmp($k,"$viewArgsName") !== 0)
- {
- $html .= "<input type='hidden' name='".$k."' value='$v' />";
- }
- }
- }
- $html .= "</form>\n";
- }
+ $html = "<form class='list_filter_form list_filter_form_$cleanName' action='".$action."' method='GET'>\n";
+ $html .= "<input class='list_filter_input list_filter_input_$cleanName' type='text' name='$viewArgsName' value='".$value."'>";
+ $html .= "<a class='list_filter_clear_link list_filter_clear_link_$cleanName' title='$clearLinkTitle' href='$action'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
+ $html .= "<input class='list_filter_submit list_filter_submit_$cleanName' type='image' title='$title' src='".$imgSrc."' value='trova'>\n";
+ $html .= "</form>\n";
return $html;
}
diff --git a/h-source/Library/Helper/Menu.php b/h-source/Library/Helper/Menu.php
index 4b33261..8fd4bf4 100755
--- a/h-source/Library/Helper/Menu.php
+++ b/h-source/Library/Helper/Menu.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,8 +25,7 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to write the top menĂ¹ of the view files
class Helper_Menu extends Helper_Html
{
- public static $htmlLinks = array();
-
+
public $panelController; //panel controller
public $controller;
@@ -50,7 +49,6 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Back'),
'url' => 'main',
'icon' => $baseUrl."left.png",
- 'queryString' => null,
),
'add' => array(
@@ -59,7 +57,6 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Add'),
'url' => 'form/insert',
'icon' => $baseUrl."add.png",
- 'queryString' => null,
),
'panel' => array(
@@ -68,25 +65,9 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Panel'),
'url' => 'main',
'icon' => $baseUrl."panel.png",
- 'queryString' => null,
)
);
-
- foreach (self::$htmlLinks as $k => $v)
- {
- if (!array_key_exists($k, $this->links))
- {
- $this->links[$k] = $v;
- }
- else
- {
- foreach ($v as $subK => $subV)
- {
- $this->links[$k][$subK] = $subV;
- }
- }
- }
}
public function build($controller = null, $panelController = null)
@@ -108,11 +89,8 @@ class Helper_Menu extends Helper_Html
//check that the text and the ure are defined
if (isset($this->links[$linkName]['text']) and isset($this->links[$linkName]['url']))
{
- $title = isset($this->links[$linkName]['title']) ? "title=\"".$this->links[$linkName]['title']."\"" : null;
-
+ $title = isset($this->links[$linkName]['title']) ? "title='".$this->links[$linkName]['title']."'" : null;
$class = isset($this->links[$linkName]['class']) ? "class='".$this->links[$linkName]['class']."'" : null;
- $class = isset(self::$htmlLinks[$linkName]["class"]) ? "class='".self::$htmlLinks[$linkName]["class"]."'" : $class;
-
$icon = isset($this->links[$linkName]['icon']) ? "<img class='top_menu_icon' src='".$this->links[$linkName]['icon']."'> " : null;
//choose the controller (current or panel)
@@ -120,18 +98,8 @@ class Helper_Menu extends Helper_Html
$viewStatus = (strcmp($linkName,'panel') === 0) ? null : $this->viewStatus;
$href = Url::getRoot($controller.$this->links[$linkName]['url'].$viewStatus);
-
- if (isset($this->links[$linkName]['queryString']))
- {
- $href .= $this->links[$linkName]['queryString'];
- }
-
$text = $this->links[$linkName]['text'];
- $htmlBefore = isset($this->links[$linkName]["htmlBefore"]) ? $this->links[$linkName]["htmlBefore"] : "<div $class>$icon ";
- $htmlAfter = isset($this->links[$linkName]["htmlAfter"]) ? $this->links[$linkName]["htmlAfter"] : "</div>";
- $attributes = isset($this->links[$linkName]["attributes"]) ? $this->links[$linkName]["attributes"] : null;
-
- $menu .= "$htmlBefore<a $title $attributes href='$href'>$text</a>$htmlAfter\n";
+ $menu .= "<div $class>$icon <a $title href='$href'>$text</a></div>\n";
}
}
}
diff --git a/h-source/Library/Helper/Pages.php b/h-source/Library/Helper/Pages.php
index 3826469..d8ac856 100755
--- a/h-source/Library/Helper/Pages.php
+++ b/h-source/Library/Helper/Pages.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -109,16 +109,9 @@ class Helper_Pages extends Helper_Html
public function html($pageNumber,$string = null) {
if (isset($string)) {
$strNumber = $string;
- if (strcmp($pageNumber,"1") === 0)
- {
- $strClass = "class='itemListPage previous_page'";
- }
- else
- {
- $strClass = "class='itemListPage next_page'";
- }
+ $strClass = "class='itemListPage'";
} else {
- if (strcmp($pageNumber,$this->_currentPage) === 0)
+ if ($pageNumber === $this->_currentPage)
{
$strNumber = $pageNumber;
$strClass = "class='currentPage'";
@@ -130,7 +123,7 @@ class Helper_Pages extends Helper_Html
}
}
$this->viewArgs[$this->_variableArg] = $pageNumber;
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$href= Url::getRoot(null) . $this->_urlViewAction .$viewStatus;
return $this->getATag($href,$strNumber,$strClass);
}
diff --git a/h-source/Library/Helper/Popup.php b/h-source/Library/Helper/Popup.php
index f3e6058..18bb00d 100755
--- a/h-source/Library/Helper/Popup.php
+++ b/h-source/Library/Helper/Popup.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,15 +25,6 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to create the popup menu
class Helper_Popup extends Helper_Html {
- //the HTML of the popup
- public static $popupHtml = array(
- "before_loop" => "",
- "top" => "<div class='row col-md-2 ext_menu_block ext_menu_block_[[field]]'><ul class='menuBlock'><li class='innerItem inner_item_[[field]]'>[[name]]<ul class='innerList'>\n",
- "middle" => "</ul>\n</li>\n</ul>\n",
- "bottom" => "</div>",
- "after_loop" => "",
- );
-
public $popupArray = array(); //array of popup objects (see popup.php)
public $url = null; //the url (controller/action) to link by means of the popup menĂ¹
// public $fieldArg = null; //the key of the viewArgs array to set to the field in the where clause
@@ -94,17 +85,9 @@ class Helper_Popup extends Helper_Html {
}
}
- public function replacePlaceholders($string, $field, $name)
- {
- $string = str_replace("[[field]]",$field,$string);
- $string = str_replace("[[name]]",$name,$string);
-
- return $string;
- }
-
//create the HTML of the popup
public function render() {
- $returnString = self::$popupHtml["before_loop"];
+ $returnString = null;
if ($this->checkViewArgs())
{
if (isset($this->viewArgs[$this->pageArg]))
@@ -121,12 +104,11 @@ class Helper_Popup extends Helper_Html {
$tempArg = $this->viewArgs[$field];
$this->legend[$field] = $tempArg;
- $returnString .= $this->replacePlaceholders(self::$popupHtml["top"],$field,$popup->name);
-
+ $returnString .= "<ul onMouseOver='DisplayTag(this,\"block\");' onMouseOut='DisplayTag(this,\"none\");' id='menuBlock'><li class='innerItem'>".$popup->name."<ul class='innerList'>\n";
for ($i = 0; $i < count($popup->itemsValue); $i++)
{
$this->viewArgs[$field] = $popup->itemsValue[$i];
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$returnString .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>".$popup->itemsName[$i]."</a></li>\n";
//set the legend
@@ -136,20 +118,24 @@ class Helper_Popup extends Helper_Html {
}
}
$this->viewArgs[$field] = Params::$nullQueryValue;
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$returnString .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>".$this->allString."</a></li>\n";
- $returnString .= self::$popupHtml["middle"];
+ $returnString .= "</ul>\n</li>\n</ul>\n";
$this->viewArgs[$field] = $tempArg;
-
- if ($this->printLegend)
+ }
+ if ($this->printLegend)
+ {
+ $returnString .= "<div class='popup_legend'>\n";
+ foreach ($this->popupArray as $field => $popup)
{
- $returnString .= "<div class='popup_legend_item popup_legend_item_$field'>".$this->legend[$field]."</div>";
+ $returnString .= "<div class='popup_legend_item'>".$this->legend[$field]."</div>";
}
-
- $returnString .= self::$popupHtml["bottom"];
+ $returnString .= "</div>\n";
+ }
+ if (count($this->popupArray)>0) {
+ $returnString .= "<script type=\"text/javascript\" src=\"http://".DOMAIN_NAME."/Public/Js/DisplayTag.js\"></script>\n";
}
}
- $returnString .= self::$popupHtml["after_loop"];
return $returnString;
}