Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 4:07 AM

in-portal

This file is larger than 256 KB, so syntax highlighting was skipped.
Index: trunk/kernel/parser.php
===================================================================
--- trunk/kernel/parser.php (revision 639)
+++ trunk/kernel/parser.php (revision 640)
@@ -1,3417 +1,3416 @@
<?php
$ItemTypes["category"]=1;
$ItemTables[1] = "Category";
$ParserFiles[] = "kernel/parser.php";
function m_ParseEnv($str = NULL)
{
global $m_var_list, $objConfig, $objCatList, $objLanguages, $objThemes;
if ($str != NULL)
{
$str = substr($str,1);
$pieces = explode("-", $str);
//echo "<PRE>";print_r($pieces);echo "</PRE>";
$m_var_list["cat"] = $pieces[0];
$m_var_list["p"] = $pieces[1];
$objCatList->Page = $m_var_list["p"];
$m_var_list["lang"] = $pieces[2];
$m_var_list["theme"] = $pieces[3];
}
else
{
$m_var_list["cat"]=0;
$m_var_list["p"] = 1;
$m_var_list["lang"] = $objLanguages->GetPrimary();
$m_var_list["theme"]= $objThemes->GetPrimaryTheme();
}
}
function m_BuildEnv()
{
global $m_var_list, $m_var_list_update;
$module_vars = Array('cat','p','lang','theme');
$ret = GenerateModuleEnv('m', $module_vars);
if( isset($GLOBALS['m_var_list_update']['cat']) ) unset($GLOBALS['m_var_list_update']['cat']);
return $ret;
}
function m_GetVar($name)
{
// get variable from template variable's list
global $m_var_list, $m_var_list_update;
return isset($m_var_list_update[$name]) ? $m_var_list_update[$name] : $m_var_list[$name];
}
function &LoadRelatedItems(&$Relations,&$RelatedItems,$ResourceId)
{
global $objItemTypes;
if(!is_object($Relations))
{
$Relations = new clsRelationshipList();
}
//$Relations->debuglevel = 2;
if ($ResourceId != '') {
$sql = sprintf("SELECT RelationshipId, Type, Enabled, Priority,
IF(TargetId = %1\$s, TargetId, SourceId) AS SourceId,
IF(TargetId = %1\$s, SourceId, TargetId) AS TargetId,
IF(TargetId = %1\$s, TargetType, SourceType) AS SourceType,
IF(TargetId = %1\$s, SourceType, TargetType) AS TargetType
FROM %%s", $ResourceId);
$where = "((SourceId=$ResourceId) OR (TargetId=$ResourceId AND Type=1)) AND Enabled=1";
$Relations->LoadRelated($where,"",$sql);
$ids = array();
if($Relations->NumItems()>0)
{
foreach($Relations->Items as $r)
{
if($r->Get("SourceId")==$ResourceId)
{
$ids[$r->Get("TargetType")][] = $r->Get("TargetId");
}
if($r->Get("TargetId")==$ResourceId && $r->Get("Type")==1)
{
$ids[$r->Get("SourceType")][] = $ResourceId;
}
}
foreach($ids as $ItemType=>$idlist)
{
$Item =& $objItemTypes->GetItem($ItemType);
$table = GetTablePrefix().$Item->Get("SourceTable");
if($ItemType!=1)
{
$cattable = GetTablePrefix()."CategoryItems";
$sql = "SELECT *,CategoryId FROM $table INNER JOIN $cattable ON ";
$sql .=" ($table.ResourceId=$cattable.ItemResourceId) WHERE $table.Status=1 AND PrimaryCat=1 ";
$sql .=" AND ResourceId IN (".implode(",",$ids[$ItemType]).")";
}
else
{
$sql = "SELECT *,CategoryId FROM $table ";
$sql .="WHERE $table.Status=1 ";
$sql .=" AND ResourceId IN (".implode(",",$ids[$ItemType]).")";
}
// echo $sql."<br>\n";
$RelatedItems->Query_Item($sql,-1,-1,$ItemType);
}
}
}
}
/*
@description: Inserts the html from a remote source
@attrib: _url:: Remote URL to include
@attrib: _StartPos:: Numeric start point of text to include, or string match
@attrib: _EndPos:: Numeric end point of text to include, or string match
@example: <inp:m_insert_url _Url="http://www.google.com" _StartPos="\<center\>" _EndPos="\</center\>" />
*/
function m_insert_url($attribs=array())
{
global $pathtoroot;
$url = $attribs["_url"];
$StartPos = $attribs["_startpos"];
$EndPos = $attribs["_endpos"];
$socket = new Socket($url,0,NULL);
$txt = $socket->socket_read_all();
$lines = explode("\n",$txt);
$txt = substr($txt,strpos($txt,"<"));
$tmp = strtolower($txt);
$bodypos = strpos($tmp,"<body");
if(strlen($bodypos)>0)
{
$head = substr($txt,0,$bodypos-1);
$body = substr($txt,$bodypos);
if(substr($tmp,-7)=="</html>")
$body = substr($body,0,-7);
}
else
$body = $txt;
if(strlen($body))
{
if(strlen($StartPos))
{
if(!is_numeric($StartPos))
{
$start = strpos($body,$StartPos);
}
else
$start = (int)$StartPos;
}
else
$start = 0;
if(strlen($EndPos))
{
if(!is_numeric($EndPos))
{
$end = strpos($body,$EndPos,$start) + strlen($EndPos);
}
else
$end = (int)$EndPos;
}
else
$end = NULL;
$o = substr($body,$start,$end-$start);
}
return $o;
}
/*
@description: Displays a template depending on the login status of the user
@attrib: _logintemplate:tpl: template to display when the user is NOT logged in
@attrib: _LoggedinTemplate:tpl: template to display when the user is logged in
@example: <inp:m_loginbox _LoginTemplate="right_login" _LoggedInTemplate="right_loggedin" />
*/
function m_loginbox($attribs = array())
{
global $var_list, $objSession, $objUsers, $objTemplate;
$userid = $objSession->Get("PortalUserId");
$groupid = $objSession->Get("GroupId");
if ($userid == 0)
{
if (strlen($attribs["_logintemplate"]))
$t = $objTemplate->ParseTemplate($attribs["_logintemplate"]);
return $t;
}
else
{
$user =& $objUsers->GetItem($userid);
if (strlen($attribs["_loggedintemplate"]))
$t = $user->ParseTemplate($attribs["_loggedintemplate"]);
return $t;
}
}
/*
@description: result of suggest site action
*/
function m_suggest_result()
{
global $suggest_result;
return $suggest_result;
}
/*
@description: result of subscribe to mailing list action
*/
function m_subscribe_result()
{
global $SubscribeResult;
if(strlen($SubscribeResult))
return language($SubscribeResult);
return "";
}
/*
@description: email address of user subscribing to mailing list
*/
function m_subscribe_address()
{
global $SubscribeAddress;
if(strlen($SubscribeAddress))
return $SubscribeAddress;
return "";
}
/*
@description: Error message of subscribe to mailing list action
*/
function m_subscribe_error()
{
global $SubscribeError;
if(strlen($SubscribeError))
return language($SubscribeError);
return "";
}
/*
@description: Displays a prompt for a form field
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _LangText:lang: Language var to use for field label
@attrib: _plaintext:: Plain text to use for field label (langtext is used by default if both are set)
@attrib: _Template:tpl: template used to display the field label (if not set "<inp:form_prompt />" is used
@attrib: _ErrorTemplate:tpl: If the field is in an error state (ie missing input) this template is used. Will default to the normal template if not set
*/
function m_form_prompt($attribs = array())
{
global $FormError, $objTemplate, $objConfig;
$form = strtolower($attribs["_form"]);
$field = strtolower($attribs["_field"]);
if($form=="m_register" && ($field=="password" || $field=="passwordverify") && $objConfig->Get("User_Password_Auto"))
{
$o = "";
}
else
{
$t = $attribs["_template"];
if(!strlen($t))
{
$templateText = "<inp:form_prompt />";
}
$e = $attribs["_errortemplate"];
if(!strlen($e))
$e = $t;
if(strlen($attribs["_langtext"]))
{
$txt = language($attribs["_langtext"]);
}
else
$txt = $attribs["_plaintext"];
if (strtolower($field) == "dob")
{
if (isset($FormError[strtolower($form)][strtolower($field."_day")]) || isset($FormError[strtolower($form)][strtolower($field."_month")]) || isset($FormError[strtolower($form)][strtolower($field."_year")]))
$rawtext = $objTemplate->GetTemplate($e, true);
}
if(isset($FormError[strtolower($form)][strtolower($field)]))
{
$rawtext = $objTemplate->GetTemplate($e);
}
elseif (strlen($t))
$rawtext = $objTemplate->GetTemplate($t);
if(is_object($rawtext))
{
$src = $rawtext->source;
$o = str_replace("<inp:form_prompt />",$txt, $src);
}
else
$o = str_replace("<inp:form_prompt />", $txt, $templateText);
}
return $o;
}
/*
@description: Returns text if system is configured to use auto-generated passwords
@attrib:_LangText:lang:Language tag to return
@attrib:_PlainText::Plain text to return (_LangText takes precedece)
@attrib:_Value:bool:Auto Password setting value to match
*/
function m_autopassword($attribs = array())
{
global $objConfig;
if($attribs["_value"]=="true" || $attribs["_value"]==1)
{
$IsAuto = $objConfig->Get("User_Password_Auto");
}
else
{
$IsAuto = !$objConfig->Get("User_Password_Auto");
}
if($IsAuto)
{
if(strlen($attribs["_langtext"]))
{
$ret = language($attribs["_langtext"]);
}
else
$ret = $attribs["_plaintext"];
if(!$ret)
return "true";
}
return $ret;
}
/*
@description: checks if field specified is equals to value specified
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Value:: Field value to compare to
@example: <inp:m_field_equals _field="topic_subject" _Form="edit_topic" _Value="test" />true</inp:m_field_equals>
*/
function m_field_equals($attribs = array())
{
global $FormValues;
//print_pre($attribs);
$form = $attribs["_form"];
$field = $attribs["_field"];
if(isset($_POST[$field]))
{
$value = $_POST[$field];
}
else
$value = $FormValues[$form][$field];
//echo "POST_VALUE: [$value] vs USER_VALUE: [".$attribs['_value']."]<br>";
return $value == $attribs['_value'] ? 1 : '';
}
/*
@description: creates an INPUT tag for a form field. All extra attributes are passed to the INPUT tag
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _ForgetValue:bool: if true, forget value
@attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting
@example: <inp:m_form_input type="text" class="input" style="width:600px;" _field="topic_subject" _Form="edit_topic" _Required="1" />
*/
function m_form_input($attribs = array())
{
global $FormValues, $objConfig;
$html_attribs = ExtraAttributes($attribs);
$form = $attribs["_form"];
$field = strtolower($attribs["_field"]);
if(isset($_POST[$field]) && $attribs['_forgetvalue'] != 1)
{
$value = $_POST[$field];
}
else {
if ($attribs['_forgetvalue'] != 1) {
$value = $FormValues[$form][$field];
}
}
//echo $form.".".$field."=".$value." = ".$attribs['_forgetvalue']."<br>\n";
if($form=="m_register" && ($field=="password" || $field=="passwordverify") && $objConfig->Get("User_Password_Auto"))
{
$ret = "";
}
else
{
$ret = "<INPUT ".$html_attribs." name=\"$field\" VALUE=\"$value\" />";
if($attribs["_required"])
$ret .= "<input type=hidden name=\"required[]\" VALUE=\"$field\" />";
if($attribs["_custom"])
$ret .= "<input type=hidden name=\"custom[]\" VALUE=\"$field\" />";
}
return $ret;
}
/*
@description: creates an INPUT tag (type checkbox) for a form field. All extra attributes are passed to the INPUT tag
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Value:bool: If true, the radio button is CHECKED
@attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting
@attrib: _Custom:bool: If set, handled as a custom field
@example: <inp:m_form_checkbox _field="owner_notify" _Form="edit_topic" />
*/
function m_form_checkbox($attribs = array())
{
global $FormValues, $objConfig;
$html_attribs = ExtraAttributes($attribs);
$form = $attribs["_form"];
$field = strtolower($attribs["_field"]);
if(isset($_POST[$field]))
{
$value = (int)$_POST[$field];
if($value==1)
$checked = " CHECKED";
}
else
{
$value = (int)$FormValues[$form][$field];
if($value==1)
$checked=" CHECKED";
}
//echo $form.".".$field."=".$value."<br>\n";
$ret = "<INPUT TYPE=\"checkbox\" $html_attribs name=\"$field\" VALUE=\"1\" $checked />";
if($attribs["_required"])
$ret .= "<input type=hidden name=\"required[]\" VALUE=\"$field\" />";
if($attribs["_custom"])
$ret .= "<input type=hidden name=\"custom[]\" VALUE=\"$field\" />";
return $ret;
}
/*
@description: creates an INPUT tag (type radio) for a form field. All extra attributes are passed to the INPUT tag
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Value:: Value assigned to radio button. If the form field value matches this attribute, the radio button is CHECKED
@attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting
@attrib: _Custom:bool: If set, handled as a custom field
@example: <inp:m_form_checkbox _field="owner_notify" _Form="edit_topic" />
*/
function m_form_radio($attribs = array())
{
global $FormValues, $objConfig;
$html_attribs = ExtraAttributes($attribs);
$form = $attribs["_form"];
$field = strtolower($attribs["_field"]);
$val = $attribs["_value"];
if(isset($_POST[$field]))
{
$value = (int)$_POST[$field];
if($value==1)
$checked = " CHECKED";
}
else
{
$value = (int)$FormValues[$form][$field];
if($value==$val)
$checked=" CHECKED";
}
//echo $form.".".$field."=".$value."<br>\n";
$ret = "<INPUT TYPE=\"radio\" $html_attribs name=\"$field\" VALUE=\"$val\" $checked />";
if($attribs["_required"])
$ret .= "<input type=hidden name=\"required[]\" VALUE=\"$field\" />";
if($attribs["_custom"])
$ret .= "<input type=hidden name=\"custom[]\" VALUE=\"$field\" />";
return $ret;
}
/*
@description: returns the value for a form field. This may be defaulted by the system or set by a previus submit (as in an error condition)
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@example: <inp:m_form_value _field="owner_notify" _Form="edit_topic" />
*/
function m_form_value($attribs = array())
{
global $FormValues;
$form = $attribs["_form"];
$field = strtolower($attribs["_field"]);
if(isset($_POST[$field]))
{
$value = stripslashes($_POST[$field]);
}
else
$value = stripslashes($FormValues[$form][$field]);
//echo "<pre>"; print_r($FormValues); echo "</pre>";
return $value;
}
/*
@description: creates an form OPTION tag for a form SELECT tag.
All extra attributes are passed to the OPTION tag.
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Value:: Value to use for this option (ie the value attribute) If the current value of the select
field is the same as this attribute, then this option will be set SELECTED.
@attrib: _langtext:lang: language tag to display for this option in the SELECT dropdown
@attrib: _plaintext:: plain text to display for this option in the SELECT dropdown (if _langtext is set, it is used instead of _plaintext)
@example: <inp:m_form_option _value="3321" _field="formfield" _form="formname" _langtext="lu..."
*/
function m_form_option($attribs = array())
{
global $FormValues;
$html_attribs = ExtraAttributes($attribs);
$field = $attribs["_field"];
$val = $attribs["_value"];
if(isset($_POST[$field]))
{
$value = $_POST[$field];
}
else
{
$value = $FormValues[$attribs['_form']][$field];
}
$selected = ($val == $value)? "SELECTED" : "";
if(strlen($attribs["_langtext"]))
{
$txt = language($attribs["_langtext"]);
}
else
$txt = $attribs["_plaintext"];
$o = "<OPTION $html_attribs VALUE=\"$val\" $selected>$txt</OPTION>";
return $o;
}
/*
@description: creates an form TEXTAREA field. All extra attributes are passed to the TEXTAREA tag
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting
@attrib: _Custom:bool: If set, handled as a custom field
@example: <inp:m_form_textarea class="textarea" _field="bb_signature" _Form="bb_profile" ID="textbody" style="width:300px;" ROWS=10 COLS=65 WRAP="VIRTUAL" />
*/
function m_form_textarea($attribs = array())
{
global $FormValues;
$html_attribs = ExtraAttributes($attribs);
$field = $attribs["_field"];
$form = $attribs["_form"];
if(isset($_POST[$field]))
{
$value = stripslashes($_POST[$field]);
}
else
$value = stripslashes($FormValues[$attribs["_form"]][$field]);
$ret = "<TEXTAREA NAME=\"$field\" $html_attribs>$value</TEXTAREA>";
if($attribs["_required"])
$ret .= "<input type=hidden name=required[] VALUE=\"$field\" />";
if($attribs["_custom"])
$ret .= "<input type=hidden name=\"custom[]\" VALUE=\"$field\" />";
return $ret;
}
/*
@description: creates an form field to upload images. (INPUT type=file) All extra attributes are passed to the INPUT tag
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
@attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting
@attrib: _ImageTypes:: Comma-separated list of file extensions allowed
@attrib: _Thumbnail:bool: If true, image is treated as a thumbnail
@attrib: _ImageName:: System name of image being uploaded
@attrib: _MaxSize:int: Maximum size of image to upload, or 0 to allow all
*/
function m_form_imageupload($attribs = array())
{
$html_attribs = ExtraAttributes($attribs);
$field = $attribs["_field"];
$form = $attribs["_form"];
$TypesAllowed = $attribs["_imagetypes"];
$isthumb = (int)$attribs["_thumbnail"];
$imgname = $attribs["_imagename"];
$maxsize = $attribs["_maxsize"];
$ret = "<INPUT $html_attribs TYPE=file NAME=\"$field\" >";
$ret .= "<INPUT TYPE=HIDDEN name=\"isthumb[$field]\" VALUE=\"$isthumb\">";
$ret .= "<INPUT TYPE=HIDDEN name=\"imagetypes[$field]\" VALUE=\"$TypesAllowed\">";
$ret .= "<INPUT TYPE=HIDDEN name=\"imagename[$field]\" VALUE=\"$imgname\">";
$ret .= "<INPUT TYPE=HIDDEN name=\"maxsize[$field]\" VALUE=\"$maxsize\">";
if($attribs["_required"])
$ret .= "<input type=hidden name=required[] VALUE=\"$field\" />";
return $ret;
}
/*
@description: Returns the error text for a form field, or nothing if no error exists for the field
@attrib: _Form:: Form name for the field
@attrib: _Field:: Field Name
*/
function m_form_error($attribs = array())
{
global $FormError;
$form = $attribs["_form"];
$field = $attribs["_field"];
return $FormError[$form][$field];
}
/**
@description: Provides a simple solution for displaying a language flag when a form has an error. Generic and limited to 1 language vairable.
@attrib: _Form:: Form name for the field
*/
function m_form_has_errors($attribs = array())
{
// shows specified template once if form has error(-s)
global $FormError;
$f = $attribs["_form"];
$ret = is_array($FormError[$f]);
if(!$ret) return '';
return isset($attribs["_asif"]) ? true : language('lu_errors_on_form');
}
/**
@description: Lists form errors for all fields in a form
@attrib: _Form:: Form name for the field
@attrib: _ItemTemplate:tpl: Template used to display each form error (if not set, "<inp:form_error />" is used)
*/
function m_list_form_errors($attribs = array())
{
global $FormError, $content_set, $objTemplate;
$t = $attribs["_itemtemplate"];
if(!strlen($t))
$templateText = "<inp:form_error />";
$f = $attribs["_form"];
$o = "";
if (strlen($t))
{
$rawtext = $objTemplate->GetTemplate($t, true);
$src = $rawtext->source;
}
else
$src = $templateText;
//echo $f."<br>";
//echo $t."<br>";
// echo "<PRE>"; print_r($FormError); echo "</pre>";
if(is_array($FormError[$f]))
{
foreach($FormError[$f] as $e)
{
$o .= str_replace("<inp:form_error />",$e, $src);
}
}
if(!strlen($o))
$content_set = 0;
return $o;
}
function m_form_load_values($FormName,$IdValue)
{
global $FormValues, $objUsers, $objSession, $objConfig;
switch($FormName)
{
case "m_acctinfo":
$u =& $objUsers->GetItem($IdValue);
$FormValues[$FormName]["username"] = $u->Get("Login");
//$FormValues[$FormName]["password"] = $u->Get("Password");
//$FormValues[$FormName]["passwordverify"] = $u->Get("Password");
$FormValues[$FormName]["password"] = "";
$FormValues[$FormName]["passwordverify"] = "";
$FormValues[$FormName]["firstname"] = $u->Get("FirstName");
$FormValues[$FormName]["lastname"] = $u->Get("LastName");
$FormValues[$FormName]["email"] = $u->Get("Email");
$FormValues[$FormName]["phone"] = $u->Get("Phone");
$FormValues[$FormName]["street"] = $u->Get("Street");
$FormValues[$FormName]["city"] = $u->Get("City");
$FormValues[$FormName]["state"] = $u->Get("State");
$FormValues[$FormName]["zip"] = $u->Get("Zip");
$FormValues[$FormName]["country"] = $u->Get("Country");
// $FormValues[$FormName]["dob"] = LangDate($u->Get("dob"));
$FormValues[$FormName]["dob_day"] = date("d", $u->Get("dob"));
$FormValues[$FormName]["dob_year"] = date("Y", $u->Get("dob"));
$FormValues[$FormName]["dob_month"] = date("m", $u->Get("dob"));
$u->LoadCustomFields();
if(is_array($u->CustomFields->Items))
{
foreach($u->CustomFields->Items as $f)
{
$FormValues[$FormName][$f->Get("FieldName")] = $f->Get("Value");
}
}
break;
case "m_profile":
$u =& $objUsers->GetItem($IdValue);
if(is_object($u))
{
$FormValues[$FormName]["pp_firstname"] = $objSession->GetPersistantVariable("pp_firstname");
$FormValues[$FormName]["pp_lastname"] = $objSession->GetPersistantVariable("pp_lastname");
$FormValues[$FormName]["pp_dob"] = $objSession->GetPersistantVariable("pp_dob");
$FormValues[$FormName]["pp_email"] = $objSession->GetPersistantVariable("pp_email");
$FormValues[$FormName]["pp_phone"] = $objSession->GetPersistantVariable("pp_phone");
$FormValues[$FormName]["pp_street"] = $objSession->GetPersistantVariable("pp_street");
$FormValues[$FormName]["pp_city"] = $objSession->GetPersistantVariable("pp_city");
$FormValues[$FormName]["pp_state"] = $objSession->GetPersistantVariable("pp_state");
$FormValues[$FormName]["pp_zip"] = $objSession->GetPersistantVariable("pp_zip");
$FormValues[$FormName]["pp_country"] = $objSession->GetPersistantVariable("pp_country");
}
break;
case "m_simplesearch":
$FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords");
break;
case "m_simple_subsearch":
$FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords");
break;
}
}
/*
@description: Generates the ACTTION property for a FORM tag used by In-Portal
@attrib: _Template:tpl: If set, this is the template the form submits to (default is the current template)
@attrib: _Form:: The form name<br>Possible Values:
<UL>
<LI>login: user login
<LI>logout: user logout
<LI>forgotpw: Form to prompt the user for forgotten password information
<LI>forgotpw_confirm: confirmation form for forgotpw
<LI>suggest: form to suggest the site to a friend
<LI>suggest_confirm: form to confirm suggestion of the site to a friend
<LI>m_subscribe: form to subscribe to the mailing list
<LI>subscribe_confirm: form to confirm subscription to the mailing list
<LI>m_unsubscribe: form to unsubscribe from the mailing list
<LI>unsubscribe_confirm: form to confirm un-subscription from the mailing list
<LI>m_acctinfo: user account information
<LI>m_profile: system-level profile information
<LI>m_register: New User registration form
<LI>m_addcat: Suggest Category form
<LI>m_addcat_confirm: Confirmation for add category
<LI>m_simplesearch: Perform a simple search
<LI>m_simple_subsearch: Search within results
<LI>m_adv_searchtype: Form to select type of advanced search
<LI>m_adv_subsearch: Advanced Search
<LI>error_access: form displayed on the access denied template
<LI>error_template: Form displayed on the template error page
<LI>m_set_theme: Form displayed for theme selection
</UL>
@attrib: _SubscribeTemplate:tpl: The destination template with "m_subscribe", "subscribe_confirm", "unsubscribe_confirm" _Form actions. Can be reused in other scenarios as programmed.
@attrib: _UnSubscribeTemplate:tpl: The destination template for "m_subscribe" _Form action. Can be reused in other scenarios as programmed.
@attrib: _ConfirmTemplate:tpl: The destination template for "m_unsubscribe", "suggest" _Form actions. Can be reused in other scenarios as programmed.
@attrib: _DestTemplate:tpl: The destination template for "suggest_confirm", "suggest" _Form actions. Can be reused in other scenarios as programmed.
@attrib: _ErrorTemplate:tpl: The destination template extensively used in most of _Form actions in case of error.
@attrib: _Referer:bool: The destination template will be taken from referer page we can from.
@example: <FORM enctype="multipart/form-data" method="POST" NAME="article_review" ACTION="<inp:m_form_action _Form="register" _confirm="join_confirm" />">
*/
function m_form_action($attribs = array())
{
global $var_list, $var_list_update, $m_var_list_update, $objSession, $objConfig, $objCatList;
$target_template = $attribs["_template"];
if(strlen($target_template))
{
$var_list_update["t"] = $target_template;
}
else
$var_list_update["t"] = $var_list["t"];
$ret = "";
$form = strtolower($attribs["_form"]);
switch($form)
{
case "login":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_login";
if($attribs["_successtemplate"])
{
$ret .= "&dest=".$attribs["_successtemplate"];
}
else
if(strlen($var_list["dest"]))
$ret .= "&dest=".$var_list["dest"];
}
break;
case "logout":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_logout";
break;
case "forgotpw":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
if(strlen($attribs["_errortemplate"]))
{
$err = $attribs["_errortemplate"];
}
else
$err = $var_list["t"];
$ret = GetIndexURL(2)."?env=".BuildEnv()."&Action=m_forgotpw&error=$err";
}
break;
case "forgotpw_confirm":
$ret = GetIndexURL(2)."?env=".BuildEnv();
break;
case "suggest":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_suggest_email";
if(strlen($attribs["_confirmtemplate"])>0)
{
$ret .= "&Confirm=".$attribs["_confirmtemplate"];
}
if(strlen($Dest))
{
$ret .= "&DestTemplate=$Dest";
}
else
{
if(strlen($attribs["_confirmtemplate"])>0)
$ret .="&DestTemplate=".$var_list["t"];
}
if(strlen($attribs["_errortemplate"])>0)
{
$ret .= "&Error=".$attribs["_errortemplate"];
}
}
break;
case "suggest_confirm":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
if(strlen($_GET["DestTemplate"]))
{
$var_list_update["t"] = $_GET["DestTemplate"];
}
else
$var_list_update["t"] = "index";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
break;
case "m_subscribe":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_subscribe_confirm";
if(strlen($attribs["_subscribetemplate"]))
{
$ret .="&Subscribe=".$attribs["_subscribetemplate"];
}
if(strlen($attribs["_unsubscribetemplate"])>0)
{
$ret .= "&Unsubscribe=".$attribs["_unsubscribetemplate"];
}
if(strlen($attribs["_errortemplate"])>0)
{
$ret .= "&Error=".$attribs["_errortemplate"];
}
}
break;
case "subscribe_confirm":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_subscribe";
if($attribs["_subscribetemplate"])
$ret .= "&Subscribe=".$attribs["_subscribetemplate"];
break;
case "unsubscribe_confirm":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_unsubscribe";
if($attribs["_subscribetemplate"])
$ret .= "&Subscribe=".$attribs["_subscribetemplate"];
break;
case "m_unsubscribe":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_unsubscribe";
if(strlen($attribs["_confirmtemplate"])>0)
{
$ret .= "&Confirm=".$attribs["_confirmtemplate"];
}
if(strlen($Dest))
{
$ret .= "&DestTemplate=$Dest";
}
else
{
if(strlen($attribs["_confirmtemplate"])>0)
$ret .="&DestTemplate=".$var_list["t"];
}
}
if(strlen($attribs["_confirmtemplate"])>0)
{
$ret .="&ErrorTemplate=".$attribs["_confirmtemplate"];
}
break;
case "m_unsubscribe_confirm":
$ret = GetIndexURL(2)."?env=" . BuildEnv();
break;
case "m_acctinfo":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_acctinfo&UserId=".$objSession->Get("PortalUserId");
m_form_load_values($form, $objSession->Get("PortalUserId"));
break;
case "m_profile":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_profile&UserId=".$objSession->Get("PortalUserId");
m_form_load_values($form,$objSession->Get("PortalUserId"));
break;
case "m_set_theme":
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_set_theme";
break;
case "m_register":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_register";
switch ($objConfig->Get("User_Allow_New"))
{
case "1":
if(strlen($attribs["_confirmtemplate"]) && $objConfig->Get("User_Password_Auto"))
$_dest = "&dest=".$attribs["_confirmtemplate"];
else
$_dest = "&dest=".$attribs["_logintemplate"];
break;
case "2":
if(strlen($attribs["_notallowedtemplate"]))
$_dest = "&dest=".$attribs["_notallowedtemplate"];
break;
case "3":
if(strlen($attribs["_pendingtemplate"]))
$_dest = "&dest=".$attribs["_pendingtemplate"];
break;
}
if (strlen($_dest))
$ret .= $_dest;
}
break;
case "register_confirm":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
break;
case "m_addcat":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$action = "m_add_cat";
if ($objSession->HasCatPermission("CATEGORY.ADD.PENDING"))
{
if(strlen($attribs["_confirmpending"]))
{
$ConfirmTemplate = $attribs["_confirmpending"];
}
else
$ConfirmTemplate = $attribs["_confirm"];
$action="m_add_cat_confirm";
}
if ($objSession->HasCatPermission("CATEGORY.ADD"))
{
$ConfirmTemplate = $attribs["_confirm"];
$action="m_add_cat_confirm";
}
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=$action";
if(strlen($ConfirmTemplate))
$ret .= "&Confirm=$ConfirmTemplate";
if (strlen($attribs["_mod_finishtemplate"])) {
$CurrentCat = $objCatList->CurrentCategoryID();
if((int)$CurrentCat>0)
{
$c = $objCatList->GetCategory($CurrentCat);
//will prefix the template with module template root path depending on category
$ids = $c->GetParentIds();
$tpath = GetModuleArray("template");
$roots = GetModuleArray("rootcat");
// get template path of module, by searching for moudle name
// in this categories first parent category
// and then using found moudle name as a key for module template paths array
$path = $tpath[array_search ($ids[0], $roots)];
$t = $path . $attribs["_mod_finishtemplate"];
}
else {
$t = $attribs["_mod_finishtemplate"]; //Just in case
}
}
else {
$t = $attribs["_finishtemplate"];
}
$ret .="&DestTemplate=".$t;
}
break;
case "m_addcat_confirm":
$target_template = $_GET["DestTemplate"];
if(strlen($target_template))
{
$var_list_update["t"] = $target_template;
}
else
$var_list_update["t"] = $var_list["t"];
$ret = GetIndexURL(2)."?env=".BuildEnv();
break;
case "m_simplesearch":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_simple_search";
if(strlen($attribs["_errortemplate"]))
$ret.= "&Error=".$attribs["_errortemplate"];
m_form_load_values($form, 0);
}
break;
case "m_simple_subsearch":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_simple_subsearch";
m_form_load_values($form,0);
}
break;
case "m_adv_search_type":
if(!$objSession->SessionEnabled())
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_advsearch_type";
m_form_load_values($form,0);
}
break;
case "m_adv_search":
$SearchType = $_GET["type"];
if(!is_numeric($SearchType))
$SearchType = $_POST["itemtype"];
if(!$objSession->SessionEnabled() && !strlen($SearchType))
{
$var_list_update["t"] = "error_session";
$ret = GetIndexURL(2)."?env=" . BuildEnv();
}
else
{
$ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_adv_search&type=$SearchType";
m_form_load_values($form,0);
}
break;
case "error_access":
$target_template = $_GET["DestTemplate"];
if(!strlen($target_template))
$target_template="login";
$var_list_update["t"] = $target_template;
$ret = GetIndexURL(2)."?env=" . BuildEnv();
break;
case "error_template":
$target_template = $_GET["DestTemplate"];
if($attribs["_referer"] == 1)
{
$target_template = "_referer_";
}
elseif (!strlen($target_template))
{
$target_template = "index";
}
$var_list_update["t"] = $target_template;
// $m_var_list_update["cat"]=0;
$ret = GetIndexURL(2)."?env=".BuildEnv();
break;
}
return $ret;
}
/*
@description: creates a URL to allow the user to log out. Accepts the same attributes as m_template_link
*/
function m_logout_link($attribs)
{
$ret = m_template_link($attribs)."&Action=m_logout";
return $ret;
}
/*
@description: returns a URL to the current theme
@attrib: _page:: Additional address to be added to the end of the theme URL
*/
function m_theme_url($attribs=array())
{
global $objConfig,$objSession, $objThemes, $CurrentTheme;
if(!is_object($CurrentTheme))
$CurrentTheme = $objThemes->GetItem($m_var_list["theme"]);
$theme_url = "http://". ThisDomain().$objConfig->Get("Site_Path")."themes/".$CurrentTheme->Get("Name")."/";
if($attribs["_page"])
{
if ($attribs["_page"] != 'current')
{
$theme_url .= $attribs["_page"];
}
else
{
$theme_url = "http://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv();
}
}
return $theme_url;
}
/*
@description: returns a URL to the current theme
*/
function m_current_page_url($attribs=array())
{
global $objConfig,$objSession;
$theme_url = "http://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv();
return $theme_url;
}
/*
@description: returns a URL to the current theme
@attrib: _fullpath:bool: Append the title with the full path of the current category
@attrib: _currentcategory:bool: Append the title with the current category
@attrib: _catfield:: If _currentcategory is used, this attribute determines which category field to use (Name, Description, etc) Defaults to Name
*/
function m_page_title($attribs = array())
{
global $objConfig, $objCatList;
$ret = $objConfig->Get("Site_Name");
if($attribs["_fullpath"] || $attribs["_currentcategory"])
{
$CurrentCat = $objCatList->CurrentCategoryID();
if((int)$CurrentCat>0)
{
$c = $objCatList->GetCategory($CurrentCat);
if($attribs["_fullpath"])
{
$path = $c->Get("CachedNavbar");
if(strlen($path))
$ret .= " - ".$path;
}
else
{
if($attribs["_currentcategory"])
{
$f = $attribs["_catfield"];
if(!strlen($f))
$f = "Name";
$ret .= " - ".$c->Get($f);
}
}
}
}
$ret = stripslashes($ret);
return $ret;
}
/*
@description: list all active themes
@attrib: _ItemTemplate:tpl: Template to display each theme in the list
*/
function m_list_themes($attribs=array())
{
global $objThemes;
$t = $attribs["_itemtemplate"];
if(strlen($t))
{
$objThemes->Clear();
$objThemes->LoadThemes("Enabled=1","PrimaryTheme DESC");
foreach($objThemes->Items as $theme)
{
$o .= $theme->ParseTemplate($t);
}
}
return $o;
}
/*
@description: display text based on the user's language
@attrib: _Phrase:lang: label to replace with language-specific text
@example: <inp:m_language _Phrase="lu_hello_world" />
*/
function m_language($attribs)
{
global $objSession, $objLanguages, $ForceLanguage;
$phrase = $attribs["_phrase"];
$LangId = (int)$ForceLanguage;
if(strlen($phrase))
{
$lang = $attribs["_language"];
if(strlen($lang))
{
$l = $objLanguages->GetItemByField("PackName",$lang);
if(is_object($l))
{
$LangId = $l->Get("LanguageId");
}
}
return language($phrase,$LangId);
}
else
return "";
}
/*
@description: Creates a URL used to set the current language for a user
@attrib: _language:: Language to set (this value should be the language Pack Name)
*/
function m_setlang_link($attribs)
{
global $m_var_list_update, $objSession,$objLanguages;
$lang = $attribs["_language"];
if(strlen($lang))
{
$l = $objLanguages->GetItemByField("PackName",$lang);
if(is_object($l))
$LangId = $l->Get("LanguageId");
}
else
$LangId=$objSession->Get("Language");
if($LangId)
{
$m_var_list_update["lang"] = $LangId;
$ret = GetIndexURL()."?env=".BuildEnv();
unset($m_var_list_update["lang"]);
}
else
$ret = "";
return $ret;
}
/*
@description: list all active languages
@attrib: _ItemTemplate:tpl: Template to display each language in the list
*/
function m_list_languages($attribs)
{
global $objLanguages, $content_set;
$sql = "SELECT * FROM ".GetTablePrefix()."Language WHERE Enabled=1";
$objLanguages->Clear();
$objLanguages->Query_Item($sql);
if($objLanguages->NumItems()>0)
{
foreach($objLanguages->Items as $l)
$o .= $l->ParseTemplate($attribs["_itemtemplate"]);
}
else
$content_set=0;
return $o;
}
/*
@description: returns the date format for a language
@attrib: _lang:: Pack Name of language to use. The current language is used if this is not set
*/
function m_lang_dateformat($attribs=array())
{
global $objLanguages, $objSession;
$lang = $attribs["_lang"];
if(!strlen($lang))
{
$LangId = $objSession->Get("Language");
$l = $objLanguages->GetItem($LangId);
}
else
{
$l = $objLanguages->GetItemByField("PackName",$lang);
}
$fmt = GetDateFormat($LangId);
$fmt = GetStdFormat($fmt);
return $fmt;
}
/*
@description: returns a language field value
@attrib: _Field:: Language field to return
@attrib: _lang:: Pack Name of language to use. The current language is used if this is not set
*/
function m_lang_field($attribs = array())
{
global $objLanguages, $objSession;
if(!strlen($attribs["_field"]))
return "";
$lang = $attribs["_lang"];
if(!strlen($lang))
{
$LangId = $objSession->Get("Language");
$l = $objLanguages->GetItem($LangId);
}
else
{
$l = $objLanguages->GetItemByField("PackName",$lang);
}
if(is_object($l))
{
//$ret = $l->Get($attribs["_field"]);
$e = new clsHtmlTag();
$e->name=$l->TagPrefix;
$e->attributes=$attribs;
$ret = $l->ParseObject($e);
}
return $ret;
}
/*
@description: Creates a URL used to set the current theme for a user
@attrib: _theme:: Name of Theme to set. The template selected in the new them is always "index"
*/
function m_settheme_link($attribs)
{
global $m_var_list_update, $objSession, $objThemes, $CurrentTheme;
$ThemeName = $attribs["_theme"];
if(strlen($ThemeName))
{
$t = $objThemes->GetItemByField("Name",$ThemeName);
if(is_object($t))
{
$Id = $t->Get("ThemeId");
}
else
$Id = 0;
}
else
{
$t = $CurrentTheme;
$Id = 0;
}
$m_var_list_update["theme"] = $Id;
$ret = GetIndexURL()."?env=".BuildEnv();
unset($m_var_list_update["theme"]);
return $ret;
}
/*
@description: Initializes categories
*/
function m_init_cats($attribs = array())
{
// save current & previous category (used in pagination)
global $objSession, $objCatList;
global $var_list;
//echo "SID_INIT: ".$var_list["sid"].'(COOKIE_SID: '.$_COOKIE["sid"].')<br>';
$objSession->SetVariable('prev_category', $objSession->GetVariable('last_category') );
$objSession->SetVariable('last_category', $objCatList->CurrentCategoryID() );
//$last_cat = $objSession->GetVariable('last_category');
//$prev_cat = $objSession->GetVariable('prev_category');
//echo "Last CAT: [$last_cat]<br>";
//echo "Prev CAT: [$prev_cat]<br>";
}
/*
@description: List all subcategories a user is allowed to view
@attrib: _columns:int: Numver of columns to display the categories in (defaults to 1)
@attrib: _maxlistcount:int: Maximum number of categories to list
@attrib: _FirstItemTemplate:tpl: Template used for the first category listed
@attrib: _LastItemTemplate:tpl: Template used for the last category listed
@attrib: _ItemTemplate:tpl: default template used for category list items
@attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag
@example: <inp:m_list_cats _NoTable="0" _columns="2" _ItemTemplate="catlist_element" border="0" cellspacing="0" cellpadding="0" width="98%" />
*/
function m_list_cats($attribs = array())
{
global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set, $objSystemCache;
$CachedList = GetTagCache("kernel","m_list_cats",$attribs,m_BuildEnv());
if(strlen($CachedList))
{
return $CachedList;
}
$cols = $attribs["_columns"];
if($cols<1)
$cols =1;
$CategoryId = $attribs["_catid"];
if(!is_numeric($CategoryId))
$CategoryId = $objCatList->CurrentCategoryID();
$cat_count = (int)$attribs["_maxlistcount"];
/* validation */
if(strlen($attribs["_itemtemplate"])==0)
{
if($attribs["dataexists"])
$content_set = 0;
return "";
}
$GroupList = $objSession->Get("GroupList");
if(strlen($GroupList))
{
$Groups = explode(",",$GroupList);
}
$acl_where = "";
if(@count($Groups)>0 && is_array($Groups))
{
$acl_where = array();
for($i=0;$i<count($Groups);$i++)
{
$g = $Groups[$i];
$acl_where[] = "(FIND_IN_SET($g,acl) OR ((NOT FIND_IN_SET($g,dacl)) AND acl='')) ";
}
if(count($acl_where))
{
$acl_where = "(".implode(" OR ",$acl_where).")";
}
else
$acl_where = "(FIND_IN_SET(0,acl))";
}
else
$acl_where = "(FIND_IN_SET(0,acl))";
$objCatList->Clear();
$OrderBy = $objCatList->QueryOrderByClause(TRUE,TRUE,TRUE);
$objCatList->LoadCategories("ParentId=$CategoryId AND Status=1",$OrderBy);
if ($objCatList->NumItems() == 0)
{
if($attribs["_dataexists"])
$content_set = 0;
return "";
}
$html_attr = ExtraAttributes($attribs);
$o="";
$notable = $attribs["_notable"];
$count=0;
$row=0;
$var_list_update["t"] = $var_list["t"];
if(!$notable)
{
$per_row = ceil($objCatList->NumItems()/$cols);
$o = "<TABLE $html_attr><TR CLASS=\"m_list_cats\">";
$o .= "<TD valign=\"top\">";
$CatCount = $objCatList->NumItems();
foreach($objCatList->Items as $cat)
{
$parsed=0;
if($count==$per_row)
{
$o .= "</TD><TD valign=\"top\">";
$count=0;
}
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
$o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed=1;
}
if($row==$CatCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
$o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed=1;
}
if(!$parsed)
$o.= $cat->ParseTemplate($attribs["_itemtemplate"]);
$count++;
$row++;
}
if($count != $per_row)
$o .= "</TD>";
$o .= "\n</tr></table>\n";
}
else
{
$CatCount = $objCatList->NumItems();
foreach($objCatList->Items as $cat)
{
if($cat->Get("ParentId")==$CategoryId)
{
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
//echo 'Saving <b>ID</b> in <b>m_sub_cats</b>[ first ] '.$cat->UniqueId().'<br>';
//$GLOBALS['cat_ID'] = $cat->UniqueId();
$o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed=1;
}
if($row==$CatCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
//echo 'Saving <b>ID</b> in <b>m_sub_cats</b>[ last ] '.$cat->UniqueId().'<br>';
//$GLOBALS['cat_ID'] = $cat->UniqueId();
$o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed=1;
}
if(!$parsed)
{
//echo 'Saving <b>ID</b> in <b>m_sub_cats</b>[ each ] '.$cat->UniqueId().'<br>';
//$GLOBALS['cat_ID'] = $cat->UniqueId();
$o .= $cat->ParseTemplate($attribs["_itemtemplate"]);
}
$row++;
$i++;
$count++;
if($count>=$cat_count && $cat_count>0)
break;
}
}
}
unset($var_list_update["t"]);
SaveTagCache("kernel","m_list_cats",$attribs,m_BuildEnv(),$o);
return $o;
}
function LoadCatSearchResults($attribs)
{
global $objSession, $objPermissions, $objCatList, $objSearchCats, $objConfig, $CountVal;
$GroupList = $objSession->Get("GroupList");
if(strlen($GroupList))
$Groups = explode(",",$GroupList);
$acl_where = "";
if(@count($Groups)>0 && is_array($Groups))
{
$acl_where = array();
for($i=0;$i<count($Groups);$i++)
{
$g = $Groups[$i];
$acl_where[] = "(FIND_IN_SET($g,acl) OR ((NOT FIND_IN_SET($g,dacl)) AND acl='')) ";
}
if(count($acl_where))
{
$acl_where = "(".implode(" OR ",$acl_where).")";
}
else
$acl_where = "(FIND_IN_SET(0,acl))";
}
else
$acl_where = "(FIND_IN_SET(0,acl))";
$CAT_VIEW = $objPermissions->GetPermId("CATEGORY.VIEW");
$ctable = $objCatList->SourceTable;
$stable = $objSession->GetSearchTable(); // $objSearchCats->SourceTable;
$ptable = GetTablePrefix()."PermCache";
$sql = "SELECT * FROM $stable INNER JOIN $ctable ON ($stable.ItemId=$ctable.CategoryId) ";
$sql .= "INNER JOIN $ptable ON ($ctable.CategoryId=$ptable.CategoryId) ";
$sql .="WHERE ItemType=1 AND Status=1 AND $acl_where AND PermId=$CAT_VIEW ORDER BY EdPick DESC,Relevance DESC ";
$objSearchCats->Page = $m_var_list["p"];
if($objSearchCats->Page<1)
$objSearchCats->Page=1;
if(is_numeric($objConfig->Get($objSearchCats->PerPageVar)))
{
$Start = ($objSearchCats->Page-1)*$objConfig->Get($objSearchCats->PerPageVar);
$limit = "LIMIT ".$Start.",".$objConfig->Get($objSearchCats->PerPageVar);
}
else
$limit = NULL;
if(strlen($limit))
$sql .= $limit;
// echo "TEST:<BR>$sql<br>\n";
$objSearchCats->Query_Item($sql);
$where = "ItemType=1";
if(is_numeric($CountVal[1]))
{
$objSearchCats->QueryItemCount = $CountVal[1];
}
else
{
$objSearchCats->QueryItemCount = QueryCount($sql);
$CountVal[1]= $objSearchCats->QueryItemCount;
}
}
/*
@description: Used in conjuction with m_search_list_cats. This function generates a navigation link which is
used to switch from a short list to a longer list. The page number is not changed.
If this tag is called before the list tag, this function will load the category list.
Generally, it is good practice to duplicate all attributes set for m_search_list_cats.
Any extra HTML attributes are passed to the anchor tag
@attrib: _Template:tpl: Template to link to
@attrib: _text:lang: language tag to include as text for the anchor tag
@attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence
if both are included.
@attrib: _image:: URL to an image to include inside the anchor tag.
*/
function m_search_cat_more($attribs = array())
{
global $objSearchCats, $objConfig, $m_var_list_update;
$html_attribs = ExtraAttributes($attribs);
$DestTemplate = $attribs["_template"];
if($attribs["_shortlist"])
$objSearchList->PerPageVar = "Perpage_Category_Short";
if($objSearchCats->NumItems()==0)
{
LoadCatSearchResults($attribs);
}
$max = $objConfig->Get($objSearchList->PerPageVar);
$val = $objSearchCats->QueryItemCount;
if($val > $max)
{
if($attribs["_root"])
$attribs["_category"]=0;
$m_var_list_update["p"]=1;
$url = m_template_link($attribs);
unset($m_var_list_update["p"]);
$o = "<A $html_attribs HREF=\"$url\">";
$text = $attribs["_text"];
if(!strlen($text))
{
$text = $attribs["_plaintext"];
if(!strlen($text))
{
}
$o .= $text."</A>";
}
else
$o .= language($text);
if(strlen($attribs["_image"]))
{
$o .= "<IMG SRC=\"".$attribs["_image"]."\" BORDER=\"0\" />";
}
$o .= "</A>";
}
return $o;
}
/*
@description: Used in conjuction with m_search_list_cats. This function generates the page navigation
for the list. If this tag is called before the list tag, this function will load
the category list. Generally, it is good practice to duplicate all attributes set for
m_search_list_cats.
@attrib: _PagesToList:int: Number of pages to list (default is 10)
@attrib: _label:lang: language tag to include in the output if there are pages to list. If there are no pages
listed, this text will not be included (resulting in an empty output)
*/
function m_search_cat_pagenav($attribs = array())
{
global $objSearchCats, $objConfig, $objCatList, $objSession;
$DestTemplate = $attribs["_template"];
$PagesToList = $attribs["_pagestolist"];
if(!is_numeric($PagesToList))
$PagesToList = 10;
$CatId = $attribs["_catid"];
if(!is_numeric($CatId))
$CatId = $objCatList->CurrentCategoryID();
$objSearchCats->PerPageVar = "Perpage_Category";
if($attribs["_shortlist"])
$objSearchCats->PerPageVar = "Perpage_Category_Short";
if($objSearchCats->NumItems()==0)
{
LoadCatSearchResults($attribs);
}
$o = $objSearchCats->GetPageLinkList($DestTemplate);
if(strlen($o) && strlen($attribs["_label"]))
$o = language($attribs["_label"]).$o;
return $o;
}
/*
@description: List all categories matched in a search
@attrib: _columns:int: Numver of columns to display the categories in (defaults to 1)
@attrib: _maxlistcount:int: Maximum number of categories to list
@attrib: _ShortList:bool: If set, the Perpage_Category_Short setting is used instead of Perpage_Category
@attrib: _FirstItemTemplate:tpl: Template used for the first category listed
@attrib: _LastItemTemplate:tpl: Template used for the last category listed
@attrib: _ItemTemplate:tpl: default template used for category list items
@attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag
@example: <inp:m_search_list_cats _NoTable="1" _ItemTemplate="category_search_results_element" />
*/
function m_search_list_cats($attribs = array())
{
global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set,
$objSearchCats, $objPermissions, $m_var_list;
if(!is_object($objSearchCats))
{
$objSearchCats = new clsCatList();
$objSearchCats->SourceTable = $objSession->GetSessionTable('Search'); //"ses_".$objSession->GetSessionKey()."_Search"
$objSearchCats->Clear();
}
$objSearchCats->PerPageVar = "Perpage_Category";
if($attribs["_shortlist"])
{
$objSearchCats->Page=1;
$m_var_list["p"] = 1;
$objSearchCats->PerPageVar = "Perpage_Category_Short";
}
$keywords = $objSession->GetVariable("Search_Keywords"); // for using in all this func branches
if($objSearchCats->NumItems()==0)
{
LoadCatSearchResults($attribs);
//echo "Cat count: ". $objSearchCats->QueryItemCount;
$ret = 0;
if ($keywords) {
foreach ($objSearchCats->Items as $cat) {
if (strstr(strip_tags(strtolower($cat->Data['Name'])), strtolower($_POST['keywords'])) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($_POST['keywords']))) {
$ret++;
}
}
}
else {
$ret = $objSearchCats->QueryItemCount;
}
if ($ret == 0) //if ($objSearchCats->NumItems() == 0)
{
$content_set = 0;
return language("lu_no_categories");
}
}
$html_attr = ExtraAttributes($attribs);
$cols = $attribs["_columns"];
if($cols<1)
$cols =1;
$cat_count = (int)$attribs["_maxlistcount"];
/* validation */
if(strlen($attribs["_itemtemplate"])==0)
{
$content_set = 0;
return "ERROR -1";
}
$o="";
$notable = $attribs["_notable"];
$count=0;
$row=0;
$var_list_update["t"] = $var_list["t"];
if(!$notable)
{
$per_row = ceil($objCatList->NumItems()/$cols);
$o = "<TABLE $html_attr><TR CLASS=\"m_list_cats\">";
$o .= "<TD valign=\"top\">";
foreach($objSearchCats->Items as $cat)
{
$parsed=0;
if($count==$per_row)
{
$o .= "</TD><TD valign=\"top\">";
$count=0;
}
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
$o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed=1;
}
if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
$o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed=1;
}
if(!$parsed)
$o.= $cat->ParseTemplate($attribs["_itemtemplate"]);
$count++;
}
if($count != $per_row)
$o .= "</TD>";
$o .= "\n</tr></table>\n";
}
else
{
//echo "<pre>"; print_r($objSearchCats->Items); echo "</pre>";
foreach($objSearchCats->Items as $cat)
{
//$cat->Keywords = GetKeywords($objSession->GetVariable("Search_Keywords"));
$keywords_found = strstr( strip_tags(strtolower($cat->Data['Name'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($keywords));
if(!$keywords) $keywords_found = true;
if ($keywords_found) {
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
$o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed=1;
}
if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
$o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed=1;
}
if(!$parsed)
$o.= $cat->ParseTemplate($attribs["_itemtemplate"]);
$row++;
$i++;
$count++;
}
}
}
unset($var_list_update["t"]);
return $o;
}
/*
@description: Parse a template based on the current advanced search type
@attrib:_TypeSelect:tpl:Template to parse if no item type has been selected
@attrib:_ItemSelect:tpl:Template to parse if an item type has been selected to search
*/
function m_advsearch_include($attribs)
{
global $objTemplate;
$TypeSelectTemplate = $attribs["_typeselect"];
$ItemTemplate = $attribs["_itemselect"];
if((strlen($_GET["type"])>0 || $_POST["itemtype"]>0) && ($_GET["Action"]=="m_advsearch_type" || $_GET["Action"]=="m_adv_search"))
{
$o = $objTemplate->ParseTemplate($ItemTemplate);
}
else
$o = $objTemplate->ParseTemplate($TypeSelectTemplate);
return $o;
}
/*
@description: Returns the name of the item type currently being advanced searched
@attrib::_plaintext:bool:If set, simply returns the name of the item if not, builds a language tag (lu_searchtitle_[name])
*/
function m_advsearch_type($attribs)
{
global $objItemTypes;
if($_GET["Action"]=="m_advsearch_type")
{
$ItemType = $_POST["itemtype"];
}
elseif($_GET["Action"]=="m_adv_search")
$ItemType = $_GET["type"];
$o = "";
if((int)$ItemType>0)
{
$Item = $objItemTypes->GetItem($ItemType);
if(is_object($Item))
{
$name = strtolower($Item->Get("ItemName"));
if($attribs["_plaintext"])
{
$o .= $name;
}
else
$o = language("lu_searchtitle_".strtolower($name));
}
}
return $o;
}
/*
@description: Lists advanced search fields for the selected item type
@attrib: _FirstItemTemplate:tpl: Template used for the first field listed
@attrib: _LastItemTemplate:tpl: Template used for the last field listed
@attrib: _AltLastItemTemplate:tpl: Altername Template used for the last field listed
@attrib: _ItemTemplate:tpl: default template used for field list items
@attrib: _AltTemplate:tpl: Alternate template used for field list items
*/
function m_advsearch_fields($attribs)
{
global $objItemTypes, $objTemplate, $objSearchConfig;
if(!is_object($objSearchConfig))
$objSearchConfig = new clsSearchConfigList();
if($_GET["Action"]=="m_advsearch_type")
{
$ItemType = $_POST["itemtype"];
}
elseif($_GET["Action"]=="m_adv_search")
$ItemType = $_GET["type"];
$o = "";
if((int)$ItemType>0)
{
$Item = $objItemTypes->GetItem($ItemType);
if(is_object($Item))
{
$name = strtolower($Item->Get("ItemName"));
$table = $Item->Get("SourceTable");
$sql = "SELECT * FROM ".$objSearchConfig->SourceTable." WHERE TableName='$table' AND AdvancedSearch=1 ORDER BY DisplayOrder";
$objSearchConfig->Query_Item($sql);
$row=0;
if(is_array($objSearchConfig->Items))
{
$ItemCount = count($objSearchConfig->Items);
foreach($objSearchConfig->Items as $s)
{
$even = (($row+1) % 2 == 0);
$parsed=0;
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
$o .= $s->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed=1;
}
if($row==$ItemCount-1 && $even && !$parsed && strlen($attribs["_altlastitemtemplate"])>0)
{
$o .= $s->ParseTemplate($attribs["_altlastitemtemplate"]);
$parsed=1;
}
if($row==$ItemCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
$o .= $s->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed=1;
}
if(!$parsed)
{
if($even && strlen($attribs["_altitemtemplate"])>0)
{
$o .= $s->ParseTemplate($attribs["_altitemtemplate"]);
}
else
$o .= $s->ParseTemplate($attribs["_itemtemplate"]);
}
$row++;
}
}
}
}
return $o;
}
/*
@description: create a link to a template based on attributes passed into the tag. All extra HTML attributes
are passed to the anchor tag created.
@attrib: _Template:tpl: Template to link to. Just the template name is listed here. (ex: use "index" instead if "inlink/index")
@attrib: _Module:: Module being linked to (ie In-Bulletin or In-News or In-Link)
@attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list,
the link will be generated. (If the _DeniedTemplate attribute is set, this template is used
and the link is created.)
@attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm
attribute. If this attirbute is not included and the user does not have access,
nothing is returned. (The link is not created.)
@attrib: _Root:bool: If set, the current category is set to the module's root category
@attrib: _text:lang: language tag to include as text for the anchor tag
@attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence
if both are included.
@attrib: _image:: URL to an image to include inside the anchor tag.
@attrib: _image_actions:: Image events.
*/
function m_module_link($attribs = array())
{
global $objCatList, $objSession;
$permission = $attribs["_perm"];
$o = "";
$tpath = GetModuleArray("template");
if(strlen($permission))
{
$perms = explode(",",$permission);
$hasperm = FALSE;
for($x=0;$x<count($perms);$x++)
{
if($objSession->HasCatPermission($perms[$x]))
{
$hasperm = TRUE;
break;
}
}
}
else
$hasperm = TRUE;
if(!$hasperm && strlen($attribs["_deniedtemplate"])>0)
{
$hasperm = TRUE;
$attribs["_template"]=$attribs["_deniedtemplate"];
}
if($hasperm)
{
$module = $attribs["_module"];
if(ModuleEnabled($module))
{
$t = $tpath[$attribs["_module"]];
$t .= $attribs["_template"];
$attribs["_template"] = $t;
$html_attr = ExtraAttributes($attribs);
if($attribs["_root"])
{
$func = ModuleTagPrefix($module)."_root_link";
if(function_exists($func))
{
$url = $func($attribs);
}
else
$url = m_template_link($attribs);
}
else
$url = m_template_link($attribs);
$o = "<A $html_attr HREF=\"";
$o .= $url;
$o .= "\"> ";
$text = $attribs["_text"];
if(!strlen($text))
{
$text = $attribs["_plaintext"];
if(!strlen($text))
{
if(strlen($attribs["_image"]))
{
$text = "<IMG SRC=\"".$attribs["_image"]."\" BORDER=\"0\">";
}
}
$o .= $text."</A>";
}
else
$o .= language($text)."</A>";
}
else
{
$o = "";
}
}
return $o;
}
/*
@description: create a link to a template based on attributes passed into the tag. All extra HTML attributes
are passed to the anchor tag created.
@attrib: _Template:tpl: Template to link to. Just the template name is listed here. (ex: use "index" instead if "inlink/index")
@attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list,
the link will be generated. (If the _DeniedTemplate attribute is set, this template is used
and the link is created.)
@attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm
attribute. If this attirbute is not included and the user does not have access,
nothing is returned. (The link is not created.)
@attrib: _text:lang: language tag to include as text for the anchor tag
@attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence
if both are included.
@attrib: _image:: URL to an image to include inside the anchor tag.
*/
function m_permission_link($attribs = array())
{
global $objCatList, $objSession;
$permission = $attribs["_perm"];
$o = "";
if(strlen($permission))
{
$perms = explode(",",$permission);
$hasperm = FALSE;
for($x=0;$x<count($perms);$x++)
{
if($objSession->HasCatPermission($perms[$x]))
{
$hasperm = TRUE;
break;
}
}
}
else
$hasperm = TRUE;
if(!$hasperm && strlen($attribs["_deniedtemplate"])>0)
{
$hasperm = TRUE;
$attribs["_template"]=$attribs["_deniedtemplate"];
}
if($hasperm)
{
$url = m_template_link($attribs);
$o = "<A $html_attr HREF=\"";
$o .= $url;
$o .= "\"> ";
$text = $attribs["_text"];
if(!strlen($text))
{
$text = $attribs["_plaintext"];
if(!strlen($text))
{
if(strlen($attribs["_image"]))
{
$text = "<IMG SRC=\"".$attribs["_image"]."\" BORDER=\"0\">";
}
}
$o .= $text."</A>";
}
else
$o .= language($text)."</A>";
}
else
{
$o = "";
}
return $o;
}
/*
@description: Create a link to a template.
@attrib: _Template:tpl: Template to link to (ex: "inbulletin/post_list")
@attrib: _Query:str: Extra query sring to be added to link URL (ex: "&test=test")
@attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged
@attrib: _anchor:: If included, a local anchor (#) is added. (ex: _anchor="top" results in <A HREF="..#top">)
@attrib: _Secure:bool:If set, creates an https URL
@attrib: _Root:bool:If set, gets module root category id
@attrib: _Module:str:Module Name
@attrib: _Unsecure:bool: Is set, creates an insecure full url (http://...)
@example: <a href="<inp:m_template_link _Template="index" _Category=0 />"><inp:m_language _Phrase="lu_home" /></a>
*/
function m_template_link($attribs = array())
{
global $var_list, $var_list_update, $m_var_list_update, $objCatList;
$template = $attribs["_template"];
$query = trim($attribs["_query"]);
$query = !ereg("^&", $query)? "&$query" : $query;
if(!strlen($template))
$template = $var_list["t"];
$cat = $attribs["_category"];
$var_list_update["t"] = $template;
if(strlen($cat))
{
if($cat=="NULL")
{
$m_var_list_update["cat"]=0;
}
else
{
$m_var_list_update["cat"] = $cat;
}
}
if($attribs["_secure"])
{
$ret = GetIndexURL(1)."?env=".BuildEnv().$query;
}
elseif($attribs["_unsecure"])
{
$ret = GetIndexURL(2)."?env=".BuildEnv().$query;
}
else
$ret = GetIndexURL()."?env=".BuildEnv().$query;
if(strlen($attribs["_anchor"]))
$ret .= "#".$attribs["_anchor"];
unset($var_list_update["t"]);
if(strlen($cat))
unset($m_var_list_update["cat"]);
return $ret;
}
/*
@description: create a link to a template based on user permissions. All extra HTML attributes are passed to the anchor tag created.
@attrib: _Template:tpl: Template to link to if the user has access
@attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm
attribute. If this attirbute is not included and the user does not have access,
the "login" template is used.
@attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list,
the link will be generated. (If the _DeniedTemplate attribute is set, this template is used
and the link is created.)
@attrib: _System:bool: Set this attribute if one of the permissions in the list is a system permission (ie: LOGIN)
@attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged
@example: <a href="<inp:m_access_template_link _Template="my_account" _DeniedTemplate="login" _Perm="login" />"><inp:m_language _Phrase="lu_myaccount" /></A>
*/
function m_access_template_link($attribs = array(), $Permission="")
{
global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession;
$cat = $attribs["_category"];
if(strlen($cat))
{
if($cat=="NULL")
$cat = 0;
}
else
$cat = $objCatList->CurrentCategoryID();
if(!strlen($Permission))
{
$Permission = strtoupper($attribs["_perm"]);
}
$o = "";
$hasperm = FALSE;
if(strlen($Permission))
{
$perms = explode(",",$Permission);
for($x=0;$x<count($perms);$x++)
{
if($objSession->HasCatPermission(trim($perms[$x]),$cat))
{
$hasperm = TRUE;
break;
}
}
if(!$hasperm && $attribs["_system"])
{
for($x=0;$x<count($perms);$x++)
{
if($objSession->HasSystemPermission(trim($perms[$x])))
{
$hasperm = TRUE;
break;
}
}
}
}
$access = $attribs["_template"];
$denied = $attribs["_deniedtemplate"];
if(!strlen($denied))
$denied = "login";
$m_var_list_update["cat"] = $cat;
if($hasperm)
{
$template = $access;
if(!strlen($template))
$template = $var_list["t"];
$var_list_update["t"] = $template;
}
else
{
$template = $denied;
if(!strlen($template))
$template = $var_list["t"];
if($template == "login")
{
$dest = $access;
}
$var_list_update["t"] = $template;
}
$ret = GetIndexURL()."?env=".BuildEnv();
unset($var_list_update["t"]);
if(strlen($dest))
$ret .= "&dest=$dest";
return $ret;
}
/*
@description: returns a text based on user permissions. Text from inside of the tag will be returned if text attributes are not specified and user has permissions to category, or if _NoPerm attribute set to 1 and user doesn't have permissions. Otherwise entire section will be excluded.
@attrib: _Text:lang: Template to link to if the user has access
@attrib: _PlainText:: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, the "login" template is used.
@attrib: _DenyText:lang: Template to link to if the user has access
@attrib: _PlainDenyText:: This exact text is used if the user does not have a permission listed in the _perm attribute and _DenyText attribute is not set.
@attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list, the link will be generated.
@attrib: _System:bool: Set this attribute if one of the permissions in the list is a system permission (ie: LOGIN)
@attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged
@attrib: _MatchAllPerms:int: Checks for all listed Permissions to be TRUE. Note: this attribute is rarely used.
@attrib: _NoPerm:int: The whole tag will return inner text if user has no permissions and attribute set to 1. Default value is 0.
@example: <inp:m_perm_text _Text="!lu_allow_language_tag!" _PlainText="Just a text" _DenyText="!lu_deny_language_tag!" _PlainDenyText="Just a plain text" _Perm="login" _MatchAllPerms="1" _NoPerm="0">Some HTML here!</inp>
*/
function m_perm_text($attribs = array())
{
global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession;
$cat = $attribs["_category"];
if(strlen($cat))
{
if($cat=="NULL")
$cat = 0;
}
else
$cat = $objCatList->CurrentCategoryID();
if(!strlen($Permission))
{
$Permission = strtoupper($attribs["_perm"]);
}
$o = "";
$hasperm = FALSE;
$count = 0;
if(strlen($Permission))
{
$perms = explode(",",$Permission);
for($x=0;$x<count($perms);$x++)
{
$_AllPermsCount[$count] = 0;
if($objSession->HasCatPermission($perms[$x],$cat))
{
$hasperm = TRUE;
$_AllPermsCount[$count] = 1;
// break;
}
$count++;
}
if(!$hasperm && $attribs["_system"])
{
for($x=0; $x<count($perms); $x++)
{
$_AllPermsCount[$count] = 0;
if($objSession->HasSystemPermission($perms[$x]))
{
$hasperm = TRUE;
$_AllPermsCount[$count] = 1;
// break;
}
$count++;
}
}
}
if ((int)$attribs["_matchallperms"])
{
if (count($_AllPermsCount) != array_sum($_AllPermsCount))
$hasperm = FALSE;
}
$text = $attribs["_text"];
$plaintext = $attribs["_plaintext"];
$denytext = $attribs["_denytext"];
$plaindenytext = $attribs["_plaindenytext"];
$nopermissions_status = (int)$attribs["_noperm"]? 1 : 0;
if(!strlen($denied))
$denied = "login";
if (!$nopermissions_status)
{
if ($hasperm)
{
if (strlen($text) || strlen($plaintext))
$ret = strlen($text)? language($text) : $plaintext;
else
$ret = "1";
}
else
$ret = strlen($denytext)? language($denytext) : $plaindenytext;
}
elseif (!$hasperm)
{
$ret = "1";
}
return $ret;
}
/*
@description: Returns the error string associated with a permission
*/
function m_permission_error($attribs = array())
{
global $objPermissions;
$ret = "";
$perm = strtoupper($_GET["error"]);
if(strlen($perm))
{
$ado = &GetADODBConnection();
$sql = "SELECT * FROM ".GetTablePrefix()."PermissionConfig WHERE PermissionName ='$perm'";
$rs = $ado->Execute($sql);
if($rs && !$rs->EOF)
{
$data = $rs->fields;
$error_tag = $data["ErrorMessage"];
}
else
$error_tag = "lu_unknown_error";
$ret = language($error_tag);
}
return $ret;
}
/*
@description: Returns the error text encountered when parsing templates
*/
function m_template_error($attribs = array())
{
global $objTemplate;
$ret = "";
if($objTemplate->ErrorNo<0)
{
$ret = $objTemplate->ErrorStr;
}
return $ret;
}
/*
@description: Creates a category navigation bar
@attrib: _Template:tpl: template to use for navigation links
@attrib: _RootTemplate:bool: If set, this template is linked to for the root category
@attrib: _LinkCurrent:bool: If set, the last (current) category is linked. Otherwise the current category is simply displayed
@attrib: _Separator:: text to display between levels of the navigation bar
@attrib: _Root:: Root category configuration variable to use. (ex: Link for In-Link's root category) If not set, the system root is used
@example: <inp:m_navbar _RootTemplate="index" _Template="inbulletin/index" _LinkCurrent="1" _separator=" &gt; " />
*/
function m_navbar($attribs = array())
{
global $m_var_list_update, $var_list, $objCatList, $objConfig, $objModules;
$separator = GetElem($attribs, '_separator');
if(!$separator) $separator = "<span class=\"NAV_ARROW\"> > </span>";
$admin = (int)GetElem($attribs, 'admin');
$t = GetElem($attribs, '_template');
$LinkLeafNode = GetElem($attribs, '_linkcurrent');
$catid = (int)GetElem($attribs, '_catid');
if( GetElem($attribs, '_root') )
{
$var = GetElem($attribs, '_root')."_Root";
$Root = (int)$objConfig->Get($var);
}
else
$Root = 0;
$RootTemplate = GetElem($attribs, '_roottemplate') ? GetElem($attribs, '_roottemplate') : '';
$Module = GetElem($attribs, '_module');
$ModuleRootTemplate = '';
if($Module)
{
$ModuleRootCat = $objModules->GetModuleRoot($Module);
if($ModuleRootCat>0)
{
$modkey = "_moduleroottemplate";
$ModuleRootTemplate = GetElem($attribs, $modkey);
}
else
$ModuleRootTemplate="";
}
else
$ModuleRootCat = 0;
if(!$catid)
$catid = $objCatList->CurrentCategoryID();
$ret = $objCatList->cat_navbar($admin, $catid, $t, $separator,$LinkLeafNode,$Root,$RootTemplate,$ModuleRootCat,$ModuleRootTemplate);
return $ret;
}
/*
@description: Parse a category field and return the value
@attrib: _Field:: Category field to parse
@attrib: _CatId:int: Category ID to parse (uses current category if not set)
@attrib: _StripHTML:bool: if set, all HTML is removed from the output
*/
function m_category_field($attribs)
{
global $objCatList;
$ret = "";
$catid = (int)$attribs["_catid"];
$field = $attribs["_field"];
if(!$catid)
$catid = $objCatList->CurrentCategoryID();
if(strlen($field))
{
$cat =& $objCatList->GetCategory($catid);
if(is_object($cat))
{
$element = new clsHtmlTag();
$element->name=$cat->TagPrefix;
$element->attributes = $attribs;
$ret = $cat->ParseObject($element);
}
}
if($attribs["_striphtml"])
$ret = strip_tags($ret);
return $ret;
}
/*
@description: returns the date of the last modification to a category
@attrib: _Part:: part of the date to display
@attrib: _Local:bool: If set, only subcategories of the current category is checked
@example: <inp:m_category_modified />
*/
function m_category_modified($attribs)
{
global $objConfig, $objCatList;
$ado = &GetADODBConnection();
if($attribs["_local"] && $objCatList->CurrentCategoryID() != 0)
{
$c =& $objCatList->GetItem($objCatList->CurrentCategoryID());
$catlist = $c->GetSubCatIds();
$catwhere = "CategoryId IN (".explode(",",$catlist).")";
$sql = "SELECT MAX(Modified) as ModDate,MAX(CreatedOn) as NewDate FROM ".GetTablePrefix()."Category ";
$sql .= "INNER JOIN ".GetTablePrefix()."CategoryItems ON (".GetTablePrefix()."Category.ResourceId=".GetTablePrefix()."CategoryItems.ItemResourceId) ";
$sql .= "WHERE $catwhere LIMIT 1";
}
else
$sql = "SELECT MAX(Modified) as ModDate FROM ".GetTablePrefix()."Category LIMIT 1";
$rs = $ado->Execute($sql);
if($rs && ! $rs->EOF)
{
$mod = $rs->fields["ModDate"];
if($mod)
{
$part = strtolower($attribs["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$mod);
}
else
{
$ret = LangDate($mod);
}
}
}
return $ret;
}
/*
@description: creates LINK tags to include all module style sheets
@attrib: _Modules:: Accepts a comma-separated list of modules to include (ie: "In-Link, In-News, In-Bulletin")
@attrib: _*css:none: Each module may set a custom-named stylesheet. For example, for In-Link the attribute would be _In-Linkcss="..".
If a module does not have a *css attribute, the default (style.css) is assumed.
@example: <inp:m_module_stylesheets _Modules="In-Portal,In-News,In-Bulletin,In-Link" _In-PortalCss="incs/inportal_main.css" />
*/
function m_module_stylesheets($attribs)
{
global $TemplateRoot;
$IncludeList = explode(",",trim($attribs["_modules"]));
$tpath = GetModuleArray("template");
for($inc=0;$inc<count($IncludeList);$inc++)
{
$css_attr = "_".strtolower($IncludeList[$inc])."css";
if(strlen($attribs[$css_attr]))
{
$mod_css = $tpath[$IncludeList[$inc]].$attribs[$css_attr];
}
else
$mod_css = $tpath[$IncludeList[$inc]]."style.css";
$file = $TemplateRoot.$mod_css;
if(file_exists($file))
$ret .= "<link rel=\"stylesheet\" href=\"$mod_css\" type=\"text/css\" />\n";
}
return $ret;
}
/*
@description: lists items related to a category
@attrib:CatId:int: Category ID of category, or current category if not set
@attrib:_ListItem: Comma-separated list of item types (ie: Link, Topic, Category, News) The items are listed in the order this list provides, then by priority.
Each item should have its own template passed in as an attribute (_{ItemType}Template)
*/
function m_related_items($attribs)
{
global $objItemTypes, $objCatList, $content_set;
static $Related;
global $CatRelations;
$cat = $attribs["_catid"];
if(!is_numeric($cat))
{
$cat = $objCatList->CurrentCategoryID();
}
$c =& $objCatList->GetCategory($cat);
$data_sent=0;
if(is_object($c))
{
$ResourceId = $c->Get("ResourceId");
$IncludeList = explode(",",trim(strtolower($attribs["_listitems"])));
$o = "";
if(!is_object($CatRelations))
{
$CatRelations = new clsMultiTypeList();
LoadRelatedItems($Related, $CatRelations,$c->Get("ResourceId"));
}
if($CatRelations->NumItems()>0)
{
for($inc=0;$inc<count($IncludeList);$inc++)
{
$t_attr = "_".$IncludeList[$inc]."template";
$t = $attribs[$t_attr];
$item_type = $IncludeList[$inc];
if(strlen($item_type))
{
$objType = $objItemTypes->GetTypeByName($item_type);
if(is_object($objType))
{
foreach($CatRelations->Items as $item)
{
if(is_object($item))
{
if(strtolower($objType->Get("ItemName")) == strtolower($item_type) && $item->type==$objType->Get("ItemType"))
{
if(strlen($item->BasePermissionName))
{
$perm = $item->BasePermissionName.".VIEW";
$haspem = $objSession->HasCatPermission($perm,$item->Get("CategoryId"));
}
else
$hasperm = 1;
if($hasperm)
{
$data_sent =1;
$classname = $objType->Get("ClassName");
if(strlen($classname))
{
$l = new $classname;
$l->Data = $item->Data;
$o .= $l->ParseTemplate($t);
}
}
}
}
$item = NULL;
}
}
else
echo $item_type." not found <br>\n";
}
}
if($data_sent)
{
return $o;
}
else
{
$content_set=0;
return "";
}
}
else
{
$content_set = 0;
return "";
}
}
else
{
$content_set = 0;
return "";
}
}
/*
@description: Returns the number of items related to the current category
@attrib:_CatId:int: If set, this is the category ID to use, otherwise the current category is used
@attrib:_ItemType::Name of item to count. If not set, all related items are counted
*/
function m_related_count($attribs)
{
global $objItemTypes, $objCatList, $content_set;
$cat = $attribs["_catid"];
if(!is_numeric($cat))
{
$cat = $objCatList->CurrentCategoryID();
}
$c =& $objCatList->GetCategory($cat);
$data_sent=0;
//echo "Category: $cat<pre>"; print_r($c); echo " </pre>";
if(is_object($c))
{
$ResourceId = $c->Get("ResourceId");
if(!is_object($CatRelations))
{
$CatRelations = new clsMultiTypeList();
LoadRelatedItems($Related, $CatRelations, $c->Get("ResourceId"));
}
$item_type = $attribs["_itemtype"];
if(strlen($item_type))
{
$objType = $objItemTypes->GetTypeByName($item_type);
if(is_object($objType))
{
$TargetType = $objType->Get("ItemType");
}
else
$TargetType="";
}
if($CatRelations->NumItems()>0)
{
for($x=0;$x<$CatRelations->NumItems();$x++)
{
$a = $CatRelations->GetItemByIndex($x);
if($a->type == $TargetType || !strlen($TargetType))
{
$count++;
}
}
}
}
return $count;
}
/*
@description: Returns the MetaKeywords field for a category, or the system MetaKeywords value
if the category doesn't have a value for MetaKeywords
@attrib: _CatId:int: Category to use (The current category is used by default)
*/
function m_meta_keywords($attribs = array())
{
global $objCatList, $objConfig;
$catid = (int)$attribs["_catid"];
if(!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
if($catid)
{
$c = $objCatList->GetItem($catid);
$keywords = $c->Get("MetaKeywords");
}
if(!strlen($keywords))
{
$keywords = $objConfig->Get("MetaKeywords");
}
return $keywords;
}
/*
@description: Returns the MetaDescription field for a category, or the system MetaDescription value
if the category doesn't have a value for MetaDescription
@attrib: _CatId:int: Category to use (The current category is used by default)
*/
function m_meta_description($attribs = array())
{
global $objCatList, $objConfig;
$catid = (int)$attribs["_catid"];
if(!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
if($catid)
{
$c = $objCatList->GetItem($catid);
$desc = $c->Get("MetaDescription");
}
if(!strlen($desc))
{
$desc = $objConfig->Get("MetaDescription");
}
return $desc;
}
/*
@description: return the number of items in the database
@attrib: _ItemType:: Name of item to count
@attrib: _ListType:: Type of item to count (ie: favorites, editor's pick, etc)
@attrib: _CategoryCount:int: Limit scope to the current category
@attrib: _SubCats:bool: Count items in all subcategories (_CategoryCount must be set)
@attrib: _Today:bool: Count items added today
@attrib: _GroupOnly:bool: Only count items the current user can view
@attrib: _NoCache:bool: Count without using cache
*/
function m_itemcount($attribs = array())
{
global $objItemTypes, $objCatList, $objSession, $objCountCache;
$Bit_None = 0;
$Bit_Today = 1;
$Bit_Owner = 2;
$Bit_Global = 4;
$Bit_SubCats=8;
if($attribs["_categorycount"])
{
$evar = m_BuildEnv();
}
else
$evar = "";
$cat = $attribs["_catid"];
if(!is_numeric($cat))
{
$cat = $objCatList->CurrentCategoryID();
}
if((int)$cat>0)
$c = $objCatList->GetCategory($cat);
if(is_numeric($attribs["_itemtype"]))
{
$item = $objItemTypes->GetItem($attribs["_itemtype"]);
}
else
$item = $objItemTypes->GetTypeByName($attribs["_itemtype"]);
$DoUpdate=0;
//echo "<pre>"; print_r($item); echo "</pre>";
$ExtraId="";
if(is_object($item))
{
if($item->Get("ItemType")==1) /* counting categories */
{
$ret = $objCatList->CountCategories($attribs);
}
else
{
$ListVar =& GetItemCollection($attribs["_itemtype"]);
if(is_object($ListVar))
{
$ret = $ListVar->PerformItemCount($attribs);
}
}
}
else
$ret = 0;
return !$ret ? 0 : $ret;
}
/*
@description: Parse a User field and return the value
@attrib: _Field:: User field to parse
@attrib: _UserId:int: Category ID to parse (uses current user if not set)
*/
function m_user_field($attribs)
{
global $objUsers, $objSession;
$o = "";
$userid = $attribs["_userid"];
if(!is_numeric($userid) || $userid=="0")
$userid = $objSession->Get("PortalUserId");
if($userid)
{
$u =& $objUsers->GetItem($userid);
if(is_object($u))
{
$element = new clsHtmlTag();
$element->name = $u->TagPrefix;
$element->attributes = $attribs;
$o = $u->ParseObject($element);
}
}
return $o;
}
/*
@description: Parses a user template
@attrib:_Template:tpl: Template to parse
@attrib:_UserId:int: User ID to parse. If not set, the current user is used
*/
function m_user_detail($attribs = array())
{
global $objTemplate, $objUsers, $objSession;
$tname = $attribs["_template"];
$UserId = (int)$attribs["_userid"];
if(!$UserId)
{
$UserId=$objSession->Get("PortalUserId");
}
if($UserId>0)
{
$u = $objUsers->GetUser($UserId);
$o = $u->ParseTemplate($tname);
}
else
{
$u = new clsPortalUser(NULL);
$o = $u->ParseTemplate($tname);
}
return $o;
}
/*
@description: returns a user field from the current profile being viewed
@example:<inp:m_user_profile_field _Field="login" />
*/
function m_user_profile_field($attribs = array())
{
if((int)$_GET["UserId"])
{
$attribs["_userid"] = $_GET["UserId"];
}
$ret = m_user_field($attribs);
/* if ($ret == '') {
$ret = admin_language("lu_Guest");
}*/
return $ret;
}
/*
@description: Parses a user profile template
@attrib:_Template:tpl: Template to parse
@attrib:_UserId:int: User ID to parse. If not set, the current user is used
*/
function m_user_profile_detail($attribs)
{
if((int)$_GET["UserId"])
{
$attribs["_userid"] = $_GET["UserId"];
}
$ret = m_user_detail($attribs);
return $ret;
}
/*
@description: Lists all user profile fields the user has indicated to be public
@attrib: _ItemTemplate:tpl: Template used to list each field
@example:<inp:m_user_profile _ItemTemplate="view_profile_field" />
*/
function m_user_profile($attribs = array())
{
global $objTemplate, $objUsers;
$tname = $attribs["_itemtemplate"];
$t = $objTemplate->GetTemplate($tname);
if(is_object($t))
{
$html = $t->source;
}
$userid = $_GET["UserId"];
$o = "";
if((int)$userid>0)
{
$u = $objUsers->GetItem($userid);
$vars = $u->GetAllPersistantVars();
foreach($vars as $field=>$value)
{
if(substr($field,0,3)=="pp_")
{
if($value==1)
{
$src = $html;
$src = str_replace("<inp:user_profile_field />","<inp:user _field=\"".substr($field,3)."\" />",$src);
$src = str_replace("lu_profile_field","lu_".$field,$src);
$o .= $u->ParseTemplateText($src);
}
}
}
}
return $o;
}
/*
@description: List users the current user has marked as 'friend'
@attrib: _Status:: Determines which online status to list, either "online" or "offline".
@attrib: _ItemTemplate:tpl: Template used to parse list items
*/
function m_list_friends($attribs = array())
{
global $objUsers, $objSession;
global $online_friends;
$ado = &GetADODBConnection();
$status = strtolower($attribs["_status"]);
$logedin_user = $objSession->Get("PortalUserId");
$u =& $objUsers->GetUser($logedin_user);
//echo "<pre>"; print_r($u); echo "</pre>";
if(!isset($online_friends) || $status=="online")
{
$ftable = GetTablePrefix()."Favorites";
$stable = GetTablePrefix()."UserSession";
$ptable = GetTablePrefix()."PortalUser";
if(isset($online_friends))
{
foreach($online_friends as $id=>$name)
{
$u =& $objUsers->GetUser($id);
$o .= $u->ParseTemplate($attribs["_itemtemplate"]);
}
}
else
{
$sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId,$stable.PortalUserId FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) INNER JOIN $stable ON ";
$sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
//echo $sql;
$rs = $ado->Execute($sql);
while($rs && ! $rs->EOF)
{
$u =& $objUsers->GetItem($rs->fields["PortalUserId"]);
if($status=="online")
{
$o .= $u->ParseTemplate($attribs["_itemtemplate"]);
}
$online_friends[]=$rs->fields["PortalUserId"];
if(ADODB_EXTENSION>0)
{
adodb_movenext($rs);
}
else
$rs->MoveNext();
}
}
}
if($status=="offline")
{
$ftable = GetTablePrefix()."Favorites";
$stable = GetTablePrefix()."UserSession";
$ptable = GetTablePrefix()."PortalUser";
$sessql = "SELECT DISTINCT(PortalUserId) FROM $stable";
if(count($online_friends)>0)
{
$sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND ";
$sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
}
else
{
$sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
}
//echo $sql;
$rs = $ado->Execute($sql);
while($rs && ! $rs->EOF)
{
$u = $objUsers->GetItem($rs->fields["PortalUserId"]);
$o .= $u->ParseTemplate($attribs["_itemtemplate"]);
if(ADODB_EXTENSION>0)
{
adodb_movenext($rs);
}
else
$rs->MoveNext();
}
}
$t = $attribs["_itemtemplate"];
return $o;
}
/*
@description: Returns the number of users the current user has marked as 'friend'
@attrib: _Status:: Determines which online status to count, either "online" or "offline".
*/
function m_friend_count($attribs=array())
{
global $objUsers, $objSession;
global $online_friends;
$ado = &GetADODBConnection();
$logedin_user = $objSession->Get("PortalUserId");
$u =& $objUsers->GetUser($logedin_user);
$status = strtolower($attribs["_status"]);
if(!isset($online_friends) || $status=="online")
{
$ftable = GetTablePrefix()."Favorites";
$stable = GetTablePrefix()."UserSession";
$ptable = GetTablePrefix()."PortalUser";
if(isset($online_friends) && $status="online")
{
return count($online_friends);
}
else
{
$online_friends = array();
$sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId,$stable.PortalUserId FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) INNER JOIN $stable ON ";
$sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
//echo $sql."<br>\n";
$rs = $ado->Execute($sql);
while($rs && ! $rs->EOF)
{
$online_friends[$rs->fields["PortalUserId"]]=$rs->fields["PortalUserId"];
if(ADODB_EXTENSION>0)
{
adodb_movenext($rs);
}
else
$rs->MoveNext();
}
if($status=="online")
return count($online_friends);
}
}
if($status=="offline")
{
$ftable = GetTablePrefix()."Favorites";
$stable = GetTablePrefix()."UserSession";
$ptable = GetTablePrefix()."PortalUser";
$sessql = "SELECT DISTINCT(PortalUserId) FROM $stable";
if(count($online_friends)>0)
{
$sql = "SELECT count($ftable.ResourceId) as ItemCount FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND ";
$sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
}
else
{
$sql = "SELECT count($ftable.ResourceId) as ItemCount FROM $ftable ";
$sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId'];
}
$rs = $ado->Execute($sql);
return $rs->fields["ItemCount"];
}
}
/*
@description: Returns the number of users the current user has marked as 'friend' today
*/
function m_friend_count_today($attribs)
{
global $objSession;
$logedin_user = $objSession->Get("PortalUserId");
$ret =0;
$ado = &GetADODBConnection();
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$sql = "SELECT count(*) as c FROM ".GetTablePrefix()."Favorites WHERE ItemTypeId=6 and PortalUserId=".$objSession->Get("PortalUserId")." AND Modified>$today";
$rs = $ado->Execute($sql);
if($rs && !$rs->EOF)
$ret = $rs->fields["c"];
return $ret;
}
/*
@description: Returns the number of items in a search result
@Example: <span>(<inp:m_search_item_count _ItemType="Topic" />)</span>
*/
function m_search_item_count($attribs)
{
global $objItemTypes, $objCatList, $objSession, $CountVal;
if(!is_array($CountVal))
$CountVal=array();
$item = $objItemTypes->GetTypeByName($attribs["_itemtype"]);
if(is_object($item))
{
$val = $CountVal[$item->Get("ItemType")];
if(is_numeric($val))
return $val;
$where = "ItemType=".$item->Get("ItemType");
$table = $objSession->GetSearchTable();
$ret = TableCount($table,$where,0);
$CountVal[$item->Get("ItemType")]=(int)$ret;
}
-
return $ret;
}
/*
@description: Returns the number of categories in a search result
@Example: <span>(<inp:m_search_cat_count />)</span>
*/
function m_search_cat_count($attribs = array())
{
global $objItemTypes, $objCatList, $objSession, $CountVal, $objSearchCats;
if(!is_object($objSearchCats))
{
$objSearchCats = new clsCatList();
$objSearchCats->SourceTable = $objSession->GetSearchTable();
$objSearchCats->Clear();
}
LoadCatSearchResults($attribs);
//echo "<pre>"; print_r($objSearchCats->Items); echo "</pre>";
$ret = 0;
$keywords = $objSession->GetVariable("Search_Keywords");
if ($keywords) {
foreach ($objSearchCats->Items as $cat) {
if (strstr(strip_tags(strtolower($cat->Data['Name'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($keywords))) {
$ret++;
}
}
}
else {
$ret = $objSearchCats->QueryItemCount;
}
if ($ret == '') {
$ret = 0;
}
//echo $ret;
//$objSearchCats->QueryItemCount = $ret;
return $ret;
}
/*
@description: Returns super global variable by type and name
@attrib: _Name:: Name of variable
@attrib: _Type:: Type super global variable <br>Possible Values:
<UL>
<LI>get: $_GET super variable
<LI>post: $_POST super variable
<LI>cookie: $_COOKIE super variable
<LI>env: $_ENV super variable
<LI>server: $_SERVER super variable
<LI>session: $_SESSION super variable
</UL>
@Example: <inp:m_get_var _name="url" _type="get" />
*/
function m_get_var($attribs = array())
{
global $_GET, $_POST, $_COOKIE, $_FILES, $_ENV, $_SERVER, $_SESSION;
$type = strtolower($attribs['_type']);
$name = $attribs['_name'];
switch ($type)
{
case "get":
$vars = $_GET;
break;
case "cookie":
$vars = $_COOKIE;
break;
case "files":
$vars = $_FILES;
break;
case "server":
$vars = $_SERVER;
break;
case "session":
$vars = $_SESSION;
break;
case "env":
$vars = $_ENV;
break;
case "post":
$vars = $_POST;
break;
default :
$vars = $_POST;
break;
}
$ret = $vars[$name];
return $ret;
}
/*
@description: Returns number of users currently on-line
@attrib: _LastActive:: Last user/session activity in seconds
@attrib: _OwnCount:bool: Count user's own session
*/
function m_users_online($attribs = array())
{
global $objSession;
$LastActive = (int)($attribs['_lastactive']);
$OwnCount = (int)($attribs['_owncount']);
if ($LastActive && !is_null($LastActive))
$sql_add = " AND LastAccessed>".(time()-$LastActive);
if (!$OwnCount || is_null($OwnCount))
$sql_add.= " AND SessionKey!='".$objSession->GetSessionKey()."'";
$ado = &GetADODBConnection();
$sql = "SELECT COUNT(*) AS Counter FROM ".GetTablePrefix()."UserSession WHERE Status=1".$sql_add;
$rs = $ado->Execute($sql);
$ret = ($rs && !$rs->EOF)? $rs->fields["Counter"] : 0;
return $ret;
}
function m_debug_mode($attribs = array())
{
$const_name = $attribs['_debugconst'];
return defined($const_name) && (constant($const_name) == 1) ? 'yes' : '';
}
function m_info($attribs = array())
{
switch ($attribs['_infotype'])
{
case 'site':
global $objConfig;
$ret = ThisDomain().$objConfig->Get('Site_Path');
break;
default:
$ret = '';
break;
}
return $ret;
}
function m_module_enabled($attribs = array())
{
global $objModules;
$module = $attribs['_module'];
// check if module is installed
$ModuleItem = $objModules->GetItemByField('Name', $module);
if( !is_object($ModuleItem) ) return '';
// module is enabled
$ret = $ModuleItem->Get('Loaded') == 1;
// check if installed module is licensed
return $ret && _ModuleLicensed($module) ? 'yes' : '';
}
function m_recall($attribs = array())
{
global $objSession;
return $objSession->GetVariable($attribs['_name']);
}
?>
Property changes on: trunk/kernel/parser.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.16
\ No newline at end of property
+1.17
\ No newline at end of property
Index: trunk/kernel/include/parseditem.php
===================================================================
--- trunk/kernel/include/parseditem.php (revision 639)
+++ trunk/kernel/include/parseditem.php (revision 640)
@@ -1,2951 +1,2953 @@
<?php
global $ItemTypePrefixes;
$ItemTypePrefixes = array();
$ItemTagFiles = array();
function RegisterPrefix($class,$prefix,$file)
{
global $ItemTypePrefixes, $ItemTagFiles;
$ItemTypePrefixes[$class] = $prefix;
$ItemTagFiles[$prefix] = $file;
}
class clsParsedItem extends clsItemDB
{
var $TagPrefix;
var $Parser;
var $AdminParser;
function clsParsedItem($id=NULL)
{
global $TemplateRoot;
$this->clsItemDB();
$this->Parser = new clsTemplateList($TemplateRoot);
$this->AdminParser = new clsAdminTemplateList();
}
/* function ParseObject($element)
{
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
$tag = $this->TagPrefix."_".$field;
$ret = $this->parsetag($tag);
}
return $ret;
}
*/
function ParseTimeStamp($d,$attribs=array())
{
if( isset($attribs["_tz"]) )
{
$d = GetLocalTime($d,$objSession->Get("tz"));
}
$part = isset($attribs["_part"]) ? strtolower($attribs["_part"]) : '';
if(strlen($part))
{
$ret = ExtractDatePart($part,$d);
}
else
{
if($d<=0)
{
$ret = "";
}
else
$ret = LangDate($d);
}
return $ret;
}
function ParseObject($element)
{
global $objConfig, $objCatList, $var_list_update, $var_list, $n_var_list_update, $m_var_list_update;
$extra_attribs = ExtraAttributes($element->attributes);
$ret = "";
if ($this->TagPrefix == "email" && strtolower($element->name) == "touser") {
$this->TagPrefix = "touser";
}
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "id":
$ret = $this->Get($this->id_field);
break;
case "resourceid":
if(!$this->NoResourceId)
$ret = $this->Get("ResourceId");
break;
case "category":
$c = $objCatList->GetItem($this->Get("CategoryId"));
if(is_object($c))
{
$ret = $c->parsetag($element->attributes["_cattag"]);
}
break;
case "priority":
if($this->Get("Priority")!=0)
{
$ret = (int)$this->Get("Priority");
}
else
$ret = "";
break;
case "link":
if(method_exists($this,"ItemURL"))
{
$ret = $this->ItemURL($element->attributes["_template"],FALSE,"");
}
break;
case "cat_link":
if(method_exists($this,"ItemURL"))
{
$ret = $this->ItemURL($element->attributes["_template"],TRUE,"");
}
break;
case "fullpath":
$ret = $this->Get("CachedNavbar");
if(!strlen($ret))
{
if(is_numeric($this->Get("CategoryId")))
{
$c = $objCatList->GetItem($this->Get("CategoryId"));
if(is_object($c))
$ret = $c->Get("CachedNavbar");
}
else
{
if(method_exists($this,"GetPrimaryCategory"))
{
$cat = $this->GetPrimaryCategory();
$c = $objCatList->GetItem($cat);
if(is_object($c))
$ret = $c->Get("CachedNavbar");
}
}
}
// $ret = $this->HighlightText($ret);
break;
case "relevance":
$style = $element->attributes["_displaymode"];
if(!strlen($style))
$style = "numerical";
switch ($style)
{
case "numerical":
$ret = (100 * LangNumber($this->Get("Relevance"),1))."%";
break;
case "bar":
$OffColor = $element->attributes["_offbackgroundcolor"];
$OnColor = $element->attributes["_onbackgroundcolor"];
$percentsOff = (int)(100 - (100 * $this->Get("Relevance"))); if ($percentsOff)
{
$percentsOn = 100 - $percentsOff;
$ret = "<td width=\"$percentsOn%\" bgcolor=\"$OnColor\"><img src=\"img/s.gif\"></td><td width=\"$percentsOff%\" bgcolor=\"$OffColor\"><img src=\"img/s.gif\"></td>";
}
else
$ret = "<td width=\"100%\" bgcolor=\"$OnColor\"><img src=\"img/s.gif\"></td>";
break;
case "graphical":
$OnImage = $element->attributes["_onimage"];
if (!strlen($OnImage))
break;
// Get image extension
$image_data = explode(".", $OnImage);
$image_ext = $image_data[count($image_data)-1];
unset($image_data[count($image_data)-1]);
$rel = (10 * LangNumber($this->Get("Relevance"),1));
$OnImage1 = join(".", $image_data);
if ($rel)
$img_src = $OnImage1."_".$rel.".".$image_ext;
else
$img_src = $OnImage;
$ret = "<img src=\"$img_src\" border=\"0\" alt=\"".(10*$rel)."\">";
break;
}
break;
case "rating":
$style = $element->GetAttributeByName("_displaymode");
if(!strlen($style))
$style = "numerical";
switch($style)
{
case "numerical":
$ret = LangNumber($this->Get("CachedRating"),1);
break;
case "text":
$ret = RatingText($this->Get("CachedRating"));
break;
case "graphical":
$OnImage = $element->attributes["_onimage"];
$OffImage = $element->attributes["_offimage"];
$images = RatingTickImage($this->Get("CachedRating"),$OnImage,$OffImage);
for($i=1;$i<=count($images);$i++)
{
$url = $images[$i];
if(strlen($url))
{
$ret .= "<IMG src=\"$url\" $extra_attribs >";
$ret .= $element->attributes["_separator"];
}
}
break;
}
break;
case "reviews":
$today = FALSE;
if(method_exists($this,"ReviewCount"))
{
if($element->GetAttributeByName("_today"))
$today = TRUE;
$ret = $this->ReviewCount($today);
}
else
$ret = "";
break;
case "votes":
$ret = (int)$this->Get("CachedVotesQty");
break;
case "favorite":
if(method_exists($this,"IsFavorite"))
{
if($this->IsFavorite())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_favorite";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "new":
if(method_exists($this,"IsNewItem"))
{
if($this->IsNewItem())
{
$ret = $element->GetAttributeByName('_label');
if(!strlen($ret))
$ret = "lu_new";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "pop":
if(method_exists($this,"IsPopItem"))
{
if($this->IsPopItem())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_pop";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "hot":
if(method_exists($this,"IsHotItem"))
{
if($this->IsHotItem())
{
$ret = $element->GetAttributeByName("_label");
if(!strlen($ret))
$ret = "lu_hot";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "pick":
if($this->Get("EditorsPick")==1)
{
$ret = $element->GetAttributeByName('_label');
if(!strlen($ret))
$ret = "lu_pick";
$ret = language($ret);
}
else
$ret = "";
break;
case "admin_icon":
if(method_exists($this,"StatusIcon"))
{
if($element->GetAttributeByName("fulltag"))
{
$ret = "<IMG $extra_attribs SRC=\"".$this->StatusIcon()."\">";
}
else
$ret = $this->StatusIcon();
}
break;
case "custom":
if(method_exists($this,"GetCustomFieldValue"))
{
$field = $element->attributes["_customfield"];
$default = $element->attributes["_default"];
if (strlen($field))
$ret = $this->GetCustomFieldValue($field,$default);
}
break;
case "image":
$default = $element->attributes["_primary"];
$name = $element->attributes["_name"];
if(strlen($name))
{
$img = $this->GetImageByName($name);
}
else
{
if($default)
$img = $this->GetDefaultImage();
}
if(is_object($img))
{
if(strlen($element->attributes["_imagetemplate"]))
{
$ret = $img->ParseTemplate($element->attributes["_imagetemplate"]);
break;
}
else
{
if($element->attributes["_thumbnail"])
{
$url = $img->parsetag("thumb_url");
}
else
{
if(!$element->attributes["_nothumbnail"])
{
$url = $img->parsetag("image_url");
}
else
{
$url = $img->FullURL(TRUE,"");
}
}
}
}
else
{
$url = $element->attributes["_defaulturl"];
}
if($element->attributes["_imagetag"])
{
if(strlen($url))
{
$ret = "<IMG src=\"$url\" $extra_attribs >";
}
else
$ret = "";
}
else
$ret = $url;
break;
default:
$ret = "Undefined:".$element->name;
break;
}
}
else if ($this->TagPrefix == 'email'){
$ret = "Undefined:".$element->name;
}
return $ret;
}
function ParseString($name)
{
$el = new clsHtmlTag();
$el->Clear();
$el->prefix = "inp";
$el->name = $name;
$numargs = func_num_args();
$arg_list = func_get_args();
for ($i = 1; $i < $numargs; $i++)
{
$attr = $arg_list[$i];
$parts = explode("=",$attr,2);
$name = $parts[0];
$val = $parts[1];
$el->attributes[$name] = $val;
}
return $this->ParseObject($el);
}
/* pass attributes as strings
ie: ParseStringEcho('tagname','_field="something" _data="somethingelse"');
*/
function ParseStringEcho($name)
{
$el = new clsHtmlTag();
$el->Clear();
$el->prefix = "inp";
$el->name = $name;
$numargs = func_num_args();
$arg_list = func_get_args();
for ($i = 1; $i < $numargs; $i++)
{
$attr = $arg_list[$i];
$parts = explode("=",$attr,2);
$name = $parts[0];
$val = $parts[1];
$el->attributes[$name] = $val;
}
echo $this->ParseObject($el);
}
function ParseElement($raw, $inner_html ="")
{
$tag = new clsHtmlTag($raw);
$tag->inner_html = $inner_html;
if($tag->parsed)
{
if($tag->name=="include" || $tag->name=="perm_include" || $tag->name=="lang_include")
{
$output = $this->Parser->IncludeTemplate($tag);
}
else
{
$output = $this->ParseObject($tag);
//echo $output."<br>";
if(substr($output,0,9)=="Undefined")
{
$output = $tag->Execute();
// if(substr($output,0,8)="{Unknown")
// $output = $raw;
} return $output;
}
}
else
return "";
}
function AdminParseTemplate($file)
{
$html = "";
$t = $this->AdminParser->GetTemplate($file);
if(is_object($t))
{
array_push($this->AdminParser->stack,$file);
$html = $t->source;
$next_tag = strpos($html,"<inp:");
while($next_tag)
{
$end_tag = strpos($html,"/>",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseElement($tagtext);
$html = $pre.$inner.$post;
$next_tag = strpos($html,"<inp:");
}
array_pop($this->AdminParser->stack);
}
return $html;
}
function ParseTemplateText($text)
{
$html = $text;
$search = "<inp:".$this->TagPrefix;
//$next_tag = strpos($html,"<inp:");
$next_tag = strpos($html,$search);
while($next_tag)
{
$closer = strpos(strtolower($html),">",$next_tag);
$end_tag = strpos($html,"/>",$next_tag);
if($end_tag < $closer || $closer == 0)
{
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseElement($tagtext);
$html = $pre.$inner.$post;
}
else
{
$OldTagStyle = "</inp>";
## Try to find end of TagName
$TagNameEnd = strpos($html, " ", $next_tag);
## Support Old version
// $closer = strpos(strtolower($html),"</inp>",$next_tag);
if ($TagNameEnd)
{
$Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag));
$TagName = explode(":", $Tag);
if (strlen($TagName[1]))
$CloserTag = "</inp:".$TagName[1].">";
}
else
{
$CloserTag = $OldTagStyle;
}
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
## Try to find old tag closer
if (!$closer && ($CloserTag != $OldTagStyle))
{
$CloserTag = $OldTagStyle;
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
}
$end_tag = strpos($html,">",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1);
$pre = substr($html,0,$next_tag);
$inner = substr($html,$end_tag+1,$closer-($end_tag+1));
$post = substr($html,$end_tag+1+strlen($inner) + strlen($CloserTag));
//echo "PRE:". htmlentities($pre,ENT_NOQUOTES);
//echo "INNER:". htmlentities($inner,ENT_NOQUOTES);
//echo "POST:". htmlentities($post,ENT_NOQUOTES);
$parsed = $this->ParseElement($tagtext);
if(strlen($parsed))
{
$html = $pre.$this->ParseTemplateText($inner).$post;
}
else
$html = $pre.$post;
}
$next_tag = strpos($html,$search);
}
return $html;
}
function ParseTemplate($tname)
{
global $objTemplate, $LogLevel,$ptime,$timestart;
//echo 'Saving ID'.$this->UniqueId().' in Main parseTempalate<br>';
//$GLOBALS[$this->TagPrefix.'_ID'] = $this->UniqueId();
LogEntry("Parsing $tname\n");
$LogLevel++;
$html = "";
$t = $objTemplate->GetTemplate($tname);
//$t = $this->Parser->GetTemplate($tname);
if( is_array($this->Parser->stack) ) $this->Parser->stack = Array();
if(is_object($t))
{
array_push($this->Parser->stack,$tname);
$html = $t->source;
$html = $this->ParseTemplateText($html);
array_pop($this->Parser->stack);
}
$LogLevel--;
LogEntry("Finished Parsing $tname\n");
$ptime = round(getmicrotime() - $timestart,6);
$xf = 867530; //Download ID
if($xf != 0)
{
$x2 = substr($ptime,-6);
$ptime .= $xf ^ $x2; //(1/1000);
}
return $html;
}
function SendUserEventMail($EventName,$ToUserId,$LangId=NULL,$RecptName=NULL)
{
global $objMessageList,$FrontEnd;
$Event =& $objMessageList->GetEmailEventObject($EventName,0,$LangId);
if(is_object($Event))
{
if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd))
{
$Event->Item = $this;
if(is_numeric($ToUserId))
{
return $Event->SendToUser($ToUserId);
}
else
return $Event->SendToAddress($ToUserId,$RecptName);
}
}
}
function SendAdminEventMail($EventName,$LangId=NULL)
{
global $objMessageList,$FrontEnd;
//echo "Firing Admin Event $EventName <br>\n";
$Event =& $objMessageList->GetEmailEventObject($EventName,1,$LangId);
if(is_object($Event))
{
if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd))
{
$Event->Item = $this;
//echo "Admin Event $EventName Enabled <br>\n";
return $Event->SendAdmin($ToUserId);
}
}
}
function parse_template($t)
{
}
}
class clsItemCollection
{
var $Items;
var $CurrentItem;
var $adodbConnection;
var $classname;
var $SourceTable;
var $LiveTable;
var $QueryItemCount;
var $AdminSearchFields = array();
var $SortField;
var $debuglevel;
var $id_field = null; // id field for list item
var $BasePermission;
var $Dummy = null;
// enshure that same sql won't be queried twice
var $QueryDone = false;
var $LastQuerySQL = '';
function SetTable($action, $table_name = null) // new by Alex
{
// $action = {'live', 'restore','edit'}
switch($action)
{
case 'live':
$this->LiveTable = $table_name;
$this->SourceTable = $this->LiveTable;
break;
case 'restore':
$this->SourceTable = $this->LiveTable;
break;
case 'edit':
global $objSession;
$this->SourceTable = $objSession->GetEditTable($this->LiveTable);
break;
}
}
function &GetDummy() // new by Alex
{
if( !isset($this->Dummy) )
$this->Dummy =& new $this->classname();
$this->Dummy->tablename = $this->SourceTable;
return $this->Dummy;
}
function clsItemCollection()
{
$this->adodbConnection = &GetADODBConnection();
$this->Clear();
$this->BasePermission="";
}
function GetIDField() // new by Alex
{
// returns id field for list item
if( !isset($this->id_field) )
{
$dummy =& $this->GetDummy();
$this->id_field = $dummy->IdField();
}
return $this->id_field;
}
function &GetNewItemClass()
{
return new $this->classname();
}
function Clear()
{
unset($this->Items);
$this->Items = array();
$this->CurrentItem=0;
}
function &SetCurrentItem($id)
{
$this->CurrentItem=$id;
return $this->GetItem($id);
}
function &GetCurrentItem()
{
if($this->CurrentItem>0)
{
return $this->GetItem($this->CurrentItem);
}
else
return FALSE;
}
function NumItems()
{
if(is_array($this->Items))
{
// echo "TEST COUNT: ".count($this->Items)."<BR>";
return count($this->Items);
}
else
return 0;
}
function ItemLike($index, $string)
{
// check if any of the item field
// even partially matches $string
$found = false;
$string = strtolower($string);
$item_data = $this->Items[$index]->GetData();
foreach($item_data as $field => $value)
if( in_array($field, $this->AdminSearchFields) )
if( strpos(strtolower($value), $string) !== false)
{
$found = true;
break;
}
return $found;
}
function DeleteItem($index) // by Alex
{
// deletes item with specific index from list
$i = $index; $item_count = $this->NumItems();
while($i < $item_count - 1)
{
$this->Items[$i] = $this->Items[$i + 1];
$i++;
}
unset($this->Items[$i]);
}
function ShowItems()
{
$i = 0; $item_count = $this->NumItems();
while($i < $item_count)
{
echo "Item No <b>$i</b>:<br>";
$this->Items[$i]->PrintVars();
$i++;
}
}
function SwapItems($Index,$Index2)
{
$temp = $this->Items[$Index]->GetData();
$this->Items[$Index]->SetData($this->Items[$Index2]->GetData());
$this->Items[$Index2]->SetData($temp);
}
function CopyResource($OldId,$NewId)
{
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$OldId";
$this->Query_Item($sql);
// echo $sql."<br>\n";
if($this->NumItems()>0)
{
foreach($this->Items as $item)
{
$item->UnsetIdField();
$item->Set("ResourceId",$NewId);
$item->Create();
}
}
}
function ItemsOnClipboard()
{
global $objSession;
$clip = $objSession->GetPersistantVariable("ClipBoard");
$count = 0;
$table = $this->SourceTable;
$prefix = GetTablePrefix();
if(substr($table,0,strlen($prefix))==$prefix)
$table = substr($table,strlen($prefix));
if(strlen($clip))
{
$clipboard = ParseClipboard($clip);
if($clipboard["table"] == $table)
{
$count = count(explode(",",$clipboard["ids"]));
}
else
$count = 0;
}
else
$count = 0;
return $count;
}
function CopyToClipboard($command,$idfield, $idlist)
{
global $objSession,$objCatList;
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$clip = $command."-".$objCatList->CurrentCategoryID().".".$this->SourceTable.".$idfield=".$list;
$objSession->SetVariable("ClipBoard",$clip);
}
function SortItems($asc=TRUE)
{
$done = FALSE;
$field = $this->SortField;
$ItemCount = $this->NumItems();
while(!$done)
{
$done=TRUE;
for($i=1;$i<$this->NumItems();$i++)
{
$doswap = FALSE;
if($asc)
{
$val1 = $this->Items[$i-1]->Get($field);
$val2 = $this->Items[$i]->Get($field);
$doswap = ($val1 > $val2);
}
else
{
$val1 = $this->Items[$i-1]->Get($field);
$val2 = $this->Items[$i]->Get($field);
$doswap = ($val1 < $val2);
}
if($doswap)
{
$this->SwapItems($i-1,$i);
$done = FALSE;
}
}
}
}
function &GetItem($ID,$LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items) && count($this->Items) )
{
for($x=0;$x<count($this->Items);$x++)
{
$i =& $this->GetItemRefByIndex($x);
if($i->UniqueID()==$ID)
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
if($LoadFromDB)
{
$n = NULL;
$n = new $this->classname();
$n->tablename = $this->SourceTable;
$n->LoadFromDatabase($ID);
$index = array_push($this->Items, $n);
$i =& $this->Items[count($this->Items)-1];
}
else
$i = FALSE;
}
return $i;
}
function GetItemByIndex($index)
{
return $this->Items[$index];
}
function &GetItemRefByIndex($index)
{
return $this->Items[$index];
}
function &GetItemByField($Field,$Value,$LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->Get($Field)==$Value)
{
$found = TRUE;
break;
}
}
}
if(!$found && $LoadFromDB==TRUE)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE $Field = '$Value'";
//echo $sql;
$res = $this->adodbConnection->Execute($sql);
if($res && !$res->EOF)
{
$i = $this->AddItemFromArray($res->fields);
$i->tablename = $this->SourceTable;
$i->Clean();
}
else
$i = FALSE;
}
return $i;
}
function GetPage($Page, $ItemsPerPage)
{
$result = array_slice($this->Items, ($Page * $ItemsPerPage) - $ItemsPerPage, $ItemsPerPage);
return $result;
}
function GetNumPages($ItemsPerPage)
{
if( isset($_GET['reset']) && $_GET['reset'] == 1) $this->Page = 1;
return GetPageCount($ItemsPerPage,$this->QueryItemCount);
}
function &AddItemFromArray($data, $clean=FALSE)
{
$class = new $this->classname;
$class->SetFromArray($data);
$class->tablename = $this->SourceTable;
if($clean==TRUE)
$class->Clean();
//array_push($this->Items,$class);
$this->Items[] =& $class;
return $class;
}
function Query_Item($sql, $offset=-1,$rows=-1)
{
global $Errors;
//echo "Method QItem [<b>".get_class($this).'</b>], sql: ['.$sql.']<br>';
//if( get_class($this) == 'clsthemefilelist') trace();
$dummy =& $this->GetDummy();
if( !$dummy->TableExists() )
{
if($this->debuglevel) echo "ERROR: table <b>".$dummy->tablename."</b> missing.<br>";
$this->Clear();
return false;
}
if($rows>-1 && $offset>-1)
{
+ //print_pre(debug_backtrace());
//echo "<b>Executing SelectLimit</b> $sql <b>Offset:</b> $offset,$rows<br>\n";
$result = $this->adodbConnection->SelectLimit($sql, $rows,$offset);
}
else {
$result = $this->adodbConnection->Execute($sql);
}
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Query_Item");
if($this->debuglevel) {
echo '<br><br>'.$sql.'<br><br>';
echo "Error: ".$this->adodbConnection->ErrorMsg()."<br>";
}
$this->Clear();
return false;
}
$this->Clear();
-
+
if($this->debuglevel > 0)
{
- echo "This SQL: $sql<br>";
+ echo "This SQL: $sql<br><br>";
if( ($this->debuglevel > 1) && ($result->RecordCount() > 0) )
{
echo '<pre>'.print_r($result->GetRows(), true).'</pre>';
$result->MoveFirst();
}
}
+ //echo "SQL: $sql<br><br>";
LogEntry("SQL Loop Start\n");
$count = 0;
while ($result && !$result->EOF)
{
$count++;
$data = $result->fields;
$this->AddItemFromArray($data,TRUE);
if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
adodb_movenext($result);
else
$result->MoveNext();
}
LogEntry("SQL Loop End ($count iterations)\n");
$result->Free();
return $this->Items;
}
function GetOrderClause($FieldVar,$OrderVar,$DefaultField,$DefaultVar,$Priority=TRUE,$UseTableName=FALSE)
{
global $objConfig, $objSession;
if($UseTableName)
{
$TableName = $this->SourceTable.".";
}
else
$TableName = "";
$PriorityClause = $TableName."EditorsPick DESC, ".$TableName."Priority DESC";
if(strlen(trim($FieldVar))>0)
{
if(is_object($objSession))
{
if(strlen($objSession->GetPersistantVariable($FieldVar))>0)
{
$OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ".
$objSession->GetPersistantVariable($OrderVar));
$FieldUsed = $objSession->GetPersistantVariable($FieldVar);
}
}
$OrderBy = trim($OrderBy);
if (strlen(trim($OrderBy))==0)
{
if(!$UseTableName)
{
$OrderBy = trim($DefaultField." ".$DefaultVar);
}
else
{
if(strlen(trim($DefaultField))>0)
{
$OrderBy = $this->SourceTable.".".$DefaultField.".".$DefaultVar;
}
$FieldUsed=$DefaultField;
}
}
}
if(($FieldUsed != "Priority" || strlen($OrderBy)==0) && $Priority==TRUE)
{
if(strlen($OrderBy)==0)
{
$OrderBy = $PriorityClause;
}
else
$OrderBy = $PriorityClause.", ".$OrderBy;
}
return $OrderBy;
}
function GetResourceIDList()
{
$ret = array();
foreach($this->Items as $i)
array_push($ret,$i->Get("ResourceId"));
return $ret;
}
function GetFieldList($field)
{
$ret = array();
foreach($this->Items as $i)
array_push($ret,$i->Get($field));
return $ret;
}
function SetCommonField($FieldName,$FieldValue)
{
for($i=0;$i<$this->NumItems();$i++)
{
$this->Items[$i]->Set($FieldName,$fieldValue);
$this->Items[$i]->Update();
}
}
function ClearCategoryItems($CatId,$CatTable = "CategoryItems")
{
$CatTable = AddTablePrefix($CatTable);
$sql = "SELECT * FROM ".$this->SourceTable." INNER JOIN $CatTable ".
" ON (".$this->SourceTable.".ResourceId=$CatTable.ItemResourceId) WHERE CategoryId=$CatId";
$this->Clear();
$this->Query_Item($sql);
if($this->NumItems()>0)
{
foreach($this->Items as $i)
{
$i->DeleteCategoryItems($CatId,$CatTable);
}
}
}
function CopyToEditTable($idfield = null, $idlist = 0)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function CreateEmptyEditTable($idfield = null)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield = -1";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
//echo $insert."<br>";
}
function CopyFromEditTable($idfield = null)
{
global $objSession;
$dropRelTableFlag = false;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table";
$rs = $this->adodbConnection->Execute($sql);
//echo "In Main <b>CopyFromEditTable</b> in class <b>".get_class($this).'</b><br>';
//echo $sql."<BR>";
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->idfield = $idfield;
$c->Dirty();
if($c->Get($idfield) < 1)
{
$old_id = $c->Get($idfield);
$c->UnsetIdField();
if(!is_numeric($c->Get("OrgId")) || $c->Get("OrgId")==0)
{
$c->Clean(array("OrgId"));
}
else
{
if($c->Get("Status") != -2)
{
$org = new $this->classname();
$org->LoadFromDatabase($c->Get("OrgId"));
$org->DeleteCustomData();
$org->Delete(TRUE);
$c->Set("OrgId",0);
}
}
$c->Create();
}
if(is_numeric($c->Get("ResourceId")))
{
if( isset($c->Related) && is_object($c->Related) )
{
$r = $c->Related;
$r->CopyFromEditTable($c->Get("ResourceId"));
$dropRelTableFlag = true;
}
unset($r);
if( isset($c->Reviews) && is_object($c->Reviews) )
{
$r = $c->Reviews;
$r->CopyFromEditTable($c->Get("ResourceId"));
}
}
if(!is_numeric($c->Get("OrgId")) || $c->Get("OrgId")==0)
{
$c->Clean(array("OrgId"));
}
else
{
if($c->Get("Status") != -2)
{
$org = new $this->classname();
$org->LoadFromDatabase($c->Get("OrgId"));
$org->DeleteCustomData();
$org->Delete(TRUE);
$c->Set("OrgId",0);
}
}
if(method_exists($c,"CategoryMemberList"))
{
$cats = $c->CategoryMemberList($objSession->GetEditTable("CategoryItems"));
$ci_table = $objSession->GetEditTable('CategoryItems');
$primary_cat = $c->GetPrimaryCategory($ci_table);
$c->Update();
UpdateCategoryItems($c,$cats,$primary_cat);
}
else
$c->Update();
unset($c);
unset($r);
$rs->MoveNext();
}
if ($dropRelTableFlag)
{
$objRelGlobal = new clsRelationshipList();
$objRelGlobal->PurgeEditTable();
}
if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->GetEditTable("CategoryItems"));
}
function GetNextTempID()
{
// get next temporary id (lower then zero) from temp table
$db =& $this->adodbConnection;
$sql = 'SELECT MIN(%s) AS MinValue FROM %s';
return $db->GetOne( sprintf($sql, $this->GetIDField(), $this->SourceTable) ) - 1;
}
function PurgeEditTable($idfield = null)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
/* $rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table");
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->id_field = $idfield;
$c->tablename = $edit_table;
$c->Delete();
$rs->MoveNext();
}*/
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->Get("CategoryItems"));
}
function CopyCatListToEditTable($idfield, $idlist)
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function CreateEmptyCatListTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield = -1";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function PurgeCatListEditTable()
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
function AdminSearchWhereClause($SearchList)
{
$sql = "";
if( !is_array($SearchList) ) $SearchList = explode(",",$SearchList);
if( !count($SearchList) || !count($this->AdminSearchFields) ) return '';
for($f = 0; $f < count($SearchList); $f++)
{
$value = $SearchList[$f];
if( strlen($value) )
{
$inner_sql = "";
for($i = 0; $i < count($this->AdminSearchFields); $i++)
{
$field = $this->AdminSearchFields[$i];
if( strlen( trim($value) ) )
{
if( strlen($inner_sql) ) $inner_sql .= " OR ";
$inner_sql .= $field." LIKE '%".$value."%'";
}
}
if( strlen($inner_sql) )
{
$sql .= '('.$inner_sql.') ';
if($f < count($SearchList) - 1) $sql .= " AND ";
}
}
}
return $sql;
}
function BackupData($OutFileName,$Start,$Limit)
{
$fp=fopen($Outfile,"a");
if($fp)
{
if($Start==1)
{
$sql = "DELETE FROM ".$this->SourceTable;
fputs($fp,$sql);
}
$this->Query_Item("SELECT * FROM ".$this->SourceTable." LIMIT $Start, $Limit");
foreach($this->Items as $i)
{
$sql = $i->CreateSQL();
fputs($fp,$sql);
}
fclose($fp);
$this->Clear();
}
}
function RestoreData($InFileName,$Start,$Limit)
{
$res = -1;
$fp=fopen($InFileName,"r");
if($fp)
{
fseek($fp,$Start);
$Line = 0;
while($Line < $Limit)
{
$sql = fgets($fp,16384);
$this->adodbConnection->Execute($sql);
$Line++;
}
$res = ftell($fp);
fclose($fp);
}
return $res;
}
function Delete_Item($Id)
{
global $objCatList;
$l =& $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->DeleteCategoryItems($objCatList->CurrentCategoryID());
}
function Move_Item($Id, $OldCat, $ParentTo)
{
global $objCatList;
$l = $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->AddtoCategory($ParentTo);
$l->RemoveFromCategory($OldCat);
}
function Copy_Item($Id, $ParentTo)
{
$l = $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->AddtoCategory($ParentTo);
}
}/* clsItemCollection */
class clsItemList extends clsItemCollection
{
var $Page;
var $PerPageVar;
var $DefaultPerPage; // use this perpage value in case if no found in config
var $EnablePaging;
var $MaxListCount = 0;
var $PageEnvar;
var $PageEnvarIndex;
var $ListType;
var $LastLimitClause = ''; // used to store last limit cluse used in query
function clsItemList()
{
$this->clsItemCollection();
$this->EnablePaging = TRUE;
$this->PageEnvarIndex = "p";
}
function GetPageLimitSQL()
- {
+ {
global $objConfig;
$limit = NULL;
if($this->EnablePaging)
{
if($this->Page<1)
$this->Page=1;
//echo "Limited to ".$objConfig->Get($this->PerPageVar)." items per page<br>\n";
if(is_numeric($objConfig->Get($this->PerPageVar)))
{
$Start = ($this->Page-1)*$objConfig->Get($this->PerPageVar);
$limit = "LIMIT ".$Start.",".$objConfig->Get($this->PerPageVar);
}
else
$limit = NULL;
}
else
{
if($this->MaxListCount)
{
$limit = "LIMIT 0, $MaxListCount";
}
}
return $limit;
}
function GetPageOffset()
{
$Start = 0;
if($this->EnablePaging)
- {
+ {
if($this->Page < 1) $this->Page = 1;
$PerPage = $this->GetPerPage();
$Start = ($this->Page - 1) * $PerPage;
}
else
- {
+ {
if((int)$this->MaxListCount == 0) $Start = -1;
}
return $Start;
}
function GetPageRowCount()
{
if($this->EnablePaging)
{
if($this->Page < 1) $this->Page = 1;
return $this->GetPerPage();
}
else
return (int)$this->MaxListCount;
}
function Query_Item($sql,$limit = null, $fix_method = 'set_first')
{
// query itemlist (module items) using $sql specified
// apply direct limit clause ($limit) or calculate it if not specified
// fix invalid page in case if needed by method specified in $fix_method
if(strlen($limit))
{
$sql .= " ".$limit;
return parent::Query_Item($sql);
}
else
- {
+ {
//echo "page fix pre (class: ".get_class($this).")<br>";
$this->QueryItemCount = QueryCount($sql); // must get total item count before fixing
$this->FixInvalidPage($fix_method);
// specially made for cats delete
if ( GetVar('Action', true) != 'm_cat_delete') {
return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount());
}
else {
return parent::Query_Item($sql);
}
}
}
function Query_List($whereClause,$orderByClause=NULL,$JoinCats=TRUE,$fix_method='set_first')
{
global $objSession, $Errors;
if($JoinCats)
{
$cattable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT *,CategoryId FROM $t INNER JOIN $cattable ON $cattable.ItemResourceId=$t.ResourceId";
}
else
$sql = "SELECT * FROM ". $this->SourceTable;
if(trim($whereClause)!="")
{
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
}
if(strlen($orderByClause)>0)
{
if(substr($orderByClause,0,8)=="ORDER BY")
{
$sql .= " ".$orderByClause;
}
else
{
$sql .= " ORDER BY $orderByClause";
}
}
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
return $this->Query_Item($sql, null, $fix_method);
}
function GetPerPage()
{
// return category perpage
global $objConfig;
$PerPage = $objConfig->Get( $this->PerPageVar );
if( !is_numeric($PerPage) ) $PerPage = $this->DefaultPerPage ? $this->DefaultPerPage : 10;
return $PerPage;
}
function FixInvalidPage($fix_method = 'set_first')
{
// in case if current page > total page count,
// then set current page to last possible "set_last"
// or first possible "set_first"
$PerPage = $this->GetPerPage();
$NumPages = ceil( $this->GetNumPages($PerPage) );
/*
echo "=====<br>";
echo "Class <b>".get_class($this)."</b>: Page ".$this->Page." of $NumPages<br>";
echo "PerPage: $PerPage<br>";
echo "Items Queries: ".$this->QueryItemCount."<br>";
echo "=====<br>";
*/
if($this->Page > $NumPages)
{
switch($fix_method)
{
case 'set_first':
$this->Page = 1;
//echo "Move 2 First (class <b>".get_class($this)."</b>)<br>";
break;
case 'set_last':
$this->Page = $NumPages;
//echo "Move 2 Last (class <b>".get_class($this)."</b>)<br>";
break;
}
$this->SaveNewPage();
}
}
function SaveNewPage()
{
// redefine in each list, should save to env array new page value
}
function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE,$EnvSuffix = '')
{
global $objConfig, $var_list_update, $var_list;
$v= $this->PageEnvar;
global ${$v};
if(!strlen($page))
$page = GetIndexURL();
$PerPage = $objConfig->Get($this->PerPageVar);
if($PerPage<1)
$PerPage=20;
$NumPages = ceil($this->GetNumPages($PerPage));
if($NumPages==1 && $HideEmpty)
return "";
if(strlen($dest_template))
{
$var_list_update["t"] = $dest_template;
}
else
$var_list_update["t"] = $var_list["t"];
$o = "";
if($this->Page==0 || !is_numeric($this->Page))
$this->Page=1;
if($this->Page>$NumPages)
$this->Page=$NumPages;
$StartPage = (int)$this->Page - ($PagesToList/2);
if($StartPage<1)
$StartPage=1;
$EndPage = $StartPage+($PagesToList-1);
if($EndPage>$NumPages)
{
$EndPage = $NumPages;
$StartPage = $EndPage-($PagesToList-1);
if($StartPage<1)
$StartPage=1;
}
$o = "";
if($StartPage>1)
{
${$v}[$this->PageEnvarIndex] = $this->Page-$PagesToList;
$prev_url = $page."?env=".BuildEnv().$EnvSuffix;
$o .= "<A HREF=\"$prev_url\">&lt;&lt;</A>";
}
for($p=$StartPage;$p<=$EndPage;$p++)
{
if($p!=$this->Page)
{
${$v}[$this->PageEnvarIndex]=$p;
$href = $page."?env=".BuildEnv().$EnvSuffix;
$o .= " <A HREF=\"$href\">$p</A> ";
}
else
{
$o .= " <SPAN class=\"current-page\">$p</SPAN>";
}
}
if($EndPage<$NumPages && $EndPage>0)
{
${$v}[$this->PageEnvarIndex]=$this->Page+$PagesToList;
$next_url = $page."?env=".BuildEnv().$EnvSuffix;
$o .= "<A HREF=\"$next_url\"> &gt;&gt;</A>";
}
unset(${$v}[$this->PageEnvarIndex],$var_list_update["t"] );
return $o;
}
function GetAdminPageLinkList($url)
{
global $objConfig;
$update =& $GLOBALS[$this->PageEnvar]; // env_var_update
// insteresting stuff :)
if(!$this->PerPageVar) $this->PerPageVar = "Perpage_Links";
$PerPage = $objConfig->Get($this->PerPageVar);
if($PerPage < 1) $PerPage = 20;
$NumPages = ceil($this->GetNumPages($PerPage));
//echo $this->CurrentPage." of ".$NumPages." Pages";
if($this->Page > $NumPages) $this->Page = $NumPages;
$StartPage = $this->Page - 5;
if($StartPage < 1) $StartPage = 1;
$EndPage = $StartPage + 9;
if($EndPage > $NumPages)
{
$EndPage = $NumPages;
$StartPage = $EndPage-9;
if($StartPage < 1) $StartPage = 1;
}
$o = '';
if($StartPage > 1)
{
$update[$this->PageEnvarIndex]= $this->Page - 10;
$prev_url = $url.'?env='.BuildEnv();
$o .= '<a href="'.$prev_url.'">&lt;&lt;</a>';
}
for($p = $StartPage; $p <= $EndPage; $p++)
{
if($p != $this->Page)
{
$update[$this->PageEnvarIndex] = $p;
$href = $url.'?env='.BuildEnv();
$o .= ' <a href="'.$href.'" class="NAV_URL">'.$p.'</a> ';
}
else
{
$o .= '<SPAN class="CURRENT_PAGE">'.$p.'</SPAN>';
}
}
if($EndPage < $NumPages)
{
$update[$this->PageEnvarIndex] = $this->Page + 10;
$next_url = $url.'?env='.BuildEnv();
$o .= '<a href="'.$next_url.'"> &gt;&gt;</a>';
}
unset( $update[$this->PageEnvarIndex] );
return $o;
}
}
function ParseClipboard($clip)
{
$ret = array();
$parts = explode(".",$clip,3);
$command = $parts[0];
$table = $parts[1];
$prefix = GetTablePrefix();
if(substr($table,0,strlen($prefix))==$prefix)
$table = substr($table,strlen($prefix));
$subparts = explode("=",$parts[2],2);
$idfield = $subparts[0];
$idlist = $subparts[1];
$cmd = explode("-",$command);
$ret["command"] = $cmd[0];
$ret["source"] = $cmd[1];
$ret["table"] = $table;
$ret["idfield"] = $idfield;
$ret["ids"] = $idlist;
//print_pre($ret);
return $ret;
}
function UpdateCategoryItems($item,$NewCatList,$PrimaryCatId = false)
{
global $objCatList;
$CurrentList = explode(",",$item->CategoryMemberList());
$del_list = array();
$ins_list = array();
if(!is_array($NewCatList))
{
if(strlen(trim($NewCatList))==0)
$NewCatList = $objCatList->CurrentCategoryID();
$NewCatList = explode(",",$NewCatList);
}
//print_r($NewCatList);
for($i=0;$i<count($NewCatList);$i++)
{
$cat = $NewCatList[$i];
if(!in_array($cat,$CurrentList))
$ins_list[] = $cat;
}
for($i=0;$i<count($CurrentList);$i++)
{
$cat = $CurrentList[$i];
if(!in_array($cat,$NewCatList))
$del_list[] = $cat;
}
for($i=0;$i<count($ins_list);$i++)
{
$cat = $ins_list[$i];
$item->AddToCategory($cat);
}
for($i=0;$i<count($del_list);$i++)
{
$cat = $del_list[$i];
$item->RemoveFromCategory($cat);
}
if($PrimaryCatId !== false) $item->SetPrimaryCategory($PrimaryCatId);
}
class clsCatItemList extends clsItemList
{
var $PerPageVarLong;
var $PerPageShortVar;
var $Query_SortField;
var $Query_SortOrder;
var $ItemType;
function clsCatItemList()
{
$this->ClsItemList();
$this->Query_SortField = array();
$this->Query_SortOrder = array();
}
function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE)
{
global $objSession;
if($UseTableName)
{
$TableName = $this->SourceTable.".";
}
else {
$TableName = "";
}
$Orders = array();
if($EditorsPick)
{
$Orders[] = $TableName."EditorsPick DESC";
}
if($Priority)
{
$Orders[] = $TableName."Priority DESC";
}
if(count($this->Query_SortField)>0)
{
for($x=0; $x<count($this->Query_SortField); $x++)
{
$FieldVar = $this->Query_SortField[$x];
$OrderVar = $this->Query_SortOrder[$x];
if(is_object($objSession))
{
$FieldVarData = $objSession->GetPersistantVariable($FieldVar);
if(strlen($FieldVarData)>0)
{
$Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ".
$objSession->GetPersistantVariable($OrderVar));
}
}
}
}
if(count($Orders)>0)
{
$OrderBy = "ORDER BY ".implode(", ",$Orders);
}
else
$OrderBy="";
return $OrderBy;
}
function AddSortField($SortField, $SortOrder)
{
if(strlen($SortField))
{
$this->Query_SortField[] = $SortField;
$this->Query_SortOrder[] = $SortOrder;
}
}
function ClearSortFields()
{
$this->Query_SortField = array();
$this->Query_SortOrder = array();
}
/* skeletons in this closet */
function GetNewValue($CatId=NULL)
{
return 0;
}
function GetPopValue($CategoryId=NULL)
{
return 0;
}
/* end of skeletons */
function GetCountSQL($PermName,$CatId=NULL, $GroupId=NULL, $AdditonalWhere="")
{
global $objSession, $objPermissions, $objCatList;
$ltable = $this->SourceTable;
$acl = $objSession->GetACLClause();
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$VIEW = $objPermissions->GetPermId($PermName);
$sql = "SELECT count(*) as CacheVal FROM $ltable ";
$sql .="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) ";
$sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) ";
$sql .="INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) ";
$sql .="WHERE ($acl AND PermId=$VIEW AND $cattable.PrimaryCat=1 AND $CategoryTable.Status=1) ";
if(strlen($AdditonalWhere)>0)
{
$sql .= "AND (".$AdditonalWhere.")";
}
return $sql;
}
function SqlCategoryList($attribs = array())
{
$CatTable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT *,$CatTable.CategoryId FROM $t INNER JOIN $CatTable ON $CatTable.ItemResourceId=$t.ResourceId ";
$sql .="WHERE ($CatTable.CategoryId=".$catid." AND $t.Status=1)";
return $sql;
}
function CategoryCount($attribs=array())
{
global $objCatList, $objCountCache;
$cat = $attribs["_catid"];
if(!is_numeric($cat))
{
$cat = $objCatList->CurrentCategoryID();
}
if((int)$cat>0)
$c = $objCatList->GetCategory($cat);
$CatTable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) ";
if($attribs["_subcats"])
{
$ctable = $objCatList->SourceTable;
$sql .= "INNER JOIN $ctable ON ($CatTable.CategoryId=$ctable.CategoryId) ";
$sql .= "WHERE (ParentPath LIKE '".$c->Get("ParentPath")."%' ";
if(!$attribs["_countcurrent"])
{
$sql .=" AND $ctable.CategoryId != $cat) ";
}
else
$sql .=") ";
}
else
$sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) ";
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$sql .= "AND ($t.CreatedOn>=$today) ";
}
//echo $sql."<br><br>\n";
$rs = $this->adodbConnection->Execute($sql);
$ret = "";
if($rs && !$rs->EOF)
$ret = (int)$rs->fields["MyCount"];
return $ret;
}
function SqlGlobalCount($attribs=array())
{
global $objSession;
$p = $this->BasePermission.".VIEW";
$t = $this->SourceTable;
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where = "($t.CreatedOn>=$today)";
}
if($attribs["_grouponly"])
{
$GroupList = $objSession->Get("GroupList");
}
else
$GroupList = NULL;
$sql = $this->GetCountSQL($p,NULL,$GroupList,$where);
return $sql;
}
function DoGlobalCount($attribs)
{
global $objCountCache;
$cc = $objCountCache->GetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)$attribs["_today"], 3600);
if(!is_numeric($cc))
{
$sql = $this->SqlGlobalCount($attribs);
$ret = QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)$attribs["_today"],$ret);
}
else
$ret = $cc;
return $ret;
}
function CacheListExtraId($ListType)
{
global $objSession;
if(!strlen($ListType))
$ListType="_";
switch($ListType)
{
case "_":
$ExtraId = $objSession->Get("GroupList");
break;
case "category":
$ExtraId = $objSession->Get("GroupList");
break;
case "myitems":
$ExtraId = $objSession->Get("PortalUserId");
break;
case "hot":
$ExtraId = $objSession->Get("GroupList");
break;
case "pop":
$ExtraId = $objSession->Get("GroupList");
break;
case "pick":
$ExtraId = $objSession->Get("GroupList");
break;
case "favorites":
$ExtraId = $objSession->Get("PortalUserId");
break;
case "new":
$ExtraId = $objSession->Get("GroupList");
break;
}
return $ExtraId;
}
function CacheListType($ListType)
{
if(!strlen($ListType))
$ListType="_";
switch($ListType)
{
case "_":
$ListTypeId = 0;
break;
case "category":
$ListTypeId = 1;
break;
case "myitems":
$ListTypeId = 2;
break;
case "hot":
$ListTypeId = 3;
break;
case "pop":
$ListTypeId = 4;
break;
case "pick":
$ListTypeId = 5;
break;
case "favorites":
$ListTypeId = 6;
break;
case "new":
$ListTypeId = 8;
break;
}
return $ListTypeId;
}
function PerformItemCount($attribs=array())
{
global $objCountCache, $objSession;
$ret = "";
$ListType = $attribs["_listtype"];
if(!strlen($ListType))
$ListType="_";
$ListTypeId = $this->CacheListType($ListType);
//echo "ListType: $ListType ($ListTypeId)<br>\n";
$ExtraId = $this->CacheListExtraId($ListType);
switch($ListType)
{
case "_":
$ret = $this->DoGlobalCount($attribs);
break;
case "category":
$ret = $this->CategoryCount($attribs);
break;
case "myitems":
$sql = $this->SqlMyItems($attribs);
break;
case "hot":
$sql = $this->SqlHotItems($attribs);
break;
case "pop":
$sql = $this->SqlPopItems($attribs);
break;
case "pick":
$sql = $this->SqlPickItems($attribs);
break;
case "favorites":
$sql = $this->SqlFavorites($attribs);
break;
case "search":
$sql = $this->SqlSearchItems($attribs);
break;
case "new":
$sql = $this->SqlNewItems($attribs);
break;
}
//echo "SQL: $sql<br>";
if(strlen($sql))
{
if(is_numeric($ListTypeId))
{
$cc = $objCountCache->GetValue($ListTypeId,$this->ItemType,$ExtraId,(int)$attribs["_today"], 3600);
if(!is_numeric($cc) || $attribs['_nocache'] == 1)
{
$ret = QueryCount($sql);
$objCountCache->SetValue($ListTypeId,$this->ItemType,$ExtraId,(int)$attribs["_today"],$ret);
}
else
$ret = $cc;
}
else
$ret = QueryCount($sql);
}
return $ret;
}
function GetJoinedSQL($PermName, $CatId=NULL, $AdditionalWhere="")
{
global $objSession, $objPermissions;
$ltable = $this->SourceTable;
$acl = $objSession->GetACLClause();
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$VIEW = $objPermissions->GetPermId($PermName);
$sql ="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) ";
$sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) ";
$sql .= "INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) ";
$sql .="WHERE ($acl AND PermId=$VIEW AND PrimaryCat=1 AND $CategoryTable.Status=1) ";
if(is_numeric($CatId))
{
$sql .= " AND ($CategoryTable.CategoryId=$CatId) ";
}
if(strlen($AdditionalWhere)>0)
{
$sql .= "AND (".$AdditionalWhere.")";
}
return $sql;
}
function CountFavorites($attribs)
{
if($attribs["_today"])
{
global $objSession, $objConfig, $objPermissions;
$acl = $objSession->GetACLClause();
$favtable = GetTablePrefix()."Favorites";
$ltable = $this->SourceTable;
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1";
$where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType;
$p = $this->BasePermission.".VIEW";
$sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) ";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$ret = QueryCount($sql);
}
else
{
if (!$this->ListType == "favorites")
{
$this->ListType = "favorites";
$this->LoadFavorites($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
}
return $ret;
}
function CountPickItems($attribs)
{
if (!$this->ListType == "pick")
{
$this->ListType = "pick";
$this->LoadPickItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountMyItems($attribs)
{
if (!$this->ListType == "myitems")
{
$this->ListType = "myitems";
$this->LoadMyItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountHotItems($attribs)
{
if (!$this->ListType == "hotitems")
{
$this->ListType = "hotitems";
$this->LoadHotItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountNewItems($attribs)
{
if (!$this->ListType == "newitems")
{
$this->ListType = "newitems";
$this->LoadNewItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountPopItems($attribs)
{
if (!$this->ListType == "popitems")
{
$this->ListType = "popitems";
$this->LoadPopItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountSearchItems($attribs)
{
if (!$this->ListType == "search")
{
$this->ListType = "search";
$this->LoadSearchItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function SqlFavorites($attribs)
{
global $objSession, $objConfig, $objPermissions;
$acl = $objSession->GetACLClause();
$favtable = GetTablePrefix()."Favorites";
$ltable = $this->SourceTable;
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1";
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType;
}
$p = $this->BasePermission.".VIEW";
$sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) ";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadFavorites($attribs)
{
global $objSession, $objCountCache;
$sql = $this->SqlFavorites($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount = QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount = (int)$CachedCount;
return $this->Query_Item($sql);
}
function SqlPickItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ".$TableName.".EditorsPick=1 AND ".$TableName.".Status=1";
}
else
{
$where = $TableName.".EditorsPick=1 AND ".$TableName.".Status=1 ";
$catid=NULL;
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadPickItems($attribs)
{
global $objSession, $objCountCache;
$sql = $this->SqlPickItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlMyItems($attribs= array())
{
global $objSession;
$TableName = $this->SourceTable;
$where = " ".$TableName.".Status>-1 AND ".$TableName.".CreatedById=".$objSession->Get("PortalUserId");
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadMyItems($attribs=array())
{
global $objSession,$objCountCache;
$sql = $this->SqlMyItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlNewItems($attribs = array())
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($attribs["_today"])
{
$cutoff = mktime(0,0,0,date("m"),date("d"),date("Y"));
}
else
{
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$cutoff = $this->GetNewValue($catid);
}
else
$cutoff = $this->GetNewValue();
}
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 ";
}
else
{
$where = "((".$TableName.".CreatedOn >=".$this->GetNewValue()." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 ";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadNewItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlNewItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlPopItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".Hits >=".$this->GetLinkPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1";
}
else
{
$where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
$where = "((".$TableName.".Hits >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$catid,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadPopItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlPopItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlHotItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
// $JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
$OrderBy = $TableName.".CachedRating DESC";
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".CachedRating >=".$this->GetHotValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1";
}
else
{
$where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$CatId = !$scope? NULL : $catid;
$sql .= $this->GetJoinedSQL($p,$CatId,$where);
if(strlen($OrderBy))
$sql .= " ORDER BY $OrderBy ";
return $sql;
}
function LoadHotItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlHotItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlSearchItems($attribs = array())
{
global $objConfig, $objItemTypes, $objSession, $objPermissions, $CountVal;
$acl = $objSession->GetACLClause();
$this->Clear();
//$stable = "ses_".$objSession->GetSessionKey()."_Search";
$stable = $objSession->GetSearchTable();
$ltable = $this->SourceTable;
$catitems = GetTablePrefix()."CategoryItems";
$cattable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$p = $this->BasePermission.".VIEW";
$i = new $this->classname();
$sql = "SELECT $cattable.CategoryId,$cattable.CachedNavbar,$ltable.*, Relevance FROM $stable ";
$sql .= "INNER JOIN $ltable ON ($stable.ItemId=$ltable.".$i->id_field.") ";
$where = "ItemType=".$this->ItemType." AND $ltable.Status=1";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$sql .= " ORDER BY EdPick DESC,Relevance DESC ";
$tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE);
$tmp = substr($tmp,9);
if(strlen($tmp))
{
$sql .= ", ".$tmp." ";
}
return $sql;
}
function LoadSearchItems($attribs = array())
{
global $CountVal, $objSession;
//echo "Loading <b>".get_class($this)."</b> Search Items<br>";
$sql = $this->SqlSearchItems($attribs);
//echo "$sql<br>";
$this->Query_Item($sql);
$Keywords = GetKeywords($objSession->GetVariable("Search_Keywords"));
//echo "SQL Loaded ItemCount (<b>".get_class($this).'</b>): '.$this->NumItems().'<br>';
for($i = 0; $i < $this->NumItems(); $i++)
{
$this->Items[$i]->Keywords = $Keywords;
}
if(is_numeric($CountVal[$this->ItemType]))
{
$this->QueryItemCount = $CountVal[$this->ItemType];
//echo "CACHE: <pre>"; print_r($CountVal); echo "</pre><BR>";
}
else
{
$this->QueryItemCount = QueryCount($sql);
//echo "<b>SQL</b>: ".$sql."<br><br>";
$CountVal[$this->ItemType] = $this->QueryItemCount;
}
}
function PasteFromClipboard($TargetCat,$NameField="")
{
global $objSession,$objCatList;
$clip = $objSession->GetVariable("ClipBoard");
if(strlen($clip))
{
$ClipBoard = ParseClipboard($clip);
$IsCopy = (substr($ClipBoard["command"],0,4)=="COPY") || ($ClipBoard["source"] == $TargetCat);
$item_ids = explode(",",$ClipBoard["ids"]);
for($i=0;$i<count($item_ids);$i++)
{
$item = $this->GetItem($item_ids[$i]);
if(!$IsCopy) // paste to other category then current
{
$item->MoveToCategory($ClipBoard["source"],$TargetCat);
$clip = str_replace("CUT","COPY",$clip);
$objSession->SetVariable("ClipBoard",$clip);
}
else
{
$item->CopyToNewResource($TargetCat,$NameField); // create item copy, but with new ResourceId
$item->AddToCategory($TargetCat);
UpdateCategoryCount($item->type,$TargetCat);
}
}
}
}
function AdminPrintItems($template)
{
// prints item listing for admin (browse/advanced view) tabs
$o = '<table border="0" cellspacing="2" width="100%"><tbody><tr>';
$i = 1;
$topleft = 0;
$topright = 0;
$rightcount = 0;
$total_items = $this->NumItems();
$topleft = ceil($total_items / 2);
$topright = $total_items - $topleft;
for($x = 0; $x < $topleft; $x++)
{
//printingleft
$item = $this->Items[$x];
if ($i > 2)
{
$o .= "</tr>\n<tr>";
$i = 1;
}
$o .= $item->AdminParseTemplate($template);
$i++;
//printingright
if ($rightcount < $topright && ( ($x + $topleft) < $total_items) )
{
$item = $this->Items[ $x + $topleft ];
if ($i > 2)
{
$o.="</tr>\n<tr>";
$i = 1;
}
$o .= $item->AdminParseTemplate($template);
$i++;
$rightcount++;
}
}
$o .= "\n</tr></tbody></table>\n";
return $o;
}
}
// -------------- NEW CLASSES -----------------------
class DBList {
// table related attributes
var $db = null;
var $table_name = '';
var $LiveTable = '';
var $EditTable = '';
// record related attributes
var $records = Array();
var $record_count = 0;
var $cur_rec = -1; // "-1" means no records, or record index otherwise
// query related attributes
var $SelectSQL = "SELECT * FROM %s";
function DBList()
{
// use $this->SetTable('live', 'table name');
// in inherited constructors to set table for list
$this->db =&GetADODBConnection();
}
function SetTable($action, $table_name = null)
{
// $action = {'live', 'restore','edit'}
switch($action)
{
case 'live':
$this->LiveTable = $table_name;
$this->table_name = $this->LiveTable;
break;
case 'restore':
$this->table_name = $this->LiveTable;
break;
case 'edit':
global $objSession;
$this->table_name = $objSession->GetEditTable($this->LiveTable);
break;
}
}
function Clear()
{
// no use of this method at a time :)
$this->records = Array();
$this->record_count = 0;
$this->cur_rec = -1;
}
function Query()
{
// query list
$sql = sprintf($this->SelectSQL, $this->table_name);
echo "SQL: $sql<br>";
$rs =& $this->db->Execute($sql);
if( $this->db->ErrorNo() == 0 )
{
$this->records = $rs->GetRows();
$this->record_count = count($this->records);
//$this->cur_rec = $this->record_count ? 0 : -1;
}
else
return false;
}
function ProcessList($callback_method)
{
// process list using user-defined method called
// with one parameter - current record fields
// (associative array)
if($this->record_count > 0)
{
$this->cur_rec = 0;
while($this->cur_rec < $this->record_count)
{
if( method_exists($this, $callback_method) )
$this->$callback_method( $this->GetCurrent() );
$this->cur_rec++;
}
}
}
function &GetCurrent()
{
// return currently processed record (with change ability)
return ($this->cur_rec != -1) ? $this->records[$this->cur_rec] : false;
}
function GetDBField($field_name)
{
$rec =& $this->GetCurrent();
return is_array($rec) && isset($rec[$field_name]) ? $rec[$field_name] : false;
}
}
?>
Property changes on: trunk/kernel/include/parseditem.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.33
\ No newline at end of property
+1.34
\ No newline at end of property
Index: trunk/kernel/include/image.php
===================================================================
--- trunk/kernel/include/image.php (revision 639)
+++ trunk/kernel/include/image.php (revision 640)
@@ -1,1130 +1,1132 @@
<?php
class clsImage extends clsParsedItem
{
var $Pending;
function clsImage($id=NULL)
{
global $objSession;
$this->clsParsedItem();
$this->tablename = GetTablePrefix()."Images";
$this->Pending = FALSE;
$this->id_field = "ImageId";
$this->type=-30;
$this->TagPrefix = "image";
$this->NoResourceId=1;
if($id)
$this->LoadFromDatabase($id);
//$this->SetDebugLevel(0);
}
function GetFileName($thumb = 0)
{
global $pathtoroot;
if($thumb)
{
$p = $this->Get("ThumbPath");
}
else
{
$p = $this->Get("LocalPath");
if(!strlen($p) && $this->Get("SameImages"))
{
$p = $this->Get("ThumbPath");
}
}
if(strlen($p))
{
$parts = pathinfo($pathtoroot.$p);
$filename = $parts["basename"];
}
else
$filename = "";
return $filename;
}
function GetImageDir()
{
global $pathtoroot;
$p = $this->Get("ThumbPath");
if(strlen($p))
{
$parts = pathinfo($pathtoroot.$p);
$d = $parts["dirname"]."/";
}
if($this->Pending)
$d .= "pending/";
return $d;
}
function Delete()
{
$this->DeleteLocalImage();
parent::Delete();
}
function LoadFromDatabase($Id)
{
global $Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ImageId = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
function LoadFromResource($Id,$ImageIndex)
{
global $Errors;
if(!isset($Id) || !isset($ImageIndex))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromResource");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ResourceId = '%s'AND ImageIndex = '%s'",$Id,$ImageIndex);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
// $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromResource");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
return true;
}
function LocalImageExists()
{
global $objConfig, $pathtoroot;
$result=FALSE;
if($this->Get("LocalImage")==1 && $this->Get("SameImages")==0)
{
//$imagepath = $pathtoroot.$this->Get("LocalPath");
$imagepath = $this->GetImageDir().$this->GetFileName();
// echo "PATH: ".$this->GetImageDir()."; FILE: ".$this->GetFileName()."<BR>";
if(strlen($imagepath)>0)
{
$result = file_exists($imagepath);
}
}
return $result;
}
function LocalThumbExists()
{
$result=FALSE;
global $objConfig, $pathtoroot;
if($this->Get("LocalThumb")==1)
{
//$imagepath = $pathtoroot.$this->Get("ThumbPath");
$imagepath = $this->GetImageDir().$this->GetFileName(1);
if(strlen($imagepath)>0)
{
$result = file_exists($imagepath);
}
}
return $result;
}
function DeleteLocalImage($Thumb=TRUE,$Full=TRUE)
{
global $pathtoroot;
if($Full)
{
if($this->LocalImageExists())
{
$filename = $this->GetImageDir().$this->GetFileName();
// echo "FULL: $filename<BR>\n";
@unlink($filename);
}
}
if($Thumb)
{
if($this->LocalThumbExists())
{
$filename = $this->GetImageDir().$this->GetFileName(1);
// echo "THUMB: $filename<BR>\n";
@unlink($filename);
}
}
}
function StoreUploadedImage($file, $rewrite_name=1,$DestDir,$IsThumb=0,$IsUpload=TRUE)
{
/* move the uploaded image to its final location and update the LocalPath property */
/* returns the destination filename on success */
global $objConfig,$pathtoroot;
$Dest_Dir = $DestDir;
if($this->Pending)
$Dest_Dir .= "pending/";
if(((int)$file["error"]==0) && (substr($file["type"],0,6)=="image/"))
{
$parts = pathinfo($file["name"]);
$ext = strtolower($parts["extension"]);
if( $GLOBALS['debuglevel'] ) echo "Processing ".$file["tmp_name"]."<br>\n";
if($rewrite_name==1)
{
if($IsThumb)
$filename = "th_";
$filename .= $this->Get("ResourceId")."_".$this->Get("ImageIndex").".".$ext;
}
else
{
$filename = $file["name"];
}
$destination = $pathtoroot.$Dest_Dir.$filename;
if( $GLOBALS['debuglevel'] ) echo $file["tmp_name"]."=>".$destination."<br>\n";
if(IsUpload==TRUE)
{
$result = @move_uploaded_file($file["tmp_name"],$destination);
}
else
$result = copy($file["tmp_name"],$destination);
if($result)
{
+ @chmod($Dest_Dir.$filename, 0666);
return $Dest_Dir.$filename;
}
else
return "";
}
else
return "";
}
function CopyToPending()
{
global $pathtoroot;
$ThumbPath = (strlen($this->Get("ThumbPath"))>0) ? $pathtoroot.$this->Get("ThumbPath") : '';
$FullPath = strlen($this->Get("LocalPath")) ? $pathtoroot.$this->Get("LocalPath") : '';
$dest = $this->GetImageDir()."pending/";
// echo "DESTIN DIR: $dest<BR>";
// echo "THUMB PATH: $ThumbPath <BR>";
if(strlen($ThumbPath))
{
if(file_exists($ThumbPath))
{
$p = pathinfo($ThumbPath);
$d = $dest.$p["basename"];
if(file_exists($d))
unlink($d);
copy($ThumbPath,$d);
}
}
if(strlen($FullPath))
{
if(file_exists($FullPath))
{
$p = pathinfo($FullPath);
$d = $dest.$p["basename"];
if(file_exists($d))
unlink($d);
copy($FullPath,$d);
}
}
}
function CopyFromPending()
{
global $pathtoroot,$pathchar;
$ThumbPath = $this->Get("ThumbPath");
$FullPath = $this->Get("LocalPath");
// $src = $this->GetImageDir()."pending/";
$src = $this->GetImageDir();
if(strlen($ThumbPath))
{
if(strpos($ThumbPath,"pending/"))
{
if(file_exists($pathtoroot.$ThumbPath))
{
$path = pathinfo($pathtoroot.$ThumbPath);
$p = explode("/",$ThumbPath);
unset($p[count($p)-2]);
$d = $pathtoroot.implode("/",$p);
if(file_exists($d))
unlink($d);
copy($pathtoroot.$ThumbPath,$d);
unlink($pathtoroot.$ThumbPath);
}
}
}
if(strlen($FullPath))
{
if(file_exists($pathtoroot.$FullPath))
{
if(strpos($FullPath,"pending/"))
{
$path = pathinfo($pathtoroot.$FullPath);
$p = explode("/",$FullPath);
unset($p[count($p)-2]);
$d = $pathtoroot.implode("/",$p);
if(file_exists($d))
unlink($d);
copy($pathtoroot.$FullPath,$d);
unlink($pathtoroot.$FullPath);
}
}
}
}
function DeleteFromPending()
{
global $pathtoroot;
$ThumbPath = $pathtoroot.$this->Get("ThumbPath");
$FullPath = $pathtoroot.$this->Get("LocalPath");
$src = $this->GetImageDir()."pending/";
$p = pathinfo($ThumbPath);
$d = $src.$p["basename"];
if(file_exists($d))
@unlink($d);
$p = pathinfo($FullPath);
$d = $src.$p["basename"];
if(file_exists($d))
@unlink($d);
}
function RenameFiles($OldResId,$NewResId)
{
global $pathtoroot;
if($this->Pending)
{
$ThumbPath = $this->GetImageDir().$this->GetFileName(TRUE);
}
else
$ThumbPath = $pathtoroot.$this->Get("ThumbPath");
$parts = pathinfo($ThumbPath);
$ext = $parts["extension"];
$pending="";
if($this->Pending)
{
$pending="pending/";
$FullPath = $this->GetImageDir().$this->GetFileName(FALSE);
}
else
$FullPath = $pathtoroot.$this->Get("LocalPath");
$NewThumb = $pathtoroot."kernel/images/".$pending."th_$NewResId_".$this->Get("ImageIndex").".$ext";
$NewFull = $pathtoroot."kernel/images/".$pending."$NewResId_".$this->Get("ImageIndex").".$ext";
if(file_exists($ThumbPath))
{
@rename($ThumbPath,$NewThumb);
}
if(file_exists($FullPath))
{
@rename($FullPath,$NewFull);
}
}
function ReplaceImageFile($file)
{
global $objConfig;
if($file["error"]==0)
{
$this->DeleteLocalImage();
move_uploaded_file($file,$this->Get("LocalPath"));
+ @chmod($this->Get("LocalPath"), 0666);
}
}
function FullURL($ForceNoThumb=FALSE,$Default="kernel/images/noimage.gif")
{
global $rootURL, $objConfig,$pathtoroot;
if($this->Get("SameImages") && !$ForceNoThumb)
return $this->ThumbURL();
if(strlen($this->Get("Url")))
return $this->Get("Url");
if($this->Get("LocalImage")=="1")
{
$url = $this->Get("LocalPath");
//$url = $this->GetImageDir().$this->GetFileName();
if(file_exists($pathtoroot.$url))
{
if(strlen($url))
{
$url = $rootURL.$url;
return $url;
}
else
{
if(strlen($Default))
$url = $rootURL.$Default;
return $url;
}
}
else
{
if(strlen($Default))
{
return $rootURL.$Default;
}
else
return "";
}
}
else
{
if(strlen($Default))
{
return $rootURL.$Default;
}
else
return "";
}
}
function ThumbURL()
{
global $rootURL, $pathtoroot, $objConfig;
if(strlen($this->Get("ThumbUrl")))
return $this->Get("ThumbUrl");
if($this->Get("LocalThumb")=="1")
{
$url = $this->Get("ThumbPath");
//$url = $this->GetImageDir().$this->GetFileName();
if(file_exists($pathtoroot.$url))
{
if(strlen($url))
{
$url = $rootURL.$url;
}
else
$url = $rootURL."kernel/images/noimage.gif";
return $url;
}
else
return $rootURL."kernel/images/noimage.gif";
}
else
return $rootURL."kernel/images/noimage.gif";
}
function ParseObject($element)
{
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "name":
$ret = $this->Get("Name");
break;
case "alt":
$ret = $this->Get("AltName");
break;
case "full_url":
$ret = $this->FullURL();
break;
case "thumb_url":
$ret = $this->ThumbURL();
break;
}
}
else
$ret = $element->Execute();
return $ret;
}
function parsetag($tag)
{
if(is_object($tag))
{
$tagname = $tag->name;
}
else
$tagname = $tag;
switch($tagname)
{
case "image_name":
$ret = $this->Get("Name");
break;
case "image_alt":
$ret = $this->Get("AltName");
break;
case "image_url":
$ret = $this->FullURL();
break;
case "thumb_url":
$ret = $this->ThumbURL();
break;
}
return $ret;
}
//Changes priority
function MoveUp()
{
$this->Increment("Priority");
}
function MoveDown()
{
$this->Decrement("Priority");
}
function GetMaxPriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MAX(Priority) as p from ".$this->tablename."WHERE ResourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function GetMinPriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MIN(Priority) as p from ".$this->tablename."WHERE ResourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function UpdatePriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MAX(Priority) as p from ".$this->tablename."WHERE ReourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
$this->Set("Priority", $result->fields["p"]+1);
}
}
class clsImageList extends clsItemCollection
{
var $Page;
var $PerPageVar;
function clsImageList()
{
$this->clsItemCollection();
$this->PerPageVar = "Perpage_Images";
$this->SourceTable = GetTablePrefix()."Images";
$this->classname = "clsImage";
}
function LoadImages($where="",$orderBy = "")
{
global $objConfig;
$this->Clear();
if($this->Page<1)
$this->Page=1;
if(is_numeric($objConfig->Get("Perpage_Images")))
{
$Start = ($this->Page-1)*$objConfig->Get("Perpage_Images");
$limit = "LIMIT ".$Start.",".$objConfig->Get("Perpage_Images");
}
else
$limit = NULL;
$this->QueryItemCount=TableCount("Images",$where,0);
//echo $this->QueryItemCount."<br>\n";
if(strlen(trim($orderBy))>0)
{
$orderBy = "Priority DESC, ".$orderBy;
}
else
$orderBy = "Priority DESC";
return $this->Query_Images($where,$orderBy,$limit);
}
function Query_Images($whereClause,$orderByClause=NULL,$limit=NULL)
{
global $objSession, $Errors;
$sql = "SELECT * FROM ".$this->SourceTable;
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
if(isset($orderByClause) && strlen(trim($orderByClause))>0)
$sql = sprintf('%s ORDER BY %s',$sql,$orderByClause);
if(isset($limit) && strlen(trim($limit)))
$sql .= " ".$limit;
//echo $sql;
return $this->Query_Item($sql);
}
function &Add($Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled=1, $Priority=0, $DefaultImg=0, $ImageIndex=0,
$SameImages=0, $ImageId=-999)
{
if($DefaultImg==1)
{
$sql = "UPDATE ".$this->SourceTable." SET DefaultImg=0 WHERE ResourceId=$ResourceId";
$this->adodbConnection->Execute($sql);
}
$img = new clsImage();
$img->tablename = $this->SourceTable;
$img->Set(array("Name","AltName","ResourceId","LocalImage","LocalThumb",
"Url","ThumbUrl","Enabled","Priority","DefaultImg","ImageIndex","SameImages"),
array($Name,$Alt,$ResourceId,$LocalImage,$LocalThumb,
$Url,$ThumbUrl,$Enabled,$Priority,$DefaultImg,$ImageIndex,$SameImages));
if ($ImageId != -999)
{
$img->Set("ImageId", $ImageId);
}
if((int)$ImageIndex==0)
$img->Set("ImageIndex",$this->GetNextImageIndex($ResourceId));
$img->Create();
array_push($this->Items,$img);
return $img;
}
function Edit($ImageId,$Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled=1, $Priority=0, $DefaultImg=0, $ImageIndex=0,
$SameImages=0)
{
$img = $this->GetItem($ImageId);
if((int)$ImageIndex==0)
$ImageIndex = $img->Get("ImageIndex");
if(!strlen($ThumbUrl) && !$LocalThumb)
$ThumbUrl = $img->Get("ThumbUrl");
$img->Set(array("Name","AltName","ResourceId","LocalImage","LocalThumb",
"Url","ThumbUrl","Enabled","Priority","DefaultImg","ImageIndex","SameImages"),
array($Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled, $Priority, $DefaultImg, $ImageIndex,$SameImages));
if((int)$ImageIndex==0)
$img->Set("ImageIndex",$this->GetNextImageIndex($ResourceId));
$img->Update();
if($DefaultImg==1)
{
$sql = "UPDATE ".$this->SourceTable." SET DefaultImg=0 WHERE ResourceId=".$ResourceId." AND ImageId !=$ImageId";
$this->adodbConnection->Execute($sql);
}
array_push($this->Items,$img);
return $img;
}
function Delete_Image($ImageId)
{
$i = $this->GetItem($ImageId);
$i->Delete();
}
function DeleteResource($ResourceId)
{
$this->Clear();
$images = $this->Query_Images("ResourceId=".$ResourceId);
if(is_array($images))
{
foreach($images as $i)
{
$i->Delete();
}
}
}
function LoadResource($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId";
$this->Query_Item($sql);
}
function CopyResource($SourceId,$DestId)
{
global $pathtoroot;
$this->Clear();
$this->LoadResource($SourceId);
foreach($this->Items as $i)
{
if($i->Get("LocalThumb"))
{
$f = $pathtoroot.$i->Get("ThumbPath");
if(file_exists($f))
{
$p = pathinfo($f);
$dir = $p["dirname"];
$ext = $p["extension"];
$newfile = $dir."/th_".$DestId."_".$i->Get("ImageIndex").".".$ext;
if(file_exists($newfile))
@unlink($newfile);
// echo $f." -> ".$newfile;
copy($f,$newfile);
}
}
if($i->Get("LocalImage"))
{
$f = $pathtoroot.$i->Get("LocalPath");
if(file_exists($f))
{
$p = pathinfo($f);
$dir = $p["dirname"];
$ext = $p["extension"];
$newfile = $dir."/".$DestId."_".$i->Get("ImageIndex").".".$ext;
if(file_exists($newfile))
@unlink($newfile);
// echo $f." -> ".$newfile;
copy($f,$newfile);
}
}
}
parent::CopyResource($SourceId,$DestId);
$this->Clear();
$this->LoadResource($DestId);
foreach($this->Items as $img)
{
if($img->Get("LocalThumb"))
{
$f = str_replace("th_$SourceId","th_$DestId",$img->Get("ThumbPath"));
$img->Set("ThumbPath",$f);
}
if($img->Get("LocalImage"))
{
$f = str_replace("/".$SourceId."_","/".$DestId."_",$img->Get("LocalPath"));
$img->Set("LocalPath",$f);
}
$img->Update();
}
}
function GetImageByResource($ResourceId,$Index)
{
$found=FALSE;
if($this->NumItems()>0)
{
foreach($this->Items as $i)
{
if($i->Get("ResourceID")==$ResourceId and ($i->Get("ImageIndex")==$Index))
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
$i = NULL;
$i = new clsImage();
if($i->LoadFromResource($ResourceId,$Index))
{
array_push($this->Items, $i);
}
else
unset($i);
}
if(is_object($i))
{
return $i;
}
else
return FALSE;
}
function &GetDefaultImage($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId AND DefaultImg=1";
$rs = $this->adodbConnection->Execute($sql);
if($rs && ! $rs->EOF)
{
$data = $rs->fields;
$img= new clsImage();
$img->SetFromArray($data);
$img->Clean();
return $img;
}
else
return FALSE;
}
function HandleImageUpload($FILE,$ResourceId,$RelatedTo,$DestDir, $Name="",$AltName="",$IsThumb=0)
{
global $objConfig;
$img = $this->GetImageByResource($ResourceId,$RelatedTo);
if(is_object($img) && $RelatedTo>0)
{
$img->Set("LocalImage",1);
$img->Set("Name",$Name);
$img->Set("AltName",$AltName);
$img->Set("IsThumbnail",$IsThumb);
$dest = $img->StoreUploadedImage($FILE,1,$DestDir);
if(strlen($dest))
{
$img->Set("Url", $objConfig->Get("Site_Path").$dest);
$img->Update();
}
}
else
{
$img=$this->NewLocalImage($ResourceId,$RelatedTo,$Name,$AltName,$IsThumb,$FILE,$DestDir);
}
return $img;
}
function GetResourceImages($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$img = new clsImage();
$img->LoadFromResource($ResourceId,$rs->fields["RelatedTo"]);
array_push($this->Images,$img);
$rs->MoveNext();
}
}
function GetResourceThumbnail($ResourceId)
{
$found=FALSE;
foreach($this->Images as $img)
{
if($img->Get("ResourceId")==$ResourceId && $img->Get("IsThumbnail")==1)
{
$found=TRUE;
break;
}
}
if($found)
{
return $img;
}
else
return FALSE;
}
function &GetImageByName($ResourceId,$name)
{
$found = FALSE;
foreach($this->Items as $img)
{
if($img->Get("ResourceId")==$ResourceId && $img->Get("Name")==$name)
{
$found=TRUE;
break;
}
}
if($found)
{
return $img;
}
else
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId AND Name LIKE '$name'";
//echo $sql;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$img = $this->AddItemFromArray($rs->fields);
return $img;
}
else
return FALSE;
}
}
function CopyToPendingFiles()
{
$sql = "SELECT * FROM ".$this->SourceTable;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
if(strlen($i->Get("LocalImage")) || strlen($i->Get("LocalThumb")))
{
$i->CopyToPending();
}
}
}
function CopyFromPendingFiles($edit_table)
{
$sql = "SELECT * FROM ".$edit_table;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
## Delete original Images
$OrgImage = new clsImage($i->Get("ImageId"));
$OrgImage->DeleteLocalImage();
if($i->Get("LocalImage") || $i->Get("LocalThumb"))
{
$i->CopyFromPending();
$t = $i->Get("LocalPath");
$p = pathinfo($t);
$p_arr = explode("/", $p['dirname']);
if (eregi("pending", $p_arr[count($p_arr)-1]))
{
unset($p_arr[count($p_arr)-1]);
$p['dirname'] = implode("/", $p_arr);
$LocalPath = $p['dirname']."/".$p['basename'];
$i->Set("LocalPath", $LocalPath);
}
$t = $i->Get("ThumbPath");
$p = pathinfo($t);
$p_arr = explode("/", $p['dirname']);
if (eregi("pending", $p_arr[count($p_arr)-1]))
{
unset($p_arr[count($p_arr)-1]);
$p['dirname'] = implode("/", $p_arr);
$ThumbPath = $p['dirname']."/".$p['basename'];
$i->Set("ThumbPath", $ThumbPath);
}
$i->tablename = $edit_table;
$update = 1;
}
## Empty the fields if are not used
if (!$i->Get("LocalImage"))
{
$i->Set("LocalPath", "");
$update = 1;
}
if (!$i->Get("LocalThumb"))
{
$i->Set("ThumbPath", "");
$update = 1;
}
if ($update)
$i->Update();
}
}
function DeletePendingFiles($edit_table)
{
$sql = "SELECT * FROM ".$edit_table;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
$i->DeleteFromPending();
}
}
function CopyToEditTable($idfield, $idlist)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
$this->SourceTable = $edit_table;
$this->CopyToPendingFiles();
$this->UpdateFilenamesToPendings();
}
function UpdateFilenamesToPendings()
{
global $objSession;
$edit_table = $this->SourceTable;
$sql = "SELECT * FROM ".$edit_table." WHERE (LocalPath!='' AND LocalPath IS NOT NULL) OR (ThumbPath!='' AND ThumbPath IS NOT NULL)";
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
$set = "";
$ImageId = $i->Get("ImageId");
## Update Local Image Path -> add "pending/" to PATH
if (strlen($i->Get("LocalPath")))
{
$p = pathinfo($i->Get("LocalPath"));
if (!eregi("/pending $", $p['dirname']))
{
$LocalPath = $p['dirname']."/pending/".$p['basename'];
$set = "SET LocalPath='$LocalPath'";
}
}
// echo "LocalImage: ".$i->Get("LocalImage").", PATH: ".$i->Get("LocalPath")."<BR>";
## Update Local Thumb Path -> add "pending/" to PATH
if (strlen($i->Get("ThumbPath")))
{
$p = pathinfo($i->Get("ThumbPath"));
if (!eregi("/pending $", $p['dirname']))
{
$LocalThumb = $p['dirname']."/pending/".$p['basename'];
if (strlen($set))
$set.= ", ThumbPath='$LocalThumb'";
else
$set = "SET ThumbPath='$LocalThumb'";
}
}
// echo "LocalThumb: ".$i->Get("LocalThumb").", PATH: ".$i->Get("ThumbPath")."<BR>";
if (strlen($set))
{
$sql = "UPDATE $edit_table $set WHERE ImageId=$ImageId";
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($sql);
}
}
}
function CopyFromEditTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$dummy =& $this->GetDummy();
if( !$dummy->TableExists($edit_table) )
{
echo 'ERROR: Table "<b>'.$edit_table.'</b>" missing (class: <b>'.get_class($this).'</b>)<br>';
//exit;
return;
}
$rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table WHERE ResourceId=0");
while($rs && !$rs->EOF)
{
$id = $rs->fields["ImageId"];
if($id>0)
{
$img = $this->GetItem($id);
$img->Delete();
}
$rs->MoveNext();
}
$this->adodbConnection->Execute("DELETE FROM $edit_table WHERE ResourceId=0");
$this->CopyFromPendingFiles($edit_table);
parent::CopyFromEditTable($idfield);
}
function PurgeEditTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$this->DeletePendingFiles($edit_table);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
function GetNextImageIndex($ResourceId)
{
$sql = "SELECT MAX(ImageIndex) as MaxVal FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$rs = $this->adodbConnection->Execute($sql);
if($rs)
{
$val = (int)$rs->fields["MaxVal"];
$val++;
}
return $val;
}
function GetMaxPriority($ResourceId)
{
$sql = "SELECT MAX(Priority) as p from ".$this->SourceTable."WHERE ResourceId=$ResourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function GetMinPriority($ResourceId)
{
$sql = "SELECT MIN(Priority) as p from ".$this->SourceTable."WHERE ResourceId=$ResourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
} /*clsImageList*/
?>
Property changes on: trunk/kernel/include/image.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/themes/default/misc/right_loggedin.tpl
===================================================================
--- trunk/themes/default/misc/right_loggedin.tpl (revision 639)
+++ trunk/themes/default/misc/right_loggedin.tpl (revision 640)
@@ -1,65 +1,65 @@
<!-- template=right_loggedin.tpl -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!-- login box -->
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="login-name"><img src="img/s.gif" width="1" height="1" alt="" /><br /></td>
<td class="login-name" width="22"><a href="<inp:m_access_template_link _Template="my_account" _System="1" _DeniedTemplate="login" _Perm="login" />"><img src="img/ic_loggedin.gif" width="22" height="22" alt="" /></a><br /></td>
<td class="login-name"><a href="<inp:m_access_template_link _Template="my_account" _System="1" _DeniedTemplate="login" _Perm="login" />"><inp:user _Field="firstname" /> <inp:user _Field="lastname" /></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="bgr-loggedin">
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td align="center"><a href="<inp:m_template_link _Template="my_info" />"><img src="img/ic_myprofile.gif" width="22" height="18" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_template_link _Template="my_info" />"><inp:m_language _Phrase="lu_my_info" /></a></td>
</tr>
<tr>
<td align="center"><a href="<inp:m_template_link _Template="my_favorites" />"><img src="img/ic_myfavorites.gif" width="22" height="15" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_template_link _Template="my_favorites" />"><inp:m_language _Phrase="lu_my_favorites" /></a></td>
</tr>
<tr>
<td align="center"><a href="<inp:m_template_link _Template="my_friends" />"><img src="img/ic_myfriends.gif" width="22" height="19" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_template_link _Template="my_friends" />"><inp:m_language _Phrase="lu_my_friends" /></a></td>
</tr>
<inp:m_module_enabled _Module="In-Bulletin">
<tr>
<td align="center"><a href="<inp:m_template_link _Template="inbulletin/pm_list" />&ResetPage=1"><img src="inbulletin/img/ic_pm_list.gif" width="22" height="19" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_template_link _Template="inbulletin/pm_list" />&ResetPage=1"><inp:m_language _Phrase="lu_pm_list" /> (<inp:bb_new_pm_count/>)</a></td>
</tr>
</inp:m_module_enabled>
<tr>
<td align="center"><a href="<inp:m_template_link _Template="my_preferences" />"><img src="img/ic_mypreferences.gif" width="22" height="18" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_template_link _Template="my_preferences" />"><inp:m_language _Phrase="lu_my_preferences" /></a></td>
</tr>
<tr>
<td align="center"><a href="<inp:m_logout_link _Tenplate="index" _Category=0 />"><img src="img/ic_logout.gif" width="22" height="23" alt="" /></a><br /></td>
<td class="item-my"><a href="<inp:m_logout_link _Tenplate="index" _Category=0 />"><inp:m_language _Phrase="lu_logout" /></a></td>
</tr>
<tr>
<td colspan="2"><img src="img/s.gif" width="1" height="10" alt="" /><br /></td>
</tr>
<tr>
<td colspan="2" class="bgr-path"><img src="img/s.gif" width="1" height="1" alt="" /><br /></td>
</tr>
<tr>
- <td colspan="2"><img src="img/s.gif" width="190" height="10" alt="" /><br /></td>
+ <td colspan="2"><img src="img/s.gif" width="200" height="10" alt="" /><br /></td>
</tr>
<inp:mod_include _Template="menu_my_items" />
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end login box -->
</table>
Property changes on: trunk/themes/default/misc/right_loggedin.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/themes/default/misc/right_login.tpl
===================================================================
--- trunk/themes/default/misc/right_login.tpl (revision 639)
+++ trunk/themes/default/misc/right_login.tpl (revision 640)
@@ -1,72 +1,72 @@
<!-- template=right_login.tpl -->
<!-- login box -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="login-box-top"><inp:m_language _Phrase="lu_login" /></td>
<td class="login-box-top" align="right">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="img/ic_notloggedin.gif" width="11" height="11" alt="" /><br /></td>
<td><img src="img/s.gif" width="3" height="1" alt="" /><br /></td>
<td class="copyright"><inp:m_language _Phrase="lu_not_logged_in" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="bgr-login">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<FORM method="POST" NAME="login" ACTION="<inp:m_form_action _form="login"/>">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="field-title"><inp:m_language _Phrase="lu_prompt_username" />:</td>
</tr>
<tr>
<td><inp:m_form_input type="text" class="input" style="width:135px;" _field="login_user" _Form="login" _Required="1" /><br /></td>
</tr>
<tr>
<td class="field-title"><inp:m_language _Phrase="lu_prompt_password" />:</td>
</tr>
<tr>
<td><inp:m_form_input type="password" class="input" _field="login_password" _Form="login" _Required="1" style="width:135px;" /><br /></td>
</tr>
<tr>
<td class="tips" nowrap>
<INPUT type="submit" name="login" value="<inp:m_language _Phrase="lu_login" />" class="button"> <input type="checkbox" name="usercookie" VALUE="1"><inp:m_language _Phrase="lu_remember_login" />
</td>
</tr>
<tr>
<td class="field-title"><span class="error"><inp:m_list_form_errors _Form="login" _ItemTemplate="misc/form_error.tpl" /></span></td>
</tr>
<tr>
<td class="option-txt"><br /><br />
<a href="<inp:m_template_link _Template="register" />"><inp:m_language _Phrase="lu_register" /></a> <img src="img/arr_more.gif" width="16" height="7" alt="" /><br />
<a href="<inp:m_template_link _Template="forgotpw" />"><inp:m_language _Phrase="lu_forgot_password_link" /></a> <img src="img/arr_more.gif" width="16" height="7" alt="" /><br />
</td>
</tr>
</table>
</td>
<td valign="top">
<img src="img/s.gif" width="1" height="13" alt="" /><br />
<img src="img/lock.gif" width="31" height="49" alt="" /><br />
</td>
</tr>
</FORM>
</table>
</td>
</tr>
<tr>
- <td><img src="img/s.gif" width="1" height="1" alt="" /><br /></td>
+ <td><img src="img/s.gif" width="218" height="1" alt="" /><br /></td>
</tr>
</table>
<!-- end login box -->
Property changes on: trunk/themes/default/misc/right_login.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/admin/install.php
===================================================================
--- trunk/admin/install.php (revision 639)
+++ trunk/admin/install.php (revision 640)
@@ -1,1926 +1,1937 @@
<?php
error_reporting(0);
define('BACKUP_NAME', 'dump(.*).txt'); // how backup dump files are named
$general_error = '';
$pathtoroot = "";
if(!strlen($pathtoroot))
{
$path=dirname(realpath(__FILE__));
//$path=dirname(realpath(__FILE__));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$path_char = GetPathChar();
//phpinfo(INFO_VARIABLES);
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
ini_set('include_path', '.');
if( file_exists($pathtoroot.'debug.php') && !defined('DEBUG_MODE') ) include_once($pathtoroot.'debug.php');
if(!defined('IS_INSTALL'))define('IS_INSTALL',1);
$admin = substr($path,strlen($pathtoroot));
$state = isset($_GET["state"]) ? $_GET["state"] : '';
if(!strlen($state))
{
$state = isset($_POST['state']) ? $_POST['state'] : '';
}
if (!defined("GET_LICENSE_URL")) {
define("GET_LICENSE_URL", "http://www.intechnic.com/myaccount/license.php");
}
include($pathtoroot.$admin."/install/install_lib.php");
$install_type = GetVar('install_type', true);
$force_finish = isset($_REQUEST['ff']) ? true : false;
$ini_file = $pathtoroot."config.php";
if(file_exists($ini_file))
{
$write_access = is_writable($ini_file);
$ini_vars = inst_parse_portal_ini($ini_file,TRUE);
foreach($ini_vars as $secname => $section)
{
foreach($section as $key => $value)
{
$key = "g_".str_replace('-', '', $key);
global $$key;
$$key = $value;
}
}
}
else
{
$state="";
$write_access = is_writable($pathtoroot);
if($write_access)
{
set_ini_value("Database", "DBType", "");
set_ini_value("Database", "DBHost", "");
set_ini_value("Database", "DBUser", "");
set_ini_value("Database", "DBUserPassword", "");
set_ini_value("Database", "DBName", "");
set_ini_value("Module Versions", "In-Portal", "");
save_values();
}
}
$titles[1] = "General Site Setup";
$configs[1] = "in-portal:configure_general";
$mods[1] = "In-Portal";
$titles[2] = "User Setup";
$configs[2] = "in-portal:configure_users";
$mods[2] = "In-Portal:Users";
$titles[3] = "Category Display Setup";
$configs[3] = "in-portal:configure_categories";
$mods[3] = "In-Portal";
// simulate rootURL variable: begin
$rootURL = 'http://'.dirname($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']);
$tmp = explode('/', $rootURL);
if( $tmp[ count($tmp) - 1 ] == $admin) unset( $tmp[ count($tmp) - 1 ] );
$rootURL = implode('/', $tmp).'/';
unset($tmp);
//echo "RU: $rootURL<br>";
// simulate rootURL variable: end
$db_savings = Array('dbinfo', 'db_config_save', 'db_reconfig_save'); //, 'reinstall_process'
if( isset($g_DBType) && $g_DBType && strlen($state)>0 && !in_array($state, $db_savings) )
{
require_once($pathtoroot."kernel/startup.php");
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
//require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
}
function GetPathChar($path = null)
{
if( !isset($path) ) $path = $GLOBALS['pathtoroot'];
$pos = strpos($path, ':');
return ($pos === false) ? "/" : "\\";
}
function SuperStrip($str, $inverse = false)
{
$str = $inverse ? str_replace("%5C","\\",$str) : str_replace("\\","%5C",$str);
return stripslashes($str);
}
require_once($pathtoroot.$admin."/install/inst_ado.php");
$helpURL = $rootURL.$admin.'/help/install_help.php?destform=popup&help_usage=install';
?>
<html>
<head>
<title>In-Portal Installation</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Notepad">
<link rel="stylesheet" type="text/css" href="include/style.css">
<LINK REL="stylesheet" TYPE="text/css" href="install/2col.css">
<SCRIPT LANGUAGE="JavaScript1.2">
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 swap(imgid, src){
var ob = document.getElementById(imgid);
ob.src = 'images/' + src;
}
function Continue() {
document.iform1.submit();
}
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','<?php echo $rootURL.$admin; ?>/help/blank.html'); // , null, 600);
frm.target = 'HelpPopup';
frm.submit();
}
</SCRIPT>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" style="height: 100%">
<form name="help_form" id="help_form" action="<?php echo $helpURL; ?>" method="post"><input type="hidden" id="section" name="section" value=""></form>
<form enctype="multipart/form-data" name="iform1" id="iform1" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr>
<td height="90">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="90">
<tr>
<td rowspan="3" valign="top"><a href="http://www.in-portal.net" target="_top"><img alt="In-portal" src="images/globe.gif" width="84" height="91" border="0"></a></td>
<td rowspan="3" valign="top"><a href="http://www.in-portal.net" target="_top"><img alt="In-portal" src="images/logo.gif" width="150" height="91" border="0"></a></td>
<td rowspan="3" width="100000" align="right">&nbsp;</td>
<td width="400"><img alt="" src="images/blocks.gif" width="400" height="73"></td>
</tr>
<tr><td align="right" background="images/version_bg.gif" class="head_version" valign="top"><img alt="" src="images/spacer.gif" width="1" height="14">In-Portal Version <?php echo GetMaxPortalVersion($pathtoroot.$admin)?>: English US</td></tr>
<tr><td><img alt="" src="images/blocks2.gif" width="400" height="2"><br></td></tr>
<tr><td bgcolor="black" colspan="4"><img alt="" src="images/spacer.gif" width="1" height="1"><br></td></tr>
</table>
</td>
</tr>
<?php
require_once($pathtoroot."kernel/include/adodb/adodb.inc.php");
if(!strlen($state))
$state = @$_POST["state"];
//echo $state;
if(strlen($state)==0)
{
$ado =& inst_GetADODBConnection();
$installed = $ado ? TableExists($ado,"ConfigurationAdmin,Category,Permissions") : false;
if(!minimum_php_version("4.1.2"))
{
$general_error = "You have version ".phpversion()." - please upgrade!";
//die();
}
if(!$write_access)
{
if ($general_error != '') {
$general_error .= '<br /><br />';
}
$general_error .= "Install cannot write to config.php in the root directory of your in-portal installation ($pathtoroot).";
//die();
}
if(!is_writable($pathtoroot."themes/"))
{
if ($general_error != '') {
$general_error .= '<br /><br />';
}
$general_error .= "In-portal's Theme directory must be writable (".$pathtoroot."themes/).";
//die();
}
if(!is_writable($pathtoroot."kernel/images/"))
{
if ($general_error != '') {
$general_error .= '<br /><br />';
}
$general_error .= "In-portal's Image Upload directory must be writable (".$pathtoroot."kernel/images/).";
//die();
- }
+ }
+
+ if(!is_writable($pathtoroot."kernel/images/pending"))
+ {
+ if ($general_error != '') {
+ $general_error .= '<br /><br />';
+ }
+ $general_error .= "In-portal's Pending Image Upload directory must be writable (".$pathtoroot."kernel/images/pending).";
+ //die();
+ }
if(!is_writable($pathtoroot."admin/backupdata/"))
{
if ($general_error != '') {
$general_error .= '<br /><br />';
}
$general_error .= "In-portal's Backup directory must be writable (".$pathtoroot."admin/backupdata/).";
//die();
}
if(!is_writable($pathtoroot."admin/export/"))
{
if ($general_error != '') {
$general_error .= '<br /><br />';
}
$general_error .= "In-portal's Exportd directory must be writable (".$pathtoroot."admin/export/).";
//die();
}
if($installed)
{
$state="reinstall";
}
else {
$state="dbinfo";
}
}
if($state=="reinstall_process")
{
$login_err_mesg = ''; // always init vars before use
if( !isset($g_License) ) $g_License = '';
$lic = base64_decode($g_License);
if(strlen($lic))
{
inst_ParseLicense($lic);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
}
$LoggedIn = FALSE;
if($_POST["UserName"]=="root")
{
$ado =& inst_GetADODBConnection();
$sql = "SELECT * FROM ".$g_TablePrefix."ConfigurationValues WHERE VariableName='RootPass'";
$rs = $ado->Execute($sql);
if($rs && !$rs->EOF)
{
$RootPass = $rs->fields["VariableValue"];
if(strlen($RootPass)>0)
$LoggedIn = ($RootPass==md5($_POST["UserPass"]));
}
}
else
{
$act = '';
if (ConvertVersion($g_InPortal) >= ConvertVersion("1.0.5")) {
$act = 'check';
}
$rfile = @fopen(GET_LICENSE_URL."?login=".md5($_POST['UserName'])."&password=".md5($_POST['UserPass'])."&action=$act&license_code=".base64_encode($g_LicenseCode)."&version=".GetMaxPortalVersion($pathtoroot.$admin)."&domain=".base64_encode($_SERVER['HTTP_HOST']), "r");
if (!$rfile) {
$login_err_mesg = "Unable to connect to the Intechnic server!";
$LoggedIn = false;
}
else {
$rcontents = '';
while (!feof($rfile)) {
$line = fgets($rfile, 10000);
$rcontents .= $line;
}
@fclose($rfile);
if (substr($rcontents, 0, 5) == 'Error') {
$login_err_mesg = substr($rcontents, 6);
$LoggedIn = false;
}
else {
$LoggedIn = true;
}
}
//$LoggedIn = ($i_User == $_POST["UserName"] && ($i_Pswd == $_POST["UserPass"]) && strlen($i_User)>0) || strlen($i_User)==0;
}
if($LoggedIn)
{
if (!(int)$_POST["inp_opt"]) {
$state="reinstall";
$inst_error = "Please select one of the options above!";
}
else {
switch((int)$_POST["inp_opt"])
{
case 0:
$inst_error = "Please select an option above";
break;
case 1:
/* clean out all tables */
$install_type = 4;
$ado =& inst_GetADODBConnection();
$filename = $pathtoroot.$admin."/install/inportal_remove.sql";
RunSchemaFile($ado,$filename);
// removing other tables
$tables = $ado->MetaTables();
foreach($tables as $tab_name) {
if (stristr($tab_name, $g_TablePrefix."ses_")) {
$sql = "DROP TABLE IF EXISTS $tab_name";
$ado->Execute($sql);
}
}
/* run install again */
$state="license";
break;
case 2:
$install_type = 3;
$state="dbinfo";
break;
case 3:
$install_type = 5;
$state="license";
break;
case 4:
$install_type = 6;
/* clean out all tables */
$ado =& inst_GetADODBConnection();
//$filename = $pathtoroot.$admin."/install/inportal_remove.sql";
//RunSchemaFile($ado,$filename);
/* run install again */
$state="restore_select";
break;
case 5:
$install_type = 7;
/* change DB config */
$state="db_reconfig";
break;
case 6:
$install_type = 8;
$state = "upgrade";
break;
}
}
}
else
{
$state="reinstall";
$login_error = $login_err_mesg;//"Invalid Username or Password - Try Again";
}
}
if ($state == "upgrade") {
$ado =& inst_GetADODBConnection();
$Modules = array();
$Texts = array();
if (ConvertVersion(GetMaxPortalVersion($pathtoroot.$admin)) >= ConvertVersion("1.0.5") && ($g_LicenseCode == '' && $g_License != '')) {
$state = 'reinstall';
$inst_error = "Your license must be updated before you can upgrade. Please don't use 'Existing License' option, instead either Download from Intechnic or Upload a new license file!";
}
else {
$sql = "SELECT Name, Version FROM ".$g_TablePrefix."Modules ORDER BY LoadOrder asc";
$rs = $ado->Execute($sql);
$i = 0;
while ($rs && !$rs->EOF) {
$p = strtolower($rs->fields['Name']);
if ($p == 'in-portal') {
$p = '';
}
$dir_name = $pathtoroot.$p."/admin/install/upgrades/";
$dir = @dir($dir_name);
while ($file = $dir->read()) {
if ($file != "." && $file != ".." && !is_dir($dir_name.$file))
{
if (strstr($file, 'inportal_upgrade_v')) {
$file = str_replace("inportal_upgrade_v", "", $file);
$file = str_replace(".sql", "", $file);
$sql = "SELECT count(*) AS count FROM ".$g_TablePrefix."Modules WHERE Name = '".$rs->fields['Name']."' AND Version = '$file'";
$rs1 = $ado->Execute($sql);
if ($rs1->fields['count'] == 0 && ConvertVersion($file) > ConvertVersion($rs->fields['Version'])) {
if ($Modules[$i-1] == $rs->fields['Name']) {
$Texts[$i-1] = $rs->fields['Name']." (".$rs->fields['Version']." ".prompt_language("la_to")." ".$file.")";
$i--;
}
else {
$Texts[$i] = $rs->fields['Name']." (".$rs->fields['Version']." ".prompt_language("la_to")." ".$file.")";
$Modules[$i] = $rs->fields['Name'];
}
$i++;
}
}
}
}
$rs->MoveNext();
}
$include_file = $pathtoroot.$admin."/install/upgrade.php";
}
}
if ($state == "upgrade_process") {
$ado =& inst_GetADODBConnection();
$mod_arr = $_POST['modules'];
$mod_str = '';
foreach ($mod_arr as $tmp_mod) {
$mod_str .= "'$tmp_mod',";
}
$mod_str = substr($mod_str, 0, strlen($mod_str) - 1);
$sql = "SELECT Name FROM ".$g_TablePrefix."Modules WHERE Name IN ($mod_str) ORDER BY LoadOrder";
$rs = $ado->Execute($sql);
$mod_arr = array();
while ($rs && !$rs->EOF) {
$mod_arr[] = $rs->fields['Name'];
$rs->MoveNext();
}
foreach($mod_arr as $p)
{
$mod_name = strtolower($p);
$sql = "SELECT Version FROM ".$g_TablePrefix."Modules WHERE Name = '$p'";
$rs = $ado->Execute($sql);
$current_version = $rs->fields['Version'];
if ($mod_name == 'in-portal') {
$mod_name = '';
}
$dir_name = $pathtoroot.$mod_name."/admin/install/upgrades/";
$dir = @dir($dir_name);
$upgrades_arr = Array();
$new_version = '';
while ($file = $dir->read()) {
if ($file != "." && $file != ".." && !is_dir($dir_name.$file)) {
if (strstr($file, 'inportal_upgrade_v')) {
$upgrades_arr[] = $file;
}
}
}
usort($upgrades_arr, "VersionSort");
foreach($upgrades_arr as $file) {
$file_tmp = str_replace("inportal_upgrade_v", "", $file);
$file_tmp = str_replace(".sql", "", $file_tmp);
if (ConvertVersion($file_tmp) > ConvertVersion($current_version)) {
$filename = $pathtoroot.$mod_name."/admin/install/upgrades/$file";
//echo "Running: $filename<br>";
if(file_exists($filename))
{
RunSQLFile($ado, $filename);
}
}
}
set_ini_value("Module Versions", $p, GetMaxPortalVersion($pathtoroot.$mod_name."/admin/"));
save_values();
}
$state = 'languagepack_upgrade';
}
// upgrade language pack
if($state=='languagepack_upgrade')
{
$state = 'lang_install_init';
$_POST['lang'][] = 'english.lang';
$force_finish = true;
}
if($state=="db_reconfig_save")
{
$ini_vars = inst_parse_portal_ini($ini_file,TRUE);
foreach($ini_vars as $secname => $section)
{
foreach($section as $key => $value)
{
$key = "g_".str_replace("-", "", $key);
global $$key;
$$key = $value;
}
}
unset($ado);
$ado = VerifyDB('db_reconfig', 'finish', 'SaveDBConfig', true);
}
if($state=="db_reconfig")
{
$include_file = $pathtoroot.$admin."/install/db_reconfig.php";
}
if($state=="restore_file")
{
if($_POST["submit"]=="Update")
{
$filepath = $_POST["backupdir"];
$state="restore_select";
}
else
{
$filepath = stripslashes($_POST['backupdir']);
$backupfile = $filepath.$path_char.str_replace('(.*)', $_POST['backupdate'], BACKUP_NAME);
if(file_exists($backupfile) && is_readable($backupfile))
{
$ado =& inst_GetADODBConnection();
$show_warning = false;
if (!$_POST['warning_ok']) {
// Here we comapre versions between backup and config
$file_contents = file_get_contents($backupfile);
$file_tmp_cont = explode("#------------------------------------------", $file_contents);
$tmp_vers = $file_tmp_cont[0];
$vers_arr = explode(";", $tmp_vers);
$ini_values = inst_parse_portal_ini($ini_file);
foreach ($ini_values as $key => $value) {
foreach ($vers_arr as $k) {
if (strstr($k, $key)) {
if (!strstr($k, $value)) {
$show_warning = true;
}
}
}
}
//$show_warning = true;
}
if (!$show_warning) {
$filename = $pathtoroot.$admin.$path_char.'install'.$path_char.'inportal_remove.sql';
RunSchemaFile($ado,$filename);
$state="restore_run";
}
else {
$state = "warning";
$include_file = $pathtoroot.$admin."/install/warning.php";
}
}
else {
if ($_POST['backupdate'] != '') {
$include_file = $pathtoroot.$admin."/install/restore_select.php";
$restore_error = "$backupfile not found or could not be read";
}
else {
$include_file = $pathtoroot.$admin."/install/restore_select.php";
$restore_error = "No backup selected!!!";
}
}
}
//echo $restore_error;
}
if($state=="restore_select")
{
if( isset($_POST['backupdir']) ) $filepath = stripslashes($_POST['backupdir']);
$include_file = $pathtoroot.$admin."/install/restore_select.php";
}
if($state=="restore_run")
{
$ado =& inst_GetADODBConnection();
$FileOffset = (int)$_GET["Offset"];
if(!strlen($backupfile))
$backupfile = SuperStrip($_GET['File'], true);
$include_file = $pathtoroot.$admin."/install/restore_run.php";
}
if($state=="db_config_save")
{
set_ini_value("Database", "DBType",$_POST["ServerType"]);
set_ini_value("Database", "DBHost",$_POST["ServerHost"]);
set_ini_value("Database", "DBName",$_POST["ServerDB"]);
set_ini_value("Database", "DBUser",$_POST["ServerUser"]);
set_ini_value("Database", "DBUserPassword",$_POST["ServerPass"]);
set_ini_value("Database","TablePrefix",$_POST["TablePrefix"]);
save_values();
$ini_vars = inst_parse_portal_ini($ini_file,TRUE);
foreach($ini_vars as $secname => $section)
{
foreach($section as $key => $value)
{
$key = "g_".str_replace("-", "", $key);
global $$key;
$$key = $value;
}
}
unset($ado);
$ado = VerifyDB('dbinfo', 'license');
}
if($state=="dbinfo")
{
if ($install_type == '') {
$install_type = 1;
}
$include_file = $pathtoroot.$admin."/install/dbinfo.php";
}
if ($state == "download_license") {
$ValidLicense = FALSE;
$lic_login = isset($_POST['login']) ? $_POST['login'] : '';
$lic_password = isset($_POST['password']) ? $_POST['password'] : '';
if ($lic_login != '' && $lic_password != '') {
// Here we determine weather login is ok & check available licenses
$rfile = @fopen(GET_LICENSE_URL."?login=".md5($_POST['login'])."&password=".md5($_POST['password'])."&version=".GetMaxPortalVersion($pathtoroot.$admin)."&domain=".base64_encode($_SERVER['HTTP_HOST']), "r");
if (!$rfile) {
$get_license_error = "Unable to connect to the Intechnic server! Please try again later!";
$state = "get_license";
$include_file = $pathtoroot.$admin."/install/get_license.php";
}
else {
$rcontents = '';
while (!feof($rfile)) {
$line = fgets($rfile, 10000);
$rcontents .= $line;
}
@fclose($rfile);
if (substr($rcontents, 0, 5) == 'Error') {
$get_license_error = substr($rcontents, 6);
$state = "get_license";
$include_file = $pathtoroot.$admin."/install/get_license.php";
}
else {
if (substr($rcontents, 0, 3) == "SEL") {
$state = "download_license";
$license_select = substr($rcontents, 4);
$include_file = $pathtoroot.$admin."/install/download_license.php";
}
else {
// Here we get one license
$tmp_data = explode('Code==:', $rcontents);
$data = base64_decode(str_replace("In-Portal License File - do not edit!\n", "", $tmp_data[0]));
inst_ParseLicense($data);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
if($ValidLicense)
{
set_ini_value("Intechnic","License",base64_encode($data));
set_ini_value("Intechnic","LicenseCode",$tmp_data[1]);
save_values();
$state="domain_select";
$got_license = 1;
}
else {
$license_error="Invalid License File";
}
if(!$ValidLicense)
{
$state="license";
}
}
}
}
}
else if ($_POST['licenses'] == '') {
$state = "get_license";
$get_license_error = "Username and / or password not specified!!!";
$include_file = $pathtoroot.$admin."/install/get_license.php";
}
else {
// Here we download license
$rfile = @fopen(GET_LICENSE_URL."?license_id=".md5($_POST['licenses'])."&dlog=".md5($_POST['dlog'])."&dpass=".md5($_POST['dpass'])."&version=".GetMaxPortalVersion($pathtoroot.$admin)."&domain=".base64_encode($_POST['domain']), "r");
if (!$rfile) {
$get_license_error = "Unable to connect to the Intechnic server! Please try again later!";
$state = "get_license";
$include_file = $pathtoroot.$admin."/install/get_license.php";
}
else {
$rcontents = '';
while (!feof($rfile)) {
$line = fgets($rfile, 10000);
$rcontents .= $line;
}
@fclose($rfile);
if (substr($rcontents, 0, 5) == 'Error') {
$download_license_error = substr($rcontents, 6);
$state = "download_license";
$include_file = $pathtoroot.$admin."/install/download_license.php";
}
else {
$tmp_data = explode('Code==:', $rcontents);
$data = base64_decode(str_replace("In-Portal License File - do not edit!\n", "", $tmp_data[0]));
inst_ParseLicense($data);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
if($ValidLicense)
{
set_ini_value("Intechnic","License",base64_encode($data));
// old licensing script doen't return 2nd parameter (licanse code)
if( isset($tmp_data[1]) ) set_ini_value("Intechnic","LicenseCode",$tmp_data[1]);
save_values();
$state="domain_select";
}
else {
$license_error="Invalid License File";
}
if(!$ValidLicense)
{
$state="license";
}
}
}
}
}
if($state=="license_process")
{
$ValidLicense = FALSE;
$tmp_lic_opt = GetVar('lic_opt', true);
switch($tmp_lic_opt)
{
case 1: /* download from intechnic */
$include_file = $pathtoroot.$admin."/install/get_license.php";
$state = "get_license";
//if(!$ValidLicense)
//{
// $state="license";
//}
break;
case 2: /* upload file */
$file = $_FILES["licfile"];
if(is_array($file))
{
move_uploaded_file($file["tmp_name"],$pathtoroot."themes/tmp.lic");
+ @chmod($pathtoroot."themes/tmp.lic", 0666);
+
$fp = @fopen($pathtoroot."themes/tmp.lic","rb");
if($fp)
{
$lic = fread($fp,filesize($pathtoroot."themes/tmp.lic"));
fclose($fp);
}
$tmp_data = inst_LoadLicense(FALSE,$pathtoroot."themes/tmp.lic");
$data = $tmp_data[0];
@unlink($pathtoroot."themes/tmp.lic");
inst_ParseLicense($data);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
if($ValidLicense)
{
set_ini_value("Intechnic","License",base64_encode($data));
set_ini_value("Intechnic","LicenseCode",$tmp_data[1]);
save_values();
$state="domain_select";
}
else
$license_error="Invalid License File";
}
if(!$ValidLicense)
{
$state="license";
}
break;
case 3: /* existing */
if(strlen($g_License))
{
$lic = base64_decode($g_License);
inst_ParseLicense($lic);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
if($ValidLicense)
{
$state="domain_select";
}
else
{
$state="license";
$license_error="Invalid or corrupt license detected";
}
}
else
{
$state="license";
$license_error="Missing License File";
}
if(!$ValidLicense)
{
$state="license";
}
break;
case 4:
//set_ini_value("Intechnic","License",base64_encode("local"));
//set_ini_value("Intechnic","LicenseCode",base64_encode("local"));
//save_values();
$state="domain_select";
break;
}
if($ValidLicense)
$state="domain_select";
}
if($state=="license")
{
$include_file = $pathtoroot.$admin."/install/sel_license.php";
}
if($state=="reinstall")
{
$ado =& inst_GetADODBConnection();
$show_upgrade = false;
$sql = "SELECT Name FROM ".$g_TablePrefix."Modules";
$rs = $ado->Execute($sql);
$modules = '';
while ($rs && !$rs->EOF) {
$modules .= strtolower($rs->fields['Name']).',';
$rs->MoveNext();
}
$mod_arr = explode(",", substr($modules, 0, strlen($modules) - 1));
foreach($mod_arr as $p)
{
if ($p == 'in-portal') {
$p = '';
}
$dir_name = $pathtoroot.$p."/admin/install/upgrades/";
$dir = @dir($dir_name);
//echo "<pre>"; print_r($dir); echo "</pre>";
while ($file = $dir->read()) {
if ($file != "." && $file != ".." && !is_dir($dir_name.$file))
{
if (strstr($file, 'inportal_upgrade_v')) {
$file = str_replace("inportal_upgrade_v", "", $file);
$file = str_replace(".sql", "", $file);
if ($p == '') {
$p = 'in-portal';
}
$sql = "SELECT Version FROM ".$g_TablePrefix."Modules WHERE Name = '".$p."'";
$rs = $ado->Execute($sql);
if (ConvertVersion($rs->fields['Version']) < ConvertVersion($file)) {
$show_upgrade = true;
}
}
}
}
}
if ( !isset($install_type) || $install_type == '') {
$install_type = 2;
}
$include_file = $pathtoroot.$admin."/install/reinstall.php";
}
if($state=="login")
{
$lic = base64_decode($g_License);
if(strlen($lic))
{
inst_ParseLicense($lic);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
}
if(!$ValidLicense)
{
$state="license";
}
else
if($i_User == $_POST["UserName"] || $i_Pswd == $_POST["UserPass"])
{
$state = "domain_select";
}
else
{
$state="getuser";
$login_error = "Invalid User Name or Password. If you don't know your username or password, contact Intechnic Support";
}
//die();
}
if($state=="getuser")
{
$include_file = $pathtoroot.$admin."/install/login.php";
}
if($state=="set_domain")
{
if( !is_array($i_Keys) || !count($i_Keys) )
{
$lic = base64_decode($g_License);
if(strlen($lic))
{
inst_ParseLicense($lic);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
}
}
if($_POST["domain"]==1)
{
$domain = $_SERVER['HTTP_HOST'];
if (strstr($domain, $i_Keys[0]['domain']) || inst_IsLocalSite($domain)) {
set_ini_value("Intechnic","Domain",$domain);
save_values();
$state="runsql";
}
else {
$DomainError = 'Domain name selected does not match domain name in the license!';
$state = "domain_select";
}
}
else
{
$domain = str_replace(" ", "", $_POST["other"]);
if ($domain != '') {
if (strstr($domain, $i_Keys[0]['domain']) || inst_IsLocalSite($domain)) {
set_ini_value("Intechnic","Domain",$domain);
save_values();
$state="runsql";
}
else {
$DomainError = 'Domain name entered does not match domain name in the license!';
$state = "domain_select";
}
}
else {
$DomainError = 'Please enter valid domain!';
$state = "domain_select";
}
}
}
if($state=="domain_select")
{
if(!is_array($i_Keys))
{
$lic = base64_decode($g_License);
if(strlen($lic))
{
inst_ParseLicense($lic);
$ValidLicense = ((strlen($i_User)>0) && (strlen($i_Pswd)>0));
}
}
$include_file = $pathtoroot.$admin."/install/domain.php";
}
if($state=="runsql")
{
$ado =& inst_GetADODBConnection();
$installed = TableExists($ado,"ConfigurationAdmin,Category,Permissions");
if(!$installed)
{
// create tables
$filename = $pathtoroot.$admin."/install/inportal_schema.sql";
RunSchemaFile($ado,$filename);
// insert default info
$filename = $pathtoroot.$admin."/install/inportal_data.sql";
RunSQLFile($ado,$filename);
$sql = "SELECT Version FROM ".$g_TablePrefix."Modules WHERE Name = 'In-Portal'";
$rs = $ado->Execute($sql);
set_ini_value("Module Versions", "In-Portal", $rs->fields['Version']);
save_values();
require_once $pathtoroot.'kernel/include/tag-class.php';
if( !is_object($objTagList) ) $objTagList = new clsTagList();
// install kernel specific tags
$objTagList->DeleteTags(); // delete all existing tags in db
// create 3 predifined tags (because there no functions with such names
$t = new clsTagFunction();
$t->Set("name","include");
$t->Set("description","insert template output into the current template");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert","",TRUE);
$t->AddAttribute("_supresserror","bool","Supress missing template errors","",FALSE);
$t->AddAttribute("_dataexists","bool","Only include template output if content exists (content is defined by the tags in the template)","",FALSE);
$t->AddAttribute("_nodatatemplate","tpl","Template to include if the nodataexists condition is true","",FALSE);
unset($t);
$t = new clsTagFunction();
$t->Set("name","perm_include");
$t->Set("description","insert template output into the current template if permissions are set");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert","",TRUE);
$t->AddAttribute("_noaccess","tpl","Template to insert if access is denied","",FALSE);
$t->AddAttribute("_permission","","Comma-separated list of permissions, any of which will grant access","",FALSE);
$t->AddAttribute("_module","","Used in place of the _permission attribute, this attribute verifies the module listed is enabled","",FALSE);
$t->AddAttribute("_system","bool","Must be set to true if any permissions in _permission list is a system permission","",FALSE);
$t->AddAttribute("_supresserror","bool","Supress missing template errors","",FALSE);
$t->AddAttribute("_dataexists","bool","Only include template output if content exists (content is defined by the tags in the template)","",FALSE);
$t->AddAttribute("_nodatatemplate","tpl","Template to include if the nodataexists condition is true","",FALSE);
unset($t);
$t = new clsTagFunction();
$t->Set("name","mod_include");
$t->Set("description","insert templates from all enabled modules. No error occurs if the template does not exist.");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert. This template path should be relative to the module template root directory","",TRUE);
$t->AddAttribute("_modules","","Comma-separated list of modules. Defaults to all enabled modules if not set","",FALSE);
$t->AddAttribute("_supresserror","bool","Supress missing template errors","",FALSE);
$t->AddAttribute("_dataexists","bool","Only include template output if content exists (content is defined by the tags in the template)","",FALSE);
$t->AddAttribute("_nodatatemplate","tpl","Template to include if the nodataexists condition is true","",FALSE);
$objTagList->ParseFile($pathtoroot.'kernel/parser.php'); // insert module tags
if( is_array($ItemTagFiles) )
foreach($ItemTagFiles as $file)
$objTagList->ParseItemFile($pathtoroot.$file);
$state="RootPass";
}
else {
$include_file = $pathtoroot.$admin."/install/install_finish.php";
$state="finish";
}
}
if ($state == "finish") {
$ado =& inst_GetADODBConnection();
$PhraseTable = $g_TablePrefix."ImportPhrases";
$EventTable = $g_TablePrefix."ImportEvents";
$ado->Execute("DROP TABLE IF EXISTS $PhraseTable");
$ado->Execute("DROP TABLE IF EXISTS $EventTable");
$include_file = $pathtoroot.$admin."/install/install_finish.php";
}
if($state=="RootSetPass")
{
$pass = $_POST["RootPass"];
if(strlen($pass)<4)
{
$PassError = "Root Password must be at least 4 characters";
$state = "RootPass";
}
else if ($pass != $_POST["RootPassConfirm"]) {
$PassError = "Passwords does not match";
$state = "RootPass";
}
else
{
$pass = md5($pass);
$sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '$pass' WHERE VariableName='RootPass' OR VariableName='RootPassVerify'";
$ado =& inst_GetADODBConnection();
$ado->Execute($sql);
$state="modselect";
}
}
if($state=="RootPass")
{
$include_file = $pathtoroot.$admin."/install/rootpass.php";
}
if($state=="lang_install_init")
{
include_once($pathtoroot."kernel/include/xml.php");
$ado =& inst_GetADODBConnection();
if (TableExists($ado, "Language,Phrase")) {
$MaxInserts = 200;
$PhraseTable = $g_TablePrefix."ImportPhrases";
$EventTable = $g_TablePrefix."ImportEvents";
$sql = "CREATE TABLE $PhraseTable SELECT Phrase,Translation,PhraseType,LanguageId FROM ".$g_TablePrefix."Phrase WHERE PhraseId=-1";
$ado->Execute($sql);
$sql = "CREATE TABLE $EventTable SELECT Template,MessageType,EventId,LanguageId FROM ".$g_TablePrefix."EmailMessage WHERE EmailMessageId=-1";
$ado->Execute($sql);
$sql = "SELECT EventId,Event,Type FROM ".$g_TablePrefix."Events";
$rs = $ado->Execute($sql);
$Events = array();
while($rs && !$rs->EOF)
{
$Events[$rs->fields["Event"]."_".$rs->fields["Type"]] = $rs->fields["EventId"];
$rs->MoveNext();
}
if(count($_POST["lang"])>0)
{
$Langs = $_POST["lang"];
for($x=0;$x<count($Langs);$x++)
{
$lang = $Langs[$x];
$p = $pathtoroot.$admin."/install/langpacks/".$lang;
/* parse xml file */
$fp = fopen($p,"r");
$xml = fread($fp,filesize($p));
fclose($fp);
unset($objInXML);
$objInXML = new xml_doc($xml);
$objInXML->parse();
$objInXML->getTag(0,$name,$attribs,$contents,$tags);
if(is_array($tags))
{
foreach($tags as $t)
{
$LangRoot =& $objInXML->getTagByID($t);
$PackName = $LangRoot->attributes["PACKNAME"];
$l = $objLanguages->GetItemByField("PackName",$PackName);
if(is_object($l))
{
$LangId = $l->Get("LanguageId");
$NewLang = false;
}
else
{
$l = new clsLanguage();
$l->Set("Enabled",1);
$l->Create();
$NewLang = true;
$LangId = $l->Get("LanguageId");
}
foreach($LangRoot->children as $tag)
{
switch($tag->name)
{
case "PHRASES":
foreach($tag->children as $PhraseTag)
{
$Phrase = $ado->qstr($PhraseTag->attributes["LABEL"]);
$Translation = $ado->qstr(base64_decode($PhraseTag->contents));
$PhraseType = $PhraseTag->attributes["TYPE"];
$psql = "INSERT INTO $PhraseTable (Phrase,Translation,PhraseType,LanguageId) VALUES ($Phrase,$Translation,$PhraseType,$LangId)";
$ado->Execute($psql);
//echo "$psql <br>\n";
}
break;
case "DATEFORMAT":
$DateFormat = $tag->contents;
break;
case "TIMEFORMAT":
$TimeFormat = $tag->contents;
break;
case "DECIMAL":
$Decimal = $tag->contents;
break;
case "THOUSANDS":
$Thousands = $tag->contents;
break;
case "EVENTS":
foreach($tag->children as $EventTag)
{
$event = $EventTag->attributes["EVENT"];
$MsgType = strtolower($EventTag->attributes["MESSAGETYPE"]);
$template = base64_decode($EventTag->contents);
$Type = $EventTag->attributes["TYPE"];
$EventId = $Events[$event."_".$Type];
$esql = "INSERT INTO $EventTable (Template,MessageType,EventId,LanguageId) VALUES ('$template','$MsgType',$EventId,$LangId)";
$ado->Execute($esql);
//echo htmlentities($esql)."<br>\n";
}
break;
}
if($NewLang)
{
$l->Set("PackName",$PackName);
$l->Set("LocalName",$PackName);
$l->Set("DateFormat",$DateFormat);
$l->Set("TimeFormat",$TimeFormat);
$l->Set("DecimalPoint",$Decimal);
$l->Set("ThousandSep",$Thousands);
$l->Update();
}
}
}
}
}
$state="lang_install";
}
else {
$state="lang_select";
}
}
else {
$general_error = 'Database error! No language tables found!';
}
}
if($state=="lang_install")
{
/* do pack install */
$Offset = (int)$_GET["Offset"];
$Status = (int)$_GET["Status"];
$PhraseTable = $g_TablePrefix."ImportPhrases";
$EventTable = $g_TablePrefix."ImportEvents";
if($Status==0)
{
$Total = TableCount($PhraseTable,"",0);
}
else
{
$Total = TableCount($EventTable,"",0);
}
if($Status==0)
{
$Offset = $objLanguages->ReadImportTable($PhraseTable, 1,"0,1,2", $force_finish ? false : true, 200,$Offset);
if($Offset>=$Total)
{
$Offset=0;
$Status=1;
}
$next_step = GetVar('next_step', true);
if($force_finish == true) $next_step = 3;
$NextUrl = $_SERVER['PHP_SELF']."?Offset=$Offset&Status=$Status&state=lang_install&next_step=$next_step&install_type=$install_type";
if($force_finish == true) $NextUrl .= '&ff=1';
$include_file = $pathtoroot.$admin."/install/lang_run.php";
}
else
{
if(!is_object($objMessageList))
$objMessageList = new clsEmailMessageList();
$Offset = $objMessageList->ReadImportTable($EventTable, $force_finish ? false : true,100,$Offset);
if($Offset>$Total)
{
$next_step = GetVar('next_step', true);
if($force_finish == true) $next_step = 3;
$NextUrl = $_SERVER['PHP_SELF']."?Offset=$Offset&Status=$Status&State=lang_install&next_step=$next_step&install_type=$install_type";
if($force_finish == true) $NextUrl .= '&ff=1';
$include_file = $pathtoroot.$admin."/install/lang_run.php";
}
else
{
$db =&GetADODBConnection();
$prefix = $g_TablePrefix;
$db->Execute('DROP TABLE IF EXISTS '.$prefix.'ImportPhrases');
$db->Execute('DROP TABLE IF EXISTS '.$prefix.'ImportEvents');
if( !$force_finish )
{
$state = 'lang_default';
}
else
{
$_POST['next_step'] = 4;
$state = 'finish';
$include_file = $pathtoroot.$admin."/install/install_finish.php";
}
}
}
}
if($state=="lang_default_set")
{
// phpinfo(INFO_VARIABLES);
/*$ado =& inst_GetADODBConnection();
$PhraseTable = GetTablePrefix()."ImportPhrases";
$EventTable = GetTablePrefix()."ImportEvents";
$ado->Execute("DROP TABLE IF EXISTS $PhraseTable");
$ado->Execute("DROP TABLE IF EXISTS $EventTable");*/
$Id = $_POST["lang"];
$objLanguages->SetPrimary($Id);
$state="postconfig_1";
}
if($state=="lang_default")
{
$Packs = Array();
$objLanguages->Clear();
$objLanguages->LoadAllLanguages();
foreach($objLanguages->Items as $l)
{
$Packs[$l->Get("LanguageId")] = $l->Get("PackName");
}
$include_file = $pathtoroot.$admin."/install/lang_default.php";
}
if($state=="modinstall")
{
$doms = $_POST["domain"];
if(is_array($doms))
{
$ado =& inst_GetADODBConnection();
require_once $pathtoroot.'kernel/include/tag-class.php';
if( !isset($objTagList) || !is_object($objTagList) ) $objTagList = new clsTagList();
foreach($doms as $p)
{
$filename = $pathtoroot.$p.'/admin/install.php';
if(file_exists($filename) )
{
include($filename);
}
}
}
/* $sql = "SELECT Name FROM ".GetTablePrefix()."Modules";
$rs = $ado->Execute($sql);
while($rs && !$rs->EOF)
{
$p = $rs->fields['Name'];
$mod_name = strtolower($p);
if ($mod_name == 'in-portal') {
$mod_name = '';
}
$dir_name = $pathtoroot.$mod_name."/admin/install/upgrades/";
$dir = @dir($dir_name);
$new_version = '';
$tmp1 = 0;
$tmp2 = 0;
while ($file = $dir->read()) {
if ($file != "." && $file != ".." && !is_dir($dir_name.$file))
{
$file = str_replace("inportal_upgrade_v", "", $file);
$file = str_replace(".sql", "", $file);
if ($file != '' && !strstr($file, 'changelog') && !strstr($file, 'readme')) {
$tmp1 = str_replace(".", "", $file);
if ($tmp1 > $tmp2) {
$new_version = $file;
}
}
}
$tmp2 = $tmp1;
}
$version_nrs = explode(".", $new_version);
for ($i = 0; $i < $version_nrs[0] + 1; $i++) {
for ($j = 0; $j < $version_nrs[1] + 1; $j++) {
for ($k = 0; $k < $version_nrs[2] + 1; $k++) {
$try_version = "$i.$j.$k";
$filename = $pathtoroot.$mod_name."/admin/install/upgrades/inportal_upgrade_v$try_version.sql";
if(file_exists($filename))
{
RunSQLFile($ado, $filename);
set_ini_value("Module Versions", $p, $try_version);
save_values();
}
}
}
}
$rs->MoveNext();
}
*/
$state="lang_select";
}
if($state=="lang_select")
{
$Packs = GetLanguageList();
$include_file = $pathtoroot.$admin."/install/lang_select.php";
}
if($state=="modselect")
{
/* /admin/install.php */
$UrlLen = (strlen($admin) + 12)*-1;
$pathguess =substr($_SERVER["SCRIPT_NAME"],0,$UrlLen);
$sitepath = $pathguess;
$esc_path = str_replace("\\","/",$pathtoroot);
$esc_path = str_replace("/","\\",$esc_path);
//set_ini_value("Site","DomainName",$_SERVER["HTTP_HOST"]);
//$g_DomainName= $_SERVER["HTTP_HOST"];
save_values();
$ado =& inst_GetADODBConnection();
if(substr($sitepath,0,1)!="/")
$sitepath="/".$sitepath;
if(substr($sitepath,-1)!="/")
$sitepath .= "/";
$sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '$sitepath' WHERE VariableName='Site_Path'";
$ado->Execute($sql);
$sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '$g_Domain' WHERE VariableName='Server_Name'";
$ado->Execute($sql);
$sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '".$_SERVER['DOCUMENT_ROOT'].$sitepath."admin/backupdata' WHERE VariableName='Backup_Path'";
$ado->Execute($sql);
$Modules = inst_GetModuleList();
$include_file = $pathtoroot.$admin."/install/modselect.php";
}
if(substr($state,0,10)=="postconfig")
{
$p = explode("_",$state);
$step = $p[1];
if ($_POST['Site_Path'] != '') {
$sql = "SELECT Name, Version FROM ".$g_TablePrefix."Modules";
$rs = $ado->Execute($sql);
$modules_str = '';
while ($rs && !$rs->EOF) {
$modules_str .= $rs->fields['Name'].' ('.$rs->fields['Version'].'),';
$rs->MoveNext();
}
$modules_str = substr($modules_str, 0, strlen($modules_str) - 1);
$rfile = @fopen(GET_LICENSE_URL."?url=".base64_encode($_SERVER['HTTP_HOST'].$_POST['Site_Path'])."&modules=".base64_encode($modules_str)."&license_code=".base64_encode($g_LicenseCode)."&version=".GetMaxPortalVersion($pathtoroot.$admin)."&domain=".md5($_SERVER['HTTP_HOST']), "r");
if (!$rfile) {
//$get_license_error = "Unable to connect to the Intechnic server! Please try again later!";
//$state = "postconfig_1";
//$include_file = $pathtoroot.$admin."/install/postconfig.php";
}
else {
$rcontents = '';
while (!feof($rfile)) {
$line = fgets($rfile, 10000);
$rcontents .= $line;
}
@fclose($rfile);
}
}
if(strlen($_POST["oldstate"])>0)
{
$s = explode("_",$_POST["oldstate"]);
$oldstep = $s[1];
if($oldstep<count($configs))
{
$section = $configs[$oldstep];
$module = $mods[$oldstep];
$title = $titles[$oldstep];
$objAdmin = new clsConfigAdmin($module,$section,TRUE);
$objAdmin->SaveItems($_POST,TRUE);
}
}
$section = $configs[$step];
$module = $mods[$step];
$title = $titles[$step];
$step++;
if($step <= count($configs)+1)
{
$include_file = $pathtoroot.$admin."/install/postconfig.php";
}
else
$state = "theme_sel";
}
if($state=="theme_sel")
{
$objThemes->CreateMissingThemes();
$include_file = $pathtoroot.$admin."/install/theme_select.php";
}
if($state=="theme_set")
{
## get & define Non-Blocking & Blocking versions ##
$blocking_sockets = minimum_php_version("4.3.0")? 0 : 1;
$ado =& inst_GetADODBConnection();
$sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '$blocking_sockets' WHERE VariableName='SocketBlockingMode'";
$ado->Execute($sql);
## get & define Non-Blocking & Blocking versions ##
$theme_id = $_POST["theme"];
$pathchar="/";
//$objThemes->SetPrimaryTheme($theme_id);
$t = $objThemes->GetItem($theme_id);
$t->Set("Enabled",1);
$t->Set("PrimaryTheme",1);
$t->Update();
$t->VerifyTemplates();
$include_file = $pathtoroot.$admin."/install/install_finish.php";
$state="finish";
}
if ($state == "adm_login") {
echo "<script>window.location='index.php';</script>";
}
// init variables
$vars = Array('db_error','restore_error','PassError','DomainError','login_error','inst_error');
foreach($vars as $var_name) ReSetVar($var_name);
switch($state)
{
case "modselect":
$title = "Select Modules";
$help = "<p>Select the In-Portal modules you wish to install. The modules listed to the right ";
$help .="are all modules included in this installation that are licensed to run on this server. </p>";
break;
case "reinstall":
$title = "Installation Maintenance";
$help = "<p>A Configuration file has been detected on your system and it appears In-Portal is correctly installed. ";
$help .="In order to work with the maintenance functions provided to the left you must provide the Intechnic ";
$help .="Username and Password you used when obtaining the license file residing on the server, or your admin Root password. ";
$help .=" <i>(Use Username 'root' if using your root password)</i></p>";
$help .= "<p>To removing your existing database and start with a fresh installation, select the first option ";
$help .= "provided. Note that this operation cannot be undone and no backups are made! Use at your own risk.</p>";
$help .="<p>If you wish to scrap your current installation and install to a new location, choose the second option. ";
$help .="If this option is selected you will be prompted for new database configuration information.</p>";
$help .="<p>The <i>Update License Information</i> option is used to update your In-Portal license data. Select this option if you have ";
$help .="modified your licensing status with Intechnic, or you have received new license data via email</p>";
break;
case "RootPass":
$title = "Set Admin Root Password";
$help = "<p>The Root Password is initially required to access the admin sections of In-Portal. ";
$help .="The root user cannot be used to access the front-end of the system, so it is recommended that you ";
$help .="create additional users with admin privlidges.</p>";
break;
case "finish":
$title = "Thank You!";
$help ="<P>Thanks for using In-Portal! Be sure to visit <A TARGET=\"_new\" HREF=\"http://www.in-portal.net\">www.in-portal.net</A> ";
$help.=" for the latest news, module releases and support. </p>";
break;
case "license":
$title = "License Configuration";
$help ="<p>A License is required to run In-Portal on a server connected to the Internet. You ";
$help.="can run In-Portal on localhost, non-routable IP addresses, or other computers on your LAN. ";
$help.="If Intechnic has provided you with a license file, upload it here. Otherwise select the first ";
$help.="option to allow Install to download your license for you.</p>";
$help.="<p>If a valid license has been detected on your server, you can choose the <i>Use Existing License</i> ";
$help.="and continue the installation process</p>";
break;
case "domain_select":
$title="Select Licensed Domain";
$help ="<p>Select the domain you wish to configure In-Portal for. The <i>Other</i> option ";
$help.=" can be used to configure In-Portal for use on a local domain.</p>";
$help.="<p>For local domains, enter the hostname or LAN IP Address of the machine running In-Portal.</p>";
break;
case "db_reconfig":
case "dbinfo":
$title="Database Configuration";
$help = "<p>In-Portal needs to connect to your Database Server. Please provide the database server type*, ";
$help .="host name (<i>normally \"localhost\"</i>), Database user name, and database Password. ";
$help .="These fields are required to connect to the database.</p><p>If you would like In-Portal ";
$help .="to use a table prefix, enter it in the field provided. This prefix can be any ";
$help .=" text which can be used in the names of tables on your system. The characters entered in this field ";
$help .=" are placed <i>before</i> the names of the tables used by In-Portal. For example, if you enter \"inp_\"";
$help .=" into the prefix field, the table named Category will be named inp_Category.</p>";
break;
case "lang_select":
$title="Language Pack Installation";
$help = "<p>Select the language packs you wish to install. Each language pack contains all the phrases ";
$help .="used by the In-Portal administration and the default template set. Note that at least one ";
$help .="pack <b>must</b> be installed.</p>";
break;
case "lang_default":
$title="Select Default Language";
$help = "<p>Select which language should be considered the \"default\" language. This is the language ";
$help .="used by In-Portal when a language has not been selected by the user. This selection is applicable ";
$help .="to both the administration and front-end.</p>";
break;
case "lang_install":
$title="Installing Language Packs";
$help = "<p>The language packs you have selected are being installed. You may install more languages at a ";
$help.="later time from the Regional admin section.</p>";
break;
case "postconfig_1":
$help = "<P>These options define the general operation of In-Portal. Items listed here are ";
$help .="required for In-Portal's operation.</p><p>When you have finished, click <i>save</i> to continue.</p>";
break;
case "postconfig_2":
$help = "<P>User Management configuration options determine how In-Portal manages your user base.</p>";
$help .="<p>The groups listed to the right are pre-defined by the installation process and may be changed ";
$help .="through the Groups section of admin.</p>";
break;
case "postconfig_3":
$help = "<P>The options listed here are used to control the category list display functions of In-Portal. </p>";
break;
case "theme_sel":
$title="Select Default Theme";
$help = "<P>This theme will be used whenever a front-end session is started. ";
$help .="If you intend to upload a new theme and use that as default, you can do so through the ";
$help .="admin at a later date. A default theme is required for session management.</p>";
break;
case "get_license":
$title="Download License from Intechnic";
$help ="<p>A License is required to run In-Portal on a server connected to the Internet. You ";
$help.="can run In-Portal on localhost, non-routable IP addresses, or other computers on your LAN.</p>";
$help.="<p>Here as you have selected download license from Intechnic you have to input your username and ";
$help.="password of your In-Business account in order to download all your available licenses.</p>";
break;
case "download_license":
$title="Download License from Intechnic";
$help ="<p>A License is required to run In-Portal on a server connected to the Internet. You ";
$help.="can run In-Portal on localhost, non-routable IP addresses, or other computers on your LAN.</p>";
$help.="<p>Please choose the license from the drop down for this site! </p> ";
break;
case "restore_select":
$title="Select Restore File";
$help = "<P>Select the restore file to use to reinstall In-Portal. If your backups are not performed ";
$help .= "in the default location, you can enter the location of the backup directory and click the ";
$help .="<i>Update</i> button.</p>";
case "restore_run":
$title= "Restore in Progress";
$help = "<P>Restoration of your system is in progress. When the restore has completed, the installation ";
$help .="will continue as normal. Hitting the <i>Cancel</i> button will restart the entire installation process. ";
break;
case "warning":
$title = "Restore in Progress";
$help = "<p>Please approve that you understand that you are restoring your In-Portal data base from other version of In-Portal.</p>";
break;
case "update":
$title = "Update In-Portal";
$help = "<p>Select modules from the list, you need to update to the last downloaded version of In-Portal</p>";
break;
}
$tmp_step = GetVar('next_step', true);
if (!$tmp_step) {
$tmp_step = 1;
}
if ( isset($got_license) && $got_license == 1) {
$tmp_step++;
}
$next_step = $tmp_step + 1;
if ($general_error != '') {
$state = '';
$title = '';
$help = '';
$general_error = $general_error.'<br /><br />Installation cannot continue!';
}
if ($include_file == '' && $general_error == '' && $state == '') {
$state = '';
$title = '';
$help = '';
$filename = $pathtoroot.$admin."/install/inportal_remove.sql";
RunSQLFile($ado,$filename);
$general_error = 'Unexpected installation error! <br /><br />Installation has been stopped!';
}
if ($restore_error != '') {
$next_step = 3;
$tmp_step = 2;
}
if ($PassError != '') {
$tmp_step = 4;
$next_step = 5;
}
if ($DomainError != '') {
$tmp_step--;
$next_step = $tmp_step + 1;
}
if ($db_error != '') {
$tmp_step--;
$next_step = $tmp_step + 1;
}
if ($state == "warning") {
$tmp_step--;
$next_step = $tmp_step + 1;
}
?>
<tr height="100%">
<td valign="top">
<table cellpadding=10 cellspacing=0 border=0 width="100%" height="100%">
<tr valign="top">
<td style="width: 200px; background: #009ff0 url(images/bg_install_menu.gif) no-repeat bottom right; border-right: 1px solid #000">
<img src="images/spacer.gif" width="180" height="1" border="0" alt=""><br>
<span class="admintitle-white">Installation</span>
<!--<ol class="install">
<li class="current">Licence Verification
<li>Configuration
<li>File Permissions
<li>Security
<li>Integrity Check
</ol>
</td>-->
<?php
$lic_opt = isset($_POST['lic_opt']) ? $_POST['lic_opt'] : false;
if ($general_error == '') {
?>
<?php if ($install_type == 1) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1) { ?>class="current"<?php } ?>>Database Configuration
<li <?php if ($tmp_step == 2 || $lic_opt == 1) { ?>class="current"<?php } ?>>Select License
<li <?php if ($tmp_step == 3 && $lic_opt != 1) { ?>class="current"<?php } ?>>Select Domain
<li <?php if ($tmp_step == 4 ) { ?>class="current"<?php } ?>>Set Root Password
<li <?php if ($tmp_step == 5) { ?>class="current"<?php } ?>>Select Modules to Install
<li <?php if ($tmp_step == 6) { ?>class="current"<?php } ?>>Install Language Packs
<li <?php if ($tmp_step == 7) { ?>class="current"<?php } ?>>Post-Install Configuration
<li <?php if ($tmp_step == 8) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 2) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<!--<li <?php if (($tmp_step == 2 && $login_error == '' && $inst_error == '') || $_POST['lic_opt'] == 1) { ?>class="current"<?php } ?>>Select License
<li <?php if ($tmp_step == 3 && $_POST['lic_opt'] != 1) { ?>class="current"<?php } ?>>Select Domain
<li <?php if ($tmp_step == 4) { ?>class="current"<?php } ?>>Set Root Password
<li <?php if ($tmp_step == 5) { ?>class="current"<?php } ?>>Select Modules to Install
<li <?php if ($tmp_step == 6) { ?>class="current"<?php } ?>>Install Language Packs
<li <?php if ($tmp_step == 7) { ?>class="current"<?php } ?>>Post-Install Configuration
<li <?php if ($tmp_step == 8) { ?>class="current"<?php } ?>>Finish-->
</ol>
<?php } else if ($install_type == 3) { ?>
<ol class="install">
<li>License Verification
<li <?php if ($tmp_step == 2) { ?>class="current"<?php } ?>>Database Configuration
<li <?php if ($tmp_step == 3 || $_POST['lic_opt'] == 1) { ?>class="current"<?php } ?>>Select License
<li <?php if ($tmp_step == 4 && $_POST['lic_opt'] != 1) { ?>class="current"<?php } ?>>Select Domain
<li <?php if ($tmp_step == 5) { ?>class="current"<?php } ?>>Set Root Password
<li <?php if ($tmp_step == 6) { ?>class="current"<?php } ?>>Select Modules to Install
<li <?php if ($tmp_step == 7) { ?>class="current"<?php } ?>>Install Language Packs
<li <?php if ($tmp_step == 8) { ?>class="current"<?php } ?>>Post-Install Configuration
<li <?php if ($tmp_step == 9) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 4) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<li <?php if (($tmp_step == 2 && $login_error == '' && $inst_error == '') || $lic_opt == 1) { ?>class="current"<?php } ?>>Select License
<li <?php if ($tmp_step == 3 && $_POST['lic_opt'] != 1) { ?>class="current"<?php } ?>>Select Domain
<li <?php if ($tmp_step == 4) { ?>class="current"<?php } ?>>Set Root Password
<li <?php if ($tmp_step == 5) { ?>class="current"<?php } ?>>Select Modules to Install
<li <?php if ($tmp_step == 6) { ?>class="current"<?php } ?>>Install Language Packs
<li <?php if ($tmp_step == 7) { ?>class="current"<?php } ?>>Post-Install Configuration
<li <?php if ($tmp_step == 8) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 5) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<li <?php if (($tmp_step == 2 && $login_error == '' && $inst_error == '') || $lic_opt == 1) { ?>class="current"<?php } ?>>Select License
<li <?php if ($tmp_step == 3 && $lic_opt != 1) { ?>class="current"<?php } ?>>Select Domain
<li <?php if ($tmp_step == 4) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 6) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<li <?php if (($tmp_step == 2 && $login_error == '' && $inst_error == '') || $_GET['show_prev'] == 1 || $_POST['backupdir']) { ?>class="current"<?php } ?>>Select Backup File
<li <?php if ($tmp_step == 3 && $_POST['lic_opt'] != 1 && $_GET['show_prev'] != 1 && !$_POST['backupdir']) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 7) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<li <?php if ($tmp_step == 2 && $login_error == '' && $inst_error == '') { ?>class="current"<?php } ?>>Database Configuration
<li <?php if ($tmp_step == 3) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } else if ($install_type == 8) { ?>
<ol class="install">
<li <?php if ($tmp_step == 1 || $login_error != '' || $inst_error != '') { ?>class="current"<?php } ?>>License Verification
<li <?php if ($tmp_step == 2 && $login_error == '' && $inst_error == '') { ?>class="current"<?php } ?>>Select Modules to Upgrade
<li <?php if ($tmp_step == 3) { ?>class="current"<?php } ?>>Language Pack Upgrade
<li <?php if ($tmp_step == 4) { ?>class="current"<?php } ?>>Finish
</ol>
<?php } ?>
<?php include($include_file); ?>
<?php } else { ?>
<?php include("install/general_error.php"); ?>
<?php } ?>
<td width="40%" style="border-left: 1px solid #000; background: #f0f0f0">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="subsectiontitle" style="border-bottom: 1px solid #000000; background-color:#999"><?php if( isset($title) ) echo $title;?></td>
</tr>
<tr>
<td class="text"><?php if( isset($help) ) echo $help;?></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="footer">
Powered by In-portal &copy; 1997-2004, Intechnic Corporation. All rights reserved.
<br><img src="images/spacer.gif" width="1" height="10" alt="">
</td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
Property changes on: trunk/admin/install.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.63
\ No newline at end of property
+1.64
\ No newline at end of property
Index: trunk/admin/templates/cat_search_element.tpl
===================================================================
--- trunk/admin/templates/cat_search_element.tpl (revision 639)
+++ trunk/admin/templates/cat_search_element.tpl (revision 640)
@@ -1,16 +1,16 @@
<TD>
<div inportaltype="categories">
- <input type="checkbox" value="<inp:cat_id/>" name="catlist[]">
- <a href="javascript:AdminCatNav('<inp:cat_link_admin/>');"><img src="<inp:cat_admin_icon/>" border="0" align="absMiddle"></a><span class="priority"><sup><inp:cat_priority/></sup></span>
- <a class="link" href="javascript:AdminCatNav('<inp:cat_link_admin/>');"><b><inp:cat_name/></b></a>:
- <span class="cat_pick"><inp:cat_pick/></SPAN>
- <span class="cat_new"><inp:cat_new/></SPAN>
- <span class="cats_stats">(Cats <inp:subcat_count/> / Links 2)</span>
+ <input type="checkbox" value="<inp:cat _field="id"/>" name="catlist[]">
+ <a href="javascript:AdminCatNav('<inp:cat _field="link_admin"/>');"><img src="<inp:cat _field="admin_icon"/>" border="0" align="absMiddle"></a><span class="priority"><sup><inp:cat _field="priority"/></sup></span>
+ <a class="link" href="javascript:AdminCatNav('<inp:cat _field="link_admin"/>');"><b><inp:cat _field="name"/></b></a>:
+ <span class="cat_pick"><inp:cat _field="pick"/></SPAN>
+ <span class="cat_new"><inp:cat _field="new"/></SPAN>
+ <span class="cats_stats">(Cats <inp:cat _Field="subcatcount" /> / Items <inp:cat _field="totalitems"/>)</span>
<br>
<div style="padding-left:3px">
- <span class="cat_desc"><inp:cat_desc/></SPAN><br>
- <span class="cats_stats">(Added 02-12-2002)</span><br>
- <span class="cat_fullpath"><inp:cat_fullpath/></span>
+ <span class="cat_desc"><inp:cat _field="description"/></SPAN><br>
+ <span class="cats_stats">(Added <inp:cat _field="date" />)</span><br>
+ <span class="cat_fullpath"><inp:cat _field="fullpath"/></span>
</div>
</div>
</TD>
Property changes on: trunk/admin/templates/cat_search_element.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/config/importlang_progress.php
===================================================================
--- trunk/admin/config/importlang_progress.php (revision 639)
+++ trunk/admin/config/importlang_progress.php (revision 640)
@@ -1,329 +1,331 @@
<?php
##############################################################
##In-portal ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
if(!strlen($pathtoroot))
{
$path=dirname(realpath(__FILE__));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
$FrontEnd=2;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
// $pathtolocal = $pathtoroot."in-link/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
//require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
include_once($pathtoroot."kernel/include/xml.php");
$section = "in-portal:lang_import";
$ado = &GetADODBConnection();
$MaxInserts = 200;
$PhraseTable = "ses_".$objSession->GetSessionKey()."_".GetTablePrefix()."ImportPhrases";
$EventTable = "ses_".$objSession->GetSessionKey()."_".GetTablePrefix()."ImportEvents";
$OverWrite = $_POST['overwrite'];
if(count($_POST)>0)
{
$Offset = 0;
$CurrentLang=0;
$file = $_FILES["lang_file"];
if(is_array($file))
{
if((int)$file["size"]>0)
{
move_uploaded_file($file["tmp_name"],$pathtoroot.$admin."/export/".$file["name"]);
+ @chmod($pathtoroot.$admin."/export/".$file["name"], 0666);
+
$filename = $pathtoroot.$admin."/export/".$file["name"];
if(file_exists($filename))
{
/* parse xml file */
$fp = @fopen($filename,"r");
$xml = @fread($fp,filesize($filename));
@fclose($fp);
$objInXML = new xml_doc($xml);
$objInXML->parse();
$sql = "CREATE TABLE $PhraseTable SELECT Phrase,Translation,PhraseType,LanguageId FROM ".GetTablePrefix()."Phrase WHERE PhraseId=-1";
$ado->Execute($sql);
$sql = "CREATE TABLE $EventTable SELECT Template,MessageType,EventId,LanguageId FROM ".GetTablePrefix()."EmailMessage WHERE EmailMessageId=-1";
$ado->Execute($sql);
//$sql = "ALTER TABLE $EventTable ADD `Type` INT(11) default 0";
//$ado->Execute($sql);
$sql = "SELECT EventId,Event,Type FROM ".GetTablePrefix()."Events";
$rs = $ado->Execute($sql);
$Events = array();
while($rs && !$rs->EOF)
{
$Events[$rs->fields["Event"]."_".$rs->fields["Type"]] = $rs->fields["EventId"];
$rs->MoveNext();
}
$objInXML->getTag(0,$name,$attribs,$contents,$tags);
if(is_array($tags))
{
foreach($tags as $t)
{
$LangRoot =& $objInXML->getTagByID($t);
$PackName = $LangRoot->attributes["PACKNAME"];
$l = $objLanguages->GetItemByField("PackName",$PackName);
if(is_object($l))
{
$LangId = $l->Get("LanguageId");
}
else
{
$l = new clsLanguage();
$l->Create();
$NewLang = TRUE;
$LangId = $l->Get("LanguageId");
}
foreach($LangRoot->children as $tag)
{
switch($tag->name)
{
case "PHRASES":
foreach($tag->children as $PhraseTag)
{
$Phrase = $ado->qstr($PhraseTag->attributes["LABEL"]);
$Translation = $ado->qstr(base64_decode($PhraseTag->contents));
$PhraseType = $PhraseTag->attributes["TYPE"];
$psql = "INSERT INTO $PhraseTable (Phrase,Translation,PhraseType,LanguageId) VALUES ($Phrase,$Translation,$PhraseType,$LangId)";
$ado->Execute($psql);
//echo "$psql <br>\n";
}
break;
case "DATEFORMAT":
$DateFormat = $tag->contents;
break;
case "TIMEFORMAT":
$TimeFormat = $tag->contents;
break;
case "DECIMAL":
$Decimal = $tag->contents;
break;
case "THOUSANDS":
$Thousands = $tag->contents;
break;
case "EVENTS":
foreach($tag->children as $EventTag)
{
$event = $EventTag->attributes["EVENT"];
$MsgType = strtolower($EventTag->attributes["MESSAGETYPE"]);
$template = base64_decode($EventTag->contents);
$Type = $EventTag->attributes["TYPE"];
$EventId = $Events[$event."_".$Type];
$esql = "INSERT INTO $EventTable (Template,MessageType,EventId,LanguageId) VALUES ('$template','$MsgType',$EventId,$LangId)";
$ado->Execute($esql);
//echo htmlentities($esql)."<br>\n";
}
break;
}
if($NewLang)
{
$l->Set("PackName",$PackName);
$l->Set("LocalName",$PackName);
$l->Set("DateFormat",$DateFormat);
$l->Set("TimeFormat",$TimeFormat);
$l->Set("DecimalPoint",$Decimal);
$l->Set("ThousandSep",$Thousands);
$l->Update();
}
}
}
$Types = implode(",",$_POST["langtypes"]);
$objSession->SetVariable("lang_types",$Types);
$objSession->SetVariable("lang_overwrite",(int)$_POST["overwrite"]);
$Total = TableCount($PhraseTable,"PhraseType IN ($Types)",0);
$objSession->SetVariable("phrase_total",$Total);
$Total = TableCount($EventTable,"",0);
$objSession->SetVariable("event_total",$Total);
$Offset = 0;
$Status = 0;
//unlink($filename);
}
}
}
}
}
else
{
$Offset = (int)$_GET["Offset"];
$Status = (int)$_GET["Status"];
$OverWrite = $objSession->GetVariable("lang_overwrite");
$Types = $objSession->GetVariable("lang_types");
if($Status==0)
{
$Total = $objSession->GetVariable("phrase_total");
}
else
$Total = $objSession->GetVariable("event_total");
}
//echo $Total;
if ($Total == "") {
$url = $adminURL."/config/importlang.php?env=".BuildEnv()."&importerror=1";
Header("Location: $url");
//reload($url);
}
$title = admin_language("la_Text_LangImport")." - ".admin_language("la_Step")." 2";
int_header(NULL,NULL, $title);
?>
<TABLE cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<?php
if($Status==0)
{
$Total = $objSession->GetVariable("phrase_total");
stats(prompt_language("la_lang_import_progress"),$Offset,$Total);
$Offset = $objLanguages->ReadImportTable($PhraseTable,1,$Types,$OverWrite,$MaxInserts,$Offset);
if($Offset<$Total)
{
$url = $_SERVER["PHP_SELF"]."?env=".BuildEnv()."&Offset=$Offset&Status=0";
}
else
{
if($objSession->GetVariable("event_total")>0)
{
$url = $_SERVER["PHP_SELF"]."?env=".BuildEnv()."&Offset=0&Status=1";
}
else
$url = $adminURL."/config/config_lang.php?env=".BuildEnv();
}
reload($url);
}
else
{
$Total = $objSession->GetVariable("event_total");
$Offset = $objMessageList->ReadImportTable($EventTable,$OverWrite,$MaxInserts,$Offset);
if($Offset<$Total)
{
$url = $_SERVER["PHP_SELF"]."?env=".BuildEnv()."&Offset=$Offset&Status=1";
}
else
{
$ado->Execute("DROP TABLE IF EXISTS $PhraseTable");
$ado->Execute("DROP TABLE IF EXISTS $EventTable");
$url = $adminURL."/config/config_lang.php?env=".BuildEnv();
}
stats(prompt_language("la_event_import_progress"),$Offset,$Total);
reload($url);
}
function stats($caption,$myprogress,$totalnum)
{
global $rootURL, $CancelURL, $PageTitle;
if($totalnum>0)
{
$pct=round(($myprogress/ $totalnum)*100);
}
else
$pct = 100;
$o .="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"tableborder\">";
echo "\n";
$o .= int_subsection_title_ret($caption." - ".$pct."%");
$o .= "<TR><TD align=\"middle\"><br />";
$o .= " <TABLE CLASS=\"tableborder_full\" width=\"75%\">";
$o .=" <TR border=1><TD width=\"".$pct."%\" STYLE=\"background:url('".$rootURL."admin/images/progress_bar_segment.gif');\">&nbsp;</TD>";
$comp_pct = 100-$pct;
$o .= " <TD bgcolor=#FFFFFF width=\"".$comp_pct."%\"></TD></TR>";
$o .= " </TABLE>";
$o .= " <BR /><input type=button VALUE=\"".admin_language("la_Cancel")."\" CLASS=\"button\" ONCLICK=\"document.location='".$CancelURL."config_lang.php?env=".BuildEnv()."&action=cancel';\">";
echo $o."\n";
echo "</TD></TR></TABLE>";
}
function reload($url)
{
print "<script language=\"javascript\">" ;
print "setTimeout(\"document.location='$url';\",100);";
print " </script>";
//echo "<A HREF=\"$url\">Next </A>";
}
?>
<?php int_footer(); ?>
Property changes on: trunk/admin/config/importlang_progress.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property

Event Timeline