aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--App.php2
-rw-r--r--Controller.php6
-rw-r--r--README4
-rw-r--r--View.php68
4 files changed, 75 insertions, 5 deletions
diff --git a/App.php b/App.php
index 803aa27..1c45735 100644
--- a/App.php
+++ b/App.php
@@ -121,8 +121,6 @@ class App
static function error($msg)
{
$err = array('result' => 'error', 'msg' => $msg);
- // Send error to client
- self::json($msg);
// And log it locally
self::log($msg);
}
diff --git a/Controller.php b/Controller.php
index 458d3a3..5e14f4b 100644
--- a/Controller.php
+++ b/Controller.php
@@ -31,7 +31,10 @@ class Controller
if ($id) {
return $this->get($id);
}
+
+ $this->view = new MainView();
return $this;
+
}
/**
@@ -349,8 +352,9 @@ class Controller
$tpl_contents = ob_get_contents();
ob_end_clean();
+ $title = ($this->pageTitle) ? $this->pageTitle : App::conf("defaults.title");
$tpl_contents = preg_replace(
- '/<title>.*?<\/title>/', "<title>{$this->pageTitle}</title>", $tpl_contents
+ '/<title>.*?<\/title>/', "<title>{$title}</title>", $tpl_contents
);
echo str_replace('%%page_content%%', $view_contents, $tpl_contents);
diff --git a/README b/README
index e511e1a..552e770 100644
--- a/README
+++ b/README
@@ -15,11 +15,11 @@ site:
## index.php ##
-A typical index.php using MAIN would look like this:
+A typical index.php using Main would look like this:
<?php
$sysdir = realpath(dirname(__FILE__).'/../system');
-
+ np
set_include_path(
get_include_path() . PATH_SEPARATOR
. $sysdir . PATH_SEPARATOR
diff --git a/View.php b/View.php
new file mode 100644
index 0000000..762d75b
--- /dev/null
+++ b/View.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * main/MainView.php
+ * @created 31.10.2009
+ * @author Filipp Lepalaan <filipp@mac.com>
+ */
+class MainView
+{
+ /**
+ * Create HTML <select> options from array
+ * @param array array
+ * @param mixed select option with this value
+ * @return string
+ */
+ function select($array, $current = null)
+ {
+ $out = '';
+
+ foreach ($array as $k => $v) {
+ $sel = ($k == $current) ? ' selected="selected" ' : '';
+ $out .= "<option value=\"{$k}\"{$sel}>{$v}</option>\n\t";
+ }
+
+ return $out;
+
+ }
+
+ function tag($name, $args = '', $content = '', $selected = '')
+ {
+ $str_args = '';
+ $out = '<' . $name;
+
+ // special treatment for certain tags
+ switch ($name)
+ {
+ case 'form':
+ break;
+ case 'img':
+ if (empty ($args['alt'])) $args['alt'] = 'Image';
+ break;
+ }
+
+ if (is_array ($args))
+ {
+ while (list ($k, $v) = each ($args)) {
+ if (!empty ($k)) $str_args .= ' ' . $k . '="' . $v . '"';
+ }
+ }
+
+ if (is_array ($content))
+ {
+ foreach ($content as $k => $v)
+ {
+ //
+ }
+ } else {
+ //
+ }
+
+ if (empty ($content)) return $out . $str_args . ' />';
+
+ return "{$out}{$str_args}>{$content}</{$name}>\n";
+
+ }
+
+}
+
+?> \ No newline at end of file