]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/action.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / lib / action.php
index d8efad07408ac70324033b8f8d4e152d2681ff52..251b1dadac820aecc7db092ee4c1587aa3a70dd8 100644 (file)
@@ -118,7 +118,7 @@ class Action extends HTMLOutputter // lawsuit
         }
     }
 
-    function timingComment()
+    function endHTML()
     {
         global $_startTime;
 
@@ -127,15 +127,10 @@ class Action extends HTMLOutputter // lawsuit
             $diff = round(($endTime - $_startTime) * 1000);
             $this->raw("<!-- ${diff}ms -->");
         }
-    }
 
-    function endHTML()
-    {
-        $this->timingComment();
         return parent::endHTML();
     }
 
-    
     /**
      * Show head, a template method.
      *
@@ -144,7 +139,6 @@ class Action extends HTMLOutputter // lawsuit
     function showHead()
     {
         // XXX: attributes (profile?)
-        $this->timingComment();
         $this->elementStart('head');
         if (Event::handle('StartShowHeadElements', array($this))) {
             if (Event::handle('StartShowHeadTitle', array($this))) {
@@ -160,7 +154,6 @@ class Action extends HTMLOutputter // lawsuit
             Event::handle('EndShowHeadElements', array($this));
         }
         $this->elementEnd('head');
-        $this->timingComment();
     }
 
     /**
@@ -253,20 +246,6 @@ class Action extends HTMLOutputter // lawsuit
                 Event::handle('EndShowUAStyles', array($this));
             }
 
-            if (Event::handle('StartShowDesign', array($this))) {
-
-                $user = common_current_user();
-
-                if (empty($user) || $user->viewdesigns) {
-                    $design = $this->getDesign();
-
-                    if (!empty($design)) {
-                        $design->showCSS($this);
-                    }
-                }
-
-                Event::handle('EndShowDesign', array($this));
-            }
             Event::handle('EndShowStyles', array($this));
 
             if (common_config('custom_css', 'enabled')) {
@@ -298,6 +277,13 @@ class Action extends HTMLOutputter // lawsuit
             $this->cssLink('css/display.css', $baseTheme, $media);
         }
         $this->cssLink('css/display.css', $mainTheme, $media);
+
+        // Additional styles for RTL languages
+        if (is_rtl(common_language())) {
+            if (file_exists(Theme::file('css/rtl.css'))) {
+                $this->cssLink('css/rtl.css', $mainTheme, $media);
+            }
+        }
     }
 
     /**
@@ -316,6 +302,7 @@ class Action extends HTMLOutputter // lawsuit
                     $this->script('jquery.cookie.min.js');
                     $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/json2.min.js').'"); }');
                     $this->script('jquery.joverlay.min.js');
+                    $this->script('jquery.infieldlabel.min.js');
                 } else {
                     $this->script('jquery.js');
                     $this->script('jquery.form.js');
@@ -323,7 +310,9 @@ class Action extends HTMLOutputter // lawsuit
                     $this->script('jquery.cookie.js');
                     $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/json2.js').'"); }');
                     $this->script('jquery.joverlay.js');
+                    $this->script('jquery.infieldlabel.js');
                 }
+
                 Event::handle('EndShowJQueryScripts', array($this));
             }
             if (Event::handle('StartShowStatusNetScripts', array($this)) &&
@@ -335,9 +324,16 @@ class Action extends HTMLOutputter // lawsuit
                     $this->script('xbImportNode.js');
                     $this->script('geometa.js');
                 }
+                $this->inlineScript('var _peopletagAC = "' .
+                    common_local_url('peopletagautocomplete') . '";');
                 $this->showScriptMessages();
-                // Frame-busting code to avoid clickjacking attacks.
-                $this->inlineScript('if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');
+                // Anti-framing code to avoid clickjacking attacks in older browsers.
+                // This will show a blank page if the page is being framed, which is
+                // consistent with the behavior of the 'X-Frame-Options: SAMEORIGIN'
+                // header, which prevents framing in newer browser.
+                if (common_config('javascript', 'bustframes')) {
+                    $this->inlineScript('if (window.top !== window.self) { document.write = ""; window.top.location = window.self.location; setTimeout(function () { document.body.innerHTML = ""; }, 1); window.self.onload = function () { document.body.innerHTML = ""; }; }');
+                }
                 Event::handle('EndShowStatusNetScripts', array($this));
                 Event::handle('EndShowLaconicaScripts', array($this));
             }
@@ -352,7 +348,6 @@ class Action extends HTMLOutputter // lawsuit
      * events and appending to the array. Try to avoid adding strings that won't be used, as
      * they'll be added to HTML output.
      */
-
     function showScriptMessages()
     {
         $messages = array();
@@ -474,31 +469,25 @@ class Action extends HTMLOutputter // lawsuit
      */
     function showBody()
     {
-        $this->timingComment();
         $this->elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')),
                                                                     'class' => 'user_in')
                             : array('id' => strtolower($this->trimmed('action'))));
         $this->elementStart('div', array('id' => 'wrap'));
         if (Event::handle('StartShowHeader', array($this))) {
-            $this->timingComment();
             $this->showHeader();
             $this->flush();
-            $this->timingComment();
             Event::handle('EndShowHeader', array($this));
         }
         $this->showCore();
         $this->flush();
         if (Event::handle('StartShowFooter', array($this))) {
-            $this->timingComment();
             $this->showFooter();
             $this->flush();
-            $this->timingComment();
             Event::handle('EndShowFooter', array($this));
         }
         $this->elementEnd('div');
         $this->showScripts();
         $this->elementEnd('body');
-        $this->timingComment();
     }
 
     /**
@@ -593,6 +582,14 @@ class Action extends HTMLOutputter // lawsuit
         $this->elementStart('div', array('id' => 'site_nav_global_primary'));
         $pn = new PrimaryNav($this);
         $pn->show();
+
+        $user = common_current_user();
+
+        if (!empty($user) || !common_config('site', 'private')) {
+            $form = new SearchForm($this);
+            $form->show();
+        }
+
         $this->elementEnd('div');
     }
 
@@ -716,24 +713,18 @@ class Action extends HTMLOutputter // lawsuit
         $this->elementStart('div', array('id' => 'content_wrapper'));
         $this->elementStart('div', array('id' => 'site_nav_local_views_wrapper'));
         if (Event::handle('StartShowLocalNavBlock', array($this))) {
-            $this->timingComment();
             $this->showLocalNavBlock();
             $this->flush();
-            $this->timingComment();
             Event::handle('EndShowLocalNavBlock', array($this));
         }
         if (Event::handle('StartShowContentBlock', array($this))) {
-            $this->timingComment();
             $this->showContentBlock();
             $this->flush();
-            $this->timingComment();
             Event::handle('EndShowContentBlock', array($this));
         }
         if (Event::handle('StartShowAside', array($this))) {
-            $this->timingComment();
             $this->showAside();
             $this->flush();
-            $this->timingComment();
             Event::handle('EndShowAside', array($this));
         }
         $this->elementEnd('div');
@@ -762,7 +753,6 @@ class Action extends HTMLOutputter // lawsuit
      *
      * @return nothing
      */
-
     function showProfileBlock()
     {
         if (common_logged_in()) {
@@ -1372,16 +1362,26 @@ class Action extends HTMLOutputter // lawsuit
      *
      * @return nothing
      */
-    function menuItem($url, $text, $title=null, $is_selected=false, $id=null)
+    function menuItem($url, $text, $title=null, $is_selected=false, $id=null, $class=null)
     {
         // Added @id to li for some control.
         // XXX: We might want to move this to htmloutputter.php
-        $lattrs = array();
+        $lattrs  = array();
+        $classes = array();
+        if ($class !== null) {
+            $classes[] = trim($class);
+        }
         if ($is_selected) {
-            $lattrs['class'] = 'current';
+            $classes[] = 'current';
+        }
+
+        if (!empty($classes)) {
+            $lattrs['class'] = implode(' ', $classes);
         }
 
-        (is_null($id)) ? $lattrs : $lattrs['id'] = $id;
+        if (!is_null($id)) {
+            $lattrs['id'] = $id;
+        }
 
         $this->elementStart('li', $lattrs);
         $attrs['href'] = $url;
@@ -1450,16 +1450,6 @@ class Action extends HTMLOutputter // lawsuit
         return null;
     }
 
-    /**
-     * A design for this action
-     *
-     * @return Design a design object to use
-     */
-    function getDesign()
-    {
-        return Design::siteDesign();
-    }
-
     /**
      * Check the session token.
      *