Initial import of old legacy Zynapse Framework,

untouched since early 2008.
This commit is contained in:
2010-02-25 00:16:53 +02:00
commit 45aceab6b5
100 changed files with 7685 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<?php
class AdminController extends ApplicationController {
function index () {
echo ' controller called ';
}
function view () {
$this->render_layout = false;
echo ' controller called ';
}
}
?>

View File

@@ -0,0 +1,8 @@
<?php
class ApplicationController extends ActionController {
}
?>

View File

@@ -0,0 +1,65 @@
<?php
class PageController extends ApplicationController {
function index ($vars) {
// page view count
if ( isset($_REQUEST['kill']) ) {
unset($_SESSION['views']);
$this->redirect_to('back');
}
@$_SESSION['views']++;
$this->views = $_SESSION['views'];
// new Page object experiments
// $newpage = new Page();
// $newpage->id = 8;
// $newpage->title = 'anything else';
// $newpage->body = '...maybe not...';
// $newpage->get_association('person');
// $newpage->error_title = 'error message'; // define errors
// print_r($newpage);
// $newpage->save();
// echo $newpage->build_update_query($newpage)."\n<br />";
// $newpage->delete_all('`id` > 11');
// get page list
$page = new Page();
$this->columns = $page->_columns;
$this->pages = $page->find_all();
// App::$prefs->yay = 'hello';
// unset(App::$prefs->yay);
// App::$prefs->save();
// print_r(Znap::$prefs);
// print_r($this->page);
// print_r(Page::$table_info);
// print_r($this->page->_columns);
}
function view () {
if ( isset($_REQUEST['id']) ) {
$page = new Page();
$this->columns = $page->_columns;
$this->page = $page->find($_REQUEST['id']);
}
}
function edit () {
}
}
?>

View File

@@ -0,0 +1,11 @@
<?php
class SnippetTestingController extends ApplicationController {
function index () {
}
}
?>

View File

@@ -0,0 +1,5 @@
<?php
?>

View File

@@ -0,0 +1,5 @@
<?php
?>

View File

@@ -0,0 +1,4 @@
<?php
# Anything added to this helper will be available to all views in the TestSnippet.
?>

View File

@@ -0,0 +1,4 @@
<?php
# Anything added to this helper will be available to all views in the SnippetTestingController.
?>

9
app/models/category.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
class Category extends ActiveRecord {
public $has_and_belongs_to_many = 'pages';
}
?>

10
app/models/comment.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
class Comment extends ActiveRecord {
public $belongs_to = 'page';
public $counter_cache = true;
}
?>

41
app/models/page.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
class Page extends ActiveRecord {
public $has_many = 'comments';
public $has_and_belongs_to_many = 'categories';
// public $has_many = array(
// 'comments' => array(
// 'class_name' => 'Comment',
// 'foreign_key' => 'page_id',
// 'conditions' => array('is_public' => 1),
// ),
// );
// public $table_name = 'whatever';
// public $primary_key = 'id';
// public $type = 'mysql';
// public $host = 'db.domain.com';
// public $database = 'librarious_db';
// public $username = 'root';
// public $password = '';
// public $persistent = false;
// public $table_prefix = 'znap_';
// public $table_name = 'collection';
function validate_title () {
if ( $this->title == '' ) {
$this->error_title = 'Title can not be empty.';
}
}
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/*
Zynapse Preference Class
This class is used to store preferences, it is humanly editable
and requires no overhead processing to be loaded.
*/
class _internals_preferences extends PreferenceContainer {
public $js_url;
public $js_libs_url;
public $js_libs;
public $js_charset;
function __construct () {
parent::__construct();
$this->js_url = "/javascripts";
$this->js_libs_url = "/javascripts/libs";
$this->js_libs = array(
'jquery' => "jquery-1.2.1.pack.js",
);
$this->js_charset = "utf-8";
}
}
?>

View File

@@ -0,0 +1,23 @@
<?php
/*
Zynapse Preference Class
This class is used to store preferences, it is humanly editable
and requires no overhead processing to be loaded.
*/
class application_preferences extends PreferenceContainer {
public $language;
function __construct () {
parent::__construct();
$this->language = "english";
}
}
?>

View File

@@ -0,0 +1,8 @@
<?php
class Snippets extends SnippetController {
}
?>

View File

@@ -0,0 +1,16 @@
<?php
class TestSnippet extends Snippets {
function index () {
$this->message = 'hello world';
}
function wiiee () {
$this->message = 'helppppp';
$this->render_action = 'index';
}
}
?>

View File

View File

View File

@@ -0,0 +1,3 @@
<div id="navpane" style="border: 1px solid">
navpane here
</div>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo App::$strings['_ZNAP_LANG']; ?>" lang="<?php echo App::$strings['_ZNAP_LANG']; ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo App::$strings['_ZNAP_ENCODING']; ?>"/>
<title>application</title>
</head>
<body>
<?php render_partial('navpane'); ?>
<?php if(Session::isset_flash('error')): ?>
<div style="color: red;"><?php echo Session::flash('error') ?></div>
<?php elseif(Session::isset_flash('notice')): ?>
<div style="color: green;"><?php echo Session::flash('notice') ?></div>
<?php endif; ?>
<?php echo $content_for_layout; ?>
<?php if (Timer::$started): ?>
<div id="timer">
<?php echo Timer::end(5);?>
</div>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo App::$strings['_ZNAP_LANG']; ?>" lang="<?php echo App::$strings['_ZNAP_LANG']; ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo App::$strings['_ZNAP_ENCODING']; ?>"/>
<title>page</title>
</head>
<body>
<?php render_partial('navpane'); ?>
<?php if(Session::isset_flash('error')): ?>
<div style="color: red;"><?php echo Session::flash('error') ?></div>
<?php elseif(Session::isset_flash('notice')): ?>
<div style="color: green;"><?php echo Session::flash('notice') ?></div>
<?php endif; ?>
<?php echo $content_for_layout; ?>
<br />
<br />
<?php if (Timer::$started): ?>
<?php echo Timer::end(5); ?>
<?php endif; ?>
<pre>
<?php print_r(ActiveRecord::$query_log); ?>
</pre>
</body>
</html>

View File

@@ -0,0 +1 @@
<?php echo $content_for_layout; ?>

View File

@@ -0,0 +1 @@
<?php echo $message ?> :)

View File

View File

View File

@@ -0,0 +1,5 @@
<div style="comment">
<?php echo $comment['body']; ?><br />
<h6 style="margin: 0px;">&nbsp;&nbsp;&nbsp;<?php echo $comment['name']?> <?php if (!empty($comment['email'])) echo '('.$comment['email'].')'; ?></h6>
</div>
<hr />

View File

@@ -0,0 +1,9 @@
<tr>
<?php foreach ($page_list_item as $key => $value): ?>
<?php if ($key == 'title'): ?>
<td><a href="/page/<?php echo $page_list_item['id']?>"><?php echo $value; ?></td>
<?php else: ?>
<td><?php echo $value; ?></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>

View File

@@ -0,0 +1,16 @@
hello world!<br />
<br />
you've seen this page <?php echo $views ?> time<?php if ($views > 1) echo 's'; ?>. <a href="?kill=yes">reset</a>
<?php if ( isset($pages) && count($pages) ): ?>
<table border="1" cellspacing="0" cellpadding="2">
<tr>
<?php foreach ($columns as $column => $col_info): ?>
<th><?php echo $col_info['HumanName']; ?></th>
<?php endforeach; ?>
</tr>
<?php render_partial('page_list_item', $pages); ?>
</table>
<?php endif; ?>

28
app/views/page/view.phtml Normal file
View File

@@ -0,0 +1,28 @@
<?php if (isset($page)): ?>
<?php foreach ($page as $key => $value): if (array_key_exists($key, $columns)): ?>
<b><?php echo $key; ?>:</b> <?php echo $value; ?><br />
<?php endif; endforeach; ?>
<?php if ( $page->categories ): ?>
<b>Categories:</b> <?php
$cats = array();
foreach ($page->categories as $category) {
$cats[] = $category['name'];
}
echo implode(', ', $cats);
?>
<?php endif; ?>
<br />
<br />
<b>Comments:</b><br />
<hr />
<?php if ( $page->comments ): ?>
<?php render_partial('comment', $page->comments); ?>
<?php else: ?>
- No Comments -<br />
<hr />
<?php endif; ?>
<?php else: ?>
The page you're trying to view doesn't exist.
<?php endif; ?>

View File

@@ -0,0 +1,4 @@
testing a snippet here:
<div id="snippet">
<?php render_snippet('test') ?>
</div>