Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
authorDan
Tue, 12 Feb 2008 22:17:58 -0500
changeset 419 b8b4e38825db
parent 418 322fa0c91303
child 420 301f546688d1
child 422 ca37fcd08c4e
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
ajax.php
includes/clientside/static/acl.js
includes/clientside/static/editor.js
includes/clientside/static/faders.js
includes/template.php
--- a/ajax.php	Tue Feb 12 07:44:16 2008 -0500
+++ b/ajax.php	Tue Feb 12 22:17:58 2008 -0500
@@ -115,6 +115,7 @@
         if ( $db->numrows() > 0 )
         {
           $have_draft = true;
+          $draft_row = $db->fetchrow($q);
         }
       }
       else if ( $src !== false )
@@ -145,7 +146,7 @@
       
       if ( $have_draft )
       {
-        $row = $db->fetchrow($q);
+        $row =& $draft_row;
         $return['have_draft'] = true;
         $return['draft_author'] = $row['author'];
         $return['draft_time'] = enano_date('d M Y h:i a', intval($row['time_id']));
--- a/includes/clientside/static/acl.js	Tue Feb 12 07:44:16 2008 -0500
+++ b/includes/clientside/static/acl.js	Tue Feb 12 22:17:58 2008 -0500
@@ -435,12 +435,12 @@
             note.appendChild(document.createElement('br'));
             var a = document.createElement('a');
             a.href = '#';
-            a.onclick = function(e) { this.parentNode.parentNode.removeChild(this.parentNode); return false; };
+            a.id = aclManagerID + '_btn_dismiss';
             a.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :'));
             note.appendChild(a);
             var a2 = document.createElement('a');
             a2.href = '#';
-            a2.onclick = function(e) { killACLManager(); return false; };
+            a.id = aclManagerID + '_btn_close';
             a2.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]'));
             note.appendChild(a2);
             document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild);
@@ -449,6 +449,12 @@
             //fadeInfoBoxes();
             document.getElementById(aclManagerID+'_main').scrollTop = 0;
             
+            var a = document.getElementById(aclManagerID + '_btn_dismiss');
+            var a2 = document.getElementById(aclManagerID + '_btn_close');
+            
+            a.setAttribute('onclick', function(e) { this.parentNode.parentNode.removeChild(this.parentNode); return false; });
+            a2.setAttribute('onclick', function(e) { killACLManager(); return false; });
+            
             aclDataCache.mode = 'save_edit';
             break;
           case 'delete':
--- a/includes/clientside/static/editor.js	Tue Feb 12 07:44:16 2008 -0500
+++ b/includes/clientside/static/editor.js	Tue Feb 12 22:17:58 2008 -0500
@@ -143,10 +143,6 @@
       // Current selection is TinyMCE - make span_wiki have the link and span_mce be plaintext
       var a = document.createElement('a');
       a.href = '#';
-      a.onclick = function() {
-        ajaxSetEditorPlain();
-        return false;
-      };
       a.appendChild(document.createTextNode($lang.get('editor_btn_wikitext')));
       span_wiki.appendChild(a);
       toggler.appendChild(span_wiki);
@@ -162,10 +158,6 @@
       toggler.appendChild(document.createTextNode(' | '));
       var a = document.createElement('a');
       a.href = '#';
-      a.onclick = function() {
-        ajaxSetEditorMCE();
-        return false;
-      };
       a.appendChild(document.createTextNode($lang.get('editor_btn_graphical')));
       span_mce.appendChild(a);
       toggler.appendChild(span_mce);
@@ -490,6 +482,26 @@
   $dynano('ajaxEditArea').object._edTimestamp = timestamp;
   $dynano('ajaxEditArea').setContent(content);
   
+  if ( allow_wysiwyg )
+  {
+    if ( readCookie('enano_editor_mode') == 'tinymce' )
+    {
+      var a = document.getElementById('enano_edit_btn_pt').getElementsByTagName('a')[0];
+      a.onclick = function() {
+        ajaxSetEditorPlain();
+        return false;
+      };
+    }
+    else
+    {
+      var a = document.getElementById('enano_edit_btn_mce').getElementsByTagName('a')[0];
+      a.onclick = function() {
+        ajaxSetEditorMCE();
+        return false;
+      };
+    }
+  }
+  
   // Autosave every 5 minutes           (m  *  s  *  ms)
   setInterval('ajaxPerformAutosave();', ( 5 * 60 * 1000 ));
 }
--- a/includes/clientside/static/faders.js	Tue Feb 12 07:44:16 2008 -0500
+++ b/includes/clientside/static/faders.js	Tue Feb 12 22:17:58 2008 -0500
@@ -368,6 +368,8 @@
   j = 0;
   for(var i in d)
   {
+    if ( !d[i] )
+      continue;
     if ( !d[i].tagName )
       continue;
     if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box')
--- a/includes/template.php	Tue Feb 12 07:44:16 2008 -0500
+++ b/includes/template.php	Tue Feb 12 22:17:58 2008 -0500
@@ -81,7 +81,7 @@
     $this->style_list = $list;
     
   }
-  function sidebar_widget($t, $h)
+  function sidebar_widget($t, $h, $use_normal_section = false)
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
     if(!defined('ENANO_TEMPLATE_LOADED'))
@@ -91,9 +91,18 @@
     if(!$this->sidebar_widgets)
       $this->sidebar_widgets = '';
     $tplvars = $this->extract_vars('elements.tpl');
-    $parser = $this->makeParserText($tplvars['sidebar_section_raw']);
-    $parser->assign_vars(Array('TITLE'=>$t,'CONTENT'=>$h));
-    $this->plugin_blocks[$t] = $h;
+    
+    if ( $use_normal_section )
+    {
+      $parser = $this->makeParserText($tplvars['sidebar_section']);
+    }
+    else
+    {
+      $parser = $this->makeParserText($tplvars['sidebar_section_raw']);
+    }
+    
+    $parser->assign_vars(Array('TITLE' => '{TITLE}','CONTENT' => $h));
+    $this->plugin_blocks[$t] = $parser->run();
     $this->sidebar_widgets .= $parser->run();
   }
   function add_header($html)
@@ -1707,13 +1716,18 @@
           ob_end_clean();
           break;
         case BLOCK_PLUGIN:
-          $parser = $this->makeParserText($vars['sidebar_section_raw']);
+          $parser = $this->makeParserText('{CONTENT}');
           $c = (gettype($this->fetch_block($row['block_content'])) == 'string') ? $this->fetch_block($row['block_content']) : 'Can\'t find plugin block';
           break;
       }
       $parser->assign_vars(Array( 'TITLE'=>$this->tplWikiFormat($row['block_name']), 'CONTENT'=>$c ));
-      if    ($row['sidebar_id'] == SIDEBAR_LEFT ) $left  .= $parser->run();
-      elseif($row['sidebar_id'] == SIDEBAR_RIGHT) $right .= $parser->run();
+      $run = $parser->run();
+      if ( $row['block_type'] == BLOCK_PLUGIN )
+      {
+        $run = str_replace('{TITLE}', $this->tplWikiFormat($row['block_name']), $run);
+      }
+      if    ($row['sidebar_id'] == SIDEBAR_LEFT ) $left  .= $run;
+      elseif($row['sidebar_id'] == SIDEBAR_RIGHT) $right .= $run;
       unset($parser);
     }
     $db->free_result();