------------------------------------------------------------
revno: 1204
committer: Jakub Jankiewicz <[email protected]>
branch nick: aikiframework
timestamp: Tue 2012-05-29 15:07:53 +0200
message:
Fix redundant widgets for error 404 when widget have parents
modified:
libs/Engine_aiki.php
libs/Output.php
libs/url.php
libs/widgets.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 'libs/Engine_aiki.php'
--- libs/Engine_aiki.php 2012-05-28 17:55:38 +0000
+++ libs/Engine_aiki.php 2012-05-29 13:07:53 +0000
@@ -134,10 +134,10 @@
$this->widget_custom_output = true;
}
- if ( $widget->custom_header && $widget->custom_header != '' ) {
+ if ($widget->custom_header && $widget->custom_header != '') {
$custom_headers = explode("\n", $widget->custom_header);
foreach ($custom_headers as $custom_header) {
- if ( $custom_header != "" ) {
+ if ($custom_header != "") {
header($custom_header);
}
}
=== modified file 'libs/Output.php'
--- libs/Output.php 2012-05-28 17:55:38 +0000
+++ libs/Output.php 2012-05-29 13:07:53 +0000
@@ -232,7 +232,7 @@
* @todo the html hardcoded in here needs abstraction and shouldn't make
* assumptions about setup
*/
- public function header( $css, $aditionalHeader) {
+ public function header($css, $aditionalHeader) {
global $aiki, $db, $config;
$output="";
@@ -322,6 +322,7 @@
private function get_output_no_globals($target) {
$content = '';
foreach ($target as $item) {
+ // $item[1] is set when display_url is *
if (!$item[1]) {
$content .= $item[0];
}
@@ -331,7 +332,8 @@
public function custom_output($engine){
global $aiki;
- // @TODO will this work for images output (or a plugin)
+ // TODO: will this work for images output (or a plugin)
+ // TODO: begin and end look like not in use
$begin="";
$end="";
$aiki->Plugins->doAction("output_begin", $begin);
=== modified file 'libs/url.php'
--- libs/url.php 2012-03-15 19:34:10 +0000
+++ libs/url.php 2012-05-29 13:07:53 +0000
@@ -111,9 +111,9 @@
public function set_404(){
- $this->url= array("error_404");
- $this->pretty="error_404";
- $this->url_count = count($this->url);
+ $this->url = array("error_404");
+ $this->pretty = "error_404";
+ $this->url_count = count($this->url);
}
public function get_original_url(){
=== modified file 'libs/widgets.php'
--- libs/widgets.php 2012-05-28 17:55:38 +0000
+++ libs/widgets.php 2012-05-29 13:07:53 +0000
@@ -76,6 +76,8 @@
* return widget that responds a error_404 page.
*
* @return array of id
+ *
+ * TODO: remove this function
*/
function get_page_not_found_widgets() {
@@ -108,7 +110,7 @@
/**
* lookup a widget by id or name
*
- * @param mixed v$widgetNameOrId Widget name or id.
+ * @param mixed $widgetNameOrId Widget name or id.
* @return integer widget_ir
*/
@@ -157,63 +159,74 @@
*/
function render_site($engine) {
- global $aiki;
-
- // the widget is given directly or
- if (isset($_GET["widget"])) {
- $widget= $this->get_widget($_GET["widget"]);
- if (is_null($widget)) {
- $content= __sprintf("No valid widget %s", strip_tags($_GET["widget"]));
- } else {
- $content = $engine->parseWidget($widget);
- }
-
- if ($content !== false) {
- if (is_array($content)){
- $engine->target[$widget->widget_target][] =
- array($content[0].$content[1], false);
- } else {
- $engine->target[$widget->widget_target][] =
- array($content, false);
- }
- }
- return;
- }
-
- // or in url,
- // search widget and test there is a unique response
- $module_widgets = $this->get_candidate_widgets();
- $unique_widget_exists = false;
- if ($module_widgets) {
- foreach($module_widgets as $tested_widget){
- if ($tested_widget->display_urls != "*"){
- $unique_widget_exists = true;
- break;
- }
- }
- }
-
- // Error 404 page not found
- if (!$unique_widget_exists) {
- // first look for widget that responds error_404,
- // else use config error_404.
- $module_widgets= $aiki->widgets->get_Page_Not_Found_Widgets();
- if (!is_null($module_widgets)) {
- $aiki->Errors->pageNotFound(false);
- $aiki->url->set_404();
- } else {
- $engine->target["body"][] =
- array($aiki->Errors->pageNotFound(true), false);
- return;
- }
-
- }
-
- foreach ($module_widgets as $parent) {
- $this->render_widget($engine, $parent, 0);
- }
-
- return true;
+ global $aiki;
+
+ // the widget is given directly or
+ if (isset($_GET["widget"])) {
+ $widget= $this->get_widget($_GET["widget"]);
+ if (is_null($widget)) {
+ $content= __sprintf("No valid widget %s", strip_tags($_GET["widget"]));
+ } else {
+ $content = $engine->parseWidget($widget);
+ }
+
+ if ($content !== false) {
+ if (is_array($content)){
+ $engine->target[$widget->widget_target][] =
+ array($content[0].$content[1], false);
+ } else {
+ $engine->target[$widget->widget_target][] =
+ array($content, false);
+ }
+ }
+ return;
+ }
+
+ // or in url,
+ // search widget and test there is a unique response
+ $module_widgets = $this->get_candidate_widgets();
+ $unique_widget_exists = false;
+ if ($module_widgets) {
+ foreach($module_widgets as $tested_widget){
+ if ($tested_widget->display_urls != "*"){
+ $unique_widget_exists = true;
+ break;
+ }
+ }
+ }
+
+ // Error 404 page not found
+ if (!$unique_widget_exists) {
+ // first look for widget that responds error_404,
+ // else use config error_404.
+ $aiki->url->set_404();
+ $module_widgets = $this->get_candidate_widgets();
+ if (!is_null($module_widgets)) {
+ $aiki->Errors->pageNotFound(false);
+ } else {
+ $engine->target["body"][] =
+ array($aiki->Errors->pageNotFound(true), false);
+ return;
+ }
+ /*
+ $module_widgets = $aiki->widgets->get_Page_Not_Found_Widgets();
+ if (!is_null($module_widgets)) {
+ //$aiki->Errors->pageNotFound(false);
+ $aiki->url->set_404();
+
+ } else {
+ $engine->target["body"][] =
+ array($aiki->Errors->pageNotFound(true), false);
+ return;
+ }
+ */
+ }
+
+ foreach ($module_widgets as $parent) {
+ $this->render_widget($engine, $parent, 0);
+ }
+
+ return true;
}
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help : https://help.launchpad.net/ListHelp