Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Thu, Feb 6, 11:58 PM

in-portal

Index: branches/RC/core/units/admin/admin_events_handler.php
===================================================================
--- branches/RC/core/units/admin/admin_events_handler.php (revision 9238)
+++ branches/RC/core/units/admin/admin_events_handler.php (revision 9239)
@@ -1,228 +1,247 @@
<?php
class AdminEventsHandler extends kDBEventHandler {
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnSaveColumns' => array('self' => true),
'OnClosePopup' => array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
function OnResetModRwCache(&$event)
{
$this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName LIKE "mod_rw%"');
}
function OnResetCMSMenuCache(&$event)
{
$this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "cms_menu"');
}
function OnResetSections(&$event)
{
$this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
}
function OnResetConfigsCache(&$event)
{
$this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files" OR VarName = "configs_parsed" OR VarName = "sections_parsed"');
}
function OnCompileTemplates(&$event)
{
$compiler =& $this->Application->recallObject('NParserCompiler');
/* @var $compiler NParserCompiler */
$compiler->CompileTemplatesStep();
$event->status = erSTOP;
}
/**
* Generates sturcture for specified table
*
* @param kEvent $event
* @author Alex
*/
function OnGenerateTableStructure(&$event)
{
$types_hash = Array(
'string' => 'varchar|text|mediumtext|longtext|date|datetime|time|timestamp|char|year|enum|set',
'int' => 'smallint|mediumint|int|bigint|tinyint',
'float' => 'float',
'double' => 'double',
'numeric' => 'decimal',
);
$table_name = $this->Application->GetVar('table_name');
if (!$table_name) {
echo 'error: no table name specified';
return ;
}
if (TABLE_PREFIX && !preg_match('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', $table_name)) {
// table name without prefix, then add it
$table_name = TABLE_PREFIX.$table_name;
}
if (!$this->Conn->TableFound($table_name)) {
// table with prefix doesn't exist, assume that just config prefix passed -> resolve table name from it
$table_name = $this->Application->getUnitOption(substr($table_name, strlen(TABLE_PREFIX)), 'TableName');
}
$table_info = $this->Conn->Query('DESCRIBE '.$table_name);
// 1. prepare config keys
$id_field = '';
$fields = Array();
$float_types = Array ('float', 'double', 'numeric');
foreach ($table_info as $field_info) {
if (preg_match('/l[\d]+_.*/', $field_info['Field'])) {
// don't put multilingual fields in config
continue;
}
$field_options = Array ();
// 1. get php field type by mysql field type
foreach ($types_hash as $php_type => $db_types) {
if (preg_match('/'.$db_types.'/', $field_info['Type'])) {
$field_options['type'] = $php_type;
break;
}
}
$default_value = $field_info['Default'];
if (in_array($php_type, $float_types)) {
// this is float number
if (preg_match('/'.$db_types.'\([\d]+,([\d]+)\)/i', $field_info['Type'], $regs)) {
// size is described in structure -> add formatter
$field_options['formatter'] = 'kFormatter';
$field_options['format'] = '%01.'.$regs[1].'f';
$default_value = 0;
}
else {
// no size information, just convert to float
$default_value = (float)$default_value;
}
}
if (preg_match('/varchar\(([\d]+)\)/i', $field_info['Type'], $regs)) {
$field_options['max_len'] = (int)$regs[1];
}
if ($field_info['Null'] != 'YES') {
$field_options['not_null'] = 1;
}
if ($field_info['Key'] == 'PRI') {
$default_value = 0;
$id_field = $field_info['Field'];
}
if ($php_type == 'int' && ($field_info['Null'] != 'YES' || is_numeric($default_value))) {
// is integer field AND not null
$field_options['default'] = (int)$default_value;
}
else {
$field_options['default'] = $default_value;
}
$fields[ $field_info['Field'] ] = $this->transformDump($field_options);
}
$ret = stripslashes(var_export($fields, true));
$ret = preg_replace("/'(.*?)' => 'Array \((.*?), \)',/", "'\\1' => Array (\\2),", $ret);
$ret = preg_replace("/\n '/", "\n\t'", $ret);
$ret = "'IDField' => '".$id_field."',\n'Fields' => A".substr($ret, 1).',';
ob_start();
?>
<html>
<head>
<title>Table "<?php echo $table_name; ?>" Structure</title>
</head>
<body bgcolor="#E7E7E7">
<a href="javascript:window.close();">Close Window</a><br />
<?php echo $GLOBALS['debugger']->highlightString($ret); ?>
<br /><a href="javascript:window.close();">Close Window</a><br />
</body>
</html>
<?php
echo ob_get_clean();
$event->status = erSTOP;
}
function transformDump($dump)
{
if (is_array($dump)) {
$dump = var_export($dump, true);
}
$dump = preg_replace("/,\n[ ]*/", ', ', $dump);
$dump = preg_replace("/array \(\n[ ]*/", 'Array (', $dump); // replace array start
$dump = preg_replace("/,\n[ ]*\),/", "),", $dump); // replace array end
return $dump;
}
/**
* Refreshes ThemeFiles & Theme tables by actual content on HDD
*
* @param kEvent $event
*/
function OnRebuildThemes(&$event)
{
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
$themes_helper->refreshThemes();
}
function OnSaveColumns(&$event) {
$picker_helper =& $this->Application->RecallObject('ColumnPickerHelper');
$picker_helper->SetGridName($this->Application->GetLinkedVar('grid_name'));
/* @var $picker_helper kColumnPickerHelper */
$picked = trim($this->Application->GetVar('picked_str'), '|');
$hidden = trim($this->Application->GetVar('hidden_str'), '|');
$main_prefix = $this->Application->GetVar('main_prefix');
$picker_helper->SaveColumns($main_prefix, $picked, $hidden);
$this->finalizePopup($event);
}
/**
+ * Saves various admin settings via ajax
+ *
+ * @param kEvent $event
+ */
+ function OnSaveSetting(&$event)
+ {
+ if ($this->Application->GetVar('ajax') != 'yes') {
+ return ;
+ }
+
+ $var_name = $this->Application->GetVar('var_name');
+ $var_value = $this->Application->GetVar('var_value');
+
+ $this->Application->StorePersistentVar($var_name, $var_value);
+
+ $event->status = erSTOP;
+ }
+
+ /**
* Just closes popup & deletes last_template & opener_stack if popup, that is closing
*
* @param kEvent $event
*/
function OnClosePopup(&$event)
{
$event->SetRedirectParam('opener', 'u');
}
/**
* Occurs right after initialization of the kernel, used mainly as hook-to event
*
* @param kEvent $event
*/
function OnStartup(&$event)
{
}
/**
* Is called after tree was build (when not from cache)
*
* @param kEvent $event
*/
function OnAfterBuildTree(&$event)
{
}
}
\ No newline at end of file
Property changes on: branches/RC/core/units/admin/admin_events_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8.2.1
\ No newline at end of property
+1.8.2.2
\ No newline at end of property
Index: branches/RC/core/admin_templates/js/frame_resizer.js
===================================================================
--- branches/RC/core/admin_templates/js/frame_resizer.js (revision 9238)
+++ branches/RC/core/admin_templates/js/frame_resizer.js (revision 9239)
@@ -1,39 +1,60 @@
-function FrameResizer($show_title, $hide_title, $frameset) {
+function FrameResizer($show_title, $hide_title, $frameset, $save_url) {
this.StatusIcon = {0: 'img/list_arrow_desc.gif', 1 : 'img/list_arrow_no.gif'};
this.StatusText = {0: $hide_title, 1 : $show_title};
- this.StatusImage = document.getElementById('menu_toggle');
+ this.StatusImage = document.getElementById('menu_toggle_img');
+ this.StatusLink = document.getElementById('menu_toggle_link');
this.Frameset = $frameset;
-
+ this.SaveURL = $save_url;
+
this.SubFrameset = $frameset.document.getElementById('sub_frameset');
this.TopFrameset = $frameset.document.getElementById('top_frameset');
}
FrameResizer.prototype.InitControls = function ($instance) {
- this.StatusImage.onclick = function () {
+ this.StatusLink.onclick = function () {
$instance.FrameToggle();
+ return false;
}
}
FrameResizer.prototype.MenuVisible = function () {
return new RegExp('(.*)' + this.StatusIcon[0] + '$').exec(this.StatusImage.src);
}
FrameResizer.prototype.SetStatus = function ($status) {
this.StatusImage.src = this.StatusIcon[$status];
- this.StatusImage.alt = this.StatusText[$status];
- this.StatusImage.title = this.StatusText[$status];
+ this.StatusImage.alt = this.StatusLink.title = this.StatusText[$status];
document.getElementById('site_logo').style.display = $status ? 'none' : 'block';
+
+ // save via ajax
+ var $url = this.SaveURL.replace('#NAME#', 'ShowAdminMenu').replace('#VALUE#', $status);
+ Request.makeRequest($url, false, '', this.successCallback, this.errorCallback, '', this);
+}
+
+FrameResizer.prototype.successCallback = function($request, $params, $object) {
+ /*var $responce = $request.responseText;
+ var $match_redirect = new RegExp('^#redirect#(.*)').exec($responce);
+ if ($match_redirect != null) {
+ $object.showProgress(100);
+ // redirect to external template requested
+ window.location.href = $match_redirect[1];
+ return false;
+ }*/
+}
+
+FrameResizer.prototype.errorCallback = function($request, $params, $object) {
+ alert('AJAX Error; class: FrameResizer; ' + Request.getErrorHtml($request));
}
FrameResizer.prototype.FrameToggle = function () {
if (this.MenuVisible()) {
this.TopFrameset.setAttribute('rows', '25,*');
this.SubFrameset.setAttribute('cols', '0,*');
this.SetStatus(1);
}
else {
this.TopFrameset.setAttribute('rows', this.Frameset.$top_height + ',*');
this.SubFrameset.setAttribute('cols', '200,*');
this.SetStatus(0);
}
}
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/js/frame_resizer.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.4.1
\ No newline at end of property
+1.1.4.2
\ No newline at end of property
Index: branches/RC/core/admin_templates/index.tpl
===================================================================
--- branches/RC/core/admin_templates/index.tpl (revision 9238)
+++ branches/RC/core/admin_templates/index.tpl (revision 9239)
@@ -1,42 +1,47 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<inp2:m_CheckSSL mode="required" condition="Require_AdminSSL" />
<inp2:m_CheckSSL/>
<inp2:m_RequireLogin login_template="login"/>
<inp2:m_Set skip_last_template="1"/>
<inp2:m_NoDebug/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<inp2:lang_GetCharset/>">
<title><inp2:m_GetConfig var="Site_Name"/> - <inp2:m_Phrase label="la_AdministrativeConsole"/></title>
<inp2:m_base_ref/>
<link rel="icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" rev="stylesheet" href="incs/style.css" type="text/css" />
<script type="text/javascript">
window.name = 'main_frame';
+
var $top_height = 94;
if (navigator.appName == 'Netscape') {
$top_height = navigator.appVersion.substring(0, 1) != '5' ? 96 : 95;
}
- document.write('<frameset id="top_frameset" rows="' + $top_height + ',*" framespacing="0" scrolling="no" frameborder="0">');
+ <inp2:m_if check="m_RecallEquals" name="ShowAdminMenu" value="0" persistent="1">
+ document.write('<frameset id="top_frameset" rows="' + $top_height + ',*" framespacing="0" scrolling="no" frameborder="0">');
+ <inp2:m_else/>
+ document.write('<frameset id="top_frameset" rows="25,*" framespacing="0" scrolling="no" frameborder="0">');
+ </inp2:m_if>
</script>
</head>
<frame src="<inp2:m_t t="head" pass="m" m_cat_id="0" m_opener="s" no_pass_through="1"/>" name="head" scrolling="no" noresize="noresize">
- <frameset id="sub_frameset" cols="200,*" border="0">
+ <frameset id="sub_frameset" cols="<inp2:m_if check="m_RecallEquals" name="ShowAdminMenu" value="0" persistent="1">200<inp2:m_else/>0</inp2:m_if>,*" border="0">
<frame src="<inp2:m_t t="tree" pass="m" m_cat_id="0" m_opener="s" no_pass_through="1"/>" name="menu" target="main" noresize scrolling="auto" marginwidth="0" marginheight="0">
<inp2:m_DefineElement name="root_node">
<frame src="<inp2:m_if check="adm_MainFrameLink"><inp2:adm_MainFrameLink/><inp2:m_else/><inp2:m_param name="section_url"/></inp2:m_if>" name="main" marginwidth="0" marginheight="0" frameborder="no" noresize scrolling="auto">
</inp2:m_DefineElement>
<inp2:adm_PrintSection render_as="root_node" section_name="in-portal:root"/>
</frameset>
</frameset>
<noframes>
<body bgcolor="#FFFFFF">
<p></p>
</body>
</noframes>
</html>
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/index.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7.2.1
\ No newline at end of property
+1.7.2.2
\ No newline at end of property

Event Timeline