Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1044111
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 24, 11:27 PM
Size
31 KB
Mime Type
text/x-diff
Expires
Thu, Jun 26, 11:27 PM (7 h, 4 m)
Engine
blob
Format
Raw Data
Handle
675295
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.21.2/kernel/include/config.php
===================================================================
--- branches/unlabeled/unlabeled-1.21.2/kernel/include/config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.21.2/kernel/include/config.php (revision 4927)
@@ -0,0 +1,516 @@
+<?php
+
+class clsConfig
+{
+ var $config;
+ var $m_dirty_session;
+ var $m_IsDirty;
+ var $m_DirtyFields;
+ var $m_VarType;
+ var $adodbConnection;
+
+ function clsConfig()
+ {
+ $this->m_IsDirty=false;
+ $this->adodbConnection = &GetADODBConnection();
+ $this->config = array();
+ $this->m_IsDefault = array();
+ $this->VarType = array();
+ }
+
+ function SetDebugLevel($value)
+ {
+ }
+
+
+ function Load()
+ {
+ if(is_object($this->adodbConnection))
+ {
+ LogEntry("Config Load Start\n");
+ $sql = "select VariableName, VariableValue from ".GetTablePrefix()."ConfigurationValues";
+ $rs = $this->adodbConnection->Execute($sql);
+ unset($this->config);
+ #this->config=array();
+ $count=0;
+ while($rs && !$rs->EOF)
+ {
+ $this->config[$rs->fields["VariableName"]] = $rs->fields["VariableValue"];
+ $this->m_VarType[$rs->fields["VariableName"]] = 0;
+ // $this->Set($rs->fields["VariableName"],$rs->fields["VariableValue"],0);
+ if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
+ {
+ adodb_movenext($rs);
+ }
+ else
+ $rs->MoveNext();
+ $count++;
+ }
+ LogEntry("Config Load End - $count Variables\n");
+ }
+ unset($this->m_DirtyFields);
+ $this->m_IsDirty=false;
+ if (defined('DBG_SITE_PATH')) {
+ $this->config['Site_Path'] = DBG_SITE_PATH;
+ }
+ }
+
+ function Get($property)
+ {
+ if( isset($this->config[$property]) )
+ {
+ return $this->config[$property];
+ }
+ elseif( isset($this->config[ strtolower($property)] ) )
+ {
+ return $this->config[ strtolower($property) ];
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ function Set($property, $value,$type=0,$force=FALSE)
+ {
+ if(is_array($this->config) && strlen($property)>0)
+ {
+ if(array_key_exists($property,$this->config))
+ {
+ $current = $this->config[$property];
+ $changed = ($current != $value);
+ }
+ else
+ $changed = true;
+ }
+ else
+ $changed = false;
+ $this->config[$property]=$value;
+ $this->m_IsDirty = ($this->m_IsDirty or $changed or $force);
+ if($changed || $force)
+ {
+ $this->m_DirtyFields[$property] = $value;
+ }
+ $this->m_VarType[$property] = $type;
+ }
+
+ function Save()
+ {
+ if($this->m_IsDirty==TRUE)
+ {
+ foreach($this->m_DirtyFields as $field=>$value)
+ {
+ if($this->m_VarType[$field]==0)
+ {
+// $sql = sprintf("UPDATE ".GetTablePrefix()."ConfigurationValues SET VariableValue=%s WHERE VariableName=%s", $this->adodbConnection->qstr($value), $this->adodbConnection->qstr($field));
+ $sql = 'UPDATE '.GetTablePrefix().'ConfigurationValues SET VariableValue="'.addslashes($value).'" WHERE VariableName="'.addslashes($field).'"';
+ // echo $sql."<br>\n";
+
+ $rs = $this->adodbConnection->execute($sql);
+ }
+ }
+ }
+ $this->m_IsDirty=FALSE;
+ unset($this->m_DirtyFields);
+ }
+
+ function TimeFormat()
+ {
+ return is12HourMode() ? 'g:i:s A' : 'H:i:s';
+ }
+
+ /* vartype should be either 1 or 2, 1 = perstant data, 2 = session data */
+ function GetDirtySessionValues($VarType)
+ {
+ $result = array();
+
+ if(is_array($this->m_DirtyFields))
+ {
+ foreach($this->m_DirtyFields as $property=>$values)
+ {
+ if($this->m_VarType[$property]==$VarType)
+ $result[$property] = $values;
+ }
+ }
+ return $result;
+ }
+
+ function GetConfigValues($postfix = '')
+ {
+ // return only varibles, that match specified criteria
+ if(!$postfix) return $this->config;
+ $result = Array();
+ $postfix_len = $postfix ? strlen($postfix) : 0;
+ foreach($this->config as $config_var => $var_value)
+ {
+ if( substr($config_var, - $postfix_len) == $postfix )
+ $result[$config_var] = $var_value;
+ }
+ return $result;
+ }
+}/* clsConfig */
+
+/*
+To create the configuration forms in the admin section, populate the table ConfigurationAdmin and
+ConfigurationValues.
+
+ The tables are fairly straight-forward. The fields of concern in the ConfigurationValues table is
+ModuleOwner and Section. ModuleOwner should either be the module name or In-Portal for kernel related stuff.
+(Items which should appear under 'System Configuration').
+
+ The Section field determines the NavMenu section the value is associated with. For example,
+in-portal:configure_general refers to items listed under System Configuration->General.
+
+ In the ConfigurationAdmin table, ensure the VariableName field is the same as the one in ConfigurationValues
+(this is the field that creates the natural join.) The prompt field is the text displayed to the left of the form element
+in the table. This should contain LANGUAGE ELEMENT IDENTIFIERS that are plugged into the Language function.
+
+ The element_type field describes the type of form element is associated with this item. Possible values are:
+ - text : textbox
+ - checkbox : a simple checkbox
+ - select : creates a dropdown box. In this case, the ValueList field should be populated with a comma-separated list
+ in name=value,name=value format (each element is translated to:
+ <option VALUE="[value]">[name]</option>
+
+ To add dynamic data to this list, enclose an SQL statement with <SQL></SQL> tags for example:
+ <SQL>SELECT FieldLabel as OptionName, FieldName as OptionValue FROM <prefix>CustomField WHERE <prefix>.CustomFieldType=3></SQL>
+
+ note the specific field labels OptionName and OptionValue. They are required by the parser.
+ use the <prefix> tag to insert the system's table prefix into the sql statement as appropriate
+
+*/
+class clsConfigAdminItem
+{
+ var $name;
+ var $heading;
+ var $prompt;
+ var $ElementType;
+ var $ValueList; /* comma-separated list in name=value pair format*/
+ var $ValidationRules;
+ var $default_value;
+ var $adodbConnection;
+ var $NextItem=NULL;
+ var $Section;
+
+ var $DisplayOrder = null;
+
+ var $TabIndex = 0;
+
+ function clsConfigAdminItem($config_name=NULL)
+ {
+ $this->adodbConnection = &GetADODBConnection();
+ if($config_name)
+ $this->LoadSetting($config_name);
+ }
+
+ function LoadSetting($config_name)
+ {
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName) WHERE ".GetTablePrefix()."ConfigurationAdmin.VariableName='".$config_name."'";
+ $rs = $this->adodbConnection->Execute($sql);
+ if($rs && !$rs->EOF)
+ {
+ $this->name = $rs->fields["VariableName"];
+ $this->heading = $rs->fields["heading"];
+ $this->prompt = $rs->fields["prompt"];
+ $this->ElementType = $rs->fields["element_type"];
+ $this->ValidationRules=$rs->fields["validation"];
+ $this->default_value = $rs->fields["VariableValue"];
+ $this->ValueList=$rs->fields["ValueList"];
+ $this->Section = $rs->fields["Section"];
+ $this->DisplayOrder = $rs->fields['DisplayOrder'];
+ }
+ }
+
+ function explode_sql($sql)
+ {
+ $s = "";
+
+ $rs = $this->adodbConnection->Execute($sql);
+
+ while ($rs && !$rs->EOF)
+ {
+ if(strlen(trim($rs->fields["OptionName"]))>0 && strlen(trim($rs->fields["OptionValue"]))>0)
+ {
+ if(strlen($s))
+ $s .= ",";
+ $s .= $rs->fields["OptionName"]."="."+".$rs->fields["OptionValue"];
+ }
+ $rs->MoveNext();
+ }
+ return $s;
+ }
+
+ function replace_sql($string)
+ {
+ $string = str_replace("<PREFIX>",GetTablePrefix(),$string);
+
+ $start = strpos($string,"<SQL>");
+
+ while($start)
+ {
+ $end = strpos($string,"</SQL>");
+ if(!$end)
+ {
+ $end = strlen($string);
+ }
+ $len = $end - $start;
+ $sql = substr($string,$start+5,$len-5);
+
+ $sql_val = $this->explode_sql($sql);
+ $s = substr($string,0,$start) . $sql_val . substr($string,$end+6);
+
+ $string = $s;
+ $start = strpos($string,"<SQL>");
+ }
+ return preg_replace('/(.*)$,/','\\1', $string);
+ }
+
+ function ItemFormElement($StartFrom=1)
+ {
+ global $objConfig;
+
+ if(!$this->TabIndex) $this->TabIndex = $StartFrom;
+
+ $o = '';
+ if( $objConfig->Get($this->name) != '' )
+ {
+ $this->default_value = $objConfig->Get($this->name);
+ }
+ $this->default_value = inp_htmlize($this->default_value);
+ switch($this->ElementType)
+ {
+ case 'text':
+ $o .= '<input type="text" tabindex="'.($this->TabIndex++).'" name="'.$this->name.'" ';
+ $o .= 'value="'.$this->default_value.'">';
+ break;
+
+ case 'checkbox':
+ $o .= '<input type="checkbox" name="'.$this->name.'" tabindex="'.($this->TabIndex++).'"';
+ $o .= $this->default_value ? ' checked>' : '>';
+ break;
+
+ case 'password':
+ /* To exclude config form from populating with Root (md5) password */
+ if( $this->Section == 'in-portal:configure_users' ) $this->default_value = '';
+
+ $o .= '<input type="password" tabindex="'.($this->TabIndex++).'" name="'.$this->name.'" ';
+ $o .= 'value="'.$this->default_value.'">';
+ break;
+
+ case 'textarea':
+ $o .= '<textarea tabindex="'.($this->TabIndex++).'" '.$this->ValueList.' name="'.$this->name.'">'.$this->default_value.'</textarea>';
+ break;
+
+ case 'label':
+ if ($this->default_value) {
+ $tag_params = clsHtmlTag::ParseAttributes($this->ValueList);
+ if (isset($tag_params['cut_first'])) {
+ $cut_first = $tag_params['cut_first'];
+ if (strlen($this->default_value) > $cut_first) {
+ $o .= substr($this->default_value, 0, $cut_first).' ...';
+ }
+ else {
+ $o .= $this->default_value;
+ }
+ }
+ else {
+ $o .= $this->default_value;
+ }
+ }
+ break;
+
+ case 'radio':
+ $radioname = $this->name;
+ $ValList = $this->replace_sql($this->ValueList);
+
+ $this->TabIndex++;
+ $val = explode(',',$ValList);
+ for($i=0;$i<=count($val);$i++)
+ {
+ if(strlen($val[$i]))
+ {
+ $parts = explode('=',$val[$i]);
+ $s = $parts[1];
+ if(strlen($s)==0)
+ $s = '';
+ $o .= '<input type="radio" tabindex="'.$this->TabIndex.'" name="'.$this->name.'" value="'.$parts[0].'"';
+ $o .= ($this->default_value == $parts[0]) ? ' checked>' : '>';
+
+ $o .= (substr($s,0,1)=="+") ? $s : prompt_language($s);
+ }
+ }
+ $this->TabIndex++;
+ break;
+
+ case 'select':
+ $o .= '<select name="'.$this->name.'" tabindex="'.($this->TabIndex++).'">';
+ $ValList = $this->replace_sql($this->ValueList);
+ $val = explode(',', $ValList);
+ for($i=0;$i<=count($val);$i++)
+ {
+ if(strlen($val[$i]))
+ {
+ $parts = explode('=',$val[$i]);
+ $s = $parts[1];
+ if(strlen($s)==0) $s = '';
+ $selected = '';
+ if($this->default_value==$parts[0]) $selected = ' selected';
+
+ $title = (substr($s,0,1) == '+') ? substr($s,1) : admin_language($s);
+ $o .= '<option value="'.$parts[0].'" '.$selected.'>'.$title.'</option>';
+ }
+ }
+ $o .= '</select>';
+ break;
+ }
+ return $o;
+ }
+
+ function GetPrompt()
+ {
+ $ret = prompt_language($this->prompt);
+ return $ret;
+ }
+}
+
+class clsConfigAdmin
+{
+ var $module;
+ var $section;
+ var $Items;
+
+ function clsConfigAdmin($module="",$section="",$Inst=FALSE)
+ {
+ $this->module = $module;
+ $this->section = $section;
+ $this->Items= array();
+ if(strlen($module) && strlen($section))
+ $this->LoadItems(TRUE,$Inst);
+ }
+
+ function Clear()
+ {
+ unset($this->Items);
+ $this->Items = array();
+ }
+
+ function NumItems()
+ {
+ if(is_array($this->Items))
+ {
+ return count($this->Items);
+ }
+ else
+ return 0;
+ }
+
+ function LoadItems($CheckNextItems=TRUE, $inst=FALSE)
+ {
+ $this->Clear();
+ if(!$inst)
+ {
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName)
+ WHERE ModuleOwner='".$this->module."' AND Section='".$this->section."' ORDER BY DisplayOrder ASC";
+ }
+ else
+ {
+
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName)
+ WHERE ModuleOwner='".$this->module."' AND Section='".$this->section."' AND Install=1 ORDER BY DisplayOrder ASC";
+ }
+ if( $GLOBALS['debuglevel'] ) echo $sql."<br>\n";
+ $adodbConnection = &GetADODBConnection();
+ $rs = $adodbConnection->Execute($sql);
+ $i = null;
+ $last = '';
+ while($rs && !$rs->EOF)
+ {
+ $data = $rs->fields;
+ if(is_object($i) && $CheckNextItems)
+ {
+ $last = $i->prompt;
+ unset($i);
+ }
+ $i = new clsConfigAdminItem(NULL);
+ $i->name = $data["VariableName"];
+ $i->default_value = $data["VariableValue"];
+ $i->heading = $data["heading"];
+ $i->prompt = $data["prompt"];
+ $i->ElementType = $data["element_type"];
+ $i->ValueList = $data["ValueList"];
+ $i->ValidationRules = isset($data['validaton']) ? $data['validaton'] : '';
+ $i->Section = $data["Section"];
+ $i->DisplayOrder = $data['DisplayOrder'];
+
+ if(strlen($last)>0)
+ {
+ if($i->prompt==$last)
+ {
+ $this->Items[count($this->Items)-1]->NextItem=$i;
+ }
+ else
+ {
+ $i->NextItem=NULL;
+ array_push($this->Items,$i);
+ }
+ }
+ else
+ {
+ $i->NextItem=NULL;
+ array_push($this->Items,$i);
+ }
+ //unset($i);
+ $rs->MoveNext();
+ }
+ }
+
+ function SaveItems($POSTVARS, $force=FALSE)
+ {
+ global $objConfig;
+
+ foreach($this->Items as $i)
+ {
+ if($i->ElementType != "label")
+ {
+ if($i->ElementType != "checkbox")
+ {
+ $objConfig->Set($i->name,stripslashes($POSTVARS[$i->name]));
+ }
+ else
+ {
+ if($POSTVARS[$i->name]=="on")
+ {
+ $value=1;
+ }
+ else
+ $value = (int)$POSTVARS[$i->name];
+ $objConfig->Set($i->name,stripslashes($value),0,$force);
+ }
+ }
+ }
+ $objConfig->Save();
+ }
+
+ function GetHeadingList()
+ {
+ $res = array();
+ foreach($this->Items as $i)
+ {
+ $res[$i->heading]=1;
+ }
+ reset($res);
+ return array_keys($res);
+ }
+
+ function GetHeadingItems($heading)
+ {
+ $res = array();
+ foreach($this->Items as $i)
+ {
+ if($i->heading==$heading)
+ array_push($res,$i);
+ }
+ return $res;
+ }
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.21.2/kernel/include/config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.21
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.21.2/admin/include/mainscript.php
===================================================================
--- branches/unlabeled/unlabeled-1.21.2/admin/include/mainscript.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.21.2/admin/include/mainscript.php (revision 4927)
@@ -0,0 +1,575 @@
+<?php
+global $imagesURL,$objConfig,$adminURL,$rootURL, $en;
+
+$group_select = $adminURL."/users/group_select.php";
+$item_select = $adminURL."/relation_select.php";
+$user_select = $adminURL."/users/user_select.php";
+$cat_select = $adminURL."/cat_select.php";
+$missing_edit = $adminURL."/config/missing_label_search.php";
+
+$lang_Filter = language("la_Text_Filter");
+$lang_View = language("la_Text_View");
+$lang_Sort = language("la_Text_Sort");
+$lang_Select = language("la_Text_Select");
+$lang_Unselect = language("la_Text_Unselect");
+$lang_Invert = language("la_Text_Invert");
+$lang_PerPage = language("la_prompt_PerPage");
+$lang_All = language("la_Text_All");
+$lang_Asc = language("la_common_ascending");
+$lang_Desc = language("la_common_descending");
+$lang_Disabled = language("la_Text_Disabled");
+$lang_Enabled = language("la_Text_Enabled");
+$lang_Pending = language("la_Text_Pending");
+$lang_Default = language("la_Text_Default");
+$lang_CreatedOn = language("la_prompt_CreatedOn");
+$lang_None = language("la_Text_None");
+$lang_PerPage = language("la_prompt_PerPage");
+$lang_Views = language("la_Text_Views");
+$lang_URL = language("la_ColHeader_Url");
+$lang_Status = language("la_prompt_Status");
+$lang_Name = language("la_prompt_Name");
+$lang_MoveDn = language("la_prompt_MoveDown");
+$lang_MoveUp = language("la_prompt_MoveUp");
+$lang_Delete = language("la_prompt_Delete");
+$lang_Edit = language("la_prompt_Edit");
+$errormsg = language("la_validation_AlertMsg");
+
+$env2 = BuildEnv();
+if(is_numeric($en))
+{
+ $env2 = BuildEnv() . "&en=$en";
+}
+
+$editor_url = $adminURL."/editor/editor_new.php?env=$env2";
+$email_url = $adminURL."/email/sendmail.php?env=$env2";
+$phrase_edit = $adminURL."/config/edit_label.php?env=".$env2;
+$submit_done = isset($_REQUEST['submit_done']) ? 1 : 0; // returns form submit status
+
+$Cal = GetDateFormat(0, true);
+if (strpos($Cal, 'y')) {
+ $Cal = str_replace('y','yy',$Cal);
+}
+else {
+ $Cal = str_replace('Y','y',$Cal);
+}
+
+
+$Cal = str_replace("m","mm",$Cal);
+$Cal = str_replace("n","m",$Cal);
+$Cal = str_replace("d","dd",$Cal);
+
+$format = GetStdFormat(GetDateFormat(0, true));
+
+$yearpos = (int)DateFieldOrder($format,"year");
+$monthpos = (int)DateFieldOrder($format,"month");
+$daypos = (int)DateFieldOrder($format,"day");
+
+$ampm = is12HourMode() ? 'true' : 'false';
+
+$SiteName = addslashes( strip_tags( $GLOBALS['objConfig']->Get('Site_Name') ) );
+
+require_once($pathtoroot.$admin."/lv/js/js_lang.php");
+print <<<END
+<script type="text/javascript" src="$adminURL/lv/js/in-portal.js"></script>
+<script language="Javascript">
+
+var main_title = '$SiteName';
+
+var CurrentTab= new String();
+var \$Menus = new Array();
+if(!\$fw_menus) var \$fw_menus = new Array();
+
+var lang_Filter = "$lang_Filter";
+var lang_Sort = "$lang_Sort";
+var lang_Select = "$lang_Select";
+var lang_Unselect = "$lang_Unselect";
+var lang_Invert = "$lang_Invert";
+var lang_PerPage = "$lang_PerPage";
+var lang_All = "$lang_All";
+var lang_Asc = "$lang_Asc";
+var lang_Desc = "$lang_Desc";
+var lang_Disabled = "$lang_Disabled";
+var lang_Pending = "$lang_Pending";
+var lang_Default = "$lang_Default";
+var lang_CreatedOn = "$lang_CreatedOn";
+var lang_View = "$lang_View";
+var lang_Views = "$lang_Views";
+var lang_None = "$lang_None";
+var lang_PerPage = "$lang_PerPage";
+var lang_Enabled = "$lang_Enabled";
+var lang_URL = "$lang_URL";
+var lang_Status = "$lang_Status";
+var lang_Name = "$lang_Name";
+
+var lang_Edit = "$lang_Edit";
+var lang_Delete = "$lang_Delete";
+var lang_MoveUp = "$lang_MoveUp";
+var lang_MoveDn = "$lang_MoveDn";
+var ampm = $ampm;
+var listview_clear=1;
+var CalDateFormat = "$Cal";
+
+var yearpos = $yearpos;
+var monthpos = $monthpos;
+var daypos = $daypos;
+var ErrorMsg = '$errormsg';
+//en = $en
+var rootURL = '$rootURL';
+var \$edit_mode = false;
+
+function clear_list_checkboxes()
+{
+ var inputs = document.getElementsByTagName("INPUT");
+ for (var i = 0; i < inputs.length; i++)
+ if (inputs[i].type == "checkbox" && inputs[i].getAttribute("isSelector"))
+ {
+ inputs[i].checked=false;
+ }
+}
+
+
+function getRealLeft(el) {
+ xPos = el.offsetLeft;
+ tempEl = el.offsetParent;
+ while (tempEl != null) {
+ xPos += tempEl.offsetLeft;
+ tempEl = tempEl.offsetParent;
+ }
+ return xPos;
+}
+
+function getRealTop(el) {
+ yPos = el.offsetTop;
+ tempEl = el.offsetParent;
+ while (tempEl != null) {
+ yPos += tempEl.offsetTop;
+ tempEl = tempEl.offsetParent;
+ }
+ return yPos;
+}
+
+function MM_preloadImages() { //v3.0
+ var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
+ var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
+ if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
+}
+
+function SetButtonStateByImage(btn_id, img_src)
+{
+ // set state depending on image name
+ var btn = document.getElementById(btn_id);
+ if(btn)
+ {
+ if( !HasParam(img_src) ) img_src = btn.getAttribute('src');
+ var img_name = img_src.split('/');
+ img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
+ img_name = img_name.split('.');
+ img_name = img_name[0].split('_');
+ img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
+ if(img_name)
+ {
+ switch(img_name)
+ {
+ case 'f2': btn.setAttribute('ButtonState','over'); break;
+ case 'f3': btn.setAttribute('ButtonState','disabled'); break;
+ default: btn.setAttribute('ButtonState','enabled'); break;
+ }
+ }
+ }
+}
+
+
+function swap(imgid, src, module_name){
+ // swaps toobar icons from kernel
+ // admin or from module specified
+
+ var ob = document.getElementById(imgid);
+ if(ob)
+ {
+ SetButtonStateByImage(imgid, src);
+ var s = src;
+ s = s.slice(0,4);
+ if(s=='http')
+ {
+ ob.src = src;
+ }
+ else
+ {
+ if(module_name == null)
+ ob.src = '$adminURL' + '/images/' + src;
+ else
+ {
+ ob.src = '$rootURL' + module_name + '/$admin/images/' + src;
+ }
+ }
+ }
+}
+
+function flip(val)
+{
+ if (val == 0)
+ return 1;
+ else
+ return 0;
+}
+
+function config_val(field, val2,url){
+ //alert('Setting ' + field + ' to ' + val2);
+ if(url)
+ document.viewmenu.action=url;
+ document.viewmenu.Action.value = "m_SetVariable";
+ document.viewmenu.fieldname.value = field;
+ document.viewmenu.varvalue.value = val2;
+ document.viewmenu.submit();
+}
+
+function session_val(field, val2){
+ //alert('Setting ' + field + ' to ' + val2);
+ document.viewmenu.Action.value = "m_SetSessionVariable";
+ document.viewmenu.fieldname.value = field;
+ document.viewmenu.varvalue.value = val2;
+ document.viewmenu.submit();
+}
+
+function Submit_ListSearch(action)
+{
+ f = document.getElementById('ListSearchForm');
+ s = document.getElementById('ListSearchWord');
+ if(f)
+ {
+ f.Action.value = action;
+ f.list_search.value = s.value;
+ f.submit();
+ }
+}
+
+function ValidTime(time_str)
+{
+ var valid = true;
+
+ if( trim(time_str) == '' ) return true; // is valid in case if not entered
+ time_str = time_str.toUpperCase();
+ parts = time_str.split(/\s*[: ]\s*/);
+ hour = parseInt(parts[0]);
+ minute = parseInt(parts[1]);
+ sec = parseInt(parts[2]);
+ if(ampm == true)
+ {
+ amstr = parts[3];
+ var am_valid = (amstr == 'AM' || amstr == 'PM');
+ if(am_valid && hour > 12) valid = false;
+ if(amstr == 'PM' && hour <= 12) hour = hour + 12;
+ if(hour == 24) hour = 0;
+ if(!am_valid) valid = false;
+ }
+ valid = valid && (hour > -1 && hour < 24);
+ valid = valid && (minute > -1 && minute < 60);
+ valid = valid && (sec > -1 && sec < 60);
+ return valid;
+}
+
+function ValidCustomName(name_str)
+{
+ if (trim(name_str) == '') return false;
+ var re = new RegExp('^[a-zA-Z0-9_]{1,}$');
+ if (name_str.match(re)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+function ValidThemeName(name_str)
+{
+ if (trim(name_str) == '') return false;
+ var re = new RegExp('^[a-zA-Z0-9-_]{1,}$');
+ if (name_str.match(re)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+function DaysInMonth(month,year)
+{
+ timeA = new Date(year, month,1);
+ timeDifference = timeA - 86400000;
+ timeB = new Date(timeDifference);
+ return timeB.getDate();
+}
+
+function ValidDate(date_str)
+{
+ var valid = true;
+
+ if( trim(date_str) == '' ) return true; // is valid in case if not entered
+ parts = date_str.split(/\s*\D\s*/);
+
+ year = parts[yearpos-1];
+ month = parts[monthpos-1];
+ day = parts[daypos-1];
+
+ valid = (year>0);
+ valid = valid && ((month>0) && (month<13));
+ valid = valid && (day<DaysInMonth(month,year)+1);
+ return valid;
+}
+
+function trim(str)
+{
+ return str.replace(/(^\s*)|(\s*$)/g,'');
+}
+
+function ValidateNumber(aValue, aNumberType)
+{
+ var valid = true;
+ if( trim(aValue) == '' ) return true;
+ return (parseInt(aValue) == aValue);
+}
+
+function OpenEditor(extra_env,TargetForm,TargetField)
+{
+ var url = '$editor_url';
+
+ url = url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup';
+ if(extra_env.length>0)
+ url = url+extra_env;
+
+ window.open(url,"html_edit","width=800,height=575,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+}
+
+function BitStatus(Value,bit)
+{
+ var val = Math.pow(2,bit);
+ if((Value & val))
+ {
+ return 1;
+ }
+ else
+ return 0;
+}
+
+function FlipBit(ValueName,Value,bit)
+{
+ var val = Math.pow(2,bit);
+ //alert('Setting bit ['+bit+'] of var ['+ValueName+'] with current value ['+Value+']');
+ if(BitStatus(Value,bit))
+ {
+ Value = Value - val;
+ }
+ else
+ Value = Value + val;
+ session_val(ValueName,Value);
+}
+
+function PerPageSelected(Value,PageCount)
+{
+ if(Value==PageCount)
+ {
+ return 2;
+ }
+ else
+ return 0;
+}
+
+function RadioIsSelected(Value1,Value2)
+{
+ if(Value1 == Value2)
+ {
+ return 2;
+ }
+ else
+ return 0;
+}
+
+function OpenItemSelector(envstr)
+{
+ //alert(envstr);
+ window.open('$item_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+}
+
+function OpenUserSelector(CheckIdField,Checks,envstr)
+{
+ if(Checks) var retval = Checks.getItemList();
+ f = document.getElementById('userpopup');
+ if(f)
+ {
+ if(CheckIdField)
+ f.elements[CheckIdField].value = retval;
+ }
+ SessionPrepare('$user_select', envstr, 'userselect');
+}
+
+
+function SessionPrepare(url, get_str, window_name)
+{
+ var params = ExtractParams(get_str);
+
+ if(params['destform'])
+ {
+ if(params['destform'] == 'popup')
+ {
+ CreatePopup(window_name, url + '?' + get_str);
+ return true;
+ }
+ else
+ var frm = CreateFakeForm();
+ }
+ else
+ var frm = CreateFakeForm();
+
+ if(!frm) return false;
+ frm.destform.value = params['destform'];
+ params['destform'] = 'popup';
+ get_str = MergeParams(params);
+ CreatePopup(window_name);
+ frm.target = window_name;
+ frm.method = 'POST';
+ frm.action = url + '?' + get_str;
+ frm.submit();
+}
+
+function addField(form, type, name, value)
+{
+ // create field in form
+ var field = document.createElement("INPUT");
+ field.type = type;
+ field.name = name;
+ field.id = name;
+ field.value = value;
+ form.insertBefore(field, form.nextSibling);
+}
+
+function CreateFakeForm()
+{
+ if($submit_done == 0)
+ {
+ var theBody = document.getElementsByTagName("BODY");
+ if(theBody.length == 1)
+ {
+ var frm = document.createElement("FORM");
+ frm.name = "fake_form";
+ frm.id = "fake_form";
+ frm.method = "post";
+
+ theBody[0].insertBefore(frm, theBody[0].nextSibling);
+ addField(frm, 'hidden', 'submit_done', 1);
+ addField(frm, 'hidden', 'destform', '');
+ return document.getElementById('fake_form');
+ }
+ }
+ return false;
+}
+
+function CreatePopup(window_name, url, width, height)
+{
+ // creates a popup window & returns it
+ if(url == null && typeof(url) == 'undefined' ) url = '';
+ if(width == null && typeof(width) == 'undefined' ) width = 750;
+ if(height == null && typeof(height) == 'undefined' ) height = 400;
+
+
+ return window.open(url,window_name,'width='+width+',height='+height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no');
+}
+
+function ShowHelp(section)
+{
+ var frm = document.getElementById('help_form');
+ frm.section.value = section;
+ frm.method = 'POST';
+ CreatePopup('HelpPopup','$rootURL$admin/help/blank.html'); // , null, 600
+ frm.target = 'HelpPopup';
+ frm.submit();
+}
+
+function ExtractParams(get_str)
+{
+ // extract params into associative array
+ var params = get_str.split('&');
+ var result = Array();
+ var temp_var;
+ var i = 0;
+ var params_count = params.length;
+ while(i < params_count)
+ {
+ temp_var = params[i].split('=');
+ result[temp_var[0]] = temp_var[1];
+ i++;
+ }
+ return result;
+}
+
+function MergeParams(params)
+{
+ // join splitted params into GET string
+ var key;
+ var result = '';
+ for(key in params)
+ result += key + '=' + params[key] + '&';
+ if(result.length) result = result.substring(0, result.length - 1);
+ return result;
+}
+
+function show_props(obj, objName)
+{
+ var result = "";
+ for (var i in obj) {
+ result += objName + "." + i + " = " + obj[i] + "\\n";
+ }
+ return result;
+}
+
+function OpenGroupSelector(envstr)
+{
+ //alert(envstr);
+ SessionPrepare('$group_select', envstr, 'groupselect');
+ //window.open('$group_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+}
+
+function OpenCatSelector(envstr)
+{
+ //alert(envstr);
+ window.open('$cat_select?'+envstr,"catselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+}
+
+function openEmailPopup(envar,form,Checks)
+{
+ var email_url='$email_url';
+ var url = email_url+envar;
+
+ if(Checks.itemChecked())
+ {
+ f = document.getElementById(form);
+ if(f)
+ {
+ window.open('',"sendmail","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+ f.idlist.value = Checks.getItemList();
+ f.submit();
+ }
+ }
+}
+
+function OpenPhraseEditor(extra_env)
+{
+ //SessionPrepare('$phrase_edit', extra_env, 'phrase_edit');
+
+ var url = '$phrase_edit'+extra_env+'&destform=popup';
+ window.open(url,"phrase_edit","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
+}
+
+function set_window_title(\$title)
+{
+ var \$window = window;
+ if(\$window.parent) \$window = \$window.parent;
+ \$window.document.title = (main_title.length ? main_title + ' - ' : '') + \$title;
+}
+
+var env = '$env2';
+var SubmitFunc = false;
+
+</script>
+
+END;
+?>
Property changes on: branches/unlabeled/unlabeled-1.21.2/admin/include/mainscript.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.21
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment