------------------------------------------------------------
revno: 1088
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Sun 2012-02-12 19:22:16 +0100
message:
  change output to use by another engine
modified:
  index.php
  libs/Output.php


--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk

Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to 
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'index.php'
--- index.php	2012-02-11 23:22:55 +0000
+++ index.php	2012-02-12 18:22:16 +0000
@@ -56,29 +56,22 @@
 	require_once("libs/widgets.php");
 	$layout = new CreateLayout();
 
-	$noheaders  = false;
-	$nogui      = false;
 	if (isset($global_widget) or isset($_REQUEST['noheaders'])) {
 		$noheaders  = true;
-		$nogui      = true;
-	}
-
-	if ($layout->widget_custom_output) {
-		$noheaders = true;
-	}
-
-	if ($noheaders) {
-		$html_output = $layout->html_output;
+	} else {
+		$noheaders  = false;	
+	}
+
+	if ( $noheaders || $layout->widget_custom_output) {
+		$html_output = $aiki->Output->custom_output($layout->html_output);
 	} else {   
-		$html_output = $aiki->Output->headers($layout->widgets_css, $layout->head_output);
-		
+		$html_output = $aiki->Output->header($layout->widgets_css, $layout->head_output);		
 		$layout->html_output = str_replace(
 				'[page_title]', 
 				$aiki->Output->get_title(),
-				$layout->html_output);
-		
-		$html_output .= $layout->html_output;
-		$html_output .= $aiki->Output->footer();
+				$layout->html_output);		
+		$html_output .= $aiki->Output->body($layout->html_output);
+		$html_output .= $aiki->Output->end();
 	} 
 
 	$html_output = $aiki->languages->L10n($html_output);

=== modified file 'libs/Output.php'
--- libs/Output.php	2012-02-11 23:22:55 +0000
+++ libs/Output.php	2012-02-12 18:22:16 +0000
@@ -200,20 +200,19 @@
 		 * don't change the direction if the page is the admin panel on /admin
 		 * @todo instance of where admin and rest of code needs separation
 		 */
-		if ( isset($_GET["pretty"]) && $_GET["pretty"] == 'admin' ) {
-			$aiki->languages->language = "en";
-			$aiki->languages->dir = "ltr";
+		if ( isset($_GET["pretty"]) && $_GET["pretty"] == 'admin') {
+			$lang = "en";
+			$dir  = "ltr";
+		} else {
+			$lang =  $aiki->site->language();
+			$dir  =  $aiki->languages->dir;
 		}
-		$lang=  $aiki->site->language();
-		$dir =  $aiki->languages->dir;
 
-        $header  = "<!doctype html>\n";
-		$aiki->Plugins->doAction("output_doctype_begin", $header);
-        $html = "<html lang='$lang' dir='$dir'>\n";
-		$aiki->Plugins->doAction("output_html_begin", $html);
-        $header .= $html;
-		 
-		return $header;
+        $html  = "<!doctype html>\n".
+				 "<html lang='$lang' dir='$dir'>\n";
+		$aiki->Plugins->doAction("output_doctype", $html);
+         
+		return $html;
 	} // end of doctype function
 
 
@@ -233,20 +232,22 @@
 	 * @todo the html hardcoded in here needs abstraction and shouldn't make
 	 * assumptions about setup
 	 */
-	public function headers( $css, $aditionalHeader) {
+	public function header ( $css, $aditionalHeader) {
 		global $aiki, $db, $config;
-		
-        $header = '';
-		$aiki->Plugins->doAction("output_begin", $header);
-		$header = $this->doctype();
-		$head_tag = '<head>';
-		$aiki->Plugins->doAction("output_head_begin", $head_tag);
-        $header .= $head_tag;
-		$header .= $this->title_and_metas();
+		     
+		$output="";
+		$aiki->Plugins->doAction("output_begin", $output);
+		
+		$doctype = $this->doctype(); 
+		
+		$headStart = '<head>';
+		$aiki->Plugins->doAction("output_head_begin", $headStart);
+		
+		$head = $this->title_and_metas();
 						
 		if (is_array($css) && count($css)) {			
 			$view = $aiki->site->view();// comodity
-			$header .= sprintf(
+			$head .= sprintf(
 				'<link rel="stylesheet" type="text/css" ' .
 				' href="%sstyle.php?site=%s&amp;%swidgets=%s&amp;language=%s" />' . "\n",
 				config("url"),
@@ -255,42 +256,71 @@
 				implode("_", $css),
 				$aiki->site->language() );
 		}			
-        $header .= $this->favicon();
-		
-	
+        $head .= $this->favicon();
+
 		if ( !is_null($aditionalHeader) ){
-			$header .= $aditionalHeader;
+			$head .= $aditionalHeader;
 		}
 
-		$header .= $this->headers;
-		$head_tag_close = "</head>";
-        // Yes, the next two are the same.
-		$aiki->Plugins->doAction("output_head_end", $head_tag_close);
-        $header .= $head_tag_close;
+		$head .= $this->headers;
+		
+		$headEnd = "</head>";
+		$aiki->Plugins->doAction("output_head_end", $headEnd);
+		
+        $head = $output.$doctype.$headStart.$head.$headEnd;
+		$aiki->Plugins->doAction("output_head", $head);        		
+        		
+        return $head;
+	}			
+	
+	
+	/**
+	 * Returns body for output.
+	 *
+	 * @return	string
+	 *
+	 */
 				
-		$bodybegin = "\n<body>\n";
-		$aiki->Plugins->doAction("output_body_begin", $bodybegin);
-		$header .= $bodybegin;
-		
-		return $header;
+	public function body( $bodyHTML, $bodyTag=true)	{			
+		global $aiki;
+		$bodyStart =  ( $bodyTag ? "\n<body>\n" :"" );
+		$aiki->Plugins->doAction("output_body_begin", $bodyStart);
+		
+		$bodyEnd = ( $bodyTag ? "\n</body>" :"");
+		$aiki->Plugins->doAction("output_body_end", $bodyEnd);
+		
+		$body = $bodyStart.$bodyHTML.$bodyEnd;
+		$aiki->Plugins->doAction("output_body", $body);
+						
+		return $body;
+		
 	} // end of headers function
 
 
+	public function custom_output($output){
+		global $aiki;
+		$begin="";
+		$end="";			
+		$aiki->Plugins->doAction("output_begin", $end);
+		$aiki->Plugins->doAction("output_custom", $output);
+		$aiki->Plugins->doAction("output_end", $end);
+		return $begin.$output.$end; 
+	}
+
 	/**
-	 * Returns a footer for output.
+	 * Returns end of output ( a /html )
 	 *
 	 * @return	string
 	 *
 	 */
-	public function footer() {
+
+	public function end(){
 		global $aiki;
-		$footer = "\n</body>";
-		$aiki->Plugins->doAction("output_body_end", $footer);
-		$html= "</html>";
-		$aiki->Plugins->doAction("output_html_end", $html);
-		return $footer.$html;
+		$end= "</html>";		
+		$aiki->Plugins->doAction("output_end", $end);
+		return $end; 
 	}
-
+	
 
 	/**
 	 * Returns an formatted table from a widget. An autoformatted widget.

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to