mirror of
https://github.com/jimeh/zynapse.git
synced 2026-02-19 07:06:39 +00:00
Initial import of old legacy Zynapse Framework,
untouched since early 2008.
This commit is contained in:
16
app/controllers/admin/admin_controller.php
Normal file
16
app/controllers/admin/admin_controller.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class AdminController extends ApplicationController {
|
||||||
|
|
||||||
|
function index () {
|
||||||
|
echo ' controller called ';
|
||||||
|
}
|
||||||
|
|
||||||
|
function view () {
|
||||||
|
$this->render_layout = false;
|
||||||
|
echo ' controller called ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
8
app/controllers/application.php
Normal file
8
app/controllers/application.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationController extends ActionController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
65
app/controllers/page_controller.php
Normal file
65
app/controllers/page_controller.php
Normal 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 () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
11
app/controllers/snippet_testing_controller.php
Normal file
11
app/controllers/snippet_testing_controller.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SnippetTestingController extends ApplicationController {
|
||||||
|
|
||||||
|
function index () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
5
app/helpers/application_helper.php
Normal file
5
app/helpers/application_helper.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
5
app/helpers/snippet_helpers/snippets_helper.php
Normal file
5
app/helpers/snippet_helpers/snippets_helper.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
4
app/helpers/snippet_helpers/test_helper.php
Normal file
4
app/helpers/snippet_helpers/test_helper.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
# Anything added to this helper will be available to all views in the TestSnippet.
|
||||||
|
|
||||||
|
?>
|
||||||
4
app/helpers/snippet_testing_helper.php
Normal file
4
app/helpers/snippet_testing_helper.php
Normal 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
9
app/models/category.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Category extends ActiveRecord {
|
||||||
|
|
||||||
|
public $has_and_belongs_to_many = 'pages';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
10
app/models/comment.php
Normal file
10
app/models/comment.php
Normal 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
41
app/models/page.php
Normal 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.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
31
app/preferences/_internals.prefs.php
Normal file
31
app/preferences/_internals.prefs.php
Normal 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
23
app/preferences/application.prefs.php
Normal file
23
app/preferences/application.prefs.php
Normal 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
8
app/snippets/snippets.php
Normal file
8
app/snippets/snippets.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class Snippets extends SnippetController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
16
app/snippets/test_snippet.php
Normal file
16
app/snippets/test_snippet.php
Normal 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';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
0
app/views-wap/__layouts/.emptydir
Normal file
0
app/views-wap/__layouts/.emptydir
Normal file
0
app/views-wap/__snippets/.emptydir
Normal file
0
app/views-wap/__snippets/.emptydir
Normal file
3
app/views/__layouts/_navpane.phtml
Normal file
3
app/views/__layouts/_navpane.phtml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div id="navpane" style="border: 1px solid">
|
||||||
|
navpane here
|
||||||
|
</div>
|
||||||
31
app/views/__layouts/application.phtml
Normal file
31
app/views/__layouts/application.phtml
Normal 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>
|
||||||
34
app/views/__layouts/page.phtml
Normal file
34
app/views/__layouts/page.phtml
Normal 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>
|
||||||
1
app/views/__snippets/__layouts/snippets.phtml
Normal file
1
app/views/__snippets/__layouts/snippets.phtml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?php echo $content_for_layout; ?>
|
||||||
1
app/views/__snippets/test/index.phtml
Normal file
1
app/views/__snippets/test/index.phtml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?php echo $message ?> :)
|
||||||
0
app/views/_admin/admin/index.phtml
Normal file
0
app/views/_admin/admin/index.phtml
Normal file
0
app/views/_admin/admin/view.phtml
Normal file
0
app/views/_admin/admin/view.phtml
Normal file
5
app/views/page/_comment.phtml
Normal file
5
app/views/page/_comment.phtml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div style="comment">
|
||||||
|
<?php echo $comment['body']; ?><br />
|
||||||
|
<h6 style="margin: 0px;"> — <?php echo $comment['name']?> <?php if (!empty($comment['email'])) echo '('.$comment['email'].')'; ?></h6>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
9
app/views/page/_page_list_item.phtml
Normal file
9
app/views/page/_page_list_item.phtml
Normal 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>
|
||||||
16
app/views/page/index.phtml
Normal file
16
app/views/page/index.phtml
Normal 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
28
app/views/page/view.phtml
Normal 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; ?>
|
||||||
4
app/views/snippet_testing/index.phtml
Normal file
4
app/views/snippet_testing/index.phtml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
testing a snippet here:
|
||||||
|
<div id="snippet">
|
||||||
|
<?php render_snippet('test') ?>
|
||||||
|
</div>
|
||||||
103
config/boot.php
Normal file
103
config/boot.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Boot
|
||||||
|
- final base setup and zynapse initialization
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// include required environment setup
|
||||||
|
require_once(dirname(__FILE__).'/environment.php');
|
||||||
|
|
||||||
|
|
||||||
|
// include shell script enviroment settings
|
||||||
|
if ( defined('ZNAP_SHELL_SCRIPT') && is_file(dirname(__FILE__).'/environments/_shell.php') ) {
|
||||||
|
require_once(dirname(__FILE__).'/environments/_shell.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set zynapse root path
|
||||||
|
if ( !defined('ZNAP_ROOT') ) {
|
||||||
|
define('ZNAP_ROOT', dirname(dirname(__FILE__)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find zynapse libs
|
||||||
|
if ( !empty($zynapse_libs) && is_file($zynapse_libs.'/zynapse.php') ) {
|
||||||
|
define('ZNAP_LIB_ROOT', $zynapse_libs);
|
||||||
|
} elseif ( is_file(ZNAP_ROOT.'/vendor/zynapse/zynapse.php') ) {
|
||||||
|
define('ZNAP_LIB_ROOT', ZNAP_ROOT.'/vendor/zynapse');
|
||||||
|
} elseif ( is_file(dirname(ZNAP_ROOT).'/vendor/zynapse/zynapse.php') ) {
|
||||||
|
define('ZNAP_LIB_ROOT', dirname(ZNAP_ROOT).'/vendor/zynapse');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// figure out environment related settings
|
||||||
|
if ( defined('ZNAP_SHELL_SCRIPT') ) {
|
||||||
|
$environment = $shell_environment;
|
||||||
|
} elseif ( !empty($_SERVER['ZNAP_ENV']) ) {
|
||||||
|
$environment = $_SERVER['ZNAP_ENV'];
|
||||||
|
} elseif ( $enable_advanced_host_config == true && ($current_config = match_host($host_config)) !== false ) {
|
||||||
|
if ( !empty($current_config['environment']) ) $environment = $current_config['environment'];
|
||||||
|
if ( !empty($current_config['mode']) ) $mode = $current_config['mode'];
|
||||||
|
if ( !empty($current_config['root']) ) {
|
||||||
|
if ( !empty($_SERVER['REQUEST_URI']) ) $_SERVER['REQUEST_URI'] = '/'.$current_config['root'].$_SERVER['REQUEST_URI'];
|
||||||
|
if ( !empty($_SERVER['REDIRECT_URL']) ) $_SERVER['REDIRECT_URL'] = '/'.$current_config['root'].$_SERVER['REDIRECT_URL'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// define environment and display mode
|
||||||
|
define('ZNAP_ENV', $environment);
|
||||||
|
define('ZNAP_MODE', $mode);
|
||||||
|
|
||||||
|
|
||||||
|
// include environment specific settings
|
||||||
|
if ( is_file(dirname(__FILE__).'/environments/'.ZNAP_ENV.'.php') ) {
|
||||||
|
include_once(dirname(__FILE__).'/environments/'.ZNAP_ENV.'.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set url prefix if needed
|
||||||
|
if ( !empty($url_prefix) ) {
|
||||||
|
define('URL_PREFIX', $url_prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// php error logging
|
||||||
|
define('ZNAP_ENABLE_LOGGING', $enable_logging);
|
||||||
|
define('ZNAP_INTERNAL_LOGGING', $internal_logging);
|
||||||
|
|
||||||
|
|
||||||
|
// include and initialize main zynapse class
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/zynapse.php');
|
||||||
|
Znap::initialize();
|
||||||
|
if ( !empty($timer_enabled) || ZNAP_ENV != 'production' ) {
|
||||||
|
Znap::start_timer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// function to get all matched host settings
|
||||||
|
function match_host ($list = array()) {
|
||||||
|
if ( is_array($list) && !empty($list) ) {
|
||||||
|
$new_config = array();
|
||||||
|
foreach( $list as $host => $settings ) {
|
||||||
|
$regex = preg_quote($host, '/');
|
||||||
|
$regex = str_replace('\*', '.*', $regex);
|
||||||
|
$http_host = (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST'] ;
|
||||||
|
if ( preg_match('/^'.$regex.'$/i', $http_host) ) {
|
||||||
|
foreach( $settings as $key => $value ) {
|
||||||
|
if ( !array_key_exists($key, $new_config) ) {
|
||||||
|
$new_config[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (!empty($new_config)) ? $new_config : false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
40
config/database.php
Normal file
40
config/database.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Database configuration
|
||||||
|
- only mysql is supported at this time
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$database_settings = array(
|
||||||
|
|
||||||
|
// database settings for development environment
|
||||||
|
'development' => array(
|
||||||
|
'host' => 'localhost',
|
||||||
|
'database' => 'zynapse_development',
|
||||||
|
'username' => 'devuser',
|
||||||
|
'password' => 'devpass',
|
||||||
|
'persistent' => true,
|
||||||
|
'table_prefix' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
// database settings for testing environment
|
||||||
|
'test' => array(
|
||||||
|
'use' => 'development',
|
||||||
|
),
|
||||||
|
|
||||||
|
// database settings for production environment
|
||||||
|
'production' => array(
|
||||||
|
'host' => 'localhost',
|
||||||
|
'database' => 'database_name',
|
||||||
|
'username' => 'user',
|
||||||
|
'password' => 'password',
|
||||||
|
'persistent' => true,
|
||||||
|
'table_prefix' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
72
config/environment.php
Normal file
72
config/environment.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Environment
|
||||||
|
- configure server environments and display modes
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# default environment - overridden by $host_config
|
||||||
|
# ( development | test | production )
|
||||||
|
$environment = 'development';
|
||||||
|
|
||||||
|
|
||||||
|
# default server display mode - overridden by $host_config
|
||||||
|
$mode = 'web';
|
||||||
|
|
||||||
|
|
||||||
|
# if you don't need any of the advanced host-specific
|
||||||
|
# configuration features, you can disable it as it becomes
|
||||||
|
# excess code which you don't need.
|
||||||
|
$enable_advanced_host_config = true;
|
||||||
|
|
||||||
|
|
||||||
|
# host configuration
|
||||||
|
# - set environment, display mode, and root path for
|
||||||
|
# specific hosts. available options are "environment",
|
||||||
|
# "mode", and "root".
|
||||||
|
$host_config = array(
|
||||||
|
// 'zynapse' => array(
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// 'wap.zynapse' => array(
|
||||||
|
// 'mode' => 'wap',
|
||||||
|
// ),
|
||||||
|
// 'admin.zynapse' => array(
|
||||||
|
// 'root' => 'admin',
|
||||||
|
// ),
|
||||||
|
// 'zynapse.org' => array(
|
||||||
|
// 'environment' => 'production',
|
||||||
|
// ),
|
||||||
|
// 'admin.zynapse.org' => array(
|
||||||
|
// 'environment' => 'production',
|
||||||
|
// 'root' => 'admin',
|
||||||
|
// ),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
# set custom path to zynapse libs
|
||||||
|
$zynapse_libs = '';
|
||||||
|
|
||||||
|
|
||||||
|
# Timer enabled in production environment?
|
||||||
|
# - its always enabled in development and test environments
|
||||||
|
$timer_enabled = false;
|
||||||
|
|
||||||
|
|
||||||
|
# enable php error logging? - recommended
|
||||||
|
$enable_logging = true;
|
||||||
|
|
||||||
|
# enable internal error logging? - recommended
|
||||||
|
$internal_logging = true;
|
||||||
|
|
||||||
|
|
||||||
|
# if zynapse's root is not the root of the server, define
|
||||||
|
# the prefix path (without leading or trailing slashes).
|
||||||
|
$url_prefix = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
14
config/environments/_shell.php
Normal file
14
config/environments/_shell.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Shell Script Environment
|
||||||
|
- environment settings use by generate, migrate and other shell scripts
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
# environment used by the shell scripts, modify accordingly to
|
||||||
|
# the current environment the code is in
|
||||||
|
# ( development | test | production )
|
||||||
|
$shell_environment = 'development';
|
||||||
|
|
||||||
|
?>
|
||||||
7
config/environments/development.php
Normal file
7
config/environments/development.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Development Environment Settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
7
config/environments/production.php
Normal file
7
config/environments/production.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Production Environment Settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
7
config/environments/test.php
Normal file
7
config/environments/test.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test Environment Settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
21
config/routes.php
Normal file
21
config/routes.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Routes
|
||||||
|
- configure access urls
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// $router->connect('', array(':controller'=>'page'));
|
||||||
|
$router->connect( 'page/:id([0-9]+)', array(':controller' => 'page', ':action' => 'view', 'test' => 'wiiee') );
|
||||||
|
$router->connect( ':controller/:action/:id/:sort/:order' );
|
||||||
|
|
||||||
|
$router->connect( 'pages', array(':redirect_to' => '/page') );
|
||||||
|
|
||||||
|
|
||||||
|
// default route
|
||||||
|
$router->connect( ':controller/:action/:id' );
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
18
config/strings/_global.php
Normal file
18
config/strings/_global.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Global Strings
|
||||||
|
- language independent strings accessible directly from the
|
||||||
|
point that Znap::initialize() is called
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$strings = array(
|
||||||
|
|
||||||
|
|
||||||
|
// 'my_string' => 'some awesome text',
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
||||||
46
config/strings/english.php
Normal file
46
config/strings/english.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
English Strings
|
||||||
|
- default language strings
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$strings = array(
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Required Strings
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
# local name ("Svenska" for Swedish for example)
|
||||||
|
'_ZNAP_LANGUAGE' => 'English',
|
||||||
|
|
||||||
|
# short language name
|
||||||
|
'_ZNAP_LANG' => 'en',
|
||||||
|
|
||||||
|
# language locale values
|
||||||
|
'_ZNAP_LOCALE' => array('eng', 'en_US'),
|
||||||
|
|
||||||
|
# character encoding
|
||||||
|
'_ZNAP_ENCODING' => 'utf-8',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Custom Strings
|
||||||
|
- add your custom strings here
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 'my_string' => 'some awesome text',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
||||||
98
db/zynapse_development.sql
Normal file
98
db/zynapse_development.sql
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# Sequel Pro dump
|
||||||
|
# Version 254
|
||||||
|
# http://code.google.com/p/sequel-pro
|
||||||
|
#
|
||||||
|
# Host: localhost (MySQL 5.0.67)
|
||||||
|
# Database: reznap_development
|
||||||
|
# Generation Time: 2009-01-02 19:18:43 +0200
|
||||||
|
# ************************************************************
|
||||||
|
|
||||||
|
# Dump of table categories
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `categories`;
|
||||||
|
|
||||||
|
CREATE TABLE `categories` (
|
||||||
|
`id` int(11) NOT NULL auto_increment,
|
||||||
|
`name` varchar(64) NOT NULL,
|
||||||
|
`description` text NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
INSERT INTO `categories` (`id`,`name`,`description`)
|
||||||
|
VALUES
|
||||||
|
(1,'info',''),
|
||||||
|
(2,'stuff','');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Dump of table categories_pages
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `categories_pages`;
|
||||||
|
|
||||||
|
CREATE TABLE `categories_pages` (
|
||||||
|
`id` int(11) NOT NULL auto_increment,
|
||||||
|
`category_id` int(11) NOT NULL,
|
||||||
|
`page_id` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `category_id` (`category_id`),
|
||||||
|
KEY `page_id` (`page_id`)
|
||||||
|
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
INSERT INTO `categories_pages` (`id`,`category_id`,`page_id`)
|
||||||
|
VALUES
|
||||||
|
(1,1,2),
|
||||||
|
(2,2,2),
|
||||||
|
(3,1,1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Dump of table comments
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `comments`;
|
||||||
|
|
||||||
|
CREATE TABLE `comments` (
|
||||||
|
`id` int(11) NOT NULL auto_increment,
|
||||||
|
`name` varchar(64) NOT NULL,
|
||||||
|
`email` varchar(255) NOT NULL,
|
||||||
|
`url` varchar(255) NOT NULL,
|
||||||
|
`body` text NOT NULL,
|
||||||
|
`page_id` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `page_id` (`page_id`)
|
||||||
|
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
INSERT INTO `comments` (`id`,`name`,`email`,`url`,`body`,`page_id`)
|
||||||
|
VALUES
|
||||||
|
(1,'jim','','','fuck this is cool',2),
|
||||||
|
(2,'peter','ithinkicanfly@petrelli.com','','you suck! you really suck!!',2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Dump of table pages
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `pages`;
|
||||||
|
|
||||||
|
CREATE TABLE `pages` (
|
||||||
|
`id` int(11) NOT NULL auto_increment,
|
||||||
|
`title` varchar(64) NOT NULL,
|
||||||
|
`body` text NOT NULL,
|
||||||
|
`created_at` int(11) default NULL,
|
||||||
|
`modified_at` int(11) default NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM AUTO_INCREMENT=42 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
INSERT INTO `pages` (`id`,`title`,`body`,`created_at`,`modified_at`)
|
||||||
|
VALUES
|
||||||
|
(1,'home page','wiiee, this is the HOME page, thingy... kinda... lol!',NULL,NULL),
|
||||||
|
(2,'another page :P','this is yet another page-thingy, this is cool... hehe :D :P',NULL,NULL),
|
||||||
|
(3,'my page','my page is awesome, so awesome :$',NULL,NULL),
|
||||||
|
(4,'iphone','omg omg omg omg O M G ! ! ! !',NULL,NULL),
|
||||||
|
(10,'title','body',NULL,NULL),
|
||||||
|
(11,'anything else','...maybe not...',NULL,NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0
libs/.emptydir
Normal file
0
libs/.emptydir
Normal file
0
logs/development.log
Normal file
0
logs/development.log
Normal file
0
logs/production.log
Normal file
0
logs/production.log
Normal file
0
logs/test.log
Normal file
0
logs/test.log
Normal file
12
public/.htaccess
Normal file
12
public/.htaccess
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
RewriteRule ^.*\.svn.*$ /404
|
||||||
|
|
||||||
|
RewriteRule ^$ index.html [QSA]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !favicon.ico
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !robots.txt
|
||||||
|
RewriteRule ^(.*)$ /dispatch.php [QSA,L]
|
||||||
|
|
||||||
21
public/dispatch.php
Normal file
21
public/dispatch.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Dispatch Zynapse
|
||||||
|
- the first step
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
# path to config directory
|
||||||
|
$znap_config_path = dirname(dirname(__FILE__)).'/config';
|
||||||
|
|
||||||
|
|
||||||
|
// environment setup
|
||||||
|
require_once($znap_config_path.'/boot.php');
|
||||||
|
|
||||||
|
|
||||||
|
// start the junk :D
|
||||||
|
Dispatcher::dispatch();
|
||||||
|
|
||||||
|
?>
|
||||||
0
public/images/.emptydir
Normal file
0
public/images/.emptydir
Normal file
11
public/javascripts/libs/jquery-1.2.1.pack.js
Normal file
11
public/javascripts/libs/jquery-1.2.1.pack.js
Normal file
File diff suppressed because one or more lines are too long
0
public/stylesheets/layout.css
Normal file
0
public/stylesheets/layout.css
Normal file
0
public/stylesheets/print.css
Normal file
0
public/stylesheets/print.css
Normal file
30
public/stylesheets/reset.css
Executable file
30
public/stylesheets/reset.css
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse:collapse;
|
||||||
|
border-spacing:0;
|
||||||
|
}
|
||||||
|
fieldset,img {
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
address,caption,cite,code,dfn,em,strong,th,var {
|
||||||
|
font-style:normal;
|
||||||
|
font-weight:normal;
|
||||||
|
}
|
||||||
|
ol,ul {
|
||||||
|
list-style:none;
|
||||||
|
}
|
||||||
|
caption,th {
|
||||||
|
text-align:left;
|
||||||
|
}
|
||||||
|
h1,h2,h3,h4,h5,h6 {
|
||||||
|
font-size:100%;
|
||||||
|
font-weight:normal;
|
||||||
|
}
|
||||||
|
q:before,q:after {
|
||||||
|
content:'';
|
||||||
|
}
|
||||||
|
abbr,acronym { border:0;
|
||||||
|
}
|
||||||
0
public/stylesheets/screen.css
Normal file
0
public/stylesheets/screen.css
Normal file
0
public/stylesheets/typography.css
Normal file
0
public/stylesheets/typography.css
Normal file
46
script/fix_permissions
Executable file
46
script/fix_permissions
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#! /usr/bin/php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Permissions Fixer - check file/folder permissions and correct if necessary
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// tell boot script to run in shell mode
|
||||||
|
define('ZNAP_SHELL_SCRIPT', true);
|
||||||
|
|
||||||
|
// boot the thing
|
||||||
|
require_once(dirname(dirname(__FILE__)).'/config/boot.php');
|
||||||
|
|
||||||
|
// include and initiate generator
|
||||||
|
require_once('fix_permissions.php');
|
||||||
|
$generator = new FixPermissions();
|
||||||
|
$generator->run();
|
||||||
|
|
||||||
|
?>
|
||||||
46
script/generate
Executable file
46
script/generate
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#! /usr/bin/php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Generate Script - generate controllers, models, and more
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// tell boot script to run in shell mode
|
||||||
|
define('ZNAP_SHELL_SCRIPT', true);
|
||||||
|
|
||||||
|
// boot the thing
|
||||||
|
require_once(dirname(dirname(__FILE__)).'/config/boot.php');
|
||||||
|
|
||||||
|
// include and initiate generator
|
||||||
|
require_once('znap_generator.php');
|
||||||
|
$generator = new ZnapGenerator();
|
||||||
|
$generator->run();
|
||||||
|
|
||||||
|
?>
|
||||||
0
tmp/cache/.emptydir
vendored
Normal file
0
tmp/cache/.emptydir
vendored
Normal file
771
vendor/zynapse/action_controller.php
vendored
Normal file
771
vendor/zynapse/action_controller.php
vendored
Normal file
@@ -0,0 +1,771 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse ActionController - application logic
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
Based on action_controller.php from PHPOnTrax.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ActionController {
|
||||||
|
|
||||||
|
public $controller;
|
||||||
|
public $action;
|
||||||
|
public $id;
|
||||||
|
private $added_path = '';
|
||||||
|
private $action_params = array();
|
||||||
|
private $controllers_path;
|
||||||
|
private $helpers_path;
|
||||||
|
private $helpers_base_path;
|
||||||
|
private $layouts_path;
|
||||||
|
private $layouts_base_path;
|
||||||
|
private $url_path;
|
||||||
|
private $helper_file;
|
||||||
|
private $application_controller_file;
|
||||||
|
private $application_helper_file;
|
||||||
|
private $loaded = false;
|
||||||
|
private $router_loaded = false;
|
||||||
|
private $helpers = array();
|
||||||
|
private $before_filters = array();
|
||||||
|
private $after_filters = array();
|
||||||
|
private $render_performed = false;
|
||||||
|
private $action_called = false;
|
||||||
|
private $router;
|
||||||
|
private $currently_rendering_file;
|
||||||
|
private $content_for_layout = null;
|
||||||
|
private $default_action = 'index';
|
||||||
|
|
||||||
|
public $controller_file;
|
||||||
|
public $view_file;
|
||||||
|
public $views_path;
|
||||||
|
public $controller_class;
|
||||||
|
public $controller_object;
|
||||||
|
public $render_layout = true;
|
||||||
|
public $keep_flash = false;
|
||||||
|
public $route_params = array();
|
||||||
|
public $current_route;
|
||||||
|
public $requested_path;
|
||||||
|
public $prefs = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function __construct () {
|
||||||
|
// doesn't need to do anything at the moment
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO permanently remove __set() function or not
|
||||||
|
// -------------------------------------------------
|
||||||
|
// function __set ($key, $value) {
|
||||||
|
// if ( $key == 'before_filter' ) {
|
||||||
|
// $this->add_before_filter($value);
|
||||||
|
// } elseif ( $key == 'after_filter' ) {
|
||||||
|
// $this->add_after_filter($value);
|
||||||
|
// } elseif ( $key == 'helper' ) {
|
||||||
|
// $this->add_helper($value);
|
||||||
|
// } elseif ( $key == 'render_text' ) {
|
||||||
|
// $this->render_text($value);
|
||||||
|
// } elseif ( $key == 'redirect_to' ) {
|
||||||
|
// $this->redirect_to($value);
|
||||||
|
// } else {
|
||||||
|
// $this->$key = $value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//TODO permanently remove __call() function or not
|
||||||
|
// -------------------------------------------------
|
||||||
|
// function __call ($method, $params) {
|
||||||
|
// if ( method_exists($this, $method) ) {
|
||||||
|
// return call_user_func(array($this, $method), $params);
|
||||||
|
// } else {
|
||||||
|
// if ( $method == 'before_filter' ) {
|
||||||
|
// return call_user_func(array($this, 'add_before_filter'), $params);
|
||||||
|
// } elseif ( $method == 'after_filter' ) {
|
||||||
|
// return call_user_func(array($this, 'add_after_filter'), $params);
|
||||||
|
// } elseif ( $method == 'helper' ) {
|
||||||
|
// return call_user_func(array($this, 'add_helper'), $params);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
function init_filters () {
|
||||||
|
// check if any filters are pre-defined
|
||||||
|
if ( isset($this->before_filter) ) {
|
||||||
|
$this->add_before_filter($this->before_filter);
|
||||||
|
unset($this->before_filter);
|
||||||
|
}
|
||||||
|
if ( isset($this->after_filter) ) {
|
||||||
|
$this->add_after_filter($this->after_filter);
|
||||||
|
unset($this->after_filter);
|
||||||
|
}
|
||||||
|
if ( isset($this->helper) ) {
|
||||||
|
$this->add_helper($this->helper);
|
||||||
|
unset($this->helper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function load_router() {
|
||||||
|
$this->router_loaded = false;
|
||||||
|
$router = new Router();
|
||||||
|
|
||||||
|
// load defined routes
|
||||||
|
require(Znap::$config_path."/routes.php");
|
||||||
|
|
||||||
|
$this->router = $router;
|
||||||
|
if ( is_object($this->router) ) {
|
||||||
|
$this->router_loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function parse_request () {
|
||||||
|
if ( !$this->router_loaded ) {
|
||||||
|
$this->load_router();
|
||||||
|
}
|
||||||
|
|
||||||
|
$url_path = $this->router->get_url_path();
|
||||||
|
$this->url_path = ( !empty($url_path) ) ? explode('/', $url_path) : array() ;
|
||||||
|
$this->requested_path = $url_path;
|
||||||
|
|
||||||
|
if ( $this->router->routes_count > 0 ) {
|
||||||
|
$this->controllers_path = Znap::$controllers_path;
|
||||||
|
$this->helpers_path = $this->helpers_base_path = Znap::$helpers_path;
|
||||||
|
$this->application_controller_file = $this->controllers_path.'/application.php';
|
||||||
|
$this->application_helper_file = $this->helpers_path.'/application_helper.php';
|
||||||
|
$this->layouts_path = $this->layouts_base_path = Znap::$layouts_path;
|
||||||
|
$this->views_path = Znap::$views_path;
|
||||||
|
|
||||||
|
$route = $this->router->find_route($url_path);
|
||||||
|
|
||||||
|
if ( is_array($route) ) {
|
||||||
|
$this->check_paths();
|
||||||
|
$this->current_route = &$this->router->current_route;
|
||||||
|
|
||||||
|
$route_paths = explode('/', $route['path']);
|
||||||
|
$route_params = ( is_array($route['params']) ) ? $route['params'] : array() ;
|
||||||
|
$path_params = array();
|
||||||
|
|
||||||
|
// find path components
|
||||||
|
foreach( $route_paths as $key => $value ) {
|
||||||
|
if ( substr($value, 0, 1) == ':' && strlen($value) >= 2 ) {
|
||||||
|
$path_params[$value] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// redirect_to?
|
||||||
|
if ( array_key_exists(':redirect_to', $route_params) && $route_params[':redirect_to'] != '' ) {
|
||||||
|
$this->redirect_to($route_params[':redirect_to']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// controller
|
||||||
|
if ( array_key_exists(':controller', $route_params) && $route_params[':controller'] != '' ) {
|
||||||
|
$this->controller = strtolower($route['params'][':controller']);
|
||||||
|
} elseif ( array_key_exists(':controller', $path_params) && @$this->url_path[$path_params[':controller']] != '' ) {
|
||||||
|
$this->controller = strtolower($this->url_path[$path_params[':controller']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// action
|
||||||
|
if ( array_key_exists(':action', $route_params) && $route_params[':action'] != '' ) {
|
||||||
|
$this->action = strtolower($route['params'][':action']);
|
||||||
|
} elseif ( array_key_exists(':action', $path_params) && @$this->url_path[$path_params[':action']] != '' ) {
|
||||||
|
$this->action = strtolower($this->url_path[$path_params[':action']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// id
|
||||||
|
if ( array_key_exists(':id', $route_params) && $route_params[':id'] != '' ) {
|
||||||
|
$id = strtolower($route['params'][':id']);
|
||||||
|
} elseif ( array_key_exists(':id', $path_params) && @$this->url_path[$path_params[':id']] != '' ) {
|
||||||
|
$id = strtolower($this->url_path[$path_params[':id']]);
|
||||||
|
}
|
||||||
|
if ( isset($id) && preg_match('/^[0-9]+$/i', $id) ) {
|
||||||
|
$this->id = $id;
|
||||||
|
$_REQUEST['id'] = $this->id;
|
||||||
|
$this->action_params['id'] = $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// store route params so they can be accessed from methods
|
||||||
|
$this->route_params = &$route_params;
|
||||||
|
|
||||||
|
|
||||||
|
// additional paths
|
||||||
|
if ( !empty($path_params) ) {
|
||||||
|
foreach( $path_params as $key => $value ) {
|
||||||
|
if ( $key != ':controller' && $key != ':action' && $key != ':id' ) {
|
||||||
|
if ( array_key_exists($value, $this->url_path) && $this->url_path[$value] != '' ) {
|
||||||
|
$var = substr($key, 1);
|
||||||
|
$_REQUEST[$var] = $this->url_path[$value];
|
||||||
|
$this->action_params[$var] = $this->url_path[$value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the final stuff
|
||||||
|
$this->controller_file = $this->controllers_path.'/'.$this->controller.'_controller.php';
|
||||||
|
$this->helper_file = $this->helpers_path.'/'.$this->controller.'_helper.php';
|
||||||
|
$this->controller_class = Inflector::camelize($this->controller).'Controller';
|
||||||
|
$this->views_path .= '/'.$this->controller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_file($this->controller_file) ) {
|
||||||
|
$this->loaded = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->loaded = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function process_route () {
|
||||||
|
if ( !$this->loaded ) {
|
||||||
|
if ( !$this->parse_request() ) {
|
||||||
|
$this->raise('Controller "'.$this->controller.'" not found...', '...nor were any matching routes found.', 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// include application controller
|
||||||
|
if ( is_file($this->application_controller_file) ) {
|
||||||
|
include_once($this->application_controller_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// include current controller
|
||||||
|
include_once($this->controller_file);
|
||||||
|
if ( class_exists($this->controller_class, false) ) {
|
||||||
|
// create child controller object
|
||||||
|
$class = $this->controller_class;
|
||||||
|
$this->controller_object = new $class();
|
||||||
|
|
||||||
|
if ( is_object($this->controller_object) ) {
|
||||||
|
// set initial properties of child controller object
|
||||||
|
$this->controller_object->init_filters();
|
||||||
|
$this->controller_object->controller = $this->controller;
|
||||||
|
$this->controller_object->action = $this->action;
|
||||||
|
$this->controller_object->id = $this->id;
|
||||||
|
$this->controller_object->controllers_path = &$this->controllers_path;
|
||||||
|
$this->controller_object->helpers_path = &$this->helpers_path;
|
||||||
|
$this->controller_object->helpers_base_path = &$this->helpers_base_path;
|
||||||
|
$this->controller_object->views_path = $this->views_path;
|
||||||
|
$this->controller_object->layouts_path = &$this->layouts_path;
|
||||||
|
$this->controller_object->layouts_base_path = &$this->layouts_base_path;
|
||||||
|
$this->controller_object->route_params = &$this->route_params;
|
||||||
|
$this->controller_object->requested_path = &$this->requested_path;
|
||||||
|
$this->controller_object->current_route = &$this->current_route;
|
||||||
|
|
||||||
|
// set static Znap properties
|
||||||
|
Znap::$current_controller_object = &$this->controller_object;
|
||||||
|
Znap::$current_controller_class_name = $this->controller_class;
|
||||||
|
Znap::$current_controller_name = $this->controller;
|
||||||
|
Znap::$current_controller_path = $this->controllers_path;
|
||||||
|
Znap::$current_action_name = $this->action;
|
||||||
|
Znap::$current_route = &$this->current_route;
|
||||||
|
|
||||||
|
|
||||||
|
// include main application helper file
|
||||||
|
if ( is_file($this->application_helper_file) ) {
|
||||||
|
include_once($this->application_helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load language specific strings
|
||||||
|
// - defaults to english if Znap::$settings['language']
|
||||||
|
// is not defined by before filters
|
||||||
|
Znap::load_strings();
|
||||||
|
|
||||||
|
// include controller specific preferences
|
||||||
|
if ( isset($this->controller_object->has_prefs) && Znap::$prefs->read($this->controller, true) ) {
|
||||||
|
$this->controller_object->prefs = &Znap::$prefs->{$this->controller};
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute before_filters, display an error page if any filter method returns false
|
||||||
|
if ( ($before_filters_result = $this->controller_object->execute_before_filters()) === true ) {
|
||||||
|
|
||||||
|
// supress output for capture
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// include controller specific helper file
|
||||||
|
if ( is_file($this->helper_file) ) {
|
||||||
|
include_once($this->helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// call default action/method if none is defined
|
||||||
|
if ( $this->action === null ) {
|
||||||
|
$this->action = $this->default_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute main method
|
||||||
|
if ( $this->valid_action($this->action) ) {
|
||||||
|
$action = $this->action;
|
||||||
|
$this->controller_object->$action($this->action_params);
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$this->action.'.'.Znap::$views_extension) ) {
|
||||||
|
$action = $this->action;
|
||||||
|
} else {
|
||||||
|
$this->raise('Action "'.$this->action.'" not found.', null, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->controller_object->execute_after_filters();
|
||||||
|
$this->controller_object->action_called = true;
|
||||||
|
|
||||||
|
// include any additionaly defined helpers
|
||||||
|
if ( count($this->controller_object->helpers) ) {
|
||||||
|
foreach( $this->controller_object->helpers as $helper ) {
|
||||||
|
if ( is_file($this->helpers_base_path.'/'.$helper.'_helper.php') ) {
|
||||||
|
include_once($this->helpers_base_path.'/'.$helper.'_helper.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if true Session::flash() messages will be displayed till this is set to false on a page load.
|
||||||
|
Znap::$keep_flash = $this->keep_flash;
|
||||||
|
|
||||||
|
// check if $redirect_to was set and redirect accordingly if so
|
||||||
|
if ( isset($this->controller_object->redirect_to) && $this->controller_object->redirect_to != '' ) {
|
||||||
|
$this->redirect_to($this->controller_object->redirect_to);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if render_text is defined as a string, render it instead of layout & view files
|
||||||
|
if ( isset($this->controller_object->render_text) && $this->controller_object->render_text != '' ) {
|
||||||
|
$this->render_text($this->controller_object->render_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if render_action is defined, use it as the render action, if it is false, don't render action view file
|
||||||
|
if ( isset($this->controller_object->render_action) ) {
|
||||||
|
$action = $this->controller_object->render_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
// render view file
|
||||||
|
if ( $action !== false && !$this->controller_object->render_action($action) ) {
|
||||||
|
$this->raise('No "'.$action.'" view file found.', null, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// grab captured output
|
||||||
|
$this->controller_object->content_for_layout = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
// render or not to render layout (that is the question)
|
||||||
|
if ( $this->controller_object->render_layout !== false && ($layout_file = $this->controller_object->determine_layout()) ) {
|
||||||
|
if ( Timer::$started ) ob_start();
|
||||||
|
if ( !$this->controller_object->render_file($layout_file) ) {
|
||||||
|
echo $this->controller_object->content_for_layout;
|
||||||
|
}
|
||||||
|
if ( Timer::$started ) ob_end_flush();
|
||||||
|
} else {
|
||||||
|
echo $this->controller_object->content_for_layout;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->raise('The "'.$before_filters_result.'" before filter failed.', null, 500);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->raise('Failed to initiate controller object "'.$this->controller.'".', null, 500);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->raise('Controller class "'.$this->controller_class.'" not found.', null, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function process_exception ( $object ) {
|
||||||
|
|
||||||
|
// load language specific strings which can be used in error files
|
||||||
|
Znap::load_strings();
|
||||||
|
|
||||||
|
$this->error = $object;
|
||||||
|
$this->message = $object->getMessage();
|
||||||
|
$this->details = $object->getDetails();
|
||||||
|
$this->code = $object->getCode();
|
||||||
|
$this->trace = $object->getTrace();
|
||||||
|
|
||||||
|
if ( $this->code != 0 ) {
|
||||||
|
header('Status: '.$this->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ZNAP_ENV = ( Znap::$use_development_errors ) ? 'development' : ZNAP_ENV ;
|
||||||
|
|
||||||
|
$paths = array(
|
||||||
|
Znap::$errors_path.'/'.$ZNAP_ENV,
|
||||||
|
Znap::$errors_default_path,
|
||||||
|
ZNAP_LIB_ROOT.'/znap_error/'.$ZNAP_ENV,
|
||||||
|
ZNAP_LIB_ROOT.'/znap_error/default',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach( $paths as $path ) {
|
||||||
|
if ( is_file($path.'/'.$this->code.'.'.Znap::$views_extension) ) {
|
||||||
|
$view_file = $path.'/'.$this->code.'.'.Znap::$views_extension;
|
||||||
|
break;
|
||||||
|
} elseif ( is_file($path.'/default.'.Znap::$views_extension) ) {
|
||||||
|
$view_file = $path.'/default.'.Znap::$views_extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->render_file($view_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function valid_action ($action) {
|
||||||
|
if ( $action !== null && substr($action, 0, 1) != Znap::$protected_method_prefix ) {
|
||||||
|
|
||||||
|
// get all methods
|
||||||
|
$all_methods = get_class_methods($this->controller_object);
|
||||||
|
|
||||||
|
// get inherited methods
|
||||||
|
$inherited_methods = array_merge(
|
||||||
|
get_class_methods(__CLASS__),
|
||||||
|
$this->controller_object->before_filters,
|
||||||
|
$this->controller_object->after_filters
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( class_exists('ApplicationController', false) ) {
|
||||||
|
$inherited_methods = array_merge($inherited_methods, get_class_methods('ApplicationController'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate action
|
||||||
|
$valid_actions = array_diff($all_methods, $inherited_methods);
|
||||||
|
if ( in_array($action, $valid_actions) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function execute_filters ($filters) {
|
||||||
|
if ( count($this->$filters) ) {
|
||||||
|
foreach( $this->$filters as $filter ) {
|
||||||
|
if ( method_exists($this, $filter) ) {
|
||||||
|
if ( $this->$filter() === false ) {
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_before_filters () {
|
||||||
|
return $this->execute_filters('before_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_after_filters () {
|
||||||
|
return $this->execute_filters('after_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function add_items_to_list ($filter, $list) {
|
||||||
|
if ( is_string($filter) && !empty($filter) ) {
|
||||||
|
if ( strpos($filter, ',') !== false ) {
|
||||||
|
$filter = explode(',', $filter);
|
||||||
|
foreach( $filter as $key => $value ) {
|
||||||
|
if ( !in_array($value, $this->$list) ) {
|
||||||
|
$this->{$list}[] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->{$list}[] = $filter;
|
||||||
|
}
|
||||||
|
} elseif ( is_array($filter) ) {
|
||||||
|
if ( count($this->$list) ) {
|
||||||
|
$this->$list = array_unique(array_merge($this->$list, $filter));
|
||||||
|
} else {
|
||||||
|
$this->$list = $filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function before_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'before_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_before_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'before_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function after_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'after_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_after_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'after_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function add_helper ($helper) {
|
||||||
|
$this->add_items_to_list($helper, 'helpers');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function check_paths () {
|
||||||
|
if ( is_array($this->url_path) ) {
|
||||||
|
$controllers_path = $this->controllers_path;
|
||||||
|
$extra_path = array();
|
||||||
|
$new_path = array();
|
||||||
|
foreach( $this->url_path as $key => $path ) {
|
||||||
|
if ( is_dir($controllers_path.'/'.$path) ) {
|
||||||
|
$extra_path[] = $path;
|
||||||
|
$controllers_path .= '/'.$path;
|
||||||
|
} else {
|
||||||
|
$new_path[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !empty($extra_path) ) {
|
||||||
|
$extra_path = implode('/', $extra_path);
|
||||||
|
$this->added_path = $extra_path;
|
||||||
|
Znap::$added_path = $this->added_path;
|
||||||
|
$this->controllers_path .= '/'.$extra_path;
|
||||||
|
$this->helpers_path .= '/'.$extra_path;
|
||||||
|
$this->layouts_path .= '/'.$extra_path;
|
||||||
|
$this->views_path .= '/_'.$extra_path;
|
||||||
|
}
|
||||||
|
if ( !empty($new_path) ) {
|
||||||
|
$this->url_path = $new_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function render ($options = array(), $locals = array(), $return_as_string = false) {
|
||||||
|
if ( $this->render_performed && !$this->action_called ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( $return_as_string ) {
|
||||||
|
ob_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_string($options) ) {
|
||||||
|
$this->render_file($options, $locals, true);
|
||||||
|
} elseif ( is_array($options) ) {
|
||||||
|
$options['locals'] = ( $options['locals'] ) ? $option['locals'] : array() ;
|
||||||
|
$options['use_full_path'] = ( !$options['use_full_path'] ) ? true : $options['use_full_path'] ;
|
||||||
|
if ( $options['text'] ) {
|
||||||
|
$this->render_text($options['text']);
|
||||||
|
} elseif ( $options['action'] ) {
|
||||||
|
$this->render_action($optins['action'], $options);
|
||||||
|
} elseif ( $options['file'] ) {
|
||||||
|
$this->render_file($options['file'], array_merge($options['locals'], $locals), $options['use_full_path']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $return_as_string ) {
|
||||||
|
$result = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_text ($text, $options = array()) {
|
||||||
|
if ( isset($options['layout']) && $options['layout'] != '' ) {
|
||||||
|
$locals['content_for_layout'] = &$text;
|
||||||
|
$layout = $this->determine_layout();
|
||||||
|
$this->render_file($layout, $locals);
|
||||||
|
} else {
|
||||||
|
echo $text;
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_action ($action, $layout = null) {
|
||||||
|
if ( $this->render_performed ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $layout != null ) {
|
||||||
|
$this->layout = $layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->view_file) ) {
|
||||||
|
$len = strlen('.'.Znap::$views_extension);
|
||||||
|
if ( substr($this->view_file, -$len) != '.'.Znap::$views_extension ) {
|
||||||
|
$this->view_file .= '.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
if ( strstr($this->view_file, '/') && is_file(Znap::$views_path.'/'.$this->view_file) ) {
|
||||||
|
$this->view_file = Znap::$views_path.'/'.$this->view_file;
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$this->view_file) ) {
|
||||||
|
$this->view_file = $this->views_path.'/'.$this->view_file;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->view_file = $this->views_path.'/'.$action.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->render_performed = true;
|
||||||
|
|
||||||
|
return $this->render_file($this->view_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_file ($file, $collection = null, $locals = array(), $use_simple_name = false) {
|
||||||
|
|
||||||
|
if ( $use_simple_name ) {
|
||||||
|
$file = $this->views_path.'/'.$file.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_file($file) ) {
|
||||||
|
if ( is_object($this) ) {
|
||||||
|
foreach( $this as $tmp_key => $tmp_value ) {
|
||||||
|
${$tmp_key} = &$this->$tmp_key;
|
||||||
|
}
|
||||||
|
unset($tmp_key, $tmp_value);
|
||||||
|
}
|
||||||
|
if ( $this->content_for_layout !== null ) {
|
||||||
|
$content_for_layout = &$this->content_for_layout;
|
||||||
|
}
|
||||||
|
if ( count($locals) ) {
|
||||||
|
foreach( $locals as $tmp_key => $tmp_value ) {
|
||||||
|
${$tmp_key} = &$locals[$tmp_key];
|
||||||
|
}
|
||||||
|
unset($tmp_key, $tmp_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($use_full_path, $locals);
|
||||||
|
|
||||||
|
$this->currently_rendering_file = $file;
|
||||||
|
|
||||||
|
if ( empty($collection) ) {
|
||||||
|
include($file);
|
||||||
|
} elseif ( is_array($collection) ) {
|
||||||
|
$var_name = basename($file, '.phtml');
|
||||||
|
if ( $var_name{0} == '_' ) {
|
||||||
|
$var_name = substr($var_name, 1);
|
||||||
|
}
|
||||||
|
${$var_name.'_collection'} = &$collection;
|
||||||
|
$eval = "foreach( \${$var_name}_collection as \${$var_name}_key => \${$var_name} ):\n?>";
|
||||||
|
$eval .= file_get_contents($file);
|
||||||
|
$eval .= "\n<?php endforeach; ?>";
|
||||||
|
eval($eval);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_partial ($partial, $collection = null, $locals = array()) {
|
||||||
|
|
||||||
|
// set file name
|
||||||
|
if ( strstr($partial, '/') ) {
|
||||||
|
$file = '_'.substr(strrchr($partial, '/'), 1).'.'.Znap::$views_extension;
|
||||||
|
$path = substr($partial, 0, strrpos($partial, '/'));
|
||||||
|
$file_name = $path.'/'.$file;
|
||||||
|
} else {
|
||||||
|
$path = '';
|
||||||
|
$file_name = $file = '_'.$partial.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine file path
|
||||||
|
if ( strstr($file_name, '/') && is_file(Znap::$views_path.'/'.$file_name) ) {
|
||||||
|
$file_name = Znap::$views_path.'/'.$file_name;
|
||||||
|
} elseif ( is_file(dirname($this->currently_rendering_file).'/'.$file_name) ) {
|
||||||
|
$file_name = dirname($this->currently_rendering_file).'/'.$file_name;
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->views_path.'/'.$file_name;
|
||||||
|
} elseif ( is_file($this->layouts_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->layouts_path.'/'.$file_name;
|
||||||
|
} elseif ( $this->layouts_path != $this->layouts_base_path && is_file($this->layouts_base_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->layouts_base_path.'/'.$file_name;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// continue if partial file exists
|
||||||
|
if ( is_file($file_name) ) {
|
||||||
|
return $this->render_file($file_name, $collection, $locals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function determine_layout ($full_path = true) {
|
||||||
|
// if controller defines and sets $layout to NULL, don't use a layout
|
||||||
|
if ( isset($this->layout) && is_null($this->layout) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if _determine_layout() is defined in controller, call it to get layout name
|
||||||
|
if ( method_exists($this, Znap::$protected_method_prefix.'determine_layout') ) {
|
||||||
|
$determine_layout_method = Znap::$protected_method_prefix.'determine_layout';
|
||||||
|
$layout = $this->$determine_layout_method();
|
||||||
|
} else {
|
||||||
|
$layout = ( isset($this->layout) && $this->layout != '' ) ? $this->layout : $this->controller ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults
|
||||||
|
$layouts_base_path = Znap::$layouts_path;
|
||||||
|
$default_layout_file = $layouts_base_path.'/application.'.Znap::$views_extension;
|
||||||
|
|
||||||
|
if ( !$full_path && $layout ) {
|
||||||
|
$layout_file = $layout;
|
||||||
|
} elseif ( strstr($layout, '/') && is_file($layouts_base_path.'/'.$layout.'.'.Znap::$views_extension) ) {
|
||||||
|
$layout_file = $layouts_base_path.'/'.$layout.'.'.Znap::$views_extension;
|
||||||
|
} elseif ( is_file($this->layouts_path.'/'.$layout.'.'.Znap::$views_extension) ) {
|
||||||
|
$layout_file = $this->layouts_path.'/'.$layout.'.'.Znap::$views_extension;
|
||||||
|
} elseif ( is_file($layouts_base_path.'/'.$layout.'.'.Znap::$views_extension) ) {
|
||||||
|
$layout_file = $layouts_base_path.'/'.$layout.'.'.Znap::$views_extension;
|
||||||
|
} else {
|
||||||
|
$layout_file = $default_layout_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $layout_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function redirect_to ( $options = null ) {
|
||||||
|
if ( $options == 'back' ) {
|
||||||
|
$url = $_SERVER['HTTP_REFERER'];
|
||||||
|
} else {
|
||||||
|
$url = url_for($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( headers_sent() ) {
|
||||||
|
echo '<html><head><meta http-equiv="refresh" content="2;url='.$url.'"></head></html>';
|
||||||
|
} else {
|
||||||
|
header('Location: '.$url);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function raise ($message, $details, $code) {
|
||||||
|
throw new ActionControllerError($message, $details, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
45
vendor/zynapse/action_view.php
vendored
Normal file
45
vendor/zynapse/action_view.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
ActionView - base helpers setup
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// include main helpers class
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/action_view/helpers.php');
|
||||||
|
|
||||||
|
// include helpers
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/action_view/helpers/form_tag_helper.php');
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/action_view/helpers/javascript_helper.php');
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/action_view/helpers/url_helper.php');
|
||||||
|
require_once(ZNAP_LIB_ROOT.'/action_view/helpers/views_helper.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
162
vendor/zynapse/action_view/helpers.php
vendored
Normal file
162
vendor/zynapse/action_view/helpers.php
vendored
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Helpers - view helpers
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Helpers {
|
||||||
|
|
||||||
|
public $object_name = null;
|
||||||
|
public $attribute_name = null;
|
||||||
|
public $value = null;
|
||||||
|
|
||||||
|
|
||||||
|
function __construct ($object_name = null, $attribute_name = null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initiate ($name = null, $value = null, $auto_fill = true) {
|
||||||
|
if ( $name !== null ) {
|
||||||
|
|
||||||
|
if ( preg_match('/^(.+?)\[(.+)\]$/i', $name, $captured) ) {
|
||||||
|
$this->object_name = $captured[1];
|
||||||
|
$this->attribute_name = $captured[2];
|
||||||
|
} else {
|
||||||
|
$this->object_name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$property = &$this->object_name;
|
||||||
|
$attribute = &$this->attribute_name;
|
||||||
|
|
||||||
|
if ( $auto_fill !== false && array_key_exists($property, $_REQUEST) ) {
|
||||||
|
if ( $attribute !== null && array_key_exists($attribute, $_REQUEST[$property]) ) {
|
||||||
|
$this->value = &$_REQUEST[$property][$attribute];
|
||||||
|
} else {
|
||||||
|
$this->value = &$_REQUEST[$property];
|
||||||
|
}
|
||||||
|
} elseif ( $auto_fill !== false && property_exists(Znap::$current_controller_object, $property) ) {
|
||||||
|
$object = &Znap::$current_controller_object;
|
||||||
|
if ( $attribute !== null ) {
|
||||||
|
if ( is_object($object->$property) && property_exists($object->$property, $attribute) ) {
|
||||||
|
$this->value = &$object->$property->$attribute;
|
||||||
|
} elseif ( is_array($object->$property) && array_key_exists($attribute, $object->$property) ) {
|
||||||
|
$this->value = &$object->$property[$attribute];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->value = &$object->$property;
|
||||||
|
}
|
||||||
|
} elseif ( $value !== null ) {
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
|
} elseif ( $value !== null ) {
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag ($name, $properties = null, $open = true) {
|
||||||
|
$html = '<'.$name;
|
||||||
|
if ( ($options = $this->tag_properties($properties)) != '' ) {
|
||||||
|
$html .= ' '.$options;
|
||||||
|
}
|
||||||
|
$html .= ($open) ? '>' : ' />' ;
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function content_tag ($name, $content = '', $properties = null) {
|
||||||
|
if ( !empty($properties['strip_slashes']) ) {
|
||||||
|
$content = stripslashes($content);
|
||||||
|
unset($properties['strip_slashes']);
|
||||||
|
}
|
||||||
|
return $this->tag($name, $properties).$content.'</'.$name.'>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag_properties ($properties = null) {
|
||||||
|
if ( is_array($properties) && count($properties) ) {
|
||||||
|
$html = array();
|
||||||
|
foreach( $properties as $key => $value ) {
|
||||||
|
$html[] = $key.'="'.@htmlspecialchars($value, ENT_COMPAT).'"';
|
||||||
|
}
|
||||||
|
// sort($html); //TODO decide if tag properties should be sorted or not
|
||||||
|
return implode(' ', $html);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cdata_section ($content) {
|
||||||
|
return '<![CDATA['.$content.']]>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
root scope functions
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tag () {
|
||||||
|
$helper = new Helpers();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function content_tag () {
|
||||||
|
$helper = new Helpers();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'content_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag_properties () {
|
||||||
|
$helper = new Helpers();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'tag_properties'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cdata_section () {
|
||||||
|
$helper = new Helpers();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'cdata_section'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
229
vendor/zynapse/action_view/helpers/form_tag_helper.php
vendored
Normal file
229
vendor/zynapse/action_view/helpers/form_tag_helper.php
vendored
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Form Tag Helpers - helpers to create forms
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class FormTagHelper extends Helpers {
|
||||||
|
|
||||||
|
|
||||||
|
function form_tag ($name = null, $url = '', $properties = array()) {
|
||||||
|
if ( !empty($name) ) {
|
||||||
|
$properties = array_merge(array('name' => $name, 'id' => $name), $properties);
|
||||||
|
}
|
||||||
|
$properties = array_merge(array('method' => 'post'), $properties);
|
||||||
|
|
||||||
|
if ( array_key_exists('multipart', $properties) && $properties['multipart'] != false) {
|
||||||
|
$properties['enctype'] = 'multipart/form-data';
|
||||||
|
unset($properties['multipart']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$properties['action'] = $url;
|
||||||
|
return $this->tag('form', $properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hidden_field ($name = '', $value = null, $properties = array()) {
|
||||||
|
$this->initiate($name, $value);
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'type' => 'hidden',
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
'value' => @htmlspecialchars($this->value),
|
||||||
|
);
|
||||||
|
return $this->tag('input', array_merge($properties, $base_properties), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function text_field ($name = '', $value = null, $properties = array()) {
|
||||||
|
$this->initiate($name, $value);
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'type' => 'text',
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
'value' => @htmlspecialchars($this->value),
|
||||||
|
);
|
||||||
|
return $this->tag('input', array_merge($properties, $base_properties), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function password_field ($name = '', $auto_fill = false, $properties = array()) {
|
||||||
|
$this->initiate($name, null, $auto_fill);
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'type' => 'password',
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
'value' => ($auto_fill === false ? '' : @htmlspecialchars($this->value)),
|
||||||
|
);
|
||||||
|
return $this->tag('input', array_merge($properties, $base_properties), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function file_field ($name = '', $auto_fill = false, $properties = array()) {
|
||||||
|
$this->initiate($name, null, $auto_fill);
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'type' => 'file',
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
'value' => ($auto_fill === false ? '' : @htmlspecialchars($this->value)),
|
||||||
|
);
|
||||||
|
return $this->tag('input', array_merge($properties, $base_properties), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function textarea ($name = '', $value = null, $properties = array()) {
|
||||||
|
$this->initiate($name, $value);
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->content_tag('textarea', @htmlspecialchars($this->value), array_merge($properties, $base_properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function select_tag ($name, $options = array(), $properties = array(), $selected = null) {
|
||||||
|
$this->initiate($name, $selected);
|
||||||
|
|
||||||
|
if ( $options == null ) $options = array();
|
||||||
|
if ( $properties == null ) $properties = array();
|
||||||
|
|
||||||
|
$base_properties = array(
|
||||||
|
'name' => $name,
|
||||||
|
'id' => $name,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( array_key_exists('prefix', $properties) ) {
|
||||||
|
$prefix = $properties['prefix'];
|
||||||
|
unset($properties['prefix']);
|
||||||
|
} elseif ( array_key_exists('blank_prefix', $properties) ) {
|
||||||
|
$prefix = ' ';
|
||||||
|
unset($properties['blank_prefix']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = "\n".$this->option_tags($options, (isset($prefix)) ? $prefix : null )."\n";
|
||||||
|
return $this->content_tag('select', $content, array_merge($properties, $base_properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function option_tags ( $options, $prefix = null ) {
|
||||||
|
$html = array();
|
||||||
|
if ( $prefix != null ) {
|
||||||
|
$html[] = $this->option_tag('', $prefix);
|
||||||
|
}
|
||||||
|
foreach( $options as $key => $value ) {
|
||||||
|
$html[] = $this->option_tag($key, $value, ($this->value == $key) ? true : false );
|
||||||
|
}
|
||||||
|
return (count($html)) ? implode("\n", $html) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function option_tag ($value, $title, $selected = false) {
|
||||||
|
$properties['value'] = $value;
|
||||||
|
if ( $selected ) {
|
||||||
|
$properties['selected'] = 'selected';
|
||||||
|
}
|
||||||
|
return $this->content_tag('option', $title, $properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
root scope functions
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function form_tag () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'form_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hidden_field () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'hidden_field'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function text_field () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'text_field'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function file_field () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'file_field'), $args);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function password_field () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'password_field'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function textarea () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'textarea'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function select_tag () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'select_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function option_tags () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'option_tags'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function option_tag () {
|
||||||
|
$helper = new FormTagHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'option_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
131
vendor/zynapse/action_view/helpers/javascript_helper.php
vendored
Normal file
131
vendor/zynapse/action_view/helpers/javascript_helper.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
UrlHelper - URL and link related helpers
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class JavascriptHelper extends Helpers {
|
||||||
|
|
||||||
|
public
|
||||||
|
$js_url,
|
||||||
|
$libs_url,
|
||||||
|
$lib_url_jquery,
|
||||||
|
$default_charset,
|
||||||
|
$libs = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function __construct () {
|
||||||
|
$this->js_url = Znap::$url_prefix.App::$_internals->js_url;
|
||||||
|
$this->libs_url = Znap::$url_prefix.App::$_internals->js_libs_url;
|
||||||
|
$this->default_charset = (!empty(App::$_internals->js_charset)) ? App::$_internals->js_charset : 'utf-8' ;
|
||||||
|
if ( count(App::$_internals->js_libs) > 0 ) {
|
||||||
|
$this->libs = App::$_internals->js_libs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function script_lib ($library) {
|
||||||
|
if ( !empty($this->libs[$library]) ) {
|
||||||
|
$library = $this->libs[$library];
|
||||||
|
}
|
||||||
|
if ( substr($library, -3) !== '.js' ) {
|
||||||
|
$library .= '.js';
|
||||||
|
}
|
||||||
|
echo $this->script_tag($this->libs_url.'/'.$library, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_src ($file) {
|
||||||
|
if ( substr($file, -3) !== '.js' ) {
|
||||||
|
$file .= '.js';
|
||||||
|
}
|
||||||
|
echo $this->script_tag($this->js_url.'/'.$file, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_tag ($src = null, $charset = null, $close = false) {
|
||||||
|
$properties = array(
|
||||||
|
'src' => $src,
|
||||||
|
'type' => 'text/javascript',
|
||||||
|
'charset' => ($charset != null) ? $charset : $this->default_charset,
|
||||||
|
);
|
||||||
|
$return = $this->tag('script', $properties);
|
||||||
|
if ( $close ) {
|
||||||
|
$return .= '</script>';
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_content_tag ($src = null, $content = null, $charset = null) {
|
||||||
|
return $this->script_tag($src, $charset).$content.'</script>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
root scope functions
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function script_lib () {
|
||||||
|
$helper = new JavascriptHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'script_lib'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_src () {
|
||||||
|
$helper = new JavascriptHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'script_src'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_tag () {
|
||||||
|
$helper = new JavascriptHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'script_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function script_content_tag () {
|
||||||
|
$helper = new JavascriptHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'script_content_tag'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
158
vendor/zynapse/action_view/helpers/url_helper.php
vendored
Normal file
158
vendor/zynapse/action_view/helpers/url_helper.php
vendored
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
UrlHelper - URL and link related helpers
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class UrlHelper extends Helpers {
|
||||||
|
|
||||||
|
|
||||||
|
function link_to ($name = null, $link_to = array(), $properties = array()) {
|
||||||
|
$properties = $this->convert_confirm_property_to_javascript($properties);
|
||||||
|
|
||||||
|
if ( is_string($link_to) ) {
|
||||||
|
$url = $link_to;
|
||||||
|
} elseif ( is_array($link_to) ) {
|
||||||
|
$url = $this->url_for($link_to);
|
||||||
|
}
|
||||||
|
|
||||||
|
$properties['href'] = $url;
|
||||||
|
if ( $name == null || $name == false ) {
|
||||||
|
$name = $link_to;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->content_tag('a', $name, $properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_confirm_property_to_javascript ($properties) {
|
||||||
|
if ( array_key_exists('confirm', $properties) ) {
|
||||||
|
$properties['onclick'] = 'return confirm(\''.addslashes($properties['confirm']).'\');';
|
||||||
|
unset($properties['confirm']);
|
||||||
|
}
|
||||||
|
return $properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function url_for ($options = array()) {
|
||||||
|
if ( is_string($options) ) {
|
||||||
|
return $options;
|
||||||
|
} elseif ( is_array($options) ) {
|
||||||
|
|
||||||
|
// host
|
||||||
|
$url = $_SERVER['HTTP_HOST'];
|
||||||
|
if ( substr($url, -1) == '/' ) {
|
||||||
|
$url = substr($url, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// port
|
||||||
|
if ( $_SERVER['SERVER_PORT'] == 80 ) {
|
||||||
|
$url = 'http://'.$url;
|
||||||
|
} elseif ( $_SERVER['SERVER_PORT'] == 443 ) {
|
||||||
|
$url = 'https://'.$url;
|
||||||
|
} elseif (!empty($_SERVER['SERVER_PORT'])) {
|
||||||
|
$url = 'http://'.$url.':'.$_SERVER['SERVER_PORT'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// prefix
|
||||||
|
if ( Znap::$url_prefix != null ) {
|
||||||
|
$url = (Znap::$url_prefix{0} != '/') ? '/'.Znap::$url_prefix : Znap::$url_prefix ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$paths = array();
|
||||||
|
|
||||||
|
// controller
|
||||||
|
if ( array_key_exists(':controller', $options) && $options[':controller'] != '' ) {
|
||||||
|
$paths[] = $options[':controller'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// action
|
||||||
|
if ( count($paths) && array_key_exists(':action', $options) ) {
|
||||||
|
$paths[] = $options[':action'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// id
|
||||||
|
if ( count($paths) > 1 && array_key_exists(':id', $options) ) {
|
||||||
|
if ( is_object($options[':id']) && isset($options[':id']->id) ) {
|
||||||
|
$paths[] = $options[':id']->id;
|
||||||
|
} elseif ( !is_object($options[':id']) ) {
|
||||||
|
$paths[] = $options[':id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$extra_params = array();
|
||||||
|
if ( count($options) ) {
|
||||||
|
foreach( $options as $key => $value ) {
|
||||||
|
if ( !strpos($key, ':') ) {
|
||||||
|
$extra_params[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( substr($url, -1) != '/' ) {
|
||||||
|
$url .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url . implode('/', $paths) . (count($extra_params)) ? '?'.http_build_query($extra_params) : null ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
root scope functions
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function link_to () {
|
||||||
|
$helper = new UrlHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'link_to'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function url_for () {
|
||||||
|
$helper = new UrlHelper();
|
||||||
|
$args = func_get_args();
|
||||||
|
return call_user_func_array(array($helper, 'url_for'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
59
vendor/zynapse/action_view/helpers/views_helper.php
vendored
Normal file
59
vendor/zynapse/action_view/helpers/views_helper.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Views Helper - shorthand render functions
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function render_partial () {
|
||||||
|
$args = func_get_args();
|
||||||
|
if ( Znap::$currently_rendering_snippet === null ) {
|
||||||
|
return call_user_func_array(array(Znap::$current_controller_object, 'render_partial'), $args);
|
||||||
|
} elseif ( is_object(Znap::$current_snippet_objects[Znap::$currently_rendering_snippet]) ) {
|
||||||
|
return call_user_func_array(array(Znap::$current_snippet_objects[Znap::$currently_rendering_snippet], 'render_partial'), $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_snippet () {
|
||||||
|
$args = func_get_args();
|
||||||
|
if ( !is_object(Znap::$snippets_controller) ) {
|
||||||
|
Znap::$snippets_controller = new SnippetController();
|
||||||
|
}
|
||||||
|
return call_user_func_array(array(Znap::$snippets_controller, 'render_snippet'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function call_snippet () {
|
||||||
|
$args = func_get_args();
|
||||||
|
if ( !is_object(Znap::$snippets_controller) ) {
|
||||||
|
Znap::$snippets_controller = new SnippetController();
|
||||||
|
}
|
||||||
|
return call_user_func_array(array(Znap::$snippets_controller, 'call_snippet'), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
1139
vendor/zynapse/active_record.php
vendored
Normal file
1139
vendor/zynapse/active_record.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
48
vendor/zynapse/dispatcher.php
vendored
Normal file
48
vendor/zynapse/dispatcher.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Dispatcher - start zynapse
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Dispatcher {
|
||||||
|
|
||||||
|
function dispatch () {
|
||||||
|
try {
|
||||||
|
Session::start();
|
||||||
|
Znap::$action_controller = new ActionController();
|
||||||
|
Znap::$action_controller->process_route();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Znap::$action_controller->process_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
157
vendor/zynapse/inflections.php
vendored
Normal file
157
vendor/zynapse/inflections.php
vendored
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* File containing the Inflections class and default inflections
|
||||||
|
*
|
||||||
|
* (PHP 5)
|
||||||
|
*
|
||||||
|
* @package PHPonTrax
|
||||||
|
* @version $Id: inflector.php 195 2006-04-03 22:27:26Z haas $
|
||||||
|
* @copyright (c) 2005 John Peterson
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
# Start Default Inflections
|
||||||
|
|
||||||
|
Inflections::plural('/$/', 's');
|
||||||
|
Inflections::plural('/s$/i', 's');
|
||||||
|
Inflections::plural('/(ax|test)is$/i', '\1es');
|
||||||
|
Inflections::plural('/(octop|vir)us$/i', '\1i');
|
||||||
|
Inflections::plural('/(alias|status)$/i', '\1es');
|
||||||
|
Inflections::plural('/(bu)s$/i', '\1ses');
|
||||||
|
Inflections::plural('/(buffal|tomat)o$/i', '\1oes');
|
||||||
|
Inflections::plural('/([ti])um$/i', '\1a');
|
||||||
|
Inflections::plural('/sis$/i', 'ses');
|
||||||
|
Inflections::plural('/(?:([^f])fe|([lr])f)$/i', '\1\2ves');
|
||||||
|
Inflections::plural('/(hive)$/i', '\1s');
|
||||||
|
Inflections::plural('/([^aeiouy]|qu)y$/i', '\1ies');
|
||||||
|
Inflections::plural('/([^aeiouy]|qu)ies$/i', '\1y');
|
||||||
|
Inflections::plural('/(x|ch|ss|sh)$/i', '\1es');
|
||||||
|
Inflections::plural('/(matr|vert|ind)ix|ex$/i', '\1ices');
|
||||||
|
Inflections::plural('/([m|l])ouse$/i', '\1ice');
|
||||||
|
Inflections::plural('/^(ox)$/i', '\1en');
|
||||||
|
Inflections::plural('/(quiz)$/i', '\1zes');
|
||||||
|
|
||||||
|
Inflections::singular('/s$/i', '');
|
||||||
|
Inflections::singular('/(n)ews$/i', '\1ews');
|
||||||
|
Inflections::singular('/([ti])a$/i', '\1um');
|
||||||
|
Inflections::singular('/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i', '\1\2sis');
|
||||||
|
Inflections::singular('/(^analy)ses$/i', '\1sis');
|
||||||
|
Inflections::singular('/([^f])ves$/i', '\1fe');
|
||||||
|
Inflections::singular('/(hive)s$/i', '\1');
|
||||||
|
Inflections::singular('/(tive)s$/i', '\1');
|
||||||
|
Inflections::singular('/([lr])ves$/i', '\1f');
|
||||||
|
Inflections::singular('/([^aeiouy]|qu)ies$/i', '\1y');
|
||||||
|
Inflections::singular('/(s)eries$/i', '\1eries');
|
||||||
|
Inflections::singular('/(m)ovies$/i', '\1ovie');
|
||||||
|
Inflections::singular('/(x|ch|ss|sh)es$/i', '\1');
|
||||||
|
Inflections::singular('/([m|l])ice$/i', '\1ouse');
|
||||||
|
Inflections::singular('/(bus)es$/i', '\1');
|
||||||
|
Inflections::singular('/(o)es$/i', '\1');
|
||||||
|
Inflections::singular('/(shoe)s$/i', '\1');
|
||||||
|
Inflections::singular('/(cris|ax|test)es$/i', '\1is');
|
||||||
|
Inflections::singular('/([octop|vir])i$/i', '\1us');
|
||||||
|
Inflections::singular('/(alias|status)es$/i', '\1');
|
||||||
|
Inflections::singular('/^(ox)en/i', '\1');
|
||||||
|
Inflections::singular('/(vert|ind)ices$/i', '\1ex');
|
||||||
|
Inflections::singular('/(matr)ices$/i', '\1ix');
|
||||||
|
Inflections::singular('/(quiz)zes$/i', '\1');
|
||||||
|
|
||||||
|
Inflections::irregular('person', 'people');
|
||||||
|
Inflections::irregular('man', 'men');
|
||||||
|
Inflections::irregular('child', 'children');
|
||||||
|
Inflections::irregular('sex', 'sexes');
|
||||||
|
Inflections::irregular('move', 'moves');
|
||||||
|
|
||||||
|
Inflections::uncountable('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
|
||||||
|
|
||||||
|
# End Default Inflections
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement the Trax naming convention
|
||||||
|
*
|
||||||
|
* Inflections is never instantiated.
|
||||||
|
*/
|
||||||
|
class Inflections {
|
||||||
|
|
||||||
|
public static $plurals = array();
|
||||||
|
|
||||||
|
public static $singulars = array();
|
||||||
|
|
||||||
|
public static $uncountables = array();
|
||||||
|
|
||||||
|
# Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
|
||||||
|
# The replacement should always be a string that may include references to the matched data from the rule.
|
||||||
|
function plural($rule, $replacement) {
|
||||||
|
array_unshift(self::$plurals, array("rule" => $rule, "replacement" => $replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
# Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
|
||||||
|
# The replacement should always be a string that may include references to the matched data from the rule.
|
||||||
|
function singular($rule, $replacement) {
|
||||||
|
array_unshift(self::$singulars, array("rule" => $rule, "replacement" => $replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
# Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
|
||||||
|
# for strings, not regular expressions. You simply pass the irregular in singular and plural form.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# Inflections::irregular('octopus', 'octopi')
|
||||||
|
# Inflections::irregular('person', 'people')
|
||||||
|
function irregular($singular, $plural) {
|
||||||
|
self::plural('/('.preg_quote(substr($singular,0,1)).')'.preg_quote(substr($singular,1)).'$/i', '\1'.preg_quote(substr($plural,1)));
|
||||||
|
self::singular('/('.preg_quote(substr($plural,0,1)).')'.preg_quote(substr($plural,1)).'$/i', '\1'.preg_quote(substr($singular,1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add uncountable words that shouldn't be attempted inflected.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# Inflections::uncountable("money")
|
||||||
|
# Inflections::uncountable("money", "information")
|
||||||
|
# Inflections::uncountable(array("money", "information", "rice"))
|
||||||
|
function uncountable() {
|
||||||
|
$args = func_get_args();
|
||||||
|
if(is_array($args[0])) {
|
||||||
|
$args = $args[0];
|
||||||
|
}
|
||||||
|
foreach($args as $word) {
|
||||||
|
self::$uncountables[] = $word;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clears the loaded inflections within a given scope (functionault is :all). Give the scope as a symbol of the inflection type,
|
||||||
|
# the options are: "plurals", "singulars", "uncountables"
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# Inflections::clear("all")
|
||||||
|
# Inflections::clear("plurals")
|
||||||
|
function clear($scope = "all") {
|
||||||
|
if($scope == "all") {
|
||||||
|
self::$plurals = self::$singulars = self::$uncountables = array();
|
||||||
|
} else {
|
||||||
|
self::$$scope = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
216
vendor/zynapse/inflector.php
vendored
Normal file
216
vendor/zynapse/inflector.php
vendored
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* File containing the Inflector class
|
||||||
|
*
|
||||||
|
* (PHP 5)
|
||||||
|
*
|
||||||
|
* @package PHPonTrax
|
||||||
|
* @version $Id: inflector.php 201 2006-05-25 08:58:10Z john $
|
||||||
|
* @copyright (c) 2005 John Peterson
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modified by Jim Myhrberg for use in Zynapse framework.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
include_once(ZNAP_LIB_ROOT . "/inflections.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement the Trax naming convention
|
||||||
|
*
|
||||||
|
* This class provides static methods to implement the
|
||||||
|
* {@tutorial PHPonTrax/naming.pkg Trax naming convention}.
|
||||||
|
* Inflector is never instantiated.
|
||||||
|
* @tutorial PHPonTrax/Inflector.cls
|
||||||
|
*/
|
||||||
|
class Inflector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pluralize a word according to English rules
|
||||||
|
*
|
||||||
|
* Convert a lower-case singular word to plural form.
|
||||||
|
* @param string $word Word to be pluralized
|
||||||
|
* @return string Plural of $word
|
||||||
|
*/
|
||||||
|
function pluralize($word) {
|
||||||
|
if(!in_array($word, Inflections::$uncountables)) {
|
||||||
|
$original = $word;
|
||||||
|
foreach(Inflections::$plurals as $plural_rule) {
|
||||||
|
$word = preg_replace($plural_rule['rule'], $plural_rule['replacement'], $word);
|
||||||
|
if($original != $word) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singularize a word according to English rules
|
||||||
|
*
|
||||||
|
* @param string $word Word to be singularized
|
||||||
|
* @return string Singular of $word
|
||||||
|
*/
|
||||||
|
function singularize($word) {
|
||||||
|
if(!in_array($word, Inflections::$uncountables)) {
|
||||||
|
$original = $word;
|
||||||
|
foreach(Inflections::$singulars as $singular_rule) {
|
||||||
|
$word = preg_replace($singular_rule['rule'], $singular_rule['replacement'], $word);
|
||||||
|
if($original != $word) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capitalize a word making it all lower case with first letter uppercase
|
||||||
|
*
|
||||||
|
* @param string $word Word to be capitalized
|
||||||
|
* @return string Capitalized $word
|
||||||
|
*/
|
||||||
|
function capitalize($word) {
|
||||||
|
return ucfirst(strtolower($word));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a phrase from the lower case and underscored form
|
||||||
|
* to the camel case form
|
||||||
|
*
|
||||||
|
* @param string $lower_case_and_underscored_word Phrase to
|
||||||
|
* convert
|
||||||
|
* @return string Camel case form of the phrase
|
||||||
|
*/
|
||||||
|
function camelize($lower_case_and_underscored_word) {
|
||||||
|
return str_replace(" ","",ucwords(str_replace("_"," ",$lower_case_and_underscored_word)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a phrase from the camel case form to the lower case
|
||||||
|
* and underscored form
|
||||||
|
*
|
||||||
|
* @param string $camel_cased_word Phrase to convert
|
||||||
|
* @return string Lower case and underscored form of the phrase
|
||||||
|
*/
|
||||||
|
function underscore($camel_cased_word) {
|
||||||
|
$camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2',$camel_cased_word);
|
||||||
|
return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2',$camel_cased_word));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a more human version of a lower case underscored word
|
||||||
|
*
|
||||||
|
* @param string $lower_case_and_underscored_word A word or phrase in
|
||||||
|
* lower_case_underscore form
|
||||||
|
* @return string The input value with underscores replaced by
|
||||||
|
* blanks and the first letter of each word capitalized
|
||||||
|
*/
|
||||||
|
function humanize($lower_case_and_underscored_word) {
|
||||||
|
return ucwords(str_replace("_"," ",$lower_case_and_underscored_word));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a word or phrase into a title format "Welcome To My Site"
|
||||||
|
*
|
||||||
|
* @param string $word A word or phrase
|
||||||
|
* @return string A string that has all words capitalized and splits on existing caps.
|
||||||
|
*/
|
||||||
|
function titleize($word) {
|
||||||
|
return preg_replace('/\b([a-z])/', self::capitalize('$1'), self::humanize(self::underscore($word)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a word's underscores into dashes
|
||||||
|
*
|
||||||
|
* @param string $underscored_word Word to convert
|
||||||
|
* @return string All underscores converted to dashes
|
||||||
|
*/
|
||||||
|
function dasherize($underscored_word) {
|
||||||
|
return str_replace('_', '-', self::underscore($underscored_word));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a class name to the corresponding table name
|
||||||
|
*
|
||||||
|
* The class name is a singular word or phrase in CamelCase.
|
||||||
|
* By convention it corresponds to a table whose name is a plural
|
||||||
|
* word or phrase in lower case underscore form.
|
||||||
|
* @param string $class_name Name of {@link ActiveRecord} sub-class
|
||||||
|
* @return string Pluralized lower_case_underscore form of name
|
||||||
|
*/
|
||||||
|
function tableize($class_name) {
|
||||||
|
return self::pluralize(self::underscore($class_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a table name to the corresponding class name
|
||||||
|
*
|
||||||
|
* @param string $table_name Name of table in the database
|
||||||
|
* @return string Singular CamelCase form of $table_name
|
||||||
|
*/
|
||||||
|
function classify($table_name) {
|
||||||
|
return self::camelize(self::singularize($table_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get foreign key column corresponding to a table name
|
||||||
|
*
|
||||||
|
* @param string $table_name Name of table referenced by foreign
|
||||||
|
* key
|
||||||
|
* @return string Column name of the foreign key column
|
||||||
|
*/
|
||||||
|
function foreign_key($class_name) {
|
||||||
|
return self::underscore($class_name) . "_id";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to a number st, nd, rd, th
|
||||||
|
*
|
||||||
|
* @param integer $number Number to append to
|
||||||
|
* key
|
||||||
|
* @return string Number formatted with correct st, nd, rd, or th
|
||||||
|
*/
|
||||||
|
function ordinalize($number) {
|
||||||
|
$test = (intval($number) % 100);
|
||||||
|
if($test >= 11 && $test <= 13) {
|
||||||
|
$number = "{$number}th";
|
||||||
|
} else {
|
||||||
|
switch((intval($number) % 10)) {
|
||||||
|
case 1:
|
||||||
|
$number = "{$number}st";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$number = "{$number}nd";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$number = "{$number}rd";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$number = "{$number}th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $number;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
41
vendor/zynapse/input_filter.php
vendored
Normal file
41
vendor/zynapse/input_filter.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse InputFilter - various user-input filters
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class InputFilter {
|
||||||
|
|
||||||
|
//TODO create InputFilter class (or not?)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
257
vendor/zynapse/preferences.php
vendored
Normal file
257
vendor/zynapse/preferences.php
vendored
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Preferences - simple and powerful preference management
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class PreferenceCollection {
|
||||||
|
|
||||||
|
public static
|
||||||
|
$__current_pref_file = null;
|
||||||
|
|
||||||
|
public
|
||||||
|
$__pref_paths = array();
|
||||||
|
|
||||||
|
|
||||||
|
function __construct ($pref_paths = array()) {
|
||||||
|
if ( !empty($pref_paths) ) {
|
||||||
|
if ( is_array($pref_paths) ) {
|
||||||
|
$this->__pref_paths = $pref_paths;
|
||||||
|
} elseif ( is_string($pref_paths) ) {
|
||||||
|
$this->__pref_paths = array($pref_paths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function __get ($property) {
|
||||||
|
if ( isset($this->$property) ) {
|
||||||
|
return $this->$property;
|
||||||
|
} elseif ($this->read($property)) {
|
||||||
|
return $this->$property;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function read ($pref, $force_create = false, $create_path = null) {
|
||||||
|
if ( !isset($this->$pref) && count($this->__pref_paths) > 0 ) {
|
||||||
|
$valid_path = false;
|
||||||
|
for ( $i=0; $i < count($this->__pref_paths); $i++ ) {
|
||||||
|
if ( is_file($this->__pref_paths[$i].'/'.$pref.'.prefs.php') ) {
|
||||||
|
$valid_path = $this->__pref_paths[$i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $valid_path !== false ) {
|
||||||
|
include_once($valid_path.'/'.$pref.'.prefs.php');
|
||||||
|
$class = $pref.'_preferences';
|
||||||
|
if ( class_exists($class) ) {
|
||||||
|
self::$__current_pref_file = $valid_path.'/'.$pref.'.prefs.php';
|
||||||
|
$this->$pref = new $class();
|
||||||
|
self::$__current_pref_file = null;
|
||||||
|
if ( is_object($this->$pref) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ( $force_create ) {
|
||||||
|
$object = new PreferenceContainer();
|
||||||
|
if ( $create_path == null ) {
|
||||||
|
$create_path = $this->__pref_paths[0];
|
||||||
|
}
|
||||||
|
if ( $object->save($pref, $create_path) ) {
|
||||||
|
$this->read($pref);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreferenceContainer {
|
||||||
|
|
||||||
|
|
||||||
|
private $__file = null;
|
||||||
|
|
||||||
|
|
||||||
|
function __construct ($__file = null) {
|
||||||
|
if ( PreferenceCollection::$__current_pref_file !== null ) {
|
||||||
|
$this->__file = PreferenceCollection::$__current_pref_file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function save ($pref = null, $save_path = null, $data = null) {
|
||||||
|
|
||||||
|
// use $this for data if none is specified
|
||||||
|
if ( $data == null ) {
|
||||||
|
$data = &$this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get class and preference name
|
||||||
|
if ( empty($pref) ) {
|
||||||
|
$class = get_class($this);
|
||||||
|
$pref = substr($class, 0, -12);
|
||||||
|
} else {
|
||||||
|
$class = $pref.'_preferences';
|
||||||
|
}
|
||||||
|
|
||||||
|
// start building output
|
||||||
|
$output = "<?php\n";
|
||||||
|
$output .= "/*\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= " Zynapse Preference Class\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= " This class is used to store preferences, it is humanly editable\n";
|
||||||
|
$output .= " and requires no overhead processing to be loaded.\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= "*/\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= 'class '.$class." extends PreferenceContainer {\n";
|
||||||
|
$output .= "\t\n";
|
||||||
|
|
||||||
|
foreach( $data as $key => $value ) {
|
||||||
|
if ( $key != '__file' ) {
|
||||||
|
$output .= "\tpublic \$".$key.";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= "\t\n";
|
||||||
|
$output .= "\tfunction __construct () {\n";
|
||||||
|
$output .= "\t\tparent::__construct();\n";
|
||||||
|
$output .= "\t\t\n";
|
||||||
|
|
||||||
|
foreach( $data as $key => $value ) {
|
||||||
|
if ( $key != '__file' ) {
|
||||||
|
$output .= $this->output_var('this->'.$key, $value, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= "\t}\n";
|
||||||
|
$output .= "\t\n";
|
||||||
|
$output .= "}\n";
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= "?>";
|
||||||
|
|
||||||
|
// determine output filename
|
||||||
|
if ( $save_path == null ) {
|
||||||
|
if ( !empty($this->__file) ) {
|
||||||
|
$file = $this->__file;
|
||||||
|
}
|
||||||
|
} elseif ( is_dir($save_path) ) {
|
||||||
|
$file = $save_path.'/'.$pref.'.prefs.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
// output data to file
|
||||||
|
if ( !empty($file) ) {
|
||||||
|
if ( !is_file($file) ) {
|
||||||
|
$creating = true;
|
||||||
|
}
|
||||||
|
if ( file_put_contents($file, $output) ) {
|
||||||
|
if ( isset($creating) ) {
|
||||||
|
chmod($file, 0666);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_var ($var, $value = '', $indent = 0) {
|
||||||
|
$output = $this->output_indent($indent);
|
||||||
|
$output .= '$'.$var.' = '.$this->output_value($value, $indent).";\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_value ($value = '', $indent = 0) {
|
||||||
|
$output = '';
|
||||||
|
if ( is_null($value) ) {
|
||||||
|
$output .= 'null';
|
||||||
|
} elseif ( is_bool($value) ) {
|
||||||
|
$output .= ($value) ? 'true' : 'false' ;
|
||||||
|
} elseif ( is_int($value) || is_float($value) ) {
|
||||||
|
$output .= $value;
|
||||||
|
} elseif ( is_string($value) ) {
|
||||||
|
$output .= $this->output_string($value);
|
||||||
|
} elseif ( is_array($value) ) {
|
||||||
|
$output .= $this->output_array($value, ($indent + 1));
|
||||||
|
} elseif ( is_object($value) ) {
|
||||||
|
$output .= 'unserialize('.$this->output_string(serialize($value)).')';
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_array ($array, $indent = 1) {
|
||||||
|
$output = "array(\n";
|
||||||
|
foreach( $array as $key => $value ) {
|
||||||
|
$output .= $this->output_array_item($key, $value, $indent);
|
||||||
|
}
|
||||||
|
for ( $i=0; $i < ($indent - 1); $i++ ) {
|
||||||
|
$output .= "\t";
|
||||||
|
}
|
||||||
|
return $output.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_array_item ($key, $value = '', $indent = 0, $register_objects = false) {
|
||||||
|
$output = $this->output_indent($indent);
|
||||||
|
$output .= "'".$key."' => ";
|
||||||
|
$output .= $this->output_value($value, $indent).",\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_string ($string) {
|
||||||
|
$string = str_replace("\"", "\\\"", $string);
|
||||||
|
$string = str_replace("\'", "\\\'", $string);
|
||||||
|
$string = str_replace("\0", "\\0", $string);
|
||||||
|
$string = str_replace("\n", "\\n", $string);
|
||||||
|
$string = str_replace("\r", "\\r", $string);
|
||||||
|
$string = str_replace("\t", "\\t", $string);
|
||||||
|
return '"'.$string.'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_indent ($indent) {
|
||||||
|
$output = '';
|
||||||
|
for ( $i=0; $i < $indent; $i++ ) {
|
||||||
|
$output .= "\t";
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
148
vendor/zynapse/router.php
vendored
Normal file
148
vendor/zynapse/router.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Router - url path parser
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
Based on router.php from PHPOnTrax.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Router {
|
||||||
|
|
||||||
|
private $routes = array();
|
||||||
|
private $selected_route = null;
|
||||||
|
|
||||||
|
public $default_route_path = ':controller/:action/:id';
|
||||||
|
public $routes_count = 0;
|
||||||
|
public $url;
|
||||||
|
|
||||||
|
|
||||||
|
function get_selected_route () {
|
||||||
|
return $this->selected_route;
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect ( $url, $params = null ) {
|
||||||
|
if ( !is_array($params) ) $params = null;
|
||||||
|
$this->routes[] = array(
|
||||||
|
'path' => $url,
|
||||||
|
'params' => $params,
|
||||||
|
);
|
||||||
|
$this->routes_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function find_route ($url = null) {
|
||||||
|
if ( $this->url === null ) $this->url = $this->get_url_path();
|
||||||
|
if ( $this->routes_count == 0 ) $this->connect($this->default_route_path);
|
||||||
|
foreach( $this->routes as $key => $route ) {
|
||||||
|
$regex = $this->build_regex_path($route['path']);
|
||||||
|
if ( $regex['regex'] != '' ) {
|
||||||
|
$route['path'] = $regex['path'];
|
||||||
|
}
|
||||||
|
$regex = $regex['regex'];
|
||||||
|
if ( $url == '' && $regex == '' ) {
|
||||||
|
$selected_route = $route;
|
||||||
|
break;
|
||||||
|
} elseif ( $regex != '' && preg_match('/^'.$regex.'$/i', $url) ) {
|
||||||
|
$selected_route = $route;
|
||||||
|
break;
|
||||||
|
} elseif ( $route['path'] == $this->default_route_path ) {
|
||||||
|
$selected_route = $route;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( isset($selected_route) ) {
|
||||||
|
$this->selected_route = $selected_route;
|
||||||
|
return $selected_route;
|
||||||
|
} else {
|
||||||
|
$this->selected_route = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function build_regex_path ($path) {
|
||||||
|
if ( is_array($path) ) {
|
||||||
|
return $path;
|
||||||
|
} else {
|
||||||
|
$path = explode('/', $path);
|
||||||
|
$regex = array();
|
||||||
|
$new_path = array();
|
||||||
|
$regex_foot = '';
|
||||||
|
if ( count($path) ) {
|
||||||
|
foreach( $path as $element ) {
|
||||||
|
$elm_foot = '';
|
||||||
|
if ( strlen($element) > 0 && substr($element, -1, 1) == '?' ) {
|
||||||
|
$elm_foot = '(?:';
|
||||||
|
$regex_foot .= '|$)';
|
||||||
|
$element = substr($element, 0, strlen($element)-1);
|
||||||
|
}
|
||||||
|
if ( preg_match('/^(:[a-z0-9_\-]+)\((.*)\)$/i', $element, $capture) ) {
|
||||||
|
$regex[] = '(?:'.$capture[2].')'.$elm_foot;
|
||||||
|
$new_path[] = $capture[1];
|
||||||
|
} elseif ( preg_match('/^:[a-z0-9_\-]+$/i', $element) ) {
|
||||||
|
$regex[] = '(?:[a-z0-9_\-]+?)'.$elm_foot;
|
||||||
|
$new_path[] = $element;
|
||||||
|
} elseif ( preg_match('/^[a-z0-9_\-]+$/i', $element) ) {
|
||||||
|
$regex[] = $element.$elm_foot;
|
||||||
|
$new_path[] = $element;
|
||||||
|
} elseif ( Znap::$allow_dangerous_url_paths ) {
|
||||||
|
$regex[] = $element.$elm_foot;
|
||||||
|
$new_path[] = $element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$regex = implode('\/', $regex).$regex_foot;
|
||||||
|
$new_path = implode('/', $new_path);
|
||||||
|
return array('regex' => $regex, 'path' => $new_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_url_path ($prefix = null) {
|
||||||
|
if ( isset($_SERVER['REDIRECT_URL']) && !stristr($_SERVER['REDIRECT_URL'], 'dispatch.php') ) {
|
||||||
|
$url = $_SERVER['REDIRECT_URL'];
|
||||||
|
} elseif ( isset($_SERVER['REQUEST_URI']) ) {
|
||||||
|
if ( !strstr($_SERVER['REQUEST_URI'], '?') ) {
|
||||||
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
|
} else {
|
||||||
|
$url = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( isset($url) ) {
|
||||||
|
$url = trim($url, '/');
|
||||||
|
if ( !is_null(Znap::$url_prefix) && substr($url, 0, strlen(Znap::$url_prefix)) == Znap::$url_prefix ) {
|
||||||
|
$url = ltrim(substr($url, strlen(Znap::$url_prefix)), '/');
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
193
vendor/zynapse/session.php
vendored
Normal file
193
vendor/zynapse/session.php
vendored
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Session - session handling and flash notices
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Session {
|
||||||
|
|
||||||
|
# session name
|
||||||
|
const ZNAP_SESSION_NAME = 'PHPSESSID';
|
||||||
|
|
||||||
|
# session cookie_lifetime - defined in minutes
|
||||||
|
const ZNAP_SESSION_LIFETIME = 0;
|
||||||
|
|
||||||
|
# max session lifetime - defined in minutes
|
||||||
|
const ZNAP_SESSION_MAXLIFETIME = 30;
|
||||||
|
|
||||||
|
# php.ini setting: session.use_only_cookies
|
||||||
|
const ZNAP_SESSION_USE_ONLY_COOKIES = false;
|
||||||
|
|
||||||
|
# php.ini setting: session.gc_probability
|
||||||
|
const ZNAP_SESSION_GC_PROBABILITY = 1;
|
||||||
|
|
||||||
|
# php.ini setting: session.gc_divisor
|
||||||
|
const ZNAP_SESSION_GC_DIVISOR = 100;
|
||||||
|
|
||||||
|
# php.ini setting: session.cache_limiter
|
||||||
|
const ZNAP_SESSION_CACHE_LIMITER = 'nocache';
|
||||||
|
|
||||||
|
# session security features
|
||||||
|
# 0 = no extra security features
|
||||||
|
# 1 = user agent string is verified
|
||||||
|
# 2 = user agent string, and client ip address are verified
|
||||||
|
const ZNAP_SESSION_SECURITY = 1;
|
||||||
|
|
||||||
|
|
||||||
|
public static
|
||||||
|
|
||||||
|
# client user agent (OS, browser, etc.)
|
||||||
|
$user_agent = null,
|
||||||
|
|
||||||
|
# client's remote ip address
|
||||||
|
$ip = null,
|
||||||
|
|
||||||
|
# session id
|
||||||
|
$id = null,
|
||||||
|
|
||||||
|
# session key to store verification data in
|
||||||
|
$key = '____zynapse_secure_session_data_verification____',
|
||||||
|
|
||||||
|
# Session class has been started?
|
||||||
|
$started = false;
|
||||||
|
|
||||||
|
|
||||||
|
# internal vars
|
||||||
|
protected static
|
||||||
|
$session_name,
|
||||||
|
$session_lifetime,
|
||||||
|
$session_maxlifetime,
|
||||||
|
$session_use_only_cookies,
|
||||||
|
$session_gc_probability,
|
||||||
|
$session_gc_divisor,
|
||||||
|
$session_cache_limiter,
|
||||||
|
$session_security;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function start () {
|
||||||
|
if ( !self::$started ) {
|
||||||
|
self::var_setup();
|
||||||
|
self::ini_setup();
|
||||||
|
|
||||||
|
self::$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
self::$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
if ( !self::$session_use_only_cookies && array_key_exists('sess_id', $_REQUEST) ) {
|
||||||
|
session_id($_REQUEST['sess_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
self::$id = session_id();
|
||||||
|
self::$started = true;
|
||||||
|
|
||||||
|
self::validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function session_destroy () {
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate () {
|
||||||
|
if ( isset($_SESSION[self::$key]) && count($_SESSION[self::$key]) ) {
|
||||||
|
$valid = true;
|
||||||
|
if ( self::$session_security > 0 && (!isset($_SESSION[self::$key]['user_agent']) || $_SESSION[self::$key]['user_agent'] != self::$user_agent) ) {
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
|
if ( self::$session_security > 1 ) {
|
||||||
|
if ( !self::is_aol_host() && (!isset($_SESSION[self::$key]['ip']) || $_SESSION[self::$key]['ip'] != self::$ip) ) {
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !$valid ) {
|
||||||
|
$_SESSION = array();
|
||||||
|
self::validate();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_SESSION[self::$key] = array(
|
||||||
|
'user_agent' => self::$user_agent,
|
||||||
|
'ip' => self::$ip,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_aol_host () {
|
||||||
|
if ( stristr(self::$user_agent, 'AOL') || preg_match('/proxy\.aol\.com$/i', gethostbyaddr(self::$ip)) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function var_setup () {
|
||||||
|
self::$session_name = defined('ZNAP_SESSION_NAME') ? ZNAP_SESSION_NAME : self::ZNAP_SESSION_NAME ;
|
||||||
|
self::$session_lifetime = defined('ZNAP_SESSION_LIFETIME') ? ZNAP_SESSION_LIFETIME : self::ZNAP_SESSION_LIFETIME ;
|
||||||
|
self::$session_maxlifetime = defined('ZNAP_SESSION_MAXLIFETIME') ? ZNAP_SESSION_MAXLIFETIME : self::ZNAP_SESSION_MAXLIFETIME ;
|
||||||
|
self::$session_use_only_cookies = defined('ZNAP_SESSION_USE_ONLY_COOKIES') ? ZNAP_SESSION_USE_ONLY_COOKIES : self::ZNAP_SESSION_USE_ONLY_COOKIES ;
|
||||||
|
self::$session_gc_probability = defined('ZNAP_SESSION_GC_PROBABILITY') ? ZNAP_SESSION_GC_PROBABILITY : self::ZNAP_SESSION_GC_PROBABILITY ;
|
||||||
|
self::$session_gc_divisor = defined('ZNAP_SESSION_GC_DIVISOR') ? ZNAP_SESSION_GC_DIVISOR : self::ZNAP_SESSION_GC_DIVISOR ;
|
||||||
|
self::$session_cache_limiter = defined('ZNAP_SESSION_CACHE_LIMITER') ? ZNAP_SESSION_CACHE_LIMITER : self::ZNAP_SESSION_CACHE_LIMITER ;
|
||||||
|
self::$session_security = defined('ZNAP_SESSION_SECURITY') ? ZNAP_SESSION_SECURITY : self::ZNAP_SESSION_SECURITY ;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ini_setup () {
|
||||||
|
ini_set('session.name', self::$session_name);
|
||||||
|
ini_set('session.cookie_lifetime', self::$session_lifetime);
|
||||||
|
ini_set('session.gc_maxlifetime', self::$session_maxlifetime);
|
||||||
|
ini_set('session.use_only_cookies', self::$session_use_only_cookies);
|
||||||
|
ini_set('session.gc_probability', self::$session_gc_probability);
|
||||||
|
ini_set('session.gc_divisor', self::$session_gc_divisor);
|
||||||
|
ini_set('session.cache_limiter', self::$session_cache_limiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function flash ($key, $value = null) {
|
||||||
|
if ( $value !== null ) {
|
||||||
|
$_SESSION['flash'][$key] = $value;
|
||||||
|
} else {
|
||||||
|
$value = $_SESSION['flash'][$key];
|
||||||
|
if ( !Znap::$keep_flash ) unset($_SESSION['flash'][$key]);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isset_flash ($key) {
|
||||||
|
if ( isset($_SESSION['flash'][$key]) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
54
vendor/zynapse/shell_script.php
vendored
Normal file
54
vendor/zynapse/shell_script.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse ShellScript - provides basic funtionality for shell script classes
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ShellScript {
|
||||||
|
|
||||||
|
public $command = null;
|
||||||
|
public $script = null;
|
||||||
|
public $argv = array();
|
||||||
|
|
||||||
|
|
||||||
|
function __construct () {
|
||||||
|
|
||||||
|
// set default vars
|
||||||
|
if ( isset($_SERVER['argv']) ) {
|
||||||
|
$this->command = array_shift($_SERVER['argv']);
|
||||||
|
$this->script = basename($this->command);
|
||||||
|
$this->argv = $_SERVER['argv'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
115
vendor/zynapse/shell_scripts/fix_permissions.php
vendored
Normal file
115
vendor/zynapse/shell_scripts/fix_permissions.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Generator - generate controllers, models, and more
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class FixPermissions extends ShellScript {
|
||||||
|
|
||||||
|
|
||||||
|
function run () {
|
||||||
|
|
||||||
|
// preference folder and all preference files
|
||||||
|
$list[] = Znap::$tmp_path;
|
||||||
|
$list = array_merge($list, glob(Znap::$tmp_path.'/cache.prefs.php'));
|
||||||
|
$list[] = Znap::$cache_path;
|
||||||
|
$list[] = Znap::$prefs_path;
|
||||||
|
$list = array_merge($list, glob(Znap::$prefs_path.'/*.prefs.php'));
|
||||||
|
$list[] = Znap::$log_path;
|
||||||
|
$list = array_merge($list, glob(Znap::$log_path.'/*.log'));
|
||||||
|
|
||||||
|
foreach( $list as $item ) {
|
||||||
|
if ( !$this->check($item) ) {
|
||||||
|
if ( $this->change($item) ) {
|
||||||
|
$this->echo_changed($item);
|
||||||
|
} else {
|
||||||
|
$this->echo_change_error($item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_ok($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function check ($item) {
|
||||||
|
if ( is_file($item) && substr(sprintf('%o', fileperms($item)), -4) == '0666' ) {
|
||||||
|
return true;
|
||||||
|
} elseif ( is_dir($item) && substr(sprintf('%o', fileperms($item)), -4) == '0777' ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function change ($item) {
|
||||||
|
if ( is_file($item) ) {
|
||||||
|
$this->chmod($item, '0666');
|
||||||
|
} elseif ( is_dir($item) ) {
|
||||||
|
$this->chmod($item, '0777');
|
||||||
|
}
|
||||||
|
clearstatcache();
|
||||||
|
return $this->check($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
function chmod ($item, $mode) {
|
||||||
|
exec(Znap::$chmod_cmd.' '.$mode.' "'.$item.'"');
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_changed ($item, $mode = null) {
|
||||||
|
if ( $mode == null ) {
|
||||||
|
if ( is_file($item) ) {
|
||||||
|
$mode = '0666';
|
||||||
|
} elseif ( is_dir($item) ) {
|
||||||
|
$mode = '0777';
|
||||||
|
$item .= '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' changed to '.$mode.".\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_change_error ($item, $mode = null) {
|
||||||
|
echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' is '.substr(sprintf('%o', fileperms($item)), -4)." and could not be changed to 0666.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_ok ($item, $mode = null) {
|
||||||
|
if ( $mode == null ) {
|
||||||
|
if ( is_file($item) ) {
|
||||||
|
$mode = '0666';
|
||||||
|
} elseif ( is_dir($item) ) {
|
||||||
|
$mode = '0777';
|
||||||
|
$item .= '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' is '.$mode.".\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
202
vendor/zynapse/shell_scripts/znap_generator.php
vendored
Normal file
202
vendor/zynapse/shell_scripts/znap_generator.php
vendored
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Generator - generate controllers, models, and more
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ZnapGenerator extends ShellScript {
|
||||||
|
|
||||||
|
private
|
||||||
|
$generator_file = null,
|
||||||
|
$generator_class = null,
|
||||||
|
$generator_object = null;
|
||||||
|
|
||||||
|
public
|
||||||
|
$args = array(),
|
||||||
|
$type = null,
|
||||||
|
$name = null,
|
||||||
|
$templates_path = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function run () {
|
||||||
|
if ( $this->get_args() ) {
|
||||||
|
$this->templates_path = Znap::$shell_scripts_path.'/znap_generator/templates';
|
||||||
|
$this->generator_file = Znap::$shell_scripts_path.'/znap_generator/'.$this->type.'_generator.php';
|
||||||
|
$this->generator_class = Inflector::camelize($this->type).'Generator';
|
||||||
|
|
||||||
|
if ( is_file($this->generator_file) ) {
|
||||||
|
require_once($this->generator_file);
|
||||||
|
if ( class_exists($this->generator_class) ) {
|
||||||
|
$class = $this->generator_class;
|
||||||
|
$this->generator_object = new $class();
|
||||||
|
if ( is_object($this->generator_object) ) {
|
||||||
|
$this->generator_object->type = $this->type;
|
||||||
|
$this->generator_object->templates_path = $this->templates_path;
|
||||||
|
if ( !is_null($this->name) ) {
|
||||||
|
$this->generator_object->name = $this->name;
|
||||||
|
$this->generator_object->args = $this->args;
|
||||||
|
return $this->generator_object->generate();
|
||||||
|
} else {
|
||||||
|
$this->generator_object->help();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "\nERROR: Failed to initiate generator object.\n\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "\nERROR: Invalid generate type.\n\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "\nERROR: Invalid generate type.\n\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->generator_help();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_args () {
|
||||||
|
if ( !empty($this->argv[0]) ) {
|
||||||
|
$this->args = $this->argv;
|
||||||
|
$this->type = array_shift($this->args);
|
||||||
|
if ( isset($this->args[0]) && $this->args[0] != '' ) {
|
||||||
|
$this->name = $this->args[0];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function generator_help () {
|
||||||
|
$generators = glob(Znap::$shell_scripts_path.'/znap_generator/*_generator.php');
|
||||||
|
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage:\n";
|
||||||
|
echo "---------------------------------\n";
|
||||||
|
|
||||||
|
if ( ($count = count($generators)) > 0 ) {
|
||||||
|
for ( $i=0; $i < $count; $i++ ) {
|
||||||
|
include_once($generators[$i]);
|
||||||
|
$filename = basename($generators[$i]);
|
||||||
|
$name = substr($filename, 0, strrpos($filename, '_'));
|
||||||
|
call_user_func(array(Inflector::camelize($name).'Generator', 'help_summary'));
|
||||||
|
if ( $i < $count - 1 ) {
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "---------------------------------\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function echo_create ($item) {
|
||||||
|
echo "\tcreate ".str_replace(ZNAP_ROOT.'/', '', $item)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_exists ($item) {
|
||||||
|
echo "\texists ".str_replace(ZNAP_ROOT.'/', '', $item)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_create_error ($item, $type = null) {
|
||||||
|
echo 'ERROR: Could not create';
|
||||||
|
if ( $type !== null && is_string($type) ) {
|
||||||
|
echo ' '.$type.' file';
|
||||||
|
}
|
||||||
|
echo ': '.str_replace(ZNAP_ROOT.'/', '', $item)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_template_error ($item, $type = null) {
|
||||||
|
echo 'ERROR: ';
|
||||||
|
if ( $type !== null && is_string($type) ) {
|
||||||
|
echo ucfirst($type).' template';
|
||||||
|
} else {
|
||||||
|
echo 'Template';
|
||||||
|
}
|
||||||
|
echo ' file does not exist: '.str_replace(ZNAP_ROOT.'/', '', $item)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_path($path) {
|
||||||
|
if ( is_dir($path) ) {
|
||||||
|
$this->echo_exists($path.'/');
|
||||||
|
} elseif ( $this->dir_exists($path) ) {
|
||||||
|
$this->echo_create($path.'/');
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($path.'/');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dir_exists ($path) {
|
||||||
|
if ( !is_dir($path) ) {
|
||||||
|
if ( strstr($path, '/') ) {
|
||||||
|
$path_array = explode('/', $path);
|
||||||
|
} else {
|
||||||
|
$path_array = array($path);
|
||||||
|
}
|
||||||
|
$current_dir = $path_array[0];
|
||||||
|
unset($path_array[0]);
|
||||||
|
foreach( $path_array as $dir ) {
|
||||||
|
$current_dir .= '/'.$dir;
|
||||||
|
if ( $current_dir != '' && !is_dir($current_dir) ) {
|
||||||
|
exec(Znap::$mkdir_cmd.' "'.$current_dir.'"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !is_dir($path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
229
vendor/zynapse/shell_scripts/znap_generator/controller_generator.php
vendored
Normal file
229
vendor/zynapse/shell_scripts/znap_generator/controller_generator.php
vendored
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Controller Generator - generate controllers
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ControllerGenerator extends ZnapGenerator {
|
||||||
|
|
||||||
|
public
|
||||||
|
$class_name = null,
|
||||||
|
$extra_path = null,
|
||||||
|
$controller_path = null,
|
||||||
|
$views_path = null,
|
||||||
|
$view_root_paths = array(),
|
||||||
|
$helper_path = null,
|
||||||
|
$methods = array();
|
||||||
|
|
||||||
|
|
||||||
|
function generate () {
|
||||||
|
if ( !preg_match('/^[a-zA-Z0-9\/\\\_-]+$/', $this->name) ) {
|
||||||
|
echo "ERROR: Invalid snippet name given.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( strstr($this->name, '/') ) {
|
||||||
|
$this->extra_path = substr($this->name, 0, strripos($this->name, '/'));
|
||||||
|
$this->name = Inflector::underscore(substr(strrchr($this->name, '/'), 1));
|
||||||
|
$this->views_path = '/_'.$this->extra_path.'/'.$this->name;
|
||||||
|
$this->controller_path = '/'.$this->extra_path;
|
||||||
|
$this->helper_path = '/'.$this->extra_path;
|
||||||
|
} else {
|
||||||
|
$this->name = Inflector::underscore($this->name);
|
||||||
|
$this->views_path = '/'.$this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->name = Inflector::singularize($this->name);
|
||||||
|
$this->class_name = Inflector::camelize($this->name);
|
||||||
|
|
||||||
|
// get method/view arguments
|
||||||
|
if ( isset($this->args[1]) ) {
|
||||||
|
for ( $i=1; $i < count($this->args); $i++ ) {
|
||||||
|
$this->methods[$i] = $this->args[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all "views*" paths
|
||||||
|
$this->find_view_paths();
|
||||||
|
|
||||||
|
// validate that target controller path exists, or attempt to create if it doesn't
|
||||||
|
if ( !$this->validate_path(Znap::$controllers_path.$this->controller_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate that target helper path exists, or attempt to create if it doesn't
|
||||||
|
if ( !$this->validate_path(Znap::$helpers_path.$this->helper_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate that target view paths exists, or attempt to create if it doesn't
|
||||||
|
foreach( $this->view_root_paths as $key => $path ) {
|
||||||
|
if ( !$this->validate_path($path.$this->views_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->create_controller();
|
||||||
|
$this->create_helper();
|
||||||
|
$this->create_views();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function create_controller () {
|
||||||
|
$controller_template = $this->templates_path.'/controller.php';
|
||||||
|
$controller_file = Znap::$controllers_path.$this->controller_path.'/'.$this->name.'_controller.php';
|
||||||
|
|
||||||
|
if ( !is_file($controller_file) ) {
|
||||||
|
if ( is_file($controller_template) ) {
|
||||||
|
// controller
|
||||||
|
$controller = file_get_contents($controller_template);
|
||||||
|
$controller = str_replace('[class_name]', $this->class_name, $controller);
|
||||||
|
if ( count($this->methods) ) {
|
||||||
|
$methods = array();
|
||||||
|
foreach( $this->methods as $method ) {
|
||||||
|
$methods[] = "\tfunction ".$method." () {\n\t\t\n\t}\n";
|
||||||
|
}
|
||||||
|
$controller = str_replace('[class_methods]', "\t\n".implode("\n", $methods), $controller);
|
||||||
|
} else {
|
||||||
|
$controller = str_replace('[class_methods]', "\t", $controller);
|
||||||
|
}
|
||||||
|
if ( file_put_contents($controller_file, $controller) ) {
|
||||||
|
$this->echo_create($controller_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($controller_file, 'controller');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($controller_template, 'controller');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($controller_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_helper () {
|
||||||
|
$helper_template = $this->templates_path.'/helper.php';
|
||||||
|
$helper_file = Znap::$helpers_path.$this->helper_path.'/'.$this->name.'_helper.php';
|
||||||
|
|
||||||
|
if ( !is_file($helper_file) ) {
|
||||||
|
if ( is_file($helper_template) ) {
|
||||||
|
$helper = file_get_contents($helper_template);
|
||||||
|
$helper = str_replace('[class_name]', $this->class_name, $helper);
|
||||||
|
if ( file_put_contents($helper_file, $helper) ) {
|
||||||
|
$this->echo_create($helper_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($helper_file, 'helper');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($helper_template, 'helper');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_views () {
|
||||||
|
$view_template = $this->templates_path.'/view.phtml';
|
||||||
|
|
||||||
|
if ( is_file($view_template) ) {
|
||||||
|
foreach( $this->view_root_paths as $path ) {
|
||||||
|
foreach( $this->methods as $view ) {
|
||||||
|
$view_file = $path.$this->views_path.'/'.$view.'.'.Znap::$views_extension;
|
||||||
|
if ( !is_file($view_file) ) {
|
||||||
|
$view_data = file_get_contents($view_template);
|
||||||
|
$view_data = str_replace('[class_name]', $this->class_name, $view_data);
|
||||||
|
$view_data = str_replace('[view]', $view, $view_data);
|
||||||
|
$view_data = str_replace('[controller]', $this->name, $view_data);
|
||||||
|
$view_data = str_replace('[view_file]', str_replace(Znap::$app_path.'/', '', $view_file), $view_data);
|
||||||
|
if ( file_put_contents($view_file, $view_data) ) {
|
||||||
|
$this->echo_create($view_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($view_file, 'view');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($view_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($view_template, 'view');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function find_view_paths () {
|
||||||
|
$this->view_root_paths = glob(Znap::$app_path.'/views*');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function help_summary () {
|
||||||
|
echo "Generate Controller:\n";
|
||||||
|
echo " ./script/generate controller controller_name [view1 view2 ...]\n";
|
||||||
|
echo " for more controller info: ./script/generate controller\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage: ./script/generate controller ControllerName [view1 view2 ...]\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Description:\n";
|
||||||
|
echo "\tThe controller generator creates functions for a new controller and\n";
|
||||||
|
echo "\tits views.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tThe generator takes a controller name and a list of views as arguments.\n";
|
||||||
|
echo "\tThe controller name may be given in CamelCase or under_score and should\n";
|
||||||
|
echo "\tnot be suffixed with 'Controller'. To create a controller within a\n";
|
||||||
|
echo "\tmodule, specify the controller name as 'folder/controller'.\n";
|
||||||
|
echo "\tThe generator creates a controller class in app/controllers with view\n";
|
||||||
|
echo "\ttemplates in app/views/controller_name.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Example:\n";
|
||||||
|
echo "\t./script/generate controller CreditCard open debit credit close\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tCredit card controller with URLs like /credit_card/debit.\n";
|
||||||
|
echo "\t\tController: app/controllers/credit_card_controller.php\n";
|
||||||
|
echo "\t\tViews: app/views/credit_card/debit.phtml [...]\n";
|
||||||
|
echo "\t\tHelper: app/helpers/credit_card_helper.php\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Module/Folders Example:\n";
|
||||||
|
echo "\t./script/generate controller admin/credit_card suspend late_fee\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tCredit card admin controller with URLs /admin/credit_card/suspend.\n";
|
||||||
|
echo "\t\tController: app/controllers/admin/credit_card_controller.php\n";
|
||||||
|
echo "\t\tViews: app/views/_admin/credit_card/suspend.phtml [...]\n";
|
||||||
|
echo "\t\tHelper: app/helpers/credit_card_helper.php\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
164
vendor/zynapse/shell_scripts/znap_generator/error_generator.php
vendored
Normal file
164
vendor/zynapse/shell_scripts/znap_generator/error_generator.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Error Generator - generate error templates
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorGenerator extends ZnapGenerator {
|
||||||
|
|
||||||
|
public
|
||||||
|
$error_code = null,
|
||||||
|
$environment = null,
|
||||||
|
$errors_path = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function generate () {
|
||||||
|
|
||||||
|
if ( preg_match('/^(?:[0-9]{1,3}|default)$/', $this->name) ) {
|
||||||
|
$this->error_code = &$this->name;
|
||||||
|
} else {
|
||||||
|
$this->echo_error_code();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($this->args[1]) && $this->args[1] != '' ) {
|
||||||
|
if ( preg_match('/^(?:development|test|production)$/i', $this->args[1]) ) {
|
||||||
|
$this->environment = $this->args[1];
|
||||||
|
$this->errors_path = str_replace(Znap::$views_path.'/', '', Znap::$errors_path).'/'.$this->environment;
|
||||||
|
} else {
|
||||||
|
$this->echo_error_env();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->errors_path = str_replace(Znap::$views_path.'/', '', Znap::$errors_default_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template_file = $this->determine_template();
|
||||||
|
|
||||||
|
$view_paths = glob(Znap::$app_path.'/views*');
|
||||||
|
|
||||||
|
foreach( $view_paths as $path ) {
|
||||||
|
if ( $this->validate_path($path.'/'.$this->errors_path) ) {
|
||||||
|
$error_file = $path.'/'.$this->errors_path.'/'.$this->error_code.'.'.Znap::$views_extension;
|
||||||
|
$template_data = file_get_contents($template_file);
|
||||||
|
if ( file_put_contents($error_file, $template_data) ) {
|
||||||
|
$this->echo_create($error_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($error_file, 'error');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($path.'/'.$this->errors_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function determine_template () {
|
||||||
|
if ( $this->environment != null && is_file($this->templates_path.'/error_'.$this->environment.'_'.$this->error_code.'.'.Znap::$views_extension) ) {
|
||||||
|
return $this->templates_path.'/error_'.$this->environment.'_'.$this->error_code.'.'.Znap::$views_extension;
|
||||||
|
} elseif ( $this->environment != null && is_file($this->templates_path.'/error_'.$this->environment.'_default.'.Znap::$views_extension) ) {
|
||||||
|
return $this->templates_path.'/error_'.$this->environment.'_default.'.Znap::$views_extension;
|
||||||
|
} elseif ( is_file($this->templates_path.'/error_'.$this->error_code.'.'.Znap::$views_extension) ) {
|
||||||
|
return $this->templates_path.'/error_'.$this->error_code.'.'.Znap::$views_extension;
|
||||||
|
} elseif ( is_file($this->templates_path.'/error_default.'.Znap::$views_extension) ) {
|
||||||
|
return $this->templates_path.'/error_default.'.Znap::$views_extension;
|
||||||
|
} else {
|
||||||
|
echo "ERROR: No suitable generate template file found.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function echo_error_code () {
|
||||||
|
echo "\n";
|
||||||
|
echo "ERROR: Invalid error code given.\n";
|
||||||
|
echo "Valid error codes are numbers 0 through 999 and \"default\".\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_error_env () {
|
||||||
|
echo "\n";
|
||||||
|
echo "ERROR: Invalid environment specified.\n";
|
||||||
|
echo "Valid environment values are:\n";
|
||||||
|
echo "\t- development\n";
|
||||||
|
echo "\t- test\n";
|
||||||
|
echo "\t- production\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function help_summary () {
|
||||||
|
echo "Generate Error Template:\n";
|
||||||
|
echo " ./script/generate error error_code [environment]\n";
|
||||||
|
echo " for more layout info: ./script/generate error\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage: ./script/generate error error_code [environment]\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Description:\n";
|
||||||
|
echo "\tGenerate error templates used for \"404 Page Not Found\" errors and\n";
|
||||||
|
echo "\tmore.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tSpecifying an error code is required. Valid error code values are\n";
|
||||||
|
echo "\tany of the standard HTTP errors, like 404 for example. Also\n";
|
||||||
|
echo "\t\"default\" can be used as the error code to generate the default\n";
|
||||||
|
echo "\terror template used when there is no template for the reported\n";
|
||||||
|
echo "\terror code.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tEnvironment can also be specified, but is not required. If an\n";
|
||||||
|
echo "\tenvironment is not specified, default will be used and the\n";
|
||||||
|
echo "\tresulting error template will apply for all environments if there\n";
|
||||||
|
echo "\tis no error template file for the current error code and\n";
|
||||||
|
echo "\tenvironment.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tValid environment values are \"development\", \"test\", and\n";
|
||||||
|
echo "\t\"production\".\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Examples:\n";
|
||||||
|
echo "\t./script/generate error 404\n";
|
||||||
|
echo "\tThis will create a 404 error layout for any environment:\n";
|
||||||
|
echo "\t\tError Template: app/views/__errors/default/404.phtml\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\t./script/generate error 404 production\n";
|
||||||
|
echo "\tThis will create a 404 error layout for the production environment:\n";
|
||||||
|
echo "\t\tError Template: app/views/__errors/production/404.phtml\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
106
vendor/zynapse/shell_scripts/znap_generator/layout_generator.php
vendored
Normal file
106
vendor/zynapse/shell_scripts/znap_generator/layout_generator.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Layout Generator - generate layouts
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class LayoutGenerator extends ZnapGenerator {
|
||||||
|
|
||||||
|
public
|
||||||
|
$class_name = null;
|
||||||
|
|
||||||
|
|
||||||
|
function generate () {
|
||||||
|
$layout_template = $this->templates_path.'/layout.phtml';
|
||||||
|
|
||||||
|
if ( is_file($layout_template) ) {
|
||||||
|
|
||||||
|
$this->name = Inflector::singularize($this->name);
|
||||||
|
$this->class_name = Inflector::camelize($this->name);
|
||||||
|
|
||||||
|
if ( stristr($this->name, '_') ) {
|
||||||
|
$layout_filename = strtolower($this->name).'.'.Znap::$views_extension;
|
||||||
|
} else {
|
||||||
|
$layout_filename = Inflector::underscore($this->name).'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view_paths = glob(Znap::$app_path.'/views*');
|
||||||
|
|
||||||
|
foreach( $view_paths as $path ) {
|
||||||
|
$layout_file = $path.'/__layouts/'.$layout_filename;
|
||||||
|
if ( !is_file($layout_file) ) {
|
||||||
|
$layout_data = file_get_contents($layout_template);
|
||||||
|
$layout_data = str_replace('[layout]', $this->name, $layout_data);
|
||||||
|
if ( file_put_contents($layout_file, $layout_data) ) {
|
||||||
|
$this->echo_create($layout_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($layout_file, 'layout');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($layout_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($layout_template, 'layout');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function help_summary () {
|
||||||
|
echo "Generate Layout for specific Controller:\n";
|
||||||
|
echo " ./script/generate layout controller_name\n";
|
||||||
|
echo " for more layout info: ./script/generate layout\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage: ./script/generate layout controller_name\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Description:\n";
|
||||||
|
echo "\tThe layout generator creates layout files for existing controllers.\n";
|
||||||
|
echo "\tThe generator takes a controller name as its argument.\n";
|
||||||
|
echo "\tController name may be given in CamelCase or under_score and should\n";
|
||||||
|
echo "\tnot be suffixed with 'Controller'. The generator creates a layout\n";
|
||||||
|
echo "\tfile in app/views/__layouts.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Example:\n";
|
||||||
|
echo "\t./script/generate layout Account\n";
|
||||||
|
echo "\tThis will create an Account layout:\n";
|
||||||
|
echo "\t\tLayout: app/views/__layout/account.phtml\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
97
vendor/zynapse/shell_scripts/znap_generator/model_generator.php
vendored
Normal file
97
vendor/zynapse/shell_scripts/znap_generator/model_generator.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Model Generator - generate (super)models :D
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ModelGenerator extends ZnapGenerator {
|
||||||
|
|
||||||
|
public
|
||||||
|
$class_name = null;
|
||||||
|
|
||||||
|
|
||||||
|
function generate () {
|
||||||
|
$this->name = Inflector::singularize($this->name);
|
||||||
|
$this->class_name = Inflector::camelize($this->name);
|
||||||
|
|
||||||
|
$model_template = $this->templates_path.'/model.php';
|
||||||
|
|
||||||
|
if ( stristr($this->name, '_') ) {
|
||||||
|
$model_file = Znap::$models_path.'/'.strtolower($this->name).'.php';
|
||||||
|
} else {
|
||||||
|
$model_file = Znap::$models_path.'/'.Inflector::underscore($this->name).'.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !is_file($model_file) ) {
|
||||||
|
if ( is_file($model_template) ) {
|
||||||
|
$model_data = file_get_contents($model_template);
|
||||||
|
$model_data = str_replace('[class_name]', $this->class_name, $model_data);
|
||||||
|
if ( file_put_contents($model_file, $model_data) ) {
|
||||||
|
$this->echo_create($model_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($model_file, 'model');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($model_template, 'model');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($model_file);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function help_summary () {
|
||||||
|
echo "Generate Model:\n";
|
||||||
|
echo " ./script/generate model ModelName\n";
|
||||||
|
echo " for more model info: ./script/generate model\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage: ./script/generate model ModelName\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Description:\n";
|
||||||
|
echo "\tThe model generator creates functions for a new model.\n";
|
||||||
|
echo "\tThe generator takes a model name as its argument. The model name\n";
|
||||||
|
echo "\tmay be given in CamelCase or under_score and should not be suffixed\n";
|
||||||
|
echo "\twith 'Model'. The generator creates a model class in app/models.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Example:\n";
|
||||||
|
echo "\t./script/generate model Account\n";
|
||||||
|
echo "\tThis will create an Account model:\n";
|
||||||
|
echo "\t\tModel: app/models/account.php\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
210
vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php
vendored
Normal file
210
vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php
vendored
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Snippet Generator - generate snippets
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetGenerator extends ZnapGenerator {
|
||||||
|
|
||||||
|
public
|
||||||
|
$class_name = null,
|
||||||
|
$views_path = null,
|
||||||
|
$view_root_paths = array(),
|
||||||
|
$methods = array();
|
||||||
|
|
||||||
|
|
||||||
|
function generate () {
|
||||||
|
if ( !preg_match('/^[a-zA-Z0-9_-]+$/', $this->name) ) {
|
||||||
|
echo "ERROR: Invalid snippet name given.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->name = Inflector::underscore($this->name);
|
||||||
|
$this->views_path = '__snippets/'.$this->name;
|
||||||
|
|
||||||
|
$this->name = Inflector::singularize($this->name);
|
||||||
|
$this->class_name = Inflector::camelize($this->name);
|
||||||
|
|
||||||
|
// get method/view arguments
|
||||||
|
if ( isset($this->args[1]) ) {
|
||||||
|
for ( $i=1; $i < count($this->args); $i++ ) {
|
||||||
|
$this->methods[$i] = $this->args[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all "views*" paths
|
||||||
|
$this->find_view_paths();
|
||||||
|
|
||||||
|
// validate that target snippet path exists, or attempt to create if it doesn't
|
||||||
|
if ( !$this->validate_path(Znap::$snippets_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate that target helper path exists, or attempt to create if it doesn't
|
||||||
|
if ( !$this->validate_path(Znap::$snippet_helpers_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate that target view paths exists, or attempt to create if it doesn't
|
||||||
|
foreach( $this->view_root_paths as $key => $path ) {
|
||||||
|
if ( !$this->validate_path($path.'/'.$this->views_path) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->create_snippet();
|
||||||
|
$this->create_helper();
|
||||||
|
$this->create_views();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function create_snippet () {
|
||||||
|
$controller_template = $this->templates_path.'/snippet.php';
|
||||||
|
$controller_file = Znap::$snippets_path.'/'.$this->name.'_snippet.php';
|
||||||
|
|
||||||
|
if ( !is_file($controller_file) ) {
|
||||||
|
if ( is_file($controller_template) ) {
|
||||||
|
// controller
|
||||||
|
$controller = file_get_contents($controller_template);
|
||||||
|
$controller = str_replace('[class_name]', $this->class_name, $controller);
|
||||||
|
if ( count($this->methods) ) {
|
||||||
|
$methods = array();
|
||||||
|
foreach( $this->methods as $method ) {
|
||||||
|
$methods[] = "\tfunction ".$method." () {\n\t\t\n\t}\n";
|
||||||
|
}
|
||||||
|
$controller = str_replace('[class_methods]', "\t\n".implode("\n", $methods), $controller);
|
||||||
|
} else {
|
||||||
|
$controller = str_replace('[class_methods]', "\t", $controller);
|
||||||
|
}
|
||||||
|
if ( file_put_contents($controller_file, $controller) ) {
|
||||||
|
$this->echo_create($controller_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($controller_file, 'controller');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($controller_template, 'controller');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($controller_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_helper () {
|
||||||
|
$helper_template = $this->templates_path.'/snippet_helper.php';
|
||||||
|
$helper_file = Znap::$snippet_helpers_path.'/'.$this->name.'_helper.php';
|
||||||
|
|
||||||
|
if ( !is_file($helper_file) ) {
|
||||||
|
if ( is_file($helper_template) ) {
|
||||||
|
$helper = file_get_contents($helper_template);
|
||||||
|
$helper = str_replace('[class_name]', $this->class_name, $helper);
|
||||||
|
if ( file_put_contents($helper_file, $helper) ) {
|
||||||
|
$this->echo_create($helper_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($helper_file, 'helper');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($helper_template, 'helper');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_views () {
|
||||||
|
$view_template = $this->templates_path.'/snippet_view.phtml';
|
||||||
|
|
||||||
|
if ( is_file($view_template) ) {
|
||||||
|
foreach( $this->view_root_paths as $path ) {
|
||||||
|
foreach( $this->methods as $view ) {
|
||||||
|
$view_file = $path.'/'.$this->views_path.'/'.$view.'.'.Znap::$views_extension;
|
||||||
|
if ( !is_file($view_file) ) {
|
||||||
|
$view_data = file_get_contents($view_template);
|
||||||
|
$view_data = str_replace('[class_name]', $this->class_name, $view_data);
|
||||||
|
$view_data = str_replace('[view]', $view, $view_data);
|
||||||
|
$view_data = str_replace('[controller]', $this->name, $view_data);
|
||||||
|
$view_data = str_replace('[view_file]', str_replace(Znap::$app_path.'/', '', $view_file), $view_data);
|
||||||
|
if ( file_put_contents($view_file, $view_data) ) {
|
||||||
|
$this->echo_create($view_file);
|
||||||
|
} else {
|
||||||
|
$this->echo_create_error($view_file, 'view');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_exists($view_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->echo_template_error($view_template, 'view');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function find_view_paths () {
|
||||||
|
$this->view_root_paths = glob(Znap::$app_path.'/views*');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function help_summary () {
|
||||||
|
echo "Generate Snippet:\n";
|
||||||
|
echo " ./script/generate snippet snippet_name [action1 action2 ...]\n";
|
||||||
|
echo " for more controller info: ./script/generate snippet\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "\n";
|
||||||
|
echo "Usage: ./script/generate snippet SnippetName [action1 action2 ...]\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Description:\n";
|
||||||
|
echo "\tThe snippet generator creates a new snippet, it's actions and views,\n";
|
||||||
|
echo "\twhich are easily reusable in controller view files.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tThe generator takes a snippet name and a list of actions as arguments.\n";
|
||||||
|
echo "\tThe snippet name may be given in CamelCase or under_score and should\n";
|
||||||
|
echo "\tnot be suffixed with 'Snippet'.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tThe generator creates a snippet class in app/snippets with view\n";
|
||||||
|
echo "\ttemplates in app/views/__snippets/snippet_name.\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "Example:\n";
|
||||||
|
echo "\t./script/generate snippet TagCloud user all_users\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "\tTag cloud snippet is usable with render_snippet() helper.\n";
|
||||||
|
echo "\t\tSnippet: app/snippets/tag_cloud_snippet.php\n";
|
||||||
|
echo "\t\tViews: app/views/__snippets/tag_cloud/user.phtml [...]\n";
|
||||||
|
echo "\t\tHelper: app/helpers/snippet_helpers/tag_cloud_helper.php\n";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
7
vendor/zynapse/shell_scripts/znap_generator/templates/controller.php
vendored
Normal file
7
vendor/zynapse/shell_scripts/znap_generator/templates/controller.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class [class_name]Controller extends ApplicationController {
|
||||||
|
[class_methods]
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml
vendored
Normal file
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>404 - Page Not Found</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Error: 404</h2>
|
||||||
|
<div id="details">
|
||||||
|
The page you requested could not be found, or has been moved.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml
vendored
Normal file
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>500 - Internal Server Error</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Error: 500</h2>
|
||||||
|
<div id="details">
|
||||||
|
The server encountered an internal error.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml
vendored
Normal file
54
vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>Unknown Error</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Unknown Error</h2>
|
||||||
|
<div id="details">
|
||||||
|
An unknown error has been encountered, please try again later.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
116
vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml
vendored
Normal file
116
vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml
vendored
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title><?php echo $message; ?></title>
|
||||||
|
|
||||||
|
<?php script_lib('jquery'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 12px 14px 14px 14px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
H4 {
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 15px 0px 5px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRE {
|
||||||
|
background-color: #EEE;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$(".toggle").toggle(function(event){
|
||||||
|
$(this).parents().next('.box').animate({ height: 'show', opacity: 'show' }, 'medium');
|
||||||
|
},function(){
|
||||||
|
$(this).parents().next('.box').animate({ height: 'hide', opacity: 'hide' }, 'medium');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2><?php echo $message; ?></h2>
|
||||||
|
<?php if ($details !== null): ?>
|
||||||
|
<div id="details">
|
||||||
|
<?php echo $details; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show framework trace</a></h4>
|
||||||
|
<pre class="box" ><code><?php echo $error->get_trace(); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show Znap::$prefs dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r(Znap::$prefs); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_SESSION dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_SESSION); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_GET dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_GET); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_POST dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_POST); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_COOKIE dump</a></h4>
|
||||||
|
<pre class="box" ><code><?php print_r($_COOKIE); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_FILES dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_FILES); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show Timer dump</a></h4>
|
||||||
|
<pre class="box"><code><?php Timer::term(5); echo Timer::debug(); ?></code></pre>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
4
vendor/zynapse/shell_scripts/znap_generator/templates/helper.php
vendored
Normal file
4
vendor/zynapse/shell_scripts/znap_generator/templates/helper.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
# Anything added to this helper will be available to all views in the [class_name]Controller.
|
||||||
|
|
||||||
|
?>
|
||||||
29
vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml
vendored
Normal file
29
vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<!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>[layout]</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?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">
|
||||||
|
page generated in <?php echo Timer::end();?> seconds.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
vendor/zynapse/shell_scripts/znap_generator/templates/model.php
vendored
Normal file
7
vendor/zynapse/shell_scripts/znap_generator/templates/model.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class [class_name] extends ActiveRecord {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
10
vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php
vendored
Normal file
10
vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class [class_name]Snippet extends Snippets {
|
||||||
|
|
||||||
|
# uncomment the line bellow to use layouts
|
||||||
|
# public $render_layout = true;
|
||||||
|
[class_methods]
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
4
vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php
vendored
Normal file
4
vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
# Anything added to this helper will be available to all views in the [class_name]Snippet.
|
||||||
|
|
||||||
|
?>
|
||||||
2
vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml
vendored
Normal file
2
vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<h2>[class_name]Snippet->[view]</h2>
|
||||||
|
<p>Find me in [view_file]</p>
|
||||||
2
vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml
vendored
Normal file
2
vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<h1>[class_name]->[view]</h1>
|
||||||
|
<p>Find me in [view_file]</p>
|
||||||
522
vendor/zynapse/snippet_controller.php
vendored
Normal file
522
vendor/zynapse/snippet_controller.php
vendored
Normal file
@@ -0,0 +1,522 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse SnippetController
|
||||||
|
- call and/or render snippets of code, based on ActionController
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class SnippetController {
|
||||||
|
|
||||||
|
private $snippet;
|
||||||
|
private $action;
|
||||||
|
private $args = array();
|
||||||
|
private $snippets_path;
|
||||||
|
private $helpers_path;
|
||||||
|
private $helper_file;
|
||||||
|
private $layouts_path;
|
||||||
|
private $layout_file;
|
||||||
|
private $views_base_path;
|
||||||
|
private $views_path;
|
||||||
|
private $view_file;
|
||||||
|
private $snippets_class_file;
|
||||||
|
private $snippets_helper_file;
|
||||||
|
private $helpers = array();
|
||||||
|
private $before_filters = array();
|
||||||
|
private $after_filters = array();
|
||||||
|
private $paths_loaded = false;
|
||||||
|
private $currently_rendering_file;
|
||||||
|
private $content_for_layout = null;
|
||||||
|
private $default_action = 'index';
|
||||||
|
|
||||||
|
public $action_called = false;
|
||||||
|
public $snippet_file;
|
||||||
|
public $class_name;
|
||||||
|
public $snippet_object;
|
||||||
|
public $render_layout = false;
|
||||||
|
public $render_view = true;
|
||||||
|
public $render_action = null;
|
||||||
|
public $render_performed = false;
|
||||||
|
public $result = null;
|
||||||
|
|
||||||
|
|
||||||
|
function __construct () {
|
||||||
|
// doesn't need to do anything at the moment
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function initialize ($snippet, $action, $args) {
|
||||||
|
if ( $snippet != null ) {
|
||||||
|
$this->snippet = $snippet;
|
||||||
|
|
||||||
|
if ( $action != null ) {
|
||||||
|
$this->action = $action;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_array($args) && count($args) > 0 ) {
|
||||||
|
$this->args = $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$this->paths_loaded ) {
|
||||||
|
$this->init_paths();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->views_path = Znap::$snippet_views_path.'/'.$this->snippet;
|
||||||
|
|
||||||
|
$this->snippet_file = $this->snippets_path.'/'.$this->snippet.'_snippet.php';
|
||||||
|
$this->helper_file = $this->helpers_path.'/'.$this->snippet.'_snippet_helper.php';
|
||||||
|
$this->class_name = Inflector::camelize($this->snippet).'Snippet';
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_paths () {
|
||||||
|
$this->snippets_path = Znap::$snippets_path;
|
||||||
|
$this->helpers_path = Znap::$snippet_helpers_path;
|
||||||
|
$this->layouts_path = Znap::$snippet_layouts_path;
|
||||||
|
$this->views_base_path = Znap::$snippet_views_path;
|
||||||
|
$this->snippets_class_file = $this->snippets_path.'/snippets.php';
|
||||||
|
$this->snippets_helper_file = $this->helpers_path.'/snippets_helper.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_filters () {
|
||||||
|
// check if any filters are pre-defined
|
||||||
|
if ( isset($this->before_filter) ) {
|
||||||
|
$this->add_before_filter($this->before_filter);
|
||||||
|
unset($this->before_filter);
|
||||||
|
}
|
||||||
|
if ( isset($this->after_filter) ) {
|
||||||
|
$this->add_after_filter($this->after_filter);
|
||||||
|
unset($this->after_filter);
|
||||||
|
}
|
||||||
|
if ( isset($this->helper) ) {
|
||||||
|
$this->add_helper($this->helper);
|
||||||
|
unset($this->helper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function call_snippet ($snippet = null, $action = null, $args = array()) {
|
||||||
|
$this->render_layout = false;
|
||||||
|
$this->render_view = false;
|
||||||
|
return $this->render_snippet($snippet, $action, $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_snippet ($snippet = null, $action = null, $args = array()) {
|
||||||
|
if ( !$this->initialize($snippet, $action, $args) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_file($this->snippets_class_file) ) {
|
||||||
|
include_once($this->snippets_class_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once($this->snippet_file);
|
||||||
|
if ( class_exists($this->class_name, false) ) {
|
||||||
|
if ( !isset(Znap::$current_snippet_objects[$this->snippet]) ) {
|
||||||
|
$class = $this->class_name;
|
||||||
|
$this->snippet_object = new $class();
|
||||||
|
if ( is_object($this->snippet_object) ) {
|
||||||
|
$this->snippet_object->init_filters();
|
||||||
|
$this->snippet_object->snippet = $this->snippet;
|
||||||
|
$this->snippet_object->action = $this->action;
|
||||||
|
$this->snippet_object->args = $this->args;
|
||||||
|
$this->snippet_object->snippets_path = &$this->snippets_path;
|
||||||
|
$this->snippet_object->helpers_path = &$this->helpers_path;
|
||||||
|
$this->snippet_object->layouts_path = &$this->layouts_path;
|
||||||
|
$this->snippet_object->views_base_path = &$this->views_base_path;
|
||||||
|
$this->snippet_object->views_path = $this->views_path;
|
||||||
|
$this->snippet_object->class_name = $this->class_name;
|
||||||
|
$this->snippet_object->render_layout = $this->render_layout;
|
||||||
|
$this->snippet_object->render_view = $this->render_view;
|
||||||
|
|
||||||
|
Znap::$current_snippet_objects[$this->snippet] = &$this->snippet_object;
|
||||||
|
}
|
||||||
|
} elseif ( is_object(Znap::$current_snippet_objects[$this->snippet]) ) {
|
||||||
|
$this->snippet_object = &Znap::$current_snippet_objects[$this->snippet];
|
||||||
|
$this->snippet_object->action = $this->action;
|
||||||
|
$this->snippet_object->args = $this->args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_object($this->snippet_object) ) {
|
||||||
|
|
||||||
|
// include main snippets helpers
|
||||||
|
if ( is_file($this->snippets_helper_file) ) {
|
||||||
|
include_once($this->snippets_helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ($before_filters_result = $this->snippet_object->execute_before_filters()) === true ) {
|
||||||
|
|
||||||
|
// include snippet specific preferences
|
||||||
|
if ( isset($this->snippet_object->has_prefs) && Znap::$prefs->read('snippet_'.$this->snippet, true) ) {
|
||||||
|
$snippet = 'snippet_'.$this->snippet;
|
||||||
|
$this->snippet_object->prefs = &Znap::$prefs->$snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// supress output for capture
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// include snippet specific helper file
|
||||||
|
if ( is_file($this->helper_file) ) {
|
||||||
|
include_once($this->helper_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// call default action/method if none is defined
|
||||||
|
if ( $this->action === null ) {
|
||||||
|
$this->action = $this->default_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute main method
|
||||||
|
if ( method_exists($this->snippet_object, $this->action) && !in_array($this->action, get_class_methods('SnippetController')) ) {
|
||||||
|
$action = $this->action;
|
||||||
|
$this->result = call_user_func_array(array($this->snippet_object, $action), $this->args);
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$this->action.'.'.Znap::$views_extension) ) {
|
||||||
|
$action = $this->action;
|
||||||
|
} else {
|
||||||
|
$this->raise('Snippet action "'.$this->action.'" not found in the '.$this->snippet.' snippet class.');
|
||||||
|
ob_end_clean();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->snippet_object->execute_after_filters();
|
||||||
|
$this->snippet_object->action_called = true;
|
||||||
|
|
||||||
|
// include any additionaly defined helpers
|
||||||
|
if ( count($this->snippet_object->helpers) ) {
|
||||||
|
foreach( $this->snippet_object->helpers as $helper ) {
|
||||||
|
if ( is_file($this->helpers_path.'/'.$helper.'_helper.php') ) {
|
||||||
|
include_once($this->helpers_path.'/'.$helper.'_helper.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if render_text is defined as a string, render it instead of layout & view files
|
||||||
|
if ( isset($this->snippet_object->render_text) && $this->snippet_object->render_text != '' ) {
|
||||||
|
$this->render_text($this->snippet_object->render_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if render_action is defined, used it as the render action
|
||||||
|
if ( isset($this->snippet_object->render_action) && $this->snippet_object->render_action != '' ) {
|
||||||
|
$action = $this->snippet_object->render_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
// render view file
|
||||||
|
if ( !$this->snippet_object->render_action($action) ) {
|
||||||
|
$this->raise('No "'.$action.'" view file found for the "'.$this->snippet.'" snippet.');
|
||||||
|
ob_end_clean();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// grab captured output
|
||||||
|
$this->snippet_object->content_for_layout = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
// render or not to render layout (that is the question)
|
||||||
|
if ( $this->snippet_object->render_layout !== false && ($layout_file = $this->snippet_object->determine_layout()) ) {
|
||||||
|
if ( !$this->snippet_object->render_file($layout_file) ) {
|
||||||
|
echo $this->snippet_object->content_for_layout;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo $this->snippet_object->content_for_layout;
|
||||||
|
}
|
||||||
|
return $this->result;
|
||||||
|
} else {
|
||||||
|
$this->raise('The "'.$before_filters_result.'" snippet before filter failed.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->raise('Failed to initiate snippet object "'.$this->snippet.'".');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->raise('Snippet "'.$this->snippet.'" not found.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function determine_layout ($full_path = true) {
|
||||||
|
// if controller defines and sets $layout to NULL, don't use a layout
|
||||||
|
if ( isset($this->layout) && is_null($this->layout) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if _determine_layout() is defined in controller, call it to get layout name
|
||||||
|
if ( method_exists($this, Znap::$protected_method_prefix.'determine_layout') ) {
|
||||||
|
$determine_layout_method = Znap::$protected_method_prefix.'determine_layout';
|
||||||
|
$layout = $this->$determine_layout_method();
|
||||||
|
} else {
|
||||||
|
$layout = ( isset($this->layout) && $this->layout != '' ) ? $this->layout : $this->snippet ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$default_layout_file = $this->layouts_path.'/snippets.'.Znap::$views_extension;
|
||||||
|
|
||||||
|
if ( !$full_path && $layout ) {
|
||||||
|
return $layout;
|
||||||
|
} elseif ( is_file($this->layouts_path.'/'.$layout.'.'.Znap::$views_extension) ) {
|
||||||
|
$layout_file = $this->layouts_path.'/'.$layout.'.'.Znap::$views_extension;
|
||||||
|
} else {
|
||||||
|
$layout_file = $this->layouts_path.'/snippets.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $layout_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function execute_filters ($filters) {
|
||||||
|
if ( count($this->$filters) ) {
|
||||||
|
foreach( $this->$filters as $filter ) {
|
||||||
|
if ( method_exists($this, $filter) ) {
|
||||||
|
if ( $this->$filter() === false ) {
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_before_filters () {
|
||||||
|
return $this->execute_filters('before_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_after_filters () {
|
||||||
|
return $this->execute_filters('after_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function add_items_to_list ($filter, $list) {
|
||||||
|
if ( is_string($filter) && !empty($filter) ) {
|
||||||
|
if ( strpos($filter, ',') !== false ) {
|
||||||
|
$filter = explode(',', $filter);
|
||||||
|
foreach( $filter as $key => $value ) {
|
||||||
|
if ( !in_array($value, $this->$list) ) {
|
||||||
|
$this->{$list}[] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->{$list}[] = $filter;
|
||||||
|
}
|
||||||
|
} elseif ( is_array($filter) ) {
|
||||||
|
if ( count($this->$list) ) {
|
||||||
|
$this->$list = array_unique(array_merge($this->$list, $filter));
|
||||||
|
} else {
|
||||||
|
$this->$list = $filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_before_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'before_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_after_filter ($filter) {
|
||||||
|
$this->add_items_to_list($filter, 'after_filters');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function add_helper ($helper) {
|
||||||
|
$this->add_items_to_list($helper, 'helpers');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function render_text ($text, $options = array()) {
|
||||||
|
if ( isset($options['layout']) && $options['layout'] != '' ) {
|
||||||
|
$locals['content_for_layout'] = &$text;
|
||||||
|
$layout = $this->determine_layout();
|
||||||
|
$this->render_file($layout, $locals);
|
||||||
|
} else {
|
||||||
|
echo $text;
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_action ($action, $layout = null) {
|
||||||
|
if ( $this->render_performed || $this->render_view === false ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $layout != null ) {
|
||||||
|
$this->layout = $layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->view_file) ) {
|
||||||
|
$len = strlen('.'.Znap::$views_extension);
|
||||||
|
if ( substr($this->view_file, -$len) != '.'.Znap::$views_extension ) {
|
||||||
|
$this->view_file .= '.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
if ( strstr($this->view_file, '/') && is_file($this->views_base_path.'/'.$this->view_file) ) {
|
||||||
|
$this->view_file = $this->views_base_path.'/'.$this->view_file;
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$this->view_file) ) {
|
||||||
|
$this->view_file = $this->views_path.'/'.$this->view_file;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->view_file = $this->views_path.'/'.$action.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->render_performed = true;
|
||||||
|
|
||||||
|
return $this->render_file($this->view_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_file ($file, $locals = array(), $use_full_path = false) {
|
||||||
|
|
||||||
|
if ( $use_full_path ) {
|
||||||
|
$file = $this->views_path.'/'.$file.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_file($file) ) {
|
||||||
|
if ( is_object($this) ) {
|
||||||
|
foreach( $this as $tmp_key => $tmp_value ) {
|
||||||
|
${$tmp_key} = &$this->$tmp_key;
|
||||||
|
}
|
||||||
|
unset($tmp_key, $tmp_value);
|
||||||
|
}
|
||||||
|
if ( $this->content_for_layout !== null ) {
|
||||||
|
$content_for_layout = &$this->content_for_layout;
|
||||||
|
}
|
||||||
|
if ( count($locals) ) {
|
||||||
|
foreach( $locals as $tmp_key => $tmp_value ) {
|
||||||
|
${$tmp_key} = &$locals[$tmp_key];
|
||||||
|
}
|
||||||
|
unset($tmp_key, $tmp_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($use_full_path, $locals);
|
||||||
|
|
||||||
|
Znap::$currently_rendering_snippet = $this->snippet;
|
||||||
|
$this->currently_rendering_file = $file;
|
||||||
|
include($file);
|
||||||
|
Znap::$currently_rendering_snippet = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render_partial ($partial, $options = array()) {
|
||||||
|
|
||||||
|
// set file name
|
||||||
|
if ( strstr($partial, '/') ) {
|
||||||
|
$file = '_'.substr(strrchr($partial, '/'), 1).'.'.Znap::$views_extension;
|
||||||
|
$path = substr($partial, 0, strrpos($partial, '/'));
|
||||||
|
$file_name = $path.'/'.$file;
|
||||||
|
} else {
|
||||||
|
$path = '';
|
||||||
|
$file_name = $file = '_'.$partial.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine file path
|
||||||
|
if ( strstr($file_name, '/') && is_file($this->views_base_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->views_base_path.'/'.$file_name;
|
||||||
|
} elseif ( is_file(dirname($this->currently_rendering_file).'/'.$file_name) ) {
|
||||||
|
$file_name = dirname($this->currently_rendering_file).'/'.$file_name;
|
||||||
|
} elseif ( is_file($this->views_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->views_path.'/'.$file_name;
|
||||||
|
} elseif ( is_file($this->layouts_path.'/'.$file_name) ) {
|
||||||
|
$file_name = $this->layouts_path.'/'.$file_name;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// continue if partial file exists
|
||||||
|
if ( is_file($file_name) ) {
|
||||||
|
$locals = ( array_key_exists('locals', $options) ) ? $options['locals'] : array() ;
|
||||||
|
|
||||||
|
// use collections to render a partial multiple times with new variables available to it each time
|
||||||
|
if ( array_key_exists('collection', $options) && is_array($options['collection']) ) {
|
||||||
|
|
||||||
|
// spacer template to be rendered between each collection item's partial rendering
|
||||||
|
if ( array_key_exists('spacer', $options) || array_key_exists('spacer_template', $options) ) {
|
||||||
|
$spacer_path = (array_key_exists('spacer', $options)) ? $options['spacer'] : $options['spacer_template'];
|
||||||
|
if ( strstr($spacer_path, '/') ) {
|
||||||
|
$spacer_file = substr(strrchr($spacer_path, '/'), 1);
|
||||||
|
$spacer_path = substr($spacer_path, 0, strripos($path, '/'));
|
||||||
|
$spacer_file_path = Znap::$views_path.'/'.$spacer_path.'/_'.$spacer_file.'.'.Znap::$views_extension;
|
||||||
|
} else {
|
||||||
|
$spacer_file = $spacer_path;
|
||||||
|
$spacer_file_path = $this->views_path.'/'.$spacher_file.'.'.Znap::$views_extension;
|
||||||
|
}
|
||||||
|
if ( is_file($spacer_file_path) ) {
|
||||||
|
$add_spacer = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start the rendering
|
||||||
|
${$partial.'_counter'} = 0;
|
||||||
|
foreach( $options['collection'] as $tmp_value ) {
|
||||||
|
${$file.'_counter'}++;
|
||||||
|
$locals[$partial] = $tmp_value;
|
||||||
|
$locals[$partial.'_counter'] = ${$partial.'_counter'};
|
||||||
|
unset($tmp_value);
|
||||||
|
$this->render_performed = false;
|
||||||
|
$this->render_file($file_name, $locals);
|
||||||
|
if ( isset($add_spacer) && ${$partial.'_counter'} < count($options['collection']) ) {
|
||||||
|
$this->render_performed = false;
|
||||||
|
$this->render_file($spacer_file_path, $locals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->render_performed = true;
|
||||||
|
} else {
|
||||||
|
return $this->render_file($file_name, $locals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function raise ($message = 'UNKNOWN SNIPPET ERROR') {
|
||||||
|
error_log($message, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
21
vendor/zynapse/strings.php
vendored
Normal file
21
vendor/zynapse/strings.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Default Zynapse Strings
|
||||||
|
- default strings used by zynapse core
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$strings = array(
|
||||||
|
|
||||||
|
// default item error if error message is not specified
|
||||||
|
'_ZNAP_AR_ERROR_ITEM_UKNOWN' => 'Unknown error with %column%.',
|
||||||
|
|
||||||
|
// html used for error flashing
|
||||||
|
'_ZNAP_AR_ERROR_TITLE' => 'There was a problem with your request. Please fix the following:',
|
||||||
|
'_ZNAP_AR_ERROR_BODY_HTML' => '<div class="model_error"><div class="title">%title%</div><ul>%errors%</ul></div>',
|
||||||
|
'_ZNAP_AR_ERROR_ITEM_HTML' => '<li>%error%</li>',
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
||||||
149
vendor/zynapse/timer.php
vendored
Normal file
149
vendor/zynapse/timer.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Timer - script speedometer
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Timer {
|
||||||
|
|
||||||
|
public static
|
||||||
|
|
||||||
|
# number of decimals to calculate
|
||||||
|
$digits = 3,
|
||||||
|
|
||||||
|
# number of decimals to calulate requests per second to
|
||||||
|
$req_digits = 2,
|
||||||
|
|
||||||
|
# output pattern used by end()
|
||||||
|
# %s = seconds since start
|
||||||
|
# %r = requests per second
|
||||||
|
$pattern = '%s sec — %r reqs/sec',
|
||||||
|
|
||||||
|
|
||||||
|
# start time
|
||||||
|
$start = null,
|
||||||
|
|
||||||
|
# end time
|
||||||
|
$end = null,
|
||||||
|
|
||||||
|
# execution time
|
||||||
|
$time = null,
|
||||||
|
|
||||||
|
# requests per second at current execution time
|
||||||
|
$requests = null,
|
||||||
|
|
||||||
|
# saved output from end()
|
||||||
|
$output = null,
|
||||||
|
|
||||||
|
# timer is started? true or false
|
||||||
|
$started = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start
|
||||||
|
* @param digits number of decimals to calculate
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
|
function start ($digits = null) {
|
||||||
|
if ( !empty($digits) ) self::$digits = $digits;
|
||||||
|
self::$start = microtime(true);
|
||||||
|
self::$started = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate time since start and return using defined pattern
|
||||||
|
* @param digits number of decimals to calculate
|
||||||
|
* @param pattern output pattern ("%s" is replaced by time)
|
||||||
|
* @return time with microseconds since start, formatted using pattern
|
||||||
|
*/
|
||||||
|
function end ($digits = null, $pattern = null) {
|
||||||
|
self::$end = microtime(true);
|
||||||
|
if ( !preg_match("/[0-9]{1,3}/", $digits) ) $digits = self::$digits;
|
||||||
|
if ( strpos($pattern, '%s') === false ) $pattern = self::$pattern;
|
||||||
|
self::$time = number_format( (self::$end - self::$start), $digits);
|
||||||
|
self::$output = str_replace('%s', self::$time, $pattern);
|
||||||
|
if ( strpos($pattern, '%r') !== false ) {
|
||||||
|
self::$requests = number_format( (1 / self::$time), self::$req_digits);
|
||||||
|
self::$output = str_replace('%r', self::$requests, self::$output);
|
||||||
|
}
|
||||||
|
return self::$output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate time since start and return plain time
|
||||||
|
* @param digits number of decimals to calculate
|
||||||
|
* @return time with microseconds since start
|
||||||
|
*/
|
||||||
|
function term ($digits = null) {
|
||||||
|
self::$end = microtime(true);
|
||||||
|
if ( !preg_match("/[0-9]{1,3}/", $digits) ) $digits = self::$digits;
|
||||||
|
self::$time = number_format( (self::$end - self::$start), $digits);
|
||||||
|
self::$requests = number_format( (1 / self::$time), self::$req_digits);
|
||||||
|
return self::$time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output detailed timing info for debugging
|
||||||
|
* @return detailed execution timing info
|
||||||
|
*/
|
||||||
|
function debug () {
|
||||||
|
$lf = "\n";
|
||||||
|
|
||||||
|
$start = 'Start time: ';
|
||||||
|
$start .= (self::$started) ? self::$start.' ('.self::prettify_time(self::$start).')' : 'Not started.' ;
|
||||||
|
|
||||||
|
$end = 'End time: ';
|
||||||
|
$end .= (self::$end !== null) ? self::$end.' ('.self::prettify_time(self::$end).')' : 'Not ended.' ;
|
||||||
|
|
||||||
|
$time = 'Script execution: ';
|
||||||
|
$reqs = 'Requests/second: ';
|
||||||
|
|
||||||
|
if ( self::$started && self::$end !== null ) {
|
||||||
|
$time .= $t = number_format( (self::$end - self::$start), 5);
|
||||||
|
$reqs .= number_format( (1 / $t), self::$req_digits);
|
||||||
|
} else {
|
||||||
|
$time .= 'Unknown';
|
||||||
|
$reqs .= 'Unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $time.$lf.$reqs.$lf.$start.$lf.$end;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prettify_time ($input, $format = 'd-M-Y H:i:s') {
|
||||||
|
if ( strpos($input, '.') !== false ) {
|
||||||
|
$time = explode('.', $input);
|
||||||
|
return date($format, $time[0]).'.'.$time[1];
|
||||||
|
} else {
|
||||||
|
return date($format, $time[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
80
vendor/zynapse/znap_error.php
vendored
Normal file
80
vendor/zynapse/znap_error.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Zynapse Error Class - error handling
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
Based on action_controller.php from PHPOnTrax.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
ZnapError
|
||||||
|
- zynapse base exception class
|
||||||
|
|
||||||
|
*/
|
||||||
|
class ZnapError extends Exception {
|
||||||
|
|
||||||
|
protected $details = null;
|
||||||
|
|
||||||
|
function __construct($message = null, $details = null, $code = 0) {
|
||||||
|
$this->details = $details;
|
||||||
|
parent::__construct($message, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDetails () {
|
||||||
|
return $this->details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_trace () {
|
||||||
|
return str_replace(ZNAP_ROOT.'/', '', $this->getTraceAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Action Controller's Exception handling class
|
||||||
|
*/
|
||||||
|
class ActionControllerError extends ZnapError {}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Active Record's Exception handling class
|
||||||
|
*/
|
||||||
|
class ActiveRecordError extends ZnapError {}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Snippet Controller's Exception handling class
|
||||||
|
*/
|
||||||
|
class SnippetControllerError extends ZnapError {}
|
||||||
|
|
||||||
|
?>
|
||||||
54
vendor/zynapse/znap_error/default/404.phtml
vendored
Normal file
54
vendor/zynapse/znap_error/default/404.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>404 - Page Not Found</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Error: 404</h2>
|
||||||
|
<div id="details">
|
||||||
|
The page you requested could not be found, or has been moved.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
vendor/zynapse/znap_error/default/500.phtml
vendored
Normal file
54
vendor/zynapse/znap_error/default/500.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>500 - Internal Server Error</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Error: 500</h2>
|
||||||
|
<div id="details">
|
||||||
|
The server encountered an internal error.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
vendor/zynapse/znap_error/default/default.phtml
vendored
Normal file
54
vendor/zynapse/znap_error/default/default.phtml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title>Unknown Error</title>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2>Unknown Error</h2>
|
||||||
|
<div id="details">
|
||||||
|
An unknown error has been encountered, please try again later.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
116
vendor/zynapse/znap_error/development/default.phtml
vendored
Normal file
116
vendor/zynapse/znap_error/development/default.phtml
vendored
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<!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="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
||||||
|
<title><?php echo $message; ?></title>
|
||||||
|
|
||||||
|
<?php script_lib('jquery'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
BODY {
|
||||||
|
font-family: verdana, tahoma, arial, helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 12px 14px 14px 14px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
A:hover {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size: 22px;
|
||||||
|
margin: 10px 5px 12px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
H4 {
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 15px 0px 5px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRE {
|
||||||
|
background-color: #EEE;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
background-color: #EEE;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$(".toggle").toggle(function(event){
|
||||||
|
$(this).parents().next('.box').animate({ height: 'show', opacity: 'show' }, 'medium');
|
||||||
|
},function(){
|
||||||
|
$(this).parents().next('.box').animate({ height: 'hide', opacity: 'hide' }, 'medium');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2><?php echo $message; ?></h2>
|
||||||
|
<?php if ($details !== null): ?>
|
||||||
|
<div id="details">
|
||||||
|
<?php echo $details; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show framework trace</a></h4>
|
||||||
|
<pre class="box" ><code><?php echo $error->get_trace(); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show Znap::$prefs dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r(Znap::$prefs); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_SESSION dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_SESSION); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_GET dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_GET); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_POST dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_POST); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_COOKIE dump</a></h4>
|
||||||
|
<pre class="box" ><code><?php print_r($_COOKIE); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show $_FILES dump</a></h4>
|
||||||
|
<pre class="box"><code><?php print_r($_FILES); ?></code></pre>
|
||||||
|
|
||||||
|
<h4><a class="toggle">Show Timer dump</a></h4>
|
||||||
|
<pre class="box"><code><?php Timer::term(5); echo Timer::debug(); ?></code></pre>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
374
vendor/zynapse/zynapse.php
vendored
Normal file
374
vendor/zynapse/zynapse.php
vendored
Normal file
@@ -0,0 +1,374 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Znap - zynapse main class
|
||||||
|
|
||||||
|
|
||||||
|
http://www.zynapse.org/
|
||||||
|
Copyright (c) 2009 Jim Myhrberg.
|
||||||
|
|
||||||
|
----------
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
----------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Znap {
|
||||||
|
|
||||||
|
public static
|
||||||
|
$action_controller = null,
|
||||||
|
$snippets_controller = null,
|
||||||
|
$prefs = null,
|
||||||
|
$controllers_path = null,
|
||||||
|
$helpers_path = null,
|
||||||
|
$models_path = null,
|
||||||
|
$views_path = null,
|
||||||
|
$layouts_path = null,
|
||||||
|
$snippets_path = null,
|
||||||
|
$snippet_helpers_path = null,
|
||||||
|
$snippet_views_path = null,
|
||||||
|
$snippet_layouts_path = null,
|
||||||
|
$prefs_path = null,
|
||||||
|
$errors_path = null,
|
||||||
|
$errors_default_path = null,
|
||||||
|
$config_path = null,
|
||||||
|
$environments_path = null,
|
||||||
|
$strings_path = null,
|
||||||
|
$lib_path = null,
|
||||||
|
$app_path = null,
|
||||||
|
$log_path = null,
|
||||||
|
$vendor_path = null,
|
||||||
|
$shell_scripts_path = null,
|
||||||
|
$public_path = null,
|
||||||
|
$tmp_path = null,
|
||||||
|
$cache_path = null,
|
||||||
|
$added_path = null,
|
||||||
|
$url_prefix = null,
|
||||||
|
$protected_method_prefix = '_',
|
||||||
|
$views_extension = 'phtml',
|
||||||
|
$path_seperator = ':',
|
||||||
|
$current_controller_path = null,
|
||||||
|
$current_controller_name = null,
|
||||||
|
$current_controller_class_name = null,
|
||||||
|
$current_action_name = null,
|
||||||
|
$current_controller_object = null,
|
||||||
|
$current_route = null,
|
||||||
|
$current_snippet_objects = array(),
|
||||||
|
$keep_flash,
|
||||||
|
$timer_enabled = false,
|
||||||
|
$allow_dangerous_url_paths = false,
|
||||||
|
$use_development_errors = false,
|
||||||
|
$currently_rendering_snippet = null,
|
||||||
|
|
||||||
|
// mkdir command
|
||||||
|
$mkdir_cmd = 'mkdir',
|
||||||
|
|
||||||
|
// chmod command
|
||||||
|
$chmod_cmd = 'chmod',
|
||||||
|
|
||||||
|
// fill with language specific strings - use App::$strings
|
||||||
|
$strings = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function initialize () {
|
||||||
|
|
||||||
|
|
||||||
|
// OS is Windows?
|
||||||
|
if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
self::$path_seperator = ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set paths
|
||||||
|
self::$app_path = ZNAP_ROOT.'/app';
|
||||||
|
self::$controllers_path = self::$app_path.'/controllers';
|
||||||
|
self::$helpers_path = self::$app_path.'/helpers';
|
||||||
|
self::$models_path = self::$app_path.'/models';
|
||||||
|
self::$prefs_path = self::$app_path.'/preferences';
|
||||||
|
self::$snippets_path = self::$app_path.'/snippets';
|
||||||
|
self::$snippet_helpers_path = self::$helpers_path.'/snippet_helpers';
|
||||||
|
|
||||||
|
// display mode path
|
||||||
|
if ( ZNAP_MODE != 'web' && is_dir(self::$app_path.'/views-'.ZNAP_MODE) ) {
|
||||||
|
self::$views_path = self::$app_path.'/views-'.ZNAP_MODE;
|
||||||
|
} else {
|
||||||
|
self::$views_path = self::$app_path.'/views';
|
||||||
|
}
|
||||||
|
|
||||||
|
// set more paths
|
||||||
|
self::$layouts_path = self::$views_path.'/__layouts';
|
||||||
|
self::$errors_path = self::$views_path.'/__errors';
|
||||||
|
self::$errors_default_path = self::$views_path.'/__errors/default';
|
||||||
|
self::$snippet_views_path = self::$views_path.'/__snippets';
|
||||||
|
self::$snippet_layouts_path = self::$views_path.'/__snippets/__layouts';
|
||||||
|
|
||||||
|
self::$config_path = ZNAP_ROOT.'/config';
|
||||||
|
self::$environments_path = self::$config_path.'/environments';
|
||||||
|
self::$strings_path = self::$config_path.'/strings';
|
||||||
|
|
||||||
|
self::$tmp_path = ZNAP_ROOT.'/tmp';
|
||||||
|
self::$cache_path = self::$tmp_path.'/cache';
|
||||||
|
|
||||||
|
self::$lib_path = ZNAP_ROOT.'/libs';
|
||||||
|
self::$log_path = ZNAP_ROOT.'/logs';
|
||||||
|
self::$public_path = ZNAP_ROOT.'/public';
|
||||||
|
self::$vendor_path = ZNAP_ROOT.'/vendor';
|
||||||
|
self::$shell_scripts_path = ZNAP_LIB_ROOT.'/shell_scripts';
|
||||||
|
|
||||||
|
|
||||||
|
// logging setup
|
||||||
|
if ( ZNAP_ENABLE_LOGGING && !defined('ZNAP_SHELL_SCRIPT') ) {
|
||||||
|
ini_set('log_errors', 'On');
|
||||||
|
} else {
|
||||||
|
ini_set('log_errors', 'Off');
|
||||||
|
}
|
||||||
|
if ( ZNAP_INTERNAL_LOGGING && !defined('ZNAP_SHELL_SCRIPT') ) {
|
||||||
|
ini_set('error_log', self::$log_path.'/'.ZNAP_ENV.'.log');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ZNAP_ENV == 'development' ) {
|
||||||
|
// display errors in browser in development mode for easy debugging
|
||||||
|
ini_set('display_errors', 'On');
|
||||||
|
// ini_set('error_reporting', 'E_ALL'); //FIXME using ini_set() to change "error_reporting" stops error messages from displaying
|
||||||
|
} else {
|
||||||
|
// hide errors from browser if not in development mode
|
||||||
|
ini_set('display_errors', 'Off');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// setup include paths
|
||||||
|
ini_set('include_path',
|
||||||
|
'.'.self::$path_seperator.
|
||||||
|
ZNAP_LIB_ROOT.self::$path_seperator.
|
||||||
|
ZNAP_LIB_ROOT.'/shell_scripts'.self::$path_seperator.
|
||||||
|
self::$lib_path.self::$path_seperator.
|
||||||
|
ini_get('include_path')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// load the zynapse libs
|
||||||
|
require_once('session.php');
|
||||||
|
require_once('preferences.php');
|
||||||
|
// require_once('input_filter.php'); //TODO require InputFilter class when (if ever) it is created
|
||||||
|
require_once('active_record.php');
|
||||||
|
require_once('action_controller.php');
|
||||||
|
require_once('snippet_controller.php');
|
||||||
|
require_once('action_view.php');
|
||||||
|
require_once('dispatcher.php');
|
||||||
|
require_once('inflector.php');
|
||||||
|
require_once('router.php');
|
||||||
|
require_once('timer.php');
|
||||||
|
require_once('znap_error.php');
|
||||||
|
|
||||||
|
if ( defined('ZNAP_SHELL_SCRIPT') ) {
|
||||||
|
require_once('shell_script.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// load and set database configuration
|
||||||
|
if ( file_exists(self::$config_path.'/database.php') ) {
|
||||||
|
include_once(self::$config_path.'/database.php');
|
||||||
|
if ( !empty($database_settings) ) {
|
||||||
|
ActiveRecord::$settings = $database_settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set url prefix path if needed
|
||||||
|
if ( defined('URL_PREFIX') ) {
|
||||||
|
Znap::$url_prefix = URL_PREFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// load default strings
|
||||||
|
require_once('strings.php');
|
||||||
|
self::$strings = $strings;
|
||||||
|
unset($strings);
|
||||||
|
|
||||||
|
|
||||||
|
// load app's global strings
|
||||||
|
if ( is_file(self::$strings_path.'/_global.php') ) {
|
||||||
|
require_once(self::$strings_path.'/_global.php');
|
||||||
|
if ( !empty($strings) ) {
|
||||||
|
self::$strings = $strings;
|
||||||
|
unset($strings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize preference system
|
||||||
|
self::$prefs = new PreferenceCollection( array(self::$prefs_path, self::$tmp_path) );
|
||||||
|
self::$prefs->read('_internals');
|
||||||
|
self::$prefs->read('application');
|
||||||
|
self::$prefs->read('cache', true, self::$tmp_path);
|
||||||
|
|
||||||
|
// initialize the App class - read the comment on the class for more info
|
||||||
|
App::initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// load language specific strings - called by ActionController when needed
|
||||||
|
function load_strings () {
|
||||||
|
|
||||||
|
// check application prefrences for default language
|
||||||
|
$language = ( isset(App::$prefs->language) && App::$prefs->language != '' ) ? App::$prefs->language : 'english' ;
|
||||||
|
|
||||||
|
// check current session is set to use non-default language
|
||||||
|
$language = ( isset($_SESSION['language']) && $_SESSION['language'] != '' ) ? $_SESSION['language'] : $language ;
|
||||||
|
|
||||||
|
if ( is_file(self::$strings_path.'/'.strtolower($language).'.php') ) {
|
||||||
|
include(self::$strings_path.'/'.strtolower($language).'.php');
|
||||||
|
if ( !empty($strings) && is_array($strings) ) {
|
||||||
|
self::$strings = array_merge(self::$strings, $strings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function start_timer () {
|
||||||
|
Timer::start();
|
||||||
|
self::$timer_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
The App class is designed to store application specific
|
||||||
|
information. "App::$prefs" for exaple stores the application
|
||||||
|
preferences. These can also be accessed with
|
||||||
|
"Znap::$prefs->application".
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class App {
|
||||||
|
|
||||||
|
public static
|
||||||
|
$_internals,
|
||||||
|
$strings,
|
||||||
|
$preferences,
|
||||||
|
$cache,
|
||||||
|
$str,
|
||||||
|
$prefs;
|
||||||
|
|
||||||
|
function initialize () {
|
||||||
|
self::$_internals = &Znap::$prefs->_internals;
|
||||||
|
self::$strings = &Znap::$strings;
|
||||||
|
self::$preferences = &Znap::$prefs->application;
|
||||||
|
self::$cache = &Znap::$prefs->cache;
|
||||||
|
self::$str = &Znap::$strings;
|
||||||
|
self::$prefs = &Znap::$prefs->application;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// autoload magic
|
||||||
|
function __autoload ($class_name) {
|
||||||
|
|
||||||
|
// check cache if specified class has been found before
|
||||||
|
if ( !empty(App::$cache->autoload[$class_name]) ) {
|
||||||
|
if ( is_file(App::$cache->autoload[$class_name]) ) {
|
||||||
|
include_once(App::$cache->autoload[$class_name]);
|
||||||
|
$found = true;
|
||||||
|
} else {
|
||||||
|
unset(App::$cache->autoload[$class_name]);
|
||||||
|
$save_cache = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty($found) ) {
|
||||||
|
|
||||||
|
$name = Inflector::underscore($class_name);
|
||||||
|
|
||||||
|
$file = $name.'.php';
|
||||||
|
$file_lib = $name.'.lib.php';
|
||||||
|
$file_cla = $name.'.class.php';
|
||||||
|
|
||||||
|
$org_file = $class_name.'.php';
|
||||||
|
$org_lib = $class_name.'.lib.php';
|
||||||
|
$org_cla = $class_name.'.class.php';
|
||||||
|
|
||||||
|
$low = strtolower($class_name);
|
||||||
|
$low_file = $low.'.php';
|
||||||
|
$low_lib = $low.'.lib.php';
|
||||||
|
$low_cla = $low.'.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
$internal_paths = array(
|
||||||
|
Znap::$models_path,
|
||||||
|
Znap::$controllers_path,
|
||||||
|
Znap::$current_controller_path,
|
||||||
|
);
|
||||||
|
|
||||||
|
// autoload model and controller classes
|
||||||
|
foreach( $internal_paths as $path ) {
|
||||||
|
if ( is_file($path.'/'.$file) ) {
|
||||||
|
include_once($path.'/'.$file);
|
||||||
|
App::$cache->autoload[$class_name] = $path.'/'.$file;
|
||||||
|
$save_cache = true;
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// autload classes from libs folder
|
||||||
|
if ( empty($found) ) {
|
||||||
|
|
||||||
|
$paths = array(
|
||||||
|
Znap::$lib_path.'/'.$low,
|
||||||
|
Znap::$lib_path.'/'.$class_name,
|
||||||
|
Znap::$lib_path.'/'.$name,
|
||||||
|
Znap::$lib_path,
|
||||||
|
);
|
||||||
|
|
||||||
|
$files = array(
|
||||||
|
$low_lib, $low_cla, $low_file,
|
||||||
|
$org_lib, $org_cla, $org_file,
|
||||||
|
$file_lib, $file_cla, $file,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach( $paths as $path ) {
|
||||||
|
if ( is_dir($path) ) {
|
||||||
|
foreach( $files as $file ) {
|
||||||
|
if ( is_file($path.'/'.$file) ) {
|
||||||
|
include_once($path.'/'.$file);
|
||||||
|
App::$cache->autoload[$class_name] = $path.'/'.$file;
|
||||||
|
$save_cache = true;
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if ( !empty($save_cache) ) {
|
||||||
|
App::$cache->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user