Changeset 384 for trunk/phpbms/include
- Timestamp:
- 05/04/08 17:18:08 (4 years ago)
- Location:
- trunk/phpbms/include
- Files:
-
- 4 modified
-
common_functions.php (modified) (3 diffs)
-
fields.php (modified) (6 diffs)
-
session.php (modified) (3 diffs)
-
tables.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/include/common_functions.php
r370 r384 47 47 var $topJS = array(); 48 48 var $bottomJS = array(); 49 50 var $onload = ""; 51 49 var $onload = array(); 50 52 51 var $showFooter = true; 53 52 var $showMenu = true; … … 84 83 }//endid 85 84 }//end method 85 86 86 87 87 function getModules(){ … … 579 579 case "noencoding": 580 580 $value=$value; 581 break; 581 break; 582 583 584 case "bbcode": 585 $value=htmlQuotes($value); 586 587 // This list needs to be expanded 588 $bbcodelist["[b]"] = "<strong>"; 589 $bbcodelist["[/b]"] = "</strong>"; 590 $bbcodelist["[br]"] = "<br />"; 591 $bbcodelist["[space]"] = " "; 592 593 foreach($bbcodelist as $bbcode => $translation) 594 $value = str_replace($bbcode, $translation, $value); 595 596 break; 597 582 598 default: 583 599 $value=htmlQuotes($value); -
trunk/phpbms/include/fields.php
r308 r384 55 55 var $fields = array(); 56 56 57 var $onload = array(); 57 58 58 59 function phpbmsForm($action = NULL, $method="post", $name="record", $onsubmit="return validateForm(this);", $dontSubmit = true){ … … 145 146 $phpbms->topJS = array_merge($this->topJS,$phpbms->topJS); 146 147 $phpbms->bottomJS = array_merge($this->bottomJS,$phpbms->bottomJS); 148 $phpbms->onload = array_merge($this->onload,$phpbms->onload); 147 149 148 150 //next we go through the list of fields 149 151 foreach($this->fields as $field){ 152 150 153 $toAdd = $field->getJSMods(); 151 154 … … 156 159 $phpbms->topJS = array_merge($phpbms->topJS,$toAdd["topJS"]); 157 160 $phpbms->bottomJS = array_merge($phpbms->bottomJS,$toAdd["bottomJS"]); 158 } 159 } 160 } 161 $phpbms->onload = array_merge($phpbms->onload,$toAdd["onload"]); 162 163 }//endforeach 164 165 }//end method - jsMerge 166 }//end class 161 167 162 168 … … 244 250 245 251 function getJSMods(){ 246 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array() );252 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array(), "onload" => array()); 247 253 248 254 foreach($this->jsIncludes as $theinclude) … … 709 715 710 716 711 //============================================================================================ 712 class inputAutofill extends inputField{ 717 class inputSmartSearch extends inputField{ 718 713 719 /* 714 initialvalue = Value for get field (usually and id) 715 tabledefid = id of table to pull information from 716 getfield = Field to match value from 717 displayfield = Field to display 718 extrafield = Extra table information to display on drop down 719 whereclause = SQL where clause (without WHERE) narrowing search lookup 720 blankout = Wether to blank out invlaid entries 720 *db = (dbObj) Database Object 721 *id = (string) name of hidden field to be created 722 *searchName = (string) unique name of a stored search 723 initialvalue = (var) initial value for field (blank) 724 displayName = (string) Name to display (uses id by default) 725 displayName = (string) Name to display (uses id by default) 726 size = (int) size attribute for displayed input tag (32) 727 maxlength = (int) max length attribute for displayed input tag (255) 728 displayLabel (boolean) Show label tag with displayName (true) 729 730 The JS used by this field type requires that the field NOT be implemented inside a p tag, 731 inline element, or any tag that should not contain a div tag. In IE, if the field placed 732 inside an element that should not be able to handle a DIV tag inside it (standards-wise), 733 IE will report a Javascript error. 721 734 */ 722 function inputAutofill($db, $id, $initialvalue, $tabledefid, $getfield, $displayfield, 723 $extrafield="", $whereclause="", $displayName = NULL, $required=false, 724 $blankout=true, $displayLabel = true) { 725 $size = 32; 726 $maxlength = 128; 735 function inputSmartSearch($db, $id, $searchName, $initialvalue = "", $displayName = NULL, $required=false, 736 $size = 32, $maxlength = 255, $displayLabel = true) { 737 $this->db = $db; 727 738 728 739 parent::inputField($id, $initialvalue, $displayName,$required, NULL, $size, $maxlength, $displayLabel); 729 730 $this->db = $db; 731 732 $this->tabledefid = $tabledefid; 733 $this->getfield = $getfield; 734 $this->displayfield = $displayfield; 735 $this->extrafield = $extrafield; 736 $this->whereclause = $whereclause; 737 738 $this->blankout = $blankout; 739 740 //First let's grab the Table information 741 $querystatement = "SELECT maintable,querytable from tabledefs where id=".$tabledefid; 740 741 $this->searchName = $searchName; 742 743 //next I need to initialize and do the correct search 744 $this->searchInfo = $this->getSearchInfo($searchName); 745 746 $this->displayValue = $this->getInitialDisplay(); 747 748 }//end method - init 749 750 751 function getSearchInfo($searchInfo){ 752 753 $querystatement = " 754 SELECT 755 * 756 FROM 757 smartsearches 758 WHERE 759 name = '".mysql_real_escape_string($searchInfo)."' 760 "; 761 762 return $this->db->fetchArray($this->db->query($querystatement)); 763 764 }//end method getInfo 765 766 function getInitialDisplay(){ 767 768 $querystatement = " 769 SELECT 770 ".$this->searchInfo["displayfield"]." AS display 771 FROM 772 ".$this->searchInfo["fromclause"]." 773 WHERE 774 ".$this->searchInfo["valuefield"]." = '".mysql_real_escape_string($this->value)."' 775 "; 776 742 777 $queryresult = $this->db->query($querystatement); 743 $tableinfo = $this->db->fetchArray($queryresult); 744 745 $querystatement = "SELECT ".$displayfield." AS display FROM ".$tableinfo["maintable"]." WHERE ".$getfield."=\"".$initialvalue."\" LIMIT 1;"; 746 $queryresult = $this->db->query($querystatement); 747 748 if($this->db->numRows($queryresult)) 749 $displayresult = $this->db->fetchArray($queryresult); 750 else 751 $displayresult["display"]=""; 752 753 $this->displayValue = $displayresult["display"]; 754 755 }//end method 756 757 778 779 if($this->db->numRows($queryresult)){ 780 781 $therecord = $this->db->fetchArray($queryresult); 782 return $therecord["display"]; 783 784 } else 785 return ''; 786 787 }//end method getInitialDisplay 788 789 790 // CLASS OVERIDES ================================================ 758 791 function getJSMods(){ 759 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array()); 760 761 $thereturn["jsIncludes"][] = "common/javascript/autofill.js"; 792 793 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array(), "onload" => array()); 794 795 $thereturn["jsIncludes"][] = "common/javascript/smartsearch.js"; 762 796 763 797 if($this->required){ 798 764 799 $message = $this->message; 800 765 801 if($message == "") 766 802 $message = $this->displayName." cannot be blank."; 767 $thereturn["topJS"][] = "requiredArray[requiredArray.length]=new Array(\"".$this->name."\",\"".$message."\");"; 768 } 769 770 $thereturn["topJS"][] = 'autofill["'.$this->id.'"] = new Array();'; 771 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["ch"] = "";'; 772 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["uh"] = "";'; 773 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["fl"] = "'.urlencode(stripslashes($this->displayfield)).'"'; 774 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["xt"] = "'.urlencode(stripslashes($this->extrafield)).'"'; 775 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["td"] = '.urlencode(stripslashes($this->tabledefid)).';'; 776 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["gf"] = "'.urlencode(stripslashes($this->getfield)).'"'; 777 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["wc"] = "'.urlencode(stripslashes($this->whereclause)).'"'; 778 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["bo"] = '.(($this->blankout) ? 'true' : 'false').''; 779 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["vl"] = "'.htmlQuotes($this->displayValue).'"'; 780 $thereturn["topJS"][] = 'appPath = "'.APP_PATH.'"'; 781 782 $thereturn["bottomJS"][] = 'var display=getObjectFromID("ds-'.$this->id.'");'; 783 $thereturn["bottomJS"][] = 'display.autocomplete="off";'; 803 $thereturn["topJS"][] = "requiredArray[requiredArray.length]= [ '".$this->name."','".$message."' ];"; 804 805 }//endif - required 806 807 return $thereturn; 784 808 785 return $thereturn; 786 }//end if 787 809 }//end method - getJSMods 810 788 811 789 812 function showLabel(){ 790 813 ?><label for="ds-<?php echo $this->id?>"><?php echo $this->displayName?></label><br /><?php 791 } 814 }//end method 792 815 793 816 … … 802 825 $this->_attributes["class"] = " ".$this->_attributes["class"]; 803 826 804 $this->_attributes["class"] = "autofillField".$this->_attributes["class"]; 805 806 827 $this->_attributes["class"] = "inputSmartSearch".$this->_attributes["class"]; 828 807 829 ?><input type="hidden" name="<?php echo $this->id?>" id="<?php echo $this->id?>" value="<?php echo $this->value?>" /> 808 <input type="text" name="ds-<?php echo $this->id?>" id="ds-<?php echo $this->id?>" title="Use % for wildcard searches." <?php 809 810 $this->displayAttributes(); 811 812 ?> value="<?php echo htmlQuotes($this->displayValue) ?>" onkeyup="autofillChange(this);return true;" onblur="setTimeout('blurAutofill(\'<?php echo $this->id ?>\')', 50)" onkeydown="captureKey(event)" /> 813 <?php 814 815 }//end method 816 817 818 }//end class 819 830 <input type="hidden" id="sdbid-<?php echo $this->id?>" value="<?php echo $this->searchInfo["id"]?>"/> 831 <input type="text" name="ds-<?php echo $this->id?>" id="ds-<?php echo $this->id?>" title="Use % for wildcard searches." <?php 832 833 $this->displayAttributes(); 834 835 ?> value="<?php echo htmlQuotes($this->displayValue) ?>"/><?php 836 837 }//end method -display 838 839 }//end class - inputSmartSearch 820 840 ?> -
trunk/phpbms/include/session.php
r356 r384 248 248 $value=substr($value,$startpos+1,$endpos-$startpos-1); 249 249 if(strpos($key,"mysql_")===0){ 250 define(strtoupper($key),$value); 250 define(strtoupper($key),$value); 251 251 } 252 252 } … … 324 324 if(!defined(strtoupper($therecord["name"]))) 325 325 define(strtoupper($therecord["name"]),$therecord["value"]); 326 327 326 }//end while 328 327 … … 350 349 // This is in a function in case we want to do sessions differently in the future 351 350 352 session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v0 8ID");351 session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v096ID"); 353 352 session_start(); 354 353 } -
trunk/phpbms/include/tables.php
r359 r384 303 303 304 304 $updatestatement .= " WHERE `id`=".((int) $variables["id"]); 305 305 306 306 $updateresult = $this->db->query($updatestatement); 307 307 … … 310 310 311 311 312 function insertRecord($variables,$createdby = NULL ){312 function insertRecord($variables,$createdby = NULL, $overrideID = false){ 313 313 314 314 if($createdby === NULL) … … 327 327 switch($fieldname){ 328 328 case "id": 329 break; 329 if(isset($variables["id"])) 330 if($overrideID && $variables["id"]){ 331 $fieldlist .= "id, "; 332 $insertvalues .= ((int) $variables["id"]).", "; 333 }//endif 334 break; 330 335 331 336 case "createdby": … … 333 338 $fieldlist .= $fieldname.", "; 334 339 $insertvalues .= ((int) $createdby).", "; 335 break;340 break; 336 341 337 342 case "creationdate": … … 339 344 $fieldlist .= $fieldname.", "; 340 345 $insertvalues .= "NOW(), "; 341 break;346 break; 342 347 343 348 default: … … 348 353 $fieldlist .= "`".$fieldname."`, "; 349 354 $insertvalues .= $this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 350 } 351 break;355 }//endif - fieldname 356 break; 352 357 }//end switch field name 353 358 }//end if … … 357 362 358 363 $insertstatement = "INSERT INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 359 360 364 $insertresult = $this->db->query($insertstatement); 361 365