Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, Jun 24, 11:28 PM

in-portal

Index: branches/unlabeled/unlabeled-1.10.2/kernel/units/selectors/selectors_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/kernel/units/selectors/selectors_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/kernel/units/selectors/selectors_event_handler.php (revision 5297)
@@ -0,0 +1,370 @@
+<?php
+
+safeDefine('STYLE_BASE', 1);
+safeDefine('STYLE_BLOCK', 2);
+
+ class SelectorsEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnResetToBase' => Array('subitem' => 'add|edit'),
+ 'OnMassResetToBase' => Array('subitem' => 'add|edit'),
+
+ 'OnOpenStyleEditor' => Array('subitem' => 'add|edit'),
+ 'OnSaveStyle' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Occures before an item has been cloned
+ * Id of newly created item is passed as event' 'id' param
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeClone(&$event)
+ {
+ $event->Init($event->Prefix, '-item');
+ $object =& $event->getObject();
+
+ $title_field = 'SelectorName';
+ $new_name = $object->GetDBField($title_field);
+ $original_checked = false;
+
+ $foreign_key = $event->getEventParam('foreign_key'); // in case if whole stylesheet is cloned
+ if($foreign_key === false) $foreign_key = $object->GetDBField('StylesheetId'); // in case if selector is copied ifself
+
+ do {
+ if ( preg_match('/(.*)-([\d]+)/', $new_name, $regs) ) {
+ $new_name = $regs[1].'-'.($regs[2]+1);
+ }
+ elseif ($original_checked) {
+ $new_name = $new_name.'-1';
+ }
+
+ // if we are cloning in temp table this will look for names in temp table,
+ // since object' TableName contains correct TableName (for temp also!)
+ // if we are cloning live - look in live
+ $query = ' SELECT '.$title_field.'
+ FROM '.$object->TableName.'
+ WHERE '.$title_field.' = '.$this->Conn->qstr($new_name).' AND StylesheetId = '.$foreign_key;
+
+ $res = $this->Conn->GetOne($query);
+
+ /*// if not found in live table, check in temp table if applicable
+ if ($res === false && $object->Special == 'temp') {
+ $query = 'SELECT '.$name_field.' FROM '.$this->GetTempName($master['TableName']).'
+ WHERE '.$name_field.' = '.$this->Conn->qstr($new_name);
+ $res = $this->Conn->GetOne($query);
+ }*/
+
+ $original_checked = true;
+ } while ($res !== false);
+ $object->SetDBField($title_field, $new_name);
+ }
+
+ /**
+ * Show base styles or block styles
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ $object =& $event->getObject();
+ switch ($event->Special)
+ {
+ case 'base':
+ $object->addFilter('type_filter', '%1$s.Type = 1');
+ break;
+
+ case 'block':
+ $object->addFilter('type_filter', '%1$s.Type = 2');
+ break;
+ }
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemUpdate(&$event)
+ {
+ $this->SerializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ $this->SerializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemUpdate(&$event)
+ {
+ $this->UnserializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemCreate(&$event)
+ {
+ $this->UnserializeSelectorData($event);
+ }
+
+ /**
+ * Get's special of main item for linking with subitem
+ *
+ * @param kEvent $event
+ * @return string
+ */
+ function getMainSpecial(&$event)
+ {
+ return '';
+ }
+
+ /**
+ * Save css-style name & description before opening css editor
+ *
+ * @param kEvent $event
+ */
+ function OnOpenStyleEditor(&$event)
+ {
+ $this->SaveChanges($event);
+ $event->redirect = false;
+ }
+
+ /**
+ * Saves Changes to Item
+ *
+ * @param kEvent $event
+ */
+ function SaveChanges(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if($items_info)
+ {
+ list($id,$field_values) = each($items_info);
+ if($id == 0)
+ {
+ $parent_id = getArrayValue($field_values,'ParentId');
+ if($parent_id) $object->Load($parent_id);
+
+ $object->SetFieldsFromHash($field_values);
+ $object->Create();
+ if( $object->IsTempTable() ) $object->setTempID();
+ $this->Application->SetVar($event->getPrefixSpecial().'_id', $object->GetID() );
+ }
+ else
+ {
+ $object->Load($id);
+ $object->SetFieldsFromHash($field_values);
+ $object->Update();
+ }
+ }
+ }
+
+ /**
+ * Save style changes from style editor
+ *
+ * @param kEvent $event
+ */
+ function OnSaveStyle(&$event)
+ {
+ $this->SaveChanges($event);
+
+ $object =& $event->getObject();
+ $this->Application->SetVar($event->getPrefixSpecial().'_id', $object->GetId() );
+
+ $this->finalizePopup($event);
+ }
+
+ /**
+ * Extract styles
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemLoad(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if($selector_data)
+ {
+ $selector_data = unserialize($selector_data);
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+ else
+ {
+ $selector_data = Array();
+ }
+ $this->AddParentProperties($event, $selector_data);
+ }
+
+ /**
+ * Serialize item before saving to db
+ *
+ * @param kEvent $event
+ */
+ function SerializeSelectorData(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if(!$selector_data) $selector_data = Array();
+
+ $selector_data = $this->RemoveParentProperties($event, $selector_data);
+
+ if( !IsSerialized($selector_data) ) $selector_data = serialize($selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+
+ /**
+ * Unserialize data back when update was made
+ *
+ * @param kEvent $event
+ */
+ function UnserializeSelectorData(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if(!$selector_data) $selector_data = Array();
+ if( IsSerialized($selector_data) ) $selector_data = unserialize($selector_data);
+
+ $selector_data = $this->AddParentProperties($event, $selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+
+ /**
+ * Populate options based on temporary table :)
+ *
+ * @param kEvent $event
+ */
+ function OnPrepareBaseStyles(&$event)
+ {
+ $object =& $event->getObject();
+
+ $parent_info = $object->getLinkedInfo();
+ $title_field = $this->Application->getUnitOption($event->Prefix,'TitleField');
+ $sql = 'SELECT '.$title_field.', '.$object->IDField.' FROM '.$object->TableName.' WHERE Type = 1 AND StylesheetId = '.$parent_info['ParentId'].' ORDER BY '.$title_field;
+ $object->Fields['ParentId']['options'] = $this->Conn->GetCol($sql,$object->IDField);
+ }
+
+ /**
+ * Remove properties of parent style that match by value from style
+ *
+ * @param kEvent $event
+ */
+ function RemoveParentProperties(&$event, $selector_data)
+ {
+ $object =& $event->getObject();
+ $parent_id = $object->GetDBField('ParentId');
+ if($parent_id)
+ {
+ $sql = 'SELECT SelectorData FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.$parent_id;
+ $base_selector_data = $this->Conn->GetOne($sql);
+
+ if( IsSerialized($base_selector_data) ) $base_selector_data = unserialize($base_selector_data);
+
+ foreach($selector_data as $prop_name => $prop_value)
+ {
+ if( !$prop_value || getArrayValue($base_selector_data,$prop_name) == $prop_value )
+ {
+ unset($selector_data[$prop_name]);
+ }
+ }
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ else
+ {
+ foreach($selector_data as $prop_name => $prop_value)
+ {
+ if(!$prop_value) unset($selector_data[$prop_name]);
+ }
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ }
+
+ /**
+ * Add back properties from parent style, that match this style property values
+ *
+ * @param kEvent $event
+ */
+ function AddParentProperties(&$event, $selector_data)
+ {
+ $object =& $event->getObject();
+ $parent_id = $object->GetDBField('ParentId');
+ if($parent_id)
+ {
+ $sql = 'SELECT SelectorData FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.$parent_id;
+ $base_selector_data = $this->Conn->GetOne($sql);
+
+ if( IsSerialized($base_selector_data) ) $base_selector_data = unserialize($base_selector_data);
+
+ $selector_data = array_merge_recursive2($base_selector_data,$selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ return $selector_data;
+ }
+
+ /**
+ * Reset Style definition to base style -> no customizations
+ *
+ * @param kEvent $event
+ */
+ function OnResetToBase(&$event)
+ {
+ $object =& $event->getObject();
+ $object->SetFieldsFromHash( $this->getSubmittedFields($event) );
+ $object->ResetStyle();
+
+ $event->redirect_params['pass'] = 'all,'.$event->getPrefixSpecial();
+ }
+
+ /**
+ * Resets selected styles properties to values of their base classes
+ *
+ * @param kEvent $event
+ */
+ function OnMassResetToBase(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if($items_info)
+ {
+ foreach($items_info as $id => $field_values)
+ {
+ $object->Load($id);
+ $object->ResetStyle();
+ }
+ }
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/kernel/units/selectors/selectors_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/regional/languages_edit.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/regional/languages_edit.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/regional/languages_edit.tpl (revision 5297)
@@ -0,0 +1,101 @@
+<inp2:m_RequireLogin permissions="in-portal:configure_lang.view" system="1"/>
+<inp2:m_include t="incs/header" nobody="yes"/>
+
+<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
+<inp2:m_ParseBlock name="section_header" icon="icon46_conf_regional" title="!la_title_LanguagePacks!"/>
+
+<inp2:m_include t="regional/languages_edit_tabs"/>
+
+<inp2:m_ParseBlock name="blue_bar" prefix="lang" title_preset="languages_edit_general" module="in-portal" icon="icon46_conf_regional"/>
+
+<!-- ToolBar --->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('lang','<inp2:lang_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ submit_event('lang','OnCancelEdit');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('lang', '<inp2:lang_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('lang', '<inp2:lang_NextId/>');
+ }
+ ) );
+
+
+
+ a_toolbar.Render();
+
+ <inp2:m_if prefix="lang" function="IsSingle"/>
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if prefix="lang" function="IsLast"/>
+ a_toolbar.DisableButton('next');
+ <inp2:m_endif/>
+ <inp2:m_if prefix="lang" function="IsFirst"/>
+ a_toolbar.DisableButton('prev');
+ <inp2:m_endif/>
+ <inp2:m_endif/>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:lang_SaveWarning name="grid_save_warning"/>
+<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
+ <inp2:m_ParseBlock name="subsection" title="!la_section_General!"/>
+ <inp2:m_ParseBlock name="inp_id_label" prefix="lang" field="LanguageId" title="!la_fld_LanguageId!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="PackName" title="!la_fld_PackName!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="LocalName" title="!la_fld_LocalName!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="Charset" title="!la_fld_Charset!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="IconURL" title="!la_fld_IconURL!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="DateFormat" title="!la_fld_DateFormat!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="TimeFormat" title="!la_fld_TimeFormat!"/>
+
+ <inp2:m_ParseBlock name="inp_edit_options" prefix="lang" field="InputDateFormat" title="!la_fld_InputDateFormat!"/>
+ <inp2:m_ParseBlock name="inp_edit_options" prefix="lang" field="InputTimeFormat" title="!la_fld_InputTimeFormat!"/>
+
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="DecimalPoint" title="!la_fld_DecimalPoint!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="lang" field="ThousandSep" title="!la_fld_ThousandSep!"/>
+ <inp2:m_ParseBlock name="inp_edit_checkbox" prefix="lang" field="PrimaryLang" title="!la_fld_PrimaryLang!"/>
+ <inp2:m_ParseBlock name="inp_edit_checkbox" prefix="lang" field="Enabled" title="!la_fld_Enabled!"/>
+ <inp2:m_ParseBlock name="inp_edit_options" prefix="lang" field="UnitSystem" title="!la_fld_UnitSystem!" use_phrases="1"/>
+ <inp2:m_if check="lang_IsNewMode">
+ <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
+ <inp2:m_inc param="tab_index" by="1"/>
+ <td class="text">
+ <inp2:m_phrase name="la_fld_CopyLabels"/>:
+ </td>
+ <td>
+ <input type="hidden" id="<inp2:lang_InputName field="CopyLabels"/>" name="<inp2:lang_InputName field="CopyLabels"/>" value="<inp2:lang_Field field="CopyLabels" db="db"/>">
+ <input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_CopyLabels" name="_cb_CopyLabels" <inp2:lang_Field field="CopyLabels" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:lang_InputName field="CopyLabels"/>'))">
+
+ <inp2:m_inc param="tab_index" by="1"/>
+ <select tabindex="<inp2:m_get param="tab_index"/>" name="<inp2:lang_InputName field="CopyFromLanguage"/>" id="<inp2:lang_InputName field="CopyFromLanguage"/>">
+ <option value="0">--<inp2:m_phrase name="la_prompt_Select_Source"/></option>
+ <inp2:lang_PredefinedOptions field="CopyFromLanguage" block="inp_option_item" selected="selected"/>
+ </select>
+ </td>
+ <td class="error">&nbsp;</td>
+ </tr>
+ </inp2:m_if>
+</table>
+
+<inp2:m_include t="incs/footer"/>
+
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/regional/languages_edit.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/toolbar.js
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/toolbar.js (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/toolbar.js (revision 5297)
@@ -0,0 +1,231 @@
+function ToolBarButton(title, alt, onclick, $hidden, prefix)
+{
+ this.Title = title || '';
+ this.CheckTitleModule();
+ this.Alt = RemoveTranslationLink(alt || '');
+
+ if (typeof(onclick) == 'function') {
+ this.onClick = onclick;
+ }
+ else {
+ this.onClick = function() {
+ if (eval('typeof('+this.Title+')') == 'function')
+ eval(this.Title + '()');
+ }
+
+ }
+
+ this.imgObject = null;
+ this.Enabled = true;
+ this.Hidden = $hidden ? true : false;
+ this.ToolBar = null;
+ this.Prefix = prefix ? prefix : '';
+}
+
+ToolBarButton.prototype.CheckTitleModule = function()
+{
+ if (this.Title.match(/([^:]+):(.*)$/)) {
+ // has module set directly
+ this.Title = RegExp.$2;
+ this.Module = RegExp.$1;
+ }
+ else {
+ // use default module
+ this.Module = 'kernel';
+ }
+}
+
+ToolBarButton.prototype.IconsPath = function()
+{
+ if (typeof(img_path) == 'undefined') {
+ alert('error: toolbar image path not set');
+ }
+ return img_path.replace('#MODULE#', this.Module) + 'toolbar/';
+}
+
+ToolBarButton.prototype.GetHTML = function() {
+ return '<img id="' + this.GetToolID() + '" src="' + this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '.gif" title="' + this.Alt + '">';
+}
+
+ToolBarButton.prototype.GetToolID = function() {
+ return this.Prefix == '' ? 'tool_' + this.Title : 'tool_['+this.Prefix+'][' + this.Title+']'
+}
+
+ToolBarButton.prototype.Init = function() {
+
+ img = document.getElementById(this.GetToolID());
+ this.imgObject = img;
+ img.btn = this;
+ this.SetOnMouseOver();
+ this.SetOnMouseOut();
+ this.SetOnClick();
+ if (this.Hidden) this.Hide();
+}
+
+ToolBarButton.prototype.SetOnMouseOver = function() {
+ this.imgObject.onmouseover = function() {
+ this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '_f2.gif';
+ };
+}
+
+ToolBarButton.prototype.SetOnMouseOut = function() {
+ this.imgObject.onmouseout = function() {
+ this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif';
+ };
+}
+
+ToolBarButton.prototype.SetOnClick = function() {
+ this.imgObject.onmouseout = function() {
+ this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif';
+ };
+ this.imgObject.inClick = false;
+ if (typeof(this.onClick) != 'function') {
+ this.imgObject.onclick = function() {
+ if (this.inClick) return;
+ this.inClick = true;
+ if (eval('typeof('+this.btn.Title+')') == 'function')
+ eval(this.btn.Title + '()');
+ this.inClick = false;
+ }
+ }
+ else {
+ this.imgObject.onclick = function() {
+ if (this.inClick) return;
+ this.inClick = true;
+ this.btn.onClick();
+ this.inClick = false;
+ }
+ }
+
+ // the following lines are correct, as long as mozilla understands 'pointer', but IE 'hand',
+ // do not change the order of these lines!
+ if (is.ie6up || is.gecko) {
+ this.imgObject.style.cursor = 'pointer';
+ }
+ else {
+ // somehow set cursor hand for IE 5/ 5.5
+// this.imgObject.style = 'cursor: hand';
+ }
+}
+
+ToolBarButton.prototype.Disable = function() {
+ if ( !this.Enabled ) return;
+ this.imgObject.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '_f3.gif';
+ this.imgObject.onmouseover = null;
+ this.imgObject.onmouseout = null;
+ this.imgObject.onclick = null;
+ this.imgObject.style.cursor = 'default';
+ this.Enabled = false;
+}
+
+ToolBarButton.prototype.Enable = function() {
+ if (this.Enabled) return;
+ this.imgObject.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '.gif';
+ this.SetOnMouseOver();
+ this.SetOnMouseOut();
+ this.SetOnClick();
+ this.Enabled = true;
+}
+
+ToolBarButton.prototype.Hide = function() {
+ this.imgObject.style.display = 'none';
+ this.Hidden = true;
+}
+
+ToolBarButton.prototype.Show = function() {
+ this.imgObject.style.display = '';
+ this.Hidden = false;
+}
+
+/* ----------- */
+
+function ToolBarSeparator(title) //extends ToolBarButton
+{
+ this.Title = title;
+}
+ToolBarSeparator.prototype = new ToolBarButton;
+
+ToolBarSeparator.prototype.GetHTML = function() {
+ return '<img id="' + this.GetToolID() + '" src="' + this.IconsPath() + 'tool_divider.gif">';
+}
+
+ToolBarSeparator.prototype.Init = function() {
+ img = document.getElementById(this.ToolBar.IconPrefix + this.Title);
+ this.imgObject = img;
+ img.btn = this;
+}
+
+ToolBarSeparator.prototype.Enable = function() { }
+ToolBarSeparator.prototype.Disable = function() { }
+
+/* ----------- */
+
+
+function ToolBar(icon_prefix, $module)
+{
+ this.Module = $module ? $module : 'kernel';
+ this.IconPrefix = icon_prefix ? icon_prefix : 'tool_';
+ this.Buttons = new Array();
+}
+
+ToolBar.prototype.AddButton = function(a_button)
+{
+ a_button.ToolBar = this;
+ this.Buttons[a_button.Title] = a_button;
+}
+
+ToolBar.prototype.Render = function($container)
+{
+ if ($container) {
+ $container.innerHTML = ''; // container will contain only buttons
+ for (var i in this.Buttons) {
+ btn = this.Buttons[i];
+ $container.innerHTML += btn.GetHTML();
+ }
+
+ // init all buttons after because objects are not yet created directly after assigning to innerHTML
+ for (var i in this.Buttons) {
+ btn = this.Buttons[i];
+ btn.Init();
+ }
+ }
+ else {
+ for (var i in this.Buttons) {
+ btn = this.Buttons[i];
+ document.write( btn.GetHTML() );
+ btn.Init();
+ }
+ }
+}
+
+ToolBar.prototype.EnableButton = function(button_id) {
+ if(this.ButtonExists(button_id)) this.Buttons[button_id].Enable();
+}
+
+ToolBar.prototype.DisableButton = function(button_id) {
+ if(this.ButtonExists(button_id)) this.Buttons[button_id].Disable();
+}
+
+ToolBar.prototype.HideButton = function(button_id) {
+ if(this.ButtonExists(button_id)) this.Buttons[button_id].Hide();
+}
+
+ToolBar.prototype.ShowButton = function(button_id) {
+ if(this.ButtonExists(button_id)) this.Buttons[button_id].Show();
+}
+
+ToolBar.prototype.SetEnabled = function(button_id, $enabled) {
+ var $ret = $enabled ? this.EnableButton(button_id) : this.DisableButton(button_id);
+}
+
+ToolBar.prototype.SetVisible = function(button_id, $visible) {
+ var $ret = $visible ? this.ShowButton(button_id) : this.HideButton(button_id);
+}
+
+ToolBar.prototype.GetButtonImage = function(button_id) {
+ if( this.ButtonExists(button_id) ) return this.Buttons[button_id].imgObject;
+}
+
+ToolBar.prototype.ButtonExists = function(button_id) {
+ return typeof(this.Buttons[button_id]) == 'object';
+}
Property changes on: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/toolbar.js
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/tree.js
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/tree.js (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/tree.js (revision 5297)
@@ -0,0 +1,385 @@
+function TreeItem(title, url, icon, onclick)
+{
+ this.Title = title;
+ this.Url = url;
+ this.Rendered = false;
+ this.Displayed = false;
+ this.Level = 0;
+ this.Icon = icon;
+ this.Onclick = onclick;
+}
+
+TreeItem.prototype.Render = function(before)
+{
+ if (!this.Rendered) {
+ if (!isset(before)) {before = null}
+
+ tr = document.createElement('tr');
+ this.ParentElement.insertBefore(tr, before);
+ if (!this.Displayed) { tr.style.display = 'none' }
+ td = document.createElement('td');
+ td.TreeElement = this;
+ tr.appendChild(td);
+
+ this.appendLevel(td);
+ if (this.ParentFolder != null) this.appendNodeImage(td);
+ this.appendIcon(td);
+ this.appendLink(td);
+
+ this.Tr = tr;
+ this.Rendered = true;
+// alert(this.Tr.innerHTML)
+ }
+}
+
+TreeItem.prototype.appendLevel = function(td)
+{
+ for (var i=0; i < this.Level; i++)
+ {
+ img = document.createElement('img');
+ img.src = TREE_ICONS_PATH+'/ftv2blank.gif';
+ img.style.verticalAlign = 'middle';
+ td.appendChild(img);
+ }
+}
+
+TreeItem.prototype.getNodeImage = function(is_last)
+{
+ return is_last ? TREE_ICONS_PATH+'/ftv2lastnode.gif' : TREE_ICONS_PATH+'/ftv2node.gif';
+}
+
+TreeItem.prototype.appendNodeImage = function(td)
+{
+ img = document.createElement('img');
+ img.src = this.getNodeImage();
+ img.style.verticalAlign = 'middle';
+ td.appendChild(img);
+}
+
+TreeItem.prototype.appendIcon = function (td)
+{
+ img = document.createElement('img');
+ if (this.Icon.indexOf('http://') != -1) {
+ img.src = this.Icon;
+ }
+ else {
+ img.src = this.Icon;
+ }
+ img.style.verticalAlign = 'middle';
+ td.appendChild(img);
+}
+
+TreeItem.prototype.appendLink = function (td)
+{
+ link = document.createElement('a');
+ link.nodeValue = this.Title;
+ link.href = this.Url;
+ link.target = 'main';
+ link.appendChild( document.createTextNode(this.Title) )
+
+ link.treeItem = this;
+ //addEvent(link, 'click',
+
+ link.onclick =
+ function(ev) {
+ var e = is.ie ? window.event : ev;
+
+ res = true;
+ if (isset(this.treeItem.Onclick)) {
+ res = eval(this.treeItem.Onclick);
+ }
+ if (!res) { // if we need to cancel onclick action
+ if (is.ie) {
+ window.event.cancelBubble = true;
+ window.event.returnValue = false;
+ } else {
+ ev.preventDefault();
+ ev.stopPropagation();
+ }
+ return res;
+ }
+ else {
+ // ensures, that click is made before AJAX request will be sent
+ if (res === true) {
+ // only in case of "true" is returned, used in catalog
+ window.parent.getFrame(link.target).location.href = this.href;
+ }
+
+ if (!this.treeItem.Expanded && typeof(this.treeItem.folderClick) == 'function') {
+ if (this.treeItem.folderClick());
+ }
+ return false;
+ }
+ }
+
+ td.appendChild(link);
+}
+
+TreeItem.prototype.display = function()
+{
+ this.Tr.style.display = is.ie ? 'block' : 'table-row';
+ this.Displayed = true;
+}
+
+TreeItem.prototype.hide = function()
+{
+ this.Tr.style.display = 'none';
+ this.Displayed = false;
+}
+
+TreeItem.prototype.expand = function() { this.display() }
+
+TreeItem.prototype.collapse = function() { this.hide() }
+
+TreeItem.prototype.updateLastNodes = function(is_last, lines_pattern)
+{
+ if (!isset(is_last)) is_last = true;
+ if (!isset(this.Tr)) return;
+ if (!isset(lines_pattern)) { var lines_pattern = new Array() }
+
+ imgs = this.Tr.getElementsByTagName('img');
+ found = false;
+ for (var i=0; i<imgs.length; i++)
+ {
+ the_img = imgs.item(i);
+ if (in_array(i, lines_pattern) && the_img.src.indexOf('ftv2blank.gif') != -1) {
+ the_img.src = TREE_ICONS_PATH+'/ftv2vertline.gif';
+ }
+ if (this.isNodeImage(the_img))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ the_img.src = this.getNodeImage(is_last);
+ }
+ this.isLast = is_last;
+ return lines_pattern;
+}
+
+TreeItem.prototype.isNodeImage = function(img)
+{
+ return (
+ img.src.indexOf('ftv2node.gif') != -1 ||
+ img.src.indexOf('ftv2lastnode.gif') != -1
+ )
+
+}
+
+TreeItem.prototype.locateLastItem = function()
+{
+ return this;
+}
+/* FOLDER */
+
+function TreeFolder(parent_id, title, url, icon, late_load_url, onclick)
+{
+ var render = false;
+ if (isset(parent_id)) {
+ this.ParentElement = document.getElementById(parent_id);
+ render = true;
+ }
+
+ this.Title = title;
+ this.Url = url;
+ this.Rendered = false;
+ this.Displayed = false;
+ this.Expanded = false;
+ this.Level = 0;
+ this.Tr = null;
+ this.Icon = icon;
+ this.LateLoadURL = isset(late_load_url) ? late_load_url : false;
+ this.Loaded = false;
+ this.Onclick = onclick;
+
+ this.Children = new Array();
+ this.ChildIndex = 0;
+ if (render) {
+ this.Expanded = true;
+ this.Displayed = true;
+ this.Render();
+ this.expand();
+ }
+}
+
+TreeFolder.prototype = new TreeItem;
+
+TreeFolder.prototype.locateLastItem = function()
+{
+ if (this.Children.length == 0) return this;
+
+ for (var i=0; i<this.Children.length; i++)
+ {
+ last_item = this.Children[i].locateLastItem()
+ }
+ return last_item;
+}
+
+TreeFolder.prototype.locateTopItem = function()
+{
+ if (this.ParentFolder == null) return this;
+ return this.ParentFolder.locateTopItem();
+}
+
+TreeFolder.prototype.AddItem = function(an_item, render, display) {
+ an_item.ParentElement = this.ParentElement;
+ an_item.Level = this.ParentFolder != null ? this.Level + 1 : 0;
+ an_item.ParentFolder = this;
+
+ last_item = this.locateLastItem();
+ this.Children.push(an_item);
+ an_item.Render(last_item.Tr.nextSibling);
+ if (this.Expanded)
+ {
+ an_item.display();
+ }
+ return an_item;
+}
+
+TreeFolder.prototype.AddFromXML = function(xml, render)
+{
+// start = new Date();
+ if (!isset(render)) render = true;
+ doc = getDocumentFromXML(xml);
+ this.LastFolder = this;
+ this.ProcessXMLNode(doc, render);
+// end = new Date();
+ this.locateTopItem().updateLastNodes();
+// alert('AddFromXML took: '+(end - start))
+}
+
+TreeFolder.prototype.ProcessXMLNode = function(node, render)
+{
+ if (!isset(render)) render = true;
+ if (!isset(this.LastFolder)) this.LastFolder = this;
+ for (var i=0; i<node.childNodes.length; i++)
+ {
+ child = node.childNodes.item(i);
+ if (child.tagName == 'folder') {
+ var backupLastFolder = this.LastFolder;
+ this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url'), child.getAttribute('onclick')), render);
+ if (child.hasChildNodes) {
+ this.ProcessXMLNode(child);
+ }
+ this.LastFolder = backupLastFolder;
+ }
+ else if (child.tagName == 'item') {
+ this.LastFolder.AddItem(new TreeItem(child.firstChild.nodeValue, child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('onclick')), render)
+ }
+ else if (child.tagName == 'tree') {
+ this.LastFolder = this;
+ this.ProcessXMLNode(child);
+ }
+ }
+}
+
+TreeFolder.prototype.getNodeImage = function(is_last)
+{
+ if (is_last) {
+ return this.Expanded ? TREE_ICONS_PATH+'/ftv2mlastnode.gif' : TREE_ICONS_PATH+'/ftv2plastnode.gif';
+ }
+ else {
+ return this.Expanded ? TREE_ICONS_PATH+'/ftv2mnode.gif' : TREE_ICONS_PATH+'/ftv2pnode.gif';
+ }
+}
+
+TreeFolder.prototype.appendNodeImage = function(td, is_last)
+{
+ img = document.createElement('img');
+ img.src = this.getNodeImage(is_last);
+ img.style.cursor = 'hand';
+ img.style.cursor = 'pointer';
+ img.style.verticalAlign = 'middle';
+ img.onclick = function() { this.parentNode.TreeElement.folderClick(this) }
+ this.Img = img;
+ td.appendChild(img);
+}
+
+TreeFolder.prototype.updateLastNodes = function(is_last, lines_pattern)
+{
+ if (!isset(is_last)) is_last = true;
+ if (!isset(lines_pattern)) { var lines_pattern = new Array() }
+ if (!is_last && !in_array(this.Level, lines_pattern)) { lines_pattern.push(this.Level) }
+
+ lines_pattern = TreeItem.prototype.updateLastNodes.apply(this, new Array(is_last, lines_pattern))
+
+ for (var i=0; i<this.Children.length; i++)
+ {
+ lines_pattern = this.Children[i].updateLastNodes((i+1) == this.Children.length, lines_pattern)
+ }
+ lines_pattern[array_search(this.Level, lines_pattern)] = -1;
+ return lines_pattern;
+}
+
+TreeFolder.prototype.isNodeImage = function(img)
+{
+ return (
+ img.src.indexOf('ftv2mlastnode.gif') != -1 ||
+ img.src.indexOf('ftv2plastnode.gif') != -1 ||
+ img.src.indexOf('ftv2mnode.gif') != -1 ||
+ img.src.indexOf('ftv2pnode.gif') != -1
+ )
+
+}
+
+TreeFolder.prototype.folderClick = function(img)
+{
+ if (this.LateLoadURL && !this.Loaded) {
+ Request.headers['Content-type'] = 'text/xml';
+ Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, '', this);
+ }
+
+ if (this.Expanded) {
+ this.collapse();
+ }
+ else {
+ this.expand();
+ }
+}
+
+TreeFolder.prototype.successCallback = function ($request, $params, $object) {
+ $object.ProcessXMLNode($request.responseXML);
+ $object.Loaded = true;
+ $object.Render();
+ $object.locateTopItem().updateLastNodes();
+ $object.expand();
+}
+
+TreeFolder.prototype.errorCallback = function($request, $params, $object) {
+ alert('AJAX ERROR: ' + Request.getErrorHtml($request));
+}
+
+TreeFolder.prototype.expand = function(mode)
+{
+ if (!isset(mode)) mode = 0;
+ this.display();
+ if (mode == 0 || this.Expanded ) {
+ for (var i=0; i<this.Children.length; i++)
+ {
+ this.Children[i].expand(mode+1);
+ }
+ }
+ if (mode == 0) {
+ this.Expanded = true;
+ if (isset(this.Img)) {
+ this.Img.src = this.getNodeImage(this.isLast);
+ }
+ }
+}
+
+TreeFolder.prototype.collapse = function(mode)
+{
+ if (!isset(mode)) mode = 0;
+ for (var i=0; i<this.Children.length; i++)
+ {
+ this.Children[i].collapse(mode+1);
+ this.Children[i].hide();
+ }
+ if (mode == 0) {
+ this.Expanded = false;
+ if (isset(this.Img)) {
+ this.Img.src = this.getNodeImage(this.isLast);
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/kernel/admin_templates/incs/tree.js
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/admin/editor/cmseditor/editor/filemanager/browser/default/frmupload.html
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/admin/editor/cmseditor/editor/filemanager/browser/default/frmupload.html (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/admin/editor/cmseditor/editor/filemanager/browser/default/frmupload.html (revision 5297)
@@ -0,0 +1,161 @@
+<!--
+ * FCKeditor - The text editor for internet
+ * Copyright (C) 2003-2004 Frederico Caldeira Knabben
+ *
+ * Licensed under the terms of the GNU Lesser General Public License:
+ * http://www.opensource.org/licenses/lgpl-license.php
+ *
+ * For further information visit:
+ * http://www.fckeditor.net/
+ *
+ * File Name: frmupload.html
+ * Page used to upload new files in the current folder.
+ *
+ * Version: 2.0 RC3
+ * Modified: 2004-11-29 16:04:32
+ *
+ * File Authors:
+ * Frederico Caldeira Knabben (fredck@fckeditor.net)
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <link href="Browser.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="js/common.js"></script>
+ <script language="javascript">
+
+function SetCurrentFolder( resourceType, folderPath )
+{
+ var sUrl = oConnector.ConnectorUrl +'Command=FileUpload' ;
+ sUrl += '&Type=' + resourceType ;
+ sUrl += '&CurrentFolder=' + folderPath ;
+
+ document.getElementById('frmUpload').action = sUrl ;
+}
+
+function OnSubmit()
+{
+ if ( document.getElementById('NewFile').value.length == 0 )
+ {
+ alert( 'Please select a file from your computer' ) ;
+ return false ;
+ }
+
+ // Set the interface elements.
+ document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder (Upload in progress, please wait...)' ;
+ document.getElementById('btnUpload').disabled = true ;
+
+ return true ;
+}
+
+function outputErrorMsg(errorNumber, fileName) {
+ switch ( errorNumber )
+ {
+ case 0 :
+ window.parent.frames['frmResourcesList'].Refresh() ;
+ break ;
+ case 201 :
+ window.parent.frames['frmResourcesList'].Refresh() ;
+ alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
+ break ;
+ case 202 :
+ alert( 'Invalid file' ) ;
+ break ;
+ case 203 :
+ alert( 'Invalid file type for this foder' ) ;
+ break ;
+ case 204 :
+ alert( 'A file with the same name is already available' ) ;
+ break ;
+ default :
+ alert( 'Error on file upload. Error number: ' + errorNumber ) ;
+ break ;
+ }
+}
+
+function OnUploadCompleted( errorNumber, fileName )
+{
+ // Reset the Upload Worker Frame.
+ window.parent.frames['frmUploadWorker'].location = 'about:blank' ;
+
+ // Reset the upload form (On IE we must do a little trick to avout problems).
+ if ( document.all )
+ document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
+ else
+ document.getElementById('frmUpload').reset() ;
+
+ // Reset the interface elements.
+ document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
+ document.getElementById('btnUpload').disabled = false ;
+ outputErrorMsg(errorNumber, fileName);
+}
+
+window.onload = function()
+{
+ window.top.IsLoadedUpload = true ;
+}
+
+function SetElementVisibility(upload_visibility, del_rename_visibility) {
+ document.getElementById("upload").style.display = upload_visibility;
+ document.getElementById("del_rename").style.display = del_rename_visibility;
+}
+
+function SetButtonAvalability(button_name, avalability) {
+ //alert(button_name+', '+avalability);
+ //document.getElementById(button_name).disabled = !avalability;
+ if (avalability == false) {
+ document.getElementById(button_name).disabled = true;
+ document.getElementById(button_name).style.color = '#666666';
+ }
+ else {
+ document.getElementById(button_name).disabled = false;
+ document.getElementById(button_name).style.color = '#000000';
+ }
+}
+
+function RenameFile()
+{
+ filename = window.parent.frames['frmResourcesList'].GetCheckedFileName('first');
+ f=prompt('Rename file "'+filename+'"?',filename);
+ if (f) {
+ window.parent.frames['frmResourcesList'].RenameFile(filename,f);
+ }
+}
+function DeleteFiles()
+{
+ cnt = window.parent.frames['frmResourcesList'].GetCheckedFileName('cnt');
+ if (cnt > 0) {
+ a = (cnt > 1) ? "Delete "+cnt+" selected files?": "Delete selected file?";
+ if (confirm(a)) {
+ window.parent.frames['frmResourcesList'].DeleteFiles(0);
+ }
+ }
+}
+
+ </script>
+ </head>
+ <body bottomMargin="0" topMargin="0">
+ <form id="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
+ <table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
+ <tr>
+ <td nowrap>
+ <div id="upload">
+ <span id="eUploadMessage">Upload a new file in this folder</span><br>
+ <table cellSpacing="0" cellPadding="0" width="100%" border="0">
+ <tr>
+ <td width="100%"><input id="NewFile" name="NewFile" size="50" type="file"></td>
+ <td nowrap>&nbsp;<input id="btnUpload" type="submit" value="Upload"></td>
+ </tr>
+ </table>
+ </div>
+ <div id="del_rename" style="display : none">
+ <img src="images/s.gif" width="1" height="10" /><br />
+ <button type="button" id="rename" style="color:#000000; font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onClick="RenameFile();">Rename</button>
+ <button type="button" id="delete" style="color:#000000; font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onClick="DeleteFiles();">Delete</button>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </body>
+</html>
Property changes on: branches/unlabeled/unlabeled-1.10.2/admin/editor/cmseditor/editor/filemanager/browser/default/frmupload.html
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/admin/category/permcacheupdate.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/admin/category/permcacheupdate.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/admin/category/permcacheupdate.php (revision 5297)
@@ -0,0 +1,383 @@
+<?php
+class clsRecursionStack
+{
+ var $Stack;
+
+ function clsRecursionStack()
+ {
+ $this->Stack = Array();
+ }
+
+ function Push($values)
+ {
+ array_push($this->Stack, $values);
+ }
+
+ function Pop()
+ {
+ if ($this->Count() > 0) {
+ return array_pop($this->Stack);
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Get()
+ {
+ if ($this->Count() > 0) {
+// return end($this->Stack);
+ return $this->Stack[count($this->Stack)-1];
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Update($values)
+ {
+ $this->Stack[count($this->Stack)-1] = $values;
+ }
+
+ function Count()
+ {
+ return count($this->Stack);
+ }
+}
+
+
+class clsCachedPermissions
+{
+ var $Allow = Array();
+ var $Deny = Array();
+ var $CatId;
+
+ function clsCachedPermissions($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function SetCatId($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function CheckPermArray($Perm)
+ {
+ if (!isset($this->Allow[$Perm])) {
+ $this->Allow[$Perm] = array();
+ $this->Deny[$Perm] = array();
+ }
+ }
+
+ function AddAllow($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Allow[$Perm])) {
+ array_push($this->Allow[$Perm], $GroupId);
+ $this->RemoveDeny($Perm, $GroupId);
+ }
+ }
+
+ function AddDeny($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Deny[$Perm])) {
+ array_push($this->Deny[$Perm], $GroupId);
+ $this->RemoveAllow($Perm, $GroupId);
+ }
+ }
+
+ function RemoveDeny($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Deny[$Perm])) {
+ array_splice($this->Deny[$Perm], array_search($GroupId, $this->Deny[$Perm]), 1);
+ }
+ }
+
+ function RemoveAllow($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Allow[$Perm])) {
+ array_splice($this->Allow[$Perm], array_search($GroupId, $this->Allow[$Perm]), 1);
+ }
+ }
+
+ function GetInsertSQL()
+ {
+ $values = array();
+
+ $has_deny = array();
+
+ /*foreach ($this->Deny as $perm => $groups) {
+ if (count($groups) > 0) {
+ $values[] = '('.$this->CatId.', '.$perm.', "", "'.join(',', $groups).'")';
+ $has_deny[] = $perm;
+ }
+ }*/
+
+ foreach ($this->Allow as $perm => $groups) {
+// if (in_array($perm, $has_deny)) continue;
+ if (count($groups) > 0) {
+ $values[] = '(' .$this->CatId. ', ' .$perm. ', "' .join(',', $groups). '", "")';
+ }
+ }
+ if (!$values) return '';
+ $sql = 'INSERT INTO '.GetTablePrefix().'PermCache (CategoryId, PermId, ACL, DACL) VALUES '.join(',', $values);
+ return $sql;
+ }
+}
+
+class clsCacheUpdater
+{
+ var $Stack;
+ var $iteration;
+ var $totalCats;
+ var $doneCats;
+ var $table;
+
+ var $root_prefixes = Array();
+
+ /**
+ * Kernel Application
+ *
+ * @var kApplication
+ */
+ var $Application = null;
+ /**
+ * Enter description here...
+ *
+ * @var kDBConnection
+ */
+ var $Conn = null;
+
+ function clsCacheUpdater($continuing=false)
+ {
+ $this->Application =& kApplication::Instance();
+ $this->Conn =& $this->Application->GetADODBConnection();
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var'];
+ }
+
+ $this->conn =& GetADODBConnection();
+ $this->iteration = 0;
+ $this->table=$GLOBALS['objSession']->GetEditTable('permCacheUpdate');
+
+ if (!$continuing) {
+ $this->Stack =& new clsRecursionStack();
+ $sql = 'DELETE FROM '.GetTablePrefix().'PermCache';
+ $this->conn->Execute($sql);
+ $this->initData();
+ }
+ else {
+ $this->getData();
+// $this->SetStack($data);
+ }
+ }
+
+ function getDonePercent()
+ {
+ if(!$this->totalCats)return 0;
+ return intval( round( $this->doneCats / $this->totalCats * 100 ) );
+ }
+
+ function getData()
+ {
+ $sql='SELECT data FROM '.$this->table;
+ if( $rs = $this->conn->Execute($sql) )
+ $tmp = unserialize($rs->fields['data']);
+
+ $this->totalCats = isset($tmp['totalCats']) ? $tmp['totalCats'] : 0;
+ $this->doneCats = isset($tmp['doneCats']) ? $tmp['doneCats'] : 0;
+ if(isset($tmp['stack']))
+ $this->Stack = $tmp['stack'];
+ else
+ $this->Stack = & new clsRecursionStack();
+
+ }
+
+ function setData()
+ {
+ $tmp=Array
+ (
+ 'totalCats' =>$this->totalCats,
+ 'doneCats' =>$this->doneCats,
+ 'stack' =>$this->Stack,
+
+ );
+ $sql='DELETE FROM '.$this->table;
+ $this->conn->Execute($sql);
+ $sql='INSERT '.$this->table.' SET data="'.addslashes(serialize($tmp)).'"';
+ $this->conn->Execute($sql);
+ }
+
+ function initData()
+ {
+ $this->clearData(); // drop table before starting anyway
+
+ $sql = 'CREATE TABLE '.$this->table.'(data LONGTEXT)';
+ $this->conn->Execute($sql);
+
+ $sql='SELECT COUNT(*) as count FROM '.GetTablePrefix().'Category';
+ if( $rs = $this->conn->Execute($sql) )
+ $this->totalCats=$rs->fields['count'];
+
+ $this->doneCats=0;
+ }
+
+ function clearData()
+ {
+ $sql='DROP TABLE IF EXISTS '.$this->table;
+ $this->conn->Execute($sql);
+ }
+
+ function DoTheJob()
+ {
+ $data = $this->Stack->Get();
+ if ($data === false) { //If Stack is empty
+ $data['current_id'] = 0;
+ $data['title'] = Array();
+ $data['named_path'] = Array();
+ $data['category_template'] = '';
+ $data['item_template'] = '';
+ $this->Stack->Push($data);
+ }
+
+ if (!isset($data['queried'])) {
+
+ $this->QueryTitle($data);
+ $this->QueryChildren($data);
+ $this->QueryPermissions($data);
+ $data['queried'] = 1;
+
+ if($sql = $data['perms']->GetInsertSQL())
+ {
+ $this->conn->Execute($sql);
+ $this->doneCats++;
+ }
+ $this->iteration++;
+ }
+
+ // start with first child if we haven't started yet
+ if (!isset($data['current_child'])) $data['current_child'] = 0;
+
+ // if we have more children
+ if (isset($data['children'][$data['current_child']]))
+ {
+ $next_data = Array();
+ $next_data['title'] = $data['title'];
+ $next_data['named_path'] = $data['named_path'];
+ $next_data['category_template'] = $data['category_template'];
+ $next_data['item_template'] = $data['item_template'];
+ $next_data['current_id'] = $data['children'][$data['current_child']]; //next iteration should process child
+ $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance
+ $next_data['perms']->SetCatId($next_data['current_id']);
+ $data['current_child']++;
+ $this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child
+ $this->Stack->Push($next_data); //next iteration should process this child
+ return true;
+ }
+ else {
+ $this->UpdateCachedPath($data);
+ $this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none)
+ // we are getting here if we finished with current level, so check if it's first level - then bail out.
+ return $this->Stack->Count() > 0;
+ }
+ }
+
+ function UpdateCachedPath(&$data)
+ {
+ $fields_hash = Array( 'CachedNavbar' => implode('>', $data['title']),
+ 'NamedParentPath' => implode('/', $data['named_path'] ),
+ 'CachedCategoryTemplate'=> $data['category_template'],
+ 'CachedItemTemplate' => $data['item_template'],
+ );
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']);
+ }
+
+ function QueryTitle(&$data)
+ {
+ $category_id = $data['current_id'];
+
+ $sql = 'SELECT Name, Filename, CategoryTemplate, ItemTemplate
+ FROM '.GetTablePrefix().'Category
+ WHERE CategoryId = '.$category_id;
+
+ $rs = $this->conn->Execute($sql);
+
+ if ($rs && !$rs->EOF)
+ {
+ $data['title'][] = $rs->fields['Name'];
+ $data['named_path'][] = $rs->fields['Filename'];
+
+ // it is one of the modules root category
+ $root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false;
+ if ($root_prefix) {
+ $fields_hash = Array();
+ if (!$rs->fields['CategoryTemplate']) {
+ $rs->fields['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate');
+ $fields_hash['CategoryTemplate'] = $rs->fields['CategoryTemplate'];
+ }
+
+ if (!$rs->fields['ItemTemplate']) {
+ $rs->fields['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate');
+ $fields_hash['ItemTemplate'] = $rs->fields['ItemTemplate'];
+ }
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
+ }
+
+ // if explicitly set, then use it; use parent template otherwise
+ if ($rs->fields['CategoryTemplate']) {
+ $data['category_template'] = $rs->fields['CategoryTemplate'];
+ }
+
+ if ($rs->fields['ItemTemplate']) {
+ $data['item_template'] = $rs->fields['ItemTemplate'];
+ }
+ }
+ }
+
+ function QueryChildren(&$data)
+ {
+ $sql = sprintf('SELECT CategoryId FROM '.GetTablePrefix().'Category WHERE ParentId = %s',
+ $data['current_id']);
+ $rs = $this->conn->Execute($sql);
+
+ $data['children'] = Array();
+ while ($rs && !$rs->EOF)
+ {
+ $data['children'][] = $rs->fields['CategoryId'];
+ $rs->MoveNext();
+ }
+ }
+
+ function QueryPermissions(&$data)
+ {
+ // don't search for section "view" permissions here :)
+ $sql = sprintf('SELECT ipc.PermissionConfigId, ip.GroupId, ip.PermissionValue FROM '.GetTablePrefix().'Permissions AS ip
+ LEFT JOIN '.GetTablePrefix().'PermissionConfig AS ipc
+ ON ipc.PermissionName = ip.Permission
+ WHERE (CatId = %s) AND (Permission LIKE "%%.VIEW") AND (ipc.PermissionConfigId IS NOT NULL)',
+ $data['current_id']);
+ $rs = $this->conn->Execute($sql);
+
+ //create permissions array only if we don't have it yet (set by parent)
+ if (!isset($data['perms'])) {
+ $data['perms'] = new clsCachedPermissions($data['current_id']);
+ }
+
+ while ($rs && !$rs->EOF)
+ {
+ if ($rs->fields['PermissionValue'] == 1) {
+ $data['perms']->AddAllow($rs->fields['PermissionConfigId'], $rs->fields['GroupId']);
+ }
+ else {
+ $data['perms']->AddDeny($rs->fields['PermissionConfigId'], $rs->fields['GroupId']);
+ }
+ $rs->MoveNext();
+ }
+ }
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/admin/category/permcacheupdate.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/admin/category/addpermission_modules.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/admin/category/addpermission_modules.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/admin/category/addpermission_modules.php (revision 5297)
@@ -0,0 +1,233 @@
+<?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. ##
+##############################################################
+
+// new startup: begin
+define('REL_PATH', 'admin/category');
+$relation_level = count( explode('/', REL_PATH) );
+define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
+require_once FULL_PATH.'/kernel/startup.php';
+// new startup: end
+
+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."/browse/toolbar.php");
+require_once($pathtoroot.$admin."/listview/listview.php");
+
+$m = GetModuleArray();
+foreach($m as $key=>$value)
+{
+ $path = $pathtoroot. $value."admin/include/parser.php";
+ if(file_exists($path))
+ {
+ include_once($path);
+ }
+}
+
+unset($objEditItems);
+
+$objEditItems = new clsCatList();
+$objEditItems->SourceTable = $objSession->GetEditTable("Category");
+
+$live_editing = $objSession->GetVariable('IsHomeCategory');
+if ($live_editing) {
+ $objEditItems->SourceTable = TABLE_PREFIX.'Category';
+}
+
+//Multiedit init
+$en = (int)$_GET["en"];
+$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable.($objEditItems->isLiveTable() ? ' WHERE CategoryId = 0' : ''));
+$itemcount=$objEditItems->NumItems();
+
+if(isset($_GET["en"]))
+{
+ $c = $objEditItems->GetItemByIndex($en);
+}
+else
+{
+ $c = new clsCategory($m_var_list["cat"]);
+}
+
+if(!is_object($c))
+{
+ $c = new clsCategory();
+ $c->Set("CategoryId",0);
+}
+if($itemcount>1)
+{
+ if ($en+1 == $itemcount)
+ $en_next = -1;
+ else
+ $en_next = $en+1;
+
+ if ($en == 0)
+ $en_prev = -1;
+ else
+ $en_prev = $en-1;
+}
+$action = "m_edit_permissions";
+
+$envar = "env=" . BuildEnv() . "&en=$en";
+
+//$section = 'in-portal:editcategory_permissions';
+$section = 'in-portal:catperm_modules';
+
+if(count($_POST))
+{
+ if($_POST["Action"]=="m_edit_permissions")
+ {
+ $GroupId = $_POST["GroupId"];
+ $g = $objGroups->GetItem($GroupId);
+ }
+ else
+ {
+ if(!is_array($_POST["itemlist"]))
+ {
+ $g = $objGroups->GetItemByField("ResourceId", $_POST["itemlist"]);
+ if(is_object($g))
+ $GroupId = $g->Get("GroupId");
+ }
+ else
+ {
+ $g = $objGroups->GetItemByField("ResourceId", $_POST["itemlist"][0]);
+ $GroupId = $g->Get("GroupId");
+ }
+ }
+}
+else
+{
+ $GroupId = $_GET["GroupId"];
+ $g = $objGroups->GetItem($GroupId);
+}
+
+$objPermList = new clsPermList($c->Get("CategoryId"),$GroupId);
+
+$ado = &GetADODBConnection();
+$sql = "SELECT DISTINCT(ModuleId) FROM ".GetTablePrefix()."PermissionConfig";
+$rs = $ado->Execute($sql);
+$Modules = array();
+
+while($rs && !$rs->EOF)
+{
+ $data = $rs->fields;
+ $Modules[] = $data["ModuleId"];
+ $rs->MoveNext();
+}
+/* page header */
+$charset = GetRegionalOption('Charset');
+print <<<END
+<html>
+<head>
+ <title>In-portal</title>
+ <meta http-equiv="content-type" content="text/html;charset=$charset">
+ <meta http-equiv="Pragma" content="no-cache">
+ <script language="JavaScript">
+ imagesPath='$imagesURL'+'/';
+ </script>
+ <script src="$browseURL/common.js"></script>
+ <script src="$browseURL/toolbar.js"></script>
+ <script src="$browseURL/utility.js"></script>
+ <script src="$browseURL/checkboxes.js"></script>
+ <script language="JavaScript1.2" src="$browseURL/fw_menu.js"></script>
+ <link rel="stylesheet" type="text/css" href="$browseURL/checkboxes.css">
+ <link rel="stylesheet" type="text/css" href="$cssURL/style.css">
+ <link rel="stylesheet" type="text/css" href="$browseURL/toolbar.css">
+END;
+
+//int_SectionHeader();
+if($c->Get("CategoryId")!=0)
+{
+ $title = admin_language("la_Text_Editing")." ".admin_language("la_Text_Category")." '".$c->Get("Name")."' - ".admin_language("la_tab_Permissions");
+ $title .= " ".admin_language("la_text_for")." '".$g->parsetag("group_name")."'";
+}
+else
+{
+ $title = admin_language("la_Text_Editing")." ".admin_language("la_Text_Root")." ".admin_language("la_Text_Category")." - "."' - ".admin_language("la_tab_Permissions");
+ $title .= " ".admin_language("la_text_for")." '".$g->parsetag("group_name")."'";
+}
+
+$objListToolBar = new clsToolBar();
+$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","do_edit_save('category','CatEditStatus','$admin/category/addcategory_permissions.php',0);",$imagesURL."/toolbar/tool_select.gif");
+$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","do_edit_save('category','CatEditStatus','".$admin."/category/addcategory_permissions.php',-1);", $imagesURL."/toolbar/tool_cancel.gif");
+
+$sec = $objSections->GetSection($section);
+if($c->Get("CategoryId")==0)
+{
+ $sec->Set("left",NULL);
+ $sec->Set("right",NULL);
+}
+
+int_header($objListToolBar,NULL,$title);
+if ($objSession->GetVariable("HasChanges") == 1) {
+?>
+<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
+ <tr>
+ <td valign="top">
+ <?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
+ </td>
+ </tr>
+</table>
+<?php } ?>
+<TABLE CELLPADDING=0 CELLSPACING=0 class="tableborder" width="100%">
+<TBODY>
+ <tr BGCOLOR="#e0e0da">
+ <td WIDTH="100%" CLASS="navar">
+ <img height="15" src="<?php echo $imagesURL; ?>/arrow.gif" width="15" align="middle" border="0">
+ <span class="NAV_CURRENT_ITEM"><?php echo admin_language("la_Prompt_CategoryPermissions"); ?></span>
+ </td>
+ </TR>
+</TBODY>
+</TABLE>
+<TABLE CELLPADDING=0 CELLSPACING=0 class="tableborder" width="100%">
+<TBODY>
+<FORM ID="category" NAME="category" method="POST" ACTION="">
+<?php
+ for($i=0;$i<count($Modules);$i++)
+ {
+ $module = $Modules[$i];
+ if($module != "Admin" && $module != "Front")
+ {
+ echo "<TR ".int_table_color_ret().">";
+ echo "<TD><IMG src=\"".$imagesURL."/itemicons/icon16_permission.gif\"> ";
+ $getvar = "?env=".BuildEnv()."&module=$module&GroupId=$GroupId&en=".GetVar('en');
+ echo "<A class=\"NAV_URL\" HREF=\"".$adminURL."/category/addpermission.php$getvar\">$module</A></TD>";
+ echo "</TR>";
+ }
+ }
+?>
+</TBODY>
+</TABLE>
+ <input type="hidden" name="ParentId" value="<?php echo $c->Get("ParentId"); ?>">
+ <input type="hidden" name="CategoryId" value="<?php echo $c->parsetag("cat_id"); ?>">
+ <input type="hidden" name="GroupId" value ="<?php echo $GroupId; ?>">
+ <input type="hidden" name="Action" value="<?php echo $action; ?>">
+ <input type="hidden" name="CatEditStatus" VALUE="0">
+</FORM>
+<FORM NAME="save_edit_buttons" ID="save_edit_buttons" method="POST" ACTION="">
+ <tr <?php int_table_color(); ?>>
+ <td colspan="3">
+ <input type=hidden NAME="Action" VALUE="save_cat_edit">
+ </td>
+ </tr>
+</FORM>
+<!-- CODE FOR VIEW MENU -->
+<form method="post" action="user_groups.php?<?php echo $envar; ?>" name="viewmenu">
+<input type="hidden" name="fieldname" value="">
+<input type="hidden" name="varvalue" value="">
+<input type="hidden" name="varvalue2" value="">
+<input type="hidden" name="Action" value="">
+</form>
+<!-- END CODE-->
+<?php int_footer(); ?>
Property changes on: branches/unlabeled/unlabeled-1.10.2/admin/category/addpermission_modules.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/core/units/selectors/selectors_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/core/units/selectors/selectors_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.10.2/core/units/selectors/selectors_event_handler.php (revision 5297)
@@ -0,0 +1,370 @@
+<?php
+
+safeDefine('STYLE_BASE', 1);
+safeDefine('STYLE_BLOCK', 2);
+
+ class SelectorsEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnResetToBase' => Array('subitem' => 'add|edit'),
+ 'OnMassResetToBase' => Array('subitem' => 'add|edit'),
+
+ 'OnOpenStyleEditor' => Array('subitem' => 'add|edit'),
+ 'OnSaveStyle' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Occures before an item has been cloned
+ * Id of newly created item is passed as event' 'id' param
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeClone(&$event)
+ {
+ $event->Init($event->Prefix, '-item');
+ $object =& $event->getObject();
+
+ $title_field = 'SelectorName';
+ $new_name = $object->GetDBField($title_field);
+ $original_checked = false;
+
+ $foreign_key = $event->getEventParam('foreign_key'); // in case if whole stylesheet is cloned
+ if($foreign_key === false) $foreign_key = $object->GetDBField('StylesheetId'); // in case if selector is copied ifself
+
+ do {
+ if ( preg_match('/(.*)-([\d]+)/', $new_name, $regs) ) {
+ $new_name = $regs[1].'-'.($regs[2]+1);
+ }
+ elseif ($original_checked) {
+ $new_name = $new_name.'-1';
+ }
+
+ // if we are cloning in temp table this will look for names in temp table,
+ // since object' TableName contains correct TableName (for temp also!)
+ // if we are cloning live - look in live
+ $query = ' SELECT '.$title_field.'
+ FROM '.$object->TableName.'
+ WHERE '.$title_field.' = '.$this->Conn->qstr($new_name).' AND StylesheetId = '.$foreign_key;
+
+ $res = $this->Conn->GetOne($query);
+
+ /*// if not found in live table, check in temp table if applicable
+ if ($res === false && $object->Special == 'temp') {
+ $query = 'SELECT '.$name_field.' FROM '.$this->GetTempName($master['TableName']).'
+ WHERE '.$name_field.' = '.$this->Conn->qstr($new_name);
+ $res = $this->Conn->GetOne($query);
+ }*/
+
+ $original_checked = true;
+ } while ($res !== false);
+ $object->SetDBField($title_field, $new_name);
+ }
+
+ /**
+ * Show base styles or block styles
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ $object =& $event->getObject();
+ switch ($event->Special)
+ {
+ case 'base':
+ $object->addFilter('type_filter', '%1$s.Type = 1');
+ break;
+
+ case 'block':
+ $object->addFilter('type_filter', '%1$s.Type = 2');
+ break;
+ }
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemUpdate(&$event)
+ {
+ $this->SerializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ $this->SerializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemUpdate(&$event)
+ {
+ $this->UnserializeSelectorData($event);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemCreate(&$event)
+ {
+ $this->UnserializeSelectorData($event);
+ }
+
+ /**
+ * Get's special of main item for linking with subitem
+ *
+ * @param kEvent $event
+ * @return string
+ */
+ function getMainSpecial(&$event)
+ {
+ return '';
+ }
+
+ /**
+ * Save css-style name & description before opening css editor
+ *
+ * @param kEvent $event
+ */
+ function OnOpenStyleEditor(&$event)
+ {
+ $this->SaveChanges($event);
+ $event->redirect = false;
+ }
+
+ /**
+ * Saves Changes to Item
+ *
+ * @param kEvent $event
+ */
+ function SaveChanges(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if($items_info)
+ {
+ list($id,$field_values) = each($items_info);
+ if($id == 0)
+ {
+ $parent_id = getArrayValue($field_values,'ParentId');
+ if($parent_id) $object->Load($parent_id);
+
+ $object->SetFieldsFromHash($field_values);
+ $object->Create();
+ if( $object->IsTempTable() ) $object->setTempID();
+ $this->Application->SetVar($event->getPrefixSpecial().'_id', $object->GetID() );
+ }
+ else
+ {
+ $object->Load($id);
+ $object->SetFieldsFromHash($field_values);
+ $object->Update();
+ }
+ }
+ }
+
+ /**
+ * Save style changes from style editor
+ *
+ * @param kEvent $event
+ */
+ function OnSaveStyle(&$event)
+ {
+ $this->SaveChanges($event);
+
+ $object =& $event->getObject();
+ $this->Application->SetVar($event->getPrefixSpecial().'_id', $object->GetId() );
+
+ $this->finalizePopup($event);
+ }
+
+ /**
+ * Extract styles
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemLoad(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if($selector_data)
+ {
+ $selector_data = unserialize($selector_data);
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+ else
+ {
+ $selector_data = Array();
+ }
+ $this->AddParentProperties($event, $selector_data);
+ }
+
+ /**
+ * Serialize item before saving to db
+ *
+ * @param kEvent $event
+ */
+ function SerializeSelectorData(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if(!$selector_data) $selector_data = Array();
+
+ $selector_data = $this->RemoveParentProperties($event, $selector_data);
+
+ if( !IsSerialized($selector_data) ) $selector_data = serialize($selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+
+ /**
+ * Unserialize data back when update was made
+ *
+ * @param kEvent $event
+ */
+ function UnserializeSelectorData(&$event)
+ {
+ $object =& $event->getObject();
+ $selector_data = $object->GetDBField('SelectorData');
+ if(!$selector_data) $selector_data = Array();
+ if( IsSerialized($selector_data) ) $selector_data = unserialize($selector_data);
+
+ $selector_data = $this->AddParentProperties($event, $selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ }
+
+ /**
+ * Populate options based on temporary table :)
+ *
+ * @param kEvent $event
+ */
+ function OnPrepareBaseStyles(&$event)
+ {
+ $object =& $event->getObject();
+
+ $parent_info = $object->getLinkedInfo();
+ $title_field = $this->Application->getUnitOption($event->Prefix,'TitleField');
+ $sql = 'SELECT '.$title_field.', '.$object->IDField.' FROM '.$object->TableName.' WHERE Type = 1 AND StylesheetId = '.$parent_info['ParentId'].' ORDER BY '.$title_field;
+ $object->Fields['ParentId']['options'] = $this->Conn->GetCol($sql,$object->IDField);
+ }
+
+ /**
+ * Remove properties of parent style that match by value from style
+ *
+ * @param kEvent $event
+ */
+ function RemoveParentProperties(&$event, $selector_data)
+ {
+ $object =& $event->getObject();
+ $parent_id = $object->GetDBField('ParentId');
+ if($parent_id)
+ {
+ $sql = 'SELECT SelectorData FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.$parent_id;
+ $base_selector_data = $this->Conn->GetOne($sql);
+
+ if( IsSerialized($base_selector_data) ) $base_selector_data = unserialize($base_selector_data);
+
+ foreach($selector_data as $prop_name => $prop_value)
+ {
+ if( !$prop_value || getArrayValue($base_selector_data,$prop_name) == $prop_value )
+ {
+ unset($selector_data[$prop_name]);
+ }
+ }
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ else
+ {
+ foreach($selector_data as $prop_name => $prop_value)
+ {
+ if(!$prop_value) unset($selector_data[$prop_name]);
+ }
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ }
+
+ /**
+ * Add back properties from parent style, that match this style property values
+ *
+ * @param kEvent $event
+ */
+ function AddParentProperties(&$event, $selector_data)
+ {
+ $object =& $event->getObject();
+ $parent_id = $object->GetDBField('ParentId');
+ if($parent_id)
+ {
+ $sql = 'SELECT SelectorData FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.$parent_id;
+ $base_selector_data = $this->Conn->GetOne($sql);
+
+ if( IsSerialized($base_selector_data) ) $base_selector_data = unserialize($base_selector_data);
+
+ $selector_data = array_merge_recursive2($base_selector_data,$selector_data);
+
+ $object->SetDBField('SelectorData', $selector_data);
+ return $selector_data;
+ }
+ return $selector_data;
+ }
+
+ /**
+ * Reset Style definition to base style -> no customizations
+ *
+ * @param kEvent $event
+ */
+ function OnResetToBase(&$event)
+ {
+ $object =& $event->getObject();
+ $object->SetFieldsFromHash( $this->getSubmittedFields($event) );
+ $object->ResetStyle();
+
+ $event->redirect_params['pass'] = 'all,'.$event->getPrefixSpecial();
+ }
+
+ /**
+ * Resets selected styles properties to values of their base classes
+ *
+ * @param kEvent $event
+ */
+ function OnMassResetToBase(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if($items_info)
+ {
+ foreach($items_info as $id => $field_values)
+ {
+ $object->Load($id);
+ $object->ResetStyle();
+ }
+ }
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/core/units/selectors/selectors_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.10
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline