]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/htmloutputter.php
Merge branch '0.8.x' into 0.9.x
[quix0rs-gnu-social.git] / lib / htmloutputter.php
index 2684baca60abbda4a664971a9279e008b3ac3e2d..ce83295fb33783f1ddeac61da5ce19a3a2fe69e1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Low-level generator for HTML
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Output
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @author    Sarven Capadisli <csarven@controlyourself.ca>
- * @copyright 2008 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @copyright 2008 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -47,11 +47,11 @@ define('PAGE_TYPE_PREFS',
  * HTML-creation class.
  *
  * @category Output
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
- * @author   Sarven Capadisli <csarven@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Sarven Capadisli <csarven@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
  * @see      Action
  * @see      XMLOutputter
@@ -109,11 +109,13 @@ class HTMLOutputter extends XMLOutputter
         header('Content-Type: '.$type);
 
         $this->extraHeaders();
-        if( ! substr($type,0,strlen('text/html'))=='text/html' ){
-            // Browsers don't like it when <?xml it output for non-xhtml documents
+        if (preg_match("/.*\/.*xml/", $type)) {
+            // Required for XML documents
             $this->xw->startDocument('1.0', 'UTF-8');
         }
-        $this->xw->writeDTD('html', $public, $system);
+        $this->xw->writeDTD('html',
+                            '-//W3C//DTD XHTML 1.0 Strict//EN',
+                            'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
 
         $language = $this->getLanguage();
 
@@ -350,9 +352,9 @@ class HTMLOutputter extends XMLOutputter
     function script($src, $type='text/javascript')
     {
         $url = parse_url($src);
-        if(! ($url->scheme || $url->host || $url->query || $url->fragment))
+        if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
         {
-            $src = common_path($src) . '?version=' . LACONICA_VERSION;
+            $src = common_path($src) . '?version=' . STATUSNET_VERSION;
         }
         $this->element('script', array('type' => $type,
                                                'src' => $src),
@@ -371,10 +373,10 @@ class HTMLOutputter extends XMLOutputter
     function cssLink($src,$theme=null,$media=null)
     {
         $url = parse_url($src);
-        if(! ($url->scheme || $url->host || $url->query || $url->fragment))
+        if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
         {
             if(file_exists(theme_file($src,$theme))){
-               $src = theme_path($src, $theme) . '?version=' . LACONICA_VERSION;
+               $src = theme_path($src, $theme) . '?version=' . STATUSNET_VERSION;
             }else{
                $src = common_path($src);
             }
@@ -412,4 +414,25 @@ class HTMLOutputter extends XMLOutputter
             $this->element('p', 'form_guide', $instructions);
         }
     }
+
+
+    /**
+    * Internal script to autofocus the given element on page onload.
+    *
+    * @param string $id element ID, must refer to an existing element
+    *
+    * @return void
+    *
+    */
+    function autofocus($id)
+    {
+        $this->elementStart('script', array('type' => 'text/javascript'));
+        $this->raw('/*<![CDATA[*/'.
+                   ' $(document).ready(function() {'.
+                   ' var el = $("#' . $id . '");'.
+                   ' if (el.length) { el.focus(); }'.
+                   ' });'.
+                   ' /*]]>*/');
+        $this->elementEnd('script');
+    }
 }