Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Aug 17, 11:37 AM

in-portal

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
Index: branches/unlabeled/unlabeled-1.2.20/kernel/include/statitem.php
===================================================================
--- branches/unlabeled/unlabeled-1.2.20/kernel/include/statitem.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.2.20/kernel/include/statitem.php (revision 3393)
@@ -0,0 +1,344 @@
+<?php
+class clsStatItem extends clsParsedItem
+{
+ var $GotValue;
+ var $TagCache = Array(); // parsed tag (in sql queries only) values are cached
+
+ var $CurrentSQL = ''; // sql query being currently processed
+ var $PostFormatting = false; // apply formatting to sql query results
+ var $PostFormattingParams = Array(); // post formatting params if any
+ function clsStatItem($id=NULL)
+ {
+ $this->clsItemDB();
+ $this->tablename = GetTablePrefix()."StatItem";
+ $this->id_field = "StatItemId";
+ $this->NoResourceId = 1;
+ $this->GotValue = FALSE;
+
+ if($id)
+ $this->LoadFromDatabase($id);
+ }
+
+
+ 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 ".$this->IdField()." = '%s'",$Id);
+ $result = $this->adodbConnection->Execute($sql);
+ if ($result === false)
+ {
+ $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
+ return false;
+ }
+
+ $data = $result->fields;
+
+ $this->SetFromArray($data);
+ return true;
+ }
+
+ function ExecuteResetSQL()
+ {
+ $sql = $this->Get("ValueSQL");
+ $sql = str_replace("<%prefix%>",GetTablePrefix(),$sql);
+ $this->adodbConnection->Execute($sql);
+ }
+
+ function ExecuteValueSQL()
+ {
+ global $ADODB_FETCH_MODE;
+
+ $ADODB_FETCH_MODE = 3;
+ $this->CurrentSQL = $this->Get("ValueSQL");
+
+ // 1. replace prefix to actual one
+ $this->CurrentSQL = str_replace("<%prefix%>", GetTablePrefix(), $this->CurrentSQL);
+
+ // 2. replace config variable to it's value
+ while( ($tag = $this->FindTag()) != false )
+ {
+ if( !array_key_exists( trim($tag), $this->TagCache ) )
+ {
+ // unprocessed tag -> parse it to get result
+ $this->TagCache[ trim($tag) ] = $this->ProcessTag($tag);
+ }
+
+ $tagResult = $this->TagCache[ trim($tag) ]; // return result from cache
+ $this->CurrentSQL = str_replace('<%'.$tag.'%>', $tagResult, $this->CurrentSQL);
+ }
+
+ $values = array();
+ $rs = $this->adodbConnection->Execute($this->CurrentSQL);
+ if($rs && !$rs->EOF)
+ {
+ $value = $rs->fields[0];
+ if($this->PostFormatting)
+ {
+ switch($this->PostFormatting)
+ {
+ case 'number': // simple-specific postformatting
+ $value = LangNumber($value, $this->PostFormattingParams['precision']);
+ break;
+
+ // extended postformatting
+ case 'COUNT':
+ $value = $rs->RecordCount();
+ break;
+ case 'SUM':
+ $field_sum = 0;
+ $rs->MoveFirst();
+ while(!$rs->EOF)
+ {
+ $field_sum += $rs->fields[ $this->PostFormattingParams['field'] ];
+ $rs->MoveNext();
+ }
+ $value = $field_sum;
+ if($this->PostFormattingParams['format_as'] == 'file') $value = size($value);
+ break;
+ // other type of information (not from db)
+ case 'SysFileSize':
+ $value = size( dir_size($GLOBALS['pathtoroot']) );
+ break;
+
+ default: // simple-default postformatting
+ $value = adodb_date($this->PostFormatting, $value);
+ break;
+ }
+ $this->PostFormatting = false;
+ $this->PostFormattingParams = Array();
+ }
+ $this->Set("Value", $value);
+ }
+ $ADODB_FETCH_MODE = 2;
+ $this->GotValue=TRUE;
+ }
+
+ // -- new: begin --
+ function FindTag()
+ {
+ // finds tag in current sql & returns it if found, false otherwise
+ $tagOpen = '<%'; $tagClose = '%>'; $tagOpenLen = strlen($tagOpen);
+ $startPos = strpos($this->CurrentSQL, $tagOpen);
+ if( $startPos !== false )
+ {
+ $endPos = strpos($this->CurrentSQL, $tagClose, $startPos);
+ return ($endPos > $startPos) ? substr($this->CurrentSQL, $startPos + $tagOpenLen, $endPos - $startPos - $tagOpenLen) : false;
+ }
+ return false;
+ }
+
+ function ProcessTag($tag)
+ {
+ $db =& $this->adodbConnection;
+ $tmp_params = explode(' ', $tag); // 1st - function, 2nd .. nth - params
+ $tag_name = array_shift($tmp_params);
+ foreach($tmp_params as $param)
+ {
+ $param = explode('=', $param);
+ $param_value = substr($param[1], 1, strlen($param[1]) - 2);
+ $param_value = str_replace('+',' ', $param_value);
+ $tag_params[ $param[0] ] = $param_value;
+ }
+ switch($tag_name)
+ {
+ case 'm:config': // rerieves config value for specific parameter (parameter name passed)
+ $sql = 'SELECT VariableValue FROM '.GetTablePrefix()."ConfigurationValues WHERE VariableName = '%s'";
+ return $db->GetOne( sprintf($sql, $tag_params['name']) );
+ break;
+
+ case 'm:post_format':
+ switch($tag_params['type'])
+ {
+ case 'date': $this->PostFormatting = GetDateFormat(); break;
+ case 'time': $this->PostFormatting = GetTimeFormat(); break;
+ case 'currency':
+ $this->PostFormatting = 'number';
+ $this->PostFormattingParams['precision'] = $tag_params['precision'];
+ break;
+ }
+ return $tag_params['field'];
+ break;
+
+ case 'm:custom_action':
+ $this->PostFormatting = $tag_params['action'];
+ return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql'];
+ break;
+
+ //m:sql_action sql="SHOW TABLES" action="COUNT" field="*"
+ case 'm:sql_action':
+ $this->PostFormatting = $tag_params['action'];
+ $this->PostFormattingParams = $tag_params;
+ return $tag_params['sql'];
+ break;
+
+ case 'link:hit_count':
+ $type = $tag_params['type'];
+ $sql = 'SELECT Hits FROM '.GetTablePrefix().'Link ';
+ if($type == 'top') // by now only top is supported
+ {
+ $top_links_count = $this->ProcessTag('m:config name="Link_TopCount"'); // 5 - default
+ $sql .= 'ORDER BY Hits DESC LIMIT 0,'.$top_links_count;
+
+ $rs = $db->Execute($sql);
+ if($rs->RecordCount() > 0)
+ {
+ $rs->MoveLast();
+ return $rs->fields['Hits'];
+ }
+ else
+ return 0;
+ }
+ break;
+
+ case 'article:hit_count':
+ $type = $tag_params['type'];
+ $sql = 'SELECT CachedRating FROM '.GetTablePrefix().'News ';
+ if($type == 'top') // by now only top is supported
+ {
+ $top_articles_count = $this->ProcessTag('m:config name="News_VotesToHot"');
+ $min_votes = $this->ProcessTag('m:config name="News_MinVotes"');
+ $sql .= 'WHERE CachedVotesQty > '.$min_votes.' ORDER BY CachedRating DESC LIMIT 0,'.$top_articles_count;
+
+ $rs = $db->Execute($sql);
+ if($rs->RecordCount() > 0)
+ {
+ $rs->MoveLast();
+ return $rs->fields['CachedRating'];
+ }
+ else
+ return 0;
+ }
+ break;
+
+ case 'topic:hit_count':
+ $type = $tag_params['type'];
+ $sql = 'SELECT Views FROM '.GetTablePrefix().'Topic ';
+ if($type == 'top') // by now only top is supported
+ {
+ $top_posts_count = $this->ProcessTag('m:config name="Topic_PostsToPop"');
+ $sql .= ' ORDER BY Views DESC LIMIT 0,'.$top_posts_count;
+
+ $rs = $db->Execute($sql);
+ if($rs->RecordCount() > 0)
+ {
+ $rs->MoveLast();
+ return $rs->fields['Views'];
+ }
+ else
+ return 0;
+ }
+ break;
+
+ case 'modules:get_current':
+ return $this->Get('Module');
+ break;
+ }
+ }
+ // -- new: end --
+
+ function GetValue()
+ {
+ if(!$this->GotValue)
+ $this->ExecuteValueSQL();
+ return $this->Get("Value");
+ }
+
+ function ParseObject($element)
+ {
+ return $this->parsetag($element->name);
+ }
+
+ function parsetag($tag)
+ {
+ if(is_object($tag))
+ {
+ $tagname = $tag->name;
+ }
+ else
+ $tagname = $tag;
+ switch($tagname)
+ {
+ case "stats_module":
+ $ret = $this->Get("Module");
+ break;
+ case "stats_label":
+ $ret = admin_language($this->Get("ListLabel"));
+ break;
+ case "stats_adminlabel":
+ $ret = admin_language($this->Get("ListLabel"));
+ brea;
+ case "stats_value":
+ $ret = $this->GetValue();
+ break;
+ }
+ return $ret;
+ }
+}
+
+class clsStatList extends clsItemCollection
+{
+ var $Page;
+ var $PerPageVar;
+
+ function clsStatList()
+ {
+ $this->clsItemCollection();
+ $this->SourceTable = GetTablePrefix()."StatItem";
+ $this->classname = "clsStatItem";
+ $this->Page=1;
+ $this->PerPageVar = "Perpage_StatItem";
+ $this->AdminSearchFields = array("ListLabel", "Module", "Value");
+ }
+
+ function ProcessList($where, $orderBy, $use_limit = false)
+ {
+ // fills list with data
+ $this->LoadStatItems($where,$orderBy, $use_limit );
+
+ for($i=0; $i < $this->NumItems(); $i++)
+ {
+ $s =& $this->GetItemRefByIndex($i);
+ $s->Set("ListLabel",admin_language($s->Get("ListLabel")));
+ }
+ $this->ExecuteValue();
+ }
+
+ function ExecuteValue()
+ {
+ for($i=0;$i<$this->NumItems();$i++)
+ {
+ $s =& $this->GetItemRefByIndex($i);
+ $s->ExecuteValueSQL();
+ }
+ if($this->debuglevel) echo "LastSQL: ".$s->CurrentSQL.'<br>';
+ }
+
+ function ExecuteResetSQL()
+ {
+ foreach($this->Items as $s) $s->ExecuteResetSQL();
+ }
+
+ function LoadStatItems($where=NULL,$orderBy, $use_limit = false)
+ {
+ global $objSession, $objConfig;
+
+ $sql = "SELECT * FROM ".$this->SourceTable;
+ if(strlen(trim($where)))
+ $sql .= " WHERE ".$where;
+ if(strlen(trim($orderBy)))
+ $sql .= " ORDER BY ".$orderBy;
+
+ if($use_limit)
+ $sql .= " ".GetLimitSQL($this->Page,$objConfig->Get($this->PerPageVar));
+
+ if($this->debuglevel) echo "StatGetSQL: $sql<br>";
+ $this->Query_Item($sql);
+ }
+}
+?>
Property changes on: branches/unlabeled/unlabeled-1.2.20/kernel/include/statitem.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.2
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.2.20/kernel/admin/include/help/editcategory_general.txt
===================================================================
--- branches/unlabeled/unlabeled-1.2.20/kernel/admin/include/help/editcategory_general.txt (nonexistent)
+++ branches/unlabeled/unlabeled-1.2.20/kernel/admin/include/help/editcategory_general.txt (revision 3393)
@@ -0,0 +1,15 @@
+<ul>
+<li> Enable HTML? – this check box enables or disables HTML code in the category name and the category description. When checked, it will render the HTML (for example, a &lt;B&gt; tag will actually make the text bold). When unchecked, it will display the HTML as regular text (the &lt;B&gt; tag will appear exactly as ‘&lt;B&gt;'). This is very important, since some HTML tags can break the page layout, and in some instances can be a security weakness (the Java Script, for example).
+<li> Category ID - this is a read-only field that displays the internal system ID. It is of a small importance, other than the fact that it's a truly unique identifier of a category – there can never be two categories with the same ID.
+<li> Name - this is the category name
+<li> Description - this is the category description
+<li> Automatic Directory Name – specifies whether the Directory Name used for mod_rewrite should be generated automatically from the category name, or entered manually. If checked, the Directory Name will be generated from the category name, replacing all special characters ( !@#$%^&*()+|\=-~`{}][:”’;,./?>< ) by the underscore character (“_”), and all multiple underscores with a single underscore. If the resulting name ends with an underscore followed by number, an additional letter will be appended, since the names ending with a number are reserved for system use. The resulting name will also be checked for uniqueness, and if it’s not unique, additional letters will be appended to the end of the name
+<li>Directory Name – the directory name used for the URL generation when using mod_rewrite. The field is disabled if Automatic Directory Name is On. If Automatic Directory Name is Off, the administrator may enter the directory name manually, however it will still be checked for uniqueness, special characters and whether it ends with a number. In such cases the Directory Name will be automatically corrected before saving.
+<li> ‘Editor' – this icon that looks like a notepad and a pen, will pop up the online HTML editor for the category description. It will only work if the Enable HTML check box is checked.
+<li> Status – this is the category status
+<li> New – this is the control for the ‘New' flag. The ‘auto' setting will let the system set the ‘new' flag automatically, based on the number of days since its creation and a setting; ‘always' will enable the flag, and ‘never' will disable it.
+<li> Editor's Pick – this sets the Editor's pick flag
+<li> Created on – this is the creation date. It can be either entered directly into the field, or you can use the calendar tool to select a date. The ‘Calendar' button is an icon to the right of the field that looks like a date book page. To the right of the ‘Calendar' button there is a hint that shows the current date format. This format may change, if a different Regional package is activated.
+<li> META keywords – this field contains the META keywords that will be displayed on the front end of the In-portal site, in the special HTML “meta” tags. These particular keywords will be displayed when the current category is entered.
+META description – similar to the META keywords, but for the META description HTML tag. Both are useful for search engine recognition of the page, as well as alternative descriptions of the category that will not be visible to a human visitor.
+</ul>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.2.20/kernel/admin/include/help/editcategory_general.txt
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.2
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline