diff options
Diffstat (limited to 'h-source')
31 files changed, 145 insertions, 76 deletions
diff --git a/h-source/Application/Controllers/AcquisitioncardsController.php b/h-source/Application/Controllers/AcquisitioncardsController.php index 4e320d9..08e99f0 100644 --- a/h-source/Application/Controllers/AcquisitioncardsController.php +++ b/h-source/Application/Controllers/AcquisitioncardsController.php @@ -82,7 +82,7 @@ class AcquisitioncardsController extends GenericController ); $this->mod->setWhereQueryClause($whereArray); - + parent::catalogue($lang); } diff --git a/h-source/Application/Include/hardware.php b/h-source/Application/Include/hardware.php index e5dccea..4a651f6 100644 --- a/h-source/Application/Include/hardware.php +++ b/h-source/Application/Include/hardware.php @@ -31,6 +31,7 @@ class Hardware public static $translations = array( "amd64" => 'x86-64/amd64', + "PC-Card" => 'PCMCIA/PC-Card', ); public static $regExpressions = array( diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php index cbaf6bb..6f1fac4 100644 --- a/h-source/Application/Include/languages.php +++ b/h-source/Application/Include/languages.php @@ -334,6 +334,7 @@ class Lang /*0286*/"October" => "ottobre", /*0287*/"November" => "novembre", /*0288*/"December" => "dicembre", + /*0289*/"not-specified" => "non specificato", ), 'es' => array ( diff --git a/h-source/Application/Models/AcquisitioncardsModel.php b/h-source/Application/Models/AcquisitioncardsModel.php index ab04fed..147aa94 100644 --- a/h-source/Application/Models/AcquisitioncardsModel.php +++ b/h-source/Application/Models/AcquisitioncardsModel.php @@ -42,9 +42,7 @@ class AcquisitioncardsModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,compatibility,comm_year,interface'); diff --git a/h-source/Application/Models/BluetoothModel.php b/h-source/Application/Models/BluetoothModel.php index 82aab59..022c889 100644 --- a/h-source/Application/Models/BluetoothModel.php +++ b/h-source/Application/Models/BluetoothModel.php @@ -42,11 +42,9 @@ class BluetoothModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); - $this->createPopupWhere('vendor,bluetooth_works,comm_year,interface'); + + $this->setPopupFunctions(); $this->diffFields = array( 'vendor' => gtext("vendor"), diff --git a/h-source/Application/Models/EthernetcardsModel.php b/h-source/Application/Models/EthernetcardsModel.php index 1727f71..08dc997 100644 --- a/h-source/Application/Models/EthernetcardsModel.php +++ b/h-source/Application/Models/EthernetcardsModel.php @@ -42,9 +42,7 @@ class EthernetcardsModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,ethernet_card_works,comm_year,interface'); diff --git a/h-source/Application/Models/FingerprintreadersModel.php b/h-source/Application/Models/FingerprintreadersModel.php index 8e3f8da..7a2f3e8 100644 --- a/h-source/Application/Models/FingerprintreadersModel.php +++ b/h-source/Application/Models/FingerprintreadersModel.php @@ -42,9 +42,7 @@ class FingerprintreadersModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,fingerprint_works,comm_year,interface'); diff --git a/h-source/Application/Models/GenericModel.php b/h-source/Application/Models/GenericModel.php index 9a619fd..002149b 100644 --- a/h-source/Application/Models/GenericModel.php +++ b/h-source/Application/Models/GenericModel.php @@ -66,4 +66,39 @@ class GenericModel extends Model_Tree { $this->_popupWhere[$field] = 'type="'.$this->type.'" and deleted="no" and cleared="no"'; } } + + //set the fuction to be applied upon each popup name + public function setPopupFunctions() + { + foreach ($this->_popupItemNames as $name => $field) + { + $this->_popupFunctions[$name] = $this->getTranslationFunction($name); + } + } + + public function getPopupLabel($viewArgs) + { + $html = null; + foreach ($viewArgs as $field => $value) + { + $html .= "<div class='viewall_popup_menu_status_item'>$value</div>\n"; + } + return $html; + } + + //get the translation function + public function getTranslationFunction($fieldName) + { + $fieldsFunc = array( + "vendor" => "betterVendor", + "interface" => "translate", + ); + + if (array_key_exists($fieldName,$fieldsFunc)) + { + return $fieldsFunc[$fieldName]; + } + + return "gtext"; + } }
\ No newline at end of file diff --git a/h-source/Application/Models/ModemsModel.php b/h-source/Application/Models/ModemsModel.php index 5417524..92571d2 100644 --- a/h-source/Application/Models/ModemsModel.php +++ b/h-source/Application/Models/ModemsModel.php @@ -42,9 +42,7 @@ class ModemsModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,compatibility,comm_year,interface'); diff --git a/h-source/Application/Models/NotebooksModel.php b/h-source/Application/Models/NotebooksModel.php index cc1b9eb..ce158a1 100644 --- a/h-source/Application/Models/NotebooksModel.php +++ b/h-source/Application/Models/NotebooksModel.php @@ -41,9 +41,7 @@ class NotebooksModel extends GenericModel { 'subtype' => gtext("subtype"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,compatibility,comm_year,subtype'); diff --git a/h-source/Application/Models/PrintersModel.php b/h-source/Application/Models/PrintersModel.php index 74cc0af..355bb67 100644 --- a/h-source/Application/Models/PrintersModel.php +++ b/h-source/Application/Models/PrintersModel.php @@ -41,6 +41,8 @@ class PrintersModel extends GenericModel 'comm_year' => gtext("year"), 'interface' => gtext("interface"), ); + + $this->setPopupFunctions(); $this->createPopupWhere('vendor,compatibility,comm_year,interface'); diff --git a/h-source/Application/Models/ScannersModel.php b/h-source/Application/Models/ScannersModel.php index 430142d..4710503 100644 --- a/h-source/Application/Models/ScannersModel.php +++ b/h-source/Application/Models/ScannersModel.php @@ -44,6 +44,8 @@ class ScannersModel extends GenericModel $this->createPopupWhere('vendor,compatibility,comm_year,interface'); + $this->setPopupFunctions(); + $this->diffFields = array( 'vendor' => gtext("vendor"), 'model' => gtext('model name'), diff --git a/h-source/Application/Models/SdcardreadersModel.php b/h-source/Application/Models/SdcardreadersModel.php index f580d87..85950a5 100644 --- a/h-source/Application/Models/SdcardreadersModel.php +++ b/h-source/Application/Models/SdcardreadersModel.php @@ -42,9 +42,7 @@ class SdcardreadersModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,sd_card_works,comm_year,interface'); diff --git a/h-source/Application/Models/SoundcardsModel.php b/h-source/Application/Models/SoundcardsModel.php index cda9c99..7137d79 100644 --- a/h-source/Application/Models/SoundcardsModel.php +++ b/h-source/Application/Models/SoundcardsModel.php @@ -42,9 +42,7 @@ class SoundcardsModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,sound_card_works,comm_year,interface'); diff --git a/h-source/Application/Models/ThreegcardsModel.php b/h-source/Application/Models/ThreegcardsModel.php index 4a89a97..88ae580 100644 --- a/h-source/Application/Models/ThreegcardsModel.php +++ b/h-source/Application/Models/ThreegcardsModel.php @@ -41,11 +41,8 @@ class ThreegcardsModel extends GenericModel 'wifi_works' => gtext("does it work?"), 'interface' => gtext("interface"), ); - - $this->_popupFunctions = array( - 'vendor' => 'betterVendor', - 'interface' => 'betterVendor', - ); + + $this->setPopupFunctions(); $this->createPopupWhere('vendor,wifi_works,comm_year,interface'); diff --git a/h-source/Application/Models/VideocardsModel.php b/h-source/Application/Models/VideocardsModel.php index 2e9a3ee..961340e 100644 --- a/h-source/Application/Models/VideocardsModel.php +++ b/h-source/Application/Models/VideocardsModel.php @@ -43,6 +43,8 @@ class VideocardsModel extends GenericModel ); $this->createPopupWhere('vendor,video_card_works,comm_year,interface'); + + $this->setPopupFunctions(); $this->diffFields = array( 'vendor' => gtext("vendor"), diff --git a/h-source/Application/Models/WebcamsModel.php b/h-source/Application/Models/WebcamsModel.php index a59da6e..0942bcb 100644 --- a/h-source/Application/Models/WebcamsModel.php +++ b/h-source/Application/Models/WebcamsModel.php @@ -47,6 +47,8 @@ class WebcamsModel extends GenericModel ); $this->createPopupWhere('vendor,webcam_works,comm_year,interface'); + + $this->setPopupFunctions(); $this->diffFields = array( 'vendor' => gtext("vendor"), diff --git a/h-source/Application/Models/WifiModel.php b/h-source/Application/Models/WifiModel.php index 12dedc2..0b6d6c2 100644 --- a/h-source/Application/Models/WifiModel.php +++ b/h-source/Application/Models/WifiModel.php @@ -42,9 +42,7 @@ class WifiModel extends GenericModel 'interface' => gtext("interface"), ); - $this->_popupFunctions = array( - 'interface' => 'betterVendor', - ); + $this->setPopupFunctions(); $this->createPopupWhere('vendor,wifi_works,comm_year,interface'); diff --git a/h-source/Application/Views/Threegcards/catalogue.php b/h-source/Application/Views/Threegcards/catalogue.php index a0962e4..6b17e55 100644 --- a/h-source/Application/Views/Threegcards/catalogue.php +++ b/h-source/Application/Views/Threegcards/catalogue.php @@ -28,7 +28,7 @@ <div class="viewall_popup_menu_status_item"><?php echo betterVendor($this->viewArgs['vendor']);?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['comm_year']?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['wifi_works']?></div> - <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['interface']?></div> + <div class="viewall_popup_menu_status_item"><?php echo translate($this->viewArgs['interface'])?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['sort-by']?></div> </div> </div> @@ -67,7 +67,7 @@ <div class="notebook_vendor"> <div class="inner_label"><?php echo gtext("interface");?>:</div> - <div class="inner_value"><b><?php echo ThreeGcards::$interfaceReverse[$item['hardware']['interface']];?></b></div> + <div class="inner_value"><b><?php echo translate($item['hardware']['interface']);?></b></div> </div> <div class="notebook_kernel"> diff --git a/h-source/Application/Views/Wifi/catalogue.php b/h-source/Application/Views/Wifi/catalogue.php index a1bf725..3ea9380 100644 --- a/h-source/Application/Views/Wifi/catalogue.php +++ b/h-source/Application/Views/Wifi/catalogue.php @@ -28,7 +28,7 @@ <div class="viewall_popup_menu_status_item"><?php echo betterVendor($this->viewArgs['vendor']);?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['comm_year']?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['wifi_works']?></div> - <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['interface']?></div> + <div class="viewall_popup_menu_status_item"><?php echo translate($this->viewArgs['interface'])?></div> <div class="viewall_popup_menu_status_item"><?php echo $this->viewArgs['sort-by']?></div> </div> </div> @@ -67,7 +67,7 @@ <div class="notebook_vendor"> <div class="inner_label"><?php echo gtext("interface");?>:</div> - <div class="inner_value"><b><?php echo Wifi::$interfaceReverse[$item['hardware']['interface']];?></b></div> + <div class="inner_value"><b><?php echo translate($item['hardware']['interface']);?></b></div> </div> <div class="notebook_kernel"> diff --git a/h-source/Application/Views/page.php b/h-source/Application/Views/page.php index e59aa87..e879d0e 100644 --- a/h-source/Application/Views/page.php +++ b/h-source/Application/Views/page.php @@ -79,7 +79,7 @@ <div class="notebook_vendor"> <div class="inner_label"><?php echo gtext("interface");?>:</div> - <div class="inner_value"><b><?php echo $item[$tableName]['interface'];?></b></div> + <div class="inner_value"><b><?php echo translate($item[$tableName]['interface']);?></b></div> </div> <div class="model_tested_on"> diff --git a/h-source/Library/Call.php b/h-source/Library/Call.php index 29a3046..c75508b 100755 --- a/h-source/Library/Call.php +++ b/h-source/Library/Call.php @@ -232,12 +232,13 @@ function rewrite($url) { foreach (Route::$map as $key => $address) { + $oldKey = $key; $key = str_replace('\/','/',$key); $key = str_replace('/','\/',$key); if (preg_match('/^'.$key.'/',$url)) { $nurl = preg_replace('/^'.$key.'/',$address,$url); - return array($nurl,$key); + return array($nurl,$oldKey); // return preg_replace('/^'.$key.'/',$address,$url); } } diff --git a/h-source/Library/Controller.php b/h-source/Library/Controller.php index 742e89d..5a9ec79 100755 --- a/h-source/Library/Controller.php +++ b/h-source/Library/Controller.php @@ -55,7 +55,6 @@ class Controller { protected $scaffold = null; //the reference to the scaffold object function __construct($model, $controller, $queryString = array()) { - $this->controller = $controller; $this->modelName = $model; $this->_queryString = $queryString; diff --git a/h-source/Library/Form/Entry.php b/h-source/Library/Form/Entry.php index a17ac5e..8136dda 100755 --- a/h-source/Library/Form/Entry.php +++ b/h-source/Library/Form/Entry.php @@ -32,6 +32,7 @@ abstract class Form_Entry { public $labelString = null; //label of the form public $labelClass = null; //the class of the tag of the label public $options = array(); //options (if the entry is a <select> entry or a radio button). Associative array or comma-divided list. + public $reverse = null; //reverse label with value in select entries public $defaultValue = ''; public $wrap = array(); public $deleteButton = null; diff --git a/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php index f358651..a1a9fda 100755 --- a/h-source/Library/Form/Form.php +++ b/h-source/Library/Form/Form.php @@ -81,6 +81,7 @@ class Form_Form { $defaultValue = array_key_exists('defaultValue',$entry) ? $entry['defaultValue'] : null; $wrap = array_key_exists('wrap',$entry) ? $entry['wrap'] : array(); $deleteButton = array_key_exists('deleteButton',$entry) ? $entry['deleteButton'] : null; + $reverse = array_key_exists('reverse',$entry) ? $entry['reverse'] : null; $this->entry[$name]->entryClass = $entryClass; $this->entry[$name]->labelString = $labelString; @@ -90,6 +91,7 @@ class Form_Form { $this->entry[$name]->defaultValue = $defaultValue; $this->entry[$name]->wrap = $wrap; $this->entry[$name]->deleteButton = $deleteButton; + $this->entry[$name]->reverse = $reverse; } } diff --git a/h-source/Library/Form/Select.php b/h-source/Library/Form/Select.php index 521e3b5..53d7632 100755 --- a/h-source/Library/Form/Select.php +++ b/h-source/Library/Form/Select.php @@ -39,7 +39,7 @@ class Form_Select extends Form_Entry $returnString .= $wrap[1]; $returnString .= $this->getLabelTag(); $returnString .= $wrap[2]; - $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName); + $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName, $this->reverse); $returnString .= $wrap[3]; $returnString .="</div>\n"; $returnString .= $wrap[4]; diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php index 3ffce1c..51ed09c 100755 --- a/h-source/Library/Helper/List.php +++ b/h-source/Library/Helper/List.php @@ -55,9 +55,12 @@ class Helper_List extends Helper_Html { 'link' => 'associate the record' ); - //properties of each column + //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(); @@ -180,7 +183,7 @@ class Helper_List extends Helper_Html { } public function wrapList($string) { - return wrap($string,array('table'=>'listTable')); + return wrap($string,array('table'=>$this->tableAttributes)); } //method to create the HTML of the head of the table @@ -335,7 +338,8 @@ class Helper_List extends Helper_Html { } public function simpleText($itemArray) { - $string = "<span class='textItem'>".$itemArray['action']."</span>\n"; + $text = strcmp($itemArray['action'],'') !== 0 ? $itemArray['action'] : ' '; + $string = "<span class='textItem'>".$text."</span>\n"; return $string; } diff --git a/h-source/Library/Html/Form.php b/h-source/Library/Html/Form.php index f82cd2d..0714d3c 100644 --- a/h-source/Library/Html/Form.php +++ b/h-source/Library/Html/Form.php @@ -31,13 +31,13 @@ class Html_Form { //$options: options of the select. This param can be a comma-separated list of options or an associative array ('name'=>'value') //$className: the class name of the select //$idName: name of the id - static public function select($name, $value, $options, $className = null, $idName = null) + static public function select($name, $value, $options, $className = null, $idName = null, $reverse = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; $returnString = null; - $returnString .= "<select ".$idStr." $strClass name='".$name."'>\n"; + $returnString .= "<select $attributes ".$idStr." $strClass name='".$name."'>\n"; if (is_string($options)) { $tempArray = explode(',',$options); foreach ($tempArray as $item) @@ -60,16 +60,26 @@ class Html_Form { $flag = 0; foreach ($optionsArray as $optionName => $optionValue) { - if (strcmp($optionValue,'optgroupOpen') === 0) + + $a = $optionName; + $b = $optionValue; + + if (strcmp($reverse,'yes') === 0) + { + $b = $optionName; + $a = $optionValue; + } + + if (strcmp($b,'optgroupOpen') === 0) { if ($flag === 1) $returnString .= "</optgroup>\n"; - $returnString .= "<optgroup label=" . $optionName . ">\n"; + $returnString .= "<optgroup label='" . $a . "'>\n"; $flag = 1; } else { - $str= (strcmp($value,$optionValue) === 0) ? "selected='$optionValue'" : null; - $returnString .= "<option value='".$optionValue."' $str>$optionName</option>\n"; + $str= (strcmp($value,$b) === 0) ? "selected='$b'" : null; + $returnString .= "<option value='".$b."' $str>$a</option>\n"; } } if ($flag === 1) $returnString .= "</optgroup>\n"; @@ -82,12 +92,12 @@ class Html_Form { //$value: the value of the input //$className: the class name of the input //$idName: name of the id - static public function input($name, $value, $className = null, $idName = null) + static public function input($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - $returnString ="<input ".$idStr." $strClass type='text' name='" .$name. "' value = '$value'>\n"; + $returnString ="<input $attributes ".$idStr." $strClass type='text' name='" .$name. "' value = '$value' />\n"; return $returnString; } @@ -95,12 +105,12 @@ class Html_Form { //$name: the name of the input //$className: the class name of the input //$idName: name of the id - static public function fileUpload($name, $value, $className = null, $idName = null) + static public function fileUpload($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - $returnString ="<input ".$idStr." $strClass type='file' name='" .$name. "'>\n"; + $returnString ="<input $attributes ".$idStr." $strClass type='file' name='" .$name. "' />\n"; return $returnString; } @@ -110,13 +120,13 @@ class Html_Form { //$option: option of the checkBox (string or number) //$className: the class name of the checkBox (string) //$idName: name of the id - static public function checkbox($name, $value, $option, $className = null, $idName = null) + static public function checkbox($name, $value, $option, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; $str = (strcmp($value,$option) === 0) ? "checked = 'checked'" : null; - return "<input ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str>\n"; + return "<input $attributes ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str />\n"; } //return the HTML of a hidden entry @@ -131,24 +141,24 @@ class Html_Form { //$name: name of the password entry (string) //$value: the value of the password entry (string or number) //$idName: name of the id - static public function password($name, $value, $className = null, $idName = null) + static public function password($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - return "<input ".$idStr." $strClass type='password' name='" .$name. "' value='$value'>\n"; + return "<input $attributes ".$idStr." $strClass type='password' name='" .$name. "' value='$value' />\n"; } //return the HTML of a textarea //$name: name of the textarea (string) //$value: the value of the textarea (string or number) //$idName: name of the id - static public function textarea($name, $value, $className = null, $idName = null) + static public function textarea($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - return "<textarea ".$idStr." $strClass name='" .$name. "'>$value</textarea>\n"; + return "<textarea $attributes ".$idStr." $strClass name='" .$name. "'>$value</textarea>\n"; } //return the HTML of a radio button @@ -158,7 +168,7 @@ class Html_Form { //$className: the class name of the radio button //$position: position of the strings of the radio with respect to the "circles". It can be before or after //$idName: name of the id - static public function radio($name, $value, $options, $className = null, $position = 'after', $idName = null) + static public function radio($name, $value, $options, $className = null, $position = 'after', $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; @@ -189,7 +199,7 @@ class Html_Form { } $str= (strcmp($value,$optionValue) === 0) ? "checked='checked'" : null; - $returnString .= "$before<input ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str>$after\n"; + $returnString .= "$before<input $attributes ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str />$after\n"; } return $returnString; diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php index c89abcd..57d769a 100755 --- a/h-source/Library/Model/Base.php +++ b/h-source/Library/Model/Base.php @@ -236,7 +236,7 @@ abstract class Model_Base //method to create the where clause of the select query from the $this->where array //$level: level of the ricorsion //$whereClauseLevel: array containing the field=>value statements of the where clause. If $whereClause = null than $this->where is considered - public function createWhereClause($level = 0, $whereClauseLevel = null) + public function createWhereClause($level = 0, $whereClauseLevel = null, $operator = null) { $whereClause = null; $whereClauseArray = array(); @@ -247,7 +247,19 @@ abstract class Model_Base { if (is_array($value)) { - $newValue = $this->createWhereClause($level+1, $value); + if (strstr($field,"OR")) + { + $op = " OR "; + } + else if (strstr($field,"AND")) + { + $op = " AND "; + } + else + { + $op = null; + } + $newValue = $this->createWhereClause($level+1, $value, $op); if (isset($newValue)) $whereClauseArray[] = $newValue; } else @@ -283,7 +295,14 @@ abstract class Model_Base } } //get the logic operator at the current level - $logicOper = isset($this->logicalOperators[$level]) ? ' '.$this->logicalOperators[$level].' ' : ' AND '; + if (isset($operator)) + { + $logicOper = $operator; + } + else + { + $logicOper = isset($this->logicalOperators[$level]) ? ' '.$this->logicalOperators[$level].' ' : ' AND '; + } $whereClause = !empty($whereClauseArray) ? implode($logicOper,$whereClauseArray) : null; $whereClause = (isset($whereClause) and $level>0) ? '('.$whereClause.')' : $whereClause; return $whereClause; diff --git a/h-source/Library/Params.php b/h-source/Library/Params.php index 001040e..488c8b2 100644 --- a/h-source/Library/Params.php +++ b/h-source/Library/Params.php @@ -26,11 +26,14 @@ if (!defined('EG')) die('Direct access not allowed!'); class Params { - public static $allowedDb = array('Mysql','Mysqli','None'); //allowed database type + //allowed database type + public static $allowedDb = array('Mysql','Mysqli','None'); - public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1'; //allowed sanitize functions + //allowed sanitize functions + public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1'; - public static $allowedHashFunc = array('md5','sha1'); //allowed hash functions + //allowed hash functions + public static $allowedHashFunc = array('md5','sha1'); //conventional null value for the value of the field in the createWhereClause method of the Model class public static $nullQueryValue = false; @@ -46,9 +49,12 @@ class Params public static $htmlentititiesCharset = DEFAULT_CHARSET; //list of symbols used in the statements of the where clause of the select queries - public static $whereClauseSymbolArray = array('<','>','!=','<=','>=','in(','not in('); + public static $whereClauseSymbolArray = array('<','>','!=','<=','>=','in(','not in(','like'); //is the mbstring extension enabled? public static $mbStringLoaded = false; + //subfolder of the View folder where to look for view files + public static $viewSubfolder = null; + }
\ No newline at end of file diff --git a/h-source/Library/Theme.php b/h-source/Library/Theme.php index 45cace4..a001631 100755 --- a/h-source/Library/Theme.php +++ b/h-source/Library/Theme.php @@ -75,19 +75,22 @@ class Theme { public function render() { extract($this->_data); + //find the View subfolder where to look for view files + $subfolder = isset(Params::$viewSubfolder) ? Params::$viewSubfolder . DS : null; + foreach ($this->_viewFiles as $file) { - if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . ucwords($this->controller) . DS . $file . '.php')) { - include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . ucwords($this->controller) . DS . $file . '.php'); + if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php')) { + include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php'); } else { - include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . $file . '.php'); + include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. $file . '.php'); } } if (isset($this->_lastView)) { - if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . ucwords($this->controller) . DS . $this->_lastView . '.php')) { - include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . ucwords($this->controller) . DS . $this->_lastView . '.php'); + if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php')) { + include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php'); } else { - include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . $this->_lastView . '.php'); + include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. $this->_lastView . '.php'); } } |