]> 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 233ac7856788e05dd36dc668e319e57fa85cc0a1..251b1dadac820aecc7db092ee4c1587aa3a70dd8 100644 (file)
@@ -83,6 +83,11 @@ class Action extends HTMLOutputter // lawsuit
     function prepare($argarray)
     {
         $this->args =& common_copy_args($argarray);
+
+        if ($this->boolean('ajax')) {
+            StatusNet::setAjax(true);
+        }
+
         return true;
     }
 
@@ -95,10 +100,12 @@ class Action extends HTMLOutputter // lawsuit
     {
         if (Event::handle('StartShowHTML', array($this))) {
             $this->startHTML();
+            $this->flush();
             Event::handle('EndShowHTML', array($this));
         }
         if (Event::handle('StartShowHead', array($this))) {
             $this->showHead();
+            $this->flush();
             Event::handle('EndShowHead', array($this));
         }
         if (Event::handle('StartShowBody', array($this))) {
@@ -158,7 +165,7 @@ class Action extends HTMLOutputter // lawsuit
     {
         $this->element('title', null,
                        // TRANS: Page title. %1$s is the title, %2$s is the site name.
-                       sprintf(_("%1\$s - %2\$s"),
+                       sprintf(_('%1$s - %2$s'),
                                $this->title(),
                                common_config('site', 'name')));
     }
@@ -174,7 +181,7 @@ class Action extends HTMLOutputter // lawsuit
     function title()
     {
         // TRANS: Page title for a page without a title set.
-        return _("Untitled page");
+        return _('Untitled page');
     }
 
     /**
@@ -222,6 +229,8 @@ class Action extends HTMLOutputter // lawsuit
                 Event::handle('EndShowLaconicaStyles', array($this));
             }
 
+            $this->cssLink(common_path('js/css/smoothness/jquery-ui.css'));
+
             if (Event::handle('StartShowUAStyles', array($this))) {
                 $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
                                'href="'.Theme::path('css/ie.css', 'base').'?version='.STATUSNET_VERSION.'" /><![endif]');
@@ -237,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')) {
@@ -282,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);
+            }
+        }
     }
 
     /**
@@ -296,16 +298,21 @@ class Action extends HTMLOutputter // lawsuit
                 if (common_config('site', 'minify')) {
                     $this->script('jquery.min.js');
                     $this->script('jquery.form.min.js');
+                    $this->script('jquery-ui.min.js');
                     $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');
+                    $this->script('jquery-ui.min.js');
                     $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)) &&
@@ -317,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));
             }
@@ -334,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();
@@ -462,11 +475,14 @@ class Action extends HTMLOutputter // lawsuit
         $this->elementStart('div', array('id' => 'wrap'));
         if (Event::handle('StartShowHeader', array($this))) {
             $this->showHeader();
+            $this->flush();
             Event::handle('EndShowHeader', array($this));
         }
         $this->showCore();
+        $this->flush();
         if (Event::handle('StartShowFooter', array($this))) {
             $this->showFooter();
+            $this->flush();
             Event::handle('EndShowFooter', array($this));
         }
         $this->elementEnd('div');
@@ -566,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');
     }
 
@@ -595,17 +619,16 @@ class Action extends HTMLOutputter // lawsuit
      */
     function showNoticeForm()
     {
-        $tabs = array('status' => _('Status'));
+        // TRANS: Tab on the notice form.
+        $tabs = array('status' => _m('TAB','Status'));
 
         $this->elementStart('div', 'input_forms');
 
         if (Event::handle('StartShowEntryForms', array(&$tabs))) {
-
             $this->elementStart('ul', array('class' => 'nav',
                                             'id' => 'input_form_nav'));
 
             foreach ($tabs as $tag => $title) {
-
                 $attrs = array('id' => 'input_form_nav_'.$tag,
                                'class' => 'input_form_nav_tab');
 
@@ -633,7 +656,6 @@ class Action extends HTMLOutputter // lawsuit
             $this->elementEnd('div');
 
             foreach ($tabs as $tag => $title) {
-
                 $attrs = array('class' => 'input_form',
                                'id' => 'input_form_'.$tag);
 
@@ -643,7 +665,8 @@ class Action extends HTMLOutputter // lawsuit
 
                 if (Event::handle('StartMakeEntryForm', array($tag, $this, &$form))) {
                     if ($tag == 'status') {
-                        $form = new NoticeForm($this);
+                        $options = $this->noticeFormOptions();
+                        $form = new NoticeForm($this, $options);
                     }
                     Event::handle('EndMakeEntryForm', array($tag, $this, $form));
                 }
@@ -659,6 +682,11 @@ class Action extends HTMLOutputter // lawsuit
         $this->elementEnd('div');
     }
 
+    function noticeFormOptions()
+    {
+        return array();
+    }
+
     /**
      * Show anonymous message.
      *
@@ -681,19 +709,28 @@ class Action extends HTMLOutputter // lawsuit
     function showCore()
     {
         $this->elementStart('div', array('id' => 'core'));
+        $this->elementStart('div', array('id' => 'aside_primary_wrapper'));
+        $this->elementStart('div', array('id' => 'content_wrapper'));
+        $this->elementStart('div', array('id' => 'site_nav_local_views_wrapper'));
         if (Event::handle('StartShowLocalNavBlock', array($this))) {
             $this->showLocalNavBlock();
+            $this->flush();
             Event::handle('EndShowLocalNavBlock', array($this));
         }
         if (Event::handle('StartShowContentBlock', array($this))) {
             $this->showContentBlock();
+            $this->flush();
             Event::handle('EndShowContentBlock', array($this));
         }
         if (Event::handle('StartShowAside', array($this))) {
             $this->showAside();
+            $this->flush();
             Event::handle('EndShowAside', array($this));
         }
         $this->elementEnd('div');
+        $this->elementEnd('div');
+        $this->elementEnd('div');
+        $this->elementEnd('div');
     }
 
     /**
@@ -706,10 +743,24 @@ class Action extends HTMLOutputter // lawsuit
         // Need to have this ID for CSS; I'm too lazy to add it to
         // all menus
         $this->elementStart('div', array('id' => 'site_nav_local_views'));
+        // Cheat cheat cheat!
         $this->showLocalNav();
         $this->elementEnd('div');
     }
 
+    /**
+     * If there's a logged-in user, show a bit of login context
+     *
+     * @return nothing
+     */
+    function showProfileBlock()
+    {
+        if (common_logged_in()) {
+            $block = new DefaultProfileBlock($this);
+            $block->show();
+        }
+    }
+
     /**
      * Show local navigation.
      *
@@ -853,6 +904,7 @@ class Action extends HTMLOutputter // lawsuit
     {
         $this->elementStart('div', array('id' => 'aside_primary',
                                          'class' => 'aside'));
+        $this->showProfileBlock();
         if (Event::handle('StartShowObjectNavBlock', array($this))) {
             $this->showObjectNavBlock();
             Event::handle('EndShowObjectNavBlock', array($this));
@@ -1310,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';
         }
 
-        (is_null($id)) ? $lattrs : $lattrs['id'] = $id;
+        if (!empty($classes)) {
+            $lattrs['class'] = implode(' ', $classes);
+        }
+
+        if (!is_null($id)) {
+            $lattrs['id'] = $id;
+        }
 
         $this->elementStart('li', $lattrs);
         $attrs['href'] = $url;
@@ -1388,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.
      *