repo
string | commit
string | message
string | diff
string |
---|---|---|---|
jtietema/Fizzy
|
34824effe3bea84ae60cf3cb6c3f95acc3b6b9b2
|
improvements in styling comments
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index 21903a0..a1364dd 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -20,520 +20,520 @@ body {
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
#sub-navigation-panel ul {
margin-left: 20px;
margin-top: 10px;
padding-bottom: 5px;
border-bottom: 1px solid #E4E4E4;
}
#sub-navigation-panel ul li {
display: inline;
list-style-type: none;
padding-right: 20px;
font-weight: bold;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
/* ********************** */
/* COMMENTS */
.comments {
margin-top: 10px;
margin-bottom: 10px;
}
.comment {
position: relative;
border: solid 1px gray;
margin-bottom:10px;
}
.comment .avatar {
float: left;
padding: 10px;
}
.comment .content {
float:left;
padding: 10px;
}
.comment .content .author-info {
margin-bottom: 5px;
}
.comment .content .actions {
- margin-top: 5px;
+ margin-top: 10px;
}
.comment .content .actions li {
display: inline;
list-style-type: none;
padding-right: 20px;
}
\ No newline at end of file
diff --git a/application/assets/css/forms.css b/application/assets/css/forms.css
index 2dced36..1095d4c 100644
--- a/application/assets/css/forms.css
+++ b/application/assets/css/forms.css
@@ -1,83 +1,84 @@
/**
* Fizzy Forms stylesheet for theme 2.0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* STANDARD FORM */
/* main form panel */
.form-panel {
padding: 10px 15px;
background-color: #ECEEEC;
border: 1px solid #DEDEDE;
+ margin-bottom: 15px;
}
.form-panel .form-title, #content-panel .form-panel h2.form-title {
margin-bottom: 10px;
font-size: 24px;
padding-left: 15px;
border: 0;
}
.form-panel label {
margin-right: 1em;
margin-bottom: .4em;
}
.form-panel input[type="text"],
.form-panel input[type="password"],
.form-panel input[type="email"],
.form-panel textarea,
.form-panel select,
.form-panel .wysiwyg
{
margin-bottom: .7em;
}
.form-panel input[type="text"],
.form-panel input[type="password"],
.form-panel input[type="email"],
.form-panel textarea
{
padding: .4em .4em;
}
.form-panel select {
margin-top: 0.4em;
margin-bottom: 0.4em;
}
/* form control */
.form-control-panel {
margin: 0 0 20px 0;
padding: 5px 15px;
}
.form-control-panel input {
margin-right: 2.8em;
font-size: 20px;
color: #FFFFFF;
}
/* form options */
.form-options-panel {
margin: 20px 0;
padding: 0px 15px;
}
.form-options-panel label {
border-bottom: 1px solid #ccc;
}
.form-options-panel select {
width: 100%;
}
.form-options-panel input[type="checkbox"] {
position: relative;
top: .2em;
}
/* STANDARD FORM */
/* ********************** */
diff --git a/application/modules/admin/views/scripts/blogs/post-form.phtml b/application/modules/admin/views/scripts/blogs/post-form.phtml
index f5ccad4..f213de9 100644
--- a/application/modules/admin/views/scripts/blogs/post-form.phtml
+++ b/application/modules/admin/views/scripts/blogs/post-form.phtml
@@ -1,68 +1,73 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
<?= $this->image('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->post->isNew()) ? 'Add post' : 'Edit post'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->body; ?>
</div>
+ <h2>
+ <?= $this->image('/fizzy_assets/images/icon/balloons.png'); ?>
+ Comments on this post
+ </h2>
+
<div class="comments">
<?= $this->partial('comments/_comments.phtml', array(
'comments' => $this->post->Comments(),
'back' => 'post'
)) ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->post->isNew()) : ?>
<li class="no-bg right">
<?= $this->link(
'/fizzy/post/' . $this->post->id . '/delete',
$this->image('fizzy_assets/images/icon/document--minus.png') . ' delete page',
array(
'class' => 'delete',
'Are you sure you want to delete this page?',
'escape' => false
)
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/blog/' . $this->post->Blog->id,
$this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name,
array('escape' => false)
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
<?= $this->form->status; ?>
<?= $this->form->author; ?>
<?= $this->form->date; ?>
<?= $this->form->comments; ?>
</div>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/_comments.phtml b/application/modules/admin/views/scripts/comments/_comments.phtml
index f116b79..787bffd 100644
--- a/application/modules/admin/views/scripts/comments/_comments.phtml
+++ b/application/modules/admin/views/scripts/comments/_comments.phtml
@@ -1,37 +1,48 @@
<?php foreach ($this->comments as $comment): ?>
+<?php
+$thread = $comment->getThreadModel();
+?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
- From <?= $comment->name ?>
+ From <?= $comment->name ?> <?= (!empty($thread)) ? 'on '.$thread->label() : '' ?>
</div>
<div class="comment-body">
<?= $comment->body ?>
</div>
<div class="actions">
<ul>
- <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $this->back) ?>">Edit</a></li>
<li>
- <?php if ($comment->isSpam()) : ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=' . $this->back) ?>">Not spam</a>
- <?php else: ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=' . $this->back) ?>">Spam</a>
- <?php endif; ?>
+ <?= $this->link('/fizzy/comment/edit/' . $comment->id . '?back=' . $this->back, 'Edit', array(
+ 'class' => 'c3button'
+ )) ?>
+ </li>
+ <li>
+ <?php if ($comment->isSpam()) : ?>
+ <?= $this->link('/fizzy/comment/ham/' . $comment->id . '?back=' . $this->back, 'Not spam', array(
+ 'class' => 'c3button'
+ )) ?>
+ <?php else: ?>
+ <?= $this->link('/fizzy/comment/spam/' . $comment->id . '?back=' . $this->back, 'Spam', array(
+ 'class' => 'c3button'
+ )) ?>
+ <?php endif; ?>
</li>
<li><?= $this->link(
'/fizzy/comment/delete/' . $comment->id . '?back=' . $this->back,
'Delete',
array(
- 'class' => 'delete',
+ 'class' => 'delete c3button',
'confirm' => 'Are you sure you want to delete this comment?',
)
); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
diff --git a/application/modules/admin/views/scripts/comments/index.phtml b/application/modules/admin/views/scripts/comments/index.phtml
index 54b8e00..b58cc62 100644
--- a/application/modules/admin/views/scripts/comments/index.phtml
+++ b/application/modules/admin/views/scripts/comments/index.phtml
@@ -1,62 +1,29 @@
<div id="content-panel">
<h2>Latest comments</h2>
- <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
- <div class="comment">
- <div class="avatar">
- <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
- </div>
- <div class="content">
- <div class="author-info">
- From <?= $comment->name ?>
- </div>
- <div class="comment-body">
- <?= $comment->body ?>
- </div>
- <div class="actions">
- <ul>
- <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=dashboard') ?>">Edit</a></li>
- <li>
- <?php if ($comment->isSpam()) : ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=dashboard') ?>">Not spam</a>
- <?php else: ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=dashboard') ?>">Spam</a>
- <?php endif; ?>
- </li>
- <li><?= $this->link(
- '/fizzy/comment/delete/' . $comment->id . '?back=dashboard',
- 'Delete',
- array(
- 'class' => 'delete',
- 'confirm' => 'Are you sure you want to delete this comment?',
- )
- ); ?>
- </li>
- </ul>
- </div>
- </div>
- <div class="clear"></div>
- </div>
- <?php endforeach; ?>
+ <?= $this->partial('comments/_comments.phtml', array(
+ 'comments' => $this->paginator->getCurrentItems(),
+ 'back' => 'dashboard'
+ )) ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
<h2>Comments overview</h2>
<table class="data">
<tbody>
<tr>
<td><a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Total comments</a></td>
<td><?= $this->totalComments ?></td>
</tr>
<tr>
<td><a href="<?= $this->baseUrl('/fizzy/comments/spam') ?>">Spam</a></td>
<td><?= $this->spamComments ?></td>
</tr>
</tbody>
</table>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/spambox.phtml b/application/modules/admin/views/scripts/comments/spambox.phtml
index e60ef04..a526a80 100644
--- a/application/modules/admin/views/scripts/comments/spambox.phtml
+++ b/application/modules/admin/views/scripts/comments/spambox.phtml
@@ -1,48 +1,15 @@
<div id="content-panel">
<h2>Spambox</h2>
- <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
- <div class="comment">
- <div class="avatar">
- <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
- </div>
- <div class="content">
- <div class="author-info">
- From <?= $comment->name ?>
- </div>
- <div class="comment-body">
- <?= $comment->body ?>
- </div>
- <div class="actions">
- <ul>
- <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=spambox') ?>">Edit</a></li>
- <li>
- <?php if ($comment->isSpam()) : ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=spambox') ?>">Not spam</a>
- <?php else: ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=spambox') ?>">Spam</a>
- <?php endif; ?>
- </li>
- <li><?= $this->link(
- '/fizzy/comment/delete/' . $comment->id . '?back=spambox',
- 'Delete',
- array(
- 'class' => 'delete',
- 'confirm' => 'Are you sure you want to delete this comment?',
- )
- ); ?>
- </li>
- </ul>
- </div>
- </div>
- <div class="clear"></div>
- </div>
- <?php endforeach; ?>
+ <?= $this->partial('comments/_comments.phtml', array(
+ 'comments' => $this->paginator->getCurrentItems(),
+ 'back' => 'spambox'
+ )) ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
</div>
|
jtietema/Fizzy
|
e5ad6ed1a281f6cda6a9aac1b57ba6e1dec7744b
|
fixed typo
|
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index 4e7384c..60c84a8 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,286 +1,286 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
$this->view->totalComments = $query->count();
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
$this->view->spamComments = $spamQuery->count();
$this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
- $paginator->setItemCountPerPage(1);
+ $paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('post_id = ?', $id)->andWhere('spam = 0')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$tempModel = $query->fetchOne();
$this->view->threadModel = $tempModel->getThreadModel();
$this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
$this->_redirectBack($comment);
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
$this->_redirectBack($comment);
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
$this->_redirectBack($comment);
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
$this->_redirectBack($comment);
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
protected function _redirectBack(Comments $comment = null)
{
$redirect = $this->_getParam('back', 'dashboard');
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
case 'post':
$postId = (int) substr($comment->post_id, 5);
$this->_redirect('/fizzy/post/' . $postId . '/edit');
default:
$this->_redirect('/fizzy/comments');
break;
}
}
}
|
jtietema/Fizzy
|
22b8cf4b1ca867b985eaab26052f3feff13e6a42
|
modified readme and added LGPL License
|
diff --git a/LICENSE.txt b/LICENSE-BSD.txt
similarity index 100%
rename from LICENSE.txt
rename to LICENSE-BSD.txt
diff --git a/LICENSE-LGPL.txt b/LICENSE-LGPL.txt
new file mode 100644
index 0000000..60d6d4c
--- /dev/null
+++ b/LICENSE-LGPL.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/README.txt b/README.txt
index 4b4af8c..c64373f 100644
--- a/README.txt
+++ b/README.txt
@@ -1,67 +1,66 @@
Welcome to Fizzy!
=================
Introduction
------------
-Fizzy is a small PHP 5 Content Management System. It is designed to be portable.
-It addition to MySQL it supports XML and SQLite. This makes it is ideal for
-small shared hosting accounts or low memory VPS systems. It's flexible MVC
-architecture allows for quick development and it storage backend ensures you
-don't have to worry about SQL queries and alike.
+Fizzy is a PHP 5 Content Management System build with the Zend Framework and
+Doctrine. It is designed to be flexible in development and is aimed at sites that
+require a large amout of customization.
For more information, see http://project.voidwalkers.nl/projects/show/fizzy
Requirements
------------
To get Fizzy running you need the following:
- Apache mod_rewrite support (or equivalent)
- PHP 5.2+
-- DOM XML extension
-- SimpleXML extension
If you want to use the SQLite backend, the following PHP extensions are required:
- PDO
- PDO SQLite extension
For MySQL you need:
- PDO
- PDO MySQL extension
Getting started
---------------
-First copy configs/fizzy.xml.default to configs/fizzy.xml and modify the xml
-path.
+First configure the database settings in the application.ini file located in
+the configs folder.
Then copy all the files to your webserver and you are good to go. It is
recommended not to copy Fizzy to your web root. Only the files from the public
folder need to be in your webroot.
The data folder and all its files need to be writeable for the webserver. Also
make sure the public/uploads folder exists and is writable by the webserver if
you want to upload files.
Visit http://<your-site> for the demo site.
Visit http://<your-site>/admin for the admin interface.
The default user is admin with password admin. Be sure to change that after the
first login.
Getting Help
------------
If you need help with Fizzy, you can get help from the following sources:
- Wiki: http://project.voidwalkers.nl/wiki/fizzy
If you discover any bugs, please report them here:
http://project.voidwalkers.nl/projects/fizzy/issues
License
-------
-The files in this archive are released under the new BSD license.
-You can find a copy of this license in LICENSE.txt.
+Doctrine and TinyMCE are LGPL Licensed.
+You can find a copy of this license in LICENSE-LGPL.txt.
+
+Zend Framework, SabreDAV and Fizzy itself are released under the new BSD license.
+You can find a copy of this license in LICENSE-BSD.txt.
|
jtietema/Fizzy
|
19f2b888a84c2c3003bdcb7dc5dcee291bf1ffe5
|
documentation and improvements in the spam backend
|
diff --git a/library/Fizzy/Spam.php b/library/Fizzy/Spam.php
index 57bf056..4fdfad1 100644
--- a/library/Fizzy/Spam.php
+++ b/library/Fizzy/Spam.php
@@ -1,64 +1,91 @@
<?php
/**
* Class Fizzy_Spam
* @package Fizzy
* @subpackage Spam
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class for filtering (comment) spam using various webservices as backend
*
+ * You can pass any content in the form of an instance of Fizzy_Spam_Document.
+ * This class will pass it on to an configured backend and thus provides an
+ * unified interface for multiple backends.
+ *
* @author Jeroen Tietema <[email protected]>
*/
class Fizzy_Spam
{
protected static $_defaultAdapter = null;
protected $_adapter = null;
- public function __construct($adapter = null)
+ public function __construct(Fizzy_Spam_Adapter_Interface $adapter = null)
{
if (null === $adapter){
if (null === self::$_defaultAdapter){
throw new Fizzy_Spam_Exception('No adapter specified.');
}
$this->_adapter = self::$_defaultAdapter;
} else {
$this->_adapter = $adapter;
}
}
- public static function setDefaultAdapter($adapter)
+ /**
+ * Set the default Adapter to be used when no Adapter is specified in the
+ * constructor.
+ *
+ * @param <type> $adapter
+ */
+ public static function setDefaultAdapter(Fizzy_Spam_Adapter_Interface $adapter)
{
self::$_defaultAdapter = $adapter;
}
+ /**
+ * Check if the given document is spam
+ * @param Fizzy_Spam_Document $document
+ * @return boolean
+ */
public function isSpam(Fizzy_Spam_Document $document)
{
return $this->_adapter->isSpam($document);
}
+ /**
+ * Submit this document as spam to the backend (feedback)
+ *
+ * @param Fizzy_Spam_Document $document
+ * @return <type>
+ */
public function submitSpam(Fizzy_Spam_Document $document)
{
return $this->_adapter->submitSpam($document);
}
+ /**
+ * Submit this document as NOT spam to the backend (feedback)
+ *
+ * @param Fizzy_Spam_Document $document
+ * @return <type>
+ */
public function submitHam(Fizzy_Spam_Document $document)
{
return $this->_adapter->submitHam($document);
}
}
|
jtietema/Fizzy
|
09550e0bba71821e4bbfa975576fd38696698565
|
paging in de comments threads list
|
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index bcdaaaa..4e7384c 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,280 +1,286 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
$this->view->totalComments = $query->count();
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
$this->view->spamComments = $spamQuery->count();
$this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
+ $pageNumber = $this->_getParam('page', 1);
+
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
- $topics = $query->execute();
- $this->view->topics = $topics;
+
+ $paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
+ $paginator->setItemCountPerPage(1);
+ $paginator->setCurrentPageNumber($pageNumber);
+
+ $this->view->paginator = $paginator;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('post_id = ?', $id)->andWhere('spam = 0')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$tempModel = $query->fetchOne();
$this->view->threadModel = $tempModel->getThreadModel();
$this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
$this->_redirectBack($comment);
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
$this->_redirectBack($comment);
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
$this->_redirectBack($comment);
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
$this->_redirectBack($comment);
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
protected function _redirectBack(Comments $comment = null)
{
$redirect = $this->_getParam('back', 'dashboard');
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
case 'post':
$postId = (int) substr($comment->post_id, 5);
$this->_redirect('/fizzy/post/' . $postId . '/edit');
default:
$this->_redirect('/fizzy/comments');
break;
}
}
}
diff --git a/application/modules/admin/views/scripts/comments/index.phtml b/application/modules/admin/views/scripts/comments/index.phtml
index 9f4d9a9..54b8e00 100644
--- a/application/modules/admin/views/scripts/comments/index.phtml
+++ b/application/modules/admin/views/scripts/comments/index.phtml
@@ -1,66 +1,62 @@
<div id="content-panel">
- <h2>Comments overview</h2>
-
- <table class="data" style="width: 400px;">
- <tbody>
- <tr>
- <td><a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Total comments</a></td>
- <td><?= $this->totalComments ?></td>
- </tr>
- <tr>
- <td><a href="<?= $this->baseUrl('/fizzy/comments/spam') ?>">Spam</a></td>
- <td><?= $this->spamComments ?></td>
- </tr>
- </tbody>
- </table>
-
- <br>
-
<h2>Latest comments</h2>
<?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
From <?= $comment->name ?>
</div>
<div class="comment-body">
<?= $comment->body ?>
</div>
<div class="actions">
<ul>
<li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=dashboard') ?>">Edit</a></li>
<li>
<?php if ($comment->isSpam()) : ?>
<a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=dashboard') ?>">Not spam</a>
<?php else: ?>
<a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=dashboard') ?>">Spam</a>
<?php endif; ?>
</li>
<li><?= $this->link(
'/fizzy/comment/delete/' . $comment->id . '?back=dashboard',
'Delete',
array(
'class' => 'delete',
'confirm' => 'Are you sure you want to delete this comment?',
)
); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
+ <h2>Comments overview</h2>
+ <table class="data">
+ <tbody>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Total comments</a></td>
+ <td><?= $this->totalComments ?></td>
+ </tr>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/comments/spam') ?>">Spam</a></td>
+ <td><?= $this->spamComments ?></td>
+ </tr>
+ </tbody>
+ </table>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/list.phtml b/application/modules/admin/views/scripts/comments/list.phtml
index c962bda..72f1f6c 100644
--- a/application/modules/admin/views/scripts/comments/list.phtml
+++ b/application/modules/admin/views/scripts/comments/list.phtml
@@ -1,32 +1,34 @@
<div id="content-panel">
<h2>Discussions</h2>
<div>
<table class="data" id="pages-table">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Number comments</td>
</tr>
</thead>
<tbody>
- <?php foreach ($this->topics as $topic): ?>
+ <?php foreach ($this->paginator->getCurrentItems() as $topic): ?>
<tr>
<td class="controls">
</td>
<td><a href="<?= $this->baseUrl('/fizzy/comments/topic/' . $topic->post_id) ?>"><?= $topic->getThreadModel()->label() ?></a></td>
<td><?= $topic->getNumberTopicComments() ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
+ <?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
+
</div>
</div>
<div id="sidebar-panel">
</div>
|
jtietema/Fizzy
|
eaba789ca2038eaf44c503547f845f167ed53b10
|
comments & blog post integratie
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index c6fef36..21903a0 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,534 +1,539 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
#sub-navigation-panel ul {
margin-left: 20px;
margin-top: 10px;
padding-bottom: 5px;
border-bottom: 1px solid #E4E4E4;
}
#sub-navigation-panel ul li {
display: inline;
list-style-type: none;
padding-right: 20px;
font-weight: bold;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
/* ********************** */
/* COMMENTS */
+.comments {
+ margin-top: 10px;
+ margin-bottom: 10px;
+}
+
.comment {
position: relative;
border: solid 1px gray;
margin-bottom:10px;
}
.comment .avatar {
float: left;
padding: 10px;
}
.comment .content {
float:left;
padding: 10px;
}
.comment .content .author-info {
margin-bottom: 5px;
}
.comment .content .actions {
margin-top: 5px;
}
.comment .content .actions li {
display: inline;
list-style-type: none;
padding-right: 20px;
}
\ No newline at end of file
diff --git a/application/models/Post.php b/application/models/Post.php
index b7a2726..6ab18bd 100644
--- a/application/models/Post.php
+++ b/application/models/Post.php
@@ -1,36 +1,36 @@
<?php
/**
* Post
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Post extends BasePost
{
const PUBLISHED = 2;
const PENDING_REVIEW = 1;
const DRAFT = 0;
public function isNew()
{
return empty($this->id);
}
public function comments()
{
$query = Doctrine_Query::create()->from('Comments')
- ->where('post_id = ?', 'post:'.$this->id)->orderBy('id DESC');
+ ->where('post_id = ?', 'post:'.$this->id)->andWhere('spam = 0')->orderBy('id DESC');
$comments = $query->execute();
return $comments;
}
public function label()
{
return $this->title;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index 5a84780..bcdaaaa 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,303 +1,280 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
$this->view->totalComments = $query->count();
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
$this->view->spamComments = $spamQuery->count();
$this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
$topics = $query->execute();
$this->view->topics = $topics;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('post_id = ?', $id)->andWhere('spam = 0')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$tempModel = $query->fetchOne();
$this->view->threadModel = $tempModel->getThreadModel();
$this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
- $redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
- switch($redirect){
- case 'topic':
- $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
- break;
- case 'spambox':
- $this->_redirect('/fizzy/comments/spam');
- break;
- default:
- $this->_redirect('/fizzy/comments');
- break;
- }
+ $this->_redirectBack($comment);
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
- $redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
- switch($redirect){
- case 'topic':
- $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
- break;
- case 'spambox':
- $this->_redirect('/fizzy/comments/spam');
- break;
- default:
- $this->_redirect('/fizzy/comments');
- break;
- }
+ $this->_redirectBack($comment);
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
- switch($redirect){
- case 'topic':
- $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
- break;
- case 'spambox':
- $this->_redirect('/fizzy/comments/spam');
- break;
- default:
- $this->_redirect('/fizzy/comments');
- break;
- }
+ $this->_redirectBack($comment);
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
- $redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
- switch($redirect){
- case 'topic':
- $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
- break;
- case 'spambox':
- $this->_redirect('/fizzy/comments/spam');
- break;
- default:
- $this->_redirect('/fizzy/comments');
- break;
- }
+ $this->_redirectBack($comment);
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
+
+ protected function _redirectBack(Comments $comment = null)
+ {
+ $redirect = $this->_getParam('back', 'dashboard');
+
+ switch($redirect){
+ case 'topic':
+ $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
+ break;
+ case 'spambox':
+ $this->_redirect('/fizzy/comments/spam');
+ break;
+ case 'post':
+ $postId = (int) substr($comment->post_id, 5);
+ $this->_redirect('/fizzy/post/' . $postId . '/edit');
+ default:
+ $this->_redirect('/fizzy/comments');
+ break;
+ }
+ }
}
diff --git a/application/modules/admin/views/scripts/blogs/post-form.phtml b/application/modules/admin/views/scripts/blogs/post-form.phtml
index f3bd502..f5ccad4 100644
--- a/application/modules/admin/views/scripts/blogs/post-form.phtml
+++ b/application/modules/admin/views/scripts/blogs/post-form.phtml
@@ -1,61 +1,68 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
<?= $this->image('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->post->isNew()) ? 'Add post' : 'Edit post'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->body; ?>
</div>
+ <div class="comments">
+ <?= $this->partial('comments/_comments.phtml', array(
+ 'comments' => $this->post->Comments(),
+ 'back' => 'post'
+ )) ?>
+ </div>
+
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->post->isNew()) : ?>
<li class="no-bg right">
<?= $this->link(
'/fizzy/post/' . $this->post->id . '/delete',
$this->image('fizzy_assets/images/icon/document--minus.png') . ' delete page',
array(
'class' => 'delete',
'Are you sure you want to delete this page?',
'escape' => false
)
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/blog/' . $this->post->Blog->id,
$this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name,
array('escape' => false)
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
<?= $this->form->status; ?>
<?= $this->form->author; ?>
<?= $this->form->date; ?>
<?= $this->form->comments; ?>
</div>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/_comments.phtml b/application/modules/admin/views/scripts/comments/_comments.phtml
new file mode 100644
index 0000000..f116b79
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/_comments.phtml
@@ -0,0 +1,37 @@
+<?php foreach ($this->comments as $comment): ?>
+<div class="comment">
+ <div class="avatar">
+ <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
+ </div>
+ <div class="content">
+ <div class="author-info">
+ From <?= $comment->name ?>
+ </div>
+ <div class="comment-body">
+ <?= $comment->body ?>
+ </div>
+ <div class="actions">
+ <ul>
+ <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $this->back) ?>">Edit</a></li>
+ <li>
+ <?php if ($comment->isSpam()) : ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=' . $this->back) ?>">Not spam</a>
+ <?php else: ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=' . $this->back) ?>">Spam</a>
+ <?php endif; ?>
+ </li>
+ <li><?= $this->link(
+ '/fizzy/comment/delete/' . $comment->id . '?back=' . $this->back,
+ 'Delete',
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this comment?',
+ )
+ ); ?>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="clear"></div>
+</div>
+<?php endforeach; ?>
diff --git a/application/modules/admin/views/scripts/comments/topic.phtml b/application/modules/admin/views/scripts/comments/topic.phtml
index c55935e..c0dd535 100644
--- a/application/modules/admin/views/scripts/comments/topic.phtml
+++ b/application/modules/admin/views/scripts/comments/topic.phtml
@@ -1,48 +1,15 @@
<div id="content-panel">
<h2><?= $this->threadModel->label() ?></h2>
- <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
- <div class="comment">
- <div class="avatar">
- <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
- </div>
- <div class="content">
- <div class="author-info">
- From <?= $comment->name ?>
- </div>
- <div class="comment-body">
- <?= $comment->body ?>
- </div>
- <div class="actions">
- <ul>
- <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=topic') ?>">Edit</a></li>
- <li>
- <?php if ($comment->isSpam()) : ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=topic') ?>">Not spam</a>
- <?php else: ?>
- <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=topic') ?>">Spam</a>
- <?php endif; ?>
- </li>
- <li><?= $this->link(
- '/fizzy/comment/delete/' . $comment->id . '?back=topic',
- 'Delete',
- array(
- 'class' => 'delete',
- 'confirm' => 'Are you sure you want to delete this comment?',
- )
- ); ?>
- </li>
- </ul>
- </div>
- </div>
- <div class="clear"></div>
- </div>
- <?php endforeach; ?>
+ <?= $this->partial('comments/_comments.phtml', array(
+ 'comments' => $this->paginator->getCurrentItems(),
+ 'back' => 'topic'
+ )) ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
</div>
\ No newline at end of file
diff --git a/library/Fizzy/Form/Element/Wysiwyg.php b/library/Fizzy/Form/Element/Wysiwyg.php
index a18490c..fb82bbe 100644
--- a/library/Fizzy/Form/Element/Wysiwyg.php
+++ b/library/Fizzy/Form/Element/Wysiwyg.php
@@ -1,34 +1,34 @@
<?php
/**
* Class Fizzy_Form_Element_Wysiwyg
* @category Fizzy
- * @package Fizzy_Form_Element_Wysiwig
+ * @package Fizzy_Form_Element_Wysiwyg
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
class Fizzy_Form_Element_Wysiwyg extends Zend_Form_Element_Xhtml
{
/**
* Use formTextarea view helper by default
* @var string
*/
public $helper = 'wysiwyg';
public function init()
{
$view = $this->getView();
$view->addHelperPath('Fizzy/View/Helper', 'Fizzy_View_Helper');
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
5a25f4040ddebabd58768bcc40fcfad31b57d5aa
|
Added view helper for Fizzy assets
|
diff --git a/library/Fizzy/View/Helper/AssetUrl.php b/library/Fizzy/View/Helper/AssetUrl.php
new file mode 100644
index 0000000..e90c7bf
--- /dev/null
+++ b/library/Fizzy/View/Helper/AssetUrl.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Class Fizzy_View_Helper_AssetUrl
+ * @package Fizzy
+ * @subpackage View
+ * @category Helpers
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright 2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Helper to assist in loading fizzy assets in view files
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_View_Helper_AssetUrl extends Zend_View_Helper_Abstract
+{
+
+ /**
+ * Generates an url to fizzy assets
+ * @param string $asset the asset
+ * @param boolean $prependBase if the base url should be added
+ * @return string
+ */
+ public function assetUrl($asset, $prependBase = true)
+ {
+ $config = Zend_Registry::get('config');
+
+ // Get the base for fizzy assets
+ $base = (isset($config->assetsBase)) ? $config->assetsBase : 'fizzy_assets';
+ $base = '/' . trim($base, '/');
+ $base = rtrim($base, '/');
+
+ // Clean the asset path
+ $asset = '/' . trim($asset, '/');
+
+ $url = $base . $asset;
+ if ($prependBase) {
+ // Check for View instance existence
+ if (null == $this->view) {
+ // Assume Fizzy view helpers are added to the view by default
+ $this->view = new Zend_View();
+ }
+ // Prepend the base url
+ $url = $this->view->baseUrl($url);
+ }
+
+ return $url;
+ }
+
+}
\ No newline at end of file
|
jtietema/Fizzy
|
9ab93e9a02d767ec7a9e44abfab39119755c32e3
|
fixed bug that inserted empty items in sub-navigation
|
diff --git a/application/modules/admin/views/scripts/subnavigation.phtml b/application/modules/admin/views/scripts/subnavigation.phtml
index b48bcb8..8649f17 100644
--- a/application/modules/admin/views/scripts/subnavigation.phtml
+++ b/application/modules/admin/views/scripts/subnavigation.phtml
@@ -1,11 +1,11 @@
<ul>
<?php foreach($this->items as $page) : ?>
- <li<?= ($page->isActive(true)) ? ' class="active"' : ''; ?>>
<?php $label = $page->getLabel();
if (!empty($label)): ?>
- <a href="<?= $page->getHref(); ?>"><?= $page->getLabel(); ?></a>
+ <li<?= ($page->isActive(true)) ? ' class="active"' : ''; ?>>
+ <a href="<?= $page->getHref(); ?>"><?= $page->getLabel(); ?></a>
+ </li>
<?php endif; ?>
- </li>
<?php endforeach; ?>
</ul>
<div class="clear"></div>
\ No newline at end of file
|
jtietema/Fizzy
|
6580e7d3556a62b8f0cda0a36d7968a6fa76412e
|
sub-navigation
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index ad8f0e6..4471424 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,527 +1,541 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
.hover-edit {
background-color: #FFF6C1;
background-image: url('../images/icon/pencil-small.png');
background-repeat: no-repeat;
background-position: right;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
+#sub-navigation-panel ul {
+ margin-left: 20px;
+ margin-top: 10px;
+ padding-bottom: 5px;
+ border-bottom: 1px solid #E4E4E4;
+}
+
+#sub-navigation-panel ul li {
+ display: inline;
+ list-style-type: none;
+ padding-right: 20px;
+ font-weight: bold;
+}
+
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
/* ********************** */
/* COMMENTS */
.comment {
position: relative;
border: solid 1px gray;
margin-bottom:10px;
}
.comment .avatar {
float: left;
padding: 10px;
}
.comment .content {
float:left;
padding: 10px;
}
.comment .content .author-info {
margin-bottom: 5px;
}
.comment .content .actions {
margin-top: 5px;
}
.comment .content .actions li {
display: inline;
list-style-type: none;
padding-right: 20px;
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 913f8da..1a6aba3 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,178 +1,193 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
+ protected $_navigation = null;
+
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
- public function navigationAction() {
+ public function navigationAction()
+ {
+ if (null === $this->_navigation){
+ $this->_navigation = $this->_createNavigation();
+ }
+
+ $this->view->items = $this->_navigation->getPages();
+ $this->renderScript('navigation.phtml');
+ }
+
+ public function subnavigationAction()
+ {
+ if (null === $this->_navigation){
+ $this->_navigation = $this->_createNavigation();
+ }
+
+ $this->view->items = array();
+ foreach ($this->_navigation->getPages() as $page){
+ if ($page->isActive(true)){
+ $this->view->items = $page->getPages();
+ break;
+ }
+ }
+
+ $this->renderScript('subnavigation.phtml');
+ }
+
+ protected function _createNavigation()
+ {
$items = array();
// Blog
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'pages' => array(
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Blog',
'route' => 'admin_blog',
'pages' => array(
new Fizzy_Navigation_Page_Route(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
)),
new Fizzy_Navigation_Page_Route(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
))
)
))
)
));
// Comments
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Comments',
'route' => 'admin_comments',
'pages' => array(
new Fizzy_Navigation_Page_Route(array(
'label' => 'Thread list',
'route' => 'admin_comments_list',
'pages' => array(
new Fizzy_Navigation_Page_Route(array(
'label' => 'Show thread',
'route' => 'admin_comments_topic',
- 'pages' => array()
))
)
)),
new Fizzy_Navigation_Page_Route(array(
'label' => 'Spambox',
'route' => 'admin_comments_spambox',
- 'pages' => array()
)),
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Edit comment',
'route' => 'admin_comments_edit',
))
)
));
// Pages
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Pages',
'route' => 'admin_pages',
'pages' => array(
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Add',
+ 'label' => 'Add page',
'route' => 'admin_pages_add',
)),
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Edit',
'route' => 'admin_pages_edit',
)),
)
));
// Media
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Media',
'route' => 'admin_media',
- 'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Contact',
'route' => 'admin_contact',
- 'module' => 'admin',
- 'controller' => 'contact',
- 'action' => 'index',
'pages' => array (
- new Zend_Navigation_Page_Mvc(array(
- 'label' => 'Contact show',
+ new Fizzy_Navigation_Page_Route(array(
'route' => 'admin_contact_show',
- 'module' => 'admin',
- 'controller' => 'contact',
- 'action' => 'show',
))
)
));
}
// Users
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Users',
'route' => 'admin_users',
'pages' => array (
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Add',
+ 'label' => 'Add user',
'route' => 'admin_users_add',
)),
new Fizzy_Navigation_Page_Route(array(
- 'label' => 'Edit',
'route' => 'admin_users_edit',
)),
)
));
// Settings
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Settings',
'route' => 'admin_settings',
));
// Logout
$items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Logout',
'route' => 'admin_logout',
));
-
- $this->view->items = $items;
- $this->renderScript('navigation.phtml');
+
+ return new Zend_Navigation($items);
}
}
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 043e04e..8f4ebc3 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,77 +1,81 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<?= $this->jQuery()->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
+ <div id="sub-navigation-panel">
+ <?= $this->action('subnavigation', 'index', 'admin'); ?>
+ </div>
+
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<div id="main-panel">
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
Fizzy <?= Fizzy_Version::VERSION ?>
running on
Zend Framework <?= Zend_Version::VERSION ?>
and
Doctrine <?= Doctrine::VERSION ?>
|
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a><br />
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/subnavigation.phtml b/application/modules/admin/views/scripts/subnavigation.phtml
new file mode 100644
index 0000000..b48bcb8
--- /dev/null
+++ b/application/modules/admin/views/scripts/subnavigation.phtml
@@ -0,0 +1,11 @@
+<ul>
+ <?php foreach($this->items as $page) : ?>
+ <li<?= ($page->isActive(true)) ? ' class="active"' : ''; ?>>
+ <?php $label = $page->getLabel();
+ if (!empty($label)): ?>
+ <a href="<?= $page->getHref(); ?>"><?= $page->getLabel(); ?></a>
+ <?php endif; ?>
+ </li>
+ <?php endforeach; ?>
+</ul>
+<div class="clear"></div>
\ No newline at end of file
|
jtietema/Fizzy
|
c686e5a53c2804107e28848d3a0b45152eb7e7b2
|
fixed old viewhelper
|
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index 0f391fb..f707ca2 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,56 +1,56 @@
<div id="content-panel">
<h2><?= $this->blog->name ?></h2>
<div>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Date</td>
<td>Status</td>
<td>Author</td>
</tr>
</thead>
<tbody>
<?php $items = $this->paginator->getCurrentItems();
foreach ($items as $post): ?>
<tr>
<td class="controls">
<?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->image('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page', 'escape' => false)); ?>
</td>
<td>
<?= $post->title ?>
</td>
<td>
<?= $post->date ?>
</td>
<td>
<?php if ($post->status == Post::PUBLISHED): ?>
Published
<?php elseif ($post->status == Post::PENDING_REVIEW): ?>
Pending review
<?php else: ?>
Draft
<?php endif; ?>
</td>
<td>
<?= $post->User->displayname ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
- <?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array('escape' => false)); ?>
+ <?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->image('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array('escape' => false)); ?>
</li>
</ul>
</div>
\ No newline at end of file
|
jtietema/Fizzy
|
ab547afb330a62956d10341031fef65fa4091db3
|
Fizzy_Navigation_Page_Route
|
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index e6c4f2f..913f8da 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,233 +1,178 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
- 'module' => 'admin',
- 'controller' => 'blogs',
- 'action' => 'index',
'pages' => array(
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Blog',
'route' => 'admin_blog',
- 'module' => 'admin',
- 'controller' => 'blogs',
- 'action' => 'blog',
'pages' => array(
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
- 'module' => 'admin',
- 'controller' => 'blogs',
- 'action' => 'edit-post'
)),
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
- 'module' => 'admin',
- 'controller' => 'blogs',
- 'action' => 'add-post'
))
)
))
)
));
// Comments
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Comments',
'route' => 'admin_comments',
- 'module' => 'admin',
- 'controller' => 'comments',
- 'action' => 'index',
'pages' => array(
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Thread list',
'route' => 'admin_comments_list',
- 'module' => 'admin',
- 'controller' => 'comments',
- 'action' => 'list',
'pages' => array(
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Show thread',
'route' => 'admin_comments_topic',
- 'module' => 'admin',
- 'controller' => 'comments',
- 'action' => 'topic',
'pages' => array()
))
)
)),
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Spambox',
'route' => 'admin_comments_spambox',
- 'module' => 'admin',
- 'controller' => 'comments',
- 'action' => 'spambox',
'pages' => array()
)),
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Edit comment',
'route' => 'admin_comments_edit',
- 'module' => 'admin',
- 'controller' => 'comments',
- 'action' => 'edit'
))
)
));
// Pages
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Pages',
'route' => 'admin_pages',
- 'module' => 'admin',
- 'controller' => 'pages',
- 'action' => 'index',
'pages' => array(
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Add',
'route' => 'admin_pages_add',
- 'module' => 'admin',
- 'controller' => 'pages',
- 'action' => 'add',
)),
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
- 'module' => 'admin',
- 'controller' => 'pages',
- 'action' => 'edit',
)),
)
));
// Media
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Media',
'route' => 'admin_media',
- 'module' => 'admin',
- 'controller' => 'media',
- 'action' => 'index',
'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Users',
'route' => 'admin_users',
- 'module' => 'admin',
- 'controller' => 'user',
- 'action' => 'index',
'pages' => array (
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Add',
'route' => 'admin_users_add',
- 'module' => 'admin',
- 'controller' => 'user',
- 'action' => 'add',
)),
- new Zend_Navigation_Page_Mvc(array(
+ new Fizzy_Navigation_Page_Route(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
- 'module' => 'admin',
- 'controller' => 'user',
- 'action' => 'edit',
)),
)
));
// Settings
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Settings',
'route' => 'admin_settings',
- 'module' => 'admin',
- 'controller' => 'settings',
- 'action' => 'index',
- 'pages' => array ()
));
// Logout
- $items[] = new Zend_Navigation_Page_Mvc(array(
+ $items[] = new Fizzy_Navigation_Page_Route(array(
'label' => 'Logout',
'route' => 'admin_logout',
- 'module' => 'admin',
- 'controller' => 'auth',
- 'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
diff --git a/library/Fizzy/Navigation/Page/Route.php b/library/Fizzy/Navigation/Page/Route.php
new file mode 100644
index 0000000..83f21de
--- /dev/null
+++ b/library/Fizzy/Navigation/Page/Route.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * Description of Route
+ *
+ * @author jeroen
+ */
+class Fizzy_Navigation_Page_Route extends Zend_Navigation_Page_Mvc
+{
+ public function __construct(Array $options)
+ {
+ if (!isset($options['route']) || empty($options['route'])){
+ throw new Zend_Controller_Router_Exception('No routename specified!');
+ }
+ $front = Zend_Controller_Front::getInstance();
+ $router = $front->getRouter();
+ $route = $router->getRoute($options['route']);
+ $defaults = $route->getDefaults();
+
+ $options['module'] = $defaults['module'];
+ $options['controller'] = $defaults['controller'];
+ $options['action'] = $defaults['action'];
+
+ parent::__construct($options);
+ }
+}
|
jtietema/Fizzy
|
fd0ab2f3b3c7b77a8b36f10172c8ff70c9bcec6b
|
Resetting old setting value on save failure
|
diff --git a/application/modules/admin/views/scripts/settings/index.phtml b/application/modules/admin/views/scripts/settings/index.phtml
index c27bf58..bc2d08f 100644
--- a/application/modules/admin/views/scripts/settings/index.phtml
+++ b/application/modules/admin/views/scripts/settings/index.phtml
@@ -1,200 +1,201 @@
<div id="content-panel">
<h2>
<?= $this->image('/fizzy_assets/images/icon/gear.png', array('alt' => 'Settings Icon')); ?>
Settings
</h2>
<table class="settings" id="settings-table">
<tbody>
<?php foreach($this->settings as $component => $settings) : ?>
<tr>
<th colspan="2"><?= ucfirst($component); ?></th>
</tr>
<?php foreach($settings as $setting) : ?>
<tr>
<td class="label">
<?= $setting->label; ?>
</td>
<td class="setting editable">
<div id="<?= $setting->component; ?>:<?= $setting->setting_key; ?>" class="value text"><?= $setting->value; ?></div>
<small><?= $setting->description; ?></small>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php $this->jQuery()->uiEnable(); ?>
<script type="text/javascript">
(function($) {
$.fn.inlineEdit = function(options) {
options = $.extend({
hoverClass: 'hover-edit',
savingClass: 'saving',
successClass: 'settings-success',
errorClass: 'settings-error',
value: '',
save: ''
}, options);
return $.each(this, function() {
$.inlineEdit(this, options);
});
}
$.inlineEdit = function(object, options) {
// Define self, this is the table cell
var self = $(object);
// Register the container with the setting value
self.valueContainer = self.children('.value');
// Get the initial value
self.value = $.trim(self.valueContainer.text()) || options.value;
// Get the component and key for the setting
var parts = self.valueContainer.attr('id').split(':');
self.settingKey = parts.pop();
self.settingComponent = parts.pop();
/**
* Save function. Executes an AJAX function to save the setting
* if it changed.
* @param newValue
*/
self.save = function(newValue) {
var oldValue = self.value;
// Save new value
self.value = newValue;
// Reset the input
self.reset();
// Only save if new value was different from the old value
if (newValue != oldValue) {
self.removeClass('editing')
.removeClass(options.successClass)
.removeClass(options.errorClass)
.addClass(options.savingClass);
var settingData = {
'component': self.settingComponent,
'settingKey': self.settingKey,
'value': self.value
};
$.ajax({
url: '<?= $this->baseUrl('/fizzy/settings/update'); ?>',
type: 'POST',
processData: false,
data: JSON.stringify(settingData),
contentType: 'application/json',
error: function(data, textStatus, XMLHttpRequest) {
+ self.value = oldValue;
self.error();
},
success: function(data, textStatus, XMLHttpRequest) {
console.log(data);
self.success();
}
});
}
}
/**
* Renders the success class over the table cell.
* This is called after the ajax callback ended successfully.
*/
self.success = function() {
self.removeClass(options.savingClass)
.addClass(options.successClass);
self.delay(5000).animate({ backgroundColor: "#FFFFFF" }, 2500, function() {
$(this).removeClass(options.successClass).attr('style', '');
});
}
/**
* Renders the error class over the table cell.
* This is called after the ajax callback ended successfully.
*/
self.error = function() {
self.removeClass(options.savingClass)
.addClass(options.errorClass);
self.delay(5000).animate({ backgroundColor: "#FFFFFF" }, 2500, function() {
$(this).removeClass(options.errorClass).attr('style', '');
});
}
/**
* Reset the table cell
*/
self.reset = function() {
self.removeClass('editing').addClass('editable');
self.valueContainer.removeClass('form').addClass('value');
self.valueContainer.html(self.value);
}
/**
* Update the table cell class on hover
*/
self.hover(function() {
if (!self.hasClass('editing') && !self.hasClass(options.savingClass)) {
self.addClass(options.hoverClass);
}
}, function() {
self.removeClass(options.hoverClass);
});
/**
* OnClick convert the value container to a form.
*/
self.click(function(event) {
var target = $(event.target);
self.removeClass(options.hoverClass);
if (target.is(self[0].tagName) || target.parent().is(self[0].tagName)) {
if (null != $.inlineEdit.lastOpened) {
$.inlineEdit.lastOpened.reset();
}
$.inlineEdit.lastOpened = self;
self.removeClass('editable').addClass('editing');
self.valueContainer.removeClass('value').addClass('form');
// Input field
var tinput = $(document.createElement('input'))
.attr('type', 'text')
.val(self.value);
// Save button
var saveBtn = $(document.createElement('button'))
.attr('id', 'editable-save')
.html('Save')
.click(function() {
self.save($(this).parent().find('input').val());
});
// Cancel button
var cancelBtn = $(document.createElement('button'))
.attr('id', 'editable-cancel')
.html('Cancel')
.click(function() {
self.reset();
});
// Replace container contents
self.valueContainer.html(tinput)
.append(saveBtn)
.append(cancelBtn)
.find('input')
.focus();
}
});
}
$.inlineEdit.lastOpened = null;
})(jQuery);
$(document).ready(function() {
$('.editable').inlineEdit();
});
</script>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
</div>
\ No newline at end of file
|
jtietema/Fizzy
|
ee1a04ff30da615dae7b1b5e102247817df7f5d9
|
Added a getValue method to the Setting API
|
diff --git a/application/models/Setting.php b/application/models/Setting.php
index 34643ee..0ebe0a9 100644
--- a/application/models/Setting.php
+++ b/application/models/Setting.php
@@ -1,76 +1,93 @@
<?php
/**
* Setting
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Setting extends BaseSetting
{
public static $_settings = null;
public static function getAll($reload = false)
{
if (null === self::$_settings || $reload) {
$settings = array();
foreach (Doctrine_Core::getTable('Setting')->findAll() as $setting) {
if (!isset($settings[$setting->component])) {
$settings[$setting->component] = array();
}
$settings[$setting->component][$setting->setting_key] = $setting;
}
self::$_settings = $settings;
}
return self::$_settings;
}
/**
* Returns one or more settings for a given key. When no component is specified
* an array with settings will be returned.
* @param string $key
* @param string $component
* @param boolean $reload
* @return string|array
*/
public static function getKey($key, $component = null, $reload = false)
{
$settings = self::getAll($reload);
if (null === $component) {
$matched = array();
foreach ($settings as $componentSettings) {
foreach ($componentSettings as $setting) {
if ($key === $setting->setting_key) {
$matched[] = $setting;
}
}
}
return $matched;
}
else {
if (!isset($settings[$component]) || empty($settings[$component])) {
return null;
}
return isset($settings[$component][$key]) ? $settings[$component][$key] : null;
}
return null;
}
+ /**
+ * Get the value for a settings key.
+ * @param string $key
+ * @param string $component
+ * @param boolean $reload
+ */
+ public static function getValue($key, $component, $reload = false)
+ {
+ $setting = self::getKey($key, $component, $reload);
+
+ if (null === $setting) {
+ return null;
+ }
+
+ return $setting->value;
+ }
+
public function isNew()
{
return empty($this->id);
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
309534d6a9aeba1a390ca5c9973dc3e72452fd16
|
Settings screen
|
diff --git a/.gitignore b/.gitignore
index 0529423..d87ef07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
configs/fizzy.ini
data/*.xml
data/docs
*.swp
application/assets/images/mimetypes/gion
application/assets/images/mimetypes/humanity
application/assets/images/mimetypes/micho
public/uploads/*
+.DS_Store
+._*
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index 75664d3..575a8d9 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,494 +1,487 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
-.hover-edit {
- background-color: #FFF6C1;
- background-image: url('../images/icon/pencil-small.png');
- background-repeat: no-repeat;
- background-position: right;
-}
-
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
\ No newline at end of file
diff --git a/application/assets/css/tables.css b/application/assets/css/tables.css
index a9bd7b3..4034689 100644
--- a/application/assets/css/tables.css
+++ b/application/assets/css/tables.css
@@ -1,164 +1,194 @@
/**
* Fizzy Tables stylesheet for theme 2.0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* DATA TABLE */
table.data {
width: 100%;
}
table.data td, table.data th {
padding: 0.4em;
}
table.data thead tr {
-moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
}
table.data thead td, table.data thead th {
font-weight: bold;
text-shadow: 2px 1px 0px #CCCCCC;
background-color: #E4E4E4;
border-bottom: 1px solid #ADADAD;
}
table.data tbody > tr:first-child td {
padding: 0.8em 0.4em 0.4em 0.4em;
}
table.data tbody tr:hover {
background-color: #F9F9F9;
}
table.data tbody td {
border-collapse: collapse;
border: 1px solid #EFEFEF;
}
table.data tbody tr.even td {
background-color: #F9F9F9;
}
table.data tbody tr.odd td {
}
table.data tbody td.controls {
width: 25px;
text-align: center;
}
/* DATA TABLE */
/* ********************** */
/* ********************** */
/* DETAILS TABLE */
table.details {
width: 100%;
border-bottom: 1px solid #555555;
}
table.details thead th {
padding: 0.5em 1em;
background-color: #E4E4E4;
border: 1px solid #555555;
font-size: 120%;
font-weight: bold;
-moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
}
table.details tbody th {
padding: 0.4em;
}
table.details tbody td.label, table.details tbody th {
width: 8em;
background-color: #DDDDDD;
border: 1px solid #555555;
font-weight: bold;
}
table.details tbody td, table.details tbody td.content {
background-color: #ECEEEC;
padding: 0.4em 0.8em;
border-right: 1px solid #555555;
}
table.details tr.odd td {}
table.details tr.even td {
background-color: #E1E1E1;
}
/* DETAILS TABLE */
/* ********************** */
/* ********************** */
/* MEDIA TABLE */
table.media {
width: 100%;
}
table.media td {
padding: 0.4em;
}
table.media tbody tr.even td {
background-color: #DDDDDD;
}
table.media tbody tr.odd td {}
table.media tbody td {
padding: 0.6em 0.4em;
border-bottom: 1px solid #EFEFEF;
}
table.media td.controls {
width: 25px;
text-align: center;
}
table.media td.size {
width: 100px;
}
/* MEDIA TABLE */
/* ********************** */
/* ********************** */
/* SETTINGS TABLE */
table.settings {
width: 100%;
}
table.settings th, table.settings td {
padding: 0.4em;
}
table.settings tbody th {
- -moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
- -webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
+ -moz-box-shadow: 0;
+ -webkit-box-shadow: 0;
font-weight: bold;
text-shadow: 2px 1px 0px #CCCCCC;
background-color: #E4E4E4;
border-bottom: 1px solid #ADADAD;
}
table.settings tbody td {
border-collapse: collapse;
border: 1px solid #EFEFEF;
}
table.settings tbody td.label {
width: 200px;
vertical-align: top;
}
+table.settings tbody td.setting { padding-left: 24px; }
+table.settings tbody td .value { padding: 4px 0px; }
+table.settings tbody td .form {}
+
+.hover-edit {
+ background-color: #FFF6C1;
+ background-image: url('../images/icon/pencil-small.png');
+ background-repeat: no-repeat;
+ background-position: 4px center;
+}
+
+.saving {
+ color: #CCCCCC;
+ background-image: url('../images/spinner.gif');
+ background-repeat: no-repeat;
+ background-position: 4px center;
+}
+
+.settings-success {
+ background-color: #2CE23D;
+ background-image: url('../images/icon/tick-circle.png');
+ background-repeat: no-repeat;
+ background-position: 4px center;
+}
+.settings-error {
+ background-color: #E22C33;
+ background-image: url('../images/icon/cross-circle.png');
+ background-repeat: no-repeat;
+ background-position: 4px center;
+}
/* SETTINGS TABLE */
/* ********************** */
\ No newline at end of file
diff --git a/application/assets/images/spinner.gif b/application/assets/images/spinner.gif
new file mode 100644
index 0000000..e83a165
Binary files /dev/null and b/application/assets/images/spinner.gif differ
diff --git a/application/modules/admin/controllers/SettingsController.php b/application/modules/admin/controllers/SettingsController.php
index 964215c..3696baa 100644
--- a/application/modules/admin/controllers/SettingsController.php
+++ b/application/modules/admin/controllers/SettingsController.php
@@ -1,38 +1,91 @@
<?php
/**
* Class Admin_SettingsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_SettingsController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_SettingsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$settings = Setting::getAll();
$this->view->settings = $settings;
}
+
+ /**
+ * Update setting action called through an ajax request
+ */
+ public function ajaxUpdateAction()
+ {
+ // Disable view & layout output
+ $this->_disableDisplay();
+ // Alwasy set response type to json
+ $this->_response->setHeader('Content-Type', 'application/json', true);
+
+ // Try to get the data from the request body
+ try {
+ $data = Zend_Json::decode($this->_request->getRawBody(), Zend_Json::TYPE_OBJECT);
+ } catch(Zend_Json_Exception $exception) {
+ $this->_response->setHttpResponseCode(500);
+ $this->_response->setBody(Zend_Json::encode(array(
+ 'status' => 'error',
+ 'message' => 'data decoding failed'
+ )));
+ return;
+ }
+
+ // Retrieve the setting
+ $setting = Setting::getKey($data->settingKey, $data->component);
+ if (null === $setting) {
+ $this->_response->setHttpResponseCode(404);
+ $this->_response->setBody(Zend_Json::encode(array(
+ 'status' => 'error',
+ 'message' => 'setting key/component pair not found'
+ )));
+ return;
+ }
+
+ // Update the setting
+ $setting->value = $data->value;
+ $success = $setting->trySave();
+ if (false === $success) {
+ $this->_response->setHttpResponseCode(500);
+ $this->_response->setBody(Zend_Json::encode(array(
+ 'status' => 'error',
+ 'message' => 'saving failed due to validation errors'
+ )));
+ return;
+ }
+
+ // Return success response
+ $this->_response->setHttpResponseCode(200);
+ $this->_response->setBody(Zend_Json::encode(array(
+ 'status' => 'success',
+ 'message' => 'setting saved'
+ )));
+ }
}
\ No newline at end of file
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 043e04e..413dc38 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,77 +1,77 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
- <?= $this->jQuery()->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
+ <?= $this->jQuery()->setVersion('1.4.2')->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<div id="main-panel">
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
Fizzy <?= Fizzy_Version::VERSION ?>
running on
Zend Framework <?= Zend_Version::VERSION ?>
and
Doctrine <?= Doctrine::VERSION ?>
|
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a><br />
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/settings/index.phtml b/application/modules/admin/views/scripts/settings/index.phtml
index 23e0ff2..c27bf58 100644
--- a/application/modules/admin/views/scripts/settings/index.phtml
+++ b/application/modules/admin/views/scripts/settings/index.phtml
@@ -1,132 +1,200 @@
<div id="content-panel">
<h2>
<?= $this->image('/fizzy_assets/images/icon/gear.png', array('alt' => 'Settings Icon')); ?>
Settings
</h2>
<table class="settings" id="settings-table">
<tbody>
<?php foreach($this->settings as $component => $settings) : ?>
<tr>
<th colspan="2"><?= ucfirst($component); ?></th>
</tr>
<?php foreach($settings as $setting) : ?>
<tr>
<td class="label">
<?= $setting->label; ?>
</td>
- <td>
- <div id="<?= $setting->setting_key; ?>" class="editable text"><?= $setting->value; ?></div>
+ <td class="setting editable">
+ <div id="<?= $setting->component; ?>:<?= $setting->setting_key; ?>" class="value text"><?= $setting->value; ?></div>
<small><?= $setting->description; ?></small>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
+ <?php $this->jQuery()->uiEnable(); ?>
<script type="text/javascript">
(function($) {
$.fn.inlineEdit = function(options) {
options = $.extend({
hoverClass: 'hover-edit',
+ savingClass: 'saving',
+ successClass: 'settings-success',
+ errorClass: 'settings-error',
value: '',
save: ''
}, options);
return $.each(this, function() {
$.inlineEdit(this, options);
});
}
$.inlineEdit = function(object, options) {
- // Define self
+ // Define self, this is the table cell
var self = $(object);
-
- // create a value property to keep track of current value
- self.value = $.trim(self.text()) || options.value;
- self.settingKey = self.attr('id');
- self.settingType = self.hasClass('boolean') ? 'boolean' : 'text';
+ // Register the container with the setting value
+ self.valueContainer = self.children('.value');
+ // Get the initial value
+ self.value = $.trim(self.valueContainer.text()) || options.value;
+
+ // Get the component and key for the setting
+ var parts = self.valueContainer.attr('id').split(':');
+ self.settingKey = parts.pop();
+ self.settingComponent = parts.pop();
+ /**
+ * Save function. Executes an AJAX function to save the setting
+ * if it changed.
+ * @param newValue
+ */
self.save = function(newValue) {
var oldValue = self.value;
// Save new value
self.value = newValue;
// Reset the input
- self.html(self.value);
+ self.reset();
// Only save if new value was different from the old value
if (newValue != oldValue) {
- window.location = 'http://www.fizzy.dev/fizzy/settings/save/' + escape(self.settingKey) + '/' + self.value;
+ self.removeClass('editing')
+ .removeClass(options.successClass)
+ .removeClass(options.errorClass)
+ .addClass(options.savingClass);
+ var settingData = {
+ 'component': self.settingComponent,
+ 'settingKey': self.settingKey,
+ 'value': self.value
+ };
+ $.ajax({
+ url: '<?= $this->baseUrl('/fizzy/settings/update'); ?>',
+ type: 'POST',
+ processData: false,
+ data: JSON.stringify(settingData),
+ contentType: 'application/json',
+ error: function(data, textStatus, XMLHttpRequest) {
+ self.error();
+ },
+ success: function(data, textStatus, XMLHttpRequest) {
+ console.log(data);
+ self.success();
+ }
+ });
}
}
+ /**
+ * Renders the success class over the table cell.
+ * This is called after the ajax callback ended successfully.
+ */
+ self.success = function() {
+ self.removeClass(options.savingClass)
+ .addClass(options.successClass);
+
+ self.delay(5000).animate({ backgroundColor: "#FFFFFF" }, 2500, function() {
+ $(this).removeClass(options.successClass).attr('style', '');
+ });
+
+ }
+
+ /**
+ * Renders the error class over the table cell.
+ * This is called after the ajax callback ended successfully.
+ */
+ self.error = function() {
+ self.removeClass(options.savingClass)
+ .addClass(options.errorClass);
+ self.delay(5000).animate({ backgroundColor: "#FFFFFF" }, 2500, function() {
+ $(this).removeClass(options.errorClass).attr('style', '');
+ });
+ }
+
+ /**
+ * Reset the table cell
+ */
self.reset = function() {
- self.html(self.value);
+ self.removeClass('editing').addClass('editable');
+ self.valueContainer.removeClass('form').addClass('value');
+ self.valueContainer.html(self.value);
}
+ /**
+ * Update the table cell class on hover
+ */
self.hover(function() {
- if (0 == self.children().size()) {
- self.parent().addClass(options.hoverClass);
+ if (!self.hasClass('editing') && !self.hasClass(options.savingClass)) {
+ self.addClass(options.hoverClass);
}
}, function() {
- self.parent().removeClass(options.hoverClass);
- })
- .click(function(event) {
- var $this = $(event.target);
- $this.parent().removeClass(options.hoverClass);
-
- self.parent().blur(function() {
- console.log('resetting');
- //self.reset();
- });
-
- if ($this.is(self[0].tagName)) {
+ self.removeClass(options.hoverClass);
+ });
+ /**
+ * OnClick convert the value container to a form.
+ */
+ self.click(function(event) {
+ var target = $(event.target);
+ self.removeClass(options.hoverClass);
+
+ if (target.is(self[0].tagName) || target.parent().is(self[0].tagName)) {
if (null != $.inlineEdit.lastOpened) {
$.inlineEdit.lastOpened.reset();
}
$.inlineEdit.lastOpened = self;
+ self.removeClass('editable').addClass('editing');
+ self.valueContainer.removeClass('value').addClass('form');
+ // Input field
var tinput = $(document.createElement('input'))
.attr('type', 'text')
.val(self.value);
-
+ // Save button
var saveBtn = $(document.createElement('button'))
.attr('id', 'editable-save')
.html('Save')
.click(function() {
- console.log('Saving');
self.save($(this).parent().find('input').val());
});
+ // Cancel button
var cancelBtn = $(document.createElement('button'))
.attr('id', 'editable-cancel')
.html('Cancel')
.click(function() {
- console.log('Canceling');
self.reset();
});
// Replace container contents
- self.html(tinput)
+ self.valueContainer.html(tinput)
.append(saveBtn)
.append(cancelBtn)
.find('input')
.focus();
}
});
}
$.inlineEdit.lastOpened = null;
})(jQuery);
$(document).ready(function() {
$('.editable').inlineEdit();
});
</script>
</div>
<div id="sidebar-panel">
-
<h2>Actions</h2>
</div>
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index 60c003b..fe3aaf2 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,147 +1,152 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/{backend}/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/{backend}/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/{backend}/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/{backend}/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
admin_blog_post_delete.route = "/{backend}/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
admin_pages.route = "/{backend}/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/{backend}/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/{backend}/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/{backend}/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/{backend}/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/{backend}/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/{backend}/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/{backend}/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin contact
admin_contact.route = "/{backend}/contact"
admin_contact.defaults.module = "admin"
admin_contact.defaults.controller = "contact"
admin_contact.defaults.action = "index"
admin_contact_show.route = "/{backend}/contact/show/:id"
admin_contact_show.defaults.module = "admin"
admin_contact_show.defaults.controller = "contact"
admin_contact_show.defaults.action = "show"
admin_contact_delete.route = "/{backend}/contact/delete/:id"
admin_contact_delete.defaults.module = "admin"
admin_contact_delete.defaults.controller = "contact"
admin_contact_delete.defaults.action = "delete"
;; Admin users
admin_users.route = "/{backend}/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/{backend}/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/{backend}/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/{backend}/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin settings
admin_settings.route = "/{backend}/settings"
admin_settings.defaults.module = "admin"
admin_settings.defaults.controller = "settings"
admin_settings.defaults.action = "index"
+admin_settings_update.route = "/{backend}/settings/update"
+admin_settings_update.defaults.module = "admin"
+admin_settings_update.defaults.controller = "settings"
+admin_settings_update.defaults.action = "ajax-update"
+
;; Admin WebDAV
-admin_configuration.route = "/{backend}/webdav/*"
-admin_configuration.defaults.module = "admin"
-admin_configuration.defaults.controller = "webdav"
-admin_configuration.defaults.action = "request"
+admin_webdav.route = "/{backend}/webdav/*"
+admin_webdav.defaults.module = "admin"
+admin_webdav.defaults.controller = "webdav"
+admin_webdav.defaults.action = "request"
;; Auth section
admin_login.route = "/{backend}/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/{backend}/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/{backend}"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
|
jtietema/Fizzy
|
e49af446e989fbd499a5286d50897acbe5455603
|
fixed old viewhelper in pages viewscripts
|
diff --git a/application/modules/admin/views/scripts/pages/form.phtml b/application/modules/admin/views/scripts/pages/form.phtml
index c389f26..a25dce2 100644
--- a/application/modules/admin/views/scripts/pages/form.phtml
+++ b/application/modules/admin/views/scripts/pages/form.phtml
@@ -1,68 +1,68 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
- <?= $this->img('/fizzy_assets/images/icon/document.png'); ?>
+ <?= $this->image('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->page->isNew()) ? 'Add page' : 'Edit page'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->slug; ?>
<?= $this->form->body; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->page->isNew()) : ?>
<li class="no-bg right">
<?= $this->link(
'/fizzy/pages/delete/' . $this->page->id,
$this->image('fizzy_assets/images/icon/document--minus.png') . ' delete page',
array(
'class' => 'delete',
'confirm' => 'Are you sure you want to delete this page?',
'escape' => false
)
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/pages',
$this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to pages',
array('escape' => false)
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
<?= $this->form->template; ?>
<?= $this->form->layout; ?>
<div class="form-row" id="homepage-row">
<label for="homepage">Homepage</label>
<?= $this->form->homepage->setDecorators(array('ViewHelper', 'Errors')); ?>
<?= $this->form->homepage->getDescription(); ?>
</div>
</div>
</div>
</form>
|
jtietema/Fizzy
|
cae2cadf4a046993f3c62170686255466f256e05
|
better navigation in comments module
|
diff --git a/application/models/Comments.php b/application/models/Comments.php
index def2929..ab5e47e 100644
--- a/application/models/Comments.php
+++ b/application/models/Comments.php
@@ -1,77 +1,77 @@
<?php
/**
* Comments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Comments extends BaseComments
{
public function isNew()
{
return empty($this->id);
}
/**
* Returns the model where the comments are attached to.
* It uses the post_id field, which follows the convention <type>:<id>
* The type references a model in the config and the id, well an id.
*
* @return Doctrine_Record|null
*/
public function getThreadModel()
{
if (false === strpos($this->post_id, ':')){
return null;
}
list($type, $id) = explode(':', $this->post_id);
$types = Fizzy_Types::getInstance();
if (!$types->hasType($type) && null === $types->getTypeModel($type)){
return null;
}
$modelName = $types->getTypeModel($type);
$query = Doctrine_Query::create()->from($modelName)
->where('id = ?', $id);
$model = $query->fetchOne();
return $model;
}
public function getNumberTopicComments()
{
$query = Doctrine_Query::create()->from('Comments')
- ->where('post_id = ?', $this->post_id);
+ ->where('post_id = ?', $this->post_id)->andWhere('spam = 0');
return $query->count();
}
public function isSpam()
{
return (boolean) $this->spam;
}
public function verifyIsSpam()
{
$fizzySpam = new Fizzy_Spam();
$fizzySpam->isSpam($this->getSpamDocument());
}
public function getSpamDocument()
{
return new Fizzy_Spam_Document(
$this->body,
$this->name,
$this->email,
$this->website,
$this->ip,
$this->user_agent,
$this->referrer
);
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index 6c9f3e8..5a84780 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,303 +1,303 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
$this->view->totalComments = $query->count();
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
$this->view->spamComments = $spamQuery->count();
$this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
$topics = $query->execute();
$this->view->topics = $topics;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
- ->where('post_id = ?', $id)->where('spam = 0')->orderBy('id DESC');
+ ->where('post_id = ?', $id)->andWhere('spam = 0')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$tempModel = $query->fetchOne();
$this->view->threadModel = $tempModel->getThreadModel();
$this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
}
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index abc2662..e6c4f2f 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,200 +1,233 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
// Comments
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Comments',
'route' => 'admin_comments',
'module' => 'admin',
'controller' => 'comments',
'action' => 'index',
- 'pages' => array()
+ 'pages' => array(
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Thread list',
+ 'route' => 'admin_comments_list',
+ 'module' => 'admin',
+ 'controller' => 'comments',
+ 'action' => 'list',
+ 'pages' => array(
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Show thread',
+ 'route' => 'admin_comments_topic',
+ 'module' => 'admin',
+ 'controller' => 'comments',
+ 'action' => 'topic',
+ 'pages' => array()
+ ))
+ )
+ )),
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Spambox',
+ 'route' => 'admin_comments_spambox',
+ 'module' => 'admin',
+ 'controller' => 'comments',
+ 'action' => 'spambox',
+ 'pages' => array()
+ )),
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Edit comment',
+ 'route' => 'admin_comments_edit',
+ 'module' => 'admin',
+ 'controller' => 'comments',
+ 'action' => 'edit'
+ ))
+ )
));
// Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
// Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
// Settings
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Settings',
'route' => 'admin_settings',
'module' => 'admin',
'controller' => 'settings',
'action' => 'index',
'pages' => array ()
));
// Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
|
jtietema/Fizzy
|
273de6029d887e87a2fcb0ec49665c3532423ea4
|
fixed usage of old view helpers
|
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index 4b24dbf..6c9f3e8 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,303 +1,303 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
$this->view->totalComments = $query->count();
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
$this->view->spamComments = $spamQuery->count();
$this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
$topics = $query->execute();
$this->view->topics = $topics;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
- ->where('post_id = ?', $id)->orderBy('id DESC');
+ ->where('post_id = ?', $id)->where('spam = 0')->orderBy('id DESC');
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$tempModel = $query->fetchOne();
$this->view->threadModel = $tempModel->getThreadModel();
$this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
case 'spambox':
$this->_redirect('/fizzy/comments/spam');
break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
$pageNumber = $this->_getParam('page', 1);
$query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->paginator = $paginator;
}
}
diff --git a/application/modules/admin/views/scripts/comments/edit.phtml b/application/modules/admin/views/scripts/comments/edit.phtml
index c84327f..2b8045f 100644
--- a/application/modules/admin/views/scripts/comments/edit.phtml
+++ b/application/modules/admin/views/scripts/comments/edit.phtml
@@ -1,48 +1,54 @@
<form action="<?= $this->form->getAction(); ?>" method="post">
<div id="content-panel">
<h2>
Edit Comment
</h2>
<div class="form-panel">
<?= $this->form->name; ?>
<?= $this->form->email; ?>
<?= $this->form->website; ?>
<?= $this->form->body; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<li class="no-bg right">
- <?= $this->linkConfirm(
+ <?= $this->link(
'/fizzy/comment/delete/' . $this->comment->id,
- $this->img('fizzy_assets/images/icon/document--minus.png') . ' delete comment',
- 'Are you sure you want to delete this comment?',
- array('class' => 'delete')
+ $this->image('fizzy_assets/images/icon/document--minus.png') . ' delete comment',
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this comment?',
+ 'escape' => false
+ )
); ?>
</li>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/comments/topic/' . $this->comment->post_id,
- $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to comments'
+ $this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to comments',
+ array(
+ 'escape' => false
+ )
); ?>
</li>
</ul>
</div>
</form>
diff --git a/application/modules/admin/views/scripts/comments/index.phtml b/application/modules/admin/views/scripts/comments/index.phtml
index 5fad422..9f4d9a9 100644
--- a/application/modules/admin/views/scripts/comments/index.phtml
+++ b/application/modules/admin/views/scripts/comments/index.phtml
@@ -1,64 +1,66 @@
<div id="content-panel">
<h2>Comments overview</h2>
<table class="data" style="width: 400px;">
<tbody>
<tr>
<td><a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Total comments</a></td>
<td><?= $this->totalComments ?></td>
</tr>
<tr>
<td><a href="<?= $this->baseUrl('/fizzy/comments/spam') ?>">Spam</a></td>
<td><?= $this->spamComments ?></td>
</tr>
</tbody>
</table>
<br>
<h2>Latest comments</h2>
<?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
From <?= $comment->name ?>
</div>
<div class="comment-body">
<?= $comment->body ?>
</div>
<div class="actions">
<ul>
<li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=dashboard') ?>">Edit</a></li>
<li>
<?php if ($comment->isSpam()) : ?>
<a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=dashboard') ?>">Not spam</a>
<?php else: ?>
<a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=dashboard') ?>">Spam</a>
<?php endif; ?>
</li>
- <li><?= $this->linkConfirm(
+ <li><?= $this->link(
'/fizzy/comment/delete/' . $comment->id . '?back=dashboard',
'Delete',
- 'Are you sure you want to delete this comment?',
- array('class' => 'delete')
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this comment?',
+ )
); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/spambox.phtml b/application/modules/admin/views/scripts/comments/spambox.phtml
index 9cdf4fd..e60ef04 100644
--- a/application/modules/admin/views/scripts/comments/spambox.phtml
+++ b/application/modules/admin/views/scripts/comments/spambox.phtml
@@ -1,46 +1,48 @@
<div id="content-panel">
<h2>Spambox</h2>
<?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
From <?= $comment->name ?>
</div>
<div class="comment-body">
<?= $comment->body ?>
</div>
<div class="actions">
<ul>
<li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=spambox') ?>">Edit</a></li>
<li>
<?php if ($comment->isSpam()) : ?>
<a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=spambox') ?>">Not spam</a>
<?php else: ?>
<a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=spambox') ?>">Spam</a>
<?php endif; ?>
</li>
- <li><?= $this->linkConfirm(
+ <li><?= $this->link(
'/fizzy/comment/delete/' . $comment->id . '?back=spambox',
'Delete',
- 'Are you sure you want to delete this comment?',
- array('class' => 'delete')
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this comment?',
+ )
); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
</div>
diff --git a/application/modules/admin/views/scripts/comments/topic.phtml b/application/modules/admin/views/scripts/comments/topic.phtml
index 8b609bf..c55935e 100644
--- a/application/modules/admin/views/scripts/comments/topic.phtml
+++ b/application/modules/admin/views/scripts/comments/topic.phtml
@@ -1,46 +1,48 @@
<div id="content-panel">
<h2><?= $this->threadModel->label() ?></h2>
<?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
From <?= $comment->name ?>
</div>
<div class="comment-body">
<?= $comment->body ?>
</div>
<div class="actions">
<ul>
<li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=topic') ?>">Edit</a></li>
<li>
<?php if ($comment->isSpam()) : ?>
<a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=topic') ?>">Not spam</a>
<?php else: ?>
<a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=topic') ?>">Spam</a>
<?php endif; ?>
</li>
- <li><?= $this->linkConfirm(
+ <li><?= $this->link(
'/fizzy/comment/delete/' . $comment->id . '?back=topic',
'Delete',
- 'Are you sure you want to delete this comment?',
- array('class' => 'delete')
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this comment?',
+ )
); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
<?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
<div id="sidebar-panel">
</div>
\ No newline at end of file
|
jtietema/Fizzy
|
4dda7628023ad72235347ca33c109d708b8cb9be
|
Blog & Comments WIP
|
diff --git a/application/models/generated/BaseComments.php b/application/models/generated/BaseComments.php
index 84bb67f..c1bcfe4 100644
--- a/application/models/generated/BaseComments.php
+++ b/application/models/generated/BaseComments.php
@@ -1,92 +1,93 @@
<?php
/**
* BaseComments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $post_id
* @property string $body
* @property string $name
* @property string $email
* @property string $website
* @property timestamp $date
* @property boolean $spam
* @property boolean $approved
* @property string $ip
* @property string $user_agent
* @property string $referrer
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseComments extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('comments');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('post_id', 'string', 100, array(
'type' => 'string',
'length' => '100',
));
$this->hasColumn('body', 'string', null, array(
'type' => 'string',
));
$this->hasColumn('name', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('email', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('website', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('date', 'timestamp', null, array(
'type' => 'timestamp',
));
$this->hasColumn('spam', 'boolean', null, array(
'type' => 'boolean',
+ 'default' => 0,
));
$this->hasColumn('approved', 'boolean', null, array(
'type' => 'boolean',
));
$this->hasColumn('ip', 'string', 100, array(
'type' => 'string',
'length' => '100',
));
$this->hasColumn('user_agent', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('referrer', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->index('post_id_index', array(
'fields' =>
array(
0 => 'post_id',
),
));
}
public function setUp()
{
parent::setUp();
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
index 08677de..4b24dbf 100644
--- a/application/modules/admin/controllers/CommentsController.php
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -1,269 +1,303 @@
<?php
/**
* Class Admin_CommentsController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Controller class for the moderation panel of comments
*
* @author Jeroen Tietema <[email protected]>
*/
class Admin_CommentsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Dashboard. Shows latest comments and total numbers of comments, spam, etc.
*/
public function indexAction()
{
+ $pageNumber = $this->_getParam('page', 1);
+ $query = Doctrine_Query::create()->from('Comments')->where('spam = 0')->orderBy('id DESC');
+
+ $this->view->totalComments = $query->count();
+
+ $paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setCurrentPageNumber($pageNumber);
+
+ $spamQuery = Doctrine_Query::create()->from('Comments')->where('spam = 1');
+ $this->view->spamComments = $spamQuery->count();
+ $this->view->paginator = $paginator;
}
/**
* List of discussions/topics
*/
public function listAction()
{
$query = Doctrine_Query::create()->from('Comments')
->groupBy('post_id')->orderBy('id DESC');
$topics = $query->execute();
$this->view->topics = $topics;
}
/**
* Shows one discussion/topic/thread.
*/
public function topicAction()
{
$id = $this->_getParam('id', null);
+ $pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('comments/topic-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('post_id = ?', $id)->orderBy('id DESC');
- $comments = $query->execute();
- if (count($comments) < 1){
- return $this->renderScript('comments/topic-not-found.phtml');
- }
- $this->view->threadModel = $comments[0]->getThreadModel();
- $this->view->comments = $comments;
+ $paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setCurrentPageNumber($pageNumber);
+
+ $tempModel = $query->fetchOne();
+ $this->view->threadModel = $tempModel->getThreadModel();
+ $this->view->paginator = $paginator;
}
/**
* Marks given message as spam.
*/
public function spamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = true;
$comment->save();
/**
* @todo pass to the spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
+ case 'spambox':
+ $this->_redirect('/fizzy/comments/spam');
+ break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Unmarks given message as spam.
*/
public function hamAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->spam = false;
$comment->save();
/**
* @todo pass to the Spam backend
*/
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
+ case 'spambox':
+ $this->_redirect('/fizzy/comments/spam');
+ break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Edit the comment.
*/
public function editAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Author name'
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'Author E-mail'
)));
$form->addElement(new Zend_Form_Element_Text('website', array(
'label' => 'Author website'
)));
$form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Comment'
)));
$form->addElement(new Zend_Form_Element_Submit('save', array(
'label' => 'Save'
)));
if ($this->_request->isPost() && $form->isValid($_POST)){
$comment->name = $form->name->getValue();
$comment->email = $form->email->getValue();
$comment->website = $form->website->getValue();
$comment->body = $form->body->getValue();
$comment->save();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
+ case 'spambox':
+ $this->_redirect('/fizzy/comments/spam');
+ break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
$form->name->setValue($comment->name);
$form->email->setValue($comment->email);
$form->website->setValue($comment->website);
$form->body->setValue($comment->body);
$this->view->form = $form;
$this->view->comment = $comment;
$this->view->back = $redirect;
}
/**
* Delete the comment.
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
$redirect = $this->_getParam('back', 'dashboard');
if (null === $id){
return $this->renderScript('comments/comment-not-found.phtml');
}
$query = Doctrine_Query::create()->from('Comments')
->where('id = ?', $id);
$comment = $query->fetchOne();
if (null == $comment){
return $this->renderScript('comments/comment-not-found.phtml');
}
$comment->delete();
switch($redirect){
case 'topic':
$this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
break;
+ case 'spambox':
+ $this->_redirect('/fizzy/comments/spam');
+ break;
default:
$this->_redirect('/fizzy/comments');
break;
}
}
/**
* Approve the comment (when using moderation).
*/
public function approveAction()
{
}
/**
* Unapprove the given comment.
*/
public function unapproveAction()
{
}
/**
* Shows the spambox containing all spam comments
*/
public function spamboxAction()
{
+ $pageNumber = $this->_getParam('page', 1);
+ $query = Doctrine_Query::create()->from('Comments')->where('spam = ?', 1);
+
+ $paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setCurrentPageNumber($pageNumber);
+
+ $this->view->paginator = $paginator;
}
}
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 7e839f8..abc2662 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,200 +1,200 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
// Comments
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Comments',
- 'route' => 'admin_comments_list',
+ 'route' => 'admin_comments',
'module' => 'admin',
'controller' => 'comments',
- 'action' => 'list',
+ 'action' => 'index',
'pages' => array()
));
// Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
// Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
// Settings
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Settings',
'route' => 'admin_settings',
'module' => 'admin',
'controller' => 'settings',
'action' => 'index',
'pages' => array ()
));
// Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
diff --git a/application/modules/admin/views/scripts/blogs/_pagination.phtml b/application/modules/admin/views/scripts/_pagination.phtml
similarity index 100%
rename from application/modules/admin/views/scripts/blogs/_pagination.phtml
rename to application/modules/admin/views/scripts/_pagination.phtml
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index 688afe7..a2fa04d 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,56 +1,56 @@
<div id="content-panel">
<h2><?= $this->blog->name ?></h2>
<div>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Date</td>
<td>Status</td>
<td>Author</td>
</tr>
</thead>
<tbody>
<?php $items = $this->paginator->getCurrentItems();
foreach ($items as $post): ?>
<tr>
<td class="controls">
<?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
</td>
<td>
<?= $post->title ?>
</td>
<td>
<?= $post->date ?>
</td>
<td>
<?php if ($post->status == Post::PUBLISHED): ?>
Published
<?php elseif ($post->status == Post::PENDING_REVIEW): ?>
Pending review
<?php else: ?>
Draft
<?php endif; ?>
</td>
<td>
<?= $post->User->displayname ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
- <?= $this->paginationControl($this->paginator, 'All', 'blogs/_pagination.phtml') ?>
+ <?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array()); ?>
</li>
</ul>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/index.phtml b/application/modules/admin/views/scripts/comments/index.phtml
new file mode 100644
index 0000000..5fad422
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/index.phtml
@@ -0,0 +1,64 @@
+<div id="content-panel">
+
+ <h2>Comments overview</h2>
+
+ <table class="data" style="width: 400px;">
+ <tbody>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Total comments</a></td>
+ <td><?= $this->totalComments ?></td>
+ </tr>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/comments/spam') ?>">Spam</a></td>
+ <td><?= $this->spamComments ?></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <br>
+
+ <h2>Latest comments</h2>
+
+ <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
+ <div class="comment">
+ <div class="avatar">
+ <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
+ </div>
+ <div class="content">
+ <div class="author-info">
+ From <?= $comment->name ?>
+ </div>
+ <div class="comment-body">
+ <?= $comment->body ?>
+ </div>
+ <div class="actions">
+ <ul>
+ <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=dashboard') ?>">Edit</a></li>
+ <li>
+ <?php if ($comment->isSpam()) : ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=dashboard') ?>">Not spam</a>
+ <?php else: ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=dashboard') ?>">Spam</a>
+ <?php endif; ?>
+ </li>
+ <li><?= $this->linkConfirm(
+ '/fizzy/comment/delete/' . $comment->id . '?back=dashboard',
+ 'Delete',
+ 'Are you sure you want to delete this comment?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <?php endforeach; ?>
+
+ <?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
+
+</div>
+
+<div id="sidebar-panel">
+
+</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/comments/spambox.phtml b/application/modules/admin/views/scripts/comments/spambox.phtml
new file mode 100644
index 0000000..9cdf4fd
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/spambox.phtml
@@ -0,0 +1,46 @@
+<div id="content-panel">
+ <h2>Spambox</h2>
+
+ <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
+ <div class="comment">
+ <div class="avatar">
+ <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
+ </div>
+ <div class="content">
+ <div class="author-info">
+ From <?= $comment->name ?>
+ </div>
+ <div class="comment-body">
+ <?= $comment->body ?>
+ </div>
+ <div class="actions">
+ <ul>
+ <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=spambox') ?>">Edit</a></li>
+ <li>
+ <?php if ($comment->isSpam()) : ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=spambox') ?>">Not spam</a>
+ <?php else: ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=spambox') ?>">Spam</a>
+ <?php endif; ?>
+ </li>
+ <li><?= $this->linkConfirm(
+ '/fizzy/comment/delete/' . $comment->id . '?back=spambox',
+ 'Delete',
+ 'Are you sure you want to delete this comment?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <?php endforeach; ?>
+
+ <?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
+
+</div>
+
+<div id="sidebar-panel">
+
+</div>
diff --git a/application/modules/admin/views/scripts/comments/topic.phtml b/application/modules/admin/views/scripts/comments/topic.phtml
index e68e866..8b609bf 100644
--- a/application/modules/admin/views/scripts/comments/topic.phtml
+++ b/application/modules/admin/views/scripts/comments/topic.phtml
@@ -1,43 +1,46 @@
<div id="content-panel">
<h2><?= $this->threadModel->label() ?></h2>
- <?php foreach ($this->comments as $comment): ?>
+ <?php foreach ($this->paginator->getCurrentItems() as $comment): ?>
<div class="comment">
<div class="avatar">
<img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
</div>
<div class="content">
<div class="author-info">
From <?= $comment->name ?>
</div>
<div class="comment-body">
- <?= $comment->body ?>
+ <?= $comment->body ?>
</div>
<div class="actions">
<ul>
<li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=topic') ?>">Edit</a></li>
<li>
- <?php if ($comment->isSpam()) : ?>
+ <?php if ($comment->isSpam()) : ?>
<a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=topic') ?>">Not spam</a>
- <?php else: ?>
+ <?php else: ?>
<a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=topic') ?>">Spam</a>
- <?php endif; ?>
+ <?php endif; ?>
</li>
<li><?= $this->linkConfirm(
- '/fizzy/comment/delete/' . $comment->id . '?back=topic',
- 'Delete',
- 'Are you sure you want to delete this comment?',
- array('class' => 'delete')
- ); ?>
+ '/fizzy/comment/delete/' . $comment->id . '?back=topic',
+ 'Delete',
+ 'Are you sure you want to delete this comment?',
+ array('class' => 'delete')
+ ); ?>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php endforeach; ?>
+
+ <?= $this->paginationControl($this->paginator, 'All', '_pagination.phtml') ?>
+
</div>
<div id="sidebar-panel">
</div>
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index fa3dc5d..dd68672 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,177 +1,187 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/fizzy/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/fizzy/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
+admin_comments.route = "/fizzy/comments"
+admin_comments.defaults.action = "index"
+admin_comments.defaults.controller = "comments"
+admin_comments.defaults.module = "admin"
+
admin_comments_list.route = "/fizzy/comments/list"
admin_comments_list.defaults.action = "list"
admin_comments_list.defaults.controller = "comments"
admin_comments_list.defaults.module = "admin"
admin_comments_topic.route = "/fizzy/comments/topic/:id"
admin_comments_topic.defaults.action = "topic"
admin_comments_topic.defaults.controller = "comments"
admin_comments_topic.defaults.module = "admin"
admin_comments_ham.route = "/fizzy/comment/ham/:id"
admin_comments_ham.defaults.action = "ham"
admin_comments_ham.defaults.controller = "comments"
admin_comments_ham.defaults.module = "admin"
admin_comments_spam.route = "/fizzy/comment/spam/:id"
admin_comments_spam.defaults.action = "spam"
admin_comments_spam.defaults.controller = "comments"
admin_comments_spam.defaults.module = "admin"
admin_comments_delete.route = "/fizzy/comment/delete/:id"
admin_comments_delete.defaults.action = "delete"
admin_comments_delete.defaults.controller = "comments"
admin_comments_delete.defaults.module = "admin"
admin_comments_edit.route = "/fizzy/comment/edit/:id"
admin_comments_edit.defaults.action = "edit"
admin_comments_edit.defaults.controller = "comments"
admin_comments_edit.defaults.module = "admin"
+admin_comments_spambox.route = "/fizzy/comments/spam"
+admin_comments_spambox.defaults.action = "spambox"
+admin_comments_spambox.defaults.controller = "comments"
+admin_comments_spambox.defaults.module = "admin"
+
admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin contact
admin_contact.route = "/fizzy/contact"
admin_contact.defaults.module = "admin"
admin_contact.defaults.controller = "contact"
admin_contact.defaults.action = "index"
admin_contact_show.route = "/fizzy/contact/show/:id"
admin_contact_show.defaults.module = "admin"
admin_contact_show.defaults.controller = "contact"
admin_contact_show.defaults.action = "show"
admin_contact_delete.route = "/fizzy/contact/delete/:id"
admin_contact_delete.defaults.module = "admin"
admin_contact_delete.defaults.controller = "contact"
admin_contact_delete.defaults.action = "delete"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin settings
admin_settings.route = "/fizzy/settings"
admin_settings.defaults.module = "admin"
admin_settings.defaults.controller = "settings"
admin_settings.defaults.action = "index"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
diff --git a/configs/types.yml b/configs/types.yml
new file mode 100644
index 0000000..50822cd
--- /dev/null
+++ b/configs/types.yml
@@ -0,0 +1,7 @@
+## YAML Template.
+---
+Types:
+ page:
+ model: Page
+ post:
+ model: Post
\ No newline at end of file
diff --git a/database/fixtures/blogs.yml b/database/fixtures/blogs.yml
index ba49f72..c60c210 100644
--- a/database/fixtures/blogs.yml
+++ b/database/fixtures/blogs.yml
@@ -1,15 +1,38 @@
Blog:
Default:
name: Default Blog
slug: default
group_slug: default
Post:
Test:
title: Test post
body: dit is een test post
date: now
comments: true
status: 2
author: 1
- blog_id: 1
\ No newline at end of file
+ blog_id: 1
+
+Comments:
+ test_comment1:
+ post_id: 'post:1'
+ body: Some random body
+ name: Jeroen
+ email: [email protected]
+ date: 2010-05-20
+ about_comment:
+ post_id: 'page:3'
+ body: Awesome about page
+ name: Jeroen
+ email: [email protected]
+ about_comment2:
+ post_id: 'page:3'
+ body: Awesome about page comment number 2
+ name: Jeroen
+ email: [email protected]
+ about_comment3:
+ post_id: 'page:3'
+ body: Awesome about page comment number 3
+ name: Jeroen
+ email: [email protected]
\ No newline at end of file
diff --git a/database/fixtures/pages.yml b/database/fixtures/pages.yml
index 07287cd..4f7a3ec 100644
--- a/database/fixtures/pages.yml
+++ b/database/fixtures/pages.yml
@@ -1,48 +1,50 @@
Page:
Home:
title: Congratulations
slug: home
body: |
<p>
<img src="/fizzy.git/public/uploads/pastedpic_04222008_234311.png" alt="" width="80" />
</p>
<p>
This is the default layout for <a>Fizzy</a>. You are seeing this page because you did not configure a default layout and template. See the <a href="/fizzy.git/public/fizzy/pages/edit/configuration">Configuration</a> page for more information about configuring Fizzy.
</p>
<p>
If you want to know more about Fizzy, check the <a href="/fizzy.git/public/fizzy/pages/edit/about">About</a> page or visit the <a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">project website</a> by clicking the more link.
</p>
<p>
You can administer your website by going to the <a href="/fizzy.git/public/fizzy/pages/edit/admin">administrator page</a>. There you can change the content of your site and add users. The default username and password for the administrator section is "admin". Please change this to something more appropriate.
</p>
homepage: true
Configuration:
title: Configuration
slug: configuration
body: |
<p>
Configuring Fizzy done in two locations.
</p>
<h2>Configuration file</h2>
<p>
To change the systems configuration the fizzy.xml file in the configs directory under the root of the application can be changed. For a complete list of the configuration options visit the project website.
</p>
<h2>Customized templates & Layouts</h2>
<p>
Fizzy pages can be enriched with templates and layouts. These templates can be selected when adding or editing a page in the administrator section. <br />
</p>
<p>
New templates and layouts can be placed in the custom directory under the application root. For a complete overview of templating and layout options visit the <a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">project website</a>.
</p>
homepage: false
About:
title: About Fizzy
slug: about
body: |
<p>
Fizzy is a lightweight, easy to deploy Content Management System to administer paginated content on a website. The system allows users to create, update and delete content on their site with ease.
</p>
<p>
The dependencies for Fizzy are kept to a minimum, but can be extended by any PHP programmer. In it's most basic form Fizzy does not require a database and stores all its data in <a href="http://en.wikipedia.org/wiki/XML">XML</a> files.
</p>
homepage: false
+
+
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index d769b75..d1ffd54 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,79 +1,81 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
displayname: string(255)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
status: integer(1)
comments: boolean
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
post_id: string(100)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
- spam: boolean
+ spam:
+ type: boolean
+ default: 0
approved: boolean
ip: string(100)
user_agent: string(255)
referrer: string(255)
indexes:
post_id_index:
fields: [post_id]
Setting:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
component: string(50)
setting_key: string(50)
value: string
label: string(255)
description: string
Contact:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
email: string(255)
body: string
date: datetime
\ No newline at end of file
|
jtietema/Fizzy
|
22ff292dce5204117870e06f6a6736a606f682b5
|
Comments module
|
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index afb5a56..23dff2c 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,85 +1,103 @@
<?php
/**
* Class Bootstrap
* @category Fizzy
* @package Fizzy_Bootstrap
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Description of Bootstrap
*
* @author jeroen
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$view->addHelperPath(
realpath(implode(DIRECTORY_SEPARATOR,
array(ROOT_PATH, 'library', 'ZendX', 'JQuery', 'View', 'Helper')
)), 'ZendX_JQuery_View_Helper');
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$this->bootstrap('FrontController');
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getResource('FrontController');
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
protected function _initRoutes()
{
$this->bootstrap('FrontController');
$router = $this->getContainer()->frontcontroller->getRouter();
$config = new Zend_Config_Ini(ROOT_PATH . '/configs/routes.ini');
$router->addConfig($config->{$this->getEnvironment()});
return $router;
}
+ protected function _initTypes()
+ {
+ $config = new ZendL_Config_Yaml(ROOT_PATH . '/configs/types.yml');
+ $types = Fizzy_Types::initialize($config);
+ return $types;
+ }
+
+ /**
+ * @todo make adapter class configurable
+ */
+ protected function _initSpam()
+ {
+ $this->bootstrap('Config');
+ $config = $this->getContainer()->config;
+ $adapter = new Fizzy_Spam_Adapter_Akismet($config->spam->akismetKey, $config->spam->siteUrl);
+ Fizzy_Spam::setDefaultAdapter($adapter);
+ }
+
}
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index 575a8d9..27885b2 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,487 +1,520 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
-/* ********************** */
\ No newline at end of file
+/* ********************** */
+
+/* ********************** */
+/* COMMENTS */
+
+.comment {
+ position: relative;
+ border: solid 1px gray;
+ margin-bottom:10px;
+}
+
+.comment .avatar {
+ float: left;
+ padding: 10px;
+}
+
+.comment .content {
+ float:left;
+ padding: 10px;
+}
+
+.comment .content .author-info {
+ margin-bottom: 5px;
+}
+
+.comment .content .actions {
+ margin-top: 5px;
+}
+
+.comment .content .actions li {
+ display: inline;
+ list-style-type: none;
+ padding-right: 20px;
+}
\ No newline at end of file
diff --git a/application/models/Comments.php b/application/models/Comments.php
index 061a8ca..def2929 100644
--- a/application/models/Comments.php
+++ b/application/models/Comments.php
@@ -1,20 +1,77 @@
<?php
/**
* Comments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Comments extends BaseComments
{
public function isNew()
{
return empty($this->id);
}
+ /**
+ * Returns the model where the comments are attached to.
+ * It uses the post_id field, which follows the convention <type>:<id>
+ * The type references a model in the config and the id, well an id.
+ *
+ * @return Doctrine_Record|null
+ */
+ public function getThreadModel()
+ {
+ if (false === strpos($this->post_id, ':')){
+ return null;
+ }
+ list($type, $id) = explode(':', $this->post_id);
+ $types = Fizzy_Types::getInstance();
+
+ if (!$types->hasType($type) && null === $types->getTypeModel($type)){
+ return null;
+ }
+ $modelName = $types->getTypeModel($type);
+
+ $query = Doctrine_Query::create()->from($modelName)
+ ->where('id = ?', $id);
+ $model = $query->fetchOne();
+ return $model;
+ }
+
+ public function getNumberTopicComments()
+ {
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('post_id = ?', $this->post_id);
+ return $query->count();
+ }
+
+ public function isSpam()
+ {
+ return (boolean) $this->spam;
+ }
+
+ public function verifyIsSpam()
+ {
+ $fizzySpam = new Fizzy_Spam();
+ $fizzySpam->isSpam($this->getSpamDocument());
+ }
+
+ public function getSpamDocument()
+ {
+ return new Fizzy_Spam_Document(
+ $this->body,
+ $this->name,
+ $this->email,
+ $this->website,
+ $this->ip,
+ $this->user_agent,
+ $this->referrer
+ );
+ }
+
}
\ No newline at end of file
diff --git a/application/models/Page.php b/application/models/Page.php
index b3b4e5e..58c5c50 100644
--- a/application/models/Page.php
+++ b/application/models/Page.php
@@ -1,59 +1,64 @@
<?php
/**
* Page
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Page extends BasePage
{
public function getTemplate()
{
if(empty($this->template)) {
$pages = Zend_Registry::get('config')->pages;
$this->template = $pages->defaultTemplate;
}
return $this->template;
}
/**
* Override to return the default layout if none is set.
* @return string
*/
public function getLayout()
{
if(empty($this->layout)) {
$pages = Zend_Registry::get('config')->pages;
$this->layout = $pages->defaultLayout;
}
return $this->layout;
}
public function populate($array)
{
$this->title = $array['title'];
$this->slug = $array['slug'];
$this->body = $array['body'];
$this->homepage = (boolean) $array['homepage'];
if ('default' !== $array['template'])
$this->template = $array['template'];
$this->layout = $array['layout'];
return $this;
}
public function isNew()
{
return empty($this->id);
}
+ public function label()
+ {
+ return $this->title;
+ }
+
}
diff --git a/application/models/Post.php b/application/models/Post.php
index 562cc35..b7a2726 100644
--- a/application/models/Post.php
+++ b/application/models/Post.php
@@ -1,31 +1,36 @@
<?php
/**
* Post
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Post extends BasePost
{
const PUBLISHED = 2;
const PENDING_REVIEW = 1;
const DRAFT = 0;
public function isNew()
{
return empty($this->id);
}
public function comments()
{
$query = Doctrine_Query::create()->from('Comments')
- ->where('post_id = ?', 'blog:'.$this->id)->orderBy('id DESC');
+ ->where('post_id = ?', 'post:'.$this->id)->orderBy('id DESC');
$comments = $query->execute();
return $comments;
}
+
+ public function label()
+ {
+ return $this->title;
+ }
}
\ No newline at end of file
diff --git a/application/models/generated/BaseComments.php b/application/models/generated/BaseComments.php
index d8dc7cf..84bb67f 100644
--- a/application/models/generated/BaseComments.php
+++ b/application/models/generated/BaseComments.php
@@ -1,69 +1,92 @@
<?php
/**
* BaseComments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $post_id
* @property string $body
* @property string $name
* @property string $email
* @property string $website
* @property timestamp $date
+ * @property boolean $spam
+ * @property boolean $approved
+ * @property string $ip
+ * @property string $user_agent
+ * @property string $referrer
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseComments extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('comments');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('post_id', 'string', 100, array(
'type' => 'string',
'length' => '100',
));
$this->hasColumn('body', 'string', null, array(
'type' => 'string',
));
$this->hasColumn('name', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('email', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('website', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('date', 'timestamp', null, array(
'type' => 'timestamp',
));
+ $this->hasColumn('spam', 'boolean', null, array(
+ 'type' => 'boolean',
+ ));
+ $this->hasColumn('approved', 'boolean', null, array(
+ 'type' => 'boolean',
+ ));
+ $this->hasColumn('ip', 'string', 100, array(
+ 'type' => 'string',
+ 'length' => '100',
+ ));
+ $this->hasColumn('user_agent', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('referrer', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
$this->index('post_id_index', array(
'fields' =>
array(
0 => 'post_id',
),
));
}
public function setUp()
{
parent::setUp();
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/CommentsController.php b/application/modules/admin/controllers/CommentsController.php
new file mode 100644
index 0000000..08677de
--- /dev/null
+++ b/application/modules/admin/controllers/CommentsController.php
@@ -0,0 +1,269 @@
+<?php
+/**
+ * Class Admin_CommentsController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Controller class for the moderation panel of comments
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Admin_CommentsController extends Fizzy_SecuredController
+{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
+ /**
+ * Dashboard. Shows latest comments and total numbers of comments, spam, etc.
+ */
+ public function indexAction()
+ {
+
+ }
+
+ /**
+ * List of discussions/topics
+ */
+ public function listAction()
+ {
+ $query = Doctrine_Query::create()->from('Comments')
+ ->groupBy('post_id')->orderBy('id DESC');
+ $topics = $query->execute();
+ $this->view->topics = $topics;
+ }
+
+ /**
+ * Shows one discussion/topic/thread.
+ */
+ public function topicAction()
+ {
+ $id = $this->_getParam('id', null);
+
+ if (null === $id){
+ return $this->renderScript('comments/topic-not-found.phtml');
+ }
+
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('post_id = ?', $id)->orderBy('id DESC');
+ $comments = $query->execute();
+ if (count($comments) < 1){
+ return $this->renderScript('comments/topic-not-found.phtml');
+ }
+
+ $this->view->threadModel = $comments[0]->getThreadModel();
+ $this->view->comments = $comments;
+ }
+
+ /**
+ * Marks given message as spam.
+ */
+ public function spamAction()
+ {
+ $id = $this->_getParam('id', null);
+ $redirect = $this->_getParam('back', 'dashboard');
+
+ if (null === $id){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('id = ?', $id);
+
+ $comment = $query->fetchOne();
+
+ if (null == $comment){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $comment->spam = true;
+ $comment->save();
+ /**
+ * @todo pass to the spam backend
+ */
+
+ switch($redirect){
+ case 'topic':
+ $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
+ break;
+ default:
+ $this->_redirect('/fizzy/comments');
+ break;
+ }
+ }
+
+ /**
+ * Unmarks given message as spam.
+ */
+ public function hamAction()
+ {
+ $id = $this->_getParam('id', null);
+ $redirect = $this->_getParam('back', 'dashboard');
+
+ if (null === $id){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('id = ?', $id);
+
+ $comment = $query->fetchOne();
+
+ if (null == $comment){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $comment->spam = false;
+ $comment->save();
+ /**
+ * @todo pass to the Spam backend
+ */
+
+ switch($redirect){
+ case 'topic':
+ $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
+ break;
+ default:
+ $this->_redirect('/fizzy/comments');
+ break;
+ }
+ }
+
+ /**
+ * Edit the comment.
+ */
+ public function editAction()
+ {
+ $id = $this->_getParam('id', null);
+ $redirect = $this->_getParam('back', 'dashboard');
+
+ if (null === $id){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('id = ?', $id);
+
+ $comment = $query->fetchOne();
+
+ if (null == $comment){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $form = new Zend_Form();
+ $form->setAction($this->view->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=' . $redirect));
+
+ $form->addElement(new Zend_Form_Element_Text('name', array(
+ 'label' => 'Author name'
+ )));
+ $form->addElement(new Zend_Form_Element_Text('email', array(
+ 'label' => 'Author E-mail'
+ )));
+ $form->addElement(new Zend_Form_Element_Text('website', array(
+ 'label' => 'Author website'
+ )));
+ $form->addElement(new Zend_Form_Element_Textarea('body', array(
+ 'label' => 'Comment'
+ )));
+ $form->addElement(new Zend_Form_Element_Submit('save', array(
+ 'label' => 'Save'
+ )));
+
+ if ($this->_request->isPost() && $form->isValid($_POST)){
+ $comment->name = $form->name->getValue();
+ $comment->email = $form->email->getValue();
+ $comment->website = $form->website->getValue();
+ $comment->body = $form->body->getValue();
+ $comment->save();
+
+ switch($redirect){
+ case 'topic':
+ $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
+ break;
+ default:
+ $this->_redirect('/fizzy/comments');
+ break;
+ }
+ }
+
+ $form->name->setValue($comment->name);
+ $form->email->setValue($comment->email);
+ $form->website->setValue($comment->website);
+ $form->body->setValue($comment->body);
+
+ $this->view->form = $form;
+ $this->view->comment = $comment;
+ $this->view->back = $redirect;
+ }
+
+ /**
+ * Delete the comment.
+ */
+ public function deleteAction()
+ {
+ $id = $this->_getParam('id', null);
+ $redirect = $this->_getParam('back', 'dashboard');
+
+ if (null === $id){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('id = ?', $id);
+
+ $comment = $query->fetchOne();
+
+ if (null == $comment){
+ return $this->renderScript('comments/comment-not-found.phtml');
+ }
+
+ $comment->delete();
+
+ switch($redirect){
+ case 'topic':
+ $this->_redirect('/fizzy/comments/topic/' . $comment->post_id);
+ break;
+ default:
+ $this->_redirect('/fizzy/comments');
+ break;
+ }
+ }
+
+ /**
+ * Approve the comment (when using moderation).
+ */
+ public function approveAction()
+ {
+
+ }
+
+ /**
+ * Unapprove the given comment.
+ */
+ public function unapproveAction()
+ {
+
+ }
+
+ /**
+ * Shows the spambox containing all spam comments
+ */
+ public function spamboxAction()
+ {
+
+ }
+}
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 0c220fa..7e839f8 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,190 +1,200 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
+ // Comments
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Comments',
+ 'route' => 'admin_comments_list',
+ 'module' => 'admin',
+ 'controller' => 'comments',
+ 'action' => 'list',
+ 'pages' => array()
+ ));
+
// Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
// Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
// Settings
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Settings',
'route' => 'admin_settings',
'module' => 'admin',
'controller' => 'settings',
'action' => 'index',
'pages' => array ()
));
// Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
diff --git a/application/modules/admin/views/scripts/comments/comment-not-found.phtml b/application/modules/admin/views/scripts/comments/comment-not-found.phtml
new file mode 100644
index 0000000..e303127
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/comment-not-found.phtml
@@ -0,0 +1,2 @@
+<h2>Comment not found.</h2>
+<a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Back to discussion list</a>
diff --git a/application/modules/admin/views/scripts/comments/edit.phtml b/application/modules/admin/views/scripts/comments/edit.phtml
new file mode 100644
index 0000000..c84327f
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/edit.phtml
@@ -0,0 +1,48 @@
+<form action="<?= $this->form->getAction(); ?>" method="post">
+
+<div id="content-panel">
+
+ <h2>
+ Edit Comment
+ </h2>
+
+ <div class="form-panel">
+ <?= $this->form->name; ?>
+ <?= $this->form->email; ?>
+ <?= $this->form->website; ?>
+ <?= $this->form->body; ?>
+ </div>
+</div>
+<div id="sidebar-panel">
+
+ <h2>Actions</h2>
+
+ <ul class="actions">
+ <li class="last">
+ <input type="submit" value="Save" />
+ </li>
+ </ul>
+
+ <hr />
+
+ <ul class="actions">
+ <li class="no-bg right">
+ <?= $this->linkConfirm(
+ '/fizzy/comment/delete/' . $this->comment->id,
+ $this->img('fizzy_assets/images/icon/document--minus.png') . ' delete comment',
+ 'Are you sure you want to delete this comment?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ <li class="no-bg right last">
+ <?= $this->link(
+ '/fizzy/comments/topic/' . $this->comment->post_id,
+ $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to comments'
+ ); ?>
+ </li>
+ </ul>
+
+</div>
+
+</form>
+
diff --git a/application/modules/admin/views/scripts/comments/list.phtml b/application/modules/admin/views/scripts/comments/list.phtml
new file mode 100644
index 0000000..c962bda
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/list.phtml
@@ -0,0 +1,32 @@
+<div id="content-panel">
+
+ <h2>Discussions</h2>
+ <div>
+ <table class="data" id="pages-table">
+ <thead>
+ <tr>
+ <td> </td>
+ <td>Title</td>
+ <td>Number comments</td>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach ($this->topics as $topic): ?>
+ <tr>
+ <td class="controls">
+
+ </td>
+ <td><a href="<?= $this->baseUrl('/fizzy/comments/topic/' . $topic->post_id) ?>"><?= $topic->getThreadModel()->label() ?></a></td>
+ <td><?= $topic->getNumberTopicComments() ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+
+ </div>
+
+</div>
+
+<div id="sidebar-panel">
+
+</div>
diff --git a/application/modules/admin/views/scripts/comments/topic-not-found.phtml b/application/modules/admin/views/scripts/comments/topic-not-found.phtml
new file mode 100644
index 0000000..0bda8ae
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/topic-not-found.phtml
@@ -0,0 +1,2 @@
+<h2>Topic not found.</h2>
+<a href="<?= $this->baseUrl('/fizzy/comments/list') ?>">Back to discussion list</a>
diff --git a/application/modules/admin/views/scripts/comments/topic.phtml b/application/modules/admin/views/scripts/comments/topic.phtml
new file mode 100644
index 0000000..e68e866
--- /dev/null
+++ b/application/modules/admin/views/scripts/comments/topic.phtml
@@ -0,0 +1,43 @@
+<div id="content-panel">
+ <h2><?= $this->threadModel->label() ?></h2>
+
+ <?php foreach ($this->comments as $comment): ?>
+ <div class="comment">
+ <div class="avatar">
+ <img src="http://www.gravatar.com/avatar/<?= md5(trim(strtolower($comment->email))) ?>?s=80" alt="<?= $comment->name ?>" />
+ </div>
+ <div class="content">
+ <div class="author-info">
+ From <?= $comment->name ?>
+ </div>
+ <div class="comment-body">
+ <?= $comment->body ?>
+ </div>
+ <div class="actions">
+ <ul>
+ <li><a href="<?= $this->baseUrl('/fizzy/comment/edit/' . $comment->id . '?back=topic') ?>">Edit</a></li>
+ <li>
+ <?php if ($comment->isSpam()) : ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/ham/' . $comment->id . '?back=topic') ?>">Not spam</a>
+ <?php else: ?>
+ <a href="<?= $this->baseUrl('/fizzy/comment/spam/' . $comment->id . '?back=topic') ?>">Spam</a>
+ <?php endif; ?>
+ </li>
+ <li><?= $this->linkConfirm(
+ '/fizzy/comment/delete/' . $comment->id . '?back=topic',
+ 'Delete',
+ 'Are you sure you want to delete this comment?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <?php endforeach; ?>
+</div>
+
+<div id="sidebar-panel">
+
+</div>
\ No newline at end of file
diff --git a/configs/application.ini b/configs/application.ini
index 5cd0b76..8379c18 100644
--- a/configs/application.ini
+++ b/configs/application.ini
@@ -1,40 +1,43 @@
[production]
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.session.save_path = "/tmp"
autoloaderNamespaces.fizzy = "Fizzy_"
+autoloaderNamespaces.zendl = "ZendL_"
pluginPaths.Fizzy_Resource = APPLICATION_PATH "/../library/Fizzy/Resource/"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
title = "Fizzy"
pages.defaultTemplate = "page.phtml"
pages.defaultLayout = "default"
paths.templatePath = APPLICATION_PATH "/modules/default/views/templates"
paths.layoutPath = APPLICATION_PATH "/modules/default/views/layouts"
contact.email = "[email protected]"
; Doctrine resources
resources.doctrine.manager.attributes.attr_model_loading = model_loading_conservative
resources.doctrine.connections.default.dsn = "mysql://root@localhost/fizzy"
resources.doctrine.paths.models_path = APPLICATION_PATH "/models/"
resources.doctrine.paths.yaml_schema_path = ROOT_PATH "/database/schema/"
resources.doctrine.paths.sql_path = ROOT_PATH "/database/sql/"
resources.doctrine.paths.migrations_path = ROOT_PATH "/database/migrations/"
resources.doctrine.paths.data_fixtures_path = ROOT_PATH "/database/fixtures/"
+spam.akismetKey = 6498bcae933b
+spam.siteUrl = http://tietema.net
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.throwExceptions = "true"
resources.doctrine.connections.default.dsn = "mysql://root:php-dev@localhost/fizzy"
resources.sabredav.enabled = true
resources.sabredav.browser = true
[test : production]
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index 23aa6ab..fa3dc5d 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,147 +1,177 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/fizzy/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/fizzy/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
+admin_comments_list.route = "/fizzy/comments/list"
+admin_comments_list.defaults.action = "list"
+admin_comments_list.defaults.controller = "comments"
+admin_comments_list.defaults.module = "admin"
+
+admin_comments_topic.route = "/fizzy/comments/topic/:id"
+admin_comments_topic.defaults.action = "topic"
+admin_comments_topic.defaults.controller = "comments"
+admin_comments_topic.defaults.module = "admin"
+
+admin_comments_ham.route = "/fizzy/comment/ham/:id"
+admin_comments_ham.defaults.action = "ham"
+admin_comments_ham.defaults.controller = "comments"
+admin_comments_ham.defaults.module = "admin"
+
+admin_comments_spam.route = "/fizzy/comment/spam/:id"
+admin_comments_spam.defaults.action = "spam"
+admin_comments_spam.defaults.controller = "comments"
+admin_comments_spam.defaults.module = "admin"
+
+admin_comments_delete.route = "/fizzy/comment/delete/:id"
+admin_comments_delete.defaults.action = "delete"
+admin_comments_delete.defaults.controller = "comments"
+admin_comments_delete.defaults.module = "admin"
+
+admin_comments_edit.route = "/fizzy/comment/edit/:id"
+admin_comments_edit.defaults.action = "edit"
+admin_comments_edit.defaults.controller = "comments"
+admin_comments_edit.defaults.module = "admin"
+
admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin contact
admin_contact.route = "/fizzy/contact"
admin_contact.defaults.module = "admin"
admin_contact.defaults.controller = "contact"
admin_contact.defaults.action = "index"
admin_contact_show.route = "/fizzy/contact/show/:id"
admin_contact_show.defaults.module = "admin"
admin_contact_show.defaults.controller = "contact"
admin_contact_show.defaults.action = "show"
admin_contact_delete.route = "/fizzy/contact/delete/:id"
admin_contact_delete.defaults.module = "admin"
admin_contact_delete.defaults.controller = "contact"
admin_contact_delete.defaults.action = "delete"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin settings
admin_settings.route = "/fizzy/settings"
admin_settings.defaults.module = "admin"
admin_settings.defaults.controller = "settings"
admin_settings.defaults.action = "index"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 42578cf..d769b75 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,74 +1,79 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
displayname: string(255)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
status: integer(1)
comments: boolean
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
post_id: string(100)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
+ spam: boolean
+ approved: boolean
+ ip: string(100)
+ user_agent: string(255)
+ referrer: string(255)
indexes:
post_id_index:
fields: [post_id]
Setting:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
component: string(50)
setting_key: string(50)
value: string
label: string(255)
description: string
Contact:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
email: string(255)
body: string
date: datetime
\ No newline at end of file
diff --git a/library/Fizzy/Spam.php b/library/Fizzy/Spam.php
new file mode 100644
index 0000000..57bf056
--- /dev/null
+++ b/library/Fizzy/Spam.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Class Fizzy_Spam
+ * @package Fizzy
+ * @subpackage Spam
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Class for filtering (comment) spam using various webservices as backend
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Spam
+{
+ protected static $_defaultAdapter = null;
+
+ protected $_adapter = null;
+
+ public function __construct($adapter = null)
+ {
+ if (null === $adapter){
+ if (null === self::$_defaultAdapter){
+ throw new Fizzy_Spam_Exception('No adapter specified.');
+ }
+ $this->_adapter = self::$_defaultAdapter;
+ } else {
+ $this->_adapter = $adapter;
+ }
+
+ }
+
+ public static function setDefaultAdapter($adapter)
+ {
+ self::$_defaultAdapter = $adapter;
+ }
+
+ public function isSpam(Fizzy_Spam_Document $document)
+ {
+ return $this->_adapter->isSpam($document);
+ }
+
+ public function submitSpam(Fizzy_Spam_Document $document)
+ {
+ return $this->_adapter->submitSpam($document);
+ }
+
+ public function submitHam(Fizzy_Spam_Document $document)
+ {
+ return $this->_adapter->submitHam($document);
+ }
+}
diff --git a/library/Fizzy/Spam/Adapter/Akismet.php b/library/Fizzy/Spam/Adapter/Akismet.php
new file mode 100644
index 0000000..ad4679f
--- /dev/null
+++ b/library/Fizzy/Spam/Adapter/Akismet.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Class Fizzy_Spam_Adapter_Akismet
+ * @package Fizzy
+ * @subpackage Spam
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Description of Akismet
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Spam_Adapter_Akismet implements Fizzy_Spam_Adapter_Interface
+{
+ protected $_akismet = null;
+
+ public function __construct($apiKey, $blogUrl)
+ {
+ $this->_akismet = new Zend_Service_Akismet($apiKey, $blogUrl);
+ }
+
+ public function isSpam($document)
+ {
+ $data = $this->_convertDocument($document);
+ return $this->_akismet->isSpam($data);
+ }
+
+ public function submitSpam($document)
+ {
+ $data = $this->_convertDocument($document);
+ $this->_akismet->submitSpam($data);
+ }
+
+ public function submitHam($document)
+ {
+ $data = $this->_convertDocument($document);
+ $this->_akismet->submitHam($data);
+ }
+
+ /**
+ * Converts a Fizzy_Spam_Document to Akismet request parameters
+ *
+ * Akismet paramters:
+ * - blog: URL of the blog. If not provided, uses value returned by {@link getBlogUrl()}
+ * - user_ip (required): IP address of comment submitter
+ * - user_agent (required): User Agent used by comment submitter
+ * - referrer: contents of HTTP_REFERER header
+ * - permalink: location of the entry to which the comment was submitted
+ * - comment_type: typically, one of 'blank', 'comment', 'trackback', or 'pingback', but may be any value
+ * - comment_author: name submitted with the content
+ * - comment_author_email: email submitted with the content
+ * - comment_author_url: URL submitted with the content
+ * - comment_content: actual content
+ *
+ * @param Fizzy_Spam_Document $document
+ * @return array
+ */
+ protected function _convertDocument(Fizzy_Spam_Document $document)
+ {
+ $params = array(
+ 'user_ip' => $document->getAuthorIp(),
+ 'user_agent' => $document->getUserAgent(),
+ 'referrer' => $document->getReferrer(),
+ 'comment_author' => $document->getAuthorName(),
+ 'comment_author_email' => $document->getAuthorEmail(),
+ 'comment_author_url' => $document->getAuthorWebsite(),
+ 'comment_content' => $document->getBody()
+ );
+ return $params;
+ }
+}
diff --git a/library/Fizzy/Spam/Adapter/Interface.php b/library/Fizzy/Spam/Adapter/Interface.php
new file mode 100644
index 0000000..6fb1409
--- /dev/null
+++ b/library/Fizzy/Spam/Adapter/Interface.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Class Fizzy_Spam_Adapter_Interface
+ * @package Fizzy
+ * @subpackage Spam
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Description of Fizzy_Spam_Adapter_Interface
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+interface Fizzy_Spam_Adapter_Interface
+{
+ public function isSpam($data);
+ public function submitSpam($data);
+ public function submitHam($data);
+}
diff --git a/library/Fizzy/Spam/Document.php b/library/Fizzy/Spam/Document.php
new file mode 100644
index 0000000..947e753
--- /dev/null
+++ b/library/Fizzy/Spam/Document.php
@@ -0,0 +1,116 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Document
+ *
+ * @author jeroen
+ */
+class Fizzy_Spam_Document
+{
+ protected $_body;
+ protected $_authorName;
+ protected $_authorEmail;
+ protected $_authorWebsite;
+ protected $_authorIp;
+ protected $_userAgent;
+ protected $_referrer;
+
+ public function __construct(
+ $body,
+ $authorName,
+ $authorEmail,
+ $authorWebsite,
+ $authorIp,
+ $userAgent,
+ $referrer)
+ {
+ $this->_body = $body;
+ $this->_authorName = $authorName;
+ $this->_authorEmail = $authorEmail;
+ $this->_authorWebsite = $authorWebsite;
+ $this->_authorIp = $authorIp;
+ $this->_userAgent = $userAgent;
+ $this->_referrer = $referrer;
+ }
+
+ public function getBody()
+ {
+ return $this->_body;
+ }
+
+ public function setBody($body)
+ {
+ $this->_body = $body;
+ return $this;
+ }
+
+ public function getAuthorName()
+ {
+ return $this->_authorName;
+ }
+
+ public function setAuthorName($name)
+ {
+ $this->_authorName = $name;
+ return $this;
+ }
+
+ public function getAuthorEmail()
+ {
+ return $this->_authorEmail;
+ }
+
+ public function setAuthorEmail($email)
+ {
+ $this->_authorEmail = $email;
+ return $this;
+ }
+
+ public function getAuthorWebsite()
+ {
+ return $this->_authorWebsite;
+ }
+
+ public function setAuthorWebsite($website)
+ {
+ $this->_authorWebsite = $website;
+ return $this;
+ }
+
+ public function getAuthorIp()
+ {
+ return $this->_authorIp;
+ }
+
+ public function setAuthorIp($ip)
+ {
+ $this->_authorIp = $ip;
+ return $this;
+ }
+
+ public function getUserAgent()
+ {
+ return $this->_userAgent;
+ }
+
+ public function setUserAgent($userAgent)
+ {
+ $this->_userAgent = $userAgent;
+ return $this;
+ }
+
+ public function getReferrer()
+ {
+ return $this->_referrer;
+ }
+
+ public function setReferrer($referrer)
+ {
+ $this->_referrer = $referrer;
+ return $this;
+ }
+}
diff --git a/library/Fizzy/Types.php b/library/Fizzy/Types.php
new file mode 100644
index 0000000..416609e
--- /dev/null
+++ b/library/Fizzy/Types.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Class Fizzy_Type
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Convenience class for managing all type information from type config file.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Types {
+
+ protected static $_instance = null;
+
+ protected $_config;
+
+ protected function __construct(Zend_Config $config)
+ {
+ $this->_config = $config;
+ }
+
+ public static function initialize(Zend_Config $config)
+ {
+ if (null !== self::$_instance){
+ throw new Fizzy_Exception('Can\'t call Fizzy_Type::initialize twice.');
+ }
+ self::$_instance = new self($config);
+ return self::$_instance;
+ }
+
+ /**
+ * Returns the current instance, but only if it has been initialized in the
+ * bootstrap.
+ *
+ * @return Fizzy_Type
+ */
+ public static function getInstance()
+ {
+ if (null === self::$_instance){
+ throw new Fizzy_Exception('Type configuration not initialized. Make sure you call "Fizzy_Type::initialize($config)" first');
+ }
+ return self::$_instance;
+ }
+
+ public function hasType($type)
+ {
+ return isset($this->_config->Types->{$type});
+ }
+
+ public function getType($type)
+ {
+ if (isset($this->_config->Types->{$type})){
+ return $this->_config->Types->{$type};
+ }
+ return null;
+ }
+
+ public function getTypeModel($type)
+ {
+ if (isset($this->_config->Types->{$type}->model)){
+ return $this->_config->Types->{$type}->model;
+ }
+ return null;
+ }
+}
diff --git a/library/ZendL/Config/Json.php b/library/ZendL/Config/Json.php
new file mode 100755
index 0000000..b4fc406
--- /dev/null
+++ b/library/ZendL/Config/Json.php
@@ -0,0 +1,175 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 19059 2009-11-19 20:05:27Z jan $
+ */
+
+/**
+ * @see Zend_Config
+ */
+require_once 'Zend/Config.php';
+
+/**
+ * @see Zend_Json
+ */
+require_once 'Zend/Json.php';
+
+/**
+ * XML Adapter for Zend_Config
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendL_Config_Json extends Zend_Config
+{
+ const EXTENDS_NAME = "_extends";
+ /**
+ * Whether to skip extends or not
+ *
+ * @var boolean
+ */
+ protected $_skipExtends = false;
+
+ /**
+ * Loads the section $section from the config file encoded as JSON
+ *
+ * Sections are defined as properties of the main object
+ *
+ * In order to extend another section, a section defines the "_extends"
+ * property having a value of the section name from which the extending
+ * section inherits values.
+ *
+ * Note that the keys in $section will override any keys of the same
+ * name in the sections that have been included via "_extends".
+ *
+ * @param string $json JSON file or string to process
+ * @param mixed $section Section to process
+ * @param boolean $options Whether modifiacations are allowed at runtime
+ * @throws Zend_Config_Exception When JSON text is not set or cannot be loaded
+ * @throws Zend_Config_Exception When section $sectionName cannot be found in $json
+ */
+ public function __construct($json, $section = null, $options = false)
+ {
+ if (empty($json)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Filename is not set');
+ }
+
+ $allowModifications = false;
+ if (is_bool($options)) {
+ $allowModifications = $options;
+ } elseif (is_array($options)) {
+ if (isset($options['allowModifications'])) {
+ $allowModifications = (bool) $options['allowModifications'];
+ }
+ if (isset($options['skipExtends'])) {
+ $this->_skipExtends = (bool) $options['skipExtends'];
+ }
+ }
+
+ set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
+ if ($json[0] != '{') {
+ $json = file_get_contents($json);
+ }
+ restore_error_handler();
+ // Check if there was a error while loading file
+ if ($this->_loadFileErrorStr !== null) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception($this->_loadFileErrorStr);
+ }
+
+ $config = Zend_Json::decode($json);
+
+ if($config == null) {
+ // decode failed
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Error parsing JSON data");
+ }
+
+ if ($section === null) {
+ $dataArray = array();
+ foreach ($config as $sectionName => $sectionData) {
+ $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ } else if (is_array($section)) {
+ $dataArray = array();
+ foreach ($section as $sectionName) {
+ if (!isset($config->$sectionName)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$sectionName' cannot be found in the data");
+ }
+
+ $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ } else {
+ if (!isset($config[$section])) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$section' cannot be found in the data");
+ }
+
+ $dataArray = $this->_processExtends($config, $section);
+ if (!is_array($dataArray)) {
+ // Section in the JSON data contains just one top level string
+ $dataArray = array($section => $dataArray);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ }
+
+ $this->_loadedSection = $section;
+ }
+
+ /**
+ * Helper function to process each element in the section and handle
+ * the "_extends" inheritance attribute.
+ *
+ * @param array $data Data array to process
+ * @param string $section Section to process
+ * @param array $config Configuration which was parsed yet
+ * @throws Zend_Config_Exception When $section cannot be found
+ * @return array
+ */
+ protected function _processExtends(array $data, $section, array $config = array())
+ {
+ if (!isset($data[$section])) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$section' cannot be found");
+ }
+
+ $thisSection = $data[$section];
+
+ if (isset($thisSection[self::EXTENDS_NAME])) {
+ $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]);
+
+ if (!$this->_skipExtends) {
+ $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config);
+ }
+ unset($thisSection[self::EXTENDS_NAME]);
+ }
+
+ $config = $this->_arrayMergeRecursive($config, $thisSection);
+
+ return $config;
+ }
+}
diff --git a/library/ZendL/Config/Writer/Json.php b/library/ZendL/Config/Writer/Json.php
new file mode 100755
index 0000000..3c6fd42
--- /dev/null
+++ b/library/ZendL/Config/Writer/Json.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 18862 2009-11-05 18:25:20Z beberlei $
+ */
+
+/**
+ * @see Zend_Config_Writer
+ */
+require_once 'Zend/Config/Writer/FileAbstract.php';
+
+/**
+ * @see Zend_Config_Json
+ */
+require_once 'ZendL/Config/Json.php';
+
+/**
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendL_Config_Writer_Json extends Zend_Config_Writer_FileAbstract
+{
+ /**
+ * If we need to pretty-print JSON data
+ *
+ * @var boolean
+ */
+ protected $_prettyPrint = false;
+
+ /**
+ * Get prettyPrint flag
+ *
+ * @return the prettyPrint flag
+ */
+ public function getPrettyPrint() {
+ return $this->_prettyPrint;
+ }
+
+ /**
+ * Set prettyPrint flag
+ *
+ * @param $_prettyPrint prettyPrint flag
+ * @return Zend_Config_Writer_Json
+ */
+ public function setPrettyPrint($_prettyPrint) {
+ $this->_prettyPrint = $_prettyPrint;
+ return $this;
+ }
+
+ /**
+ * Render a Zend_Config into a JSON config string.
+ *
+ * @since 1.10
+ * @return string
+ */
+ public function render()
+ {
+ $data = $this->_config->toArray();
+ $sectionName = $this->_config->getSectionName();
+ $extends = $this->_config->getExtends();
+
+ if (is_string($sectionName)) {
+ $data = array($sectionName => $data);
+ }
+
+ foreach($extends as $section => $parent_section) {
+ $data[$section][ZendL_Config_Json::EXTENDS_NAME] = $parent_section;
+ }
+
+ $out = Zend_Json::encode($data);
+ if($this->_prettyPrint) {
+ $out = Zend_Json::prettyPrint($out);
+ }
+ return $out;
+ }
+}
diff --git a/library/ZendL/Config/Writer/Yaml.php b/library/ZendL/Config/Writer/Yaml.php
new file mode 100755
index 0000000..1ac33e2
--- /dev/null
+++ b/library/ZendL/Config/Writer/Yaml.php
@@ -0,0 +1,133 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 18862 2009-11-05 18:25:20Z beberlei $
+ */
+
+/**
+ * @see Zend_Config_Writer
+ */
+require_once 'Zend/Config/Writer/FileAbstract.php';
+
+/**
+ * @see Zend_Config_Json
+ */
+require_once 'ZendL/Config/Yaml.php';
+
+/**
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendL_Config_Writer_Yaml extends Zend_Config_Writer_FileAbstract
+{
+ /**
+ * What to call when we need to decode some YAML?
+ *
+ * @var callable
+ */
+ protected $yamlEncoder = array('ZendL_Config_Writer_Yaml', 'encode');
+
+ /**
+ * Get callback for decoding YAML
+ *
+ * @return callable
+ */
+ public function getYamlEncoder()
+ {
+ return $this->yamlEncoder;
+ }
+
+ /**
+ * Set callback for decoding YAML
+ *
+ * @param $yamlEncoder the decoder to set
+ * @returns Zend_Config_Yaml
+ */
+ public function setYamlEncoder($yamlEncoder)
+ {
+ if(!is_callable($yamlEncoder)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Invalid parameter to setYamlEncoder - must be callable');
+ }
+
+ $this->yamlEncoder = $yamlEncoder;
+ return $this;
+ }
+
+ /**
+ * Render a Zend_Config into a YAML config string.
+ *
+ * @since 1.10
+ * @return string
+ */
+ public function render()
+ {
+ $data = $this->_config->toArray();
+ $sectionName = $this->_config->getSectionName();
+ $extends = $this->_config->getExtends();
+
+ if (is_string($sectionName)) {
+ $data = array($sectionName => $data);
+ }
+
+ foreach($extends as $section => $parent_section) {
+ $data[$section][ZendL_Config_Yaml::EXTENDS_NAME] = $parent_section;
+ }
+
+ return call_user_func($this->yamlEncoder, $data);
+ }
+
+ /**
+ * Very dumb YAML encoder
+ *
+ * Until we have Zend_Yaml...
+ *
+ * @param array $data YAML data
+ * @return string
+ */
+ public static function encode($data)
+ {
+ return self::_encodeYaml(0, $data);
+ }
+
+ /**
+ * Service function for encoding YAML
+ *
+ * @param int $indent Current indent level
+ * @param array $data Data to encode
+ * @return string
+ */
+ protected static function _encodeYaml($indent, $data)
+ {
+ reset($data);
+ $result = "";
+ $numeric = is_numeric(key($data));
+
+ foreach($data as $key => $value) {
+ if(is_array($value)) {
+ $encoded = "\n".self::_encodeYaml($indent+1, $value);
+ } else {
+ $encoded = (string)$value."\n";
+ }
+ $result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded;
+ }
+ return $result;
+ }
+}
diff --git a/library/ZendL/Config/Yaml.php b/library/ZendL/Config/Yaml.php
new file mode 100755
index 0000000..64d11da
--- /dev/null
+++ b/library/ZendL/Config/Yaml.php
@@ -0,0 +1,290 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 19059 2009-11-19 20:05:27Z jan $
+ */
+
+/**
+ * @see Zend_Config
+ */
+require_once 'Zend/Config.php';
+
+/**
+ * XML Adapter for Zend_Config
+ *
+ * @category Zend
+ * @package Zend_Config
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendL_Config_Yaml extends Zend_Config
+{
+ const EXTENDS_NAME = "_extends";
+ /**
+ * Whether to skip extends or not
+ *
+ * @var boolean
+ */
+ protected $_skipExtends = false;
+
+ /**
+ * What to call when we need to decode some YAML?
+ *
+ * @var callable
+ */
+ protected $yamlDecoder = array('ZendL_Config_Yaml', 'decode');
+
+ /**
+ * Get callback for decoding YAML
+ *
+ * @return callable
+ */
+ public function getYamlDecoder()
+ {
+ return $this->yamlDecoder;
+ }
+
+ /**
+ * Set callback for decoding YAML
+ *
+ * @param $yamlDecoder the decoder to set
+ * @returns Zend_Config_Yaml
+ */
+ public function setYamlDecoder($yamlDecoder)
+ {
+ if(!is_callable($yamlDecoder)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Invalid parameter to setYamlDecoder - must be callable');
+ }
+
+ $this->yamlDecoder = $yamlDecoder;
+ return $this;
+ }
+
+ /**
+ * Loads the section $section from the config file encoded as YAML
+ *
+ * Sections are defined as properties of the main object
+ *
+ * In order to extend another section, a section defines the "_extends"
+ * property having a value of the section name from which the extending
+ * section inherits values.
+ *
+ * Note that the keys in $section will override any keys of the same
+ * name in the sections that have been included via "_extends".
+ *
+ * @param string $yaml YAML file to process
+ * @param mixed $section Section to process
+ * @param boolean $options Whether modifiacations are allowed at runtime
+ */
+ public function __construct($yaml, $section = null, $options = false)
+ {
+ if (empty($yaml)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception('Filename is not set');
+ }
+
+ $allowModifications = false;
+ if (is_bool($options)) {
+ $allowModifications = $options;
+ } elseif (is_array($options)) {
+ if (isset($options['allowModifications'])) {
+ $allowModifications = (bool) $options['allowModifications'];
+ }
+ if (isset($options['skipExtends'])) {
+ $this->_skipExtends = (bool) $options['skipExtends'];
+ }
+ if(isset($options['yamlDecoder'])) {
+ $this->setYamlDecoder($options['yamlDecoder']);
+ }
+ }
+
+ set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
+ $yaml = file_get_contents($yaml);
+ restore_error_handler();
+ // Check if there was a error while loading file
+ if ($this->_loadFileErrorStr !== null) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception($this->_loadFileErrorStr);
+ }
+
+ $config = call_user_func($this->yamlDecoder, $yaml);
+
+ if($config == null) {
+ // decode failed
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Error parsing YAML data");
+ }
+
+ if ($section === null) {
+ $dataArray = array();
+ foreach ($config as $sectionName => $sectionData) {
+ $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ } else if (is_array($section)) {
+ $dataArray = array();
+ foreach ($section as $sectionName) {
+ if (!isset($config->$sectionName)) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$sectionName' cannot be found in the data");
+ }
+
+ $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ } else {
+ if (!isset($config[$section])) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$section' cannot be found in the data");
+ }
+
+ $dataArray = $this->_processExtends($config, $section);
+ if (!is_array($dataArray)) {
+ // Section in the JSON data contains just one top level string
+ $dataArray = array($section => $dataArray);
+ }
+
+ parent::__construct($dataArray, $allowModifications);
+ }
+
+ $this->_loadedSection = $section;
+ }
+
+ /**
+ * Helper function to process each element in the section and handle
+ * the "_extends" inheritance attribute.
+ *
+ * @param array $data Data array to process
+ * @param string $section Section to process
+ * @param array $config Configuration which was parsed yet
+ * @throws Zend_Config_Exception When $section cannot be found
+ * @return array
+ */
+ protected function _processExtends(array $data, $section, array $config = array())
+ {
+ if (!isset($data[$section])) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Section '$section' cannot be found");
+ }
+
+ $thisSection = $data[$section];
+
+ if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) {
+ $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]);
+
+ if (!$this->_skipExtends) {
+ $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config);
+ }
+ unset($thisSection[self::EXTENDS_NAME]);
+ }
+
+ $config = $this->_arrayMergeRecursive($config, $thisSection);
+
+ return $config;
+ }
+
+ /**
+ * Very dumb YAML parser
+ *
+ * Until we have Zend_Yaml...
+ *
+ * @param string $yaml YAML source
+ * @return array Decoded data
+ */
+ public static function decode($yaml)
+ {
+ $lines = explode("\n", $yaml);
+ reset($lines);
+ return self::_decodeYaml(0, $lines);
+ }
+
+ /**
+ * Service function to decode YAML
+ *
+ * @param int $this_indent Current indent level
+ * @param array $lines YAML lines
+ * @return array|string
+ */
+ protected static function _decodeYaml($this_indent, &$lines)
+ {
+ $config = array();
+ $know_indent = false;
+ while(list($n, $line) = each($lines)) {
+ $lineno = $n+1;
+ if(strlen($line) == 0) {
+ continue;
+ }
+ if($line[0] == '#') {
+ // comment
+ continue;
+ }
+ $indent = strspn($line, " ");
+ // line without the spaces
+ $line = trim($line);
+ if(strlen($line) == 0) {
+ continue;
+ }
+
+ if($indent < $this_indent) {
+ // this level is done
+ prev($lines);
+ return $config;
+ }
+
+ if(!$know_indent) {
+ $this_indent = $indent;
+ $know_indent = true;
+ }
+
+ if($indent != $this_indent) {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Error parsing YAML at line $lineno - unexpected indent");
+ }
+
+ if(preg_match("/(\w+):\s*(.*)/", $line, $m)) {
+ // key: value
+ if($m[2]) {
+ // simple key: value
+ $value = $m[2];
+ } else {
+ // key: and then values on new lines
+ $value = self::_decodeYaml($this_indent+1, $lines);
+ if(is_array($value) && count($value) == 0) {
+ $value = "";
+ }
+ }
+ $config[$m[1]] = $value;
+ } else if($line[0] == "-") {
+ // item in the list:
+ // - FOO
+ if(strlen($line) > 2) {
+ $config[] = substr($line, 2);
+ } else {
+ $config[] = self::_decodeYaml($this_indent+1, $lines);
+ }
+ } else {
+ require_once 'Zend/Config/Exception.php';
+ throw new Zend_Config_Exception("Error parsing YAML at line $lineno - unsupported syntax: $line");
+ }
+ }
+ return $config;
+ }
+}
|
jtietema/Fizzy
|
c1708d650b3e8fe684462a80856a2dc283b6df5e
|
Javascript for inline edit settings
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index 575a8d9..75664d3 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,487 +1,494 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
+.hover-edit {
+ background-color: #FFF6C1;
+ background-image: url('../images/icon/pencil-small.png');
+ background-repeat: no-repeat;
+ background-position: right;
+}
+
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/settings/index.phtml b/application/modules/admin/views/scripts/settings/index.phtml
index d7ef6ed..23e0ff2 100644
--- a/application/modules/admin/views/scripts/settings/index.phtml
+++ b/application/modules/admin/views/scripts/settings/index.phtml
@@ -1,34 +1,132 @@
<div id="content-panel">
<h2>
- <?= $this->img('/fizzy_assets/images/icon/gear.png', array('alt' => 'Settings Icon')); ?>
+ <?= $this->image('/fizzy_assets/images/icon/gear.png', array('alt' => 'Settings Icon')); ?>
Settings
</h2>
<table class="settings" id="settings-table">
<tbody>
<?php foreach($this->settings as $component => $settings) : ?>
<tr>
- <th colspan="2"><?= ucfirst($component); ?></td>
+ <th colspan="2"><?= ucfirst($component); ?></th>
</tr>
<?php foreach($settings as $setting) : ?>
<tr>
<td class="label">
<?= $setting->label; ?>
</td>
<td>
- <span class="editable text"><?= $setting->value; ?></span><br />
+ <div id="<?= $setting->setting_key; ?>" class="editable text"><?= $setting->value; ?></div>
<small><?= $setting->description; ?></small>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
+ <script type="text/javascript">
+ (function($) {
+
+ $.fn.inlineEdit = function(options) {
+ options = $.extend({
+ hoverClass: 'hover-edit',
+ value: '',
+ save: ''
+ }, options);
+
+ return $.each(this, function() {
+ $.inlineEdit(this, options);
+ });
+ }
+
+ $.inlineEdit = function(object, options) {
+ // Define self
+ var self = $(object);
+
+ // create a value property to keep track of current value
+ self.value = $.trim(self.text()) || options.value;
+ self.settingKey = self.attr('id');
+ self.settingType = self.hasClass('boolean') ? 'boolean' : 'text';
+
+ self.save = function(newValue) {
+ var oldValue = self.value;
+ // Save new value
+ self.value = newValue;
+ // Reset the input
+ self.html(self.value);
+ // Only save if new value was different from the old value
+ if (newValue != oldValue) {
+ window.location = 'http://www.fizzy.dev/fizzy/settings/save/' + escape(self.settingKey) + '/' + self.value;
+ }
+ }
+
+ self.reset = function() {
+ self.html(self.value);
+ }
+
+ self.hover(function() {
+ if (0 == self.children().size()) {
+ self.parent().addClass(options.hoverClass);
+ }
+ }, function() {
+ self.parent().removeClass(options.hoverClass);
+ })
+ .click(function(event) {
+ var $this = $(event.target);
+ $this.parent().removeClass(options.hoverClass);
+
+ self.parent().blur(function() {
+ console.log('resetting');
+ //self.reset();
+ });
+
+ if ($this.is(self[0].tagName)) {
+ if (null != $.inlineEdit.lastOpened) {
+ $.inlineEdit.lastOpened.reset();
+ }
+ $.inlineEdit.lastOpened = self;
+
+ var tinput = $(document.createElement('input'))
+ .attr('type', 'text')
+ .val(self.value);
+
+ var saveBtn = $(document.createElement('button'))
+ .attr('id', 'editable-save')
+ .html('Save')
+ .click(function() {
+ console.log('Saving');
+ self.save($(this).parent().find('input').val());
+ });
+ var cancelBtn = $(document.createElement('button'))
+ .attr('id', 'editable-cancel')
+ .html('Cancel')
+ .click(function() {
+ console.log('Canceling');
+ self.reset();
+ });
+
+ // Replace container contents
+ self.html(tinput)
+ .append(saveBtn)
+ .append(cancelBtn)
+ .find('input')
+ .focus();
+ }
+ });
+ }
+ $.inlineEdit.lastOpened = null;
+ })(jQuery);
+
+ $(document).ready(function() {
+ $('.editable').inlineEdit();
+ });
+
+ </script>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
</div>
\ No newline at end of file
|
jtietema/Fizzy
|
6e15f67060ec5c3c0d33c53cfb62ced1f53cc320
|
Routes are parsed for backendSwitch config options
|
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 88b80bb..c399532 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,89 +1,104 @@
<?php
/**
* Class Bootstrap
* @category Fizzy
* @package Fizzy_Bootstrap
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Description of Bootstrap
*
* @author jeroen
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$view->addHelperPath(
realpath(implode(DIRECTORY_SEPARATOR,
array(ROOT_PATH, 'library', 'Fizzy', 'View', 'Helper')
)), 'Fizzy_View_Helper');
$view->addHelperPath(
realpath(implode(DIRECTORY_SEPARATOR,
array(ROOT_PATH, 'library', 'ZendX', 'JQuery', 'View', 'Helper')
)), 'ZendX_JQuery_View_Helper');
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$this->bootstrap('FrontController');
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getResource('FrontController');
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
protected function _initRoutes()
{
$this->bootstrap('FrontController');
+
+ $options = $this->getOptions();
+ $backendSwitch = isset($options['backendSwitch']) ? strtolower((string) $options['backendSwitch']) : 'fizzy';
+
$router = $this->getContainer()->frontcontroller->getRouter();
$config = new Zend_Config_Ini(ROOT_PATH . '/configs/routes.ini');
- $router->addConfig($config->{$this->getEnvironment()});
+
+ $routes = $config->{$this->getEnvironment()}->toArray();
+
+ // Parse all routes and replace the backend switch
+ foreach ($routes as &$route) {
+ if (false !== strpos($route['route'], '{backend}')) {
+ $route['route'] = str_replace('{backend}', $backendSwitch, $route['route']);
+ }
+ }
+
+ // Load parsed routes into the router
+ $router->addConfig(new Zend_Config($routes));
return $router;
}
}
diff --git a/configs/application.ini b/configs/application.ini
index 5cd0b76..4aaa14f 100644
--- a/configs/application.ini
+++ b/configs/application.ini
@@ -1,40 +1,41 @@
[production]
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.session.save_path = "/tmp"
autoloaderNamespaces.fizzy = "Fizzy_"
pluginPaths.Fizzy_Resource = APPLICATION_PATH "/../library/Fizzy/Resource/"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
title = "Fizzy"
pages.defaultTemplate = "page.phtml"
pages.defaultLayout = "default"
paths.templatePath = APPLICATION_PATH "/modules/default/views/templates"
paths.layoutPath = APPLICATION_PATH "/modules/default/views/layouts"
+backendSwitch = "fizzy"
contact.email = "[email protected]"
; Doctrine resources
resources.doctrine.manager.attributes.attr_model_loading = model_loading_conservative
resources.doctrine.connections.default.dsn = "mysql://root@localhost/fizzy"
resources.doctrine.paths.models_path = APPLICATION_PATH "/models/"
resources.doctrine.paths.yaml_schema_path = ROOT_PATH "/database/schema/"
resources.doctrine.paths.sql_path = ROOT_PATH "/database/sql/"
resources.doctrine.paths.migrations_path = ROOT_PATH "/database/migrations/"
resources.doctrine.paths.data_fixtures_path = ROOT_PATH "/database/fixtures/"
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.throwExceptions = "true"
resources.doctrine.connections.default.dsn = "mysql://root:php-dev@localhost/fizzy"
resources.sabredav.enabled = true
resources.sabredav.browser = true
[test : production]
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index 23aa6ab..60c003b 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,147 +1,147 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
-admin_blogs.route = "/fizzy/blogs"
+admin_blogs.route = "/{backend}/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
-admin_blog.route = "/fizzy/blog/:id"
+admin_blog.route = "/{backend}/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
-admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
+admin_blog_post_add.route = "/{backend}/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
-admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
+admin_blog_post_edit.route = "/{backend}/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
-admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
+admin_blog_post_delete.route = "/{backend}/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
-admin_pages.route = "/fizzy/pages"
+admin_pages.route = "/{backend}/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
-admin_pages_add.route = "/fizzy/pages/add"
+admin_pages_add.route = "/{backend}/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
-admin_pages_edit.route = "/fizzy/pages/edit/:id"
+admin_pages_edit.route = "/{backend}/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
-admin_pages_delete.route = "/fizzy/pages/delete/:id"
+admin_pages_delete.route = "/{backend}/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
-admin_media.route = "/fizzy/media"
+admin_media.route = "/{backend}/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
-admin_media_delete.route = "/fizzy/media/delete/:name"
+admin_media_delete.route = "/{backend}/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
-admin_media_gallery.route = "/fizzy/media/gallery"
+admin_media_gallery.route = "/{backend}/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
-admin_media_assets.route = "/fizzy/media/assets"
+admin_media_assets.route = "/{backend}/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin contact
-admin_contact.route = "/fizzy/contact"
+admin_contact.route = "/{backend}/contact"
admin_contact.defaults.module = "admin"
admin_contact.defaults.controller = "contact"
admin_contact.defaults.action = "index"
-admin_contact_show.route = "/fizzy/contact/show/:id"
+admin_contact_show.route = "/{backend}/contact/show/:id"
admin_contact_show.defaults.module = "admin"
admin_contact_show.defaults.controller = "contact"
admin_contact_show.defaults.action = "show"
-admin_contact_delete.route = "/fizzy/contact/delete/:id"
+admin_contact_delete.route = "/{backend}/contact/delete/:id"
admin_contact_delete.defaults.module = "admin"
admin_contact_delete.defaults.controller = "contact"
admin_contact_delete.defaults.action = "delete"
;; Admin users
-admin_users.route = "/fizzy/users"
+admin_users.route = "/{backend}/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
-admin_users_add.route = "/fizzy/user/add"
+admin_users_add.route = "/{backend}/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
-admin_users_edit.route = "/fizzy/user/edit/:id"
+admin_users_edit.route = "/{backend}/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
-admin_users_delete.route = "/fizzy/user/delete/:id"
+admin_users_delete.route = "/{backend}/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin settings
-admin_settings.route = "/fizzy/settings"
+admin_settings.route = "/{backend}/settings"
admin_settings.defaults.module = "admin"
admin_settings.defaults.controller = "settings"
admin_settings.defaults.action = "index"
;; Admin WebDAV
-admin_configuration.route = "/fizzy/webdav/*"
+admin_configuration.route = "/{backend}/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
-admin_login.route = "/fizzy/login"
+admin_login.route = "/{backend}/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
-admin_logout.route = "/fizzy/logout"
+admin_logout.route = "/{backend}/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
-admin.route = "/fizzy"
+admin.route = "/{backend}"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
|
jtietema/Fizzy
|
792390e934410110fd80d0786ade80e057c11dcf
|
Expanded the Link View Helper
|
diff --git a/application/modules/admin/views/scripts/pages/index.phtml b/application/modules/admin/views/scripts/pages/index.phtml
index 753e68f..85bcb33 100644
--- a/application/modules/admin/views/scripts/pages/index.phtml
+++ b/application/modules/admin/views/scripts/pages/index.phtml
@@ -1,48 +1,48 @@
<div id="content-panel">
<h2>Pages</h2>
<div>
<table class="data" id="pages-table">
<thead>
<tr>
<td> </td>
<td>Slug</td>
<td>Title</td>
</tr>
</thead>
<tbody>
<?php foreach($this->pages as $page) : ?>
<tr>
<td class="controls">
- <?= $this->link("/fizzy/pages/edit/{$page['id']}", $this->image('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page', 'escape' => false)); ?>
+ <?= $this->link("@admin_pages_edit?id={$page['id']}", $this->image('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page', 'escape' => false)); ?>
</td>
<td style="width: 200px;"><?= $page['slug'] ?></td>
<td><?= $page['title'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
- <?= $this->link('/fizzy/pages/add', $this->image('/fizzy_assets/images/icon/document--plus.png') . ' Add page', array('escape' => false)); ?>
+ <?= $this->link('@admin_pages_add', $this->image('/fizzy_assets/images/icon/document--plus.png') . ' Add page', array('escape' => false)); ?>
</li>
</ul>
<hr />
<div class="block">
<h2>About pages</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus laoreet fringilla eros in laoreet. Sed rhoncus aliquam accumsan. Nullam nec massa sed elit faucibus ultricies. Vivamus pharetra volutpat posuere. Aliquam a metus neque, et euismod odio. Suspendisse potenti. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eget metus lacus, quis rhoncus mauris. In sit amet aliquet felis. Aenean luctus ornare posuere. Fusce egestas, nisi nec mattis pretium, lorem lorem venenatis lectus, id ornare lacus justo in neque. Ut commodo risus eu justo vulputate a fringilla quam rhoncus. Curabitur fermentum neque in tellus adipiscing scelerisque.
</p>
</div>
</div>
\ No newline at end of file
diff --git a/library/Fizzy/View/Helper/Link.php b/library/Fizzy/View/Helper/Link.php
index f329447..fae3497 100644
--- a/library/Fizzy/View/Helper/Link.php
+++ b/library/Fizzy/View/Helper/Link.php
@@ -1,98 +1,129 @@
<?php
/**
* Class Fizzy_View_Helper_Link
* @package Fizzy
* @subpackage View
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* View helper for generating a link tag.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_View_Helper_Link extends Zend_View_Helper_HtmlElement
{
/**
* Construct a link tag. The passed url is prepended with the base url. This
* can be ignore by setting prependBase to false in the options.
*
* A javascript confirm dialog can be added to the link by specifying the
* confirm key in the options array. This text is converted to a javascript
* confirm dialog.
*
* Output escaping can be turned of by setting the escape options to false
* in the options array.
*
* @param string $url
* @param string $value
* @param array $options
* @return string
*/
public function link($url, $value, $options = array())
{
$defaults = array('prependBase' => true, 'escape' => true);
$options += $defaults;
if (null === $this->view) {
$view = new Zend_View();
}
$escape = (boolean) $options['escape'];
// Remove the escape option so it doesn't appear as an html attribute
unset($options['escape']);
-
+
+ // Check if the url was passed as a route name
+ if (0 === strpos($url, '@')) {
+
+ $routeName = substr($url, 1);
+ $params = array();
+
+ // Check for route parameters
+ if (false !== strpos($routeName, '?')) {
+ list($routeName, $paramString) = explode('?', $routeName);
+ if (empty($paramString)) {
+ break;
+ }
+
+ $paramPairs = explode('&', $paramString);
+ foreach ($paramPairs as $pair) {
+ if (false !== strpos($pair, '=')) {
+ list($pairKey, $pairValue) = explode('=', $pair);
+ $params[$pairKey] = $pairValue;
+ } else {
+ $params[$pairKey] = null;
+ }
+ }
+ }
+
+ $router = Zend_Controller_Front::getInstance()->getRouter();
+ $route = $router->getRoute($routeName);
+
+ // Build the url with route and parameters
+ $url = $route->assemble($params);
+ }
+
// Add base url if prependBase is true
if ((boolean) $options['prependBase']) {
$url = $this->view->baseUrl($url);
}
// Remove the prependBase option so it doesn't appear as an html attribute
unset($options['prependBase']);
// Check for confirm option
if (isset($options['confirm'])) {
$confirmText = $options['confirm'];
$confirm = "return confirm('{$this->view->escape($confirmText)}');";
unset($options['confirm']);
$onclick = '';
if (isset($options['onClick'])) {
$onclick = $options['onClick'];
unset($options['onClick']);
} else if (isset($options['onclick'])) {
$onclick = $options['onclick'];
unset($options['onclick']);
}
if (empty($onclick)) {
$onclick = $confirm;
}
else {
$onclick = $confirm . $onclick;
}
$options['onClick'] = $confirm;
}
// Construct the tag
$xhtml = '<a href="' . $url . '"' . $this->_htmlAttribs($options) . '>';
$xhtml .= ($escape) ? $this->view->escape($value) : $value;
$xhtml .= '</a>';
return $xhtml;
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
fadcb77e7b599e77f072f9854f0bfa2cebd25cf7
|
Fizzy View Helpers
|
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index afb5a56..88b80bb 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,85 +1,89 @@
<?php
/**
* Class Bootstrap
* @category Fizzy
* @package Fizzy_Bootstrap
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Description of Bootstrap
*
* @author jeroen
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
+ $view->addHelperPath(
+ realpath(implode(DIRECTORY_SEPARATOR,
+ array(ROOT_PATH, 'library', 'Fizzy', 'View', 'Helper')
+ )), 'Fizzy_View_Helper');
$view->addHelperPath(
realpath(implode(DIRECTORY_SEPARATOR,
array(ROOT_PATH, 'library', 'ZendX', 'JQuery', 'View', 'Helper')
)), 'ZendX_JQuery_View_Helper');
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$this->bootstrap('FrontController');
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getResource('FrontController');
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
protected function _initRoutes()
{
$this->bootstrap('FrontController');
$router = $this->getContainer()->frontcontroller->getRouter();
$config = new Zend_Config_Ini(ROOT_PATH . '/configs/routes.ini');
$router->addConfig($config->{$this->getEnvironment()});
return $router;
}
}
diff --git a/application/modules/admin/views/helpers/Img.php b/application/modules/admin/views/helpers/Img.php
deleted file mode 100644
index 651d1de..0000000
--- a/application/modules/admin/views/helpers/Img.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Class Admin_View_Helper_Img
- * @category Fizzy
- * @package Admin_View
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.voidwalkers.nl/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to [email protected] so we can send you a copy immediately.
- *
- * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
- * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
- */
-
-class Zend_View_Helper_Img extends Zend_View_Helper_HtmlElement
-{
-
- public function img($image, array $attribs = array())
- {
- $xhtml = '<img %s src="%s" />';
-
- return sprintf($xhtml, $this->_htmlAttribs($attribs), $this->view->baseUrl($image));
- }
-}
diff --git a/application/modules/admin/views/helpers/Link.php b/application/modules/admin/views/helpers/Link.php
deleted file mode 100644
index 93f61ae..0000000
--- a/application/modules/admin/views/helpers/Link.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Class Admin_View_Helper_Link
- * @category Fizzy
- * @package Admin_View
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.voidwalkers.nl/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to [email protected] so we can send you a copy immediately.
- *
- * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
- * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
- */
-
-class Zend_View_Helper_Link extends Zend_View_Helper_HtmlElement
-{
-
- public function link($url, $text, array $attribs = array())
- {
- $xhtml = '<a href="%s" %s>%s</a>';
-
- return sprintf($xhtml, $this->view->baseUrl($url), $this->_htmlAttribs($attribs), $text);
- }
-
-}
\ No newline at end of file
diff --git a/application/modules/admin/views/helpers/LinkConfirm.php b/application/modules/admin/views/helpers/LinkConfirm.php
deleted file mode 100644
index 7be101f..0000000
--- a/application/modules/admin/views/helpers/LinkConfirm.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * Class Admin_View_Helper_LinkConfirm
- * @category Fizzy
- * @package Admin_View
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.voidwalkers.nl/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to [email protected] so we can send you a copy immediately.
- *
- * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
- * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
- */
-
-class Zend_View_Helper_LinkConfirm extends Zend_View_Helper_HtmlElement
-{
-
- public function linkConfirm($url, $text, $confirm, array $attribs = array())
- {
- $html = '<a href="%s" onClick="return confirm(\'%s\');"%s>%s</a>';
-
- $attributes = $this->_htmlAttribs($attribs);
-
- return sprintf($html, $this->view->baseUrl($url), $confirm, $attributes, $text);
- }
-
-}
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index 688afe7..8e6c1fd 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,56 +1,56 @@
<div id="content-panel">
<h2><?= $this->blog->name ?></h2>
<div>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Date</td>
<td>Status</td>
<td>Author</td>
</tr>
</thead>
<tbody>
<?php $items = $this->paginator->getCurrentItems();
foreach ($items as $post): ?>
<tr>
<td class="controls">
- <?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
+ <?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->image('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page', 'escape' => false)); ?>
</td>
<td>
<?= $post->title ?>
</td>
<td>
<?= $post->date ?>
</td>
<td>
<?php if ($post->status == Post::PUBLISHED): ?>
Published
<?php elseif ($post->status == Post::PENDING_REVIEW): ?>
Pending review
<?php else: ?>
Draft
<?php endif; ?>
</td>
<td>
<?= $post->User->displayname ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($this->paginator, 'All', 'blogs/_pagination.phtml') ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
- <?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array()); ?>
+ <?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array('escape' => false)); ?>
</li>
</ul>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/post-form.phtml b/application/modules/admin/views/scripts/blogs/post-form.phtml
index f8bd6ef..f3bd502 100644
--- a/application/modules/admin/views/scripts/blogs/post-form.phtml
+++ b/application/modules/admin/views/scripts/blogs/post-form.phtml
@@ -1,57 +1,61 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
- <?= $this->img('/fizzy_assets/images/icon/document.png'); ?>
+ <?= $this->image('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->post->isNew()) ? 'Add post' : 'Edit post'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->body; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->post->isNew()) : ?>
<li class="no-bg right">
- <?= $this->linkConfirm(
+ <?= $this->link(
'/fizzy/post/' . $this->post->id . '/delete',
- $this->img('fizzy_assets/images/icon/document--minus.png') . ' delete page',
- 'Are you sure you want to delete this page?',
- array('class' => 'delete')
+ $this->image('fizzy_assets/images/icon/document--minus.png') . ' delete page',
+ array(
+ 'class' => 'delete',
+ 'Are you sure you want to delete this page?',
+ 'escape' => false
+ )
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/blog/' . $this->post->Blog->id,
- $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name
+ $this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name,
+ array('escape' => false)
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
<?= $this->form->status; ?>
<?= $this->form->author; ?>
<?= $this->form->date; ?>
<?= $this->form->comments; ?>
</div>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/contact/index.phtml b/application/modules/admin/views/scripts/contact/index.phtml
index 0605b13..a6882b6 100644
--- a/application/modules/admin/views/scripts/contact/index.phtml
+++ b/application/modules/admin/views/scripts/contact/index.phtml
@@ -1,30 +1,37 @@
<div id="content-panel">
<h2>Contact</h2>
<table class="data" id="contact-table">
<thead>
<tr>
<th> </th>
<th>Date</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php foreach($this->messages as $message) : ?>
<tr>
<td class="controls" style="width: 55px;">
- <?= $this->link('/fizzy/contact/show/' . $message->id, $this->img('/fizzy_assets/images/icon/mail-open.png')); ?>
+ <?= $this->link('/fizzy/contact/show/' . $message->id, $this->image('/fizzy_assets/images/icon/mail-open.png'), array('escape' => false)); ?>
- <?= $this->linkConfirm('/fizzy/contact/delete/' . $message->id, $this->img('/fizzy_assets/images/icon/mail--minus.png'), 'Are you sure you want to delete this contact request?'); ?>
+ <?= $this->link(
+ '/fizzy/contact/delete/' . $message->id,
+ $this->image('/fizzy_assets/images/icon/mail--minus.png'),
+ array (
+ 'confirm' => 'Are you sure you want to delete this contact request?',
+ 'escape' => false
+ )
+ ); ?>
</td>
<td style="width: 150px;"><?= $message->date; ?></td>
<td style="max-width: 300px;"><?= $message->name; ?> <<a href="mailto:<?= $message->email; ?>"><?= $message->email; ?></a>></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div id="sidebar-panel">
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/contact/show.phtml b/application/modules/admin/views/scripts/contact/show.phtml
index f8bd710..86bc92a 100644
--- a/application/modules/admin/views/scripts/contact/show.phtml
+++ b/application/modules/admin/views/scripts/contact/show.phtml
@@ -1,30 +1,33 @@
<div id="content-panel">
<h2>Contact request</h2>
<p>
From: <?= $this->message->name; ?> <<a href="mailto:<?= $this->message->email; ?>"><?= $this->message->email; ?></a>><br />
On: <?= $this->message->date; ?>
</p>
<p>
<?= nl2br($this->message->body); ?>
</p>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="no-bg right">
- <?= $this->linkConfirm(
+ <?= $this->link(
'/fizzy/contact/delete/' . $this->message->id,
- $this->img('/fizzy_assets/images/icon/mail--minus.png') . 'delete message',
- 'Are you sure you want to delete this message?',
- array('class' => 'delete')
+ $this->image('/fizzy_assets/images/icon/mail--minus.png') . 'delete message',
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this message?',
+ 'escape' => false
+ )
); ?>
</li>
<li class="no-bg right last">
- <?= $this->link('/fizzy/contact', $this->img('/fizzy_assets/images/icon/edit-list.png') . ' contact list'); ?>
+ <?= $this->link('/fizzy/contact', $this->image('/fizzy_assets/images/icon/edit-list.png') . ' contact list', array('escape' => false)); ?>
</li>
</ul>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/media/list.phtml b/application/modules/admin/views/scripts/media/list.phtml
index 10736f7..c67f0f3 100644
--- a/application/modules/admin/views/scripts/media/list.phtml
+++ b/application/modules/admin/views/scripts/media/list.phtml
@@ -1,59 +1,67 @@
<?php
$types = array(
'png' => $this->baseUrl('/fizzy_assets/images/icon/document-image.png'),
'jpg' => $this->baseUrl('/fizzy_assets/images/icon/document-image.png'),
'jpeg' => $this->baseUrl('/fizzy_assets/images/icon/document-image.png'),
'bmp' => $this->baseUrl('/fizzy_assets/images/icon/document-image.png'),
'gif' => $this->baseUrl('/fizzy_assets/images/icon/document-image.png'),
'doc' => $this->baseUrl('/fizzy_assets/images/icon/document-word.png'),
'docx' => $this->baseUrl('/fizzy_assets/images/icon/document-word.png'),
'xls' => $this->baseUrl('/fizzy_assets/images/icon/document-excel.png'),
'ppt' => $this->baseUrl('/fizzy_assets/images/icon/document-powerpoint.png'),
'pdf' => $this->baseUrl('/fizzy_assets/images/icon/document-pdf.png'),
'flv' => $this->baseUrl('/fizzy_assets/images/icon/document-flash-movie.png'),
'zip' => $this->baseUrl('/fizzy_assets/images/icon/document-zipper.png'),
'rar' => $this->baseUrl('/fizzy_assets/images/icon/document-zipper.png'),
'txt' => $this->baseUrl('/fizzy_assets/images/icon/document-text.png'),
);
?>
<div class="media-container">
<table class="media">
<?php if(0 < count($this->files)) : ?>
<tbody>
<?php $row = 0; foreach($this->files as $fileInfo) : ?>
<tr class="<?= (++$row % 2) === 0 ? 'even' : 'odd'; ?>">
<td class="icon">
<img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->baseUrl('/images/icon/page.png'); ?>" alt="" />
</td>
<td class="filename">
<a href="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file">
<?= $fileInfo->basename; ?>
</a>
</td>
<td class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
<td class="controls">
<?php if(is_writable($this->uploadFolder)) : ?>
- <?= $this->linkConfirm('/fizzy/media/delete/' . urlencode($fileInfo->basename), $this->img('/fizzy_assets/images/icon/minus-small.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?= $this->link(
+ '/fizzy/media/delete/' . urlencode($fileInfo->basename),
+ $this->image('/fizzy_assets/images/icon/minus-small.png'),
+ array (
+ 'confirm' => "Are you sure you want to delete {$fileInfo->basename}?",
+ 'title' => 'Delete file',
+ 'escape' => false,
+ )
+ ); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php else : ?>
<tr>
<td colspan="4">
No uploaded files were found. Use the form at the bottom to
add new files.
</td>
</tr>
<?php endif; ?>
</table>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/media/thumbnails.phtml b/application/modules/admin/views/scripts/media/thumbnails.phtml
index 64d54d3..38e7be3 100644
--- a/application/modules/admin/views/scripts/media/thumbnails.phtml
+++ b/application/modules/admin/views/scripts/media/thumbnails.phtml
@@ -1,71 +1,79 @@
<?php
// file type image declarations
$images = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
$types = array(
'png' => $this->baseUrl('/fizzy_assets/images/mimetypes/png.png'),
'jpg' => $this->baseUrl('/fizzy_assets/images/mimetypes/jpg.png'),
'jpeg' => $this->baseUrl('/fizzy_assets/images/mimetypes/jpg.png'),
'bmp' => $this->baseUrl('/fizzy_assets/images/mimetypes/bmp.png'),
'gif' => $this->baseUrl('/fizzy_assets/images/mimetypes/gif.png'),
'doc' => $this->baseUrl('/fizzy_assets/images/mimetypes/doc.png'),
'docx' => $this->baseUrl('/fizzy_assets/images/mimetypes/doc.png'),
'xls' => $this->baseUrl('/fizzy_assets/images/mimetypes/xls.png'),
'ppt' => $this->baseUrl('/fizzy_assets/images/mimetypes/ppt.png'),
'pdf' => $this->baseUrl('/fizzy_assets/images/mimetypes/pdf.png'),
'flv' => $this->baseUrl('/fizzy_assets/images/mimetypes/flv.png'),
'zip' => $this->baseUrl('/fizzy_assets/images/mimetypes/zip.png'),
'rar' => $this->baseUrl('/fizzy_assets/images/mimetypes/rar.png'),
'txt' => $this->baseUrl('/fizzy_assets/images/mimetypes/txt.png'),
);
?>
<div class="media-container">
<?php foreach($this->files as $fileInfo) : ?>
<div class="thumbnail">
<div class="head">
<span class="filename">
<?php if (strlen($fileInfo->basename) > 14):?>
<?= substr($fileInfo->basename, 0, 14); ?>...
<?php else: ?>
<?= $fileInfo->basename ?>
<?php endif; ?>
</span>
<?php if(is_writable($this->uploadFolder)) : ?>
<span class="remove">
- <?= $this->linkConfirm('/fizzy_assets/media/delete/' . urlencode($fileInfo->basename), $this->img('/fizzy_assets/images/icon/cross-small.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?= $this->link(
+ '/fizzy_assets/media/delete/' . urlencode($fileInfo->basename),
+ $this->image('/fizzy_assets/images/icon/cross-small.png'),
+ array (
+ 'confirm' => "Are you sure you want to delete {$fileInfo->basename}?",
+ 'title' => 'Delete file',
+ 'escape' => false,
+ )
+ ); ?>
</span>
<?php endif; ?>
<div class="clear"></div>
</div>
<div class="body">
<a href="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file">
<?php if (in_array($fileInfo->type, $images)): ?>
<img class="source" src="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
<?php else: ?>
<img class="icon" width="48px" height="48px" src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->baseUrl('/fizzy_assets/images/icon/page.png'); ?>" alt="" />
<?php endif; ?>
</a>
</div>
<div class="foot">
<span class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
</span>
<div class="clear"></div>
</div>
</div>
<?php endforeach; ?>
<div class="clear"></div>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/pages/form.phtml b/application/modules/admin/views/scripts/pages/form.phtml
index a118a22..c389f26 100644
--- a/application/modules/admin/views/scripts/pages/form.phtml
+++ b/application/modules/admin/views/scripts/pages/form.phtml
@@ -1,64 +1,68 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
<?= $this->img('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->page->isNew()) ? 'Add page' : 'Edit page'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->slug; ?>
<?= $this->form->body; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->page->isNew()) : ?>
<li class="no-bg right">
- <?= $this->linkConfirm(
+ <?= $this->link(
'/fizzy/pages/delete/' . $this->page->id,
- $this->img('fizzy_assets/images/icon/document--minus.png') . ' delete page',
- 'Are you sure you want to delete this page?',
- array('class' => 'delete')
+ $this->image('fizzy_assets/images/icon/document--minus.png') . ' delete page',
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this page?',
+ 'escape' => false
+ )
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/pages',
- $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to pages'
+ $this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to pages',
+ array('escape' => false)
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
<?= $this->form->template; ?>
<?= $this->form->layout; ?>
<div class="form-row" id="homepage-row">
<label for="homepage">Homepage</label>
<?= $this->form->homepage->setDecorators(array('ViewHelper', 'Errors')); ?>
<?= $this->form->homepage->getDescription(); ?>
</div>
</div>
</div>
</form>
diff --git a/application/modules/admin/views/scripts/pages/index.phtml b/application/modules/admin/views/scripts/pages/index.phtml
index b94ecab..3266505 100644
--- a/application/modules/admin/views/scripts/pages/index.phtml
+++ b/application/modules/admin/views/scripts/pages/index.phtml
@@ -1,48 +1,48 @@
<div id="content-panel">
<h2>Pages</h2>
<div>
<table class="data" id="pages-table">
<thead>
<tr>
<td> </td>
<td>Slug</td>
<td>Title</td>
</tr>
</thead>
<tbody>
<?php foreach($this->pages as $page) : ?>
<tr>
<td class="controls">
- <?= $this->link("/fizzy/pages/edit/{$page['id']}", $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
+ <?= $this->link("/fizzy/pages/edit/{$page['id']}", $this->image('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page', 'escape' => false)); ?>
</td>
<td style="width: 200px;"><?= $page['slug'] ?></td>
<td><?= $page['title'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
- <?= $this->link('/fizzy/pages/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add page', array()); ?>
+ <?= $this->link('/fizzy/pages/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add page', array('escape' => false)); ?>
</li>
</ul>
<hr />
<div class="block">
<h2>About pages</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus laoreet fringilla eros in laoreet. Sed rhoncus aliquam accumsan. Nullam nec massa sed elit faucibus ultricies. Vivamus pharetra volutpat posuere. Aliquam a metus neque, et euismod odio. Suspendisse potenti. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eget metus lacus, quis rhoncus mauris. In sit amet aliquet felis. Aenean luctus ornare posuere. Fusce egestas, nisi nec mattis pretium, lorem lorem venenatis lectus, id ornare lacus justo in neque. Ut commodo risus eu justo vulputate a fringilla quam rhoncus. Curabitur fermentum neque in tellus adipiscing scelerisque.
</p>
</div>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/user/form.phtml b/application/modules/admin/views/scripts/user/form.phtml
index 5d0c32f..a7a0e9b 100644
--- a/application/modules/admin/views/scripts/user/form.phtml
+++ b/application/modules/admin/views/scripts/user/form.phtml
@@ -1,51 +1,57 @@
<form action="<?= $this->form->getAction(); ?>" name="UserForm" id="UserForm" method="post">
<div id="content-panel">
<h2>
<?= $this->user->isNew() ? 'Add user' : 'Edit user'; ?>
</h2>
<div class="form-panel">
<?= $this->form->id; ?>
<?= $this->form->username; ?>
<?= $this->form->displayname; ?>
<?= $this->form->password; ?>
<?= $this->form->password_confirm; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if (!$this->user->isNew()) : ?>
<li class="no-bg right">
- <?= $this->linkConfirm(
+ <?= $this->link(
'/fizzy/user/delete/' . $this->user->id,
- $this->img('fizzy_assets/images/icon/user--minus.png') . ' delete user',
- 'Are you sure you want to delete this user?',
- array('class' => 'delete')
+ $this->image('fizzy_assets/images/icon/user--minus.png') . ' delete user',
+ array(
+ 'class' => 'delete',
+ 'confirm' => 'Are you sure you want to delete this user?',
+ 'escape' => false
+ )
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/users',
- $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to users'
+ $this->image('/fizzy_assets/images/icon/edit-list.png') . ' back to users',
+ array (
+ 'escape' => false
+ )
); ?>
</li>
</ul>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/user/list.phtml b/application/modules/admin/views/scripts/user/list.phtml
index ffd4001..441bb56 100644
--- a/application/modules/admin/views/scripts/user/list.phtml
+++ b/application/modules/admin/views/scripts/user/list.phtml
@@ -1,39 +1,41 @@
<div id="content-panel">
<h2>Users</h2>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Username</td>
</tr>
</thead>
<tbody>
<?php foreach($this->users as $user) : ?>
<tr>
<td class="controls">
<?= $this->link(
- "/fizzy/user/edit/{$user['id']}",
- $this->img('/fizzy_assets/images/icon/user--pencil.png',
- array('alt' => 'edit icon'))
+ "/fizzy/user/edit/{$user['id']}",
+ $this->image('/fizzy_assets/images/icon/user--pencil.png', array('alt' => 'edit icon')),
+ array (
+ 'escape' => false
+ )
); ?>
</td>
<td><?= $user['username'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
- <?= $this->link('/fizzy/user/add', $this->img('/fizzy_assets/images/icon/user--plus.png') . ' Add user', array()); ?>
+ <?= $this->link('/fizzy/user/add', $this->image('/fizzy_assets/images/icon/user--plus.png') . ' Add user', array('escape' => false)); ?>
</li>
</ul>
</div>
diff --git a/library/Fizzy/View/Helper/Image.php b/library/Fizzy/View/Helper/Image.php
new file mode 100644
index 0000000..d9c2d45
--- /dev/null
+++ b/library/Fizzy/View/Helper/Image.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Class Fizzy_View_Helper_Image
+ * @package Fizzy
+ * @subpackage View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * View helper for generating image tags.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_View_Helper_Image extends Zend_View_Helper_HtmlElement
+{
+
+ /**
+ * Generates an html image tag. The path given is prefixed with the baseUrl
+ * of the request. This can be ignored if prependBase is set to false in the
+ * options array.
+ * The options array is used to generate html attributes for the tag.
+ * @param string $path
+ * @param array $options
+ * @return string
+ */
+ public function image($path, $options = array())
+ {
+ $prependBase = true;
+ if (isset($options['prependBase'])) {
+ $prependBase = (boolean) $options['prependBase'];
+ unset($options['prependBase']);
+ }
+
+ if ($prependBase) {
+ if (null == $this->view) {
+ $this->view = new Zend_View();
+ }
+ $path = $this->view->baseUrl($path);
+ }
+
+ $xhtml = '<img src="' . $path . '"' . $this->_htmlAttribs($options) . ' />';
+
+ return $xhtml;
+ }
+
+}
\ No newline at end of file
diff --git a/library/Fizzy/View/Helper/Link.php b/library/Fizzy/View/Helper/Link.php
new file mode 100644
index 0000000..f329447
--- /dev/null
+++ b/library/Fizzy/View/Helper/Link.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Class Fizzy_View_Helper_Link
+ * @package Fizzy
+ * @subpackage View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * View helper for generating a link tag.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_View_Helper_Link extends Zend_View_Helper_HtmlElement
+{
+
+ /**
+ * Construct a link tag. The passed url is prepended with the base url. This
+ * can be ignore by setting prependBase to false in the options.
+ *
+ * A javascript confirm dialog can be added to the link by specifying the
+ * confirm key in the options array. This text is converted to a javascript
+ * confirm dialog.
+ *
+ * Output escaping can be turned of by setting the escape options to false
+ * in the options array.
+ *
+ * @param string $url
+ * @param string $value
+ * @param array $options
+ * @return string
+ */
+ public function link($url, $value, $options = array())
+ {
+ $defaults = array('prependBase' => true, 'escape' => true);
+ $options += $defaults;
+
+ if (null === $this->view) {
+ $view = new Zend_View();
+ }
+
+ $escape = (boolean) $options['escape'];
+ // Remove the escape option so it doesn't appear as an html attribute
+ unset($options['escape']);
+
+ // Add base url if prependBase is true
+ if ((boolean) $options['prependBase']) {
+ $url = $this->view->baseUrl($url);
+ }
+ // Remove the prependBase option so it doesn't appear as an html attribute
+ unset($options['prependBase']);
+
+ // Check for confirm option
+ if (isset($options['confirm'])) {
+ $confirmText = $options['confirm'];
+ $confirm = "return confirm('{$this->view->escape($confirmText)}');";
+ unset($options['confirm']);
+
+ $onclick = '';
+ if (isset($options['onClick'])) {
+ $onclick = $options['onClick'];
+ unset($options['onClick']);
+ } else if (isset($options['onclick'])) {
+ $onclick = $options['onclick'];
+ unset($options['onclick']);
+ }
+
+ if (empty($onclick)) {
+ $onclick = $confirm;
+ }
+ else {
+ $onclick = $confirm . $onclick;
+ }
+
+ $options['onClick'] = $confirm;
+ }
+
+ // Construct the tag
+ $xhtml = '<a href="' . $url . '"' . $this->_htmlAttribs($options) . '>';
+ $xhtml .= ($escape) ? $this->view->escape($value) : $value;
+ $xhtml .= '</a>';
+
+ return $xhtml;
+ }
+
+}
\ No newline at end of file
|
jtietema/Fizzy
|
c68b9cb6674de192e08b79e6e0175f7c4bb1ab6f
|
removed relation Comments -> Posts for more flexibility
|
diff --git a/application/models/Post.php b/application/models/Post.php
index 075cbe1..562cc35 100644
--- a/application/models/Post.php
+++ b/application/models/Post.php
@@ -1,24 +1,31 @@
<?php
/**
* Post
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Post extends BasePost
{
const PUBLISHED = 2;
const PENDING_REVIEW = 1;
const DRAFT = 0;
public function isNew()
{
return empty($this->id);
}
+ public function comments()
+ {
+ $query = Doctrine_Query::create()->from('Comments')
+ ->where('post_id = ?', 'blog:'.$this->id)->orderBy('id DESC');
+ $comments = $query->execute();
+ return $comments;
+ }
}
\ No newline at end of file
diff --git a/application/models/generated/BaseComments.php b/application/models/generated/BaseComments.php
index 68c7282..d8dc7cf 100644
--- a/application/models/generated/BaseComments.php
+++ b/application/models/generated/BaseComments.php
@@ -1,64 +1,69 @@
<?php
/**
* BaseComments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
- * @property integer $post_id
+ * @property string $post_id
* @property string $body
* @property string $name
* @property string $email
* @property string $website
* @property timestamp $date
- * @property Post $Post
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseComments extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('comments');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
- $this->hasColumn('post_id', 'integer', 4, array(
- 'type' => 'integer',
- 'length' => '4',
+ $this->hasColumn('post_id', 'string', 100, array(
+ 'type' => 'string',
+ 'length' => '100',
));
$this->hasColumn('body', 'string', null, array(
'type' => 'string',
));
$this->hasColumn('name', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('email', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('website', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('date', 'timestamp', null, array(
'type' => 'timestamp',
));
+
+
+ $this->index('post_id_index', array(
+ 'fields' =>
+ array(
+ 0 => 'post_id',
+ ),
+ ));
}
public function setUp()
{
parent::setUp();
- $this->hasOne('Post', array(
- 'local' => 'post_id',
- 'foreign' => 'id'));
+
}
}
\ No newline at end of file
diff --git a/application/models/generated/BasePost.php b/application/models/generated/BasePost.php
index 5ef4bca..1a726b0 100644
--- a/application/models/generated/BasePost.php
+++ b/application/models/generated/BasePost.php
@@ -1,78 +1,73 @@
<?php
/**
* BasePost
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $title
* @property string $body
* @property timestamp $date
* @property integer $author
* @property integer $status
* @property boolean $comments
* @property integer $blog_id
* @property User $User
* @property Blog $Blog
- * @property Doctrine_Collection $Comments
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BasePost extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('post');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('body', 'string', null, array(
'type' => 'string',
));
$this->hasColumn('date', 'timestamp', null, array(
'type' => 'timestamp',
));
$this->hasColumn('author', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('status', 'integer', 1, array(
'type' => 'integer',
'length' => '1',
));
$this->hasColumn('comments', 'boolean', null, array(
'type' => 'boolean',
));
$this->hasColumn('blog_id', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('User', array(
'local' => 'author',
'foreign' => 'id'));
$this->hasOne('Blog', array(
'local' => 'blog_id',
'foreign' => 'id'));
-
- $this->hasMany('Comments', array(
- 'local' => 'id',
- 'foreign' => 'post_id'));
}
}
\ No newline at end of file
diff --git a/application/modules/default/views/scripts/index/index.phtml b/application/modules/default/views/scripts/index/index.phtml
index 613b458..33a167d 100644
--- a/application/modules/default/views/scripts/index/index.phtml
+++ b/application/modules/default/views/scripts/index/index.phtml
@@ -1,14 +1,14 @@
<?php foreach ($this->posts as $post): ?>
<div>
<div><?= $post->title ?></div>
<div><?= $post->date ?> - <?= $post->User->displayname ?></div>
<div><?= $post->body ?></div>
<div>
<div>Comments:</div>
- <?php foreach ($post->Comments as $comment): ?>
+ <?php foreach ($post->comments() as $comment): ?>
<div><?= $comment->name ?> - <?= $comment->date ?></div>
<div><?= $comment->body ?></div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 33832a1..42578cf 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,76 +1,74 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
displayname: string(255)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
status: integer(1)
comments: boolean
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
- post_id: integer(4)
+ post_id: string(100)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
- relations:
- Post:
- local: post_id
- foreign: id
- foreignAlias: Comments
+ indexes:
+ post_id_index:
+ fields: [post_id]
Setting:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
component: string(50)
setting_key: string(50)
value: string
label: string(255)
description: string
Contact:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
email: string(255)
body: string
date: datetime
\ No newline at end of file
|
jtietema/Fizzy
|
aa9ae6324f7a97da7bf2ac2eb0677d84753408d3
|
fixed notice in settings
|
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 716c266..0c220fa 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,190 +1,190 @@
<?php
/**
* Class Admin_IndexController
* @category Fizzy
* @package Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
// Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
// Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
// Contact
- if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')) {
+ if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')->value) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
// Settings
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Settings',
'route' => 'admin_settings',
'module' => 'admin',
'controller' => 'settings',
'action' => 'index',
'pages' => array ()
));
// Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
|
jtietema/Fizzy
|
c192cce9399abbad8929ea36e8e58a91753e95e7
|
added lots of missing license headers
|
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 1bccd8f..f337d3e 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,67 +1,85 @@
<?php
+/**
+ * Class Bootstrap
+ * @category Fizzy
+ * @package Fizzy_Bootstrap
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Description of Bootstrap
*
* @author jeroen
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$view->addHelperPath(
realpath(implode(DIRECTORY_SEPARATOR,
array(ROOT_PATH, 'library', 'ZendX', 'JQuery', 'View', 'Helper')
)), 'ZendX_JQuery_View_Helper');
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$this->bootstrap('FrontController');
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getResource('FrontController');
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
protected function _initRoutes()
{
$this->bootstrap('FrontController');
$router = $this->getContainer()->frontcontroller->getRouter();
$config = new Zend_Config_Ini(ROOT_PATH . '/configs/routes.ini');
$router->addConfig($config->{$this->getEnvironment()});
return $router;
}
}
diff --git a/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin.js b/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin.js
index 1690a17..d830a9e 100644
--- a/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin.js
+++ b/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin.js
@@ -1,82 +1,92 @@
/**
* TinyMCE plugin for the Fizzy Media Library
*
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
* @author Jeroen Tietema <[email protected]>
* @copyright Copyright 2009, Voidwalkers, All rights reserved.
*/
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('fizzyassets');
tinymce.create('tinymce.plugins.FizzyassetsPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('fizzyAssets', function() {
ed.windowManager.open({
//
file : url + '../../../../../../fizzy/media/assets',
width : 640 + parseInt(ed.getLang('fizzyassets.delta_width', 0)),
height : 480 + parseInt(ed.getLang('fizzyassets.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('fizzyassets', {
title : 'fizzyassets.desc',
cmd : 'fizzyAssets',
image : url + '/img/document.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('fizzyassets', n.nodeName == 'A');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Fizzy Assets plugin',
author : 'Jeroen Tietema',
authorurl : 'http://www.voidwalkers.nl',
infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('fizzyassets', tinymce.plugins.FizzyassetsPlugin);
})();
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin_src.js b/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin_src.js
index d2b7e40..fa7d8fe 100644
--- a/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin_src.js
+++ b/application/assets/js/tiny_mce/plugins/fizzyassets/editor_plugin_src.js
@@ -1,82 +1,92 @@
/**
* TinyMCE plugin for the Fizzy Media Library
*
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
* @author Jeroen Tietema <[email protected]>
* @copyright Copyright 2009, Voidwalkers, All rights reserved.
*/
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('fizzyassets');
tinymce.create('tinymce.plugins.FizzyassetsPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('fizzyMedia', function() {
ed.windowManager.open({
//
file : url + '../../../../../../fizzy/media/assets',
width : 640 + parseInt(ed.getLang('fizzyassets.delta_width', 0)),
height : 480 + parseInt(ed.getLang('fizzyassets.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('fizzyassets', {
title : 'fizzyassets.desc',
cmd : 'fizzyAssets',
image : url + '/img/media.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('fizzyassets', n.nodeName == 'A');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Fizzy Assets plugin',
author : 'Jeroen Tietema',
authorurl : 'http://www.voidwalkers.nl',
infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('fizzyassets', tinymce.plugins.FizzymediaPlugin);
})();
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzyassets/js/dialog.js b/application/assets/js/tiny_mce/plugins/fizzyassets/js/dialog.js
index d9cd651..8c38c31 100644
--- a/application/assets/js/tiny_mce/plugins/fizzyassets/js/dialog.js
+++ b/application/assets/js/tiny_mce/plugins/fizzyassets/js/dialog.js
@@ -1,71 +1,88 @@
+/**
+ * TinyMCE plugin for the Fizzy Media Library
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ * @copyright Copyright 2009, Voidwalkers, All rights reserved.
+ */
+
tinyMCEPopup.requireLangPack();
var selectedAsset = null;
var selectedElement = null;
function select(asset, element){
selectedAsset = asset;
if (selectedElement != null){
selectedElement.style.background = '#CCCCCC';
}
selectedElement = element;
selectedElement.style.background = '#5555ff';
}
var FizzyassetsDialog = {
init : function() {
var f = document.forms[0],
nl = f.elements,
ed = tinyMCEPopup.editor,
dom = ed.dom,
n = ed.selection.getNode();
/* check if there is an image selected. If so we edit that image
instead of inserting a new one */
if (n.nodeName == 'A'){
// set the asset properties
nl.alt.value = n.firstChild.data;
nl.insert.value = ed.getLang('update');
// select the asset
var href = dom.getAttrib(n, 'href');
var asset = document.getElementById(href);
select(href, asset);
} else if (!ed.selection.isCollapsed()){
nl.alt.value = ed.selection.getContent();
}
},
insert : function() {
if (selectedAsset === null){
alert('Please select an Asset.');
return;
}
// Insert the contents from the input into the document
var description = document.getElementById('alt').value;
if (description == ''){
alert('Please provide a description.');
return;
}
var assetTag = document.createElement('a');
assetTag.href = selectedAsset;
assetTag.appendChild(document.createTextNode(description));
// convert domnode to string
var div = document.createElement('div');
div.appendChild(assetTag);
var assetString = div.innerHTML;
var n = tinyMCEPopup.editor.selection.getNode();
if (n.nodeName == 'A'){
n.parentNode.replaceChild(assetTag, n);
} else {
tinyMCEPopup.editor.execCommand('mceInsertContent', false, assetString);
}
tinyMCEPopup.close();
}
};
tinyMCEPopup.onInit.add(FizzyassetsDialog.init, FizzyassetsDialog);
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
index f65d3cb..5cb945a 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
@@ -1,82 +1,92 @@
/**
* TinyMCE plugin for the Fizzy Media Library
*
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
* @author Jeroen Tietema <[email protected]>
* @copyright Copyright 2009, Voidwalkers, All rights reserved.
*/
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('fizzymedia');
tinymce.create('tinymce.plugins.FizzymediaPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('fizzyMedia', function() {
ed.windowManager.open({
//
file : url + '../../../../../../fizzy/media/gallery',
width : 640 + parseInt(ed.getLang('fizzymedia.delta_width', 0)),
height : 480 + parseInt(ed.getLang('fizzymedia.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('fizzymedia', {
title : 'fizzymedia.desc',
cmd : 'fizzyMedia',
image : url + '/img/media.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('fizzymedia', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Fizzy Media plugin',
author : 'Jeroen Tietema',
authorurl : 'http://www.voidwalkers.nl',
infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('fizzymedia', tinymce.plugins.FizzymediaPlugin);
})();
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js
index 4546639..89083de 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js
@@ -1,82 +1,92 @@
/**
* TinyMCE plugin for the Fizzy Media Library
*
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
* @author Jeroen Tietema <[email protected]>
* @copyright Copyright 2009, Voidwalkers, All rights reserved.
*/
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('fizzymedia');
tinymce.create('tinymce.plugins.FizzymediaPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('fizzyMedia', function() {
ed.windowManager.open({
//
file : url + '../../../../../../fizzy/media/gallery',
width : 640 + parseInt(ed.getLang('fizzymedia.delta_width', 0)),
height : 480 + parseInt(ed.getLang('fizzymedia.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('fizzymedia', {
title : 'fizzymedia.desc',
cmd : 'fizzyMedia',
image : url + '/img/example.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('fizzymedia', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Fizzy Media plugin',
author : 'Jeroen Tietema',
authorurl : 'http://www.voidwalkers.nl',
infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('fizzymedia', tinymce.plugins.FizzymediaPlugin);
})();
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
index 30f2141..0ae3a9e 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
@@ -1,122 +1,139 @@
+/**
+ * TinyMCE plugin for the Fizzy Media Library
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ * @copyright Copyright 2009, Voidwalkers, All rights reserved.
+ */
+
tinyMCEPopup.requireLangPack();
var selectedImage = null;
var selectedElement = null;
function select(image, element){
selectedImage = image;
if (selectedElement != null){
selectedElement.style.background = '#ffffff';
}
selectedElement = element;
selectedElement.style.background = '#5555ff';
}
var FizzymediaDialog = {
init : function() {
var f = document.forms[0],
nl = f.elements,
ed = tinyMCEPopup.editor,
dom = ed.dom,
n = ed.selection.getNode();
/* check if there is an image selected. If so we edit that image
instead of inserting a new one */
if (n.nodeName == 'IMG'){
// set the image properties
nl.width.value = dom.getAttrib(n, 'width');
nl.height.value = dom.getAttrib(n, 'height');
nl.alt.value = dom.getAttrib(n, 'alt');
// we use parseInt to strip the px part
nl.border.value = parseInt(n.style.borderWidth);
nl.marginTop.value = parseInt(n.style.marginTop);
nl.marginRight.value = parseInt(n.style.marginRight);
nl.marginBottom.value = parseInt(n.style.marginBottom);
nl.marginLeft.value = parseInt(n.style.marginLeft);
// determine which style attribute is the position
var position = 'none';
if (n.style.cssFloat == 'left' || n.style.cssFloat == 'right'){
position = n.style.cssFloat;
} else if (n.style.verticalAlign != ''){
position = n.style.verticalAlign;
}
// select the current position in the dropdown box
var selectBox = nl.position.options;
for (i in selectBox){
if (selectBox[i].value == position){
selectBox.selectedIndex = i;
}
}
nl.insert.value = ed.getLang('update');
// select the image
var src = dom.getAttrib(n, 'src');
var image = document.getElementById(src);
select(src, image);
}
},
insert : function() {
if (selectedImage === null){
alert('Please select an Image!');
return;
}
// Insert the contents from the input into the document
var width = document.getElementById('width').value;
var height = document.getElementById('height').value;
var border = document.getElementById('border').value;
var marginTop = document.getElementById('marginTop').value;
var marginLeft = document.getElementById('marginLeft').value;
var marginBottom = document.getElementById('marginBottom').value;
var marginRight = document.getElementById('marginRight').value;
var description = document.getElementById('alt').value;
var position = document.getElementById('position').value;
var imageTag = new Image();
imageTag.src = selectedImage;
imageTag.alt = description;
if (width != ''){
imageTag.width = width;
}
if (height != ''){
imageTag.height = height;
}
if (position == 'left' || position == 'right'){
imageTag.style.cssFloat = position;
} else if (position !== 'none' && position !== ''){
imageTag.style.verticalAlign = position;
}
if (border !== ''){
imageTag.style.borderStyle = 'solid';
imageTag.style.borderColor = 'black';
imageTag.style.borderWidth = border + 'px';
}
if (marginTop !== ''){
imageTag.style.marginTop = marginTop + 'px';
}
if (marginRight !== ''){
imageTag.style.marginRight = marginRight + 'px';
}
if (marginBottom !== ''){
imageTag.style.marginBottom = marginBottom + 'px';
}
if (marginLeft !== ''){
imageTag.style.marginLeft = marginLeft + 'px';
}
// convert domnode to string
var div = document.createElement('div');
div.appendChild(imageTag);
var imageString = div.innerHTML;
tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageString);
tinyMCEPopup.close();
}
};
tinyMCEPopup.onInit.add(FizzymediaDialog.init, FizzymediaDialog);
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
index c154b52..76f7a04 100644
--- a/application/modules/admin/controllers/AuthController.php
+++ b/application/modules/admin/controllers/AuthController.php
@@ -1,73 +1,91 @@
<?php
+/**
+ * Class Admin_AuthController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Admin_AuthController extends Fizzy_Controller
{
public function loginAction()
{
$form = $this->_getForm();
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$authAdapter = new Fizzy_Doctrine_AuthAdapter(
$form->username->getValue(), $form->password->getValue()
);
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('fizzy'));
$result = $auth->authenticate($authAdapter);
if($result->isValid()) {
$this->_redirect('/fizzy', array('prependBase' => true));
}
$messages = $result->getMessages();
$this->addErrorMessage(array_shift($messages));
$this->_redirect('/fizzy/login', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('login.phtml');
}
public function logoutAction()
{
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('fizzy'));
$auth->clearIdentity();
$this->_redirect('/fizzy', array('prependBase' => true));
}
protected function _getForm()
{
$formConfig = array (
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true
),
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Login',
'ignore' => true
)
)
)
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
public function postDispatch()
{
$this->_helper->layout->setLayout('login');
}
}
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
index e229efb..219be0f 100644
--- a/application/modules/admin/controllers/BlogsController.php
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -1,201 +1,219 @@
<?php
+/**
+ * Class Admin_BlogsController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Admin_BlogsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$blogs = Doctrine_Query::create()->from('Blog')->execute();
$this->view->blogs = $blogs;
}
public function blogAction()
{
$id = $this->_getParam('id', null);
$pageNumber = $this->_getParam('page', 1);
if (null === $id){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$query = Doctrine_Query::create()->from('Post')
->where('blog_id = ?', $id);
$paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($pageNumber);
$this->view->blog = $blog;
$this->view->paginator = $paginator;
}
public function addPostAction()
{
$blogId = $this->_getParam('blog_id', null);
if (null === $blogId){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
$this->view->form = $form = $this->_getPostForm();
$form->date->setValue(date('Y-m-d H:i:s'));
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$form->author->setValue($identity['id']);
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Add',
'ignore' => true
)));
$this->view->post = $post = new Post();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->blog_id = $blogId;
$post->save();
$this->_redirect('/fizzy/blog/' . $blogId);
}
$this->renderScript('blogs/post-form.phtml');
}
public function editPostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$form = $this->_getPostForm();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->comments = $form->comments->getValue();
$post->status = $form->status->getValue();
$post->save();
$this->addSuccessMessage("Post \"<strong>{$post->title}</strong>\" was successfully saved.");
$this->_redirect('fizzy/post/' . $postId . '/edit');
} else {
$form->title->setValue($post->title);
$form->body->setValue($post->body);
$form->author->setValue($post->author);
$form->date->setValue($post->date);
$form->comments->setValue($post->comments);
$form->status->setValue($post->status);
}
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Edit',
'ignore' => true,
)));
$this->view->form = $form;
$this->view->post = $post;
$this->renderScript('blogs/post-form.phtml');
}
public function deletePostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post->delete();
$this->_redirect('fizzy/blog/' . $post->Blog->id);
}
protected function _getPostForm()
{
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('title', array(
'label' => 'Title',
'required' => true,
)));
$form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
'label' => 'Date',
'required' => true,
'description' => 'The published date of this post.'
)));
$form->date->setJQueryParam('changeMonth', true);
$form->date->setJQueryParam('changeYear', true);
$form->date->setJQueryParam('dateFormat', 'yy-mm-dd');
$form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
'label' => 'Body',
'attribs' => array('style' => 'width: 100%;'),
)));
$form->addElement(new Zend_Form_Element_Select('author', array(
'label' => 'Author',
'multiOptions' => $this->_getUsers(),
'description' => 'The author of this post.'
)));
$form->addElement(new Zend_Form_Element_Checkbox('comments', array(
'label' => 'Allow comments',
'value' => true,
'description' => 'Are visitors allowed to comment on this post?'
)));
$form->addElement(new Zend_Form_Element_Select('status', array(
'label' => 'Status',
'multiOptions' => array(
0 => 'Draft',
1 => 'Pending review',
2 => 'Published'
),
'description' => 'Only published posts will show up on the website.'
)));
return $form;
}
protected function _getUsers()
{
$users = Doctrine_Query::create()->from('User')->execute();
$array = array();
foreach ($users as $user){
$array[$user->id] = $user->displayname;
}
return $array;
}
}
diff --git a/application/modules/admin/controllers/ContactController.php b/application/modules/admin/controllers/ContactController.php
index 5bb7d05..14f5387 100644
--- a/application/modules/admin/controllers/ContactController.php
+++ b/application/modules/admin/controllers/ContactController.php
@@ -1,54 +1,72 @@
<?php
+/**
+ * Class Admin_ContactController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Admin_ContactController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$this->view->messages = Doctrine_Core::getTable('Contact')->findAll();
}
public function showAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/contact', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('Contact')->where('id = ?', $id);
$message = $query->fetchOne();
if(null === $message) {
$this->addErrorMessage("Message with ID {$id} could not be found.");
$this->_redirect('/fizzy/contact', array('prependBase' => true));
}
$this->view->message = $message;
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/contact', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('Contact')->where('id = ?', $id);
$message = $query->fetchOne();
if(null === $message) {
$this->addErrorMessage("Message with ID {$id} could not be found.");
$this->_redirect('/fizzy/contact', array('prependBase' => true));
}
$success = $message->delete();
if ($success) {
$this->addSuccessMessage("Message was deleted");
} else {
$this->addErrorMessage("Message with ID {$id} could not be deleted.");
}
$this->_redirect('/fizzy/contact', array('prependBase' => true));
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 2ce0df3..0ddce3a 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,171 +1,190 @@
<?php
+/**
+ * Class Admin_IndexController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
// Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
// Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
// Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
// Contact
if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')) {
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact',
'route' => 'admin_contact',
'module' => 'admin',
'controller' => 'contact',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Contact show',
'route' => 'admin_contact_show',
'module' => 'admin',
'controller' => 'contact',
'action' => 'show',
))
)
));
}
// Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
// Settings
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Settings',
'route' => 'admin_settings',
'module' => 'admin',
'controller' => 'settings',
'action' => 'index',
'pages' => array ()
));
// Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
diff --git a/application/modules/admin/controllers/MediaController.php b/application/modules/admin/controllers/MediaController.php
index 0b4c400..ff8afd7 100644
--- a/application/modules/admin/controllers/MediaController.php
+++ b/application/modules/admin/controllers/MediaController.php
@@ -1,200 +1,218 @@
<?php
+/**
+ * Class Admin_MediaController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Description of Media
*
* @author mattijs
*/
class Admin_MediaController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* @todo implement overwrite checkbox
*/
public function indexAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
$form = $this->_getForm($uploadFolder);
if($this->_request->isPost()) {
if($form->isValid($_POST) && $form->file->receive()) {
$this->addSuccessMessage('File was successfully uploaded.');
}
else {
foreach($form->getErrorMessages() as $message) {
$this->addErrorMessage($message);
}
}
$this->_redirect('/fizzy/media');
}
# Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
# Render the view
$this->view->uploadFolder = $uploadFolder;
$this->view->files = $files;
$this->view->form = $form;
$this->view->type = $this->_request->getParam('type', 'list');
$this->renderScript('media.phtml');
}
public function displayAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
$type = $this->_getParam('type', 'list');
if($type == 'thumbnail') {
$script = 'media/thumbnails.phtml';
} else {
$script = 'media/list.phtml';
}
$this->renderScript($script);
}
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = ROOT_PATH . '/public/uploads/';
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
$this->addSuccessMessage('File was successfully deleted.');
}
}
$this->_redirect($this->view->baseUrl('/fizzy/media'));
}
/**
* Returns the form for file uploads
* @param string $uploadFolder
* @return Zend_Form
*/
protected function _getForm($uploadFolder)
{
$formConfig = array (
'action' => $this->view->baseUrl('/fizzy/media'),
'enctype' => 'multipart/form-data',
'elements' => array(
'file' => array (
'type' => 'file',
'options' => array (
'label' => 'File',
'description' => 'Choose a file to upload. The maximun file size is ' . str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), ini_get('upload_max_filesize')) . '.',
'required' => true,
'destination' => $uploadFolder,
)
),
/*'overwrite' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Overwrite existing?',
'description' => 'If this is checked any existing file with the same name will be overridden.',
'required' => false,
)
),*/
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Upload',
'ignore' => true,
)
)
),
);
return new Zend_Form(new Zend_Config($formConfig));
}
/**
* Action for the image picker popup
*/
public function galleryAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
// Parse all files in the upload directory
$files = array();
$imageTypes = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
if (in_array($fileInfo['type'], $imageTypes)) {
$files[] = (object) $fileInfo;
}
}
}
// Render the view
$this->view->files = $files;
$this->_helper->layout->disableLayout();
}
public function assetsAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
// Render the view
$this->view->files = $files;
$this->_helper->layout->disableLayout();
}
}
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index cd761a2..067de52 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,214 +1,232 @@
<?php
+/**
+ * Class Admin_PagesController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Admin_PagesController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$query = Doctrine_Query::create()->from('Page');
$pages = $query->fetchArray();
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->page = $page;
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page['id']), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->page = $page;
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null !== $page) {
$page->delete();
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$config = Zend_Registry::get('config');
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $page['id'],
)
),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
'attribs' => array('style' => 'width: 100%;'),
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => $this->_fetchFiles($config->paths->templatePath),
'value' => $page->getTemplate(),
'description' => 'You can select a different template to structure the text.'
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => $this->_fetchFiles($config->paths->layoutPath, false),
'value' => $page->getLayout(),
'description' => 'You can select a different layout to render the structured text in.'
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : '',
'description' => 'Check this box to make this page the default.'
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
$form = new Fizzy_Form();
$form->setOptions($formConfig);
$form->template->addDecorator('Description');
$form->layout->addDecorator('Description');
return $form;
}
/**
* Fetches a list of files from a given directory
*
* @param string $dir
* @return array
*/
protected function _fetchFiles($dir, $keepExtension = true)
{
$files = array();
$dir = new DirectoryIterator($dir);
foreach ($dir as $file) {
if($file->isDot()) {
continue;
}
$pieces = explode('.', $file->getFilename());
if ($keepExtension) {
$files[$file->getFilename()] = $pieces[0];
} else {
$files[$pieces[0]] = $pieces[0];
}
}
return $files;
}
}
diff --git a/application/modules/admin/controllers/SettingsController.php b/application/modules/admin/controllers/SettingsController.php
index 18e8033..23f611a 100644
--- a/application/modules/admin/controllers/SettingsController.php
+++ b/application/modules/admin/controllers/SettingsController.php
@@ -1,28 +1,47 @@
<?php
+/**
+ * Class Admin_SettingsController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
/**
* Class Admin_SettingsController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_SettingsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$settings = Setting::getAll();
$settingsByComponent = array();
foreach ($settings as $setting) {
if (isset($settingsByComponent[component])) {
$settingsByComponent[$setting->component] = array();
}
$settingsByComponent[$setting->component][] = $setting;
}
$this->view->settings = $settingsByComponent;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index 1e6eca7..3723575 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,147 +1,165 @@
<?php
+/**
+ * Class Admin_UserController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Admin_UserController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$query = Doctrine_Query::create()->from('User');
$users = $query->fetchArray();
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->user = $user;
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->id), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->user = $user;
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null !== $user) {
$user->delete();
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
$passwordConfirm = new Fizzy_Validate_EqualsField();
$passwordConfirm->setOppositeField('password_confirm');
$passwordConfirm->setFieldName('Password');
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $user->id
)
),
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
'validators' => array (
'usernameUnique'
)
)
),
'displayname' => array(
'type' => 'text',
'options' => array(
'label' => 'Display name',
'required' => true,
'value' => $user->displayname
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
'validators' => array (
$passwordConfirm
)
),
),
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
}
diff --git a/application/modules/admin/controllers/WebdavController.php b/application/modules/admin/controllers/WebdavController.php
index 434d11e..7ffc2cc 100644
--- a/application/modules/admin/controllers/WebdavController.php
+++ b/application/modules/admin/controllers/WebdavController.php
@@ -1,81 +1,99 @@
<?php
+/**
+ * Class Admin_WebdavController
+ * @category Fizzy
+ * @package Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Controller that handles WebDAV requests.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_WebdavController extends Zend_Controller_Action
{
/**
* Application config
* @var Zend_Config
*/
protected $_config = null;
public function init()
{
// Disable view rendering
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
// Get the application config
$this->_config = Zend_Registry::get('config');
}
/**
* Handles a WebDAV request.
*/
public function requestAction()
{
if (!isset($this->_config->resources->sabredav->enabled) ||
0 == $this->_config->resources->sabredav->enabled) {
// Render 404
$response = $this->getResponse();
$response->clearAllHeaders();
$response->clearBody();
$response->setHttpResponseCode(404);
$response->sendResponse();
return;
}
$baseUri = '/fizzy/webdav/';
$publicDir = ROOT_PATH . '/public/uploads';
$tmpDir = ROOT_PATH . '/data/tmp';
$auth = new Sabre_HTTP_BasicAuth();
$auth->setRealm('Fizzy');
$authResult = $auth->getUserPass();
if (false === $authResult) {
$auth->requireLogin();
die('Authentication required');
}
list($username, $password) = $authResult;
$authAdapter = new Fizzy_Doctrine_AuthAdapter($username, $password);
$authResult = $authAdapter->authenticate();
if ($authResult->getCode() !== Zend_Auth_Result::SUCCESS) {
$auth->requireLogin();
die('Authentication failed');
}
$publicDirObj = new Sabre_DAV_FS_Directory($publicDir);
$objectTree = new Sabre_DAV_ObjectTree($publicDirObj);
$server = new Sabre_DAV_Server($objectTree);
$server->setBaseUri($baseUri);
if (isset($this->_config->resources->sabredav->browser) &&
false != $this->_config->resources->sabredav->browser) {
$browser = new Sabre_DAV_Browser_Plugin();
$server->addPlugin($browser);
}
$server->exec();
}
}
\ No newline at end of file
diff --git a/application/modules/admin/views/helpers/FizzyMessages.php b/application/modules/admin/views/helpers/FizzyMessages.php
index b2c2039..fa1e9c0 100644
--- a/application/modules/admin/views/helpers/FizzyMessages.php
+++ b/application/modules/admin/views/helpers/FizzyMessages.php
@@ -1,70 +1,88 @@
<?php
+/**
+ * Class Admin_View_Helper_FizzyMessages
+ * @category Fizzy
+ * @package Admin_View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Checks the session for message placed by Fizzy.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_View_Helper_FizzyMessages extends Zend_View_Helper_Abstract
{
protected $_translator = null;
/**
* A formatted list of status messages from Fizzy.
* @return string
*/
public function fizzyMessages($translator = null)
{
$this->_translator = $translator;
$output = '';
$messages = $this->_getMessages();
if(0 < $messages) {
$statusMessages = array();
# Filter out the Fizzy messages
foreach($messages as $message) {
if(is_array($message)) {
$statusMessages[$message['type']][] = $this->_translateMessage($message['message']);
}
}
# Format the messages for the statusses
foreach($statusMessages as $type => $messages) {
$output .= "<div class=\"message {$type}\">\n<ul>\n";
foreach($messages as $message) {
$output .= "<li>{$message}</li>\n";
}
$output .= "\n</ul>\n";
$output .= "</div>";
}
}
return $output;
}
/**
* Gets the messages array from the Flash Messenger controller plugin.
* @return array
*/
protected function _getMessages()
{
return Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->getMessages();
}
/**
* Tries to translate a message with the provided translator.
* @param string $message
* @return string
*/
protected function _translateMessage($message)
{
if(null !== $this->_translator) {
$message = $this->_translator->_($message);
}
return $message;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/views/helpers/Img.php b/application/modules/admin/views/helpers/Img.php
index 2d886b7..5fe6c73 100644
--- a/application/modules/admin/views/helpers/Img.php
+++ b/application/modules/admin/views/helpers/Img.php
@@ -1,12 +1,30 @@
<?php
+/**
+ * Class Admin_View_Helper_Img
+ * @category Fizzy
+ * @package Admin_View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Zend_View_Helper_Img extends Zend_View_Helper_HtmlElement
{
public function img($image, array $attribs = array())
{
$xhtml = '<img %s src="%s" />';
return sprintf($xhtml, $this->_htmlAttribs($attribs), $this->view->baseUrl($image));
}
}
diff --git a/application/modules/admin/views/helpers/Link.php b/application/modules/admin/views/helpers/Link.php
index 1d42c23..5613c61 100644
--- a/application/modules/admin/views/helpers/Link.php
+++ b/application/modules/admin/views/helpers/Link.php
@@ -1,13 +1,31 @@
<?php
+/**
+ * Class Admin_View_Helper_Link
+ * @category Fizzy
+ * @package Admin_View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Zend_View_Helper_Link extends Zend_View_Helper_HtmlElement
{
public function link($url, $text, array $attribs = array())
{
$xhtml = '<a href="%s" %s>%s</a>';
return sprintf($xhtml, $this->view->baseUrl($url), $this->_htmlAttribs($attribs), $text);
}
}
\ No newline at end of file
diff --git a/application/modules/admin/views/helpers/LinkConfirm.php b/application/modules/admin/views/helpers/LinkConfirm.php
index 9e9b6be..e064d64 100644
--- a/application/modules/admin/views/helpers/LinkConfirm.php
+++ b/application/modules/admin/views/helpers/LinkConfirm.php
@@ -1,15 +1,33 @@
<?php
+/**
+ * Class Admin_View_Helper_LinkConfirm
+ * @category Fizzy
+ * @package Admin_View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Zend_View_Helper_LinkConfirm extends Zend_View_Helper_HtmlElement
{
public function linkConfirm($url, $text, $confirm, array $attribs = array())
{
$html = '<a href="%s" onClick="return confirm(\'%s\');"%s>%s</a>';
$attributes = $this->_htmlAttribs($attribs);
return sprintf($html, $this->view->baseUrl($url), $confirm, $attributes, $text);
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Autoloader.php b/library/Fizzy/Autoloader.php
index 23902ca..988793b 100644
--- a/library/Fizzy/Autoloader.php
+++ b/library/Fizzy/Autoloader.php
@@ -1,29 +1,46 @@
<?php
+/**
+ * Class Fizzy_Autoloader
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Autoloading class for Fizzy models.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Autoloader
{
/**
* Autoload function for model classes
* @param string $class
* @return boolean
*/
public static function models($class)
{
$modelFile = ucfirst($class) . '.php';
$config = Zend_Registry::get('config');
$modelDirectory = $config->paths->models;
$modelsPath = $modelDirectory . DIRECTORY_SEPARATOR . $modelFile;
if(is_file($modelsPath)) {
require $modelsPath;
return true;
}
return false;
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Doctrine/AuthAdapter.php b/library/Fizzy/Doctrine/AuthAdapter.php
index ac44fde..e4c0e56 100644
--- a/library/Fizzy/Doctrine/AuthAdapter.php
+++ b/library/Fizzy/Doctrine/AuthAdapter.php
@@ -1,71 +1,90 @@
<?php
+/**
+ * Class Fizzy_Doctrine_AuthAdapter
+ * @category Fizzy
+ * @package Fizzy_Doctrine
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
/**
* Auth adapter for Doctrine backend
**/
class Fizzy_Doctrine_AuthAdapter implements Zend_Auth_Adapter_Interface
{
protected $_username = null;
protected $_password = null;
protected $_modelClass = 'User';
public function __construct($username = null, $password = null)
{
if (null !== $username) {
$this->setUsername($username);
}
if (null !== $password) {
$this->setPassword($password);
}
}
public function setUsername($username)
{
$this->_username = $username;
return $this;
}
public function setPassword($password)
{
$this->_password = $password;
return $this;
}
public function setModelClass($modelClass)
{
$this->_modelClass = $modelClass;
return $this;
}
public function authenticate()
{
# Check the username
$query = Doctrine_Query::create()->from($this->_modelClass)->where('username = ?', $this->_username);
$users = $query->fetchArray();
if(0 === count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null, array('Username not found.'));
}
else if(1 < count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS,
null, array('Username did not match one instance.'));
}
$user = $users[0];
# Check the password
$password = $this->_password;
$encryption = strtolower($user['encryption']);
if(!empty($encryption) && 'plain' !== $encryption && in_array($encryption, array('md5', 'sha1'))) {
$password = $encryption($password);
}
if($password !== $user['password']) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
null, array('Invalid password.'));
}
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);
}
}
diff --git a/library/Fizzy/Json/Client.php b/library/Fizzy/Json/Client.php
index b8b8c1e..17e4007 100644
--- a/library/Fizzy/Json/Client.php
+++ b/library/Fizzy/Json/Client.php
@@ -1,243 +1,262 @@
<?php
+/**
+ * Class Fizzy_Json_Client
+ * @category Fizzy
+ * @package Fizzy_Json
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
require_once 'Zend/Json.php';
require_once 'Zend/Http/Client.php';
require_once 'Fizzy/Json/Client/Exception.php';
require_once 'Fizzy/Json/Client/Response.php';
/**
* This class makes talking to Zend_Json_Server (or other JSON-RPC servers) a
* breeze. It wraps the Zend_Http_Client en only exposes some convenience
* methods.
*
* @author Jeroen Tietema <[email protected]>
*/
class Fizzy_Json_Client
{
/**
* The url of the Json server.
*/
protected $_url = null;
/**
* The id is copied from the request to the response on the server and can
* be used to identify specific responses when you are handeling multiple
* to the same method.
* @var mixed
*/
protected $_id = null;
/**
* The method to be called on the JSON-RPC server. Eg. 'hellworld'. When using
* namespaces the namespace is prepend with a dot on the end. E.g.
* 'helloworldnamespace.sayhello'
* @var string
*/
protected $_method = null;
/**
* A list of parameters passed to the method.
* @var array
*/
protected $_params = array();
/**
* Cached instance of Zend_Http_Client
* @var Zend_Http_Client|null
*/
protected $_httpClient = null;
/**
* Array of strings with methodnames support by the __call magic method.
* This allows for a more native API feel.
* @var array
*/
protected $_allowedMethods = array();
/**
* Returns the Url of the JSON-RPC server
*
* @return string
*/
public function getUrl()
{
return $this->_url;
}
/**
* Set the Url of the JSON-RPC server.
*
* @param string $url
* @return Fizzy_Json_Client
*/
public function setUrl($url)
{
$this->_url = $url;
return $this;
}
/**
* Returns the Id give to the next method call.
* @return mixed
*/
public function getId()
{
return $this->_id;
}
/**
* Set the id for the next request to the JSON-RPC server. You can use this
* id to match request en response.
*
* @param mixed $id
* @return Fizzy_Json_Client
*/
public function setId($id)
{
$this->_id = $id;
return $this;
}
/**
* Set the method to be called on the JSON-RPC server.
*
* @param string $method
* @return Fizzy_Json_Client
*/
public function setMethod($method)
{
$this->_method = $method;
return $this;
}
/**
* Returns the parameters given to the method.
*
* @return array
*/
public function getParams()
{
return $this->_params;
}
/**
* Sets the parameters to the method called on the JSON-RPC server. Make sure
* all the parameters are convertable to Json format.
*
* @param array $params
* @return Fizzy_Json_Client
*/
public function setParams(Array $params)
{
$this->_params = $params;
return $this;
}
/**
* Returns the current http object.
*
* @return Zend_Http_Client|null
*/
public function getHttpClient()
{
return $this->_httpClient;
}
/**
* Allows to set your own instance of the http client used for making requests
*
* @param Zend_Http_Client $httpClient
* @return Fizzy_Json_Client
*/
public function setHttpClient(Zend_Http_Client $httpClient)
{
$this->_httpClient = $httpClient;
return $this;
}
/**
* Make the request to the JSON-RPC server.
*
* @return Fizzy_Json_Client_Response
*/
public function request()
{
if ($this->_httpClient === null || !($this->_httpClient instanceof Zend_Http_Client)) {
if ($this->_url === null) {
throw new Fizzy_Json_Client_Exception('No Url set.');
}
if (empty($this->_method)) {
throw new Fizzy_Json_Client_Exception('No method set.');
}
$this->_httpClient = new Zend_Http_Client();
$this->_httpClient->setMethod(Zend_Http_Client::POST);
}
$this->_httpClient->setUri($this->_url);
$json = array(
'id' => $this->_id,
'method' => $this->_method,
'params' => $this->_params
);
$this->_httpClient->setRawData(Zend_Json::encode($json));
$rawResponse = $this->_httpClient->request();
$response = new Fizzy_Json_Client_Response($rawResponse);
return $response;
}
/**
* All allowed methods for using with __call
*
* @return <type>
*/
public function getAllowedMethods()
{
return $this->_allowedMethods;
}
/**
* Sets all allowed methods for use with __call. This allows you to call
* remote methods in a native like way.
*
* @param array $methods
*/
public function setAllowedMethods(Array $methods)
{
$this->_allowedMethods = $methods;
}
/**
* Proxies all calls to the webserver when the methods are in allowedMethods array
*
* @param string $name
* @param array $args
* @return Fizzy_Json_Client_Response
*/
public function __call($name, $args)
{
if (!in_array($name, $this->_allowedMethods)){
throw new Fizzy_Json_Client_Exception(
'Method not supported. Did you set it with setAllowedMethods?'
);
}
$this->setMethod($name);
$this->setParams($args);
$response = $this->request();
if ($response->isError()) {
throw new Fizzy_Json_Client_Exception($response->getError());
}
return $response->getResult();
}
}
diff --git a/library/Fizzy/Json/Client/Exception.php b/library/Fizzy/Json/Client/Exception.php
index d17bc01..da123c6 100644
--- a/library/Fizzy/Json/Client/Exception.php
+++ b/library/Fizzy/Json/Client/Exception.php
@@ -1,5 +1,24 @@
<?php
+/**
+ * Class Fizzy_Json_Client_Exception
+ * @category Fizzy
+ * @package Fizzy_Json
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
require_once 'Fizzy/Exception.php';
class Fizzy_Json_Client_Exception extends Fizzy_Exception
{}
diff --git a/library/Fizzy/Json/Client/Response.php b/library/Fizzy/Json/Client/Response.php
index 55b8e43..db10d5d 100644
--- a/library/Fizzy/Json/Client/Response.php
+++ b/library/Fizzy/Json/Client/Response.php
@@ -1,48 +1,67 @@
<?php
+/**
+ * Class Fizzy_Json_Client_Response
+ * @category Fizzy
+ * @package Fizzy_Json
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
/**
* This class parses a Zend_Http_Response containing a JSON-RPC response.
*
* @author jeroen
* @todo Should this extend Zend_Json_Response ???
*/
class Fizzy_Json_Client_Response {
protected $_error = null;
protected $_id = null;
protected $_result = null;
public function __construct(Zend_Http_Response $response)
{
$body = $response->getRawBody();
$json = Zend_Json::decode($body);
$this->_id = $json['id'];
if (null !== $json['error']){
$this->_error = $json['error'];
} else {
$this->_result = $json['result'];
}
}
public function getId()
{
return $this->_id;
}
public function getResult()
{
return $this->_result;
}
public function getError()
{
return $this->_error;
}
public function isError()
{
return (null !== $this->_error);
}
}
diff --git a/library/Fizzy/Layout/ControllerPlugin.php b/library/Fizzy/Layout/ControllerPlugin.php
index faf6ae2..5f58904 100644
--- a/library/Fizzy/Layout/ControllerPlugin.php
+++ b/library/Fizzy/Layout/ControllerPlugin.php
@@ -1,23 +1,41 @@
<?php
+/**
+ * Class Fizzy_Layout_ControllerPlugin
+ * @category Fizzy
+ * @package Fizzy_Layout
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/** Zend_Controller_Plugin_Abstract */
require_once 'Zend/Controller/Plugin/Abstract.php';
class Fizzy_Layout_ControllerPlugin extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$moduleName = $this->getRequest()->getModuleName();
if(empty($moduleName)) {
$moduleName = 'default';
}
$layoutPath = APPLICATION_PATH . '/modules/' . $moduleName . '/views/layouts/';
$layout = Zend_Layout::getMvcInstance();
$layout->setLayoutPath($layoutPath);
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Paginator/Adapter/DoctrineQuery.php b/library/Fizzy/Paginator/Adapter/DoctrineQuery.php
index 21996df..00d2957 100644
--- a/library/Fizzy/Paginator/Adapter/DoctrineQuery.php
+++ b/library/Fizzy/Paginator/Adapter/DoctrineQuery.php
@@ -1,28 +1,47 @@
<?php
+/**
+ * Class Fizzy_Paginator_Adapter_DoctrineQuery
+ * @category Fizzy
+ * @package Fizzy_Paginator
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
class Fizzy_Paginator_Adapter_DoctrineQuery
implements Zend_Paginator_Adapter_Interface
{
protected $_query;
protected $_count_query;
public function __construct($query)
{
$this->_query = $query;
$this->_count_query = clone $query;
}
public function getItems($offset, $itemsPerPage)
{
return $this->_query
->limit($itemsPerPage)
->offset($offset)
->execute();
}
public function count()
{
return $this->_count_query->count();
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Resource/Doctrine.php b/library/Fizzy/Resource/Doctrine.php
index 0d3db60..a32271d 100644
--- a/library/Fizzy/Resource/Doctrine.php
+++ b/library/Fizzy/Resource/Doctrine.php
@@ -1,198 +1,216 @@
<?php
+/**
+ * Class Fizzy_Resource_Doctrine
+ * @category Fizzy
+ * @package Fizzy_Resource
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Resource for bootstrapping Doctrine
*
* @author Mattijs Hoitink <[email protected]>
* @todo enable binding models to a connection
* @todo Add support for connection options (as array)
*/
class Fizzy_Resource_Doctrine extends Zend_Application_Resource_ResourceAbstract
{
/**
* Doctrine_Manager instance
* @var Doctrine_Manager
*/
protected $_manager = null;
/** **/
/**
* Initializes the Doctrine Resource. This is done in four steps:
* <ul>
* <li>Register Doctrines own autoloader with the Zend_Loader stack</li>
* <li>Instantiate the Doctrine_Manager</li>
* <li>Open defined connections</li>
* <li>Load model paths</li>
* </ul>
* @return Doctrine_Manager
*/
public function init()
{
// Get the Resource options
$options = $this->getOptions();
// Register the Doctrine autoloader
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$autoloader->pushAutoloader(array('Doctrine_Core', 'modelsAutoload'));
// Initialize the Doctrine Manager
$this->_manager = Doctrine_Manager::getInstance();
// Check for manager attributes in the options
if(array_key_exists('manager', $options)) {
$managerOptions = $options['manager'];
if(array_key_exists('attributes', $managerOptions) && is_array($managerOptions['attributes'])) {
$this->_setManagerAttributes($managerOptions['attributes']);
}
}
// Open defined connections
if(isset($options['connections']) && is_array($options['connections']) && !empty($options['connections'])) {
foreach($options['connections'] as $connectionName => $connectionOptions) {
$this->_openConnection($connectionName, $connectionOptions);
}
}
// Load models
if(array_key_exists('paths', $options)) {
$pathsOptions = $options['paths'];
if(array_key_exists('models_path', $pathsOptions) && !empty($pathsOptions['models_path'])) {
$this->_loadModels($pathsOptions['models_path']);
}
}
return $this->_manager;
}
/**
* Sets attributes on the Doctrine_Manager. Doctrine constants are supported
* and can be supplied in lower or upper case. Doctrine constants and arrays
* as values are also supported.
* @param array $attributes
*/
protected function _setManagerAttributes(array $attributes)
{
$reflect = new ReflectionClass('Doctrine');
$doctrineConstants = $reflect->getConstants();
$manager = Doctrine_Manager::getInstance();
foreach($attributes as $attribute => $value)
{
if (!array_key_exists(strtoupper($attribute), $doctrineConstants)) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Invalid Doctrine_Manager attribute.');
}
// Get the value for the attribute
$attributeKey = $doctrineConstants[strtoupper($attribute)];
// Check if the attribute value is a doctrine constant as well
if(array_key_exists(strtoupper($value), $doctrineConstants)) {
$attributeValue = $doctrineConstants[strtoupper($value)];
}
// Check if the value is an array itself
else if(is_array($value)) {
$attributeValue = array();
foreach($value as $subKey => $subValue) {
$attributeValue[$subKey] = $subValue;
}
}
else {
$attributeValue = $value;
}
$manager->setAttribute($attributeKey, $attributeValue);
}
}
/**
* Opens a connection with the provided options.
* @param string $name
* @param array $options
*/
protected function _openConnection($name, array $options)
{
$dsn = (is_string($options['dsn'])) ? $options['dsn'] : $this->_constructDsn($options['dsn']);
// Initialize a connection
Doctrine_Manager::connection($dsn, $name);
}
/**
* Loads model classes for Doctrine. The path can be supplied as a string or
* as an array.
* @param string|array $modelsPath
*/
protected function _loadModels($modelsPath)
{
if(is_string($modelsPath)) {
Doctrine::loadModels($modelsPath);
}
else if(is_array($modelsPath)) {
foreach($modelsPath as $path) {
Doctrine::loadModels($path);
}
}
else {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Invalid Doctrine model_path option.');
}
}
/**
* Construct a DSN from an array.
* Supported keywords:
* <ul>
* <li>phptype</li>
* <li>dbsyntax</li>
* <li>protocol</li>
* <li>hostspec</li>
* <li>database</li>
* <li>username</li>
* <li>password</li>
* <li>option</li>
* </ul>
* @param array $options
* @link http://www.doctrine-project.org/documentation/manual/1_1/en/introduction-to-connections#dsn,-the-data-source-name
*/
protected function _constructDsn($options)
{
$dsn = '';
if(!isset($options['phptype'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The phptype options is manditory for connection specification.');
}
else if(!isset($option['username'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The username options is manditory for connection specification.');
}
else if(!isset($options['hostspec'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The hostspec options is manditory for connection specification.');
}
else if(!isset($options['database'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The database options is manditory for connection specification.');
}
$dsn .= $options['phptype'] . '://' . $options['username'];
if(isset($options['password'])) {
$dsn .= ':' . $options['password'];
}
$dsn .= '@';
if(isset($options['protocol'])) {
$dsn .= $options['protocol'] . '+';
}
$dsn .= $options['hostspec'] . '/' . $options['database'];
return $dsn;
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Resource/Sabredav.php b/library/Fizzy/Resource/Sabredav.php
index 8ca807a..7061537 100644
--- a/library/Fizzy/Resource/Sabredav.php
+++ b/library/Fizzy/Resource/Sabredav.php
@@ -1,21 +1,39 @@
<?php
+/**
+ * Class Fizzy_Resource_Sabredav
+ * @category Fizzy
+ * @package Fizzy_Resource
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Fizzy_Resource_Sabredav extends Zend_Application_Resource_ResourceAbstract
{
public function init()
{
$options = $this->getOptions();
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array($this, 'autoload'));
}
public static function autoload($className)
{
if(strpos($className,'Sabre_')===0) {
include str_replace('_','/',$className) . '.php';
}
}
}
\ No newline at end of file
diff --git a/library/Fizzy/Version.php b/library/Fizzy/Version.php
index 254a960..ac33809 100644
--- a/library/Fizzy/Version.php
+++ b/library/Fizzy/Version.php
@@ -1,5 +1,23 @@
<?php
+/**
+ * Class Fizzy_Version
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
final class Fizzy_Version
{
const VERSION = '2.0.0-dev';
}
diff --git a/library/Fizzy/View/Helper/Wysiwyg.php b/library/Fizzy/View/Helper/Wysiwyg.php
index b85d64c..0eed1fe 100644
--- a/library/Fizzy/View/Helper/Wysiwyg.php
+++ b/library/Fizzy/View/Helper/Wysiwyg.php
@@ -1,89 +1,107 @@
<?php
+/**
+ * Class Fizzy_View_Helper_Wysiwyg
+ * @category Fizzy
+ * @package Fizzy_View
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a wysiwyg textarea element
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_View_Helper_Wysiwyg extends Zend_View_Helper_FormElement
{
/**
* The default number of rows for a textarea.
*
* @access public
*
* @var int
*/
public $rows = 24;
/**
* The default number of columns for a textarea.
*
* @access public
*
* @var int
*/
public $cols = 80;
/**
* Generates a 'textarea' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @param boolean
*
* @return string The element XHTML.
*/
public function wysiwyg($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
/*
if ($enabled) {
// disabled.
$disabled = ' disabled="disabled"';
}*/
// Make sure that there are 'rows' and 'cols' values
// as required by the spec. noted by Orjan Persson.
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
// build the element
$xhtml = '<div class="wysiwyg">'
. '<div class="wysiwyg-editor">'
. '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>'
. '</div>'
. '<div class="wysiwyg-toggle"></div>'
. '<script type="text/javascript">'
. 'fizzy.wysiwyg.register("'.$this->view->escape($id).'");'
. '</script>'
. '</div>';
return $xhtml;
}
}
|
jtietema/Fizzy
|
296bc3f0863e68d304370948b15f577a75bccf54
|
styling version numbers
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index fd5a54f..575a8d9 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,491 +1,487 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
-#version-panel {
- text-align: center;
- margin-top: 25px;
-}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
\ No newline at end of file
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 4fe4911..bb84c83 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,78 +1,76 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<?= $this->jQuery()->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<div id="main-panel">
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
- (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a><br />
- </div>
- <div id="version-panel">
- Fizzy <?= Fizzy_Version::VERSION ?>
+ Fizzy <?= Fizzy_Version::VERSION ?>
running on
Zend Framework <?= Zend_Version::VERSION ?>
and
- Doctrine <?= Doctrine::VERSION ?>
+ Doctrine <?= Doctrine::VERSION ?>
+ (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a><br />
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
|
jtietema/Fizzy
|
263444d5a6e94589628366aaa9520dad34132a90
|
Basic contact log && Setting change
|
diff --git a/application/assets/css/tables.css b/application/assets/css/tables.css
index b2b87f7..a9bd7b3 100644
--- a/application/assets/css/tables.css
+++ b/application/assets/css/tables.css
@@ -1,131 +1,164 @@
/**
* Fizzy Tables stylesheet for theme 2.0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* DATA TABLE */
table.data {
width: 100%;
}
table.data td, table.data th {
padding: 0.4em;
}
table.data thead tr {
-moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
}
table.data thead td, table.data thead th {
font-weight: bold;
text-shadow: 2px 1px 0px #CCCCCC;
background-color: #E4E4E4;
border-bottom: 1px solid #ADADAD;
}
table.data tbody > tr:first-child td {
padding: 0.8em 0.4em 0.4em 0.4em;
}
table.data tbody tr:hover {
background-color: #F9F9F9;
}
table.data tbody td {
border-collapse: collapse;
border: 1px solid #EFEFEF;
}
table.data tbody tr.even td {
background-color: #F9F9F9;
}
table.data tbody tr.odd td {
}
table.data tbody td.controls {
width: 25px;
text-align: center;
}
/* DATA TABLE */
/* ********************** */
/* ********************** */
/* DETAILS TABLE */
table.details {
width: 100%;
border-bottom: 1px solid #555555;
}
table.details thead th {
padding: 0.5em 1em;
background-color: #E4E4E4;
border: 1px solid #555555;
font-size: 120%;
font-weight: bold;
-moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
}
table.details tbody th {
padding: 0.4em;
}
table.details tbody td.label, table.details tbody th {
width: 8em;
background-color: #DDDDDD;
border: 1px solid #555555;
font-weight: bold;
}
table.details tbody td, table.details tbody td.content {
background-color: #ECEEEC;
padding: 0.4em 0.8em;
border-right: 1px solid #555555;
}
table.details tr.odd td {}
table.details tr.even td {
background-color: #E1E1E1;
}
/* DETAILS TABLE */
/* ********************** */
/* ********************** */
/* MEDIA TABLE */
table.media {
width: 100%;
}
table.media td {
padding: 0.4em;
}
table.media tbody tr.even td {
background-color: #DDDDDD;
}
table.media tbody tr.odd td {}
table.media tbody td {
padding: 0.6em 0.4em;
border-bottom: 1px solid #EFEFEF;
}
table.media td.controls {
width: 25px;
text-align: center;
}
table.media td.size {
width: 100px;
}
/* MEDIA TABLE */
+/* ********************** */
+
+/* ********************** */
+/* SETTINGS TABLE */
+
+table.settings {
+ width: 100%;
+}
+
+table.settings th, table.settings td {
+ padding: 0.4em;
+}
+
+table.settings tbody th {
+ -moz-box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.2);
+ -webkit-box-shadow: 0 4px 4px -1px rgba(0,0,0,0.2);
+ font-weight: bold;
+ text-shadow: 2px 1px 0px #CCCCCC;
+ background-color: #E4E4E4;
+ border-bottom: 1px solid #ADADAD;
+}
+
+table.settings tbody td {
+ border-collapse: collapse;
+ border: 1px solid #EFEFEF;
+}
+
+table.settings tbody td.label {
+ width: 200px;
+ vertical-align: top;
+}
+
+/* SETTINGS TABLE */
/* ********************** */
\ No newline at end of file
diff --git a/application/models/Contact.php b/application/models/Contact.php
new file mode 100644
index 0000000..49d0fb5
--- /dev/null
+++ b/application/models/Contact.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Class Contact
+ * @package Fizzy
+ * @category Model
+ */
+
+/**
+ * Model class for contact requests
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Contact extends BaseContact
+{
+
+ /**
+ * Sends the contact request to the configured contact email address.
+ *
+ * @throws Exception when contact email is not configured
+ */
+ public function send()
+ {
+
+ $contactEmail = Setting::getKey('address', 'contact');
+
+ if (null === $contactEmail) {
+ throw new Exception('Contact email not configured');
+ }
+
+ $mail = new Zend_Mail();
+ $mail->setSubject('Contact request')
+ ->setFrom($this->email, $this->name)
+ ->setBodyText($this->body)
+ ->addTo($contactEmail)
+ ->send();
+ }
+
+}
\ No newline at end of file
diff --git a/application/models/Setting.php b/application/models/Setting.php
index 0891c29..34643ee 100644
--- a/application/models/Setting.php
+++ b/application/models/Setting.php
@@ -1,43 +1,76 @@
<?php
/**
* Setting
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Setting extends BaseSetting
{
public static $_settings = null;
public static function getAll($reload = false)
{
if (null === self::$_settings || $reload) {
$settings = array();
foreach (Doctrine_Core::getTable('Setting')->findAll() as $setting) {
- $settings[$setting->setting_key] = $setting;
+ if (!isset($settings[$setting->component])) {
+ $settings[$setting->component] = array();
+ }
+ $settings[$setting->component][$setting->setting_key] = $setting;
}
+
self::$_settings = $settings;
}
return self::$_settings;
}
- public static function getKey($key, $reload = false)
+ /**
+ * Returns one or more settings for a given key. When no component is specified
+ * an array with settings will be returned.
+ * @param string $key
+ * @param string $component
+ * @param boolean $reload
+ * @return string|array
+ */
+ public static function getKey($key, $component = null, $reload = false)
{
$settings = self::getAll($reload);
- return isset($settings[$key]) ? $settings[$key] : null;
+ if (null === $component) {
+ $matched = array();
+
+ foreach ($settings as $componentSettings) {
+ foreach ($componentSettings as $setting) {
+ if ($key === $setting->setting_key) {
+ $matched[] = $setting;
+ }
+ }
+ }
+
+ return $matched;
+ }
+ else {
+ if (!isset($settings[$component]) || empty($settings[$component])) {
+ return null;
+ }
+
+ return isset($settings[$component][$key]) ? $settings[$component][$key] : null;
+ }
+
+ return null;
}
public function isNew()
{
return empty($this->id);
}
}
\ No newline at end of file
diff --git a/application/models/generated/BaseContact.php b/application/models/generated/BaseContact.php
new file mode 100644
index 0000000..3acb78f
--- /dev/null
+++ b/application/models/generated/BaseContact.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * BaseContact
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $name
+ * @property string $email
+ * @property string $body
+ * @property datetime $date
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BaseContact extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('contact');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('name', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('email', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('body', 'string', null, array(
+ 'type' => 'string',
+ ));
+ $this->hasColumn('date', 'datetime', null, array(
+ 'type' => 'datetime',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ }
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/ContactController.php b/application/modules/admin/controllers/ContactController.php
new file mode 100644
index 0000000..5bb7d05
--- /dev/null
+++ b/application/modules/admin/controllers/ContactController.php
@@ -0,0 +1,54 @@
+<?php
+
+class Admin_ContactController extends Fizzy_SecuredController
+{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
+ public function indexAction()
+ {
+ $this->view->messages = Doctrine_Core::getTable('Contact')->findAll();
+ }
+
+ public function showAction()
+ {
+ $id = $this->_getParam('id', null);
+ if(null === $id) {
+ $this->_redirect('/fizzy/contact', array('prependBase' => true));
+ }
+
+ $query = Doctrine_Query::create()->from('Contact')->where('id = ?', $id);
+ $message = $query->fetchOne();
+ if(null === $message) {
+ $this->addErrorMessage("Message with ID {$id} could not be found.");
+ $this->_redirect('/fizzy/contact', array('prependBase' => true));
+ }
+
+ $this->view->message = $message;
+ }
+
+ public function deleteAction()
+ {
+ $id = $this->_getParam('id', null);
+ if(null === $id) {
+ $this->_redirect('/fizzy/contact', array('prependBase' => true));
+ }
+
+ $query = Doctrine_Query::create()->from('Contact')->where('id = ?', $id);
+ $message = $query->fetchOne();
+ if(null === $message) {
+ $this->addErrorMessage("Message with ID {$id} could not be found.");
+ $this->_redirect('/fizzy/contact', array('prependBase' => true));
+ }
+
+ $success = $message->delete();
+ if ($success) {
+ $this->addSuccessMessage("Message was deleted");
+ } else {
+ $this->addErrorMessage("Message with ID {$id} could not be deleted.");
+ }
+
+ $this->_redirect('/fizzy/contact', array('prependBase' => true));
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 353926a..2ce0df3 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,136 +1,171 @@
<?php
/**
* Class Admin_IndexController
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
/**
* Renders navigation for the admin section.
*/
public function navigationAction() {
$items = array();
+ // Blog
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Blogs',
'route' => 'admin_blogs',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Blog',
'route' => 'admin_blog',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'blog',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit Post',
'route' => 'admin_blog_post_edit',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'edit-post'
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add Post',
'route' => 'admin_blog_post_add',
'module' => 'admin',
'controller' => 'blogs',
'action' => 'add-post'
))
)
))
)
));
+ // Pages
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Pages',
'route' => 'admin_pages',
'module' => 'admin',
'controller' => 'pages',
'action' => 'index',
'pages' => array(
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_pages_add',
'module' => 'admin',
'controller' => 'pages',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_pages_edit',
'module' => 'admin',
'controller' => 'pages',
'action' => 'edit',
)),
)
));
+ // Media
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Media',
'route' => 'admin_media',
'module' => 'admin',
'controller' => 'media',
'action' => 'index',
'pages' => array ()
));
+ // Contact
+ if (null !== Setting::getKey('log', 'contact') && 0 < Setting::getKey('log', 'contact')) {
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Contact',
+ 'route' => 'admin_contact',
+ 'module' => 'admin',
+ 'controller' => 'contact',
+ 'action' => 'index',
+ 'pages' => array (
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Contact show',
+ 'route' => 'admin_contact_show',
+ 'module' => 'admin',
+ 'controller' => 'contact',
+ 'action' => 'show',
+ ))
+ )
+ ));
+ }
+
+ // Users
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Users',
'route' => 'admin_users',
'module' => 'admin',
'controller' => 'user',
'action' => 'index',
'pages' => array (
new Zend_Navigation_Page_Mvc(array(
'label' => 'Add',
'route' => 'admin_users_add',
'module' => 'admin',
'controller' => 'user',
'action' => 'add',
)),
new Zend_Navigation_Page_Mvc(array(
'label' => 'Edit',
'route' => 'admin_users_edit',
'module' => 'admin',
'controller' => 'user',
'action' => 'edit',
)),
)
));
+ // Settings
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Settings',
+ 'route' => 'admin_settings',
+ 'module' => 'admin',
+ 'controller' => 'settings',
+ 'action' => 'index',
+ 'pages' => array ()
+ ));
+
+ // Logout
$items[] = new Zend_Navigation_Page_Mvc(array(
'label' => 'Logout',
'route' => 'admin_logout',
'module' => 'admin',
'controller' => 'auth',
'action' => 'logout'
));
$this->view->items = $items;
$this->renderScript('navigation.phtml');
}
}
diff --git a/application/modules/admin/views/scripts/contact/index.phtml b/application/modules/admin/views/scripts/contact/index.phtml
new file mode 100644
index 0000000..0605b13
--- /dev/null
+++ b/application/modules/admin/views/scripts/contact/index.phtml
@@ -0,0 +1,30 @@
+<div id="content-panel">
+ <h2>Contact</h2>
+
+ <table class="data" id="contact-table">
+ <thead>
+ <tr>
+ <th> </th>
+ <th>Date</th>
+ <th>Name</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($this->messages as $message) : ?>
+ <tr>
+ <td class="controls" style="width: 55px;">
+ <?= $this->link('/fizzy/contact/show/' . $message->id, $this->img('/fizzy_assets/images/icon/mail-open.png')); ?>
+
+ <?= $this->linkConfirm('/fizzy/contact/delete/' . $message->id, $this->img('/fizzy_assets/images/icon/mail--minus.png'), 'Are you sure you want to delete this contact request?'); ?>
+ </td>
+ <td style="width: 150px;"><?= $message->date; ?></td>
+ <td style="max-width: 300px;"><?= $message->name; ?> <<a href="mailto:<?= $message->email; ?>"><?= $message->email; ?></a>></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+</div>
+
+<div id="sidebar-panel">
+
+</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/contact/show.phtml b/application/modules/admin/views/scripts/contact/show.phtml
new file mode 100644
index 0000000..f8bd710
--- /dev/null
+++ b/application/modules/admin/views/scripts/contact/show.phtml
@@ -0,0 +1,30 @@
+<div id="content-panel">
+ <h2>Contact request</h2>
+
+ <p>
+ From: <?= $this->message->name; ?> <<a href="mailto:<?= $this->message->email; ?>"><?= $this->message->email; ?></a>><br />
+ On: <?= $this->message->date; ?>
+ </p>
+
+ <p>
+ <?= nl2br($this->message->body); ?>
+ </p>
+</div>
+
+<div id="sidebar-panel">
+ <h2>Actions</h2>
+
+ <ul class="actions">
+ <li class="no-bg right">
+ <?= $this->linkConfirm(
+ '/fizzy/contact/delete/' . $this->message->id,
+ $this->img('/fizzy_assets/images/icon/mail--minus.png') . 'delete message',
+ 'Are you sure you want to delete this message?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ <li class="no-bg right last">
+ <?= $this->link('/fizzy/contact', $this->img('/fizzy_assets/images/icon/edit-list.png') . ' contact list'); ?>
+ </li>
+ </ul>
+</div>
\ No newline at end of file
diff --git a/application/modules/default/controllers/ContactController.php b/application/modules/default/controllers/ContactController.php
index 724fd28..b93d271 100644
--- a/application/modules/default/controllers/ContactController.php
+++ b/application/modules/default/controllers/ContactController.php
@@ -1,46 +1,52 @@
<?php
/**
* Contact form controller
**/
class ContactController extends Zend_Controller_Action
{
public function indexAction()
{
$form = $this->_getForm();
if ($this->_request->isPost()) {
if ($form->isValid($_POST)) {
- $mail = new Zend_Mail();
- $mail->setBodyText($form->feedback->getValue());
- $mail->setFrom($form->email->getValue(), $form->name->getValue());
- $config = Zend_Registry::get('config');
- $mail->addTo($config->contact->email);
- $mail->send();
+
+ $contact = new Contact();
+ $contact->name = $form->name->getValue();
+ $contact->email = $form->email->getValue();
+ $contact->body = $form->body->getValue();
+ $contact->date = date('Y/m/d H:i:s', time());
+
+ if (Setting::getKey('contact_log', 'contact')) {
+ $contact->save();
+ }
+ $contact->send();
+
$this->renderScript('contact/thankyou.phtml');
return;
}
}
$this->view->form = $form;
}
protected function _getForm()
{
$form = new Zend_Form();
$form->setAction($this->view->baseUrl('/contact'));
$form->addElement(new Zend_Form_Element_Text('name', array(
'label' => 'Name',
'required' => true
)));
$form->addElement(new Zend_Form_Element_Text('email', array(
'label' => 'E-mail',
'required' => true
)));
- $form->addElement(new Zend_Form_Element_Textarea('feedback', array(
+ $form->addElement(new Zend_Form_Element_Textarea('body', array(
'label' => 'Question / feedback',
'required' => true
)));
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Send',
)));
return $form;
}
}
diff --git a/configs/routes.ini b/configs/routes.ini
index fe2c51f..23aa6ab 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,131 +1,147 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/fizzy/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/fizzy/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
+;; Admin contact
+admin_contact.route = "/fizzy/contact"
+admin_contact.defaults.module = "admin"
+admin_contact.defaults.controller = "contact"
+admin_contact.defaults.action = "index"
+
+admin_contact_show.route = "/fizzy/contact/show/:id"
+admin_contact_show.defaults.module = "admin"
+admin_contact_show.defaults.controller = "contact"
+admin_contact_show.defaults.action = "show"
+
+admin_contact_delete.route = "/fizzy/contact/delete/:id"
+admin_contact_delete.defaults.module = "admin"
+admin_contact_delete.defaults.controller = "contact"
+admin_contact_delete.defaults.action = "delete"
+
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin settings
admin_settings.route = "/fizzy/settings"
admin_settings.defaults.module = "admin"
admin_settings.defaults.controller = "settings"
admin_settings.defaults.action = "index"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 2895d29..e5f4d0f 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,66 +1,74 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
displayname: string(255)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
post_id: integer(4)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
relations:
Post:
local: post_id
foreign: id
foreignAlias: Comments
Setting:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
component: string(50)
setting_key: string(50)
value: string
label: string(255)
- description: string
\ No newline at end of file
+ description: string
+
+Contact:
+ columns:
+ id: { type: integer(4), primary: true, autoincrement: true }
+ name: string(255)
+ email: string(255)
+ body: string
+ date: datetime
\ No newline at end of file
|
jtietema/Fizzy
|
7b645d8e4e708867f3705b12a589b1485f401342
|
pagination controls layout + forgotten file
|
diff --git a/application/modules/admin/views/scripts/blogs/_pagination.phtml b/application/modules/admin/views/scripts/blogs/_pagination.phtml
index 44efc46..e88da1a 100644
--- a/application/modules/admin/views/scripts/blogs/_pagination.phtml
+++ b/application/modules/admin/views/scripts/blogs/_pagination.phtml
@@ -1,15 +1,21 @@
-<?php if (isset($this->previous)){ ?>
+<?php if (isset($this->previous)): ?>
<a href="?page=<?= $this->previous ?>">
- prev
+ << prev
</a>
-<?php } ?>
-<?php foreach ($this->pagesInRange as $page){ ?>
+<?php else: ?>
+ << prev
+<?php endif; ?>
+
+<?php foreach ($this->pagesInRange as $page): ?>
<a href="?page=<?= $page ?>">
<?= $page; ?>
</a>
-<?php } ?>
-<?php if (isset($this->next)){ ?>
+<?php endforeach; ?>
+
+<?php if (isset($this->next)): ?>
<a href="?page=<?= $this->next ?>">
- next
+ next >>
</a>
-<?php } ?>
\ No newline at end of file
+<?php else: ?>
+ next >>
+<?php endif; ?>
\ No newline at end of file
diff --git a/library/Fizzy/Paginator/Adapter/DoctrineQuery.php b/library/Fizzy/Paginator/Adapter/DoctrineQuery.php
new file mode 100644
index 0000000..21996df
--- /dev/null
+++ b/library/Fizzy/Paginator/Adapter/DoctrineQuery.php
@@ -0,0 +1,28 @@
+<?php
+class Fizzy_Paginator_Adapter_DoctrineQuery
+ implements Zend_Paginator_Adapter_Interface
+{
+
+ protected $_query;
+ protected $_count_query;
+
+ public function __construct($query)
+ {
+ $this->_query = $query;
+ $this->_count_query = clone $query;
+ }
+
+ public function getItems($offset, $itemsPerPage)
+ {
+ return $this->_query
+ ->limit($itemsPerPage)
+ ->offset($offset)
+ ->execute();
+ }
+
+ public function count()
+ {
+ return $this->_count_query->count();
+ }
+
+}
\ No newline at end of file
|
jtietema/Fizzy
|
3d06202af01d4d483d39eb073260c964c7eacb78
|
comment and status options for posts
|
diff --git a/application/models/Blog.php b/application/models/Blog.php
index 177cfc5..c2c617b 100644
--- a/application/models/Blog.php
+++ b/application/models/Blog.php
@@ -1,20 +1,30 @@
<?php
/**
* Blog
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Blog extends BaseBlog
{
public function isNew()
{
return empty($this->id);
}
+ public function publishedPosts()
+ {
+ $posts = array();
+ foreach ($this->Posts as $post){
+ if ($post->status == 2){
+ $posts[] = $post;
+ }
+ }
+ return $posts;
+ }
}
\ No newline at end of file
diff --git a/application/models/Post.php b/application/models/Post.php
index 19708f4..075cbe1 100644
--- a/application/models/Post.php
+++ b/application/models/Post.php
@@ -1,20 +1,24 @@
<?php
/**
* Post
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Post extends BasePost
{
+ const PUBLISHED = 2;
+ const PENDING_REVIEW = 1;
+ const DRAFT = 0;
+
public function isNew()
{
return empty($this->id);
}
}
\ No newline at end of file
diff --git a/application/models/generated/BasePost.php b/application/models/generated/BasePost.php
index 3deb953..f4f7b13 100644
--- a/application/models/generated/BasePost.php
+++ b/application/models/generated/BasePost.php
@@ -1,69 +1,78 @@
<?php
/**
* BasePost
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $title
* @property string $body
* @property timestamp $date
* @property integer $author
+ * @property integer $status
+ * @property boolean $comments
* @property integer $blog_id
* @property User $User
* @property Blog $Blog
* @property Doctrine_Collection $Comments
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
abstract class BasePost extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('post');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('body', 'string', null, array(
'type' => 'string',
));
$this->hasColumn('date', 'timestamp', null, array(
'type' => 'timestamp',
));
$this->hasColumn('author', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
+ $this->hasColumn('status', 'integer', 1, array(
+ 'type' => 'integer',
+ 'length' => '1',
+ ));
+ $this->hasColumn('comments', 'boolean', null, array(
+ 'type' => 'boolean',
+ ));
$this->hasColumn('blog_id', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('User', array(
'local' => 'author',
'foreign' => 'id'));
$this->hasOne('Blog', array(
'local' => 'blog_id',
'foreign' => 'id'));
$this->hasMany('Comments', array(
'local' => 'id',
'foreign' => 'post_id'));
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
index fdf413b..e229efb 100644
--- a/application/modules/admin/controllers/BlogsController.php
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -1,167 +1,201 @@
<?php
class Admin_BlogsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$blogs = Doctrine_Query::create()->from('Blog')->execute();
$this->view->blogs = $blogs;
}
public function blogAction()
{
$id = $this->_getParam('id', null);
+ $pageNumber = $this->_getParam('page', 1);
+
if (null === $id){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
+ $query = Doctrine_Query::create()->from('Post')
+ ->where('blog_id = ?', $id);
+
+ $paginator = new Zend_Paginator(new Fizzy_Paginator_Adapter_DoctrineQuery($query));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setCurrentPageNumber($pageNumber);
+
$this->view->blog = $blog;
+ $this->view->paginator = $paginator;
}
public function addPostAction()
{
$blogId = $this->_getParam('blog_id', null);
if (null === $blogId){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
$this->view->form = $form = $this->_getPostForm();
$form->date->setValue(date('Y-m-d H:i:s'));
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$form->author->setValue($identity['id']);
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Add',
'ignore' => true
)));
$this->view->post = $post = new Post();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->blog_id = $blogId;
$post->save();
$this->_redirect('/fizzy/blog/' . $blogId);
}
$this->renderScript('blogs/post-form.phtml');
}
public function editPostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$form = $this->_getPostForm();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
+ $post->comments = $form->comments->getValue();
+ $post->status = $form->status->getValue();
$post->save();
+ $this->addSuccessMessage("Post \"<strong>{$post->title}</strong>\" was successfully saved.");
+ $this->_redirect('fizzy/post/' . $postId . '/edit');
} else {
$form->title->setValue($post->title);
$form->body->setValue($post->body);
$form->author->setValue($post->author);
$form->date->setValue($post->date);
+ $form->comments->setValue($post->comments);
+ $form->status->setValue($post->status);
}
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Edit',
'ignore' => true,
)));
$this->view->form = $form;
$this->view->post = $post;
$this->renderScript('blogs/post-form.phtml');
}
public function deletePostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post->delete();
$this->_redirect('fizzy/blog/' . $post->Blog->id);
}
protected function _getPostForm()
{
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('title', array(
'label' => 'Title',
'required' => true,
)));
$form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
'label' => 'Date',
'required' => true,
+ 'description' => 'The published date of this post.'
)));
$form->date->setJQueryParam('changeMonth', true);
$form->date->setJQueryParam('changeYear', true);
$form->date->setJQueryParam('dateFormat', 'yy-mm-dd');
$form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
'label' => 'Body',
'attribs' => array('style' => 'width: 100%;'),
)));
$form->addElement(new Zend_Form_Element_Select('author', array(
'label' => 'Author',
- 'multiOptions' => $this->_getUsers()
+ 'multiOptions' => $this->_getUsers(),
+ 'description' => 'The author of this post.'
+ )));
+
+ $form->addElement(new Zend_Form_Element_Checkbox('comments', array(
+ 'label' => 'Allow comments',
+ 'value' => true,
+ 'description' => 'Are visitors allowed to comment on this post?'
+ )));
+
+ $form->addElement(new Zend_Form_Element_Select('status', array(
+ 'label' => 'Status',
+ 'multiOptions' => array(
+ 0 => 'Draft',
+ 1 => 'Pending review',
+ 2 => 'Published'
+ ),
+ 'description' => 'Only published posts will show up on the website.'
)));
return $form;
}
protected function _getUsers()
{
$users = Doctrine_Query::create()->from('User')->execute();
$array = array();
foreach ($users as $user){
$array[$user->id] = $user->displayname;
}
return $array;
}
}
diff --git a/application/modules/admin/views/scripts/blogs/_pagination.phtml b/application/modules/admin/views/scripts/blogs/_pagination.phtml
new file mode 100644
index 0000000..44efc46
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/_pagination.phtml
@@ -0,0 +1,15 @@
+<?php if (isset($this->previous)){ ?>
+ <a href="?page=<?= $this->previous ?>">
+ prev
+ </a>
+<?php } ?>
+<?php foreach ($this->pagesInRange as $page){ ?>
+ <a href="?page=<?= $page ?>">
+ <?= $page; ?>
+ </a>
+<?php } ?>
+<?php if (isset($this->next)){ ?>
+ <a href="?page=<?= $this->next ?>">
+ next
+ </a>
+<?php } ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index 232a914..688afe7 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,44 +1,56 @@
<div id="content-panel">
<h2><?= $this->blog->name ?></h2>
<div>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Date</td>
+ <td>Status</td>
<td>Author</td>
</tr>
</thead>
<tbody>
- <?php foreach ($this->blog->Posts as $post): ?>
+ <?php $items = $this->paginator->getCurrentItems();
+ foreach ($items as $post): ?>
<tr>
<td class="controls">
<?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
</td>
<td>
<?= $post->title ?>
</td>
<td>
<?= $post->date ?>
</td>
+ <td>
+ <?php if ($post->status == Post::PUBLISHED): ?>
+ Published
+ <?php elseif ($post->status == Post::PENDING_REVIEW): ?>
+ Pending review
+ <?php else: ?>
+ Draft
+ <?php endif; ?>
+ </td>
<td>
<?= $post->User->displayname ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
+ <?= $this->paginationControl($this->paginator, 'All', 'blogs/_pagination.phtml') ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array()); ?>
</li>
</ul>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/post-form.phtml b/application/modules/admin/views/scripts/blogs/post-form.phtml
index 9127ebe..f8bd6ef 100644
--- a/application/modules/admin/views/scripts/blogs/post-form.phtml
+++ b/application/modules/admin/views/scripts/blogs/post-form.phtml
@@ -1,56 +1,57 @@
<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
<div id="content-panel">
<h2>
<?= $this->img('/fizzy_assets/images/icon/document.png'); ?>
<?= ($this->post->isNew()) ? 'Add post' : 'Edit post'; ?>
</h2>
<div class="form-panel">
<?= $this->form->title; ?>
<?= $this->form->body; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if(!$this->post->isNew()) : ?>
<li class="no-bg right">
<?= $this->linkConfirm(
'/fizzy/post/' . $this->post->id . '/delete',
$this->img('fizzy_assets/images/icon/document--minus.png') . ' delete page',
'Are you sure you want to delete this page?',
array('class' => 'delete')
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/blog/' . $this->post->Blog->id,
$this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name
); ?>
</li>
</ul>
<h2>Options</h2>
<div class="form-options-panel">
-
+ <?= $this->form->status; ?>
<?= $this->form->author; ?>
<?= $this->form->date; ?>
+ <?= $this->form->comments; ?>
</div>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/default/controllers/IndexController.php b/application/modules/default/controllers/IndexController.php
index 39aff6e..7179be6 100644
--- a/application/modules/default/controllers/IndexController.php
+++ b/application/modules/default/controllers/IndexController.php
@@ -1,11 +1,11 @@
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$blog = Doctrine_Query::create()->from('Blog')->where('slug = ?', 'default')->fetchOne();
- $this->view->posts = $blog->Posts;
+ $this->view->posts = $blog->publishedPosts();
}
}
diff --git a/database/fixtures/blogs.yml b/database/fixtures/blogs.yml
index 036ad65..ba49f72 100644
--- a/database/fixtures/blogs.yml
+++ b/database/fixtures/blogs.yml
@@ -1,12 +1,15 @@
Blog:
Default:
name: Default Blog
slug: default
group_slug: default
Post:
Test:
title: Test post
body: dit is een test post
+ date: now
+ comments: true
+ status: 2
author: 1
blog_id: 1
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 2895d29..14b36aa 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,66 +1,68 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
displayname: string(255)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
+ status: integer(1)
+ comments: boolean
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
post_id: integer(4)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
relations:
Post:
local: post_id
foreign: id
foreignAlias: Comments
Setting:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
component: string(50)
setting_key: string(50)
value: string
label: string(255)
description: string
\ No newline at end of file
|
jtietema/Fizzy
|
58b5d512a4672779da652a3091916b20b132feb2
|
datepicker now returns correct format
|
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
index dd4ed4c..fdf413b 100644
--- a/application/modules/admin/controllers/BlogsController.php
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -1,166 +1,167 @@
<?php
class Admin_BlogsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$blogs = Doctrine_Query::create()->from('Blog')->execute();
$this->view->blogs = $blogs;
}
public function blogAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
}
public function addPostAction()
{
$blogId = $this->_getParam('blog_id', null);
if (null === $blogId){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
$this->view->form = $form = $this->_getPostForm();
$form->date->setValue(date('Y-m-d H:i:s'));
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$form->author->setValue($identity['id']);
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Add',
'ignore' => true
)));
$this->view->post = $post = new Post();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->blog_id = $blogId;
$post->save();
$this->_redirect('/fizzy/blog/' . $blogId);
}
$this->renderScript('blogs/post-form.phtml');
}
public function editPostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$form = $this->_getPostForm();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->save();
} else {
$form->title->setValue($post->title);
$form->body->setValue($post->body);
$form->author->setValue($post->author);
$form->date->setValue($post->date);
}
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Edit',
'ignore' => true,
)));
$this->view->form = $form;
$this->view->post = $post;
$this->renderScript('blogs/post-form.phtml');
}
public function deletePostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post->delete();
$this->_redirect('fizzy/blog/' . $post->Blog->id);
}
protected function _getPostForm()
{
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('title', array(
'label' => 'Title',
'required' => true,
)));
$form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
'label' => 'Date',
'required' => true,
)));
$form->date->setJQueryParam('changeMonth', true);
$form->date->setJQueryParam('changeYear', true);
+ $form->date->setJQueryParam('dateFormat', 'yy-mm-dd');
$form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
'label' => 'Body',
'attribs' => array('style' => 'width: 100%;'),
)));
$form->addElement(new Zend_Form_Element_Select('author', array(
'label' => 'Author',
'multiOptions' => $this->_getUsers()
)));
return $form;
}
protected function _getUsers()
{
$users = Doctrine_Query::create()->from('User')->execute();
$array = array();
foreach ($users as $user){
$array[$user->id] = $user->displayname;
}
return $array;
}
}
|
jtietema/Fizzy
|
a36ed11a05ad3c434ff04f8fdeff1f64b7eb7f82
|
adds version info to CMS layout
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index 575a8d9..fd5a54f 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,487 +1,491 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
input[type="text"].hasDatepicker {
width: auto;
}
#ui-datepicker-div {
z-index: 1000;
}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
+#version-panel {
+ text-align: center;
+ margin-top: 25px;
+}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
\ No newline at end of file
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 930ea13..4fe4911 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,72 +1,78 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<?= $this->jQuery()->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<div id="main-panel">
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
-
<div id="copyright-panel">
- (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
+ (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a><br />
+ </div>
+ <div id="version-panel">
+ Fizzy <?= Fizzy_Version::VERSION ?>
+ running on
+ Zend Framework <?= Zend_Version::VERSION ?>
+ and
+ Doctrine <?= Doctrine::VERSION ?>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/library/Fizzy/Version.php b/library/Fizzy/Version.php
new file mode 100644
index 0000000..254a960
--- /dev/null
+++ b/library/Fizzy/Version.php
@@ -0,0 +1,5 @@
+<?php
+final class Fizzy_Version
+{
+ const VERSION = '2.0.0-dev';
+}
|
jtietema/Fizzy
|
6ac521b79ac142d240350f0eae7d6b41734f1ce0
|
Settings screen
|
diff --git a/application/models/Setting.php b/application/models/Setting.php
new file mode 100644
index 0000000..0891c29
--- /dev/null
+++ b/application/models/Setting.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Setting
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+class Setting extends BaseSetting
+{
+
+ public static $_settings = null;
+
+ public static function getAll($reload = false)
+ {
+ if (null === self::$_settings || $reload) {
+ $settings = array();
+ foreach (Doctrine_Core::getTable('Setting')->findAll() as $setting) {
+ $settings[$setting->setting_key] = $setting;
+ }
+ self::$_settings = $settings;
+ }
+
+ return self::$_settings;
+ }
+
+ public static function getKey($key, $reload = false)
+ {
+ $settings = self::getAll($reload);
+
+ return isset($settings[$key]) ? $settings[$key] : null;
+ }
+
+ public function isNew()
+ {
+ return empty($this->id);
+ }
+
+}
\ No newline at end of file
diff --git a/application/models/generated/BaseSetting.php b/application/models/generated/BaseSetting.php
new file mode 100644
index 0000000..89c3f85
--- /dev/null
+++ b/application/models/generated/BaseSetting.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * BaseSetting
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $component
+ * @property string $setting_key
+ * @property string $value
+ * @property string $label
+ * @property string $description
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BaseSetting extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('setting');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('component', 'string', 50, array(
+ 'type' => 'string',
+ 'length' => '50',
+ ));
+ $this->hasColumn('setting_key', 'string', 50, array(
+ 'type' => 'string',
+ 'length' => '50',
+ ));
+ $this->hasColumn('value', 'string', null, array(
+ 'type' => 'string',
+ ));
+ $this->hasColumn('label', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('description', 'string', null, array(
+ 'type' => 'string',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ }
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/SettingsController.php b/application/modules/admin/controllers/SettingsController.php
new file mode 100644
index 0000000..18e8033
--- /dev/null
+++ b/application/modules/admin/controllers/SettingsController.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Class Admin_SettingsController
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+
+class Admin_SettingsController extends Fizzy_SecuredController
+{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
+ public function indexAction()
+ {
+ $settings = Setting::getAll();
+ $settingsByComponent = array();
+
+ foreach ($settings as $setting) {
+ if (isset($settingsByComponent[component])) {
+ $settingsByComponent[$setting->component] = array();
+ }
+ $settingsByComponent[$setting->component][] = $setting;
+ }
+
+ $this->view->settings = $settingsByComponent;
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/settings/index.phtml b/application/modules/admin/views/scripts/settings/index.phtml
new file mode 100644
index 0000000..d7ef6ed
--- /dev/null
+++ b/application/modules/admin/views/scripts/settings/index.phtml
@@ -0,0 +1,34 @@
+<div id="content-panel">
+ <h2>
+ <?= $this->img('/fizzy_assets/images/icon/gear.png', array('alt' => 'Settings Icon')); ?>
+ Settings
+ </h2>
+
+ <table class="settings" id="settings-table">
+ <tbody>
+ <?php foreach($this->settings as $component => $settings) : ?>
+ <tr>
+ <th colspan="2"><?= ucfirst($component); ?></td>
+ </tr>
+ <?php foreach($settings as $setting) : ?>
+ <tr>
+ <td class="label">
+ <?= $setting->label; ?>
+ </td>
+ <td>
+ <span class="editable text"><?= $setting->value; ?></span><br />
+ <small><?= $setting->description; ?></small>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+
+</div>
+
+<div id="sidebar-panel">
+
+ <h2>Actions</h2>
+</div>
\ No newline at end of file
|
jtietema/Fizzy
|
6659d2cc806e2404ca802dbe76c0e85b1a66c69a
|
users now have a displayname
|
diff --git a/application/models/User.php b/application/models/User.php
index 868567a..2b9d1a4 100644
--- a/application/models/User.php
+++ b/application/models/User.php
@@ -1,27 +1,28 @@
<?php
/**
* User
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class User extends BaseUser
{
public function populate($array)
{
$this->username = $array['username'];
$this->password = $array['password'];
+ $this->displayname = $array['displayname'];
$this->encryption = $array['encryption'];
return $this;
}
public function isNew()
{
return empty($this->id);
}
}
diff --git a/application/models/generated/BaseUser.php b/application/models/generated/BaseUser.php
index 1846fda..e6b3e6e 100644
--- a/application/models/generated/BaseUser.php
+++ b/application/models/generated/BaseUser.php
@@ -1,51 +1,56 @@
<?php
/**
* BaseUser
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $username
+ * @property string $displayname
* @property string $password
* @property string $encryption
* @property Doctrine_Collection $BlogPosts
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
abstract class BaseUser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('username', 'string', 150, array(
'type' => 'string',
'length' => '150',
));
+ $this->hasColumn('displayname', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
$this->hasColumn('password', 'string', 150, array(
'type' => 'string',
'length' => '150',
));
$this->hasColumn('encryption', 'string', 10, array(
'type' => 'string',
'length' => '10',
));
}
public function setUp()
{
parent::setUp();
$this->hasMany('Post as BlogPosts', array(
'local' => 'id',
'foreign' => 'author'));
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
index 35b2d1b..dd4ed4c 100644
--- a/application/modules/admin/controllers/BlogsController.php
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -1,165 +1,166 @@
<?php
class Admin_BlogsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$blogs = Doctrine_Query::create()->from('Blog')->execute();
$this->view->blogs = $blogs;
}
public function blogAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
}
public function addPostAction()
{
$blogId = $this->_getParam('blog_id', null);
if (null === $blogId){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
$this->view->form = $form = $this->_getPostForm();
$form->date->setValue(date('Y-m-d H:i:s'));
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$form->author->setValue($identity['id']);
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Add',
'ignore' => true
)));
$this->view->post = $post = new Post();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->blog_id = $blogId;
$post->save();
$this->_redirect('/fizzy/blog/' . $blogId);
}
$this->renderScript('blogs/post-form.phtml');
}
public function editPostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$form = $this->_getPostForm();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->save();
} else {
$form->title->setValue($post->title);
$form->body->setValue($post->body);
$form->author->setValue($post->author);
$form->date->setValue($post->date);
}
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Edit',
'ignore' => true,
)));
$this->view->form = $form;
$this->view->post = $post;
$this->renderScript('blogs/post-form.phtml');
}
public function deletePostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post->delete();
$this->_redirect('fizzy/blog/' . $post->Blog->id);
}
protected function _getPostForm()
{
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('title', array(
'label' => 'Title',
'required' => true,
)));
$form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
'label' => 'Date',
'required' => true,
)));
$form->date->setJQueryParam('changeMonth', true);
$form->date->setJQueryParam('changeYear', true);
$form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
'label' => 'Body',
+ 'attribs' => array('style' => 'width: 100%;'),
)));
$form->addElement(new Zend_Form_Element_Select('author', array(
'label' => 'Author',
'multiOptions' => $this->_getUsers()
)));
return $form;
}
protected function _getUsers()
{
$users = Doctrine_Query::create()->from('User')->execute();
$array = array();
foreach ($users as $user){
- $array[$user->id] = $user->username;
+ $array[$user->id] = $user->displayname;
}
return $array;
}
}
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index ea84fbc..1e6eca7 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,139 +1,147 @@
<?php
class Admin_UserController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$query = Doctrine_Query::create()->from('User');
$users = $query->fetchArray();
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->user = $user;
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->id), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->user = $user;
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null !== $user) {
$user->delete();
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
$passwordConfirm = new Fizzy_Validate_EqualsField();
$passwordConfirm->setOppositeField('password_confirm');
$passwordConfirm->setFieldName('Password');
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $user->id
)
),
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
'validators' => array (
'usernameUnique'
)
)
),
+ 'displayname' => array(
+ 'type' => 'text',
+ 'options' => array(
+ 'label' => 'Display name',
+ 'required' => true,
+ 'value' => $user->displayname
+ )
+ ),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
'validators' => array (
$passwordConfirm
)
),
),
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
}
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 4c54b0f..930ea13 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,72 +1,72 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
- <?= $this->jQuery()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
+ <?= $this->jQuery()->enable()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<div id="main-panel">
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index fa23e44..232a914 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,44 +1,44 @@
<div id="content-panel">
<h2><?= $this->blog->name ?></h2>
<div>
<table class="data">
<thead>
<tr>
<td> </td>
<td>Title</td>
<td>Date</td>
<td>Author</td>
</tr>
</thead>
<tbody>
<?php foreach ($this->blog->Posts as $post): ?>
<tr>
<td class="controls">
<?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
</td>
<td>
<?= $post->title ?>
</td>
<td>
<?= $post->date ?>
</td>
<td>
- <?= $post->User->username ?>
+ <?= $post->User->displayname ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array()); ?>
</li>
</ul>
</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/user/form.phtml b/application/modules/admin/views/scripts/user/form.phtml
index 65b8798..5d0c32f 100644
--- a/application/modules/admin/views/scripts/user/form.phtml
+++ b/application/modules/admin/views/scripts/user/form.phtml
@@ -1,49 +1,51 @@
<form action="<?= $this->form->getAction(); ?>" name="UserForm" id="UserForm" method="post">
<div id="content-panel">
<h2>
<?= $this->user->isNew() ? 'Add user' : 'Edit user'; ?>
</h2>
<div class="form-panel">
+ <?= $this->form->id; ?>
<?= $this->form->username; ?>
+ <?= $this->form->displayname; ?>
<?= $this->form->password; ?>
<?= $this->form->password_confirm; ?>
</div>
</div>
<div id="sidebar-panel">
<h2>Actions</h2>
<ul class="actions">
<li class="last">
<input type="submit" value="Save" />
</li>
</ul>
<hr />
<ul class="actions">
<?php if (!$this->user->isNew()) : ?>
<li class="no-bg right">
<?= $this->linkConfirm(
'/fizzy/user/delete/' . $this->user->id,
$this->img('fizzy_assets/images/icon/user--minus.png') . ' delete user',
'Are you sure you want to delete this user?',
array('class' => 'delete')
); ?>
</li>
<?php endif; ?>
<li class="no-bg right last">
<?= $this->link(
'/fizzy/users',
$this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to users'
); ?>
</li>
</ul>
</div>
</form>
\ No newline at end of file
diff --git a/application/modules/default/views/scripts/index/index.phtml b/application/modules/default/views/scripts/index/index.phtml
index 9fdae42..613b458 100644
--- a/application/modules/default/views/scripts/index/index.phtml
+++ b/application/modules/default/views/scripts/index/index.phtml
@@ -1,11 +1,14 @@
<?php foreach ($this->posts as $post): ?>
<div>
<div><?= $post->title ?></div>
- <div><?= $post->date ?> - <?= $post->User->username ?></div>
+ <div><?= $post->date ?> - <?= $post->User->displayname ?></div>
<div><?= $post->body ?></div>
- <?php foreach ($post->Comments as $comment): ?>
- <div><?= $comment->name ?> - <?= $comment->date ?></div>
- <div><?= $comment->body ?></div>
- <?php endforeach; ?>
+ <div>
+ <div>Comments:</div>
+ <?php foreach ($post->Comments as $comment): ?>
+ <div><?= $comment->name ?> - <?= $comment->date ?></div>
+ <div><?= $comment->body ?></div>
+ <?php endforeach; ?>
+ </div>
</div>
<?php endforeach; ?>
\ No newline at end of file
diff --git a/database/fixtures/users.yml b/database/fixtures/users.yml
index 97a3b43..634f1a2 100644
--- a/database/fixtures/users.yml
+++ b/database/fixtures/users.yml
@@ -1,4 +1,5 @@
User:
Admin:
username: admin
password: admin
+ displayname: The Admin
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 19e4480..3f9a5ee 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,80 +1,78 @@
User:
- columns:
- id:
- type: integer(4)
- primary: true
- autoincrement: true
- username:
- type: string(150)
- password:
- type: string(150)
- encryption:
- type: string(10)
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ username: string(150)
+ displayname: string(255)
+ password: string(150)
+ encryption: string(10)
Page:
- columns:
- id:
- type: integer(4)
- primary: true
- autoincrement: true
- title:
- type: string(255)
- slug:
- type: string(255)
- body:
- type: string
- homepage:
- type: boolean
- layout:
- type: string(150)
- template:
- type: string(150)
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ title:
+ type: string(255)
+ slug:
+ type: string(255)
+ body:
+ type: string
+ homepage:
+ type: boolean
+ layout:
+ type: string(150)
+ template:
+ type: string(150)
Blog:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
title: string(255)
body: string
date: timestamp
author: integer(4)
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
post_id: integer(4)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
relations:
Post:
local: post_id
foreign: id
foreignAlias: Comments
\ No newline at end of file
|
jtietema/Fizzy
|
5c52cb8ec7ec046d276287456f4506d38e000fec
|
blog styling
|
diff --git a/application/assets/css/fizzy-2.0.css b/application/assets/css/fizzy-2.0.css
index b31c128..575a8d9 100644
--- a/application/assets/css/fizzy-2.0.css
+++ b/application/assets/css/fizzy-2.0.css
@@ -1,481 +1,487 @@
/**
* Fizzy 2.0 Stylesheet
*
* Scheme: http://colorschemedesigner.com/#3D11TpE--l2br
* Scheme: http://colorschemedesigner.com/#3z21NBR..v5g0
*
* @author Mattijs Hoitink <[email protected]>
*/
/* ********************** */
/* HTML ELEMENTS */
html {
background-color: #F1EFE2;
}
body {
font: 75%/1.2 'Lucida Grande',Arial,Helvetica,sans-serif;
}
em { font-style: italic; }
a {
color: #3581C5;
text-decoration: none;
}
a:hover {
color: #033F75;
text-decoration: underline;
}
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 120%; }
h4 { font-size: 110%; }
h5 {}
h6 {}
h1 ,h2, h3, h4, h5, h6, strong {
font-weight:bold;
}
h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
h3 {
margin-bottom: .3em;
padding-bottom: .2em;
border-bottom: 1px solid #E4E4E4;
}
p { margin-bottom: 1em; }
label {
display: block;
margin-bottom: .3em;
font-weight: bold;
}
fieldset {
display: block;
padding: 10px;
border: 1px groove #E4E4E4;
}
legend { color: #918A8A; }
input[type="text"], input[type="password"], input[type="email"], textarea {
width: 300px;
padding: 2px 4px;
border: 1px solid #918A8A;
}
+input[type="text"].hasDatepicker {
+ width: auto;
+}
+#ui-datepicker-div {
+ z-index: 1000;
+}
/* HTML ELEMENTS */
/* ********************** */
/* ********************** */
/* BUTTONS */
.c3button, a.c3button {
display: inline-block;
padding: 5px 10px;
background: #222 url('../images/button-overlay.png') repeat-x;
-moz-box-shadow: 0 1px 3px 1px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border: 1px solid rgb(0,0,0,0.25);
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
background-color: #EBEBEB;
color: #666666;
}
a.c3button:hover {
text-decoration: none;
}
.c3button.large {
padding: 0.5em 1em;
font-size: 20px;
}
.c3button.orange {
background-color: #FF5C00;
color: #FFFFFF;
}
.c3button.green {
background-color: #20C519;
color: #FFFFFF;
}
.c3button.blue {
background-color: #195CC5;
color: #FFFFFF;
}
.c3button img {
position: relative;
top: 0.3em;
}
/* BUTTONS */
/* ********************** */
/* ********************** */
/* GENERAL CLASSES */
.fleft { float: left; }
.fright { float: right; }
.tleft { text-align: left; }
.tright { text-align: right; }
.tcenter { text-align: center; }
.clr, .clear {
height: 1px;
line-height: 1px;
font-size: 0;
clear: both;
}
#container {
background-color: #FFFFFF;
}
/* GENERAL CLASSES */
/* ********************** */
/* ********************** */
/* PANELS */
#header-panel {
position: relative;
background-color: #0A62B2;
color: #F8F8F8;
height: 5.3em;
margin: 0;
padding: 15px 30px 0 30px;
-moz-box-shadow: inset 0px -8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 -8px 6px -4px rgba(0,0,0,0.2);
}
#navigation-panel {
position: absolute;
bottom: -1px;
}
#main-panel {
position: relative;
min-height: 400px;
}
#messages-panel {
/*width: 400px;
position: absolute;
top: 0;
left: 50%;
margin-left: -200px;*/
min-height: 3em;
}
#content-panel {
margin: 0px 345px 10px 30px;
}
#sidebar-panel {
margin: 0px 30px 0 0;
min-height: 300px;
padding: 0;
position: absolute;
top: 0;
right: 0;
width: 300px;
z-index: 9;
}
#footer-panel {
height: 6em;
padding-top: 20px;
color: #999999;
/*-moz-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0px 8px 6px -4px rgba(0,0,0,0.2);*/
background: #F1EFE2 url(../images/footerbg.png) repeat-x scroll 0 0
}
#copyright-panel {
float: right;
margin: 10px 20px;
}
/* PANELS */
/* ********************** */
/* ********************** */
/* Login */
#login-panel {
position: absolute;
top: 50px;
left: 50%;
margin-left: -250px;
width: 500px;
padding: 10px;
background-color: #FFFFFF;
border: 1px solid #E9E9E9;
-moz-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
-webkit-box-shadow: 4px 4px 6px -4px rgba(0,0,0,0.2);
}
#login-panel h1 {
display: block;
padding: 15px 10px;
background-color: #0A62B2;
color: #F8F8F8;
}
/* Login */
/* ********************** */
/* ********************** */
/* NAVIGATION */
#navigation-panel ul li {
float: left;
list-style-type: none;
margin: 0 2px 0 0;
padding: 0;
white-space: nowrap;
}
#navigation-panel ul li a {
color: #FFFFFF;
display: block;
margin: 0;
padding: 4px 10px;
text-decoration: none;
}
#navigation-panel ul li.active a, #navigation-panel ul li.active a:hover {
background-color: #FFFFFF;
color: #555555;
}
#navigation-panel ul li a:hover {
color: #FFFFFF;
background-color: #3581C5;
}
/* NAVIGATION */
/* ********************** */
/* ********************** */
/* MESSAGES */
#messages-panel #messages {
padding: 1em 2.5em;
}
#messages-panel .message {
position: relative;
}
#messages-panel .message .message-close {
position: absolute;
right: 10px;
top: 10px;
}
.error, .notice, .success, .info { padding: .8em; border: 1px solid #ddd; }
.error { background: #E22C33; color: #440A09; border-color: #B20A0A; }
.notice { background: #E2CC2C; color: #443E09; border-color: #B28C0A; }
.success { background: #2CE23D; color: #264409; border-color: #22B20A; }
.info { background: #2C88E2; color: #091144; border-color: #0A1AB2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
/* MESSAGES */
/* ********************** */
/* ********************** */
/* CONTENT */
#content-panel h2 {
margin-bottom: 1em;
border-bottom: 1px solid #E4E4E4;
}
#content-panel h2 img {
float: left;
margin-top: 2px;
margin-right: 10px;
}
.details-panel {
margin-bottom: 2em;
padding: 1.5em;
background-color: #ECEEEC;
}
/* CONTENT */
/* ********************** */
/* ********************** */
/* SIDEBAR */
#sidebar-panel .block {
display: block;
margin-bottom: 20px;
}
#sidebar-panel .block h2 {}
#sidebar-panel .block p, #sidebar-panel .block .content {
margin: 1em;
}
#sidebar-panel hr {
margin: 1.5em .5em;
background-color: #E4E4E4;
border: 0;
height: 1px;
}
/* actions */
#sidebar-panel ul.actions {
margin: .5em;
}
#sidebar-panel ul.actions li {
padding: 0.7em 1em;
margin: 0;
background-color: #EFEFEF;
border-collapse: collapse;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #D4D4D4;
}
#sidebar-panel ul.actions li.no-bg {
background-color: transparent;
border: 0;
}
#sidebar-panel ul.actions li.last {
border-bottom: 0;
}
#sidebar-panel ul.actions li a,
#sidebar-panel ul.actions li input[type="submit"]
{}
#sidebar-panel ul.actions li a.delete {
color: #8D3134;
text-decoration: underline;
}
#sidebar-panel ul.actions li img {
float: left;
margin-top: -1px;
margin-right: 1em;
}
#sidebar-panel ul.actions li.right {
text-align: right;
}
#sidebar-panel ul.actions li.right img {
float: right;
margin-right: 0;
margin-left: 1em;
}
/* SIDEBAR */
/* ********************** */
/* ********************** */
/* MEDIA */
#media-panel {}
#media-tabs-panel {}
#media-tabs-panel ul {
margin: 0;
padding: 0;
list-style: none;
}
#media-tabs-panel ul li {
display: inline-block;
}
#media-panel .media-container {
overflow: auto;
margin: 0;
padding-bottom: 10px;
height: 390px;
border: 1px solid #DEDEDE;
background-color: #ECEEEC;
/*-moz-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 2px 4px 4px -1px rgba(0,0,0,0.2);*/
}
#media-panel .media-container div.thumbnail {
position: relative;
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
#media-panel .media-container div.thumbnail div.head {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.head .filename {
float: left;
}
#media-panel .media-container div.thumbnail div.head .remove {
float: right;
}
#media-panel .media-container div.thumbnail div.body {
height: 100px;
line-height: 100px;
background-color: #E9EEF0;
border: solid 1px black;
}
#media-panel .media-container div.thumbnail div.body a,
#media-panel .media-container div.thumbnail div.body a:link,
#media-panel .media-container div.thumbnail div.body a:active,
#media-panel .media-container div.thumbnail div.body a:visited
{
display: block;
vertical-align: middle;
text-align: center;
}
#media-panel .media-container div.thumbnail div.body img {
margin: 0 -4px 0 4px;
}
#media-panel .media-container div.thumbnail img.source {
max-width: 120px;
max-height: 80px;
vertical-align: middle;
}
#media-panel .media-container div.thumbnail img.icon {
vertical-align: middle;
}
#media-panel .media-container div.thumbnail div.foot {
height: 20px;
line-height: 20px;
}
#media-panel .media-container div.thumbnail div.foot .size {
float: right;
display: block;
}
/* MEDIA */
/* ********************** */
\ No newline at end of file
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
index 314aff9..35b2d1b 100644
--- a/application/modules/admin/controllers/BlogsController.php
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -1,143 +1,165 @@
<?php
class Admin_BlogsController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
public function indexAction()
{
$blogs = Doctrine_Query::create()->from('Blog')->execute();
$this->view->blogs = $blogs;
}
public function blogAction()
{
$id = $this->_getParam('id', null);
if (null === $id){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
}
public function addPostAction()
{
$blogId = $this->_getParam('blog_id', null);
if (null === $blogId){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
if (null == $blog){
return $this->renderScript('blogs/blogNotFound.phtml');
}
$this->view->blog = $blog;
$this->view->form = $form = $this->_getPostForm();
$form->date->setValue(date('Y-m-d H:i:s'));
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$form->author->setValue($identity['id']);
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Add',
'ignore' => true
)));
+ $this->view->post = $post = new Post();
+
if ($this->_request->isPost() && $form->isValid($_POST)){
- $post = new Post();
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->blog_id = $blogId;
$post->save();
$this->_redirect('/fizzy/blog/' . $blogId);
}
+
+ $this->renderScript('blogs/post-form.phtml');
}
public function editPostAction()
{
$postId = $this->_getParam('post_id', null);
if (null === $postId){
return $this->renderScript('blogs/postNotFound.phtml');
}
$post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
if (null == $post){
return $this->renderScript('blogs/postNotFound.phtml');
}
$form = $this->_getPostForm();
if ($this->_request->isPost() && $form->isValid($_POST)){
$post->title = $form->title->getValue();
$post->body = $form->body->getValue();
$post->author = $form->author->getValue();
$post->date = $form->date->getValue();
$post->save();
} else {
$form->title->setValue($post->title);
$form->body->setValue($post->body);
$form->author->setValue($post->author);
$form->date->setValue($post->date);
}
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Edit',
'ignore' => true,
)));
$this->view->form = $form;
$this->view->post = $post;
+ $this->renderScript('blogs/post-form.phtml');
+ }
+
+ public function deletePostAction()
+ {
+ $postId = $this->_getParam('post_id', null);
+ if (null === $postId){
+ return $this->renderScript('blogs/postNotFound.phtml');
+ }
+
+ $post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
+
+ if (null == $post){
+ return $this->renderScript('blogs/postNotFound.phtml');
+ }
+
+ $post->delete();
+
+ $this->_redirect('fizzy/blog/' . $post->Blog->id);
}
protected function _getPostForm()
{
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('title', array(
'label' => 'Title',
'required' => true,
)));
$form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
'label' => 'Date',
'required' => true,
)));
$form->date->setJQueryParam('changeMonth', true);
$form->date->setJQueryParam('changeYear', true);
$form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
'label' => 'Body',
)));
$form->addElement(new Zend_Form_Element_Select('author', array(
'label' => 'Author',
'multiOptions' => $this->_getUsers()
)));
return $form;
}
protected function _getUsers()
{
$users = Doctrine_Query::create()->from('User')->execute();
$array = array();
foreach ($users as $user){
$array[$user->id] = $user->username;
}
return $array;
}
}
diff --git a/application/modules/admin/views/scripts/blogs/add-post.phtml b/application/modules/admin/views/scripts/blogs/add-post.phtml
deleted file mode 100644
index 71e03c8..0000000
--- a/application/modules/admin/views/scripts/blogs/add-post.phtml
+++ /dev/null
@@ -1,3 +0,0 @@
-<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->blog->id) ?>"><< Back to <?= $this->blog->name ?></a>
-
-<?= $this->form ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
index 53868a0..fa23e44 100644
--- a/application/modules/admin/views/scripts/blogs/blog.phtml
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -1,13 +1,44 @@
-<h1><?= $this->blog->name ?></h1>
+<div id="content-panel">
+ <h2><?= $this->blog->name ?></h2>
-<table>
- <tbody>
- <?php foreach ($this->blog->Posts as $post): ?>
- <tr>
- <td><a href="<?= $this->baseUrl('/fizzy/post/' . $post->id . '/edit') ?>"><?= $post->title ?></a></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
-</table>
+ <div>
+ <table class="data">
+ <thead>
+ <tr>
+ <td> </td>
+ <td>Title</td>
+ <td>Date</td>
+ <td>Author</td>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach ($this->blog->Posts as $post): ?>
+ <tr>
+ <td class="controls">
+ <?= $this->link('/fizzy/post/' . $post->id . '/edit', $this->img('/fizzy_assets/images/icon/document--pencil.png', array('alt' => 'edit icon')), array('title' => 'edit page')); ?>
+ </td>
+ <td>
+ <?= $post->title ?>
+ </td>
+ <td>
+ <?= $post->date ?>
+ </td>
+ <td>
+ <?= $post->User->username ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+</div>
-<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->blog->id . '/add') ?>">Add post</a>
\ No newline at end of file
+<div id="sidebar-panel">
+ <h2>Actions</h2>
+
+ <ul class="actions">
+ <li class="last">
+ <?= $this->link('/fizzy/blog/' . $this->blog->id . '/add', $this->img('/fizzy_assets/images/icon/document--plus.png') . ' Add post', array()); ?>
+ </li>
+ </ul>
+</div>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/edit-post.phtml b/application/modules/admin/views/scripts/blogs/edit-post.phtml
deleted file mode 100644
index 18c17b1..0000000
--- a/application/modules/admin/views/scripts/blogs/edit-post.phtml
+++ /dev/null
@@ -1,3 +0,0 @@
-<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->post->Blog->id) ?>"><< Back to <?= $this->post->Blog->name ?></a>
-
-<?= $this->form ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/index.phtml b/application/modules/admin/views/scripts/blogs/index.phtml
index be8cd8e..4f3fe16 100644
--- a/application/modules/admin/views/scripts/blogs/index.phtml
+++ b/application/modules/admin/views/scripts/blogs/index.phtml
@@ -1,11 +1,25 @@
-<table>
- <tbody>
- <?php foreach ($this->blogs as $blog) : ?>
- <tr>
- <td><a href="<?= $this->baseUrl('/fizzy/blog/' . $blog->id) ?>"><?= $blog->name ?></a></td>
- <td><?= $blog->slug ?></td>
- <td><?= $blog->group_slug ?></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
-</table>
+<div id="content-panel">
+ <h2>Blogs</h2>
+ <div>
+ <table class="data">
+ <thead>
+ <tr>
+ <td>Blog name</td>
+ <td>Slug</td>
+ <td>Group slug</td>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach ($this->blogs as $blog) : ?>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/blog/' . $blog->id) ?>"><?= $blog->name ?></a></td>
+ <td><?= $blog->slug ?></td>
+ <td><?= $blog->group_slug ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+</div>
+
+<div id="sidebar-panel"></div>
diff --git a/application/modules/admin/views/scripts/blogs/post-form.phtml b/application/modules/admin/views/scripts/blogs/post-form.phtml
new file mode 100644
index 0000000..9127ebe
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/post-form.phtml
@@ -0,0 +1,56 @@
+<form action="<?= $this->form->getAction(); ?>" method="post" id="PageForm" name="PageForm">
+
+ <div id="content-panel">
+ <h2>
+ <?= $this->img('/fizzy_assets/images/icon/document.png'); ?>
+ <?= ($this->post->isNew()) ? 'Add post' : 'Edit post'; ?>
+ </h2>
+
+ <div class="form-panel">
+ <?= $this->form->title; ?>
+ <?= $this->form->body; ?>
+ </div>
+
+ </div>
+
+ <div id="sidebar-panel">
+ <h2>Actions</h2>
+
+ <ul class="actions">
+ <li class="last">
+ <input type="submit" value="Save" />
+ </li>
+ </ul>
+
+ <hr />
+
+ <ul class="actions">
+ <?php if(!$this->post->isNew()) : ?>
+ <li class="no-bg right">
+ <?= $this->linkConfirm(
+ '/fizzy/post/' . $this->post->id . '/delete',
+ $this->img('fizzy_assets/images/icon/document--minus.png') . ' delete page',
+ 'Are you sure you want to delete this page?',
+ array('class' => 'delete')
+ ); ?>
+ </li>
+ <?php endif; ?>
+ <li class="no-bg right last">
+ <?= $this->link(
+ '/fizzy/blog/' . $this->post->Blog->id,
+ $this->img('/fizzy_assets/images/icon/edit-list.png') . ' back to ' . $this->post->Blog->name
+ ); ?>
+ </li>
+ </ul>
+
+ <h2>Options</h2>
+
+ <div class="form-options-panel">
+
+ <?= $this->form->author; ?>
+ <?= $this->form->date; ?>
+
+ </div>
+
+ </div>
+</form>
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index acbeded..7165056 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,126 +1,131 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/fizzy/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/fizzy/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
+admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
+admin_blog_post_delete.defaults.action = "delete-post"
+admin_blog_post_delete.defaults.controller = "blogs"
+admin_blog_post_delete.defaults.module = "admin"
+
admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin configuration
admin_configuration.route = "/fizzy/configuration"
admin_configuration.defaults.action = "configuration"
admin_configuration.defaults.controller = "index"
admin_configuration.defaults.module = "admin"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
|
jtietema/Fizzy
|
36c3094e9d55dd4b634bbb70087b8a13f9e0d439
|
Added settings routes, updated settings schema
|
diff --git a/configs/routes.ini b/configs/routes.ini
index 7165056..fe2c51f 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,131 +1,131 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
admin_blogs.route = "/fizzy/blogs"
admin_blogs.defaults.action = "index"
admin_blogs.defaults.controller = "blogs"
admin_blogs.defaults.module = "admin"
admin_blog.route = "/fizzy/blog/:id"
admin_blog.defaults.action = "blog"
admin_blog.defaults.controller = "blogs"
admin_blog.defaults.module = "admin"
admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
admin_blog_post_add.defaults.action = "add-post"
admin_blog_post_add.defaults.controller = "blogs"
admin_blog_post_add.defaults.module = "admin"
admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
admin_blog_post_edit.defaults.action = "edit-post"
admin_blog_post_edit.defaults.controller = "blogs"
admin_blog_post_edit.defaults.module = "admin"
admin_blog_post_delete.route = "/fizzy/post/:post_id/delete"
admin_blog_post_delete.defaults.action = "delete-post"
admin_blog_post_delete.defaults.controller = "blogs"
admin_blog_post_delete.defaults.module = "admin"
admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
-;; Admin configuration
-admin_configuration.route = "/fizzy/configuration"
-admin_configuration.defaults.action = "configuration"
-admin_configuration.defaults.controller = "index"
-admin_configuration.defaults.module = "admin"
+;; Admin settings
+admin_settings.route = "/fizzy/settings"
+admin_settings.defaults.module = "admin"
+admin_settings.defaults.controller = "settings"
+admin_settings.defaults.action = "index"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
diff --git a/database/fixtures/settings.yml b/database/fixtures/settings.yml
index 727ffd1..430f2d9 100644
--- a/database/fixtures/settings.yml
+++ b/database/fixtures/settings.yml
@@ -1,43 +1,43 @@
Setting:
website_title:
component: application
- key: title
+ setting_key: title
value: Fizzy
label: "Application title"
description: "This is used as the base for the application title in the browser window"
page_template:
component: page
- key: default_template
+ setting_key: default_template
value: "default.phtml"
label: "Default Page template"
description: "The default template that is used for pages"
page_layout:
component: page
- key: default_layout
+ setting_key: default_layout
value: "default"
label: "Default Page layout"
description: "The default layout that is used for pages"
webdav:
component: media
- key: webdav_enabled
+ setting_key: webdav_enabled
value: true
label: "Enable webdav upload"
description: "If WebDAV upload for the media library should be enabled"
webdav_browser:
component: media
- key: webdav_browser
+ setting_key: webdav_browser
value: true
label: "WebDAV browser"
description: "If the media library should be browsable through WebDAV"
contact_log:
component: contact
- key: log
+ setting_key: log
value: true
label: "Contact log"
description: "If contact requests send throught the contact form should be logged and browsable"
contact_email:
component: contact
- key: address
+ setting_key: address
value: [email protected]
label: "Contact Email"
description: "The email address contact requests from the contact form are send to"
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index c60b707..e1180b3 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,64 +1,65 @@
User:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
username: string(150)
password: string(150)
encryption: string(10)
Page:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
slug: string(255)
body: string
homepage: boolean
layout: string(150)
template: string(150)
-Setting:
- columns:
- id: { type: integer(4), primary: true, autoincrement: true }
- component: string(50)
- key: string(50)
- value: string(255)
- label: string(150)
- description: text
Blog:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
slug: string(255)
group_slug: string(255)
Post:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
title: string(255)
body: string
date: timestamp
author: integer(4)
blog_id: integer(4)
relations:
User:
local: author
foreign: id
foreignAlias: BlogPosts
Blog:
local: blog_id
foreign: id
foreignAlias: Posts
Comments:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
post_id: integer(4)
body: string
name: string(255)
email: string(255)
website: string(255)
date: timestamp
relations:
Post:
local: post_id
foreign: id
- foreignAlias: Comments
\ No newline at end of file
+ foreignAlias: Comments
+
+Setting:
+ columns:
+ id: { type: integer(4), primary: true, autoincrement: true }
+ component: string(50)
+ setting_key: string(50)
+ value: string
+ label: string(255)
+ description: string
\ No newline at end of file
|
jtietema/Fizzy
|
ad9e97b44304eeab1b3e776ac629a79e0382605b
|
isNew function for all models
|
diff --git a/application/models/Blog.php b/application/models/Blog.php
index edf0839..177cfc5 100644
--- a/application/models/Blog.php
+++ b/application/models/Blog.php
@@ -1,16 +1,20 @@
<?php
/**
* Blog
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Blog extends BaseBlog
{
+ public function isNew()
+ {
+ return empty($this->id);
+ }
}
\ No newline at end of file
diff --git a/application/models/Comments.php b/application/models/Comments.php
index 1b272e1..061a8ca 100644
--- a/application/models/Comments.php
+++ b/application/models/Comments.php
@@ -1,16 +1,20 @@
<?php
/**
* Comments
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Comments extends BaseComments
{
+ public function isNew()
+ {
+ return empty($this->id);
+ }
}
\ No newline at end of file
diff --git a/application/models/Post.php b/application/models/Post.php
index dfdaa9e..19708f4 100644
--- a/application/models/Post.php
+++ b/application/models/Post.php
@@ -1,16 +1,20 @@
<?php
/**
* Post
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Post extends BasePost
{
+ public function isNew()
+ {
+ return empty($this->id);
+ }
}
\ No newline at end of file
|
jtietema/Fizzy
|
ea59dae37cda0b5805595a855c74a019ea17aa6a
|
Added setting model
|
diff --git a/database/fixtures/settings.yml b/database/fixtures/settings.yml
new file mode 100644
index 0000000..727ffd1
--- /dev/null
+++ b/database/fixtures/settings.yml
@@ -0,0 +1,43 @@
+Setting:
+ website_title:
+ component: application
+ key: title
+ value: Fizzy
+ label: "Application title"
+ description: "This is used as the base for the application title in the browser window"
+ page_template:
+ component: page
+ key: default_template
+ value: "default.phtml"
+ label: "Default Page template"
+ description: "The default template that is used for pages"
+ page_layout:
+ component: page
+ key: default_layout
+ value: "default"
+ label: "Default Page layout"
+ description: "The default layout that is used for pages"
+ webdav:
+ component: media
+ key: webdav_enabled
+ value: true
+ label: "Enable webdav upload"
+ description: "If WebDAV upload for the media library should be enabled"
+ webdav_browser:
+ component: media
+ key: webdav_browser
+ value: true
+ label: "WebDAV browser"
+ description: "If the media library should be browsable through WebDAV"
+ contact_log:
+ component: contact
+ key: log
+ value: true
+ label: "Contact log"
+ description: "If contact requests send throught the contact form should be logged and browsable"
+ contact_email:
+ component: contact
+ key: address
+ value: [email protected]
+ label: "Contact Email"
+ description: "The email address contact requests from the contact form are send to"
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 5c0d9b5..b2da692 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,31 +1,25 @@
User:
- columns:
- id:
- type: integer(4)
- primary: true
- autoincrement: true
- username:
- type: string(150)
- password:
- type: string(150)
- encryption:
- type: string(10)
+ columns:
+ id: { type: integer(4), primary: true, autoincrement: true }
+ username: string(150)
+ password: string(150)
+ encryption: string(10)
Page:
- columns:
- id:
- type: integer(4)
- primary: true
- autoincrement: true
- title:
- type: string(255)
- slug:
- type: string(255)
- body:
- type: string
- homepage:
- type: boolean
- layout:
- type: string(150)
- template:
- type: string(150)
+ columns:
+ id: { type: integer(4), primary: true, autoincrement: true }
+ title: string(255)
+ slug: string(255)
+ body: string
+ homepage: boolean
+ layout: string(150)
+ template: string(150)
+
+Setting:
+ columns:
+ id: { type: integer(4), primary: true, autoincrement: true }
+ component: string(50)
+ key: string(50)
+ value: string(255)
+ label: string(150)
+ description: text
\ No newline at end of file
|
jtietema/Fizzy
|
40f8225a69b459d00570e438ae0e49a4651adeca
|
eerste versie blog WIP
|
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 5e3cfbb..1bccd8f 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,63 +1,67 @@
<?php
/**
* Description of Bootstrap
*
* @author jeroen
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
+ $view->addHelperPath(
+ realpath(implode(DIRECTORY_SEPARATOR,
+ array(ROOT_PATH, 'library', 'ZendX', 'JQuery', 'View', 'Helper')
+ )), 'ZendX_JQuery_View_Helper');
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$this->bootstrap('FrontController');
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getResource('FrontController');
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
protected function _initRoutes()
{
$this->bootstrap('FrontController');
$router = $this->getContainer()->frontcontroller->getRouter();
$config = new Zend_Config_Ini(ROOT_PATH . '/configs/routes.ini');
$router->addConfig($config->{$this->getEnvironment()});
return $router;
}
}
diff --git a/application/models/Blog.php b/application/models/Blog.php
new file mode 100644
index 0000000..edf0839
--- /dev/null
+++ b/application/models/Blog.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Blog
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+class Blog extends BaseBlog
+{
+
+}
\ No newline at end of file
diff --git a/application/models/Comments.php b/application/models/Comments.php
new file mode 100644
index 0000000..1b272e1
--- /dev/null
+++ b/application/models/Comments.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Comments
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+class Comments extends BaseComments
+{
+
+}
\ No newline at end of file
diff --git a/application/models/Page.php b/application/models/Page.php
index 60902b1..9a7febb 100644
--- a/application/models/Page.php
+++ b/application/models/Page.php
@@ -1,55 +1,54 @@
<?php
-require_once 'generated/BasePage.php';
/**
* Page
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Page extends BasePage
{
public function getTemplate()
{
if(empty($this->template)) {
$pages = Zend_Registry::get('config')->pages;
$this->template = $pages->defaultTemplate;
}
return $this->template;
}
/**
* Override to return the default layout if none is set.
* @return string
*/
public function getLayout()
{
if(empty($this->layout)) {
$pages = Zend_Registry::get('config')->pages;
$this->layout = $pages->defaultLayout;
}
return $this->layout;
}
public function populate($array)
{
$this->title = $array['title'];
$this->slug = $array['slug'];
$this->body = $array['body'];
$this->homepage = (boolean) $array['homepage'];
if ('default' !== $array['template'])
$this->template = $array['template'];
$this->layout = $array['layout'];
return $this;
}
}
diff --git a/application/models/Post.php b/application/models/Post.php
new file mode 100644
index 0000000..dfdaa9e
--- /dev/null
+++ b/application/models/Post.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Post
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+class Post extends BasePost
+{
+
+}
\ No newline at end of file
diff --git a/application/models/User.php b/application/models/User.php
index 61033b8..c962a67 100644
--- a/application/models/User.php
+++ b/application/models/User.php
@@ -1,23 +1,22 @@
<?php
-require_once 'generated/BaseUser.php';
/**
* User
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class User extends BaseUser
{
public function populate($array)
{
$this->username = $array['username'];
$this->password = $array['password'];
$this->encryption = $array['encryption'];
return $this;
}
}
diff --git a/application/models/generated/BaseBlog.php b/application/models/generated/BaseBlog.php
new file mode 100644
index 0000000..19450e0
--- /dev/null
+++ b/application/models/generated/BaseBlog.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * BaseBlog
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $name
+ * @property string $slug
+ * @property string $group_slug
+ * @property Doctrine_Collection $Posts
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BaseBlog extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('blog');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('name', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('slug', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('group_slug', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->hasMany('Post as Posts', array(
+ 'local' => 'id',
+ 'foreign' => 'blog_id'));
+ }
+}
\ No newline at end of file
diff --git a/application/models/generated/BaseComments.php b/application/models/generated/BaseComments.php
new file mode 100644
index 0000000..c0ed773
--- /dev/null
+++ b/application/models/generated/BaseComments.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * BaseComments
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property integer $post_id
+ * @property string $body
+ * @property string $name
+ * @property string $email
+ * @property string $website
+ * @property timestamp $date
+ * @property Post $Post
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BaseComments extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('comments');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('post_id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'length' => '4',
+ ));
+ $this->hasColumn('body', 'string', null, array(
+ 'type' => 'string',
+ ));
+ $this->hasColumn('name', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('email', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('website', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('date', 'timestamp', null, array(
+ 'type' => 'timestamp',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->hasOne('Post', array(
+ 'local' => 'post_id',
+ 'foreign' => 'id'));
+ }
+}
\ No newline at end of file
diff --git a/application/models/generated/BasePost.php b/application/models/generated/BasePost.php
new file mode 100644
index 0000000..3deb953
--- /dev/null
+++ b/application/models/generated/BasePost.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * BasePost
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $title
+ * @property string $body
+ * @property timestamp $date
+ * @property integer $author
+ * @property integer $blog_id
+ * @property User $User
+ * @property Blog $Blog
+ * @property Doctrine_Collection $Comments
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BasePost extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('post');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('title', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('body', 'string', null, array(
+ 'type' => 'string',
+ ));
+ $this->hasColumn('date', 'timestamp', null, array(
+ 'type' => 'timestamp',
+ ));
+ $this->hasColumn('author', 'integer', 4, array(
+ 'type' => 'integer',
+ 'length' => '4',
+ ));
+ $this->hasColumn('blog_id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'length' => '4',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->hasOne('User', array(
+ 'local' => 'author',
+ 'foreign' => 'id'));
+
+ $this->hasOne('Blog', array(
+ 'local' => 'blog_id',
+ 'foreign' => 'id'));
+
+ $this->hasMany('Comments', array(
+ 'local' => 'id',
+ 'foreign' => 'post_id'));
+ }
+}
\ No newline at end of file
diff --git a/application/models/generated/BaseUser.php b/application/models/generated/BaseUser.php
index a11fdd6..1846fda 100644
--- a/application/models/generated/BaseUser.php
+++ b/application/models/generated/BaseUser.php
@@ -1,48 +1,51 @@
<?php
/**
* BaseUser
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $username
* @property string $password
* @property string $encryption
+ * @property Doctrine_Collection $BlogPosts
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
abstract class BaseUser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('username', 'string', 150, array(
'type' => 'string',
'length' => '150',
));
$this->hasColumn('password', 'string', 150, array(
'type' => 'string',
'length' => '150',
));
$this->hasColumn('encryption', 'string', 10, array(
'type' => 'string',
'length' => '10',
));
}
public function setUp()
{
parent::setUp();
-
+ $this->hasMany('Post as BlogPosts', array(
+ 'local' => 'id',
+ 'foreign' => 'author'));
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/BlogsController.php b/application/modules/admin/controllers/BlogsController.php
new file mode 100644
index 0000000..314aff9
--- /dev/null
+++ b/application/modules/admin/controllers/BlogsController.php
@@ -0,0 +1,143 @@
+<?php
+
+class Admin_BlogsController extends Fizzy_SecuredController
+{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
+ public function indexAction()
+ {
+ $blogs = Doctrine_Query::create()->from('Blog')->execute();
+ $this->view->blogs = $blogs;
+ }
+
+ public function blogAction()
+ {
+ $id = $this->_getParam('id', null);
+ if (null === $id){
+ return $this->renderScript('blogs/blogNotFound.phtml');
+ }
+
+ $blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $id)->fetchOne();
+
+ if (null == $blog){
+ return $this->renderScript('blogs/blogNotFound.phtml');
+ }
+
+ $this->view->blog = $blog;
+ }
+
+ public function addPostAction()
+ {
+ $blogId = $this->_getParam('blog_id', null);
+ if (null === $blogId){
+ return $this->renderScript('blogs/blogNotFound.phtml');
+ }
+
+ $blog = Doctrine_Query::create()->from('Blog')->where('id = ?', $blogId)->fetchOne();
+ if (null == $blog){
+ return $this->renderScript('blogs/blogNotFound.phtml');
+ }
+
+ $this->view->blog = $blog;
+ $this->view->form = $form = $this->_getPostForm();
+
+ $form->date->setValue(date('Y-m-d H:i:s'));
+ $auth = Zend_Auth::getInstance();
+ $identity = $auth->getIdentity();
+ $form->author->setValue($identity['id']);
+
+ $form->addElement(new Zend_Form_Element_Submit('submit', array(
+ 'label' => 'Add',
+ 'ignore' => true
+ )));
+
+ if ($this->_request->isPost() && $form->isValid($_POST)){
+ $post = new Post();
+ $post->title = $form->title->getValue();
+ $post->body = $form->body->getValue();
+ $post->author = $form->author->getValue();
+ $post->date = $form->date->getValue();
+ $post->blog_id = $blogId;
+ $post->save();
+
+ $this->_redirect('/fizzy/blog/' . $blogId);
+ }
+ }
+
+ public function editPostAction()
+ {
+ $postId = $this->_getParam('post_id', null);
+ if (null === $postId){
+ return $this->renderScript('blogs/postNotFound.phtml');
+ }
+
+ $post = Doctrine_Query::create()->from('Post')->where('id = ?', $postId)->fetchOne();
+
+ if (null == $post){
+ return $this->renderScript('blogs/postNotFound.phtml');
+ }
+
+ $form = $this->_getPostForm();
+
+ if ($this->_request->isPost() && $form->isValid($_POST)){
+ $post->title = $form->title->getValue();
+ $post->body = $form->body->getValue();
+ $post->author = $form->author->getValue();
+ $post->date = $form->date->getValue();
+ $post->save();
+ } else {
+ $form->title->setValue($post->title);
+ $form->body->setValue($post->body);
+ $form->author->setValue($post->author);
+ $form->date->setValue($post->date);
+ }
+
+ $form->addElement(new Zend_Form_Element_Submit('submit', array(
+ 'label' => 'Edit',
+ 'ignore' => true,
+ )));
+
+ $this->view->form = $form;
+ $this->view->post = $post;
+ }
+
+ protected function _getPostForm()
+ {
+ $form = new Zend_Form();
+ $form->addElement(new Zend_Form_Element_Text('title', array(
+ 'label' => 'Title',
+ 'required' => true,
+ )));
+
+ $form->addElement(new ZendX_JQuery_Form_Element_DatePicker('date', array(
+ 'label' => 'Date',
+ 'required' => true,
+ )));
+ $form->date->setJQueryParam('changeMonth', true);
+ $form->date->setJQueryParam('changeYear', true);
+
+ $form->addElement(new Fizzy_Form_Element_Wysiwyg('body', array(
+ 'label' => 'Body',
+ )));
+
+ $form->addElement(new Zend_Form_Element_Select('author', array(
+ 'label' => 'Author',
+ 'multiOptions' => $this->_getUsers()
+ )));
+
+ return $form;
+ }
+
+ protected function _getUsers()
+ {
+ $users = Doctrine_Query::create()->from('User')->execute();
+
+ $array = array();
+ foreach ($users as $user){
+ $array[$user->id] = $user->username;
+ }
+
+ return $array;
+ }
+}
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 95515c8..daf9699 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,79 +1,80 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
- <script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
+ <?= $this->jQuery()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css') ?>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
<ul>
- <li class="active"><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
+ <li class="active"><a href="<?= $this->baseUrl("/fizzy/blogs") ?>">Blogs</a></li>
+ <li><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/media") ?>">Media</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/users") ?>">Users</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/configuration") ?>">Configuration</a></li>
<li class="link-logout"><a href="<?= $this->baseUrl("/fizzy/logout") ?>">Logout</a></li>
</ul>
<div class="clear"></div>
</div>
</div>
<div id="main-panel">
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/blogs/add-post.phtml b/application/modules/admin/views/scripts/blogs/add-post.phtml
new file mode 100644
index 0000000..71e03c8
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/add-post.phtml
@@ -0,0 +1,3 @@
+<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->blog->id) ?>"><< Back to <?= $this->blog->name ?></a>
+
+<?= $this->form ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/blog.phtml b/application/modules/admin/views/scripts/blogs/blog.phtml
new file mode 100644
index 0000000..53868a0
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/blog.phtml
@@ -0,0 +1,13 @@
+<h1><?= $this->blog->name ?></h1>
+
+<table>
+ <tbody>
+ <?php foreach ($this->blog->Posts as $post): ?>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/post/' . $post->id . '/edit') ?>"><?= $post->title ?></a></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+</table>
+
+<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->blog->id . '/add') ?>">Add post</a>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/blogNotFound.phtml b/application/modules/admin/views/scripts/blogs/blogNotFound.phtml
new file mode 100644
index 0000000..7cd31aa
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/blogNotFound.phtml
@@ -0,0 +1 @@
+Blog not found....
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/edit-post.phtml b/application/modules/admin/views/scripts/blogs/edit-post.phtml
new file mode 100644
index 0000000..18c17b1
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/edit-post.phtml
@@ -0,0 +1,3 @@
+<a href="<?= $this->baseUrl('/fizzy/blog/' . $this->post->Blog->id) ?>"><< Back to <?= $this->post->Blog->name ?></a>
+
+<?= $this->form ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/blogs/index.phtml b/application/modules/admin/views/scripts/blogs/index.phtml
new file mode 100644
index 0000000..be8cd8e
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/index.phtml
@@ -0,0 +1,11 @@
+<table>
+ <tbody>
+ <?php foreach ($this->blogs as $blog) : ?>
+ <tr>
+ <td><a href="<?= $this->baseUrl('/fizzy/blog/' . $blog->id) ?>"><?= $blog->name ?></a></td>
+ <td><?= $blog->slug ?></td>
+ <td><?= $blog->group_slug ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+</table>
diff --git a/application/modules/admin/views/scripts/blogs/postNotFound.phtml b/application/modules/admin/views/scripts/blogs/postNotFound.phtml
new file mode 100644
index 0000000..ee118a6
--- /dev/null
+++ b/application/modules/admin/views/scripts/blogs/postNotFound.phtml
@@ -0,0 +1 @@
+Post not found ....
\ No newline at end of file
diff --git a/application/modules/default/controllers/IndexController.php b/application/modules/default/controllers/IndexController.php
index b292111..39aff6e 100644
--- a/application/modules/default/controllers/IndexController.php
+++ b/application/modules/default/controllers/IndexController.php
@@ -1,10 +1,11 @@
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
- echo "YAH!";
+ $blog = Doctrine_Query::create()->from('Blog')->where('slug = ?', 'default')->fetchOne();
+ $this->view->posts = $blog->Posts;
}
}
diff --git a/application/modules/default/views/scripts/index/index.phtml b/application/modules/default/views/scripts/index/index.phtml
index e69de29..9fdae42 100644
--- a/application/modules/default/views/scripts/index/index.phtml
+++ b/application/modules/default/views/scripts/index/index.phtml
@@ -0,0 +1,11 @@
+<?php foreach ($this->posts as $post): ?>
+<div>
+ <div><?= $post->title ?></div>
+ <div><?= $post->date ?> - <?= $post->User->username ?></div>
+ <div><?= $post->body ?></div>
+ <?php foreach ($post->Comments as $comment): ?>
+ <div><?= $comment->name ?> - <?= $comment->date ?></div>
+ <div><?= $comment->body ?></div>
+ <?php endforeach; ?>
+</div>
+<?php endforeach; ?>
\ No newline at end of file
diff --git a/configs/application.ini b/configs/application.ini
index 02ea436..1f83a15 100644
--- a/configs/application.ini
+++ b/configs/application.ini
@@ -1,38 +1,38 @@
[production]
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.session.save_path = "/tmp"
autoloaderNamespaces.fizzy = "Fizzy_"
pluginPaths.Fizzy_Resource = APPLICATION_PATH "/../library/Fizzy/Resource/"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
title = "Fizzy"
pages.defaultTemplate = "page.phtml"
pages.defaultLayout = "default"
paths.templatePath = APPLICATION_PATH "/modules/default/views/templates"
paths.layoutPath = APPLICATION_PATH "/modules/default/views/layouts"
contact.email = "[email protected]"
; Doctrine resources
-;resources.doctrine.manager.attributes.attr_model_loading = model_loading_conservative
+resources.doctrine.manager.attributes.attr_model_loading = model_loading_conservative
resources.doctrine.connections.default.dsn = "mysql://root@localhost/fizzy"
resources.doctrine.paths.models_path = APPLICATION_PATH "/models/"
resources.doctrine.paths.yaml_schema_path = ROOT_PATH "/database/schema/"
resources.doctrine.paths.sql_path = ROOT_PATH "/database/sql/"
resources.doctrine.paths.migrations_path = ROOT_PATH "/database/migrations/"
resources.doctrine.paths.data_fixtures_path = ROOT_PATH "/database/fixtures/"
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.throwExceptions = "true"
resources.doctrine.connections.default.dsn = "mysql://root:php-dev@localhost/fizzy"
[test : production]
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index a794b73..d1d66c0 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,100 +1,120 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
+admin_blogs.route = "/fizzy/blogs"
+admin_blogs.defaults.action = "index"
+admin_blogs.defaults.controller = "blogs"
+admin_blogs.defaults.module = "admin"
+
+admin_blog.route = "/fizzy/blog/:id"
+admin_blog.defaults.action = "blog"
+admin_blog.defaults.controller = "blogs"
+admin_blog.defaults.module = "admin"
+
+admin_blog_post_add.route = "/fizzy/blog/:blog_id/add"
+admin_blog_post_add.defaults.action = "add-post"
+admin_blog_post_add.defaults.controller = "blogs"
+admin_blog_post_add.defaults.module = "admin"
+
+admin_blog_post_edit.route = "/fizzy/post/:post_id/edit"
+admin_blog_post_edit.defaults.action = "edit-post"
+admin_blog_post_edit.defaults.controller = "blogs"
+admin_blog_post_edit.defaults.module = "admin"
+
admin_pages.route = "/fizzy/pages/"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin configuration
admin_configuration.route = "/fizzy/configuration"
admin_configuration.defaults.action = "configuration"
admin_configuration.defaults.controller = "index"
admin_configuration.defaults.module = "admin"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
diff --git a/database/fixtures/blogs.yml b/database/fixtures/blogs.yml
new file mode 100644
index 0000000..036ad65
--- /dev/null
+++ b/database/fixtures/blogs.yml
@@ -0,0 +1,12 @@
+Blog:
+ Default:
+ name: Default Blog
+ slug: default
+ group_slug: default
+
+Post:
+ Test:
+ title: Test post
+ body: dit is een test post
+ author: 1
+ blog_id: 1
\ No newline at end of file
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
index 5c0d9b5..19e4480 100644
--- a/database/schema/schema.yml
+++ b/database/schema/schema.yml
@@ -1,31 +1,80 @@
User:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
username:
type: string(150)
password:
type: string(150)
encryption:
type: string(10)
Page:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
title:
type: string(255)
slug:
type: string(255)
body:
type: string
homepage:
type: boolean
layout:
type: string(150)
template:
type: string(150)
+
+Blog:
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ name: string(255)
+ slug: string(255)
+ group_slug: string(255)
+
+Post:
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ title: string(255)
+ body: string
+ date: timestamp
+ author: integer(4)
+ blog_id: integer(4)
+ relations:
+ User:
+ local: author
+ foreign: id
+ foreignAlias: BlogPosts
+ Blog:
+ local: blog_id
+ foreign: id
+ foreignAlias: Posts
+
+Comments:
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ post_id: integer(4)
+ body: string
+ name: string(255)
+ email: string(255)
+ website: string(255)
+ date: timestamp
+ relations:
+ Post:
+ local: post_id
+ foreign: id
+ foreignAlias: Comments
\ No newline at end of file
diff --git a/doctrine b/doctrine
index 8cd6a3d..1855115 100755
--- a/doctrine
+++ b/doctrine
@@ -1,31 +1,35 @@
#!/usr/bin/env php
<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
-define('LIBRARY_PATH', realpath(APPLICATION_PATH . '/library'));
+define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/library'));
-set_include_path(LIBRARY_PATH . PATH_SEPARATOR . APPLICATION_PATH . '/models/doctrine/generated' . PATH_SEPARATOR . get_include_path());
+set_include_path(LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
require_once 'Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
+spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
-$config = new Zend_Config_Ini('configs/fizzy.ini', 'storage');
+$config = new Zend_Config_Ini('configs/application.ini', 'development');
$manager = Doctrine_Manager::getInstance();
-Doctrine_Manager::connection($config->dsn, 'doctrine');
+Doctrine_Manager::connection($config->resources->doctrine->connections->default->dsn, 'doctrine');
-$manager->setAttribute('model_loading', 'conservative');
+$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
$cli_config = array(
'models_path' => APPLICATION_PATH . '/models',
'sql_path' => APPLICATION_PATH . '/../database/sql',
'yaml_schema_path' => APPLICATION_PATH . '/../database/schema',
'migrations_path' => APPLICATION_PATH . '/../database/migrations',
'data_fixtures_path' => APPLICATION_PATH . '/../database/fixtures'
);
+
+Doctrine::loadModels($cli_config['models_path']);
+
$cli = new Doctrine_Cli($cli_config);
$cli->run($_SERVER['argv']);
diff --git a/library/Fizzy/Resource/Doctrine.php b/library/Fizzy/Resource/Doctrine.php
index 615e412..0d3db60 100644
--- a/library/Fizzy/Resource/Doctrine.php
+++ b/library/Fizzy/Resource/Doctrine.php
@@ -1,197 +1,198 @@
<?php
/**
* Resource for bootstrapping Doctrine
*
* @author Mattijs Hoitink <[email protected]>
* @todo enable binding models to a connection
* @todo Add support for connection options (as array)
*/
class Fizzy_Resource_Doctrine extends Zend_Application_Resource_ResourceAbstract
{
/**
* Doctrine_Manager instance
* @var Doctrine_Manager
*/
protected $_manager = null;
/** **/
/**
* Initializes the Doctrine Resource. This is done in four steps:
* <ul>
* <li>Register Doctrines own autoloader with the Zend_Loader stack</li>
* <li>Instantiate the Doctrine_Manager</li>
* <li>Open defined connections</li>
* <li>Load model paths</li>
* </ul>
* @return Doctrine_Manager
*/
public function init()
{
// Get the Resource options
$options = $this->getOptions();
// Register the Doctrine autoloader
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
+ $autoloader->pushAutoloader(array('Doctrine_Core', 'modelsAutoload'));
// Initialize the Doctrine Manager
$this->_manager = Doctrine_Manager::getInstance();
// Check for manager attributes in the options
if(array_key_exists('manager', $options)) {
$managerOptions = $options['manager'];
if(array_key_exists('attributes', $managerOptions) && is_array($managerOptions['attributes'])) {
$this->_setManagerAttributes($managerOptions['attributes']);
}
}
// Open defined connections
if(isset($options['connections']) && is_array($options['connections']) && !empty($options['connections'])) {
foreach($options['connections'] as $connectionName => $connectionOptions) {
$this->_openConnection($connectionName, $connectionOptions);
}
}
// Load models
if(array_key_exists('paths', $options)) {
$pathsOptions = $options['paths'];
if(array_key_exists('models_path', $pathsOptions) && !empty($pathsOptions['models_path'])) {
$this->_loadModels($pathsOptions['models_path']);
}
}
return $this->_manager;
}
/**
* Sets attributes on the Doctrine_Manager. Doctrine constants are supported
* and can be supplied in lower or upper case. Doctrine constants and arrays
* as values are also supported.
* @param array $attributes
*/
protected function _setManagerAttributes(array $attributes)
{
$reflect = new ReflectionClass('Doctrine');
$doctrineConstants = $reflect->getConstants();
$manager = Doctrine_Manager::getInstance();
foreach($attributes as $attribute => $value)
{
if (!array_key_exists(strtoupper($attribute), $doctrineConstants)) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Invalid Doctrine_Manager attribute.');
}
// Get the value for the attribute
$attributeKey = $doctrineConstants[strtoupper($attribute)];
// Check if the attribute value is a doctrine constant as well
if(array_key_exists(strtoupper($value), $doctrineConstants)) {
$attributeValue = $doctrineConstants[strtoupper($value)];
}
// Check if the value is an array itself
else if(is_array($value)) {
$attributeValue = array();
foreach($value as $subKey => $subValue) {
$attributeValue[$subKey] = $subValue;
}
}
else {
$attributeValue = $value;
}
$manager->setAttribute($attributeKey, $attributeValue);
}
}
/**
* Opens a connection with the provided options.
* @param string $name
* @param array $options
*/
protected function _openConnection($name, array $options)
{
$dsn = (is_string($options['dsn'])) ? $options['dsn'] : $this->_constructDsn($options['dsn']);
// Initialize a connection
Doctrine_Manager::connection($dsn, $name);
}
/**
* Loads model classes for Doctrine. The path can be supplied as a string or
* as an array.
* @param string|array $modelsPath
*/
protected function _loadModels($modelsPath)
{
if(is_string($modelsPath)) {
Doctrine::loadModels($modelsPath);
}
else if(is_array($modelsPath)) {
foreach($modelsPath as $path) {
Doctrine::loadModels($path);
}
}
else {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Invalid Doctrine model_path option.');
}
}
/**
* Construct a DSN from an array.
* Supported keywords:
* <ul>
* <li>phptype</li>
* <li>dbsyntax</li>
* <li>protocol</li>
* <li>hostspec</li>
* <li>database</li>
* <li>username</li>
* <li>password</li>
* <li>option</li>
* </ul>
* @param array $options
* @link http://www.doctrine-project.org/documentation/manual/1_1/en/introduction-to-connections#dsn,-the-data-source-name
*/
protected function _constructDsn($options)
{
$dsn = '';
if(!isset($options['phptype'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The phptype options is manditory for connection specification.');
}
else if(!isset($option['username'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The username options is manditory for connection specification.');
}
else if(!isset($options['hostspec'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The hostspec options is manditory for connection specification.');
}
else if(!isset($options['database'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('The database options is manditory for connection specification.');
}
$dsn .= $options['phptype'] . '://' . $options['username'];
if(isset($options['password'])) {
$dsn .= ':' . $options['password'];
}
$dsn .= '@';
if(isset($options['protocol'])) {
$dsn .= $options['protocol'] . '+';
}
$dsn .= $options['hostspec'] . '/' . $options['database'];
return $dsn;
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
29f1a3718eb20e66335ec334c7190a71451d9b19
|
added ZendX (1.10.4)
|
diff --git a/library/ZendX/Application/Resource/Jquery.php b/library/ZendX/Application/Resource/Jquery.php
new file mode 100644
index 0000000..6273b7d
--- /dev/null
+++ b/library/ZendX/Application/Resource/Jquery.php
@@ -0,0 +1,167 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Application
+ * @subpackage Resource
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Jquery.php 20240 2010-01-13 04:51:56Z matthew $
+ */
+
+/**
+ * JQuery application resource
+ *
+ * Example configuration:
+ * <pre>
+ * resources.Jquery.noconflictmode = false ; default
+ * resources.Jquery.version = 1.7.1 ; <null>
+ * resources.Jquery.localpath = "/foo/bar"
+ * resources.Jquery.uienable = true;
+ * resources.Jquery.ui_enable = true;
+ * resources.Jquery.uiversion = 0.7.7;
+ * resources.Jquery.ui_version = 0.7.7;
+ * resources.Jquery.uilocalpath = "/bar/foo";
+ * resources.Jquery.ui_localpath = "/bar/foo";
+ * resources.Jquery.cdn_ssl = false
+ * resources.Jquery.render_mode = 255 ; default
+ * resources.Jquery.rendermode = 255 ; default
+ *
+ * resources.Jquery.javascriptfile = "/some/file.js"
+ * resources.Jquery.javascriptfiles.0 = "/some/file.js"
+ * resources.Jquery.stylesheet = "/some/file.css"
+ * resources.Jquery.stylesheets.0 = "/some/file.css"
+ * </pre>
+ *
+ * Resource for settings JQuery options
+ *
+ * @uses Zend_Application_Resource_ResourceAbstract
+ * @category ZendX
+ * @package ZendX_Application
+ * @subpackage Resource
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Application_Resource_Jquery
+ extends Zend_Application_Resource_ResourceAbstract
+{
+ /**
+ * @var ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ protected $_jquery;
+
+ /**
+ * @var Zend_View
+ */
+ protected $_view;
+
+ /**
+ * Defined by Zend_Application_Resource_Resource
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function init()
+ {
+ return $this->getJquery();
+ }
+
+ /**
+ * Retrieve JQuery View Helper
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function getJquery()
+ {
+ if (null === $this->_jquery) {
+ $this->getBootstrap()->bootstrap('view');
+ $this->_view = $this->getBootstrap()->view;
+
+ ZendX_JQuery::enableView($this->_view);
+ $this->_parseOptions($this->getOptions());
+
+ $this->_jquery = $this->_view->jQuery();
+ }
+
+ return $this->_jquery;
+ }
+
+ /**
+ * Parse options to find those pertinent to jquery helper and invoke them
+ *
+ * @param array $options
+ * @return void
+ */
+ protected function _parseOptions(array $options)
+ {
+ $options = array_merge($options, array('cdn_ssl' => false));
+
+ foreach ($options as $key => $value) {
+ switch($key) {
+ case 'noconflictmode':
+ if (!(bool)$value) {
+ ZendX_JQuery_View_Helper_JQuery::disableNoConflictMode();
+ } else {
+ ZendX_JQuery_View_Helper_JQuery::enableNoConflictMode();
+ }
+ break;
+ case 'version':
+ $this->_view->JQuery()->setVersion($value);
+ break;
+ case 'localpath':
+ $this->_view->JQuery()->setLocalPath($value);
+ break;
+ case 'uiversion':
+ case 'ui_version':
+ $this->_view->JQuery()->setUiVersion($value);
+ break;
+ case 'uilocalpath':
+ case 'ui_localpath':
+ $this->_view->JQuery()->setUiLocalPath($value);
+ break;
+ case 'cdn_ssl':
+ $this->_view->JQuery()->setCdnSsl($value);
+ break;
+ case 'render_mode':
+ case 'rendermode':
+ $this->_view->JQuery()->setRenderMode($value);
+ break;
+ case 'javascriptfile':
+ $this->_view->JQuery()->addJavascriptFile($value);
+ break;
+ case 'javascriptfiles':
+ foreach($options['javascriptfiles'] as $file) {
+ $this->_view->JQuery()->addJavascriptFile($file);
+ }
+ break;
+ case 'stylesheet':
+ $this->_view->JQuery()->addStylesheet($value);
+ break;
+ case 'stylesheets':
+ foreach ($value as $stylesheet) {
+ $this->_view->JQuery()->addStylesheet($stylesheet);
+ }
+ break;
+ }
+ }
+
+ if ((isset($key['uienable']) && (bool) $key['uienable'])
+ || (isset($key['ui_enable']) && (bool) $key['ui_enable'])
+ || (!isset($key['ui_enable']) && !isset($key['uienable'])))
+ {
+ $this->_view->JQuery()->uiEnable();
+ } else {
+ $this->_view->JQuery()->uiDisable();
+ }
+ }
+}
diff --git a/library/ZendX/Console/Exception.php b/library/ZendX/Console/Exception.php
new file mode 100644
index 0000000..ade59a7
--- /dev/null
+++ b/library/ZendX/Console/Exception.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Whois
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_Exception
+ */
+require_once 'ZendX/Exception.php';
+
+/**
+ * Exception class for ZendX_Console
+ *
+ * @category ZendX
+ * @package ZendX_Console
+ * @uses Zend_Exception
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Console_Exception extends ZendX_Exception
+{
+}
diff --git a/library/ZendX/Console/Process/Exception.php b/library/ZendX/Console/Process/Exception.php
new file mode 100644
index 0000000..8f2c5a6
--- /dev/null
+++ b/library/ZendX/Console/Process/Exception.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Console
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_Console_Exception
+ */
+require_once 'ZendX/Console/Exception.php';
+
+/**
+ * Exception class for ZendX_Console_Process
+ *
+ * @category ZendX
+ * @package ZendX_Console
+ * @uses ZendX_Console_Exception
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Console_Process_Exception extends ZendX_Console_Exception
+{
+}
diff --git a/library/ZendX/Console/Process/Unix.php b/library/ZendX/Console/Process/Unix.php
new file mode 100644
index 0000000..1d7ed2c
--- /dev/null
+++ b/library/ZendX/Console/Process/Unix.php
@@ -0,0 +1,658 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Console
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Unix.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+
+/**
+ * ZendX_Console_Process_Unix allows you to spawn a class as a separated process
+ *
+ * @category ZendX
+ * @package ZendX_Console
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class ZendX_Console_Process_Unix
+{
+ /**
+ * Void method
+ */
+ const VOID_METHOD = 'void_method';
+
+ /**
+ * Return method
+ */
+ const RETURN_METHOD = 'void_method';
+
+ /**
+ * Unique thread name
+ *
+ * @var string
+ */
+ private $_name;
+
+ /**
+ * PID of the child process
+ *
+ * @var integer
+ */
+ private $_pid = null;
+
+ /**
+ * UID of the child process owner
+ *
+ * @var integer
+ */
+ private $_puid = null;
+
+ /**
+ * GUID of the child process owner
+ *
+ * @var integer
+ */
+ private $_guid = null;
+
+ /**
+ * Whether the process is yet forked or not
+ *
+ * @var boolean
+ */
+ private $_isRunning = false;
+
+ /**
+ * Wether we are into child process or not
+ *
+ * @var boolean
+ */
+ private $_isChild = false;
+
+ /**
+ * A data structure to hold data for Inter Process Communications
+ *
+ * @var array
+ */
+ private $_internalIpcData = array();
+
+ /**
+ * Key to access to Shared Memory Area.
+ *
+ * @var integer
+ */
+ private $_internalIpcKey;
+
+ /**
+ * Key to access to Sync Semaphore.
+ *
+ * @var integer
+ */
+ private $_internalSemKey;
+
+ /**
+ * Is Shared Memory Area OK? If not, the start() method will block.
+ * Otherwise we'll have a running child without any communication channel.
+ *
+ * @var boolean
+ */
+ private $_ipcIsOkay;
+
+ /**
+ * Filename of the IPC segment file
+ *
+ * @var string
+ */
+ private $_ipcSegFile;
+
+ /**
+ * Filename of the semaphor file
+ *
+ * @var string
+ */
+ private $_ipcSemFile;
+
+ /**
+ * Constructor method
+ *
+ * Allocates a new pseudo-thread object. Optionally, set a PUID, a GUID and
+ * a UMASK for the child process. This also initialize Shared Memory
+ * Segments for process communications.
+ *
+ * @param integer $puid
+ * @param integer $guid
+ * @param integer $umask
+ * @throws ZendX_Console_Process_Exception When running on windows
+ * @throws ZendX_Console_Process_Exception When running in web enviroment
+ * @throws ZendX_Console_Process_Exception When shmop_* functions don't exist
+ * @throws ZendX_Console_Process_Exception When pcntl_* functions don't exist
+ * @throws ZendX_Console_Process_Exception When posix_* functions don't exist
+ */
+ public function __construct($puid = null, $guid = null, $umask = null)
+ {
+ if (substr(PHP_OS, 0, 3) === 'WIN') {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Cannot run on windows');
+ } else if (!in_array(substr(PHP_SAPI, 0, 3), array('cli', 'cgi'))) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Can only run on CLI or CGI enviroment');
+ } else if (!function_exists('shmop_open')) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('shmop_* functions are required');
+ } else if (!function_exists('pcntl_fork')) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('pcntl_* functions are required');
+ } else if (!function_exists('posix_kill')) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('posix_* functions are required');
+ }
+
+ $this->_isRunning = false;
+
+ $this->_name = md5(uniqid(rand()));
+ $this->_guid = $guid;
+ $this->_puid = $puid;
+
+ if ($umask !== null) {
+ umask($umask);
+ }
+
+ // Try to create the shared memory segment. The variable
+ // $this->_ipcIsOkay contains the return code of this operation and must
+ // be checked before forking
+ if ($this->_createIpcSegment() && $this->_createIpcSemaphore()) {
+ $this->_ipcIsOkay = true;
+ } else {
+ $this->_ipcIsOkay = false;
+ }
+ }
+
+ /**
+ * Stop the child on destruction
+ */
+ public function __destruct()
+ {
+ if ($this->isRunning()) {
+ $this->stop();
+ }
+ }
+
+ /**
+ * Causes this pseudo-thread to begin parallel execution.
+ *
+ * This method first checks of all the Shared Memory Segment. If okay, it
+ * forks the child process, attaches signal handler and returns immediatly.
+ * The status is set to running, and a PID is assigned. The result is that
+ * two pseudo-threads are running concurrently: the current thread (which
+ * returns from the call to the start() method) and the other thread (which
+ * executes its run() method).
+ *
+ * @throws ZendX_Console_Process_Exception When SHM segments can't be created
+ * @throws ZendX_Console_Process_Exception When process forking fails
+ * @return void
+ */
+ public function start()
+ {
+ if (!$this->_ipcIsOkay) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Unable to create SHM segments for process communications');
+ }
+
+ // @see http://www.php.net/manual/en/function.pcntl-fork.php#41150
+ @ob_end_flush();
+
+ pcntl_signal(SIGCHLD, SIG_IGN);
+
+ $pid = @pcntl_fork();
+ if ($pid === -1) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Forking process failed');
+ } else if ($pid === 0) {
+ // This is the child
+ $this->_isChild = true;
+
+ // Sleep a second to avoid problems
+ sleep(1);
+
+ // Install the signal handler
+ pcntl_signal(SIGUSR1, array($this, '_sigHandler'));
+
+ // If requested, change process identity
+ if ($this->_guid !== null) {
+ posix_setgid($this->_guid);
+ }
+
+ if ($this->_puid !== null) {
+ posix_setuid($this->_puid);
+ }
+
+ // Run the child
+ try {
+ $this->_run();
+ } catch (Exception $e) {
+ // We have to catch any exceptions and clean up the process,
+ // else we will have a memory leak.
+ }
+
+ // Destroy the child after _run() execution. Required to avoid
+ // unuseful child processes after execution
+ exit(0);
+ } else {
+ // Else this is the parent
+ $this->_isChild = false;
+ $this->_isRunning = true;
+ $this->_pid = $pid;
+ }
+ }
+
+ /**
+ * Causes the current thread to die.
+ *
+ * The relative process is killed and disappears immediately from the
+ * processes list.
+ *
+ * @return boolean
+ */
+ public function stop()
+ {
+ $success = false;
+
+ if ($this->_pid > 0) {
+ $status = 0;
+
+ posix_kill($this->_pid, 9);
+ pcntl_waitpid($this->_pid, $status, WNOHANG);
+ $success = pcntl_wifexited($status);
+ $this->_cleanProcessContext();
+ }
+
+ return $success;
+ }
+
+ /**
+ * Test if the pseudo-thread is already started.
+ *
+ * @return boolean
+ */
+ public function isRunning()
+ {
+ return $this->_isRunning;
+ }
+
+ /**
+ * Set a variable into the shared memory segment, so that it can accessed
+ * both from the parent and from the child process. Variable names
+ * beginning with underlines are only permitted to interal functions.
+ *
+ * @param string $name
+ * @param mixed $value
+ * @throws ZendX_Console_Process_Exception When an invalid variable name is supplied
+ * @return void
+ */
+ public function setVariable($name, $value)
+ {
+ if ($name[0] === '_') {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Only internal functions may use underline (_) as variable prefix');
+ }
+
+ $this->_writeVariable($name, $value);
+ }
+
+ /**
+ * Get a variable from the shared memory segment. Returns NULL if the
+ * variable doesn't exist.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getVariable($name)
+ {
+ $this->_readFromIpcSegment();
+
+ if (isset($this->_internalIpcData[$name])) {
+ return $this->_internalIpcData[$name];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Read the time elapsed since the last child setAlive() call.
+ *
+ * This method is useful because often we have a pseudo-thread pool and we
+ * need to know each pseudo-thread status. If the child executes the
+ * setAlive() method, the parent with getLastAlive() can know that child is
+ * alive.
+ *
+ * @return integer
+ */
+ public function getLastAlive()
+ {
+ $pingTime = $this->getVariable('_pingTime');
+
+ return ($pingTime === null ? 0 : (time() - $pingTime));
+ }
+
+ /**
+ * Returns the PID of the current pseudo-thread.
+ *
+ * @return integer
+ */
+ public function getPid()
+ {
+ return $this->_pid;
+ }
+
+ /**
+ * Set a pseudo-thread property that can be read from parent process
+ * in order to know the child activity.
+ *
+ * Practical usage requires that child process calls this method at regular
+ * time intervals; parent will use the getLastAlive() method to know
+ * the elapsed time since the last pseudo-thread life signals...
+ *
+ * @return void
+ */
+ protected function _setAlive()
+ {
+ $this->_writeVariable('_pingTime', time());
+ }
+
+
+ /**
+ * This is called from within the parent; all the communication stuff
+ * is done here.
+ *
+ * @param string $methodName
+ * @param array $argList
+ * @param string $type
+ * @return mixed
+ */
+ protected function _callCallbackMethod($methodName, array $argList = array(), $type = self::VOID_METHOD)
+ {
+ // This is the parent, so we really cannot execute the method. Check
+ // arguments passed to the method.
+ if ($type === self::RETURN_METHOD) {
+ $this->_internalIpcData['_callType'] = self::RETURN_METHOD;
+ } else {
+ $this->_internalIpcData['_callType'] = self::VOID_METHOD;
+ }
+
+ // These setting are common to both the calling types
+ $this->_internalIpcData['_callMethod'] = $methodName;
+ $this->_internalIpcData['_callInput'] = $argList;
+
+ // Write the IPC data to the shared segment
+ $this->_writeToIpcSegment();
+
+ // Now we need to differentiate a bit.
+ switch ($this->_internalIpcData['_callType']) {
+ case VOID_METHOD:
+ // Notify the child so it can process the request
+ $this->_sendSigUsr1();
+ break;
+
+ case RETURN_METHOD:
+ // Set the semaphorew
+ shmop_write($this->_internalSemKey, 1, 0);
+
+ // Notify the child so it can process the request
+ $this->_sendSigUsr1();
+
+ // Block until the child process return
+ $this->_waitForIpcSemaphore();
+
+ // Read from the SHM segment. The result is stored into
+ // $this->_internalIpcData['_callOutput']
+ $this->_readFromIpcSegment();
+
+ // Data are returned. Now we can reset the semaphore
+ shmop_write($this->_internalSemKey, 0, 1);
+
+ // Return the result. Hence no break required here
+ return $this->_internalIpcData['_callOutput'];
+ }
+ }
+
+ /**
+ * This method actually implements the pseudo-thread logic.
+ *
+ * @return void
+ */
+ abstract protected function _run();
+
+ /**
+ * Sends signal to the child process
+ *
+ * @return void
+ */
+ private function _sendSigUsr1()
+ {
+ if ($this->_pid > 0) {
+ posix_kill($this->_pid, SIGUSR1);
+ }
+ }
+
+ /**
+ * Acutally Write a variable to the shared memory segment
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ */
+ private function _writeVariable($name, $value)
+ {
+ $this->_internalIpcData[$name] = $value;
+ $this->_writeToIpcSegment();
+ }
+
+ /**
+ * Destroy thread context and free relative resources.
+ *
+ * @return void
+ */
+ private function _cleanProcessContext()
+ {
+ shmop_delete($this->_internalIpcKey);
+ shmop_delete($this->_internalSemKey);
+
+ shmop_close($this->_internalIpcKey);
+ shmop_close($this->_internalSemKey);
+
+ @unlink($this->_ipcSegFile);
+ @unlink($this->_ipcSemFile);
+
+ $this->_isRunning = false;
+ $this->_pid = null;
+ }
+
+ /**
+ * This is the signal handler that makes the communications between client
+ * and server possible.
+ *
+ * @param integer $signo
+ * @return void
+ */
+ private function _sigHandler($signo)
+ {
+ switch ($signo) {
+ case SIGTERM:
+ // Handle shutdown tasks. Hence no break is require
+ exit;
+
+ case SIGUSR1:
+ // This is the User-defined signal we'll use. Read the SHM segment
+ $this->_readFromIpcSegment();
+
+ if (isset($this->_internalIpcData['_callType'])) {
+ $method = $this->_internalIpcData['_callMethod'];
+ $params = $this->_internalIpcData['_callInput'];
+
+ switch ($this->_internalIpcData['_callType']) {
+ case self::VOID_METHOD:
+ // Simple call the (void) method and return immediatly
+ // no semaphore is placed into parent, so the processing
+ // is async
+ call_user_func(array($this, $method), $params);
+ break;
+
+ case self::RETURN_METHOD:
+ // Process the request
+ $this->_internalIpcData['_callOutput'] = call_user_func(array($this, $method), $params);
+
+ // Write the result into IPC segment
+ $this->_writeToIPCsegment();
+
+ // Unlock the semaphore but block _writeToIpcSegment()
+ shmop_write($this->_internalSemKey, 0, 0);
+ shmop_write($this->_internalSemKey, 1, 1);
+ break;
+ }
+ }
+ break;
+
+ default:
+ // Ignore all other singals
+ break;
+ }
+ }
+
+ /**
+ * Wait for IPC Semaphore
+ *
+ * @return void
+ */
+ private function _waitForIpcSemaphore()
+ {
+ while (true) {
+ $okay = shmop_read($this->_internalSemKey, 0, 1);
+
+ if ($okay === 0) {
+ break;
+ }
+
+ usleep(10);
+ }
+ }
+
+ /**
+ * Read data from IPC segment
+ *
+ * @throws ZendX_Console_Process_Exception When writing of SHM segment fails
+ * @return void
+ */
+ private function _readFromIpcSegment()
+ {
+ $serializedIpcData = shmop_read($this->_internalIpcKey,
+ 0,
+ shmop_size($this->_internalIpcKey));
+
+ if ($serializedIpcData === false) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Fatal error while reading SHM segment');
+ }
+
+ $data = @unserialize($serializedIpcData);
+
+ if ($data !== false) {
+ $this->_internalIpcData = $data;
+ }
+ }
+
+ /**
+ * Write data to IPC segment
+ *
+ * @throws ZendX_Console_Process_Exception When writing of SHM segment fails
+ * @return void
+ */
+ private function _writeToIpcSegment()
+ {
+ // Read the transaction bit (2 bit of _internalSemKey segment). If it's
+ // value is 1, we're into the execution of a PHP_FORK_RETURN_METHOD, so
+ // we must not write to segment (data corruption)
+ if (shmop_read($this->_internalSemKey, 1, 1) === 1) {
+ return;
+ }
+
+ $serializedIpcData = serialize($this->_internalIpcData);
+
+ // Set the exchange array (IPC) into the shared segment
+ $shmBytesWritten = shmop_write($this->_internalIpcKey,
+ $serializedIpcData,
+ 0);
+
+ // Check if lenght of SHM segment is enougth to contain data
+ if ($shmBytesWritten !== strlen($serializedIpcData)) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Fatal error while writing to SHM segment');
+ }
+ }
+
+ /**
+ * Create an IPC segment
+ *
+ * @throws ZendX_Console_Process_Exception When SHM segment can't be created
+ * @return boolean
+ */
+ private function _createIpcSegment()
+ {
+ $this->_ipcSegFile = realpath(sys_get_temp_dir()) . '/' . rand() . $this->_name . '.shm';
+ touch($this->_ipcSegFile);
+
+ $shmKey = ftok($this->_ipcSegFile, 't');
+ if ($shmKey === -1) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Could not create SHM segment');
+ }
+
+ $this->_internalIpcKey = @shmop_open($shmKey, 'c', 0644, 10240);
+
+ if (!$this->_internalIpcKey) {
+ @unlink($this->_ipcSegFile);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Create IPC semaphore
+ *
+ * @throws ZendX_Console_Process_Exception When semaphore can't be created
+ * @return boolean
+ */
+ private function _createIpcSemaphore()
+ {
+ $this->_ipcSemFile = realpath(sys_get_temp_dir()) . '/' . rand() . $this->_name . '.sem';
+ touch($this->_ipcSemFile);
+
+ $semKey = ftok($this->_ipcSemFile, 't');
+ if ($semKey === -1) {
+ require_once 'ZendX/Console/Process/Exception.php';
+ throw new ZendX_Console_Process_Exception('Could not create semaphore');
+ }
+
+ $this->_internalSemKey = @shmop_open($semKey, 'c', 0644, 10);
+
+ if (!$this->_internalSemKey) {
+ @unlink($this->_ipcSemFile);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/library/ZendX/Db/Adapter/Firebird.php b/library/ZendX/Db/Adapter/Firebird.php
new file mode 100644
index 0000000..53cf667
--- /dev/null
+++ b/library/ZendX/Db/Adapter/Firebird.php
@@ -0,0 +1,597 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Adapter
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: $
+ */
+
+/**
+ * @see Zend_Db_Adapter_Abstract
+ */
+require_once 'Zend/Db/Adapter/Abstract.php';
+
+/**
+ * @see Zend_Db_Profiler
+ */
+require_once 'Zend/Db/Profiler.php';
+
+/**
+ * @see Zend_Db_Select
+ */
+require_once 'Zend/Db/Select.php';
+
+/**
+ * @see Zend_Db_Statement_Firebird
+ */
+require_once 'ZendX/Db/Statement/Firebird.php';
+
+
+/**
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Adapter
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Db_Adapter_Firebird extends Zend_Db_Adapter_Abstract
+{
+ /**
+ * Specifies whether the adapter automatically quotes identifiers.
+ * If true, most SQL generated by Zend_Db classes applies
+ * identifier quoting automatically.
+ * If false, developer must quote identifiers themselves
+ * by calling quoteIdentifier().
+ *
+ * @var bool
+ */
+ protected $_autoQuoteIdentifiers = true;
+
+ /**
+ * The transaction resource.
+ *
+ * @var transaction
+ */
+ protected $_transResource = null;
+
+ /**
+ * Return the status of current transaction.
+ * @return bool
+ */
+
+ public function getTransaction()
+ {
+ return (is_resource($this->_transResource) ? $this->_transResource : null);
+ }
+
+ /**
+ * Keys are UPPERCASE SQL datatypes or the constants
+ * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
+ *
+ * Values are:
+ * 0 = 32-bit integer
+ * 1 = 64-bit integer
+ * 2 = float or decimal
+ *
+ * @var array Associative array of datatypes to values 0, 1, or 2.
+ */
+ protected $_numericDataTypes = array(
+ Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
+ Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
+ Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
+ 'SMALLINT' => Zend_Db::INT_TYPE,
+ 'INT' => Zend_Db::INT_TYPE,
+ 'INTEGER' => Zend_Db::INT_TYPE,
+ 'BIGINT' => Zend_Db::BIGINT_TYPE,
+ 'INT64' => Zend_Db::BIGINT_TYPE,
+ 'DECIMAL' => Zend_Db::FLOAT_TYPE,
+ 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
+ 'DOUBLE' => Zend_Db::FLOAT_TYPE,
+ 'NUMERIC' => Zend_Db::FLOAT_TYPE,
+ 'FLOAT' => Zend_Db::FLOAT_TYPE
+ );
+
+ /**
+ * Quote a raw string.
+ *
+ * @param string $value Raw string
+ * @return string Quoted string
+ */
+ protected function _quote($value)
+ {
+ if (is_int($value) || is_float($value)) {
+ return $value;
+ }
+ $value = str_replace("'", "''", $value);
+ return "'" . $value . "'";
+ }
+
+ /**
+ * Returns a list of the tables in the database.
+ *
+ * @return array
+ */
+ public function listTables()
+ {
+ $data = $this->fetchCol('SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG = 0');
+ foreach($data as &$v)
+ $v = trim($v);
+ return $data;
+ }
+
+ /**
+ * Returns the column descriptions for a table.
+ *
+ * The return value is an associative array keyed by the column name,
+ * as returned by the RDBMS.
+ *
+ * The value of each array element is an associative array
+ * with the following keys:
+ *
+ * SCHEMA_NAME => string; name of database or schema
+ * TABLE_NAME => string;
+ * COLUMN_NAME => string; column name
+ * COLUMN_POSITION => number; ordinal position of column in table
+ * DATA_TYPE => string; SQL datatype name of column
+ * DEFAULT => string; default expression of column, null if none
+ * NULLABLE => boolean; true if column can have nulls
+ * LENGTH => number; length of CHAR/VARCHAR
+ * SCALE => number; scale of NUMERIC/DECIMAL
+ * PRECISION => number; precision of NUMERIC/DECIMAL
+ * UNSIGNED => boolean; unsigned property of an integer type
+ * PRIMARY => boolean; true if column is part of the primary key
+ * PRIMARY_POSITION => integer; position of column in primary key
+ * IDENTITY => integer; true if column is auto-generated with unique values
+ *
+ * @param string $tableName
+ * @param string $schemaName OPTIONAL
+ * @return array
+ */
+ public function describeTable($tableName, $schemaName = null)
+ {
+ $fieldMaps = array(
+ 'TEXT' => 'CHAR',
+ 'VARYING' => 'VARCHAR',
+ 'SHORT' => 'SMALLINT',
+ 'LONG' => 'INTEGER',
+ 'FLOAT' => 'FLOAT',
+ 'INT64' => array(0 => 'BIGINT', 'NUMERIC', 'DECIMAL'),
+ 'DATE' => 'DATE',
+ 'TIME' => 'TIME',
+ 'BLOB' => 'BLOB',
+ 'DOUBLE' => 'DOUBLE PRECISION',
+ 'TIMESTAMP' => 'TIMESTAMP'
+ );
+
+ $sql = 'select
+ RF.RDB$RELATION_NAME, \'\', RF.RDB$FIELD_NAME, T.RDB$TYPE_NAME,
+ RF.RDB$DEFAULT_VALUE, RF.RDB$NULL_FLAG, RF.RDB$FIELD_POSITION,
+ F.RDB$CHARACTER_LENGTH, F.RDB$FIELD_SCALE, F.RDB$FIELD_PRECISION,
+ IXS.RDB$FIELD_POSITION, IXS.RDB$FIELD_POSITION, F.RDB$FIELD_SUB_TYPE
+ from RDB$RELATION_FIELDS RF
+ left join RDB$RELATION_CONSTRAINTS RC
+ on (RF.RDB$RELATION_NAME = RC.RDB$RELATION_NAME and RC.RDB$CONSTRAINT_TYPE = \'PRIMARY KEY\')
+ left join RDB$INDEX_SEGMENTS IXS
+ on (IXS.RDB$FIELD_NAME = RF.RDB$FIELD_NAME and RC.RDB$INDEX_NAME = IXS.RDB$INDEX_NAME)
+ inner join RDB$FIELDS F on (RF.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME)
+ inner join RDB$TYPES T on (T.RDB$TYPE = F.RDB$FIELD_TYPE and T.RDB$FIELD_NAME = \'RDB$FIELD_TYPE\')
+ where ' . $this->quoteInto('(UPPER(RF.RDB$RELATION_NAME) = UPPER(?)) ', $tableName) . '
+ order by RF.RDB$FIELD_POSITION';
+
+ $stmt = $this->query($sql);
+
+ /**
+ * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ */
+ $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
+
+ $table_name = 0;
+ $owner = 1;
+ $column_name = 2;
+ $data_type = 3;
+ $data_default = 4;
+ $nullable = 5;
+ $column_id = 6;
+ $data_length = 7;
+ $data_scale = 8;
+ $data_precision = 9;
+ $constraint_type = 10;
+ $position = 11;
+ $sub_type = 12;
+
+ $desc = array();
+ foreach ($result as $key => $row) {
+ list ($primary, $primaryPosition, $identity) = array(false, null, false);
+ if (strlen($row[$constraint_type])) {
+ $primary = true;
+ $primaryPosition = $row[$position];
+ /**
+ * Firebird does not support auto-increment keys.
+ */
+ $identity = false;
+ }
+
+ $dataType = trim($row[$data_type]);
+ $newType = $fieldMaps[$dataType];
+ if (is_array($newType) && $dataType == 'INT64')
+ $newType = $newType[$row[$sub_type]];
+ $row[$data_type] = $newType;
+
+ $desc[trim($row[$column_name])] = array(
+ 'SCHEMA_NAME' => '',
+ 'TABLE_NAME' => trim($row[$table_name]),
+ 'COLUMN_NAME' => trim($row[$column_name]),
+ 'COLUMN_POSITION' => $row[$column_id] +1,
+ 'DATA_TYPE' => $row[$data_type],
+ 'DEFAULT' => $row[$data_default],
+ 'NULLABLE' => (bool) ($row[$nullable] != '1'),
+ 'LENGTH' => $row[$data_length],
+ 'SCALE' => ($row[$data_scale] == 0 ? null : $row[$data_scale]),
+ 'PRECISION' => ($row[$data_precision] == 0 ? null : $row[$data_precision]),
+ 'UNSIGNED' => false,
+ 'PRIMARY' => $primary,
+ 'PRIMARY_POSITION' => ($primary ? $primaryPosition+1 : null),
+ 'IDENTITY' => $identity
+ );
+ }
+ return $desc;
+ }
+
+
+ /**
+ * Format a connection string to connect to database
+ *
+ * @return void
+ */
+ protected function _formatDbConnString($host, $port, $dbname)
+ {
+ if (is_numeric($port))
+ $port = '/' . (integer) $port;
+ if ($dbname)
+ $dbname = ':' . $dbname;
+
+ return $host . $port . $dbname;
+
+ }
+
+ /**
+ * Creates a connection to the database.
+ *
+ * @return void
+ * @throws ZendX_Db_Adapter_Firebird_Exception
+ */
+ protected function _connect()
+ {
+ if (isset($this->_connection) && is_resource($this->_connection)) {
+ return;
+ }
+
+ if (!extension_loaded('interbase')) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception('The Interbase extension is required for this adapter but the extension is not loaded');
+ }
+
+
+ // Suppress connection warnings here.
+ // Throw an exception instead.
+ $this->_connection = @ibase_connect(
+ $this->_formatDbConnString($this->_config['host'],$this->_config['port'] ,$this->_config['dbname']),
+ $this->_config['username'],
+ $this->_config['password'],
+ $this->_config['charset'],
+ $this->_config['buffers'],
+ $this->_config['dialect'],
+ $this->_config['role']
+ );
+
+ if ($this->_connection === false) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
+ }
+ }
+
+ /**
+ * Force the connection to close.
+ *
+ * @return void
+ */
+ public function closeConnection()
+ {
+ if (is_resource($this->_transResource)) {
+ ibase_rollback($this->_transResource);
+ }
+ $this->_transResource = null;
+
+ if (is_resource($this->_connection)) {
+ unset($this->_connection);
+ }
+ //$this->_connection = false;
+ }
+
+ /**
+ * Prepare a statement and return a Statement resource.
+ *
+ * @param string $sql SQL query
+ * @return ZendX_Db_Statement_Firebird
+ */
+ public function prepare($sql)
+ {
+ $this->_connect();
+
+ $stmt = new ZendX_Db_Statement_Firebird($this, $sql);
+ if ($stmt === false) {
+ return false;
+ }
+ $stmt->setFetchMode($this->_fetchMode);
+ return $stmt;
+ }
+
+ /**
+ * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
+ *
+ * As a convention, on RDBMS brands that support sequences
+ * (e.g. Firebird, Oracle, PostgreSQL, DB2), this method forms the name of a sequence
+ * from the arguments and returns the last id generated by that sequence.
+ * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
+ * returns the last value generated for such a column, and the table name
+ * argument is disregarded.
+ *
+ * Firebird does not support IDENTITY columns, so if the sequence is not
+ * specified, this method returns null.
+ *
+ * @param string $tableName OPTIONAL Name of table.
+ * @param string $primaryKey OPTIONAL Name of primary key column.
+ * @return string
+ * @throws ZendX_Db_Adapter_Firebird_Exception
+ */
+ public function lastInsertId($tableName = null, $primaryKey = null)
+ {
+ if ($tableName !== null) {
+ $sequenceName = $tableName;
+ if ($primaryKey) {
+ $sequenceName .= "_$primaryKey";
+ }
+ $sequenceName .= '_seq';
+ return $this->lastSequenceId($sequenceName);
+ }
+
+ // No support for IDENTITY columns; return null
+ return null;
+ }
+
+ /**
+ * Begin a transaction.
+ *
+ * @return void
+ */
+ protected function _beginTransaction()
+ {
+ $this->_connect();
+ if (is_resource($this->_transResource)){
+ return;
+ }
+
+ $this->_transResource = ibase_trans(IBASE_DEFAULT, $this->_connection);
+ }
+
+ /**
+ * Commit a transaction.
+ *
+ * @return void
+ */
+ protected function _commit()
+ {
+ if (false === ibase_commit(is_resource($this->_transResource) ? $this->_transResource : $this->_connection)) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
+ }
+ $this->_transResource = null;
+ }
+
+ /**
+ * Roll-back a transaction.
+ *
+ * @return void
+ */
+ protected function _rollBack()
+ {
+ if (false === ibase_rollback(is_resource($this->_transResource) ? $this->_transResource : $this->_connection)) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
+ }
+ $this->_transResource = null;
+ }
+
+ /**
+ * Set the fetch mode.
+ *
+ * @param int $mode
+ * @return void
+ */
+ public function setFetchMode($mode)
+ {
+ switch ($mode) {
+ case Zend_Db::FETCH_LAZY:
+ case Zend_Db::FETCH_ASSOC:
+ case Zend_Db::FETCH_NUM:
+ case Zend_Db::FETCH_BOTH:
+ case Zend_Db::FETCH_NAMED:
+ case Zend_Db::FETCH_OBJ:
+ case Zend_Db::FETCH_BOUND: // bound to PHP variable
+ $this->_fetchMode = $mode;
+ break;
+ default:
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception("Invalid fetch mode '$mode' specified");
+ }
+ }
+
+ /**
+ * Adds an adapter-specific LIMIT clause to the SELECT statement.
+ *
+ * @param string $sql
+ * @param integer $count
+ * @param integer $offset
+ * @throws Zend_Db_Adapter_Exception
+ * @return string
+ */
+ public function limit($sql, $count, $offset = 0)
+ {
+ $count = intval($count);
+ if ($count <= 0) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception("LIMIT argument count=$count is not valid");
+ }
+
+ $offset = intval($offset);
+ if ($offset < 0) {
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
+ throw new ZendX_Db_Adapter_Firebird_Exception("LIMIT argument offset=$offset is not valid");
+ }
+
+ if (trim($sql) == ''){
+ //Only compatible with FB 2.0 or newer
+ //ZF 1.5.0 don't support limit sql syntax that don't only append texto to sql, fixed in 1.5.1
+ $sql .= " rows $count";
+ if ($offset > 0)
+ $sql .= " to $offset";
+ }
+ else
+ $sql = substr_replace($sql, "select first $count skip $offset ", stripos($sql, 'select'), 6);
+
+ return $sql;
+ }
+
+ /**
+ * Quote a table identifier and alias.
+ *
+ * @param string|array|Zend_Db_Expr $ident The identifier or expression.
+ * @param string $alias An alias for the table.
+ * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
+ * @return string The quoted identifier and alias.
+ */
+ public function quoteTableAs($ident, $alias = null, $auto=false)
+ {
+ // Firebird doesn't allow the 'AS' keyword between the table identifier/expression and alias.
+ return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
+ }
+
+ /**
+ * Return the most recent value from the specified sequence in the database.
+ * This is supported only on RDBMS brands that support sequences
+ * (e.g. Firebird, Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
+ *
+ * @param string $sequenceName
+ * @return string
+ */
+ public function lastSequenceId($sequenceName)
+ {
+ $this->_connect();
+ $sql = 'SELECT GEN_ID('.$this->quoteIdentifier($sequenceName).', 0) FROM RDB$DATABASE';
+ $value = $this->fetchOne($sql);
+ return $value;
+ }
+
+ /**
+ * Generate a new value from the specified sequence in the database, and return it.
+ * This is supported only on RDBMS brands that support sequences
+ * (e.g. Firebird, Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
+ *
+ * @param string $sequenceName
+ * @return integer
+ */
+ public function nextSequenceId($sequenceName)
+ {
+ $this->_connect();
+ $sql = 'SELECT GEN_ID('.$this->quoteIdentifier($sequenceName).', 1) FROM RDB$DATABASE';
+ $value = $this->fetchOne($sql);
+ return $value;
+ }
+
+ /**
+ * Check if the adapter supports real SQL parameters.
+ *
+ * @param string $type 'positional' or 'named'
+ * @return bool
+ */
+ public function supportsParameters($type)
+ {
+ switch ($type) {
+ case 'positional':
+ return true;
+ case 'named':
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Test if a connection is active
+ *
+ * @return boolean
+ */
+ public function isConnected()
+ {
+ return ((bool) (is_resource($this->_connection)
+ && get_resource_type($this->_connection) == 'Firebird/InterBase link'));
+ }
+
+ /**
+ * Retrieve server version in PHP style
+ *
+ * @return string
+ */
+ public function getServerVersion()
+ {
+ $this->_connect();
+ $service = ibase_service_attach($this->_formatDbConnString($this->_config['host'], $this->_config['port'], ''), $this->_config['username'], $this->_config['password']);
+
+ if ($service != FALSE) {
+ $server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
+ ibase_service_detach($service);
+ $matches = null;
+ if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $server_info, $matches)) {
+ return $matches[1];
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/Db/Adapter/Firebird/Exception.php b/library/ZendX/Db/Adapter/Firebird/Exception.php
new file mode 100644
index 0000000..7e2a2e4
--- /dev/null
+++ b/library/ZendX/Db/Adapter/Firebird/Exception.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package ZendX_Db
+ * @subpackage Adapter
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: $
+ */
+
+/**
+ * @see Zend_Db_Adapter_Exception
+ */
+require_once 'Zend/Db/Adapter/Exception.php';
+
+/**
+ * ZendX_Db_Adapter_Firebird_Exception
+ *
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Adapter
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Db_Adapter_Firebird_Exception extends Zend_Db_Adapter_Exception
+{
+}
diff --git a/library/ZendX/Db/Statement/Firebird.php b/library/ZendX/Db/Statement/Firebird.php
new file mode 100644
index 0000000..dc82bd0
--- /dev/null
+++ b/library/ZendX/Db/Statement/Firebird.php
@@ -0,0 +1,369 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Statement
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: $
+ */
+
+/**
+ * @see Zend_Db_Statement
+ */
+require_once 'Zend/Db/Statement.php';
+
+/**
+ * Extends for Firebird
+ *
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Statement
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Db_Statement_Firebird extends Zend_Db_Statement
+{
+
+ /**
+ * The firebird_stmtPrepared resource.
+ *
+ * @var firebird_stmtPrepared
+ */
+ protected $_stmtPrepared = null;
+
+ /**
+ * The firebird_stmtResult resource.
+ *
+ * @var firebird_result
+ */
+ protected $_stmtResult = null;
+
+ /**
+ * The firebird_stmtResult resource.
+ *
+ * @var firebird_result
+ */
+ protected $_stmtRowCount = 0;
+
+ /**
+ * The firebird_stmtResult resource.
+ *
+ * @var firebird_result
+ */
+ protected $_stmtColumnCount = 0;
+
+ /**
+ * Column names.
+ *
+ * @var array
+ */
+ protected $_keys = array();
+
+ /**
+ * Fetched result values.
+ *
+ * @var array
+ */
+ protected $_values = array();
+
+ /**
+ * @var array
+ */
+ protected $_meta = null;
+
+ /**
+ * @param string $sql
+ * @return void
+ * @throws ZendX_Db_Statement_Firebird_Exception
+ */
+ public function _prepare($sql)
+ {
+ $this->_stmtRowCount = 0;
+ $this->_stmtColumnCount = 0;
+
+ $connection = $this->_adapter->getConnection();
+
+ if ($trans = $this->_adapter->getTransaction())
+ $this->_stmtPrepared = @ibase_prepare($connection, $trans, $sql);
+ else
+ $this->_stmtPrepared = @ibase_prepare($connection, $sql);
+
+ if ($this->_stmtPrepared === false) {
+ /**
+ * @see ZendX_Db_Statement_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Statement/Firebird/Exception.php';
+ throw new ZendX_Db_Statement_Firebird_Exception("Firebird prepare error: " . ibase_errmsg());
+ }
+ }
+
+ /**
+ * Binds a parameter to the specified variable name.
+ *
+ * @param mixed $parameter Name the parameter, either integer or string.
+ * @param mixed $variable Reference to PHP variable containing the value.
+ * @param mixed $type OPTIONAL Datatype of SQL parameter.
+ * @param mixed $length OPTIONAL Length of SQL parameter.
+ * @param mixed $options OPTIONAL Other options.
+ * @return bool
+ * @throws ZendX_Db_Statement_Firebird_Exception
+ */
+ protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
+ {
+ return true;
+ }
+
+ /**
+ * Closes the cursor and the statement.
+ *
+ * @return bool
+ */
+ public function close()
+ {
+ if ($stmt = $this->_stmtResult) {
+ @ibase_free_result($this->_stmtResult);
+ $this->_stmtResult = null;
+ }
+
+ if ($this->_stmtPrepared) {
+ $r = @ibase_free_query($this->_stmtPrepared);
+ $this->_stmtPrepared = null;
+ return $r;
+ }
+ return false;
+ }
+
+ /**
+ * Closes the cursor, allowing the statement to be executed again.
+ *
+ * @return bool
+ */
+ public function closeCursor()
+ {
+ if ($stmt = $this->_stmtResult) {
+ return @ibase_free_result($this->_stmtResult);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the number of columns in the result set.
+ * Returns null if the statement has no result set metadata.
+ *
+ * @return int The number of columns.
+ */
+ public function columnCount()
+ {
+ return $this->_stmtColumnCount ? $this->_stmtColumnCount : 0;
+ }
+
+ /**
+ * Retrieves the error code, if any, associated with the last operation on
+ * the statement handle.
+ *
+ * @return string error code.
+ */
+ public function errorCode()
+ {
+ if ($this->_stmtPrepared || $this->_stmtResult) {
+ return ibase_errcode();
+ }
+ return false;
+ }
+
+ /**
+ * Retrieves an array of error information, if any, associated with the
+ * last operation on the statement handle.
+ *
+ * @return array
+ */
+ public function errorInfo()
+ {
+ if (!$this->_stmtPrepared) {
+ return false;
+ }
+ return array(
+ ibase_errcode(),
+ ibase_errmsg()
+ );
+ }
+
+ /**
+ * Executes a prepared statement.
+ *
+ * @param array $params OPTIONAL Values to bind to parameter placeholders.
+ * @return bool
+ * @throws ZendX_Db_Statement_Firebird_Exception
+ */
+ public function _execute(array $params = null)
+ {
+ if (!$this->_stmtPrepared) {
+ return false;
+ }
+
+ // if no params were given as an argument to execute(),
+ // then default to the _bindParam array
+ if ($params === null) {
+ $params = $this->_bindParam;
+ }
+ // send $params as input parameters to the statement
+ if ($params) {
+ array_unshift($params, $this->_stmtPrepared);
+ $retval = @call_user_func_array(
+ 'ibase_execute',
+ $params
+ );
+ } else
+ // execute the statement
+ $retval = @ibase_execute($this->_stmtPrepared);
+ $this->_stmtResult = $retval;
+
+ if ($retval === false) {
+ $last_error = ibase_errmsg();
+ $this->_stmtRowCount = 0;
+ }
+
+ //Firebird php ibase extension, auto-commit is not after each call, but at
+ //end of script. Disabled when transaction is active
+ if (!$this->_adapter->getTransaction())
+ ibase_commit_ret();
+
+ if ($retval === false) {
+ /**
+ * @see ZendX_Db_Statement_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Statement/Firebird/Exception.php';
+ throw new ZendX_Db_Statement_Firebird_Exception("Firebird statement execute error : " . $last_error);
+ }
+
+ // statements that have no result set do not return metadata
+ if (is_resource($this->_stmtResult)) {
+
+ // get the column names that will result
+ $this->_keys = array();
+ $coln = ibase_num_fields($this->_stmtResult);
+ $this->_stmtColumnCount = $coln;
+ for ($i = 0; $i < $coln; $i++) {
+ $col_info = ibase_field_info($this->_stmtResult, $i);
+ $this->_keys[] = $this->_adapter->foldCase($col_info['name']);
+ }
+
+ // set up a binding space for result variables
+ $this->_values = array_fill(0, count($this->_keys), null);
+
+ // set up references to the result binding space.
+ // just passing $this->_values in the call_user_func_array()
+ // below won't work, you need references.
+ $refs = array();
+ foreach ($this->_values as $i => &$f) {
+ $refs[$i] = &$f;
+ }
+ }
+
+ if ($trans = $this->_adapter->getTransaction())
+ $this->_stmtRowCount = ibase_affected_rows($trans);
+ else
+ $this->_stmtRowCount = ibase_affected_rows($this->_adapter->getConnection());
+ return true;
+ }
+
+ /**
+ * Fetches a row from the result set.
+ *
+ * @param int $style OPTIONAL Fetch mode for this fetch operation.
+ * @param int $cursor OPTIONAL Absolute, relative, or other.
+ * @param int $offset OPTIONAL Number for absolute or relative cursors.
+ * @return mixed Array, object, or scalar depending on fetch mode.
+ * @throws Zend_Db_Statement_Exception
+ */
+ public function fetch($style = null, $cursor = null, $offset = null)
+ {
+ if (!$this->_stmtResult) {
+ return false;
+ }
+
+ if ($style === null) {
+ $style = $this->_fetchMode;
+ }
+
+ switch ($style) {
+ case Zend_Db::FETCH_NUM:
+ $row = ibase_fetch_row($this->_stmtResult, IBASE_TEXT);
+ break;
+ case Zend_Db::FETCH_ASSOC:
+ $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
+ break;
+ case Zend_Db::FETCH_BOTH:
+ $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
+ if ($row !== false)
+ $row = array_merge($row, array_values($row));
+ break;
+ case Zend_Db::FETCH_OBJ:
+ $row = ibase_fetch_object($this->_stmtResult, IBASE_TEXT);
+ break;
+ case Zend_Db::FETCH_BOUND:
+ $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
+ if ($row !== false){
+ $row = array_merge($row, array_values($row));
+ $row = $this->_fetchBound($row);
+ }
+ break;
+ default:
+ /**
+ * @see ZendX_Db_Adapter_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Statement/Firebird/Exception.php';
+ throw new ZendX_Db_Statement_Firebird_Exception(
+ "Invalid fetch mode '$style' specified"
+ );
+ break;
+ }
+
+
+ return $row;
+ }
+
+ /**
+ * Retrieves the next rowset (result set) for a SQL statement that has
+ * multiple result sets. An example is a stored procedure that returns
+ * the results of multiple queries.
+ *
+ * @return bool
+ * @throws ZendX_Db_Statement_Firebird_Exception
+ */
+ public function nextRowset()
+ {
+ /**
+ * @see ZendX_Db_Statement_Firebird_Exception
+ */
+ require_once 'ZendX/Db/Statement/Firebird/Exception.php';
+ throw new ZendX_Db_Statement_Firebird_Exception(__FUNCTION__.'() is not implemented');
+ }
+
+ /**
+ * Returns the number of rows affected by the execution of the
+ * last INSERT, DELETE, or UPDATE statement executed by this
+ * statement object.
+ *
+ * @return int The number of rows affected.
+ * @throws Zend_Db_Statement_Exception
+ */
+ public function rowCount()
+ {
+ return $this->_stmtRowCount ? $this->_stmtRowCount : 0;
+ }
+
+}
diff --git a/library/ZendX/Db/Statement/Firebird/Exception.php b/library/ZendX/Db/Statement/Firebird/Exception.php
new file mode 100644
index 0000000..2593627
--- /dev/null
+++ b/library/ZendX/Db/Statement/Firebird/Exception.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package ZendX_Db
+ * @subpackage Statement
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: $
+ */
+
+/**
+ * @see Zend_Db_Statement_Exception
+ */
+require_once 'Zend/Db/Statement/Exception.php';
+
+/**
+ * ZendX_Db_Adapter_Firebird_Exception
+ *
+ * @category ZendX
+ * @package ZendX_Db
+ * @subpackage Statement
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Db_Statement_Firebird_Exception extends Zend_Db_Statement_Exception
+{
+}
+
diff --git a/library/ZendX/Exception.php b/library/ZendX/Exception.php
new file mode 100644
index 0000000..befbfa9
--- /dev/null
+++ b/library/ZendX/Exception.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_Whois
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * Exception class for ZendX
+ *
+ * @category ZendX
+ * @package ZendX
+ * @uses Zend_Exception
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_Exception extends Zend_Exception
+{
+}
diff --git a/library/ZendX/JQuery.php b/library/ZendX/JQuery.php
new file mode 100644
index 0000000..8559571
--- /dev/null
+++ b/library/ZendX/JQuery.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: JQuery.php 21869 2010-04-16 07:49:18Z beberlei $
+ */
+
+/**
+ * @see Zend_Json
+ */
+require_once "Zend/Json.php";
+
+/**
+ * jQuery Global Class holding constants and static convienience methods.
+ *
+ * @todo Offer convenience methods to add a tab or accordion container/pane combination.
+ * @package ZendX_JQuery
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery
+{
+ /**
+ * Current default supported jQuery library version with ZendX_JQuery
+ *
+ * @const string
+ */
+ const DEFAULT_JQUERY_VERSION = "1.3.2";
+
+ /**
+ * Currently supported jQuery UI library version with ZendX_JQuery
+ *
+ * @const string
+ */
+ const DEFAULT_UI_VERSION = "1.7.1";
+
+ /**
+ * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
+ * @const string Base path to CDN
+ */
+ const CDN_BASE_GOOGLE = 'http://ajax.googleapis.com/ajax/libs/';
+
+ /**
+ * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
+ * @const string Base path to CDN
+ */
+ const CDN_BASE_GOOGLE_SSL = 'https://ajax.googleapis.com/ajax/libs/';
+
+ /**
+ * @const string
+ */
+ const CDN_SUBFOLDER_JQUERY = 'jquery/';
+
+ /**
+ * @const string
+ */
+ const CDN_SUBFOLDER_JQUERYUI = 'jqueryui/';
+
+ /**
+ * Always uses compressed version, because this is assumed to be the use case
+ * in production enviroment. An uncompressed version has to included manually.
+ *
+ * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
+ * @const string File path after base and version
+ */
+ const CDN_JQUERY_PATH_GOOGLE = '/jquery.min.js';
+
+ /**
+ * Which parts of the the jQuery library should be rendered on echo'ing
+ * the jQuery library to the View. The constants act as bit-mask. This
+ * way the jQuery autogenerated code can be refactored based on personal needs.
+ *
+ * @see ZendX_JQuery_Helper_JQuery::setRenderMode
+ * @const Integer
+ */
+ const RENDER_LIBRARY = 1;
+ const RENDER_SOURCES = 2;
+ const RENDER_STYLESHEETS = 4;
+ const RENDER_JAVASCRIPT = 8;
+ const RENDER_JQUERY_ON_LOAD = 16;
+ const RENDER_ALL = 255;
+
+ /**
+ * jQuery-enable a view instance
+ *
+ * @param Zend_View_Interface $view
+ * @return void
+ */
+ public static function enableView(Zend_View_Interface $view)
+ {
+ if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
+ $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
+ }
+ }
+
+ /**
+ * jQuery-enable a form instance
+ *
+ * @param Zend_Form $form
+ * @return void
+ */
+ public static function enableForm(Zend_Form $form)
+ {
+ $form->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
+ ->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element')
+ ->addElementPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
+ ->addDisplayGroupPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator');
+
+ foreach ($form->getSubForms() as $subForm) {
+ self::enableForm($subForm);
+ }
+
+ if (null !== ($view = $form->getView())) {
+ self::enableView($view);
+ }
+ }
+
+ /**
+ * Encode Json that may include javascript expressions.
+ *
+ * Take care of using the Zend_Json_Encoder to alleviate problems with the json_encode
+ * magic key mechanism as of now.
+ *
+ * @see Zend_Json::encode
+ * @param mixed $value
+ * @return mixed
+ */
+ public static function encodeJson($value)
+ {
+ if (is_array($value) && count($value) == 0) {
+ return '{}';
+ }
+
+ if(!class_exists('Zend_Json')) {
+ /**
+ * @see Zend_Json
+ */
+ require_once "Zend/Json.php";
+ }
+ return Zend_Json::encode($value, false, array('enableJsonExprFinder' => true));
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Controller/Action/Helper/AutoComplete.php b/library/ZendX/JQuery/Controller/Action/Helper/AutoComplete.php
new file mode 100644
index 0000000..95a0038
--- /dev/null
+++ b/library/ZendX/JQuery/Controller/Action/Helper/AutoComplete.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AutoComplete.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "Zend/Controller/Action/Helper/AutoComplete/Abstract.php";
+
+class ZendX_JQuery_Controller_Action_Helper_AutoComplete
+extends Zend_Controller_Action_Helper_AutoComplete_Abstract
+{
+ /**
+ * Validate autocompletion data
+ *
+ * @param mixed $data
+ * @return boolean
+ */
+ public function validateData($data)
+ {
+ if (!is_array($data)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Prepare autocompletion data
+ *
+ * @param mixed $data
+ * @param boolean $keepLayouts
+ * @return mixed
+ */
+ public function prepareAutoCompletion($data, $keepLayouts = false)
+ {
+ if (!$this->validateData($data)) {
+ /**
+ * @see Zend_Controller_Action_Exception
+ */
+ require_once 'Zend/Controller/Action/Exception.php';
+ throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
+ }
+
+ $data = (array) $data;
+ $output = "";
+ foreach($data AS $k => $v) {
+ if(is_numeric($k)) {
+ $output .= $v."\n";
+ } else {
+ $output .= $k."|".$v."\n";
+ }
+ }
+
+ if (!$keepLayouts) {
+ $this->disableLayouts();
+ }
+
+ return $output;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Exception.php b/library/ZendX/JQuery/Exception.php
new file mode 100644
index 0000000..809c886
--- /dev/null
+++ b/library/ZendX/JQuery/Exception.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "Zend/Exception.php";
+
+/**
+ * jQuery Exception
+ *
+ * @package ZendX_JQuery
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Exception extends Zend_Exception { }
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form.php b/library/ZendX/JQuery/Form.php
new file mode 100644
index 0000000..d57bd64
--- /dev/null
+++ b/library/ZendX/JQuery/Form.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Form.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "Zend/Form.php";
+
+/**
+ * Form Wrapper for jQuery-enabled forms
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form extends Zend_Form
+{
+ /**
+ * Constructor
+ *
+ * @param array|Zend_Config|null $options
+ * @return void
+ */
+ public function __construct($options = null)
+ {
+ $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
+ ->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element')
+ ->addElementPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
+ ->addDisplayGroupPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator');
+ parent::__construct($options);
+ }
+
+ /**
+ * Set the view object
+ *
+ * Ensures that the view object has the jQuery view helper path set.
+ *
+ * @param Zend_View_Interface $view
+ * @return ZendX_JQuery_Form
+ */
+ public function setView(Zend_View_Interface $view = null)
+ {
+ if (null !== $view) {
+ if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
+ $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
+ }
+ }
+ return parent::setView($view);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/AccordionContainer.php b/library/ZendX/JQuery/Form/Decorator/AccordionContainer.php
new file mode 100644
index 0000000..73ebe71
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/AccordionContainer.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AccordionContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
+ */
+require_once "UiWidgetContainer.php";
+
+/**
+ * Form Decorator for jQuery Accordion View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_AccordionContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
+{
+ protected $_helper = "accordionContainer";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/AccordionPane.php b/library/ZendX/JQuery/Form/Decorator/AccordionPane.php
new file mode 100644
index 0000000..4a6f30b
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/AccordionPane.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AccordionPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
+ */
+require_once "UiWidgetPane.php";
+
+/**
+ * Form Decorator for jQuery Accordion Pane View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_AccordionPane extends ZendX_JQuery_Form_Decorator_UiWidgetPane
+{
+ protected $_helper = "accordionPane";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/DialogContainer.php b/library/ZendX/JQuery/Form/Decorator/DialogContainer.php
new file mode 100644
index 0000000..389bf8e
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/DialogContainer.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: DialogContainer.php 20746 2010-01-29 10:36:35Z beberlei $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
+ */
+require_once "UiWidgetContainer.php";
+
+/**
+ * Form Decorator for jQuery Dialog View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_DialogContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
+{
+ protected $_helper = "dialogContainer";
+
+ /**
+ * Render an jQuery UI Widget element using its associated view helper
+ *
+ * Determine view helper from 'helper' option, or, if none set, from
+ * the element type. Then call as
+ * helper($element->getName(), $element->getValue(), $element->getAttribs())
+ *
+ * @param string $content
+ * @return string
+ * @throws Zend_Form_Decorator_Exception if element or view are not registered
+ */
+ public function render($content)
+ {
+ $element = $this->getElement();
+ $view = $element->getView();
+ if (null === $view) {
+ return $content;
+ }
+
+ $jQueryParams = $this->getJQueryParams();
+ $attribs = $this->getOptions();
+
+ $helper = $this->getHelper();
+ $id = $element->getId() . '-container';
+
+ return $view->$helper($id, $content, $jQueryParams, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/TabContainer.php b/library/ZendX/JQuery/Form/Decorator/TabContainer.php
new file mode 100644
index 0000000..84c70a8
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/TabContainer.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: TabContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
+ */
+require_once "UiWidgetContainer.php";
+
+/**
+ * Form Decorator for jQuery Tabs View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_TabContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
+{
+ protected $_helper = "tabContainer";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/TabPane.php b/library/ZendX/JQuery/Form/Decorator/TabPane.php
new file mode 100644
index 0000000..eefc89b
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/TabPane.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: TabPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
+ */
+require_once "UiWidgetPane.php";
+
+/**
+ * Form Decorator for jQuery Tab Pane View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_TabPane extends ZendX_JQuery_Form_Decorator_UiWidgetPane
+{
+ protected $_helper = "tabPane";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/UiWidgetContainer.php b/library/ZendX/JQuery/Form/Decorator/UiWidgetContainer.php
new file mode 100644
index 0000000..3749b7c
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/UiWidgetContainer.php
@@ -0,0 +1,138 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidgetContainer.php 20746 2010-01-29 10:36:35Z beberlei $
+ */
+
+require_once "Zend/Form/Decorator/Abstract.php";
+
+/**
+ * Abstract Form Decorator for all jQuery UI Widget Containers
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class ZendX_JQuery_Form_Decorator_UiWidgetContainer extends Zend_Form_Decorator_Abstract
+{
+ /**
+ * View helper
+ * @var string
+ */
+ protected $_helper;
+
+ /**
+ * Element attributes
+ * @var array
+ */
+ protected $_attribs;
+
+ /**
+ * jQuery option parameters
+ * @var array
+ */
+ protected $_jQueryParams;
+
+ /**
+ * Get view helper for rendering container
+ *
+ * @return string
+ */
+ public function getHelper()
+ {
+ if (null === $this->_helper) {
+ require_once 'Zend/Form/Decorator/Exception.php';
+ throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator');
+ }
+ return $this->_helper;
+ }
+
+ /**
+ * Get element attributes
+ *
+ * @return array
+ */
+ public function getAttribs()
+ {
+ if (null === $this->_attribs) {
+ $attribs = $this->getElement()->getAttribs();
+ if (array_key_exists('jQueryParams', $attribs)) {
+ $this->getJQueryParams();
+ unset($attribs['jQueryParams']);
+ }
+ $this->_attribs = $attribs;
+ }
+ return $this->_attribs;
+ }
+
+ /**
+ * Get jQuery option parameters
+ *
+ * @return array
+ */
+ public function getJQueryParams()
+ {
+ if (null === $this->_jQueryParams) {
+ $this->_jQueryParams = array();
+ if($attribs = $this->getElement()->getAttribs()) {
+ if (array_key_exists('jQueryParams', $attribs)) {
+ $this->_jQueryParams = $attribs['jQueryParams'];
+ }
+ }
+
+ if($options = $this->getOptions()) {
+ if (array_key_exists('jQueryParams', $options)) {
+ $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']);
+ $this->removeOption('jQueryParams');
+ }
+ }
+ }
+
+ return $this->_jQueryParams;
+ }
+
+ /**
+ * Render an jQuery UI Widget element using its associated view helper
+ *
+ * Determine view helper from 'helper' option, or, if none set, from
+ * the element type. Then call as
+ * helper($element->getName(), $element->getValue(), $element->getAttribs())
+ *
+ * @param string $content
+ * @return string
+ * @throws Zend_Form_Decorator_Exception if element or view are not registered
+ */
+ public function render($content)
+ {
+ $element = $this->getElement();
+ $view = $element->getView();
+ if (null === $view) {
+ return $content;
+ }
+
+ $jQueryParams = $this->getJQueryParams();
+ $attribs = $this->getOptions();
+
+ $helper = $this->getHelper();
+ $id = $element->getId() . '-container';
+
+ return $view->$helper($id, $jQueryParams, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/UiWidgetElement.php b/library/ZendX/JQuery/Form/Decorator/UiWidgetElement.php
new file mode 100644
index 0000000..985c3d2
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/UiWidgetElement.php
@@ -0,0 +1,178 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidgetElement.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see Zend_Form_Decorator_ViewHelper
+ */
+require_once "Zend/Form/Decorator/ViewHelper.php";
+
+/**
+ * @see ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
+ */
+require_once "ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php";
+
+/**
+ * Abstract Form Decorator for all jQuery UI Form Elements
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Decorator_UiWidgetElement
+ extends Zend_Form_Decorator_ViewHelper
+ implements ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
+{
+ /**
+ * Element attributes
+ *
+ * @var array
+ */
+ protected $_attribs;
+
+ /**
+ * jQuery UI View Helper
+ *
+ * @var ZendX_JQuery_View_Helper_UiWidget
+ */
+ public $helper;
+
+ /**
+ * jQuery related attributes/options
+ *
+ * @var array
+ */
+ protected $_jQueryParams = array();
+
+ /**
+ * Get element attributes
+ *
+ * @return array
+ */
+ public function getElementAttribs()
+ {
+ if (null === $this->_attribs) {
+ if($this->_attribs = parent::getElementAttribs()) {
+ if (array_key_exists('jQueryParams', $this->_attribs)) {
+ $this->setJQueryParams($this->_attribs['jQueryParams']);
+ unset($this->_attribs['jQueryParams']);
+ }
+ }
+ }
+
+ return $this->_attribs;
+ }
+
+ /**
+ * Set a single jQuery option parameter
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return ZendX_JQuery_Form_Decorator_UiWidgetElement
+ */
+ public function setJQueryParam($key, $value)
+ {
+ $this->_jQueryParams[(string) $key] = $value;
+ return $this;
+ }
+
+ /**
+ * Set jQuery option parameters
+ *
+ * @param array $params
+ * @return ZendX_JQuery_Form_Decorator_UiWidgetElement
+ */
+ public function setJQueryParams(array $params)
+ {
+ $this->_jQueryParams = array_merge($this->_jQueryParams, $params);
+ return $this;
+ }
+
+ /**
+ * Retrieve a single jQuery option parameter
+ *
+ * @param string $key
+ * @return mixed|null
+ */
+ public function getJQueryParam($key)
+ {
+ $this->getElementAttribs();
+ $key = (string) $key;
+ if (array_key_exists($key, $this->_jQueryParams)) {
+ return $this->_jQueryParams[$key];
+ }
+
+ return null;
+ }
+
+ /**
+ * Get jQuery option parameters
+ *
+ * @return array
+ */
+ public function getJQueryParams()
+ {
+ $this->getElementAttribs();
+ return $this->_jQueryParams;
+ }
+
+ /**
+ * Render an jQuery UI Widget element using its associated view helper
+ *
+ * @param string $content
+ * @return string
+ * @throws Zend_Form_Decorator_Exception if element or view are not registered
+ */
+ public function render($content)
+ {
+ $element = $this->getElement();
+ $view = $element->getView();
+ if (null === $view) {
+ require_once 'Zend/Form/Decorator/Exception.php';
+ throw new Zend_Form_Decorator_Exception('UiWidgetElement decorator cannot render without a registered view object');
+ }
+
+ if(method_exists($element, 'getJQueryParams')) {
+ $this->setJQueryParams($element->getJQueryParams());
+ }
+ $jQueryParams = $this->getJQueryParams();
+
+ $helper = $this->getHelper();
+ $separator = $this->getSeparator();
+ $value = $this->getValue($element);
+ $attribs = $this->getElementAttribs();
+ $name = $element->getFullyQualifiedName();
+
+ $id = $element->getId();
+ $attribs['id'] = $id;
+
+ $elementContent = $view->$helper($name, $value, $jQueryParams, $attribs);
+ switch ($this->getPlacement()) {
+ case self::APPEND:
+ return $content . $separator . $elementContent;
+ case self::PREPEND:
+ return $elementContent . $separator . $content;
+ default:
+ return $elementContent;
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php b/library/ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php
new file mode 100644
index 0000000..7bf92c4
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * Marking UiWidgetElement rendering decorator.
+ *
+ * Marker Interface to make sure that programmer using ZendX_JQuery is not
+ * switching ZendX_JQuery_Form_Decorator_UiWidgetElement with Zend_Form_Decorator_ViewHelper
+ * without noticing that this is not possible.
+ */
+interface ZendX_JQuery_Form_Decorator_UiWidgetElementMarker {
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Decorator/UiWidgetPane.php b/library/ZendX/JQuery/Form/Decorator/UiWidgetPane.php
new file mode 100644
index 0000000..79b1827
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Decorator/UiWidgetPane.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidgetPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "Zend/Form/Decorator/Abstract.php";
+
+/**
+ * Abstract Form Decorator for all jQuery UI Pane View Helpers
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class ZendX_JQuery_Form_Decorator_UiWidgetPane extends Zend_Form_Decorator_Abstract
+{
+ /**
+ * View helper
+ * @var string
+ */
+ protected $_helper;
+
+ /**
+ * Element attributes
+ * @var array
+ */
+ protected $_attribs;
+
+ /**
+ * jQuery option parameters
+ * @var array
+ */
+ protected $_jQueryParams;
+
+ /**
+ * Container title
+ * @var string
+ */
+ protected $_title;
+
+ /**
+ * Get view helper for rendering container
+ *
+ * @return string
+ */
+ public function getHelper()
+ {
+ if (null === $this->_helper) {
+ require_once 'Zend/Form/Decorator/Exception.php';
+ throw new Zend_Form_Decorator_Exception('No view helper specified fo UiWidgetContainer decorator');
+ }
+ return $this->_helper;
+ }
+
+ /**
+ * Get element attributes
+ *
+ * @return array
+ */
+ public function getAttribs()
+ {
+ if (null === $this->_attribs) {
+ $attribs = $this->getElement()->getAttribs();
+ if (array_key_exists('jQueryParams', $attribs)) {
+ $this->getJQueryParams();
+ unset($attribs['jQueryParams']);
+ }
+ $this->_attribs = $attribs;
+ }
+ return $this->_attribs;
+ }
+
+ /**
+ * Get jQuery option parameters
+ *
+ * @return array
+ */
+ public function getJQueryParams()
+ {
+ if (null === $this->_jQueryParams) {
+ $attribs = $this->getElement()->getAttribs();
+ $this->_jQueryParams = array();
+ if (array_key_exists('jQueryParams', $attribs)) {
+ $this->_jQueryParams = $attribs['jQueryParams'];
+ }
+
+ $options = $this->getOptions();
+ if (array_key_exists('jQueryParams', $options)) {
+ $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']);
+ $this->removeOption('jQueryParams');
+ }
+ }
+
+ // Ensure we have a title param
+ if (!array_key_exists('title', $this->_jQueryParams)) {
+ require_once "Zend/Form/Decorator/Exception.php";
+ throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'title' to render. This title can been set via setJQueryParam('title') on the parent element.");
+ }
+
+ return $this->_jQueryParams;
+ }
+
+ /**
+ * Render an jQuery UI Widget Pane using its associated view helper
+ *
+ * @throws Zend_Form_Decorator_Exception
+ * @param string $content
+ * @return string
+ * @throws Zend_Form_Decorator_Exception if element or view are not registered
+ */
+ public function render($content)
+ {
+ $element = $this->getElement();
+ $view = $element->getView();
+ if (null === $view) {
+ return $content;
+ }
+
+ $jQueryParams = $this->getJQueryParams();
+ $attribs = array_merge($this->getAttribs(), $this->getOptions());
+
+ if(isset($jQueryParams['title']) && !empty($jQueryParams['title'])) {
+ if (null !== ($translator = $element->getTranslator())) {
+ $jQueryParams['title'] = $translator->translate($jQueryParams['title']);
+ }
+ }
+
+ if(isset($jQueryParams['containerId'])) {
+ $id = $jQueryParams['containerId']."-container";
+ } else {
+ require_once "Zend/Form/Decorator/Exception.php";
+ throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'containerId', to point at their parent container. This containerId has been set via setAttrib('id') on the parent element.");
+ }
+
+ $helper = $this->getHelper();
+
+ return $view->$helper($id, $content, $jQueryParams, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/AutoComplete.php b/library/ZendX/JQuery/Form/Element/AutoComplete.php
new file mode 100644
index 0000000..fa26205
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/AutoComplete.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AutoComplete.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Element_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * Form Element for jQuery Autocomplete View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_AutoComplete extends ZendX_JQuery_Form_Element_UiWidget
+{
+ public $helper = "autoComplete";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/ColorPicker.php b/library/ZendX/JQuery/Form/Element/ColorPicker.php
new file mode 100644
index 0000000..dbb0497
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/ColorPicker.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: ColorPicker.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Element_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * Form Element for jQuery ColorPicker View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_ColorPicker extends ZendX_JQuery_Form_Element_UiWidget
+{
+ public $helper = "colorPicker";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/DatePicker.php b/library/ZendX/JQuery/Form/Element/DatePicker.php
new file mode 100644
index 0000000..ebe18e8
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/DatePicker.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: DatePicker.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Element_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * Form Element for jQuery DatePicker View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_DatePicker extends ZendX_JQuery_Form_Element_UiWidget
+{
+ public $helper = "datePicker";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/Slider.php b/library/ZendX/JQuery/Form/Element/Slider.php
new file mode 100644
index 0000000..88bbb28
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/Slider.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Slider.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Element_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * Form Element for jQuery Slider View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_Slider extends ZendX_JQuery_Form_Element_UiWidget
+{
+ public $helper = "slider";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/Spinner.php b/library/ZendX/JQuery/Form/Element/Spinner.php
new file mode 100644
index 0000000..25fc85a
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/Spinner.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Spinner.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_Form_Element_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * Form Element for jQuery Spinner View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_Spinner extends ZendX_JQuery_Form_Element_UiWidget
+{
+ public $helper = "spinner";
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Element/UiWidget.php b/library/ZendX/JQuery/Form/Element/UiWidget.php
new file mode 100644
index 0000000..006238b
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Element/UiWidget.php
@@ -0,0 +1,180 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidget.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "Zend/Form/Element.php";
+
+/**
+ * Base Form Element for jQuery View Helpers
+ *
+ * @package ZendX_JQuery
+ * @subpackage Form
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_Form_Element_UiWidget extends Zend_Form_Element
+{
+ /**
+ * jQuery related parameters of this form element.
+ *
+ * @var array
+ */
+ public $jQueryParams = array();
+
+ /**
+ * Just here to prevent errors.
+ *
+ * @var array
+ */
+ public $options = array();
+
+ /**
+ * Constructor
+ *
+ * @param mixed $spec
+ * @param mixed $options
+ * @return void
+ */
+ public function __construct($spec, $options = null)
+ {
+ $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator');
+ parent::__construct($spec, $options);
+ }
+
+ /**
+ * Get jQuery related parameter of this form element
+ *
+ * @param string $key
+ * @return string
+ */
+ public function getJQueryParam($key)
+ {
+ $key = (string) $key;
+ return $this->jQueryParams[$key];
+ }
+
+ /**
+ * Get all currently known jQuery related parameters of this element
+ *
+ * @return array
+ */
+ public function getJQueryParams()
+ {
+ return $this->jQueryParams;
+ }
+
+ /**
+ * Set a jQuery related parameter of this form element.
+ *
+ * @param string $key
+ * @param string $value
+ * @return ZendX_JQuery_Form_Element_UiWidget
+ */
+ public function setJQueryParam($key, $value)
+ {
+ $key = (string) $key;
+ $this->jQueryParams[$key] = $value;
+ return $this;
+ }
+
+ /**
+ * Set an array of jQuery related options for this element (merging with old options).
+ *
+ * @param Array $params
+ * @return ZendX_JQuery_Form_Element_UiWidget
+ */
+ public function setJQueryParams($params)
+ {
+ $this->jQueryParams = array_merge($this->jQueryParams, $params);
+ return $this;
+ }
+
+ /**
+ * Load default decorators
+ *
+ * @return void
+ */
+ public function loadDefaultDecorators()
+ {
+ if ($this->loadDefaultDecoratorsIsDisabled()) {
+ return;
+ }
+
+ $decorators = $this->getDecorators();
+ if (empty($decorators)) {
+ $this->addDecorator('UiWidgetElement')
+ ->addDecorator('Errors')
+ ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
+ ->addDecorator('HtmlTag', array('tag' => 'dd'))
+ ->addDecorator('Label', array('tag' => 'dt'));
+ }
+ }
+
+ /**
+ * Set the view object
+ *
+ * Ensures that the view object has the jQuery view helper path set.
+ *
+ * @param Zend_View_Interface $view
+ * @return ZendX_JQuery_Form_Element_UiWidget
+ */
+ public function setView(Zend_View_Interface $view = null)
+ {
+ if (null !== $view) {
+ if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
+ $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
+ }
+ }
+ return parent::setView($view);
+ }
+
+ /**
+ * Retrieve all decorators
+ *
+ * @throws ZendX_JQuery_Form_Exception
+ * @return array
+ */
+ public function getDecorators()
+ {
+ $decorators = parent::getDecorators();
+ if(count($decorators) > 0) {
+ // Only check this if there are decorators present, otherwise it could
+ // be that the decorators have not been initialized yet.
+ $foundUiWidgetElementMarker = false;
+ foreach($decorators AS $decorator) {
+ if($decorator instanceof ZendX_JQuery_Form_Decorator_UiWidgetElementMarker) {
+ $foundUiWidgetElementMarker = true;
+ }
+ }
+ if($foundUiWidgetElementMarker === false) {
+ require_once "ZendX/JQuery/Form/Exception.php";
+ throw new ZendX_JQuery_Form_Exception(
+ "Cannot render jQuery form element without at least one decorator ".
+ "implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. ".
+ "Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. ".
+ "Hint: The ViewHelper decorator does not render jQuery elements correctly."
+ );
+ }
+ }
+
+ return $decorators;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/Form/Exception.php b/library/ZendX/JQuery/Form/Exception.php
new file mode 100644
index 0000000..5179d8b
--- /dev/null
+++ b/library/ZendX/JQuery/Form/Exception.php
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * @see ZendX_JQuery_Exception
+ */
+require_once "ZendX/JQuery/Exception.php";
+
+class ZendX_JQuery_Form_Exception extends ZendX_JQuery_Exception
+{
+
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Exception.php b/library/ZendX/JQuery/View/Exception.php
new file mode 100644
index 0000000..43c797a
--- /dev/null
+++ b/library/ZendX/JQuery/View/Exception.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 11941 2008-10-13 19:41:38Z matthew $
+ */
+
+require_once "ZendX/JQuery/Exception.php";
+
+/**
+ * jQuery Exception
+ *
+ * @package ZendX_JQuery
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Exception extends ZendX_JQuery_Exception { }
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/AccordionContainer.php b/library/ZendX/JQuery/View/Helper/AccordionContainer.php
new file mode 100644
index 0000000..2437b71
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/AccordionContainer.php
@@ -0,0 +1,171 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AccordionContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Accordion View Helper
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_AccordionContainer extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * @var array
+ */
+ protected $_panes = array();
+
+ /**
+ * @var string
+ */
+ protected $_elementHtmlTemplate = null;
+
+ /**
+ * Add Accordion Pane for the Accordion-Id
+ *
+ * @param string $id
+ * @param string $name
+ * @param string $content
+ * @return ZendX_JQuery_View_Helper_AccordionContainer
+ */
+ public function addPane($id, $name, $content, array $options=array())
+ {
+ if(!isset($this->_panes[$id])) {
+ $this->_panes[$id] = array();
+ }
+ if(strlen($name) == 0 && isset($options['title'])) {
+ $name = $options['title'];
+ }
+ $this->_panes[$id][] = array('name' => $name, 'content' => $content, 'options' => $options);
+ return $this;
+ }
+
+ /**
+ * Render Accordion with the currently registered elements.
+ *
+ * If no arguments are given, the accordion object is returned so that
+ * chaining the {@link addPane()} function allows to register new elements
+ * for an accordion.
+ *
+ * @link http://docs.jquery.com/UI/Accordion
+ * @param string $id
+ * @param array $params
+ * @param array $attribs
+ * @return string|ZendX_JQuery_View_Helper_AccordionContainer
+ */
+ public function accordionContainer($id=null, array $params=array(), array $attribs=array())
+ {
+ if(0 === func_num_args()) {
+ return $this;
+ }
+
+ if(!isset($attribs['id'])) {
+ $attribs['id'] = $id;
+ }
+
+ $html = "";
+ if(isset($this->_panes[$id])) {
+ foreach($this->_panes[$id] AS $element) {
+ $html .= sprintf($this->getElementHtmlTemplate(), $element['name'], $element['content']).PHP_EOL;
+ }
+
+ if(count($params) > 0) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = "{}";
+ }
+
+ $js = sprintf('%s("#%s").accordion(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+ $this->jquery->addOnLoad($js);
+
+ $html = $this->getAccordionTemplate($attribs, $html);
+ }
+ return $html;
+ }
+
+ /**
+ * @param array $attribs
+ * @param string $html
+ * @return string
+ */
+ protected function getAccordionTemplate($attribs, $html)
+ {
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ $html = '<div'
+ . $this->_htmlAttribs($attribs)
+ . '>'.PHP_EOL
+ . $html
+ . '</div>'.PHP_EOL;
+ } else {
+ $html = '<ul'
+ . $this->_htmlAttribs($attribs)
+ . '>'.PHP_EOL
+ . $html
+ . '</ul>'.PHP_EOL;
+ }
+ return $html;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getElementHtmlTemplate()
+ {
+ if($this->_elementHtmlTemplate == null) {
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ $this->_elementHtmlTemplate = '<h3><a href="#">%s</a></h3><div>%s</div>';
+ } else {
+ $this->_elementHtmlTemplate = '<li class="ui-accordion-group"><a href="#" class="ui-accordion-header">%s</a><div class="ui-accordion-content">%s</div></li>';
+ }
+ }
+ return $this->_elementHtmlTemplate;
+ }
+
+ /**
+ * Set the accordion element template
+ *
+ * @param string $htmlTemplate
+ * @return ZendX_JQuery_View_Helper_AccordionContainer
+ */
+ public function setElementHtmlTemplate($htmlTemplate)
+ {
+ if(substr_count($htmlTemplate, '%s') != 2) {
+ require_once "ZendX/JQuery/View/Exception.php";
+ throw new ZendX_JQuery_View_Exception(
+ "Accordion Container HTML Template requires two sprintf() string replace markers '%s'."
+ );
+ }
+ $this->_elementHtmlTemplate = $htmlTemplate;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/AccordionPane.php b/library/ZendX/JQuery/View/Helper/AccordionPane.php
new file mode 100644
index 0000000..a2b7547
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/AccordionPane.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AccordionPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidgetPane
+ */
+require_once "UiWidgetPane.php";
+
+/**
+ * jQuery Accordion Pane, goes with Accordion Container
+ *
+ * @uses ZendX_JQuery_View_Helper_AccordionContainer
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_AccordionPane extends ZendX_JQuery_View_Helper_UiWidgetPane
+{
+ /**
+ * Add accordion pane to the accordion with $id
+ *
+ * Directly add an additional pane to the accordion with $id. The title
+ * is to be given in the $options array as 'title' key. Additionally when
+ * specified with no arguments, the helper returns itsself as object making
+ * it possible to use {@link captureStart()} and {@link captureEnd()} methods.
+ *
+ * @param string $id
+ * @param string $content
+ * @param array $options
+ * @return string|ZendX_JQuery_View_Helper_AccordionPane
+ */
+ public function accordionPane($id=null, $content='', array $options=array())
+ {
+ if(0 === func_num_args()) {
+ return $this;
+ }
+
+ $name = '';
+ if(isset($options['title'])) {
+ $name = $options['title'];
+ unset($options['title']);
+ }
+
+ $this->_addPane($id, $name, $content, $options);
+ return '';
+ }
+
+ /**
+ * Method hooks into Accordion Container and registeres new pane
+ *
+ * @param string $id
+ * @param string $name
+ * @param string $content
+ * @param array $options
+ */
+ protected function _addPane($id, $name, $content, array $options=array())
+ {
+ $this->view->accordionContainer()->addPane($id, $name, $content, $options);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/AjaxLink.php b/library/ZendX/JQuery/View/Helper/AjaxLink.php
new file mode 100644
index 0000000..56ada9a
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/AjaxLink.php
@@ -0,0 +1,308 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AjaxLink.php 21866 2010-04-16 07:28:56Z beberlei $
+ */
+
+/**
+ * @see Zend_View_Helper_HtmlElement
+ */
+include_once "Zend/View/Helper/HtmlElement.php";
+
+/**
+ * jQuery Accordion Pane, goes with Accordion Container
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_AjaxLink extends Zend_View_Helper_HtmlElement
+{
+ /**
+ * Static because multiple instances accross views of AjaxLink could reset the counter and a
+ * subcontainer because of this single private class variable seems too much overhead.
+ *
+ * @staticvar Integer
+ */
+ private static $currentLinkCallbackId = 1;
+
+ /**
+ * Create an anchor that enables ajax-based requests and handling of the response.
+ *
+ * This helper creates links that make XmlHttpRequests to the server. It allows to
+ * inject the response into the DOM. Fancy effects going with the links can be enabled
+ * via simple callback shortnames. The functionality is mostly controlled by the $options
+ * array:
+ *
+ * $options
+ * Key Behaviour
+ * =================================================================================
+ * 'update' Update a container with the content fetched from $url
+ * 'method' Explicit Requesting method mimicing the jQuery functionality: GET, POST
+ * 'inline' True or false, wheater to inline the javascript in onClick=""
+ * atttribute or append it to jQuery onLoad Stack.
+ * 'complete' String specifies javascript called after successful request or a
+ * shortname of a jQuery effect that should be applied to the 'update' element.
+ * 'beforeSend' String specifies javascript called before the request is sent, or a
+ * shortname of a jQuery effect that should be applied to the link clicked.
+ * 'noscript' True/false, include a noscript variant that directly requests
+ * the given $url (make sure to check $request->isXmlHttpRequest())
+ * 'dataType' What type of data is the response returning? text, html, json?
+ * 'title' HTML Attribute title of the Anchor
+ * 'class' HTML Attribute class of the Anchor
+ * 'id' HTML Attribute id of the Anchor
+ * 'attribs' Array of Key-Value pairs with HTML Attribute names and their content.
+ *
+ * BeforeSend Callback:
+ * Can include shortcuts as a string assignment to fire of effects before sending of request.
+ * Possible shortcuts are 'fadeOut', 'fadeOutSlow', 'hide', 'hideSlow', 'slideUp', 'flash',
+ * @example $options = array('beforeSend' => 'hideSlow', 'complete' => 'show');
+ *
+ * @link http://docs.jquery.com/Ajax
+ * @param String $label Urls Title
+ * @param String $url Link to Point to
+ * @param Array $options
+ * @param Array $params Key Value Pairs of GET/POST Parameters
+ * @return String
+ */
+ public function ajaxLink($label, $url, $options=null, $params=null)
+ {
+ $jquery = $this->view->jQuery();
+ $jquery->enable();
+
+ $jqHandler = (ZendX_JQuery_View_Helper_JQuery::getNoConflictMode()==true)?'$j':'$';
+
+ $attribs = array();
+ if(isset($options['attribs']) && is_array($options['attribs'])) {
+ $attribs = $options['attribs'];
+ }
+
+ //
+ // The next following 4 conditions check for html attributes that the link might need
+ //
+ if(empty($options['noscript']) || $options['noscript'] == false) {
+ $attribs['href'] = "#";
+ } else {
+ $attribs['href'] = $url;
+ }
+
+ if(!empty($options['title'])) {
+ $attribs['title'] = $options['title'];
+ }
+
+ // class value is an array because the jQuery CSS selector
+ // click event needs its own classname later on
+ if(!isset($attribs['class'])) {
+ $attribs['class'] = array();
+ } elseif(is_string($attribs['class'])) {
+ $attribs['class'] = explode(" ", $attribs['class']);
+ }
+ if(!empty($options['class'])) {
+ $attribs['class'][] = $options['class'];
+ }
+
+ if(!empty($options['id'])) {
+ $attribs['id'] = $options['id'];
+ }
+
+ //
+ // Execute Javascript inline?
+ //
+ $inline = false;
+ if(!empty($options['inline']) && $options['inline'] == true) {
+ $inline = true;
+ }
+
+ //
+ // Detect the callbacks:
+ // Just those two callbacks, beforeSend and complete can be defined for the $.get and $.post options.
+ // Pick all the defined callbacks and put them on their respective stacks.
+ //
+ $callbacks = array('beforeSend' => null, 'complete' => null);
+ if(isset($options['beforeSend'])) {
+ $callbacks['beforeSend'] = $options['beforeSend'];
+ }
+ if(isset($options['complete'])) {
+ $callbacks['complete'] = $options['complete'];
+ }
+
+ $updateContainer = false;
+ if(!empty($options['update']) && is_string($options['update'])) {
+ $updateContainer = $options['update'];
+
+ // Additionally check if there is a callback complete that is a shortcut to be executed
+ // on the specified update container
+ if(!empty($callbacks['complete'])) {
+ switch(strtolower($callbacks['complete'])) {
+ case 'show':
+ $callbacks['complete'] = sprintf("%s('%s').show();", $jqHandler, $updateContainer);
+ break;
+ case 'showslow':
+ $callbacks['complete'] = sprintf("%s('%s').show('slow');", $jqHandler, $updateContainer);
+ break;
+ case 'shownormal':
+ $callbacks['complete'] = sprintf("%s('%s').show('normal');", $jqHandler, $updateContainer);
+ break;
+ case 'showfast':
+ $callbacks['complete'] = sprintf("%s('%s').show('fast');", $jqHandler, $updateContainer);
+ break;
+ case 'fadein':
+ $callbacks['complete'] = sprintf("%s('%s').fadeIn('normal');", $jqHandler, $updateContainer);
+ break;
+ case 'fadeinslow':
+ $callbacks['complete'] = sprintf("%s('%s').fadeIn('slow');", $jqHandler, $updateContainer);
+ break;
+ case 'fadeinfast':
+ $callbacks['complete'] = sprintf("%s('%s').fadeIn('fast');", $jqHandler, $updateContainer);
+ break;
+ case 'slidedown':
+ $callbacks['complete'] = sprintf("%s('%s').slideDown('normal');", $jqHandler, $updateContainer);
+ break;
+ case 'slidedownslow':
+ $callbacks['complete'] = sprintf("%s('%s').slideDown('slow');", $jqHandler, $updateContainer);
+ break;
+ case 'slidedownfast':
+ $callbacks['complete'] = sprintf("%s('%s').slideDown('fast');", $jqHandler, $updateContainer);
+ break;
+ }
+ }
+ }
+
+ if(empty($options['dataType'])) {
+ $options['dataType'] = "html";
+ }
+
+ $requestHandler = $this->_determineRequestHandler($options, (count($params)>0)?true:false);
+
+ $callbackCompleteJs = array();
+ if($updateContainer != false) {
+ if($options['dataType'] == "text") {
+ $callbackCompleteJs[] = sprintf("%s('%s').text(data);", $jqHandler, $updateContainer);
+ } else {
+ $callbackCompleteJs[] = sprintf("%s('%s').html(data);", $jqHandler, $updateContainer);
+ }
+ }
+ if($callbacks['complete'] != null) {
+ $callbackCompleteJs[] = $callbacks['complete'];
+ }
+
+ if(isset($params) && count($params) > 0) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = '{}';
+ }
+
+ $js = array();
+ if($callbacks['beforeSend'] != null) {
+ switch(strtolower($callbacks['beforeSend'])) {
+ case 'fadeout':
+ $js[] = sprintf("%s(this).fadeOut();", $jqHandler);
+ break;
+ case 'fadeoutslow':
+ $js[] = sprintf("%s(this).fadeOut('slow');", $jqHandler);
+ break;
+ case 'fadeoutfast':
+ $js[] = sprintf("%s(this).fadeOut('fast');", $jqHandler);
+ break;
+ case 'hide':
+ $js[] = sprintf("%s(this).hide();", $jqHandler);
+ break;
+ case 'hideslow':
+ $js[] = sprintf("%s(this).hide('slow');", $jqHandler);
+ break;
+ case 'hidefast':
+ $js[] = sprintf("%s(this).hide('fast');", $jqHandler);
+ break;
+ case 'slideup':
+ $js[] = sprintf("%s(this).slideUp(1000);", $jqHandler);
+ break;
+ default:
+ $js[] = $callbacks['beforeSend'];
+ break;
+ }
+ }
+
+ switch($requestHandler) {
+ case 'GET':
+ $js[] = sprintf("%s.get('%s', %s, function(data, textStatus) { %s }, '%s');return false;",
+ $jqHandler, $url, $params, implode(" ", $callbackCompleteJs), $options['dataType']);
+ break;
+ case 'POST':
+ $js[] = sprintf("%s.post('%s', %s, function(data, textStatus) { %s }, '%s');return false;",
+ $jqHandler, $url, $params, implode(" ", $callbackCompleteJs), $options['dataType']);
+ break;
+ }
+
+ $js = implode($js);
+
+ if($inline == true) {
+ $attribs['onclick'] = $js;
+ } else {
+ if(!isset($attribs['id'])) {
+ $clickClass = sprintf("ajaxLink%d", ZendX_JQuery_View_Helper_AjaxLink::$currentLinkCallbackId);
+ ZendX_JQuery_View_Helper_AjaxLink::$currentLinkCallbackId++;
+
+ $attribs['class'][] = $clickClass;
+ $onLoad = sprintf("%s('a.%s').click(function() { %s });", $jqHandler, $clickClass, $js);
+ } else {
+ $onLoad = sprintf("%s('a#%s').click(function() { %s });", $jqHandler, $attribs['id'], $js);
+ }
+
+ $jquery->addOnLoad($onLoad);
+ }
+
+ if(count($attribs['class']) > 0) {
+ $attribs['class'] = implode(" ", $attribs['class']);
+ } else {
+ unset($attribs['class']);
+ }
+
+ $html = '<a'
+ . $this->_htmlAttribs($attribs)
+ . '>'
+ . $label
+ . '</a>';
+ return $html;
+ }
+
+ /**
+ * Determine which request method (GET or POST) should be used.
+ *
+ * Normally the request method is determined implicitly by the rule,
+ * if addiotional params are sent, POST, if not GET. You can overwrite
+ * this behaviiour by implicitly setting $options['method'] = "POST|GET";
+ *
+ * @param Array $options
+ * @param Boolean $hasParams
+ * @return String
+ */
+ protected function _determineRequestHandler($options, $hasParams)
+ {
+ if(isset($options['method']) && in_array(strtoupper($options['method']), array('GET', 'POST'))) {
+ return strtoupper($options['method']);
+ }
+ $requestHandler = "GET";
+ if($hasParams == true) {
+ $requestHandler = "POST";
+ }
+ return $requestHandler;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/AutoComplete.php b/library/ZendX/JQuery/View/Helper/AutoComplete.php
new file mode 100644
index 0000000..837cdfd
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/AutoComplete.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: AutoComplete.php 20754 2010-01-29 11:42:43Z beberlei $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Autocomplete View Helper
+ *
+ * @uses Zend_Json, Zend_View_Helper_FormText
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_AutoComplete extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Builds an AutoComplete ready input field.
+ *
+ * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText
+ * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete
+ * field. Make sure you have set one out of the two following options: $params['data'] or
+ * $params['url']. The first one accepts an array as data input to the autoComplete, the
+ * second accepts an url, where the autoComplete content is returned from. For the format
+ * see jQuery documentation.
+ *
+ * @link http://docs.jquery.com/UI/Autocomplete
+ * @throws ZendX_JQuery_Exception
+ * @param String $id
+ * @param String $value
+ * @param array $params
+ * @param array $attribs
+ * @return String
+ */
+ public function autoComplete($id, $value = null, array $params = array(), array $attribs = array())
+ {
+ $attribs = $this->_prepareAttributes($id, $value, $attribs);
+
+ if (!isset($params['source'])) {
+ if (isset($params['url'])) {
+ $params['source'] = $params['url'];
+ unset($params['url']);
+ } else if (isset($params['data'])) {
+ $params['source'] = $params['data'];
+ unset($params['data']);
+ } else {
+ require_once "ZendX/JQuery/Exception.php";
+ throw new ZendX_JQuery_Exception(
+ "Cannot construct AutoComplete field without specifying 'source' field, ".
+ "either an url or an array of elements."
+ );
+ }
+ }
+
+ $params = ZendX_JQuery::encodeJson($params);
+
+ $js = sprintf('%s("#%s").autocomplete(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+
+ $this->jquery->addOnLoad($js);
+
+ return $this->view->formText($id, $value, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/ColorPicker.php b/library/ZendX/JQuery/View/Helper/ColorPicker.php
new file mode 100644
index 0000000..025625d
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/ColorPicker.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: ColorPicker.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Color Picker View Helper
+ *
+ * @uses Zend_View_Helper_FormText
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_ColorPicker extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Render a Color Picker in an FormText field.
+ *
+ * @link http://docs.jquery.com/UI/ColorPicker
+ * @param string $id
+ * @param string $value
+ * @param array $params
+ * @param array $attribs
+ * @return string
+ */
+ public function colorPicker($id, $value='', array $params=array(), array $attribs=array())
+ {
+ $attribs = $this->_prepareAttributes($id, $value, $attribs);
+
+ if(strlen($value) >= 6) {
+ $params['color'] = $value;
+ }
+
+ if(count($params) > 0) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = "{}";
+ }
+
+ $js = sprintf('%s("#%s").colorpicker(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+
+ $this->jquery->addOnLoad($js);
+
+ return $this->view->formText($id, $value, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/DatePicker.php b/library/ZendX/JQuery/View/Helper/DatePicker.php
new file mode 100644
index 0000000..4445bcf
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/DatePicker.php
@@ -0,0 +1,135 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: DatePicker.php 21869 2010-04-16 07:49:18Z beberlei $
+ */
+
+/**
+ * @see Zend_Registry
+ */
+require_once "Zend/Registry.php";
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Date Picker View Helper
+ *
+ * @uses Zend_View_Helper_FormText
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Create a jQuery UI Widget Date Picker
+ *
+ * @link http://docs.jquery.com/UI/Datepicker
+ * @param string $id
+ * @param string $value
+ * @param array $params jQuery Widget Parameters
+ * @param array $attribs HTML Element Attributes
+ * @return string
+ */
+ public function datePicker($id, $value = null, array $params = array(), array $attribs = array())
+ {
+ $attribs = $this->_prepareAttributes($id, $value, $attribs);
+
+ if(!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) {
+ $params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat();
+ }
+
+ // TODO: Allow translation of DatePicker Text Values to get this action from client to server
+ $params = ZendX_JQuery::encodeJson($params);
+
+ $js = sprintf('%s("#%s").datepicker(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+
+ $this->jquery->addOnLoad($js);
+
+ return $this->view->formText($id, $value, $attribs);
+ }
+
+ /**
+ * A Check for Zend_Locale existance has already been done in {@link datePicker()}
+ * this function only resolves the default format from Zend Locale to
+ * a jQuery Date Picker readable format. This function can be potentially buggy
+ * because of its easy nature and is therefore stripped from the core functionality
+ * to be easily overriden.
+ *
+ * @return string
+ */
+ public static function resolveZendLocaleToDatePickerFormat($format=null)
+ {
+ if($format == null) {
+ $locale = Zend_Registry::get('Zend_Locale');
+ if( !($locale instanceof Zend_Locale) ) {
+ require_once "ZendX/JQuery/Exception.php";
+ throw new ZendX_JQuery_Exception("Cannot resolve Zend Locale format by default, no application wide locale is set.");
+ }
+ /**
+ * @see Zend_Locale_Format
+ */
+ require_once "Zend/Locale/Format.php";
+ $format = Zend_Locale_Format::getDateFormat($locale);
+ }
+
+ $dateFormat = array(
+ 'EEEEE' => 'D', 'EEEE' => 'DD', 'EEE' => 'D', 'EE' => 'D', 'E' => 'D',
+ 'MMMM' => 'MM', 'MMM' => 'M', 'MM' => 'mm', 'M' => 'm',
+ 'YYYYY' => 'yy', 'YYYY' => 'yy', 'YYY' => 'yy', 'YY' => 'y', 'Y' => 'yy',
+ 'yyyyy' => 'yy', 'yyyy' => 'yy', 'yyy' => 'yy', 'yy' => 'y', 'y' => 'yy',
+ 'G' => '', 'e' => '', 'a' => '', 'h' => '', 'H' => '', 'm' => '',
+ 's' => '', 'S' => '', 'z' => '', 'Z' => '', 'A' => '',
+ );
+
+ $newFormat = "";
+ $isText = false;
+ $i = 0;
+ while($i < strlen($format)) {
+ $chr = $format[$i];
+ if($chr == '"' || $chr == "'") {
+ $isText = !$isText;
+ }
+ $replaced = false;
+ if($isText == false) {
+ foreach($dateFormat AS $zl => $jql) {
+ if(substr($format, $i, strlen($zl)) == $zl) {
+ $chr = $jql;
+ $i += strlen($zl);
+ $replaced = true;
+ }
+ }
+ }
+ if($replaced == false) {
+ $i++;
+ }
+ $newFormat .= $chr;
+ }
+
+ return $newFormat;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/DialogContainer.php b/library/ZendX/JQuery/View/Helper/DialogContainer.php
new file mode 100644
index 0000000..8a9804f
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/DialogContainer.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: DialogContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Dialog View Helper
+ *
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_DialogContainer extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Create a jQuery UI Dialog filled with the given content
+ *
+ * @link http://docs.jquery.com/UI/Dialog
+ * @param string $id
+ * @param string $content
+ * @param array $params
+ * @param array $attribs
+ * @return string
+ */
+ public function dialogContainer($id, $content, $params=array(), $attribs=array())
+ {
+ if (!array_key_exists('id', $attribs)) {
+ $attribs['id'] = $id;
+ }
+
+ if(count($params) > 0) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = "{}";
+ }
+
+ $js = sprintf('%s("#%s").dialog(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+ $this->jquery->addOnLoad($js);
+
+ $html = '<div'
+ . $this->_htmlAttribs($attribs)
+ . '>'
+ . $content
+ . '</div>';
+ return $html;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/JQuery.php b/library/ZendX/JQuery/View/Helper/JQuery.php
new file mode 100644
index 0000000..e381854
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/JQuery.php
@@ -0,0 +1,167 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: JQuery.php 20184 2010-01-10 21:22:54Z freak $
+ */
+
+/**
+ * @see ZendX_JQuery
+ */
+require_once "ZendX/JQuery.php";
+
+/**
+ * @see Zend_Registry
+ */
+require_once 'Zend/Registry.php';
+
+/**
+ * @see Zend_View_Helper_Abstract
+ */
+require_once 'Zend/View/Helper/Abstract.php';
+
+/**
+ * @see ZendX_JQuery_View_Helper_JQuery_Container
+ */
+require_once "ZendX/JQuery/View/Helper/JQuery/Container.php";
+
+/**
+ * jQuery Helper. Functions as a stack for code and loads all jQuery dependencies.
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_JQuery extends Zend_View_Helper_Abstract
+{
+ /**
+ * @var Zend_View_Interface
+ */
+ public $view;
+
+ /**
+ * jQuery no Conflict Mode
+ *
+ * @see http://docs.jquery.com/Using_jQuery_with_Other_Libraries
+ * @staticvar Boolean Status of noConflict Mode
+ */
+ private static $noConflictMode = false;
+
+ /**
+ * Initialize helper
+ *
+ * Retrieve container from registry or create new container and store in
+ * registry.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $registry = Zend_Registry::getInstance();
+ if (!isset($registry[__CLASS__])) {
+ require_once 'ZendX/JQuery/View/Helper/JQuery/Container.php';
+ $container = new ZendX_JQuery_View_Helper_JQuery_Container();
+ $registry[__CLASS__] = $container;
+ }
+ $this->_container = $registry[__CLASS__];
+ }
+
+ /**
+ * Return jQuery View Helper class, to execute jQuery library related functions.
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function jQuery()
+ {
+ return $this->_container;
+ }
+
+ /**
+ * Set view object
+ *
+ * @param Zend_View_Interface $view
+ * @return void
+ */
+ public function setView(Zend_View_Interface $view)
+ {
+ $this->view = $view;
+ $this->_container->setView($view);
+ }
+
+ /**
+ * Proxy to container methods
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ * @throws Zend_View_Exception For invalid method calls
+ */
+ public function __call($method, $args)
+ {
+ if (!method_exists($this->_container, $method)) {
+ require_once 'Zend/View/Exception.php';
+ throw new Zend_View_Exception(sprintf('Invalid method "%s" called on jQuery view helper', $method));
+ }
+
+ return call_user_func_array(array($this->_container, $method), $args);
+ }
+
+ /**
+ * Enable the jQuery internal noConflict Mode to work with
+ * other Javascript libraries. Will setup jQuery in the variable
+ * $j instead of $ to overcome conflicts.
+ *
+ * @link http://docs.jquery.com/Using_jQuery_with_Other_Libraries
+ */
+ public static function enableNoConflictMode()
+ {
+ self::$noConflictMode = true;
+ }
+
+ /**
+ * Disable noConflict Mode of jQuery if this was previously enabled.
+ *
+ * @return void
+ */
+ public static function disableNoConflictMode()
+ {
+ self::$noConflictMode = false;
+ }
+
+ /**
+ * Return current status of the jQuery no Conflict Mode
+ *
+ * @return Boolean
+ */
+ public static function getNoConflictMode()
+ {
+ return self::$noConflictMode;
+ }
+
+ /**
+ * Return current jQuery handler based on noConflict mode settings.
+ *
+ * @return String
+ */
+ public static function getJQueryHandler()
+ {
+ return ((self::getNoConflictMode()==true)?'$j':'$');
+ }
+}
diff --git a/library/ZendX/JQuery/View/Helper/JQuery/Container.php b/library/ZendX/JQuery/View/Helper/JQuery/Container.php
new file mode 100644
index 0000000..3eafb02
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/JQuery/Container.php
@@ -0,0 +1,832 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Container.php 20751 2010-01-29 11:14:09Z beberlei $
+ */
+
+/**
+ * @see ZendX_JQuery
+ */
+require_once "ZendX/JQuery.php";
+
+/**
+ * jQuery View Helper. Transports all jQuery stack and render information across all views.
+ *
+ * @uses ZendX_JQuery_View_Helper_JQuery_Container
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_JQuery_Container
+{
+ /**
+ * Path to local webserver jQuery library
+ *
+ * @var String
+ */
+ protected $_jqueryLibraryPath = null;
+
+ /**
+ * Additional javascript files that for jQuery Helper components.
+ *
+ * @var Array
+ */
+ protected $_javascriptSources = array();
+
+ /**
+ * Indicates wheater the jQuery View Helper is enabled.
+ *
+ * @var Boolean
+ */
+ protected $_enabled = false;
+
+ /**
+ * Indicates if a capture start method for javascript or onLoad has been called.
+ *
+ * @var Boolean
+ */
+ protected $_captureLock = false;
+
+ /**
+ * Additional javascript statements that need to be executed after jQuery lib.
+ *
+ * @var Array
+ */
+ protected $_javascriptStatements = array();
+
+ /**
+ * Additional stylesheet files for jQuery related components.
+ *
+ * @var Array
+ */
+ protected $_stylesheets = array();
+
+ /**
+ * jQuery onLoad statements Stack
+ *
+ * @var Array
+ */
+ protected $_onLoadActions = array();
+
+ /**
+ * View is rendered in XHTML or not.
+ *
+ * @var Boolean
+ */
+ protected $_isXhtml = false;
+
+ /**
+ * Default CDN jQuery Library version
+ *
+ * @var String
+ */
+ protected $_version = ZendX_JQuery::DEFAULT_JQUERY_VERSION;
+
+ /**
+ * Default Render Mode (all parts)
+ *
+ * @var Integer
+ */
+ protected $_renderMode = ZendX_JQuery::RENDER_ALL;
+
+ /**
+ * jQuery UI Library Enabled
+ *
+ * @var Boolean
+ */
+ protected $_uiEnabled = false;
+
+ /**
+ * Local jQuery UI Path. Use Google CDN if
+ * variable is null
+ *
+ * @var String
+ */
+ protected $_uiPath = null;
+
+ /**
+ * jQuery UI Google CDN Version
+ *
+ * @var String
+ */
+ protected $_uiVersion = ZendX_JQuery::DEFAULT_UI_VERSION;
+
+ /**
+ * Load CDN Path from SSL or Non-SSL?
+ *
+ * @var boolean
+ */
+ protected $_loadSslCdnPath = false;
+
+ /**
+ * View Instance
+ *
+ * @var Zend_View_Interface
+ */
+ public $view = null;
+
+ /**
+ * Set view object
+ *
+ * @param Zend_View_Interface $view
+ * @return void
+ */
+ public function setView(Zend_View_Interface $view)
+ {
+ $this->view = $view;
+ }
+
+ /**
+ * Enable jQuery
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function enable()
+ {
+ $this->_enabled = true;
+ return $this;
+ }
+
+ /**
+ * Disable jQuery
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function disable()
+ {
+ $this->uiDisable();
+ $this->_enabled = false;
+ return $this;
+ }
+
+ /**
+ * Is jQuery enabled?
+ *
+ * @return boolean
+ */
+ public function isEnabled()
+ {
+ return $this->_enabled;
+ }
+
+ /**
+ * Set the version of the jQuery library used.
+ *
+ * @param string $version
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setVersion($version)
+ {
+ $this->_version = $version;
+ return $this;
+ }
+
+ /**
+ * Get the version used with the jQuery library
+ *
+ * @return string
+ */
+ public function getVersion()
+ {
+ return $this->_version;
+ }
+
+ /**
+ * Use CDN, using version specified. Currently supported
+ * by Googles Ajax Library API are: 1.2.3, 1.2.6
+ *
+ * @deprecated As of version 1.8, use {@link setVersion()} instead.
+ * @param string $version
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setCdnVersion($version = null)
+ {
+ return $this->setVersion($version);
+ }
+
+ /**
+ * Get CDN version
+ *
+ * @deprecated As of version 1.8, use {@link getVersion()} instead.
+ * @return string
+ */
+ public function getCdnVersion()
+ {
+ return $this->getVersion();
+ }
+
+ /**
+ * Set Use SSL on CDN Flag
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setCdnSsl($flag)
+ {
+ $this->_loadSslCdnPath = $flag;
+ return $this;
+ }
+
+ /**
+ * Are we using the CDN?
+ *
+ * @return boolean
+ */
+ public function useCdn()
+ {
+ return !$this->useLocalPath();
+ }
+
+ /**
+ * Set path to local jQuery library
+ *
+ * @param string $path
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setLocalPath($path)
+ {
+ $this->_jqueryLibraryPath = (string) $path;
+ return $this;
+ }
+
+ /**
+ * Enable jQuery UI Library Rendering
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function uiEnable()
+ {
+ $this->enable();
+ $this->_uiEnabled = true;
+ return $this;
+ }
+
+ /**
+ * Disable jQuery UI Library Rendering
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function uiDisable()
+ {
+ $this->_uiEnabled = false;
+ return $this;
+ }
+
+ /**
+ * Check wheater currently the jQuery UI library is enabled.
+ *
+ * @return boolean
+ */
+ public function uiIsEnabled()
+ {
+ return $this->_uiEnabled;
+ }
+
+ /**
+ * Set jQuery UI version used.
+ *
+ * @param string $version
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setUiVersion($version)
+ {
+ $this->_uiVersion = $version;
+ return $this;
+ }
+
+ /**
+ * Get jQuery UI Version used.
+ *
+ * @return string
+ */
+ public function getUiVersion()
+ {
+ return $this->_uiVersion;
+ }
+
+ /**
+ * Set jQuery UI CDN Version
+ *
+ * @deprecated As of 1.8 use {@link setUiVersion()}
+ * @param String $version
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setUiCdnVersion($version="1.5.2")
+ {
+ return $this->setUiVersion($version);
+ }
+
+ /**
+ * Return jQuery UI CDN Version
+ *
+ * @deprecated As of 1.8 use {@link getUiVersion()}
+ * @return String
+ */
+ public function getUiCdnVersion()
+ {
+ return $this->getUiVersion();
+ }
+
+ /**
+ * Set local path to jQuery UI library
+ *
+ * @param String $path
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setUiLocalPath($path)
+ {
+ $this->_uiPath = (string) $path;
+ return $this;
+ }
+
+ /**
+ * Return the local jQuery UI Path if set.
+ *
+ * @return string
+ */
+ public function getUiPath()
+ {
+ return $this->_uiPath;
+ }
+
+ /**
+ * Proxies to getUiPath() for consistency in function naming.
+ *
+ * @return string
+ */
+ public function getUiLocalPath()
+ {
+ return $this->getUiPath();
+ }
+
+ /**
+ * Is the jQuery Ui loaded from local scope?
+ *
+ * @return boolean
+ */
+ public function useUiLocal()
+ {
+ return (null===$this->_uiPath ? false : true);
+ }
+
+ /**
+ * Is the jQuery Ui enabled and loaded from CDN?
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function useUiCdn()
+ {
+ return !$this->useUiLocal();
+ }
+
+ /**
+ * Get local path to jQuery
+ *
+ * @return string
+ */
+ public function getLocalPath()
+ {
+ return $this->_jqueryLibraryPath;
+ }
+
+ /**
+ * Are we using a local path?
+ *
+ * @return boolean
+ */
+ public function useLocalPath()
+ {
+ return (null === $this->_jqueryLibraryPath) ? false : true;
+ }
+
+ /**
+ * Start capturing routines to run onLoad
+ *
+ * @return boolean
+ */
+ public function onLoadCaptureStart()
+ {
+ if ($this->_captureLock) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Cannot nest onLoad captures');
+ }
+
+ $this->_captureLock = true;
+ return ob_start();
+ }
+
+ /**
+ * Stop capturing routines to run onLoad
+ *
+ * @return boolean
+ */
+ public function onLoadCaptureEnd()
+ {
+ $data = ob_get_clean();
+ $this->_captureLock = false;
+
+ $this->addOnLoad($data);
+ return true;
+ }
+
+ /**
+ * Capture arbitrary javascript to include in jQuery script
+ *
+ * @return boolean
+ */
+ public function javascriptCaptureStart()
+ {
+ if ($this->_captureLock) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Cannot nest captures');
+ }
+
+ $this->_captureLock = true;
+ return ob_start();
+ }
+
+ /**
+ * Finish capturing arbitrary javascript to include in jQuery script
+ *
+ * @return boolean
+ */
+ public function javascriptCaptureEnd()
+ {
+ $data = ob_get_clean();
+ $this->_captureLock = false;
+
+ $this->addJavascript($data);
+ return true;
+ }
+
+ /**
+ * Add a Javascript File to the include stack.
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function addJavascriptFile($path)
+ {
+ $path = (string) $path;
+ if (!in_array($path, $this->_javascriptSources)) {
+ $this->_javascriptSources[] = (string) $path;
+ }
+ return $this;
+ }
+
+ /**
+ * Return all currently registered Javascript files.
+ *
+ * This does not include the jQuery library, which is handled by another retrieval
+ * strategy.
+ *
+ * @return Array
+ */
+ public function getJavascriptFiles()
+ {
+ return $this->_javascriptSources;
+ }
+
+ /**
+ * Clear all currently registered Javascript files.
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function clearJavascriptFiles()
+ {
+ $this->_javascriptSources = array();
+ return $this;
+ }
+
+ /**
+ * Add arbitrary javascript to execute in jQuery JS container
+ *
+ * @param string $js
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function addJavascript($js)
+ {
+ $this->_javascriptStatements[] = $js;
+ $this->enable();
+ return $this;
+ }
+
+ /**
+ * Return all registered javascript statements
+ *
+ * @return array
+ */
+ public function getJavascript()
+ {
+ return $this->_javascriptStatements;
+ }
+
+ /**
+ * Clear arbitrary javascript stack
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function clearJavascript()
+ {
+ $this->_javascriptStatements = array();
+ return $this;
+ }
+
+ /**
+ * Add a stylesheet
+ *
+ * @param string $path
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function addStylesheet($path)
+ {
+ $path = (string) $path;
+ if (!in_array($path, $this->_stylesheets)) {
+ $this->_stylesheets[] = (string) $path;
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve registered stylesheets
+ *
+ * @return array
+ */
+ public function getStylesheets()
+ {
+ return $this->_stylesheets;
+ }
+
+ /**
+ * Add a script to execute onLoad
+ *
+ * @param string $callback Lambda
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function addOnLoad($callback)
+ {
+ if (!in_array($callback, $this->_onLoadActions, true)) {
+ $this->_onLoadActions[] = $callback;
+ }
+ $this->enable();
+ return $this;
+ }
+
+ /**
+ * Retrieve all registered onLoad actions
+ *
+ * @return array
+ */
+ public function getOnLoadActions()
+ {
+ return $this->_onLoadActions;
+ }
+
+ /**
+ * Clear the onLoadActions stack.
+ *
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function clearOnLoadActions()
+ {
+ $this->_onLoadActions = array();
+ return $this;
+ }
+
+ /**
+ * Set which parts of the jQuery enviroment should be rendered.
+ *
+ * This function allows for a gradual refactoring of the jQuery code
+ * rendered by calling __toString(). Use ZendX_JQuery::RENDER_*
+ * constants. By default all parts of the enviroment are rendered.
+ *
+ * @see ZendX_JQuery::RENDER_ALL
+ * @param integer $mask
+ * @return ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ public function setRenderMode($mask)
+ {
+ $this->_renderMode = $mask;
+ return $this;
+ }
+
+ /**
+ * Return bitmask of the current Render Mode
+ * @return integer
+ */
+ public function getRenderMode()
+ {
+ return $this->_renderMode;
+ }
+
+ /**
+ * String representation of jQuery environment
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ if (!$this->isEnabled()) {
+ return '';
+ }
+
+ $this->_isXhtml = $this->view->doctype()->isXhtml();
+
+ $html = $this->_renderStylesheets() . PHP_EOL
+ . $this->_renderScriptTags() . PHP_EOL
+ . $this->_renderExtras();
+ return $html;
+ }
+
+ /**
+ * Render jQuery stylesheets
+ *
+ * @return string
+ */
+ protected function _renderStylesheets()
+ {
+ if( ($this->getRenderMode() & ZendX_JQuery::RENDER_STYLESHEETS) == 0) {
+ return '';
+ }
+
+ foreach ($this->getStylesheets() as $stylesheet) {
+ $stylesheets[] = $stylesheet;
+ }
+
+ if (empty($stylesheets)) {
+ return '';
+ }
+
+ array_reverse($stylesheets);
+ $style = "";
+ foreach($stylesheets AS $stylesheet) {
+ if ($this->view instanceof Zend_View_Abstract) {
+ $closingBracket = ($this->view->doctype()->isXhtml()) ? ' />' : '>';
+ } else {
+ $closingBracket = ' />';
+ }
+
+ $style .= '<link rel="stylesheet" href="'.$stylesheet.'" '.
+ 'type="text/css" media="screen"' . $closingBracket . PHP_EOL;
+ }
+
+ return $style;
+ }
+
+ /**
+ * Renders all javascript file related stuff of the jQuery enviroment.
+ *
+ * @return string
+ */
+ protected function _renderScriptTags()
+ {
+ $scriptTags = '';
+ if( ($this->getRenderMode() & ZendX_JQuery::RENDER_LIBRARY) > 0) {
+ $source = $this->_getJQueryLibraryPath();
+
+ $scriptTags .= '<script type="text/javascript" src="' . $source . '"></script>'.PHP_EOL;
+
+ if($this->uiIsEnabled()) {
+ $uiPath = $this->_getJQueryUiLibraryPath();
+ $scriptTags .= '<script type="text/javascript" src="'.$uiPath.'"></script>'.PHP_EOL;
+ }
+
+ if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
+ $scriptTags .= '<script type="text/javascript">var $j = jQuery.noConflict();</script>'.PHP_EOL;
+ }
+ }
+
+ if( ($this->getRenderMode() & ZendX_JQuery::RENDER_SOURCES) > 0) {
+ foreach($this->getJavascriptFiles() AS $javascriptFile) {
+ $scriptTags .= '<script type="text/javascript" src="' . $javascriptFile . '"></script>'.PHP_EOL;
+ }
+ }
+
+ return $scriptTags;
+ }
+
+ /**
+ * Renders all javascript code related stuff of the jQuery enviroment.
+ *
+ * @return string
+ */
+ protected function _renderExtras()
+ {
+ $onLoadActions = array();
+ if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JQUERY_ON_LOAD) > 0) {
+ foreach ($this->getOnLoadActions() as $callback) {
+ $onLoadActions[] = $callback;
+ }
+ }
+
+ $javascript = '';
+ if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JAVASCRIPT) > 0) {
+ $javascript = implode("\n ", $this->getJavascript());
+ }
+
+ $content = '';
+
+ if (!empty($onLoadActions)) {
+ if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
+ $content .= '$j(document).ready(function() {'."\n ";
+ } else {
+ $content .= '$(document).ready(function() {'."\n ";
+ }
+ $content .= implode("\n ", $onLoadActions) . "\n";
+ $content .= '});'."\n";
+ }
+
+ if (!empty($javascript)) {
+ $content .= $javascript . "\n";
+ }
+
+ if (preg_match('/^\s*$/s', $content)) {
+ return '';
+ }
+
+ $html = '<script type="text/javascript">' . PHP_EOL
+ . (($this->_isXhtml) ? '//<![CDATA[' : '//<!--') . PHP_EOL
+ . $content
+ . (($this->_isXhtml) ? '//]]>' : '//-->') . PHP_EOL
+ . PHP_EOL . '</script>';
+ return $html;
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getJQueryLibraryBaseCdnUri()
+ {
+ if($this->_loadSslCdnPath == true) {
+ $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE_SSL;
+ } else {
+ $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE;
+ }
+ return $baseUri;
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getJQueryUiLibraryBaseCdnUri()
+ {
+ if($this->_loadSslCdnPath == true) {
+ $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE_SSL;
+ } else {
+ $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE;
+ }
+ return $baseUri;
+ }
+
+ /**
+ * Internal function that constructs the include path of the jQuery library.
+ *
+ * @return string
+ */
+ protected function _getJQueryLibraryPath()
+ {
+ if($this->_jqueryLibraryPath != null) {
+ $source = $this->_jqueryLibraryPath;
+ } else {
+ $baseUri = $this->_getJQueryLibraryBaseCdnUri();
+ $source = $baseUri .
+ ZendX_JQuery::CDN_SUBFOLDER_JQUERY .
+ $this->getCdnVersion() .
+ ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE;
+ }
+
+ return $source;
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getJQueryUiLibraryPath()
+ {
+ if($this->useUiCdn()) {
+ $baseUri = $this->_getJQueryLibraryBaseCdnUri();
+ $uiPath = $baseUri.
+ ZendX_JQuery::CDN_SUBFOLDER_JQUERYUI .
+ $this->getUiCdnVersion() .
+ "/jquery-ui.min.js";
+ } else if($this->useUiLocal()) {
+ $uiPath = $this->getUiPath();
+ }
+ return $uiPath;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/Slider.php b/library/ZendX/JQuery/View/Helper/Slider.php
new file mode 100644
index 0000000..9bd7dda
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/Slider.php
@@ -0,0 +1,164 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Slider.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Slider View Helper
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_Slider extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Create jQuery slider that updates its values into a hidden form input field.
+ *
+ * @link http://docs.jquery.com/UI/Slider
+ * @param string $id
+ * @param string $value
+ * @param array $params
+ * @param array $attribs
+ * @return string
+ */
+ public function slider($id, $value = null, array $params = array(), array $attribs = array())
+ {
+ if(!isset($attribs['id'])) {
+ $attribs['id'] = $id;
+ }
+
+ $jqh = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
+
+ $params = $this->initializeStartingValues($value, $params);
+ $handleCount = $this->getHandleCount($params);
+
+ // Build the Change/Update functionality of the Slider via javascript, updating hidden fields. aswell as hidden fields
+ $hidden = "";
+ if(!isset($params['change'])) {
+ $sliderUpdateFn = 'function(e, ui) {'.PHP_EOL;
+ for($i = 0; $i < $handleCount; $i++) {
+ // Js Func
+ if($i === 0) {
+ $sliderHiddenId = $attribs['id'];
+ } else {
+ $sliderHiddenId = $attribs['id']."-".$i;
+ }
+ $sliderUpdateFn .= $this->getChangeCallback($jqh, $sliderHiddenId, $attribs['id'], $i);
+
+ // Hidden Fields
+ $startValue = $this->getHandleValue($i, $params);
+ $hiddenAttribs = array('type' => 'hidden', 'id' => $sliderHiddenId, 'name' => $sliderHiddenId, 'value' => $startValue);
+ $hidden .= '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket(). PHP_EOL;
+ }
+ $sliderUpdateFn .= "}".PHP_EOL;
+ $params['change'] = new Zend_Json_Expr($sliderUpdateFn);
+ }
+
+ $attribs['id'] .= "-slider";
+
+ if(count($params) > 0) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = '{}';
+ }
+
+ $js = sprintf('%s("#%s").slider(%s);', $jqh, $attribs['id'], $params);
+ $this->jquery->addOnLoad($js);
+
+ $html = '<div' . $this->_htmlAttribs($attribs) . '>';
+ for($i = 0; $i < $handleCount; $i++) {
+ $html .= '<div class="ui-slider-handle"></div>';
+ }
+ $html .= '</div>';
+
+ return $hidden.$html;
+ }
+
+ protected function getChangeCallback($jqh, $sliderHiddenId, $elementId, $handlerNum)
+ {
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ return sprintf(' %s("#%s").attr("value", %s("#%s-slider").slider("values", %d));'.PHP_EOL,
+ $jqh, $sliderHiddenId, $jqh, $elementId, $handlerNum
+ );
+ } else {
+ return sprintf(' %s("#%s").attr("value", %s("#%s-slider").slider("value", %d));'.PHP_EOL,
+ $jqh, $sliderHiddenId, $jqh, $elementId, $handlerNum
+ );
+ }
+ }
+
+ protected function getHandleCount($params)
+ {
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ return count($params['values']);
+ } else {
+ return count($params['handles']);
+ }
+ }
+
+ protected function getHandleValue($handleNum, $params)
+ {
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ return $params['values'][$handleNum];
+ } else {
+ return $params['handles'][$handleNum]['start'];
+ }
+ }
+
+ protected function initializeStartingValues($value, $params)
+ {
+ $values = array();
+ if(isset($params['value'])) {
+ $values[] = $params['value'];
+ unset($params['value']);
+ } else if(isset($params['values'])) {
+ $values = $params['values'];
+ unset($params['values']);
+ } else if(isset($params['handles'])) {
+ for($i = 0; $i < count($params['handles']); $i++) {
+ $values[] = $params['handles'][$i]['start'];
+ }
+ unset($params['handles']);
+ } else if(isset($params['startValue'])) {
+ $values[] = $params['startValue'];
+ unset($params['startValue']);
+ } else if(is_numeric($value)) {
+ $values[] = $value;
+ }
+
+ if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
+ $params['values'] = $values;
+ } else {
+ $params['handles'] = array();
+ for($i = 0; $i < count($values); $i++) {
+ $params['handles'][$i]['start'] = $values[$i];
+ }
+ }
+ return $params;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/Spinner.php b/library/ZendX/JQuery/View/Helper/Spinner.php
new file mode 100644
index 0000000..86aee5c
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/Spinner.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Spinner.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Spinner View Helper
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_Spinner extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Create FormText field for numeric values that can be spinned through its values.
+ *
+ * @link http://docs.jquery.com/UI/Spinner
+ * @param string $id
+ * @param string $value
+ * @param array $params
+ * @param array $attribs
+ * @return string
+ */
+ public function spinner($id, $value="", array $params=array(), array $attribs=array())
+ {
+ $attribs = $this->_prepareAttributes($id, $value, $attribs);
+
+ if(!isset($params['start']) && is_numeric($value)) {
+ $params['start'] = $value;
+ }
+
+ if(count($params)) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = '{}';
+ }
+
+ $js = sprintf('%s("#%s").spinner(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+
+ $this->jquery->addOnLoad($js);
+
+ return $this->view->formText($id, $value, $attribs);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/TabContainer.php b/library/ZendX/JQuery/View/Helper/TabContainer.php
new file mode 100644
index 0000000..41452ce
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/TabContainer.php
@@ -0,0 +1,132 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: TabContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "ZendX/JQuery/View/Helper/UiWidget.php";
+
+/**
+ * jQuery Tabs Container View Helper
+ *
+ * @uses Zend_Json
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_TabContainer extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Save all the pre-rendered tab panes to each tab container
+ *
+ * @var array
+ */
+ protected $_tabs = array();
+
+ /**
+ * Add Tab to TabsContainer
+ *
+ * @param string $id
+ * @param string $name
+ * @param string $content
+ * @param array $options
+ * @return ZendX_JQuery_View_Helper_TabsContainer
+ */
+ public function addPane($id, $name, $content, array $options=array())
+ {
+ if(!isset($this->_tabs[$id])) {
+ $this->_tabs[$id] = array();
+ }
+ if(strlen($name) == 0 && isset($options['title'])) {
+ $name = $options['title'];
+ }
+
+ $this->_tabs[$id][] = array('name' => $name, 'content' => $content, 'options' => $options);
+ return $this;
+ }
+
+ /**
+ * Render TabsContainer with all the currently registered tabs.
+ *
+ * Render all tabs to the given $id. If no arguments are given the
+ * tabsContainer view helper object is returned and can be used
+ * for chaining {@link addPane()} for tab pane adding.
+ *
+ * @link http://docs.jquery.com/UI/Tabs
+ * @param string $id
+ * @param array $params
+ * @param array $attribs
+ * @return string|ZendX_JQuery_View_Helper_TabsContainer
+ */
+ public function tabContainer($id=null, $params=array(), $attribs=array())
+ {
+ if(func_num_args() === 0) {
+ return $this;
+ }
+
+ if(!isset($attribs['id'])) {
+ $attribs['id'] = $id;
+ }
+
+ $content = "";
+ if(isset($this->_tabs[$id])) {
+ $list = '<ul class="ui-tabs-nav">'.PHP_EOL;
+ $html = '';
+ $fragment_counter = 1;
+ foreach($this->_tabs[$id] AS $k => $v) {
+ $frag_name = sprintf('%s-frag-%d', $attribs['id'], $fragment_counter++);
+ $opts = $v['options'];
+ if(isset($opts['contentUrl'])) {
+ $list .= '<li class="ui-tabs-nav-item"><a href="'.$opts['contentUrl'].'"><span>'.$v['name'].'</span></a></li>'.PHP_EOL;
+ } else {
+ $list .= '<li class="ui-tabs-nav-item"><a href="#'.$frag_name.'"><span>'.$v['name'].'</span></a></li>'.PHP_EOL;
+ $html .= '<div id="'.$frag_name.'" class="ui-tabs-panel">'.$v['content'].'</div>'.PHP_EOL;
+ }
+ }
+ $list .= '</ul>'.PHP_EOL;
+
+ $content = $list.$html;
+ unset($this->_tabs[$id]);
+ }
+
+ if(count($params)) {
+ $params = ZendX_JQuery::encodeJson($params);
+ } else {
+ $params = '{}';
+ }
+
+ $js = sprintf('%s("#%s").tabs(%s);',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $attribs['id'],
+ $params
+ );
+ $this->jquery->addOnLoad($js);
+
+ $html = '<div'
+ . $this->_htmlAttribs($attribs)
+ . '>'.PHP_EOL
+ . $content
+ . '</div>'.PHP_EOL;
+ return $html;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/TabPane.php b/library/ZendX/JQuery/View/Helper/TabPane.php
new file mode 100644
index 0000000..8d4acf2
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/TabPane.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: TabPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+require_once "UiWidgetPane.php";
+
+/**
+ * jQuery Tabs Pane View Helper, goes with Tab Container
+ *
+ * @uses Zend_Json, ZendX_JQuery_View_Helper_TabContainer
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class ZendX_JQuery_View_Helper_TabPane extends ZendX_JQuery_View_Helper_UiWidgetPane
+{
+ /**
+ * Add a tab pane to the tab container with the given $id.
+ *
+ * @param string $id
+ * @param string $content
+ * @param array $options
+ * @return string always empty
+ */
+ public function tabPane($id=null, $content='', array $options=array())
+ {
+ if(0 === func_num_args()) {
+ return $this;
+ }
+
+ $name = '';
+ if(isset($options['title'])) {
+ $name = $options['title'];
+ unset($options['title']);
+ }
+
+ $this->_addPane($id, $name, $content, $options);
+ return '';
+ }
+
+ /**
+ * Register new tab pane with tabContainer view helper.
+ *
+ * @see ZendX_JQuery_View_Helper_TabContainer::addPane
+ * @param string $id
+ * @param string $name
+ * @param string $content
+ * @param array $options
+ * @return void
+ */
+ protected function _addPane($id, $name, $content, array $options=array())
+ {
+ $this->view->tabContainer()->addPane($id, $name, $content, $options);
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/UiWidget.php b/library/ZendX/JQuery/View/Helper/UiWidget.php
new file mode 100644
index 0000000..9ae3270
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/UiWidget.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidget.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "Zend/View/Helper/HtmlElement.php";
+
+/**
+ * @see ZendX_JQuery
+ */
+require_once "ZendX/JQuery.php";
+
+/**
+ * jQuery Ui Widget Base class
+ *
+ * @uses ZendX_JQuery_View_Helper_JQuery_Container
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class ZendX_JQuery_View_Helper_UiWidget extends Zend_View_Helper_HtmlElement
+{
+ /**
+ * Contains reference to the jQuery view helper
+ *
+ * @var ZendX_JQuery_View_Helper_JQuery_Container
+ */
+ protected $jquery;
+
+ /**
+ * Set view and enable jQuery Core and UI libraries
+ *
+ * @param Zend_View_Interface $view
+ * @return ZendX_JQuery_View_Helper_Widget
+ */
+ public function setView(Zend_View_Interface $view)
+ {
+ parent::setView($view);
+ $this->jquery = $this->view->jQuery();
+ $this->jquery->enable()
+ ->uiEnable();
+ return $this;
+ }
+
+ /**
+ * Helps with building the correct Attributes Array structure.
+ *
+ * @param String $id
+ * @param String $value
+ * @param Array $attribs
+ * @return Array $attribs
+ */
+ protected function _prepareAttributes($id, $value, $attribs)
+ {
+ if(!isset($attribs['id'])) {
+ $attribs['id'] = $id;
+ }
+ $attribs['name'] = $id;
+ $attribs['value'] = (string) $value;
+
+ return $attribs;
+ }
+}
\ No newline at end of file
diff --git a/library/ZendX/JQuery/View/Helper/UiWidgetPane.php b/library/ZendX/JQuery/View/Helper/UiWidgetPane.php
new file mode 100644
index 0000000..154ce88
--- /dev/null
+++ b/library/ZendX/JQuery/View/Helper/UiWidgetPane.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @category ZendX
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: UiWidgetPane.php 20165 2010-01-09 18:57:56Z bkarwin $
+ */
+
+/**
+ * @see ZendX_JQuery_View_Helper_UiWidget
+ */
+require_once "UiWidget.php";
+
+/**
+ * jQuery Pane Base class, adds captureStart/captureEnd functionality for panes.
+ *
+ * @uses ZendX_JQuery_View_Helper_JQuery_Container
+ * @package ZendX_JQuery
+ * @subpackage View
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class ZendX_JQuery_View_Helper_UiWidgetPane extends ZendX_JQuery_View_Helper_UiWidget
+{
+ /**
+ * Capture Lock information
+ *
+ * @var array
+ */
+ protected $_captureLock = array();
+
+ /**
+ * Current capture additional information
+ *
+ * @var array
+ */
+ protected $_captureInfo = array();
+
+ /**
+ * Begin capturing content for layout container
+ *
+ * @param string $id
+ * @param string $name
+ * @param array $options
+ * @return void
+ */
+ public function captureStart($id, $name, array $options=array())
+ {
+ if (array_key_exists($id, $this->_captureLock)) {
+ require_once 'ZendX/JQuery/View/Exception.php';
+ throw new ZendX_JQuery_View_Exception(sprintf('Lock already exists for id "%s"', $id));
+ }
+
+ $this->_captureLock[$id] = true;
+ $this->_captureInfo[$id] = array(
+ 'name' => $name,
+ 'options' => $options,
+ );
+
+ return ob_start();
+ }
+
+ /**
+ * Finish capturing content for layout container
+ *
+ * @param string $id
+ * @return string
+ */
+ public function captureEnd($id)
+ {
+ if (!array_key_exists($id, $this->_captureLock)) {
+ require_once 'ZendX/JQuery/View/Exception.php';
+ throw new ZendX_JQuery_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
+ }
+
+ $content = ob_get_clean();
+ extract($this->_captureInfo[$id]);
+ unset($this->_captureLock[$id], $this->_captureInfo[$id]);
+ return $this->_addPane($id, $name, $content, $options);
+ }
+
+ /**
+ * Add an additional pane to the current Widget Container
+ *
+ * @param string $id
+ * @param string $name
+ * @param string $content
+ * @param array $options
+ */
+ abstract protected function _addPane($id, $name, $content, array $options=array());
+}
\ No newline at end of file
|
jtietema/Fizzy
|
fa8ad70a24160ae3a02210e74b078d895a391b37
|
Styled login screen
|
diff --git a/application/modules/admin/views/layouts/login.phtml b/application/modules/admin/views/layouts/login.phtml
index 3a02ccd..2e3bd41 100644
--- a/application/modules/admin/views/layouts/login.phtml
+++ b/application/modules/admin/views/layouts/login.phtml
@@ -1,54 +1,57 @@
<?php
/**
* Fizzy login layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!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">
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css"); ?>" rel="stylesheet" type="text/css" media="screen" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
+ <script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
</head>
<body>
- <div id="header">
- </div>
- <div class="container">
+ <div id="container">
+ <div id="login-panel">
+
+ <h1>Fizzy login</h1>
- <div id="messages" class="span-24 last">
- <div class="message">
+ <div id="message-panel">
<?= $this->fizzyMessages(); ?>
</div>
- </div>
- <div id="content" class="span-24 last content-container">
- <div id="content-wrapper">
- <?= $this->layout()->content; ?>
- </div>
+ <?= $this->layout()->content; ?>
+
+ <div class="clear"></div>
+
</div>
- <div id="footer" class="span-24 last">
+ <div style="position: absolute; width: 500px; top: 280px; left: 50%; margin-left: -250px; padding: 10px; text-align: right;">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
</div>
- <div class="clear"></div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/login.phtml b/application/modules/admin/views/scripts/login.phtml
index bd1811b..b2d5926 100644
--- a/application/modules/admin/views/scripts/login.phtml
+++ b/application/modules/admin/views/scripts/login.phtml
@@ -1,4 +1,7 @@
-<h1 class="header">Login</h1>
-<div class="form-container">
- <?= $this->form; ?>
+<div class="form-panel">
+ <form action="<?= $this->form->getAction(); ?>" id="Loginform" name="LoginForm" method="post">
+ <?= $this->form->username; ?>
+ <?= $this->form->password; ?>
+ <input type="submit" value="Login" />
+ </form>
</div>
\ No newline at end of file
|
jtietema/Fizzy
|
5f232149e9920a65e20a013d27627f75d695e2a7
|
Added Zend_Navigation for generating admin menu
|
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 6b8f720..f339e11 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,23 +1,103 @@
<?php
+/**
+ * Class Admin_IndexController
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
class Admin_IndexController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Zend_Registry::get('config')->toArray();
$this->renderScript('configuration.phtml');
}
+
+ /**
+ * Renders navigation for the admin section.
+ */
+ public function navigationAction() {
+ $items = array();
+
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Pages',
+ 'route' => 'admin_pages',
+ 'module' => 'admin',
+ 'controller' => 'pages',
+ 'action' => 'index',
+ 'pages' => array(
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Add',
+ 'route' => 'admin_pages_add',
+ 'module' => 'admin',
+ 'controller' => 'pages',
+ 'action' => 'add',
+ )),
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Edit',
+ 'route' => 'admin_pages_edit',
+ 'module' => 'admin',
+ 'controller' => 'pages',
+ 'action' => 'edit',
+ )),
+ )
+ ));
+
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Media',
+ 'route' => 'admin_media',
+ 'module' => 'admin',
+ 'controller' => 'media',
+ 'action' => 'index',
+ 'pages' => array ()
+ ));
+
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Users',
+ 'route' => 'admin_users',
+ 'module' => 'admin',
+ 'controller' => 'user',
+ 'action' => 'index',
+ 'pages' => array (
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Add',
+ 'route' => 'admin_users_add',
+ 'module' => 'admin',
+ 'controller' => 'user',
+ 'action' => 'add',
+ )),
+ new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Edit',
+ 'route' => 'admin_users_edit',
+ 'module' => 'admin',
+ 'controller' => 'user',
+ 'action' => 'edit',
+ )),
+ )
+ ));
+
+ $items[] = new Zend_Navigation_Page_Mvc(array(
+ 'label' => 'Logout',
+ 'route' => 'admin_logout',
+ 'module' => 'admin',
+ 'controller' => 'auth',
+ 'action' => 'logout'
+ ));
+
+ $this->view->items = $items;
+ $this->renderScript('navigation.phtml');
+ }
}
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
index 95515c8..0dfff8a 100644
--- a/application/modules/admin/views/layouts/default.phtml
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -1,79 +1,72 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/reset-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fonts-min.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy-2.0.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/tables.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/forms.css") ?>" rel="stylesheet" type="text/css" media="screen, presentation" />
<script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="container">
<div id="header-panel">
<h1>Fizzy</h1>
<div id="navigation-panel">
- <ul>
- <li class="active"><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
- <li><a href="<?= $this->baseUrl("/fizzy/media") ?>">Media</a></li>
- <li><a href="<?= $this->baseUrl("/fizzy/users") ?>">Users</a></li>
- <li><a href="<?= $this->baseUrl("/fizzy/configuration") ?>">Configuration</a></li>
- <li class="link-logout"><a href="<?= $this->baseUrl("/fizzy/logout") ?>">Logout</a></li>
- </ul>
- <div class="clear"></div>
+ <?= $this->action('navigation', 'index', 'admin'); ?>
</div>
</div>
<div id="main-panel">
<div id="messages-panel">
<?= $this->render('flashMessages.phtml'); ?>
</div>
<?= $this->layout()->content; ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="footer-panel">
<div id="copyright-panel">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
diff --git a/application/modules/admin/views/scripts/navigation.phtml b/application/modules/admin/views/scripts/navigation.phtml
new file mode 100644
index 0000000..7b97fef
--- /dev/null
+++ b/application/modules/admin/views/scripts/navigation.phtml
@@ -0,0 +1,8 @@
+<ul>
+ <?php foreach($this->items as $page) : ?>
+ <li<?= ($page->isActive(true)) ? ' class="active"' : ''; ?>>
+ <a href="<?= $page->getHref(); ?>"><?= $page->getLabel(); ?></a>
+ </li>
+ <?php endforeach; ?>
+</ul>
+<div class="clear"></div>
\ No newline at end of file
diff --git a/configs/routes.ini b/configs/routes.ini
index 91bf0b4..a2f7517 100644
--- a/configs/routes.ini
+++ b/configs/routes.ini
@@ -1,106 +1,106 @@
[development : production]
[test : production]
[production]
;; Catch all for pages slugs
page_by_slug.route = "/:slug"
page_by_slug.defaults.controller = "pages"
page_by_slug.defaults.action = "slug"
page_by_slug.defaults.module = "default"
contact.route = "/contact"
contact.defaults.controller = "contact"
contact.defaults.action = "index"
contact.defaults.module = "default"
;; Admin pages control
-admin_pages.route = "/fizzy/pages/"
+admin_pages.route = "/fizzy/pages"
admin_pages.defaults.action = "index"
admin_pages.defaults.controller = "pages"
admin_pages.defaults.module = "admin"
admin_pages_add.route = "/fizzy/pages/add"
admin_pages_add.defaults.action = "add"
admin_pages_add.defaults.controller = "pages"
admin_pages_add.defaults.module = "admin"
admin_pages_edit.route = "/fizzy/pages/edit/:id"
admin_pages_edit.defaults.action = "edit"
admin_pages_edit.defaults.controller = "pages"
admin_pages_edit.defaults.module = "admin"
admin_pages_delete.route = "/fizzy/pages/delete/:id"
admin_pages_delete.defaults.action = "delete"
admin_pages_delete.defaults.controller = "pages"
admin_pages_delete.defaults.module = "admin"
admin_media.route = "/fizzy/media"
admin_media.defaults.action = "index"
admin_media.defaults.controller = "media"
admin_media.defaults.module = "admin"
admin_media_delete.route = "/fizzy/media/delete/:name"
admin_media_delete.defaults.action = "delete"
admin_media_delete.defaults.controller = "media"
admin_media_delete.defaults.module = "admin"
admin_media_gallery.route = "/fizzy/media/gallery"
admin_media_gallery.defaults.action = "gallery"
admin_media_gallery.defaults.controller = "media"
admin_media_gallery.defaults.module = "admin"
admin_media_assets.route = "/fizzy/media/assets"
admin_media_assets.defaults.action = "assets"
admin_media_assets.defaults.controller = "media"
admin_media_assets.defaults.module = "admin"
;; Admin users
admin_users.route = "/fizzy/users"
admin_users.defaults.action = "index"
admin_users.defaults.controller = "user"
admin_users.defaults.module = "admin"
admin_users_add.route = "/fizzy/user/add"
admin_users_add.defaults.action = "add"
admin_users_add.defaults.controller = "user"
admin_users_add.defaults.module = "admin"
admin_users_edit.route = "/fizzy/user/edit/:id"
admin_users_edit.defaults.action = "edit"
admin_users_edit.defaults.controller = "user"
admin_users_edit.defaults.module = "admin"
admin_users_delete.route = "/fizzy/user/delete/:id"
admin_users_delete.defaults.action = "delete"
admin_users_delete.defaults.controller = "user"
admin_users_delete.defaults.module = "admin"
;; Admin configuration
admin_configuration.route = "/fizzy/configuration"
admin_configuration.defaults.action = "configuration"
admin_configuration.defaults.controller = "index"
admin_configuration.defaults.module = "admin"
;; Admin WebDAV
admin_configuration.route = "/fizzy/webdav/*"
admin_configuration.defaults.module = "admin"
admin_configuration.defaults.controller = "webdav"
admin_configuration.defaults.action = "request"
;; Auth section
admin_login.route = "/fizzy/login"
admin_login.defaults.action = "login"
admin_login.defaults.controller = "auth"
admin_login.defaults.module = "admin"
admin_logout.route = "/fizzy/logout"
admin_logout.defaults.action = "logout"
admin_logout.defaults.controller = "auth"
admin_logout.defaults.module = "admin"
admin.route = "/fizzy"
admin.defaults.action = "index"
admin.defaults.controller = "index"
admin.defaults.module = "admin"
|
jtietema/Fizzy
|
700b22296c41c8207ea949e63895e1fbfe03fcdf
|
geocode adapter interface aangepast
|
diff --git a/application/library/Fizzy/Geocode/Adapter/Interface.php b/application/library/Fizzy/Geocode/Adapter/Interface.php
index a0249de..5759750 100644
--- a/application/library/Fizzy/Geocode/Adapter/Interface.php
+++ b/application/library/Fizzy/Geocode/Adapter/Interface.php
@@ -1,8 +1,8 @@
<?php
interface Fizzy_Geocode_Adapter_Interface
{
public function getQuery();
public function setQuery($query);
- public function location($query);
+ public function location($query = null);
}
\ No newline at end of file
|
jtietema/Fizzy
|
b6c0a4ffc305b48c56eb44e051ce5cb592ac0884
|
Geocode Response object & yahoo adapter
|
diff --git a/application/library/Fizzy/Geocode/Adapter/Google.php b/application/library/Fizzy/Geocode/Adapter/Google.php
index eecf301..5a26496 100644
--- a/application/library/Fizzy/Geocode/Adapter/Google.php
+++ b/application/library/Fizzy/Geocode/Adapter/Google.php
@@ -1,205 +1,214 @@
<?php
require_once 'Zend/Http/Client.php';
require_once 'Zend/Json.php';
require_once 'Zend/Uri.php';
+require_once 'Fizzy/Geocode/Adapter/Interface.php';
+require_once 'Fizzy/Geocode/Response.php';
+require_once 'Fizzy/Geocode/Location.php';
+
/**
- * Description of Google
+ * Adapter voor Google Maps Geocode server V3
*
* @author Jeroen Tietema <[email protected]>
*/
class Fizzy_Geocode_Adapter_Google implements Fizzy_Geocode_Adapter_Interface
{
/**
* Base url for the geocode api
* @var string
*/
- protected $_apiUrl = 'http://maps.google.com/maps/geo';
+ protected $_apiUrl = 'http://maps.google.com/maps/api/geocode/';
/**
* Will be configurable in the future when moer output formats are supported.
* @var string
*/
protected $_output = 'json';
- /**
- * The Google maps API key
- * @var string
- */
- protected $_apiKey = null;
-
/**
* The search query to look up the coordinates for
* @var string
*/
protected $_query = null;
/**
* The country code, specified as a ccTLD ("top-level domain") two-character value.
* {@see http://code.google.com/apis/maps/documentation/geocoding/index.html#CountryCodes}
* @var string
*/
protected $_countryCode = null;
/**
* If Google API's should try to use device specific things to determine the
* location of the device. E.g. a GPS
* @var boolean
*/
protected $_sensor = false;
/**
* The Http client used. Must be an instance of Zend_Http_Client
* @var Zend_Http_Client
*/
protected $_client = null;
/** **/
- /**
- * Geocode constructor. Accepts the geocode API key as parameter.
- * @param string $apiKey
- */
- public function __construct($apiKey = null)
- {
- if (null !== $apiKey) {
- $this->setApiKey($apiKey);
- }
- }
-
- /**
- * Returns the API key.
- * @return string
- */
- public function getApiKey()
- {
- return $this->_apiKey;
- }
-
- /**
- * Set the Google Maps API key
- *
- * @param string $apiKey
- */
- public function setApiKey($apiKey)
- {
- $this->_apiKey = $apiKey;
- return $this;
- }
-
/**
* Return the Search query
*
* @return string
*/
public function getQuery()
{
return $this->_query;
}
/**
* Set the search query
*
* @param string $query
* @return Fizzy_Geocode_Adapter_Google
*/
public function setQuery($query)
{
$this->_query = str_replace(' ', '+', $query);
return $this;
}
/**
* Set the language code to influence the search results. Language code
* must be a two value TLD style string.
*
* @param string $code
* @return Fizzy_Geocode_Adapter_Google
*/
public function setCountryCode($code)
{
$this->_countryCode = strtoupper($code);
return $this;
}
/**
* Returns the country code that will be used in the search query.
*
* @return null|string
*/
public function getCountryCode()
{
return $this->_countryCode;
}
public function getSensor()
{
return $this->_sensor;
}
/**
* @param boolean $sensor
*/
public function setSensor($sensor)
{
$this->_sensor = (boolean) $sensor;
return $this;
}
/**
* Returns the current client instance if any.
* @return Zend_Http_Client|null
*/
public function getHttpClient()
{
return $this->_client;
}
/**
* Set the Http client to use for making the requests. This is usefull if
* you what Zend_Http_Client to use a specific Zend_Http_Client adapter.
* @param Zend_Http_Client $client
* @return Fizzy_Geocode_Adapter_Google
*/
public function setHttpClient(Zend_Http_Client $client)
{
$this->_client = $client;
return $this;
}
- public function location($query)
+ public function location($query = null)
{
if(null !== $query) {
$this->setQuery($query);
}
// Build the request parameters
$parameters = array (
- 'q' => $this->_query,
- 'key' => $this->_apiKey,
- 'output' => $this->_output,
+ 'address' => $this->_query,
'sensor' => ($this->_sensor ? 'true' : 'false')
);
if(null !== $this->_countryCode) {
$parameters['lg'] = $this->_countryCode;
}
// Build the request URI
- $uri = Zend_Uri::factory($this->_apiUrl);
+ $uri = Zend_Uri::factory($this->_apiUrl . $this->_output);
$uri->setQuery($parameters);
// Send the request
- if ($this->_client === null)
+ if ($this->_client === null){
$this->_client = new Zend_Http_Client($uri);
- $response = $this->_client->request();
+ } else {
+ $this->_client->setUri($uri);
+ }
+ $httpResponse = $this->_client->request();
+ $json = $httpResponse->getBody();
+
+ // parse the response into a Fizzy_Geocode_Response
+ $response = new Fizzy_Geocode_Response();
+ $responseArray = Zend_Json::decode($json);
+
+ if ($responseArray['status'] != 'OK'){
+ $response->setErrors(array($responseArray['status']));
+ }
- /*
- * @todo parse the response into a Fizzy_Geocode_Response object
- */
- // Return only the response body
- $json = $response->getBody();
+ foreach ($responseArray['results'] as $result){
+ $location = new Fizzy_Geocode_Location();
+ $location->setLat($result['geometry']['location']['lat']);
+ $location->setLng($result['geometry']['location']['lng']);
+
+ $address = array(
+ 'number' => null,
+ 'street' => null,
+ 'city' => null,
+ 'zipcode' => null,
+ 'country' => null
+ );
+ foreach ($result['address_components'] as $component){
+ if (in_array('street_number', $component['types'])){
+ $address['number'] = $component['long_name'];
+ }
+ if (in_array('route', $component['types'])){
+ $address['street'] = $component['long_name'];
+ }
+ if (in_array('locality', $component['types'])){
+ $address['city'] = $component['long_name'];
+ }
+ if (in_array('country', $component['types'])){
+ $address['country'] = $component['long_name'];
+ }
+ if (in_array('postal_code', $component['types'])){
+ $address['zipcode'] = $component['long_name'];
+ }
+ }
+
+ $location->setAddress($address['street'] . ' ' . $address['number']);
+ $location->setZipcode($address['zipcode']);
+ $location->setCity($address['city']);
+ $location->setCountry($address['country']);
+
+ $response->addLocation($location);
+ }
- return Zend_Json::decode($json);
+ return $response;
}
}
diff --git a/application/library/Fizzy/Geocode/Adapter/Interface.php b/application/library/Fizzy/Geocode/Adapter/Interface.php
index 11b6312..a0249de 100644
--- a/application/library/Fizzy/Geocode/Adapter/Interface.php
+++ b/application/library/Fizzy/Geocode/Adapter/Interface.php
@@ -1,6 +1,8 @@
<?php
interface Fizzy_Geocode_Adapter_Interface
{
+ public function getQuery();
+ public function setQuery($query);
public function location($query);
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Geocode/Adapter/Yahoo.php b/application/library/Fizzy/Geocode/Adapter/Yahoo.php
new file mode 100644
index 0000000..fe87c23
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Adapter/Yahoo.php
@@ -0,0 +1,124 @@
+<?php
+require_once 'Zend/Uri.php';
+require_once 'Zend/Http/Client.php';
+
+require_once 'Fizzy/Geocode/Adapter/Interface.php';
+require_once 'Fizzy/Geocode/Exception.php';
+require_once 'Fizzy/Geocode/Response.php';
+require_once 'Fizzy/Geocode/Location.php';
+
+/**
+ * Description of Yahoo
+ *
+ * @author jeroen
+ */
+class Fizzy_Geocode_Adapter_Yahoo implements Fizzy_Geocode_Adapter_Interface
+{
+ protected $_apiKey = null;
+
+ protected $_output = 'php';
+
+ protected $_apiUrl = 'http://local.yahooapis.com/MapsService/V1/geocode';
+
+ protected $_query = null;
+
+ protected $_httpClient = null;
+
+ public function __construct($apiKey = null)
+ {
+ if (null !== $apiKey){
+ $this->_apiKey = $apiKey;
+ }
+ }
+
+ public function getApiKey()
+ {
+ return $this->_apiKey;
+ }
+
+ public function setApiKey($apiKey)
+ {
+ $this->_apiKey = $apiKey;
+ return $this;
+ }
+
+ public function getQuery()
+ {
+ return $this->_query;
+ }
+
+ public function setQuery($query)
+ {
+ $this->_query = $query;
+ return $this;
+ }
+
+ public function getHttpClient()
+ {
+ return $this->_httpClient;
+ }
+
+ public function setHttpClient(Zend_Http_Client $client)
+ {
+ $this->_httpClient = $client;
+ return $this;
+ }
+
+ public function location($query = null)
+ {
+ if (null !== $query){
+ $this->setQuery($query);
+ }
+
+ if (null === $this->_query){
+ throw new Fizzy_Geocode_Exception('No query passed');
+ }
+
+ $parameters = array(
+ 'appid' => $this->_apiKey,
+ 'location' => $this->_query,
+ 'output' => $this->_output
+ );
+
+ $uri = Zend_Uri::factory($this->_apiUrl);
+ $uri->setQuery($parameters);
+
+ if (null === $this->_httpClient){
+ $this->_httpClient = new Zend_Http_Client($uri);
+ } else {
+ $this->_httpClient->setUri($uri);
+ }
+
+ $httpResponse = $this->_httpClient->request();
+
+ $response = new Fizzy_Geocode_Response();
+
+ if (200 != $httpResponse->getStatus()){
+ if (400 == $httpResponse->getStatus()){
+ $response->setErrors(array('Bad request'));
+ } elseif (403 == $httpResponse->getStatus()){
+ $response->setErrors(array('Forbidden'));
+ } elseif (503 == $httpResponse->getStatus()){
+ $response->setErrors(array('Service unavailable'));
+ }
+ return $response;
+ }
+
+ $php = unserialize($httpResponse->getBody());
+ var_dump($php);
+
+ foreach ($php['ResultSet'] as $result){
+ $location = new Fizzy_Geocode_Location();
+ $location->setAddress($result['Address']);
+ $location->setZipcode($result['Zip']);
+ $location->setCity($result['City']);
+ $location->setCountry($result['Country']);
+
+ $location->setLat($result['Latitude']);
+ $location->setLng($result['Longitude']);
+
+ $response->addLocation($location);
+ }
+ return $response;
+ }
+}
diff --git a/application/library/Fizzy/Geocode/Coordinate.php b/application/library/Fizzy/Geocode/Coordinate.php
deleted file mode 100644
index 4922d44..0000000
--- a/application/library/Fizzy/Geocode/Coordinate.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * Description of Coordinates
- *
- * @author jeroen
- */
-class Fizzy_Geocode_Coordinate
-{
- protected $_lat = null;
- protected $_lng = null;
-
- public function getLat()
- {
- return $this->_lat;
- }
-
- public function setLat($lat)
- {
- $this->_lat = $lat;
- return $this;
- }
-
- public function getLng()
- {
- return $this->_lng;
- }
-
- public function setLng($lng)
- {
- $this->_lng = $lng;
- return $this;
- }
-}
diff --git a/application/library/Fizzy/Geocode/Exception.php b/application/library/Fizzy/Geocode/Exception.php
index 38a23dc..8f218fd 100644
--- a/application/library/Fizzy/Geocode/Exception.php
+++ b/application/library/Fizzy/Geocode/Exception.php
@@ -1,2 +1,4 @@
<?php
+require_once 'Fizzy/Exception.php';
+
class Fizzy_Geocode_Exception extends Fizzy_Exception {}
diff --git a/application/library/Fizzy/Geocode/Location.php b/application/library/Fizzy/Geocode/Location.php
index 1737cbd..ace3a2a 100644
--- a/application/library/Fizzy/Geocode/Location.php
+++ b/application/library/Fizzy/Geocode/Location.php
@@ -1,35 +1,121 @@
<?php
-require_once 'Fizzy/Geocode/Coordinate.php';
/**
* Description of Location
*
* @author jeroen
*/
class Fizzy_Geocode_Location
{
- protected $_coordinate = null;
+ /**
+ * Array with keys `lat` and `lng`
+ * @var array|null
+ */
+ protected $_lat = null;
+ protected $_lng = null;
+
+ protected $_address = null;
+ protected $_zipcode = null;
+ protected $_city = null;
+ protected $_country = null;
public function __construct(array $data = null)
{
- if (null !== $data) {
- if (
- array_key_exists('coordinate', $data) &&
- $data['coordinate'] instanceof Fizzy_Geocode_Coordinate
- ){
- $this->_coordinate = $data['coordinate'];
- }
+ if (isset($data['address'])){
+ $this->setAddress($data['address']);
+ }
+ if (isset($data['zipcode'])){
+ $this->setZipcode($data['zipcode']);
+ }
+ if (isset($data['city'])){
+ $this->setCity($data['city']);
+ }
+ if (isset($data['country'])){
+ $this->setCountry($data['country']);
+ }
+ if (isset($data['lat'])){
+ $this->setLat($data['lat']);
+ }
+ if (isset($data['lng'])){
+ $this->setLng($data['lng']);
}
}
public function getCoordinates()
{
return $this->_coordinates;
}
- public function setCoordinates(Fizzy_Geocode_Coordinate $coordinate)
+ public function setCoordinates($lat, $lng)
+ {
+ $this->_lat = $lat;
+ $this->_lng = $lng;
+ return $this;
+ }
+
+ public function getLat()
+ {
+ return $this->_lat;
+ }
+
+ public function setLat($lat)
+ {
+ $this->_lat = $lat;
+ return $this;
+ }
+
+ public function getLng()
+ {
+ return $this->_lng;
+ }
+
+ public function setLng($lng)
+ {
+ $this->_lng = $lng;
+ return $this;
+ }
+
+ public function getAddress()
+ {
+ return $this->_address;
+ }
+
+ public function setAddress($address)
+ {
+ $this->_address = $address;
+ return $this;
+ }
+
+ public function getZipcode()
+ {
+ return $this->_zipcode;
+ }
+
+ public function setZipcode($zipcode)
+ {
+ $this->_zipcode = $zipcode;
+ return $this;
+ }
+
+ public function getCity()
+ {
+ return $this->_city;
+ }
+
+ public function setCity($city)
+ {
+ $this->_city = $city;
+ return $city;
+ }
+
+ public function getCountry()
+ {
+ return $this->_country;
+ }
+
+ public function setCountry($country)
{
- $this->_coordinate = $coordinate;
+ $this->_country = $country;
return $this;
}
}
diff --git a/application/library/Fizzy/Geocode/Response.php b/application/library/Fizzy/Geocode/Response.php
index 115e1c6..84dc8b5 100644
--- a/application/library/Fizzy/Geocode/Response.php
+++ b/application/library/Fizzy/Geocode/Response.php
@@ -1,44 +1,74 @@
<?php
require_once 'Fizzy/Geocode/Location.php';
/**
* Description of Response
*
* @author jeroen
*/
class Fizzy_Geocode_Response {
protected $_query = '';
+ protected $_errors = null;
protected $_locations = array();
- public function __construct()
- {
-
- }
-
/**
* Returns the first location found
*/
public function first()
{
-
+ if (count($this->_locations) > 0){
+ return $this->_locations[0];
+ }
+ throw new Fizzy_Geocode_Exception('No locations set');
}
/**
* Returns all locations found
*/
public function all()
{
-
+ return $this->_locations;
}
/**
* The number of locations found
*/
public function count()
{
+ return count($this->_locations);
+ }
+
+ public function isError()
+ {
+ return (null !== $this->_errors);
+ }
+
+ public function getLocations()
+ {
+ return $this->_locations;
+ }
+
+ public function addLocation(Fizzy_Geocode_Location $location)
+ {
+ $this->_locations[] = $location;
+ }
+
+ public function setLocations(array $locations)
+ {
+ $this->_locations = $locations;
+ return $this;
+ }
+ public function getErrors()
+ {
+ return $this->_errors;
}
+ public function setErrors(array $errors)
+ {
+ $this->_errors = $errors;
+ return $this;
+ }
}
|
jtietema/Fizzy
|
94d63f3be317d83629e677d0ad48920fec0484d9
|
Fizzy_Geocode initial code
|
diff --git a/application/library/Fizzy/Geocode.php b/application/library/Fizzy/Geocode.php
new file mode 100644
index 0000000..613029c
--- /dev/null
+++ b/application/library/Fizzy/Geocode.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * This class provides a uniform API for making Geocode requests to different
+ * Geocode providers. The Class is adapter based.
+ * Currently it supports:
+ * - Google
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Geocode {
+ protected $_adapter = null;
+
+ public function __construct(Fizzy_Geocode_Adapter_Interface $adapter = null)
+ {
+ if (null !== $adapter) {
+ $this->_adapter = $adapter;
+ }
+ }
+
+ public function getAdapter()
+ {
+ return $this->_adapter;
+ }
+
+ public function setAdapter(Fizzy_Geocode_Adapter_Interface $adapter)
+ {
+ $this->_adapter = $adapter;
+ return $this;
+ }
+
+ /**
+ * Fires a Geocode query
+ * @param <type> $query
+ */
+ public function location($query)
+ {
+ return $this->_adapter->location($query);
+ }
+
+}
diff --git a/application/library/Fizzy/Geocode/Adapter/Google.php b/application/library/Fizzy/Geocode/Adapter/Google.php
new file mode 100644
index 0000000..eecf301
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Adapter/Google.php
@@ -0,0 +1,205 @@
+<?php
+require_once 'Zend/Http/Client.php';
+require_once 'Zend/Json.php';
+require_once 'Zend/Uri.php';
+
+/**
+ * Description of Google
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Geocode_Adapter_Google implements Fizzy_Geocode_Adapter_Interface
+{
+
+ /**
+ * Base url for the geocode api
+ * @var string
+ */
+ protected $_apiUrl = 'http://maps.google.com/maps/geo';
+
+ /**
+ * Will be configurable in the future when moer output formats are supported.
+ * @var string
+ */
+ protected $_output = 'json';
+
+ /**
+ * The Google maps API key
+ * @var string
+ */
+ protected $_apiKey = null;
+
+ /**
+ * The search query to look up the coordinates for
+ * @var string
+ */
+ protected $_query = null;
+
+ /**
+ * The country code, specified as a ccTLD ("top-level domain") two-character value.
+ * {@see http://code.google.com/apis/maps/documentation/geocoding/index.html#CountryCodes}
+ * @var string
+ */
+ protected $_countryCode = null;
+
+ /**
+ * If Google API's should try to use device specific things to determine the
+ * location of the device. E.g. a GPS
+ * @var boolean
+ */
+ protected $_sensor = false;
+
+ /**
+ * The Http client used. Must be an instance of Zend_Http_Client
+ * @var Zend_Http_Client
+ */
+ protected $_client = null;
+
+ /** **/
+
+ /**
+ * Geocode constructor. Accepts the geocode API key as parameter.
+ * @param string $apiKey
+ */
+ public function __construct($apiKey = null)
+ {
+ if (null !== $apiKey) {
+ $this->setApiKey($apiKey);
+ }
+ }
+
+ /**
+ * Returns the API key.
+ * @return string
+ */
+ public function getApiKey()
+ {
+ return $this->_apiKey;
+ }
+
+ /**
+ * Set the Google Maps API key
+ *
+ * @param string $apiKey
+ */
+ public function setApiKey($apiKey)
+ {
+ $this->_apiKey = $apiKey;
+ return $this;
+ }
+
+ /**
+ * Return the Search query
+ *
+ * @return string
+ */
+ public function getQuery()
+ {
+ return $this->_query;
+ }
+
+ /**
+ * Set the search query
+ *
+ * @param string $query
+ * @return Fizzy_Geocode_Adapter_Google
+ */
+ public function setQuery($query)
+ {
+ $this->_query = str_replace(' ', '+', $query);
+ return $this;
+ }
+
+ /**
+ * Set the language code to influence the search results. Language code
+ * must be a two value TLD style string.
+ *
+ * @param string $code
+ * @return Fizzy_Geocode_Adapter_Google
+ */
+ public function setCountryCode($code)
+ {
+ $this->_countryCode = strtoupper($code);
+ return $this;
+ }
+
+ /**
+ * Returns the country code that will be used in the search query.
+ *
+ * @return null|string
+ */
+ public function getCountryCode()
+ {
+ return $this->_countryCode;
+ }
+
+ public function getSensor()
+ {
+ return $this->_sensor;
+ }
+
+ /**
+ * @param boolean $sensor
+ */
+ public function setSensor($sensor)
+ {
+ $this->_sensor = (boolean) $sensor;
+ return $this;
+ }
+
+ /**
+ * Returns the current client instance if any.
+ * @return Zend_Http_Client|null
+ */
+ public function getHttpClient()
+ {
+ return $this->_client;
+ }
+
+ /**
+ * Set the Http client to use for making the requests. This is usefull if
+ * you what Zend_Http_Client to use a specific Zend_Http_Client adapter.
+ * @param Zend_Http_Client $client
+ * @return Fizzy_Geocode_Adapter_Google
+ */
+ public function setHttpClient(Zend_Http_Client $client)
+ {
+ $this->_client = $client;
+ return $this;
+ }
+
+ public function location($query)
+ {
+ if(null !== $query) {
+ $this->setQuery($query);
+ }
+
+ // Build the request parameters
+ $parameters = array (
+ 'q' => $this->_query,
+ 'key' => $this->_apiKey,
+ 'output' => $this->_output,
+ 'sensor' => ($this->_sensor ? 'true' : 'false')
+ );
+ if(null !== $this->_countryCode) {
+ $parameters['lg'] = $this->_countryCode;
+ }
+
+ // Build the request URI
+ $uri = Zend_Uri::factory($this->_apiUrl);
+ $uri->setQuery($parameters);
+
+ // Send the request
+ if ($this->_client === null)
+ $this->_client = new Zend_Http_Client($uri);
+ $response = $this->_client->request();
+
+ /*
+ * @todo parse the response into a Fizzy_Geocode_Response object
+ */
+ // Return only the response body
+ $json = $response->getBody();
+
+ return Zend_Json::decode($json);
+ }
+}
diff --git a/application/library/Fizzy/Geocode/Adapter/Interface.php b/application/library/Fizzy/Geocode/Adapter/Interface.php
new file mode 100644
index 0000000..11b6312
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Adapter/Interface.php
@@ -0,0 +1,6 @@
+<?php
+interface Fizzy_Geocode_Adapter_Interface
+{
+ public function location($query);
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Geocode/Exception.php b/application/library/Fizzy/Geocode/Exception.php
new file mode 100644
index 0000000..38a23dc
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Exception.php
@@ -0,0 +1,2 @@
+<?php
+class Fizzy_Geocode_Exception extends Fizzy_Exception {}
diff --git a/application/library/Fizzy/Geocode/Response.php b/application/library/Fizzy/Geocode/Response.php
new file mode 100644
index 0000000..57e6f5b
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Response.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Description of Response
+ *
+ * @author jeroen
+ */
+class Fizzy_Geocode_Response {
+
+ protected $_query = '';
+ protected $_locations = array();
+
+ public function __construct()
+ {
+
+ }
+
+ /**
+ * Returns the first location found
+ */
+ public function first()
+ {
+
+ }
+
+ /**
+ * Returns all locations found
+ */
+ public function all()
+ {
+
+ }
+
+ /**
+ * The number of locations found
+ */
+ public function count()
+ {
+
+ }
+
+
+}
diff --git a/application/library/Fizzy/Geocode/Response/Location.php b/application/library/Fizzy/Geocode/Response/Location.php
new file mode 100644
index 0000000..3c650de
--- /dev/null
+++ b/application/library/Fizzy/Geocode/Response/Location.php
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Description of Location
+ *
+ * @author jeroen
+ */
+class Fizzy_Geocode_Response_Location
+{
+ //put your code here
+}
|
jtietema/Fizzy
|
738fb8829aeeca88c662fd83168685ff9ba49c23
|
initial version of Fizzy_Json_Client
|
diff --git a/application/library/Fizzy/Json/Client.php b/application/library/Fizzy/Json/Client.php
new file mode 100644
index 0000000..7d3aa03
--- /dev/null
+++ b/application/library/Fizzy/Json/Client.php
@@ -0,0 +1,239 @@
+<?php
+require_once 'Zend/Json.php';
+require_once 'Zend/Http/Client.php';
+
+require_once 'Fizzy/Json/Client/Exception.php';
+require_once 'Fizzy/Json/Client/Response.php';
+
+/**
+ * This class makes talking to Zend_Json_Server (or other JSON-RPC servers) a
+ * breeze. It wraps the Zend_Http_Client en only exposes some convenience
+ * methods.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Json_Client
+{
+
+ /**
+ * The url of the Json server.
+ */
+ protected $_url = null;
+
+ /**
+ * The id is copied from the request to the response on the server and can
+ * be used to identify specific responses when you are handeling multiple
+ * to the same method.
+ * @var mixed
+ */
+ protected $_id = null;
+
+ /**
+ * The method to be called on the JSON-RPC server. Eg. 'hellworld'. When using
+ * namespaces the namespace is prepend with a dot on the end. E.g.
+ * 'helloworldnamespace.sayhello'
+ * @var string
+ */
+ protected $_method = null;
+
+ /**
+ * A list of parameters passed to the method.
+ * @var array
+ */
+ protected $_params = array();
+
+ /**
+ * Cached instance of Zend_Http_Client
+ * @var Zend_Http_Client|null
+ */
+ protected $_httpClient = null;
+
+ /**
+ * Array of strings with methodnames support by the __call magic method.
+ * This allows for a more native API feel.
+ * @var array
+ */
+ protected $_allowedMethods = array();
+
+ /**
+ * Returns the Url of the JSON-RPC server
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->_url;
+ }
+
+ /**
+ * Set the Url of the JSON-RPC server.
+ *
+ * @param string $url
+ * @return Fizzy_Json_Client
+ */
+ public function setUrl($url)
+ {
+ $this->_url = $url;
+ return $this;
+ }
+
+ /**
+ * Returns the Id give to the next method call.
+ * @return mixed
+ */
+ public function getId()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * Set the id for the next request to the JSON-RPC server. You can use this
+ * id to match request en response.
+ *
+ * @param mixed $id
+ * @return Fizzy_Json_Client
+ */
+ public function setId($id)
+ {
+ $this->_id = $id;
+ return $this;
+ }
+
+ /**
+ * Set the method to be called on the JSON-RPC server.
+ *
+ * @param string $method
+ * @return Fizzy_Json_Client
+ */
+ public function setMethod($method)
+ {
+ $this->_method = $method;
+ return $this;
+ }
+
+ /**
+ * Returns the parameters given to the method.
+ *
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->_params;
+ }
+
+ /**
+ * Sets the parameters to the method called on the JSON-RPC server. Make sure
+ * all the parameters are convertable to Json format.
+ *
+ * @param array $params
+ * @return Fizzy_Json_Client
+ */
+ public function setParams(Array $params)
+ {
+ $this->_params = $params;
+ return $this;
+ }
+
+ /**
+ * Returns the current http object.
+ *
+ * @return Zend_Http_Client|null
+ */
+ public function getHttpClient()
+ {
+ return $this->_httpClient;
+ }
+
+ /**
+ * Allows to set your own instance of the http client used for making requests
+ *
+ * @param Zend_Http_Client $httpClient
+ * @return Fizzy_Json_Client
+ */
+ public function setHttpClient(Zend_Http_Client $httpClient)
+ {
+ $this->_httpClient = $httpClient;
+ return $this;
+ }
+
+ /**
+ * Make the request to the JSON-RPC server.
+ *
+ * @return Fizzy_Json_Client_Response
+ */
+ public function request()
+ {
+ if ($this->_httpClient === null || !($this->_httpClient instanceof Zend_Http_Client)) {
+
+ if ($this->_url === null) {
+ throw new Fizzy_Json_Client_Exception('No Url set.');
+ }
+
+ if (empty($this->_method)) {
+ throw new Fizzy_Json_Client_Exception('No method set.');
+ }
+
+ $this->_httpClient = new Zend_Http_Client();
+ $this->_httpClient->setMethod(Zend_Http_Client::POST);
+
+ }
+
+ $this->_httpClient->setUri($this->_url);
+
+ $json = array(
+ 'id' => $this->_id,
+ 'method' => $this->_method,
+ 'params' => $this->_params
+ );
+
+ $this->_httpClient->setRawData(Zend_Json::encode($json));
+ $rawResponse = $this->_httpClient->request();
+
+ $response = new Fizzy_Json_Client_Response($rawResponse);
+ return $response;
+ }
+
+ /**
+ * All allowed methods for using with __call
+ *
+ * @return <type>
+ */
+ public function getAllowedMethods()
+ {
+ return $this->_allowedMethods;
+ }
+
+ /**
+ * Sets all allowed methods for use with __call. This allows you to call
+ * remote methods in a native like way.
+ *
+ * @param array $methods
+ */
+ public function setAllowedMethods(Array $methods)
+ {
+ $this->_allowedMethods = $methods;
+ }
+
+ /**
+ * Proxies all calls to the webserver when the methods are in allowedMethods array
+ *
+ * @param string $name
+ * @param array $args
+ * @return Fizzy_Json_Client_Response
+ */
+ public function __call($name, $args)
+ {
+ if (!in_array($name, $this->_allowedMethods)){
+ throw new Fizzy_Json_Client_Exception(
+ 'Method not supported. Did you set it with setAllowedMethods?'
+ );
+ }
+ $this->setMethod($name);
+ $this->setParams($args);
+ /**
+ * @todo Return the Response object or the result??
+ */
+ return $this->request();
+ }
+
+}
diff --git a/application/library/Fizzy/Json/Client/Exception.php b/application/library/Fizzy/Json/Client/Exception.php
new file mode 100644
index 0000000..d17bc01
--- /dev/null
+++ b/application/library/Fizzy/Json/Client/Exception.php
@@ -0,0 +1,5 @@
+<?php
+require_once 'Fizzy/Exception.php';
+
+class Fizzy_Json_Client_Exception extends Fizzy_Exception
+{}
diff --git a/application/library/Fizzy/Json/Client/Response.php b/application/library/Fizzy/Json/Client/Response.php
new file mode 100644
index 0000000..55b8e43
--- /dev/null
+++ b/application/library/Fizzy/Json/Client/Response.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * This class parses a Zend_Http_Response containing a JSON-RPC response.
+ *
+ * @author jeroen
+ * @todo Should this extend Zend_Json_Response ???
+ */
+class Fizzy_Json_Client_Response {
+
+ protected $_error = null;
+ protected $_id = null;
+ protected $_result = null;
+
+ public function __construct(Zend_Http_Response $response)
+ {
+ $body = $response->getRawBody();
+ $json = Zend_Json::decode($body);
+
+ $this->_id = $json['id'];
+
+ if (null !== $json['error']){
+ $this->_error = $json['error'];
+ } else {
+ $this->_result = $json['result'];
+ }
+ }
+
+ public function getId()
+ {
+ return $this->_id;
+ }
+
+ public function getResult()
+ {
+ return $this->_result;
+ }
+
+ public function getError()
+ {
+ return $this->_error;
+ }
+
+ public function isError()
+ {
+ return (null !== $this->_error);
+ }
+
+}
|
jtietema/Fizzy
|
4afe665abdfcd32e09d37e984883d55a75231e64
|
errorcontroller and dev.php index file
|
diff --git a/application/bootstrap.php b/application/bootstrap.php
index e359f53..ecfc526 100644
--- a/application/bootstrap.php
+++ b/application/bootstrap.php
@@ -1,31 +1,31 @@
<?php
/**
* Fizzy bootstrap file
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
# Set temporary include path
define('ROOT_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'));
set_include_path(realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library'));
$customConfig = implode(DIRECTORY_SEPARATOR, array(ROOT_PATH, 'configs', 'fizzy.ini'));
# Bootstrap Fizzy
require_once 'Fizzy.php';
$fizzy = Fizzy::getInstance();
$fizzy->addConfig($customConfig)
- ->setEnvironment('development');
+ ->setEnvironment(ENVIRONMENT);
$fizzy->bootstrap();
\ No newline at end of file
diff --git a/application/modules/default/controllers/ErrorController.php b/application/modules/default/controllers/ErrorController.php
new file mode 100644
index 0000000..dd8885d
--- /dev/null
+++ b/application/modules/default/controllers/ErrorController.php
@@ -0,0 +1,52 @@
+<?php
+
+class ErrorController extends Zend_Controller_Action
+{
+ public function errorAction()
+ {
+
+ $errors = $this->_getParam('error_handler');
+
+ switch ($errors->type) {
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+ // 404 error -- controller or action not found
+ $this->getResponse()
+ ->setRawHeader('HTTP/1.1 404 Not Found');
+
+ $this->renderScript('error/404.phtml');
+ break;
+ default:
+ // application error; display error page, but don't change
+ // status code
+ //
+ // Mail the exception:
+ $exception = $errors->exception;
+ $body = "Exception log \n"
+ . $exception->getMessage(). "\n"
+ . "in file " . $exception->getFile() . " op regel " . $exception->getLine() . "\n\n"
+ . "Stacktrace: \n"
+ . $exception->getTraceAsString() . "\n\n"
+ . "GET:\n";
+ foreach($_GET as $key => $value) {
+ $body .= $key . ': ' . $value ."\n";
+ }
+ $body .= "POST:\n";
+ foreach($_POST as $key => $value) {
+ $body .= $key . ': ' . $value ."\n";
+ }
+ $body .= "SERVER:\n";
+ foreach($_SERVER as $key => $value) {
+ $body .= $key . ': ' . $value ."\n";
+ }
+ mail("[email protected]", "Fizzy Exception", $body);
+
+ $this->getResponse()
+ ->setRawHeader('HTTP/1.1 500 Server error');
+
+ $this->renderScript('error/500.phtml');
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/application/modules/default/controllers/PagesController.php b/application/modules/default/controllers/PagesController.php
index 0069506..3b9ef82 100644
--- a/application/modules/default/controllers/PagesController.php
+++ b/application/modules/default/controllers/PagesController.php
@@ -1,35 +1,36 @@
<?php
/**
* Description of Pages
*
* @author mattijs
*/
class PagesController extends Fizzy_Controller
{
public function slugAction()
{
$slug = $this->_getParam('slug', null);
if(null === $slug) {
# Get default homepage
$query = Doctrine_Query::create()->from('Page')->where('homepage = ?', true);
$page = $query->fetchOne();
} else {
$query = Doctrine_Query::create()->from('Page')->where('slug = ?', $slug);
$page = $query->fetchOne();
}
- if($page === null) {
- # Log user exception viewable in the backend
+ if(!$page) {
+ $this->renderScript('error/404.phtml');
+ return;
}
$config = Zend_Registry::get('config');
$templatePath = $config->paths->templatePath;
$this->view->setScriptPath($templatePath);
$this->_helper->layout->setLayout($page->getLayout());
$this->view->page = $page;
$this->renderScript($page->getTemplate());
}
}
diff --git a/application/modules/default/views/scripts/error/404.phtml b/application/modules/default/views/scripts/error/404.phtml
new file mode 100644
index 0000000..8782cf7
--- /dev/null
+++ b/application/modules/default/views/scripts/error/404.phtml
@@ -0,0 +1,5 @@
+<h1>Page not found</h1>
+<p>
+ If you think this is an error, please report it on the contact page
+</p>
+
\ No newline at end of file
diff --git a/application/modules/default/views/scripts/error/500.phtml b/application/modules/default/views/scripts/error/500.phtml
new file mode 100644
index 0000000..a5222cb
--- /dev/null
+++ b/application/modules/default/views/scripts/error/500.phtml
@@ -0,0 +1,7 @@
+<h1>An error occured</h1>
+<p>
+ An email has been send to notify the GuidedByALocal.com crew.
+</p>
+<p>
+ Please be patient while we fix this.
+</p>
diff --git a/public/dev.php b/public/dev.php
new file mode 100644
index 0000000..6c243e4
--- /dev/null
+++ b/public/dev.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Fizzy public entry point
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+# Bootstrap Fizzy
+define('ENVIRONMENT', 'development');
+require_once '../application/bootstrap.php';
\ No newline at end of file
|
jtietema/Fizzy
|
69a26ad798d7f6165b0e0a4f91579ccce958f515
|
layouts and templates now work in the pages module
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index d4e5380..7e6c2f3 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -1,644 +1,643 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Fizzy application class. Takes care of gathering all configuration,
* bootstrapping and dispatching requests.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
'contact' => array(
'route' => '/contact',
'defaults' => array(
'controller' => 'contact',
'action' => 'index'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
),
'models' => 'application/models',
- 'templates' => array (
- 'fizzy' => 'application/templates',
- ),
+ 'templatePath' => 'application/modules/default/views/templates',
+ 'layoutPath' => 'application/modules/default/views/layouts',
'assets' => 'application/assets',
'configs' => 'configs',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::connection($this->_config->storage->dsn);
$manager->setAttribute('model_loading', 'conservative');
Doctrine::loadModels(ROOT_PATH . '/' .$this->_defaultConfig['paths']['models']);
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getFrontController();
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
diff --git a/application/models/Page.php b/application/models/Page.php
index 1b3cece..42a0a6a 100644
--- a/application/models/Page.php
+++ b/application/models/Page.php
@@ -1,56 +1,55 @@
<?php
require_once 'generated/BasePage.php';
/**
* Page
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class Page extends BasePage
{
public function getTemplate()
{
if(empty($this->template)) {
$application = Zend_Registry::get('config')->application->toArray();
$this->template = $application['defaultTemplate'];
}
return $this->template;
}
/**
* Override to return the default layout if none is set.
* @return string
*/
public function getLayout()
{
if(empty($this->layout)) {
$application = Zend_Registry::get('config')->application->toArray();
$this->layout = $application['defaultLayout'];
}
return $this->layout;
}
public function populate($array)
{
$this->title = $array['title'];
$this->slug = $array['slug'];
$this->body = $array['body'];
$this->homepage = (boolean) $array['homepage'];
if ('default' !== $array['template'])
$this->template = $array['template'];
- if ('default' !== $array['layout'])
- $this->layout = $array['layout'];
+ $this->layout = $array['layout'];
return $this;
}
}
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index b371df3..bd07386 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,178 +1,204 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$query = Doctrine_Query::create()->from('Page');
$pages = $query->fetchArray();
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page['id']), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null !== $page) {
$page->delete();
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
+ $config = Zend_Registry::get('config');
+
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $page['id'],
)
),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
- 'multiOptions' => array('default' => 'Default'),
+ 'multiOptions' => $this->_fetchFiles($config->paths->templatePath),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
- 'multiOptions' => array('default' => 'Default'),
+ 'multiOptions' => $this->_fetchFiles($config->paths->layoutPath, false),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
$form = new Fizzy_Form();
$form->setOptions($formConfig);
return $form;
}
+
+ /**
+ * Fetches a list of files from a given directory
+ *
+ * @param string $dir
+ * @return array
+ */
+ protected function _fetchFiles($dir, $keepExtension = true)
+ {
+ $files = array();
+ $dir = new DirectoryIterator($dir);
+ foreach ($dir as $file) {
+ if($file->isDot()) {
+ continue;
+ }
+ $pieces = explode('.', $file->getFilename());
+ if ($keepExtension) {
+ $files[$file->getFilename()] = $pieces[0];
+ } else {
+ $files[$pieces[0]] = $pieces[0];
+ }
+ }
+ return $files;
+ }
}
diff --git a/application/modules/default/controllers/PagesController.php b/application/modules/default/controllers/PagesController.php
index a0bec2d..0069506 100644
--- a/application/modules/default/controllers/PagesController.php
+++ b/application/modules/default/controllers/PagesController.php
@@ -1,35 +1,35 @@
<?php
/**
* Description of Pages
*
* @author mattijs
*/
class PagesController extends Fizzy_Controller
{
public function slugAction()
{
$slug = $this->_getParam('slug', null);
if(null === $slug) {
# Get default homepage
$query = Doctrine_Query::create()->from('Page')->where('homepage = ?', true);
$page = $query->fetchOne();
} else {
$query = Doctrine_Query::create()->from('Page')->where('slug = ?', $slug);
$page = $query->fetchOne();
}
if($page === null) {
# Log user exception viewable in the backend
}
$config = Zend_Registry::get('config');
- $templatePaths = $config->paths->templates->toArray();
- $this->view->setScriptPath($templatePaths);
+ $templatePath = $config->paths->templatePath;
+ $this->view->setScriptPath($templatePath);
$this->_helper->layout->setLayout($page->getLayout());
$this->view->page = $page;
$this->renderScript($page->getTemplate());
}
}
|
jtietema/Fizzy
|
92101795dc7e6c5fa7d87a2ee1e75d74e9031a04
|
Domain validator
|
diff --git a/application/library/Fizzy/Validate/Domain.php b/application/library/Fizzy/Validate/Domain.php
new file mode 100644
index 0000000..2e58ef9
--- /dev/null
+++ b/application/library/Fizzy/Validate/Domain.php
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Class Fizzy_Validate_Domain
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract.php */
+require_once 'Zend/Validate/Abstract.php';
+
+/** Zend_Uri_Http */
+require_once 'Zend/Uri/Http.php';
+
+/**
+ * Validates an URL to be a inside the Facebook domain.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_Domain extends Zend_Validate_Abstract
+{
+ const INVALID = 'invalidURI';
+ const OUTSIDE_DOMAIN = 'outsideDomain';
+
+ protected $_messageTemplates = array(
+ self::INVALID => "'%value%' is not a valid url",
+ self::OUTSIDE_DOMAIN => "'%value%' is not within domain '%domain%",
+ );
+
+ /**
+ * @var array
+ */
+ protected $_messageVariables = array(
+ 'domain' => '_domain'
+ );
+
+ /**
+ * The valid domain
+ * @var string
+ */
+ protected $_domain = '';
+
+ /**
+ * Wether to check the subdomain when validating the domain
+ * @var boolean
+ */
+ protected $_validateSubdomain = false;
+
+ /** **/
+
+ /**
+ * Validator constructor accepts a string or array with options. When a
+ * string is provided it is assumed this is the domain to validate against.
+ * When an array is provided the array is searched for the keys 'domain' and
+ * 'validateSubdomain'.
+ *
+ * @param string|array $options
+ */
+ public function __construct($options)
+ {
+ if (is_string($options)) {
+ $this->_domain = $options;
+ }
+ else if (is_array($options)) {
+
+ if(isset($options['domain'])) {
+ $this->_domain = $options['domain'];
+ }
+
+ if(isset($options['validateSubdomain'])) {
+ $this->_validateSubdomain = (boolean) $options['validateSubdomain'];
+ }
+ }
+
+ // Check if the domain is valid
+ preg_match("{(?:http://|https://)?([^/]*)(?:.*)?}i", $this->_domain, $domainMatches);
+ if (0 >= count($domainMatches)) {
+ throw new Zend_Validate_Exception("Domain '$this->_domain' is not valid.");
+ }
+
+ $this->_domain = array_pop($domainMatches);
+ }
+
+ /**
+ * Checks if a url is within the set domain and/or subdomain.
+ * @param string $value
+ * @return boolean
+ */
+ public function isValid($value)
+ {
+ $this->_setValue($value);
+
+ try {
+ $uri = Zend_Uri_Http::factory($value);
+ } catch(Zend_Uri_Exception $e) {
+ $this->_error(self::INVALID);
+ return false;
+ }
+
+ // Explode the base and subdomains for our valid and input domains
+ list($validBase, $validSub) = $this->_splitHost($this->_domain);
+ list($inputBase, $inputSub) = $this->_splitHost($uri->getHost());
+
+ if($validBase != $inputBase) {
+ $this->_error(self::OUTSIDE_DOMAIN);
+ return false;
+ }
+
+ // See if we need to validate the subdomain
+ if($this->_validateSubdomain) {
+ if($validSub != $inputSub) {
+ $this->_error(self::OUTSIDE_DOMAIN);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Splits the host into a base domain and subdomain. Returns an array where
+ * the first key is the base domain and the second key is the subdomain.
+ * @param string $host
+ * @return array
+ */
+ protected function _splitHost($host)
+ {
+ preg_match("{(?:http://|https://)?([^/]*)(?:.*)?}i", $host, $hostMatches);
+
+ $domainParts = explode('.', array_pop($hostMatches));
+ $baseDomain = implode('.', array_splice($domainParts, -2));
+ $subDomain = implode('.', $domainParts);
+
+ return array($baseDomain, $subDomain);
+ }
+
+}
|
jtietema/Fizzy
|
01cc6cecd98ed7002c416585e6dd7e6dfa2546b7
|
fixed wysiwyg form submission
|
diff --git a/application/assets/js/fizzy.js b/application/assets/js/fizzy.js
index 5b8482f..4c1b519 100644
--- a/application/assets/js/fizzy.js
+++ b/application/assets/js/fizzy.js
@@ -1,39 +1,39 @@
var Fizzy = function(){
var _editors = [];
return {
"wysiwyg" : {
"count" : function(){
return _editors.length;
},
"register" : function(id){
_editors.push(id);
},
"editors" : function(){
return _editors;
},
"init" : function() {
// init all the editors
var editors = fizzy.wysiwyg.editors().join(",");
tinyMCE.init({
mode : "exact",
elements: editors,
theme : "advanced",
plugins: "fizzymedia",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
- theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo,fizzymedia",
- theme_advanced_buttons2 : "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
+ theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
+ theme_advanced_buttons2 : "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,fizzymedia,separator,charmap,code,cleanup",
theme_advanced_buttons3: "",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
theme_advanced_resize_horizontal : false,
relative_urls : false
});
}
}
}
}
var fizzy = Fizzy();
window.onload = fizzy.wysiwyg.init;
diff --git a/application/library/Fizzy/View/Helper/Wysiwyg.php b/application/library/Fizzy/View/Helper/Wysiwyg.php
index bb0aec0..b85d64c 100644
--- a/application/library/Fizzy/View/Helper/Wysiwyg.php
+++ b/application/library/Fizzy/View/Helper/Wysiwyg.php
@@ -1,102 +1,89 @@
<?php
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a wysiwyg textarea element
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_View_Helper_Wysiwyg extends Zend_View_Helper_FormElement
{
/**
* The default number of rows for a textarea.
*
* @access public
*
* @var int
*/
public $rows = 24;
/**
* The default number of columns for a textarea.
*
* @access public
*
* @var int
*/
public $cols = 80;
- public $_tinyMceConfig = array (
- 'mode' => "exact",
- 'elements' => "body",
- 'theme' => "advanced",
- 'theme_advanced_toolbar_location' => "top",
- 'theme_advanced_toolbar_align' => "left",
- 'theme_advanced_buttons1' => "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
- 'theme_advanced_buttons2' => "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
- 'theme_advanced_buttons3' => "",
- 'theme_advanced_statusbar_location' => "bottom",
- 'theme_advanced_resizing' => true,
- 'theme_advanced_resize_horizontal' => false
- );
-
/**
* Generates a 'textarea' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @param boolean
*
* @return string The element XHTML.
*/
- public function wysiwyg($name, $value = null, $attribs = null, $enabled = true)
+ public function wysiwyg($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
- if (!$enabled) {
+ /*
+ if ($enabled) {
// disabled.
$disabled = ' disabled="disabled"';
- }
+ }*/
// Make sure that there are 'rows' and 'cols' values
// as required by the spec. noted by Orjan Persson.
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
// build the element
$xhtml = '<div class="wysiwyg">'
. '<div class="wysiwyg-editor">'
. '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>'
. '</div>'
. '<div class="wysiwyg-toggle"></div>'
. '<script type="text/javascript">'
- . 'fizzy.wysiwyg.register("body");'
+ . 'fizzy.wysiwyg.register("'.$this->view->escape($id).'");'
. '</script>'
. '</div>';
return $xhtml;
}
}
|
jtietema/Fizzy
|
65abc1893f868d296e94900dedde4accf99fd774
|
Imagepicker now supports margins
|
diff --git a/application/assets/css/fizzy.css b/application/assets/css/fizzy.css
index 65255b2..e925a84 100644
--- a/application/assets/css/fizzy.css
+++ b/application/assets/css/fizzy.css
@@ -1,412 +1,441 @@
@import 'screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
.error, .notice, .success, .info { padding: .8em; margin-bottom: 1em; border: 2px solid #ddd; }
.error { background: #FBE3E4; color: #8a1f11; border-color: #FBC2C4; }
.notice { background: #FFF6BF; color: #514721; border-color: #FFD324; }
.success { background: #E6EFC2; color: #264409; border-color: #C6D880; }
.info { background: #648ADC; color: #193D88; border-color: #1B51C2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
#messages {
min-height: 3.75em;
line-height: 2em;
margin: 1em 0 0 0;
}
#messages ul {
margin: 0 0 0 1em;
}
#messages .message {
margin: 0 0 1em 8px;
padding: 2px 0;
background-repeat: no-repeat;
background-position: 8px 6px;
position: relative;
}
.message-close {
position: absolute;
right: 10px;
top: 6px;
}
#messages .info {
background-image: url('../images/icon/sign_info.png');
}
#messages .success {
background-image: url('../images/icon/sign_tick.png');
}
#messages .warning {
background-image: url('../images/icon/sign_warning.png');
}
#messages .error {
background-image: url('../images/icon/sign_error.png');
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
display: block;
color: #555555;
font-weight: bold;
}
.form-container dt {
padding: 0.5em 0.5em 0 0.5em;
}
.form-container dd {
margin: 0;
padding: 0 .5em .5em .5em;
border-bottom: 1px #CCCCCC dotted;
}
.form-container p.hint {
margin-bottom: 0;
font-size: .8em;
}
.form-container #submit-label { display: none; }
.form-container #submit-element {
border: 0;
padding: 0.5em;
}
.form-container textarea {
width: 99%;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
height: 3.1em;
background: #2E3132 url('../images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
#content {
line-height: 1.7em;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Media Thumbnails view */
.files-container div.thumbnail {
float:left;
margin: 1em 0 0 1em;
padding: 5px 10px;
text-align: center;
border: solid 1px black;
background-color: white;
width: 140px;
height: 140px;
}
.files-container div.thumbnail img.thumbnail {
max-width: 120px;
max-height: 80px;
}
.files-container div.thumbnail img.icon {
margin: 32px 52px;
}
.files-container div.thumbnail div.controls {
text-align: right;
}
.files-menubar {
background: #2E3132 url('../images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
border-left: 1px #656565 solid;
}
.files-menubar ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
.files-menubar ul li {
float: left;
margin-right: 0;
position: relative;
}
.files-menubar ul li a {
display: block;
padding: 3px 8px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
.files-menubar ul li a:hover {
background: #424242;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
+
+/* Media Dialog (Image picker) */
+div.form-right, div.form-left {
+ width: 49%;
+ float:left;
+}
+input.small {
+ width: 50px;
+}
+div.form-right table {
+ width: 150px;
+}
+div.form-right table input {
+ width: 15px;
+}
+div.form-right table td {
+ width: 50px;
+ height: 50px;
+ text-align: center;
+}
+div.form-right table td.center {
+ border: solid 1px gray;
+ vertical-align: middle;
+ /*padding: 6px 0 0 6px;*/
+}
+#image-picker div.thumbnail{
+ width: 120px;
+ height: 120px;
+}
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
index 0743c83..f65d3cb 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
@@ -1,82 +1,82 @@
/**
* TinyMCE plugin for the Fizzy Media Library
*
* @author Jeroen Tietema <[email protected]>
* @copyright Copyright 2009, Voidwalkers, All rights reserved.
*/
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('fizzymedia');
tinymce.create('tinymce.plugins.FizzymediaPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('fizzyMedia', function() {
ed.windowManager.open({
//
file : url + '../../../../../../fizzy/media/gallery',
width : 640 + parseInt(ed.getLang('fizzymedia.delta_width', 0)),
height : 480 + parseInt(ed.getLang('fizzymedia.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('fizzymedia', {
title : 'fizzymedia.desc',
cmd : 'fizzyMedia',
- image : url + '/img/example.gif'
+ image : url + '/img/media.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('fizzymedia', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Fizzy Media plugin',
author : 'Jeroen Tietema',
authorurl : 'http://www.voidwalkers.nl',
infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('fizzymedia', tinymce.plugins.FizzymediaPlugin);
})();
\ No newline at end of file
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/img/flower.png b/application/assets/js/tiny_mce/plugins/fizzymedia/img/flower.png
new file mode 100644
index 0000000..a3a4259
Binary files /dev/null and b/application/assets/js/tiny_mce/plugins/fizzymedia/img/flower.png differ
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/img/media.gif b/application/assets/js/tiny_mce/plugins/fizzymedia/img/media.gif
new file mode 100644
index 0000000..f8e79bf
Binary files /dev/null and b/application/assets/js/tiny_mce/plugins/fizzymedia/img/media.gif differ
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
index c906e39..30f2141 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
@@ -1,101 +1,122 @@
tinyMCEPopup.requireLangPack();
var selectedImage = null;
var selectedElement = null;
function select(image, element){
selectedImage = image;
if (selectedElement != null){
selectedElement.style.background = '#ffffff';
}
selectedElement = element;
selectedElement.style.background = '#5555ff';
}
var FizzymediaDialog = {
init : function() {
var f = document.forms[0],
nl = f.elements,
ed = tinyMCEPopup.editor,
dom = ed.dom,
n = ed.selection.getNode();
/* check if there is an image selected. If so we edit that image
instead of inserting a new one */
if (n.nodeName == 'IMG'){
// set the image properties
- nl.width.value = dom.getAttrib(n, 'width');
- nl.height.value = dom.getAttrib(n, 'height');
- nl.alt.value = dom.getAttrib(n, 'alt');
- nl.border.value = dom.getAttrib(n, 'border');
-
+ nl.width.value = dom.getAttrib(n, 'width');
+ nl.height.value = dom.getAttrib(n, 'height');
+ nl.alt.value = dom.getAttrib(n, 'alt');
+ // we use parseInt to strip the px part
+ nl.border.value = parseInt(n.style.borderWidth);
+ nl.marginTop.value = parseInt(n.style.marginTop);
+ nl.marginRight.value = parseInt(n.style.marginRight);
+ nl.marginBottom.value = parseInt(n.style.marginBottom);
+ nl.marginLeft.value = parseInt(n.style.marginLeft);
+
// determine which style attribute is the position
var position = 'none';
if (n.style.cssFloat == 'left' || n.style.cssFloat == 'right'){
position = n.style.cssFloat;
} else if (n.style.verticalAlign != ''){
position = n.style.verticalAlign;
}
// select the current position in the dropdown box
var selectBox = nl.position.options;
for (i in selectBox){
if (selectBox[i].value == position){
selectBox.selectedIndex = i;
}
}
nl.insert.value = ed.getLang('update');
// select the image
var src = dom.getAttrib(n, 'src');
var image = document.getElementById(src);
select(src, image);
}
},
insert : function() {
if (selectedImage === null){
alert('Please select an Image!');
return;
}
// Insert the contents from the input into the document
- var width = document.getElementById('width').value;
- var height = document.getElementById('height').value;
- var border = document.getElementById('border').value;
+ var width = document.getElementById('width').value;
+ var height = document.getElementById('height').value;
+ var border = document.getElementById('border').value;
+ var marginTop = document.getElementById('marginTop').value;
+ var marginLeft = document.getElementById('marginLeft').value;
+ var marginBottom = document.getElementById('marginBottom').value;
+ var marginRight = document.getElementById('marginRight').value;
var description = document.getElementById('alt').value;
var position = document.getElementById('position').value;
var imageTag = new Image();
imageTag.src = selectedImage;
imageTag.alt = description;
if (width != ''){
imageTag.width = width;
}
if (height != ''){
imageTag.height = height;
}
if (position == 'left' || position == 'right'){
imageTag.style.cssFloat = position;
} else if (position !== 'none' && position !== ''){
imageTag.style.verticalAlign = position;
}
if (border !== ''){
imageTag.style.borderStyle = 'solid';
imageTag.style.borderColor = 'black';
imageTag.style.borderWidth = border + 'px';
}
+ if (marginTop !== ''){
+ imageTag.style.marginTop = marginTop + 'px';
+ }
+ if (marginRight !== ''){
+ imageTag.style.marginRight = marginRight + 'px';
+ }
+ if (marginBottom !== ''){
+ imageTag.style.marginBottom = marginBottom + 'px';
+ }
+ if (marginLeft !== ''){
+ imageTag.style.marginLeft = marginLeft + 'px';
+ }
// convert domnode to string
var div = document.createElement('div');
div.appendChild(imageTag);
var imageString = div.innerHTML;
tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageString);
tinyMCEPopup.close();
}
};
tinyMCEPopup.onInit.add(FizzymediaDialog.init, FizzymediaDialog);
diff --git a/application/modules/admin/views/scripts/media/gallery.phtml b/application/modules/admin/views/scripts/media/gallery.phtml
index fe2205c..1dfc0e5 100644
--- a/application/modules/admin/views/scripts/media/gallery.phtml
+++ b/application/modules/admin/views/scripts/media/gallery.phtml
@@ -1,65 +1,91 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#fizzymedia_dlg.title}</title>
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce_popup.js') ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js') ?>"></script>
</head>
<body>
-<div class="files-container">
+
+<div id="image-picker" class="files-container">
<?php foreach($this->files as $fileInfo) : ?>
<div class="thumbnail" id="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" onclick="select('<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>', this);">
<img class="thumbnail" src="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
<div class="filename">
<?php if (strlen($fileInfo->basename) > 14):?>
<?= substr($fileInfo->basename, 0, 14); ?>...
<?php else: ?>
<?= $fileInfo->basename ?>
<?php endif; ?>
</div>
<div class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<form onsubmit="FizzymediaDialog.insert();return false;" action="#">
<div>
-<label>Description:</label>
- <input type="text" name="alt" id="alt" />
-<label>Width</label>
- <input type="text" name="width" id="width" />
-<label>Height</label>
- <input type="text" name="height" id="height" />
-<label>Alignment</label>
- <select name="position" id="position">
- <option value="none">-- Not Set --</option>
- <option value="left">Left</option>
- <option value="right">Right</option>
- <option value="baseline">Baseline</option>
- <option value="top">Top</option>
- <option value="middle">Middle</option>
- <option value="bottom">Bottom</option>
- <option value="text-top">Text top</option>
- <option value="text-bottom">Text bottom</option>
- </select>
-<label>Border</label>
- <input type="text" name="border" id="border" />
+ <div class="form-left">
+ <label>Description:</label>
+ <input type="text" name="alt" id="alt" />
+ <label>Width</label>
+ <input type="text" name="width" id="width" class="small" /> px
+ <label>Height</label>
+ <input type="text" name="height" id="height" class="small" /> px
+ <label>Alignment</label>
+ <select name="position" id="position">
+ <option value="none">-- Not Set --</option>
+ <option value="left">Left</option>
+ <option value="right">Right</option>
+ <option value="baseline">Baseline</option>
+ <option value="top">Top</option>
+ <option value="middle">Middle</option>
+ <option value="bottom">Bottom</option>
+ <option value="text-top">Text top</option>
+ <option value="text-bottom">Text bottom</option>
+ </select>
+
+ <label>Border</label>
+ <input type="text" name="border" id="border" class="small" /> px
+ </div>
+ <div class="form-right">
+ <label>Margins</label>
+ <table>
+ <tr>
+ <td></td>
+ <td> <input type="text" name="marginTop" id="marginTop" /></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td><input type="text" name="marginLeft" id="marginLeft" /></td>
+ <td class="center"><img src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/plugins/fizzymedia/img/flower.png');?>" alt="flower" /></td>
+ <td><input type="text" name="marginRight" id="marginRight" /></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td> <input type="text" name="marginBottom" id="marginBottom" /></td>
+ <td></td>
+ </tr>
+ </table>
+ <p>You can specify the margins around the picture above.</p>
+ </div>
+
<div class="clear"></div>
<input type="button" name="insert" value="{#insert}" onclick="FizzymediaDialog.insert();" />
<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>
|
jtietema/Fizzy
|
9fa2557f859f21afac052e578fe252d26ded199b
|
Twitter account validator
|
diff --git a/application/library/Fizzy/Validate/TwitterAccount.php b/application/library/Fizzy/Validate/TwitterAccount.php
new file mode 100644
index 0000000..382503b
--- /dev/null
+++ b/application/library/Fizzy/Validate/TwitterAccount.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Class Fizzy_Validate_TwitterAccount
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/** Zend_Uri_Http */
+require_once 'Zend/Uri/Http.php';
+
+/** Zend_Http_Client */
+require_once 'Zend/Http/Client.php';
+
+/**
+ * Validate a Twitter account by a username. The account is checked by sending
+ * an HTTP request to the profile page and checking the statuscode.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Validate_TwitterAccount extends Zend_Validate_Abstract
+{
+ const BASEURI = 'http://twitter.com/';
+ const INVALID_ACCOUNT = 'invalidAccount';
+
+ protected $_messageTemplates = array(
+ self::INVALID_ACCOUNT => "'%value%' is not a valid Twitter account."
+ );
+
+ /**
+ * Checks if a username is a valid Twitter account by sending an HTTP
+ * request to the profile page.
+ * @param string $value
+ * @return <type>
+ */
+ public function isValid($value)
+ {
+ $this->_setValue((string) $value);
+
+ try {
+ $uri = Zend_Uri_Http::factory(self::BASEURI . $value);
+ } catch (Zend_Uri_Exception $e){
+ $this->_error(self::INVALID_ACCOUNT);
+ return false;
+ }
+
+ $httpClient = new Zend_Http_Client($uri);
+ $response = $httpClient->request();
+
+ if ($response->getStatus() != '200') {
+ $this->_error(self::INVALID_ACCOUNT);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/application/library/Fizzy/Validate/YoutubeVideo.php b/application/library/Fizzy/Validate/YoutubeVideo.php
index 57fe471..6bcc483 100644
--- a/application/library/Fizzy/Validate/YoutubeVideo.php
+++ b/application/library/Fizzy/Validate/YoutubeVideo.php
@@ -1,75 +1,105 @@
<?php
+/**
+ * Class Fizzy_Validate_YoutubeVideo
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/** Zend_Uri_Http */
+require_once 'Zend/Uri/Http.php';
+
+/** Zend_Http_Client */
+require_once 'Zend/Http/Client.php';
/**
- * validator for YouTube video's. Uses the status code of an HTTP request to
+ * Validator for YouTube video's. Uses the status code of an HTTP request to
* to the YouTube API to verify a video exists.
*
* API URI: http://gdata.youtube.com/feeds/api/videos/VIDEO_ID
*
* @author Jeroen Tietema <[email protected]>
*/
class Fizzy_Validate_YoutubeVideo extends Zend_Validate_Abstract
{
+
const API_URL = 'http://gdata.youtube.com/feeds/api/videos/';
const INVALID_URI = 'invalidUri';
const INVALID_VIDEO = 'notAVideo';
+ /**
+ * @see Zend_Validate_Abstract
+ */
protected $_messageTemplates = array(
self::INVALID_URI => "'%value%' is not a valid url",
self::INVALID_VIDEO => "'%value%' is not a valid Youtube video"
);
/**
* Checks if a YouTube video exists
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$value = (string) $value;
$this->_setValue($value);
try {
$uri = Zend_Uri_Http::factory($value);
} catch (Zend_Uri_Exception $e) {
$this->_error(self::INVALID_URI);
return false;
}
$query = $uri->getQueryAsArray();
if(!isset($query['v'])) {
$this->_error(self::INVALID_URI);
return false;
}
$valid = $this->_checkYoutubeApi($query['v']);
if(false === $valid) {
$this->_error(self::INVALID_VIDEO);
return false;
}
return true;
}
/**
* Does a request to the YouTube API.
* @param string|int $id
* @return boolean
*/
protected function _checkYoutubeApi($id)
{
try {
$uri = Zend_Uri_Http::factory(self::API_URL . $id);
} catch (Zend_Uri_Exception $e) {
return false;
}
$httpClient = new Zend_Http_Client($uri);
$response = $httpClient->request();
return ((boolean) $response->getStatus() == '200');
}
}
|
jtietema/Fizzy
|
7c613db9fe78d80c96302fb7f912236f7c3841bc
|
New Validators
|
diff --git a/application/library/Fizzy/Validate/EmailAddressSimple.php b/application/library/Fizzy/Validate/EmailAddressSimple.php
new file mode 100644
index 0000000..5399312
--- /dev/null
+++ b/application/library/Fizzy/Validate/EmailAddressSimple.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Class Fizzy_Validate_EmailAddressSimple
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Regex */
+require_once 'Zend/Validate/Regex.php';
+
+/**
+ * Validates an email address by a regular expression. Will only return a simple
+ * invalid message, not containing errors for TLD, domains, network addresses etc.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_EmailAddressSimple extends Zend_Validate_Regex
+{
+ /**
+ * @see Zend_ValidatE_Regex
+ */
+ protected $_pattern = '/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/i';
+
+ /**
+ * @see Zend_Validate_Abstract
+ * @var array
+ */
+ protected $_messageTemplates = array(
+ self::INVALID => "Invalid type given, value should be string, integer or float",
+ self::NOT_MATCH => "'%value%' is not a valid email address",
+ );
+
+ /**
+ * Overwrite the constructor to make the pattern parameter optional.
+ * @param string $pattern
+ */
+ public function __construct($pattern = null)
+ {
+ if (null !== $pattern) {
+ parent::__construct($pattern);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/Uri.php b/application/library/Fizzy/Validate/Uri.php
new file mode 100644
index 0000000..1651cbe
--- /dev/null
+++ b/application/library/Fizzy/Validate/Uri.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Class Fizzy_Validate_Uri
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/** Zend_Uri */
+require_once 'Zend/Uri.php';
+
+/**
+ * Validator to check URI's
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_Uri extends Zend_Validate_Abstract
+{
+
+ const INVALID_URI = 'invalidUri';
+
+ /**
+ * @see Zend_Validate_Abstract
+ */
+ protected $_messageTemplates = array(
+ self::INVALID_URI => "'%value%' is not a valid URI.",
+ );
+
+ /**
+ * Checks if a URI is valid
+ * @param string $value
+ * @return boolean
+ */
+ public function isValid($value)
+ {
+ $valueString = (string) $value;
+ $this->_setValue($valueString);
+
+ if (!Zend_Uri::check($value)) {
+ $this->_error(self::INVALID_URI);
+ return false;
+ }
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/YoutubeVideo.php b/application/library/Fizzy/Validate/YoutubeVideo.php
new file mode 100644
index 0000000..57fe471
--- /dev/null
+++ b/application/library/Fizzy/Validate/YoutubeVideo.php
@@ -0,0 +1,75 @@
+<?php
+
+
+/**
+ * validator for YouTube video's. Uses the status code of an HTTP request to
+ * to the YouTube API to verify a video exists.
+ *
+ * API URI: http://gdata.youtube.com/feeds/api/videos/VIDEO_ID
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Validate_YoutubeVideo extends Zend_Validate_Abstract
+{
+ const API_URL = 'http://gdata.youtube.com/feeds/api/videos/';
+ const INVALID_URI = 'invalidUri';
+ const INVALID_VIDEO = 'notAVideo';
+
+ protected $_messageTemplates = array(
+ self::INVALID_URI => "'%value%' is not a valid url",
+ self::INVALID_VIDEO => "'%value%' is not a valid Youtube video"
+ );
+
+ /**
+ * Checks if a YouTube video exists
+ * @param string $value
+ * @return boolean
+ */
+ public function isValid($value)
+ {
+ $value = (string) $value;
+ $this->_setValue($value);
+
+ try {
+ $uri = Zend_Uri_Http::factory($value);
+ } catch (Zend_Uri_Exception $e) {
+ $this->_error(self::INVALID_URI);
+ return false;
+ }
+
+ $query = $uri->getQueryAsArray();
+ if(!isset($query['v'])) {
+ $this->_error(self::INVALID_URI);
+ return false;
+ }
+
+ $valid = $this->_checkYoutubeApi($query['v']);
+ if(false === $valid) {
+ $this->_error(self::INVALID_VIDEO);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Does a request to the YouTube API.
+ * @param string|int $id
+ * @return boolean
+ */
+ protected function _checkYoutubeApi($id)
+ {
+ try {
+ $uri = Zend_Uri_Http::factory(self::API_URL . $id);
+ } catch (Zend_Uri_Exception $e) {
+ return false;
+ }
+
+ $httpClient = new Zend_Http_Client($uri);
+ $response = $httpClient->request();
+
+ return ((boolean) $response->getStatus() == '200');
+ }
+
+
+}
|
jtietema/Fizzy
|
66e664ca146fa221a071fe2a179284e94a0fa846
|
position dropdown in image picker now works
|
diff --git a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
index 4782a6e..c906e39 100644
--- a/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
+++ b/application/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
@@ -1,67 +1,101 @@
tinyMCEPopup.requireLangPack();
var selectedImage = null;
var selectedElement = null;
function select(image, element){
selectedImage = image;
if (selectedElement != null){
selectedElement.style.background = '#ffffff';
}
selectedElement = element;
selectedElement.style.background = '#5555ff';
}
var FizzymediaDialog = {
- init : function(ed) {
+ init : function() {
var f = document.forms[0],
nl = f.elements,
ed = tinyMCEPopup.editor,
dom = ed.dom,
n = ed.selection.getNode();
-
+
/* check if there is an image selected. If so we edit that image
instead of inserting a new one */
if (n.nodeName == 'IMG'){
// set the image properties
nl.width.value = dom.getAttrib(n, 'width');
nl.height.value = dom.getAttrib(n, 'height');
nl.alt.value = dom.getAttrib(n, 'alt');
- nl.insert.value = ed.getLang('update');
+ nl.border.value = dom.getAttrib(n, 'border');
+
+ // determine which style attribute is the position
+ var position = 'none';
+ if (n.style.cssFloat == 'left' || n.style.cssFloat == 'right'){
+ position = n.style.cssFloat;
+ } else if (n.style.verticalAlign != ''){
+ position = n.style.verticalAlign;
+ }
+ // select the current position in the dropdown box
+ var selectBox = nl.position.options;
+ for (i in selectBox){
+ if (selectBox[i].value == position){
+ selectBox.selectedIndex = i;
+ }
+ }
+
+ nl.insert.value = ed.getLang('update');
+
// select the image
var src = dom.getAttrib(n, 'src');
var image = document.getElementById(src);
select(src, image);
}
},
insert : function() {
if (selectedImage === null){
alert('Please select an Image!');
return;
}
// Insert the contents from the input into the document
var width = document.getElementById('width').value;
var height = document.getElementById('height').value;
- //var border = document.getElementById('border').value;
+ var border = document.getElementById('border').value;
var description = document.getElementById('alt').value;
- var imageTag = '<img src="' + selectedImage + '" alt="' + description + '" ';
+ var position = document.getElementById('position').value;
+
+ var imageTag = new Image();
+ imageTag.src = selectedImage;
+ imageTag.alt = description;
+
if (width != ''){
- imageTag += 'width="' + width +'" ';
+ imageTag.width = width;
}
if (height != ''){
- imageTag += 'height="' + height + '" ';
+ imageTag.height = height;
+ }
+ if (position == 'left' || position == 'right'){
+ imageTag.style.cssFloat = position;
+ } else if (position !== 'none' && position !== ''){
+ imageTag.style.verticalAlign = position;
}
- /*
- if (border != ''){
- imageTag += 'style="border: solid ' + border + 'px black;" ';
- }*/
- imageTag += '/>';
- tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageTag);
+ if (border !== ''){
+ imageTag.style.borderStyle = 'solid';
+ imageTag.style.borderColor = 'black';
+ imageTag.style.borderWidth = border + 'px';
+ }
+
+ // convert domnode to string
+ var div = document.createElement('div');
+ div.appendChild(imageTag);
+ var imageString = div.innerHTML;
+
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageString);
tinyMCEPopup.close();
}
};
tinyMCEPopup.onInit.add(FizzymediaDialog.init, FizzymediaDialog);
diff --git a/application/library/Fizzy/View/Helper/Wysiwyg.php b/application/library/Fizzy/View/Helper/Wysiwyg.php
index d22280f..bb0aec0 100644
--- a/application/library/Fizzy/View/Helper/Wysiwyg.php
+++ b/application/library/Fizzy/View/Helper/Wysiwyg.php
@@ -1,100 +1,102 @@
<?php
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a wysiwyg textarea element
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_View_Helper_Wysiwyg extends Zend_View_Helper_FormElement
{
/**
* The default number of rows for a textarea.
*
* @access public
*
* @var int
*/
public $rows = 24;
/**
* The default number of columns for a textarea.
*
* @access public
*
* @var int
*/
public $cols = 80;
public $_tinyMceConfig = array (
'mode' => "exact",
'elements' => "body",
'theme' => "advanced",
'theme_advanced_toolbar_location' => "top",
'theme_advanced_toolbar_align' => "left",
'theme_advanced_buttons1' => "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
'theme_advanced_buttons2' => "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
'theme_advanced_buttons3' => "",
'theme_advanced_statusbar_location' => "bottom",
'theme_advanced_resizing' => true,
'theme_advanced_resize_horizontal' => false
);
/**
* Generates a 'textarea' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
+ * @param boolean
+ *
* @return string The element XHTML.
*/
public function wysiwyg($name, $value = null, $attribs = null, $enabled = true)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
- if ($disable) {
+ if (!$enabled) {
// disabled.
$disabled = ' disabled="disabled"';
}
// Make sure that there are 'rows' and 'cols' values
// as required by the spec. noted by Orjan Persson.
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
// build the element
$xhtml = '<div class="wysiwyg">'
. '<div class="wysiwyg-editor">'
. '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>'
. '</div>'
. '<div class="wysiwyg-toggle"></div>'
. '<script type="text/javascript">'
. 'fizzy.wysiwyg.register("body");'
. '</script>'
. '</div>';
return $xhtml;
}
}
diff --git a/application/modules/admin/controllers/MediaController.php b/application/modules/admin/controllers/MediaController.php
index df07330..c7a274b 100644
--- a/application/modules/admin/controllers/MediaController.php
+++ b/application/modules/admin/controllers/MediaController.php
@@ -1,172 +1,175 @@
<?php
/**
* Description of Media
*
* @author mattijs
*/
class Admin_MediaController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
/**
* @todo implement overwrite checkbox
*/
public function indexAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
$form = $this->_getForm($uploadFolder);
if($this->_request->isPost()) {
if($form->isValid($_POST) && $form->file->receive()) {
$this->addSuccessMessage('File was successfully uploaded.');
}
else {
foreach($form->getErrorMessages() as $message) {
$this->addErrorMessage($message);
}
}
$this->_redirect('/fizzy/media');
}
# Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
# Render the view
$this->view->uploadFolder = $uploadFolder;
$this->view->files = $files;
$this->view->form = $form;
$this->view->type = $this->_request->getParam('type', 'list');
$this->renderScript('media.phtml');
}
public function displayAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
$type = $this->_getParam('type', 'list');
if($type == 'thumbnail') {
$script = 'media/thumbnails.phtml';
} else {
$script = 'media/list.phtml';
}
$this->renderScript($script);
}
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = ROOT_PATH . '/public/uploads/';
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
$this->addSuccessMessage('File was successfully deleted.');
}
}
$this->_redirect($this->view->baseUrl('/fizzy/media'));
}
/**
* Returns the form for file uploads
* @param string $uploadFolder
* @return Zend_Form
*/
protected function _getForm($uploadFolder)
{
$formConfig = array (
'action' => $this->view->baseUrl('/fizzy/media'),
'enctype' => 'multipart/form-data',
'elements' => array(
'file' => array (
'type' => 'file',
'options' => array (
'label' => 'File',
'description' => 'Choose a file to upload. The maximun file size is ' . str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), ini_get('upload_max_filesize')) . '.',
'required' => true,
'destination' => $uploadFolder,
)
),
/*'overwrite' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Overwrite existing?',
'description' => 'If this is checked any existing file with the same name will be overridden.',
'required' => false,
)
),*/
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Upload',
'ignore' => true,
)
)
),
);
return new Zend_Form(new Zend_Config($formConfig));
}
-
+
+ /**
+ * Action for the image picker popup
+ */
public function galleryAction()
{
$uploadFolder = ROOT_PATH . '/public/uploads/';
// Parse all files in the upload directory
$files = array();
$imageTypes = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
if (in_array($fileInfo['type'], $imageTypes)) {
$files[] = (object) $fileInfo;
}
}
}
// Render the view
$this->view->files = $files;
$this->_helper->layout->disableLayout();
}
}
diff --git a/application/modules/admin/views/scripts/media/gallery.phtml b/application/modules/admin/views/scripts/media/gallery.phtml
index ae6bda5..fe2205c 100644
--- a/application/modules/admin/views/scripts/media/gallery.phtml
+++ b/application/modules/admin/views/scripts/media/gallery.phtml
@@ -1,55 +1,65 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#fizzymedia_dlg.title}</title>
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce_popup.js') ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js') ?>"></script>
</head>
<body>
<div class="files-container">
<?php foreach($this->files as $fileInfo) : ?>
<div class="thumbnail" id="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" onclick="select('<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>', this);">
<img class="thumbnail" src="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
<div class="filename">
<?php if (strlen($fileInfo->basename) > 14):?>
<?= substr($fileInfo->basename, 0, 14); ?>...
<?php else: ?>
<?= $fileInfo->basename ?>
<?php endif; ?>
</div>
<div class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<form onsubmit="FizzymediaDialog.insert();return false;" action="#">
<div>
<label>Description:</label>
<input type="text" name="alt" id="alt" />
<label>Width</label>
<input type="text" name="width" id="width" />
<label>Height</label>
<input type="text" name="height" id="height" />
-<!--
+<label>Alignment</label>
+ <select name="position" id="position">
+ <option value="none">-- Not Set --</option>
+ <option value="left">Left</option>
+ <option value="right">Right</option>
+ <option value="baseline">Baseline</option>
+ <option value="top">Top</option>
+ <option value="middle">Middle</option>
+ <option value="bottom">Bottom</option>
+ <option value="text-top">Text top</option>
+ <option value="text-bottom">Text bottom</option>
+ </select>
<label>Border</label>
<input type="text" name="border" id="border" />
--->
<div class="clear"></div>
<input type="button" name="insert" value="{#insert}" onclick="FizzymediaDialog.insert();" />
<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>
diff --git a/application/templates/page.phtml b/application/modules/default/views/templates/page.phtml
similarity index 100%
rename from application/templates/page.phtml
rename to application/modules/default/views/templates/page.phtml
|
jtietema/Fizzy
|
80fb2dc9b857e5cbc18602aa63276be0751f7f84
|
Fizzy Filters
|
diff --git a/application/library/Fizzy/Filter/Slugify.php b/application/library/Fizzy/Filter/Slugify.php
index 34bd554..535495d 100644
--- a/application/library/Fizzy/Filter/Slugify.php
+++ b/application/library/Fizzy/Filter/Slugify.php
@@ -1,44 +1,44 @@
<?php
/**
* Class Fizzy_Filter_Slugify
* @category Fizzy
* @package Fizzy_Filter
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
- * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Filter_Interface */
require_once 'Zend/Filter/Interface.php';
/**
* Filter to change a value to a slugified version. This replaces all non
* letters and digits by a '-'.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Filter_Slugify implements Zend_Filter_Interface
{
/**
* Filters the value and returns a slugified version.
* @param string $value
*/
public function filter($value)
{
# Replace all non letters or digits by -
$value = preg_replace('/\W+/', '-', $value);
$value = strtolower(trim($value, '-'));
return $value;
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Filter/StripSpaces.php b/application/library/Fizzy/Filter/StripSpaces.php
new file mode 100644
index 0000000..bdfb73e
--- /dev/null
+++ b/application/library/Fizzy/Filter/StripSpaces.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Class Fizzy_Filter_StripSpaces
+ * @category Fizzy
+ * @package Fizzy_Filter
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Filter_PregReplace */
+require_once 'Zend/Filter/PregReplace.php';
+
+/**
+ * Filter to strip all spaces from a string.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Filter_StripSpaces extends Zend_Filter_PregReplace
+{
+ /**
+ * @see Zend_Filter_PregReplace
+ */
+ protected $_matchPattern = '(\s*)';
+
+ /**
+ * @see Zend_Filter_PregReplace
+ */
+ protected $_replacement = '';
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Filter/YoutubeId.php b/application/library/Fizzy/Filter/YoutubeId.php
new file mode 100644
index 0000000..61a1985
--- /dev/null
+++ b/application/library/Fizzy/Filter/YoutubeId.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Class Fizzy_Filter_YoutubeId
+ * @category Fizzy
+ * @package Fizzy_Filter
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009-2010 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Filter_Interface */
+require_once 'Zend/Filter/Interface.php';
+
+/** Zend_Uri_Http */
+require_once 'Zend/Uri/Http.php';
+
+/**
+ * Filters the id for a YouTube video from a HTTP URI.
+ *
+ * @author Jeroen Tietema <[email protected]>
+ */
+class Fizzy_Filter_YoutubeId implements Zend_Filter_Interface
+{
+ /**
+ * Filters the YouTube video id from a URL and returns the id. Return an
+ * empty string on an invalid URL.
+ * @param string $value
+ * @return string
+ */
+ public function filter($value)
+ {
+ try {
+ $uri = Zend_Uri_Http::factory($value);
+ if($uri->valid()) {
+ $query = $uri->getQueryAsArray();
+ if (isset($query['v'])) {
+ return $query['v'];
+ } else {
+ return '';
+ }
+ }
+ else {
+ return '';
+ }
+ } catch (Zend_Uri_Exception $e) {
+ return '';
+ }
+ }
+}
|
jtietema/Fizzy
|
ad2cfab820e60ba230312ac9631153adad6ebda2
|
Image rotate
|
diff --git a/application/library/Fizzy/Image.php b/application/library/Fizzy/Image.php
index 090c264..552d1f3 100644
--- a/application/library/Fizzy/Image.php
+++ b/application/library/Fizzy/Image.php
@@ -1,281 +1,283 @@
<?php
/**
* Class Fizzy_Image
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* This represents an image that can be manipulated. It uses a backend to
* perform the manipulations and save them to a file.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Image
{
/**
* The adapter to use for image transformations.
* @var Fizzy_Image_Adapter_Abstract
*/
protected $_adapter = null;
/** **/
/**
* Constructor
* @param Fizzy_Image_Adapter_Interface|string $adapter
* @param string $source
*/
public function __construct($adapter, $source = null)
{
$this->setAdapter($adapter);
if(null !== $source) {
$this->load($source);
}
}
/**
* Sets the adapter for image manipulation.
* @param Fizzy_Image_Adapter_Interface|string $adapter
* @return Fizzy_Image
*/
public function setAdapter($adapter)
{
if($adapter instanceof Fizzy_Image_Adapter_Interface) {
$this->_adapter = $adapter;
}
else if(is_string($adapter)) {
$adapter = trim($adapter);
// Just create the class, autoloading will take care of the existence
$this->_adapter = new $adapter;
}
else {
throw new Fizzy_Image_Exception('Adapter must be a string or an instance of Fizzy_Image_Adapter_Interface.');
}
return $this;
}
/**
* Returns the adapeter for image manipulation. Checks the if an adapter is
* set and if it implements Fizzy_Image_Adapter_Interface.
* @throws Fizzy_Image_Exception
* @return Fizzy_Image_Adapter_Interface
*/
public function getAdapter()
{
if(null === $this->_adapter) {
throw new Fizzy_Image_Exception('No adapter was set.');
}
if(!($this->_adapter instanceof Fizzy_Image_Adapter_Interface)) {
throw new Fizzy_Image_Exception('Adapter ' . get_class($this->_adapter) . ' does not implement Fizzy_Image_Adapter_Interface.');
}
return $this->_adapter;
}
/**
* Returns the width of the image.
* @return int
*/
public function getWidth()
{
return $this->_adapter->getImageWidth();
}
/**
* Returns the height of the image.
* @return int
*/
public function getHeight()
{
return $this->_adapter->getImageHeight();
}
/**
* Returns a copy of the image object.
* @return Fizzy_Image
*/
public function getCopy()
{
$adapter = $this->_getAdapterClone();
return new self($adapter);
}
/**
* Load an image source.
* @param string $source
* @return Fizzy_Image
* @todo Add checks to see if the image file exists.
*/
public function load($source)
{
$this->getAdapter()->load($source);
return $this;
}
/**
* Save the image to a destination.
* @param string $destination
*/
public function save($destination)
{
if(empty($destination)) {
throw new Fizzy_Image_Exception('Save path cannot be empty.');
}
$this->getAdapter()->save($destination);
return $this;
}
/**
* Outputs the image data to the browser.
* @return mixed
*/
public function output()
{
throw new Fizzy_Image_Exception('Not implemented');
}
/**
* Resize the image
* @param int $width
* @param int $height
* @return Fizzy_Image
*/
public function resize($width, $height)
{
$adapter = $this->_getAdapterClone();
$adapter->resize($width, $height);
$image = new self($adapter);
return $image;
}
/**
* Resize the image to a maximum width maintaining the heights aspect ratio.
* @param int $width
* @return Fizzy_Image
*/
public function resizeMaxWidth($width)
{
$heightRatio = $this->getHeight() / $this->getWidth();
$height = round($width * $heightRatio);
return $this->resize((int) $width, (int) $height);
}
/**
* Resize the image to a maximum height maintaining the widths aspect ratio.
* @param int $height
* @return Fizzy_Image
*/
public function resizeMaxHeight($height)
{
$widthRatio = $this->getWidth() / $this->getHeight();
$width = round($height * $widthRatio);
return $this->resize((int) $width, (int) $height);
}
/**
* Crop the image
* @param int $startx
* @param int $starty
* @param int $width
* @param int $height
* @return Fizzy_Image
*/
public function crop($startx, $starty, $width, $height)
{
$adapter = $this->_getAdapterClone();
$adapter->crop($startx, $starty, $width, $height);
$image = new self($adapter);
return $image;
}
/**
* Crops the image to an area around the center of the image.
* @param int $width
* @param int $height
*/
public function cropCentered($width, $height)
{
$centerX = round($this->getWidth() / 2);
$centerY = round($this->getHeight() / 2);
$startX = $centerX - round($width / 2);
$startY = $centerY - round($height / 2);
return $this->crop($startX, $startY, $width, $height);
}
/**
* Returns a clone of the adapter.
* @return Fizzy_Image_Adapter_Interface
*/
protected function _getAdapterClone()
{
return clone $this->_adapter;
}
/**
* Scales the image to precentage of the original.
* @param string $percent
* @return Fizzy_Image
*/
public function scale($percent)
{
throw new Fizzy_Image_Exception('Not implemented');
}
/**
* Rotates the image given degree in given direction.
* Direction can be:
* <ul>
* <li>right</li>
* <li>left</li>
* <li>cw (clockwise)</li>
* <li>ccw (counter clockwise)</li>
* </ul>
* @param int $degree
* @param string $direction
* @return Fizzy_Image
*/
- public function rotate($degree, $direction)
+ public function rotate($degree, $direction = 'cw')
{
throw new Fizzy_Image_Exception('Not implemented');
}
/**
* Flips the image around the horizontal axis.
* @return Fizzy_Image
*/
- public function flipHorizontal()
+ public function flip()
{
- throw new Fizzy_Image_Exception('Not implemented');
+ $adapter = $this->_getAdapterClone();
+ $adapter->rotate(180);
+ return new self($adapter);
}
/**
- * Flips the image around the vertical axis.
+ * Mirrors the image around the vertical axis.
* @return Fizzy_Image
*/
- public function flipVertical()
+ public function mirror()
{
throw new Fizzy_Image_Exception('Not implemented');
}
}
diff --git a/application/library/Fizzy/Image/Adapter/GD.php b/application/library/Fizzy/Image/Adapter/GD.php
index 2a2df98..95bbf40 100644
--- a/application/library/Fizzy/Image/Adapter/GD.php
+++ b/application/library/Fizzy/Image/Adapter/GD.php
@@ -1,219 +1,241 @@
<?php
/**
* Class Fizzy_Image_Adapter_GD
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Fizzy_Image adapter using the GD library for image manipulation.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Image_Adapter_GD extends Fizzy_Image_Adapter_Abstract
{
/**
* The image resource the adapter works on
* @var Resource
*/
protected $_image = null;
/** **/
/**
* @see Fizzy_Image_Adapter_Interface
* @return Fizzy_Image_Adapter_Abstract
*/
public function load($sourcePath)
{
if(!is_file($sourcePath)) {
throw new Fizzy_Image_Exception("Path {$sourcePath} is not a file.");
}
else if(!is_readable($sourcePath)) {
throw new Fizzy_Image_Exception("File {$sourcePath} could not be read,");
}
$imageData = file_get_contents($sourcePath);
$this->_image = imagecreatefromstring($imageData);
return $this;
}
/**
* @see Fizzy_Image_Adapter_Interface
* @return boolean
*/
public function save($destination)
{
$destinationInfo = pathinfo($destination);
$function = 'image' . $destinationInfo['extension'];
if(!function_exists($function)) {
throw new Fizzy_Image_Exception('Cannot create image of type ' . $extension);
}
$success = $function($this->_image, $destination);
return $success;
}
/**
* @see Fizzy_Image_Adapter_Interface
* @return Fizzy_Image_Adapter_Abstract
*/
public function resize($width, $height)
{
// Get the original image
$originalImage = $this->_image;
// Create a canvas for the resize image
$targetImage = $this->_createCanvasFromImage($originalImage, $width, $height);
imagefill($targetImage, 0, 0, imagecolorallocate($targetImage, 255, 255, 255));
// Resize the image
imagecopyresampled($targetImage, $originalImage, 0, 0, 0, 0, $width, $height, imagesx($originalImage), imagesy($originalImage));
// Replace the original image with the resized image
$this->_image = $targetImage;
// Destroy the original canvas
imagedestroy($originalImage);
return $this;
}
/**
* @see Fizzy_Image_Adapter_Interface
* @return Fizzy_Image_Adapter_Adapter
*/
public function crop($sourcex, $sourcey, $width, $height)
{
$originalImage = $this->_image;
$targetImage = imagecreatetruecolor($width, $height);
imagefill($targetImage, 0, 0, imagecolorallocate($targetImage, 255, 255, 255));
imagecopyresampled($targetImage, $originalImage, 0, 0, $sourcex, $sourcey, $width, $height, $width, $height);
$this->_image = $targetImage;
imagedestroy($originalImage);
return $this;
}
+ /**
+ * Rotates the image by given degree.
+ * @param int $degree
+ * @param Resource $backgroundColor
+ * @return Fizzy_Image_Adapter_GD
+ */
+ public function rotate($degree, $backgroundColor = null)
+ {
+ if (!is_numeric($degree)) {
+ throw new Fizzy_Image_Exception("{$degree} is not a valid number.");
+ }
+ if (null === $backgroundColor) {
+ $backgroundColor = 0;
+ }
+
+ $originalImage = $this->_image;
+ $this->_image = imagerotate($originalImage, $degree, $backgroundColor);
+ imagedestroy($originalImage);
+
+ return $this;
+ }
+
/**
* @see Fizzy_Image_Adapter_Interface
* @return int
*/
public function getImageWidth()
{
return imagesx($this->_image);
}
/**
* @see Fizzy_Image_Adapter_Interface
* @return int
*/
public function getImageHeight()
{
return imagesy($this->_image);
}
/**
* Set the raw image resource.
* @param Resource $image
* @return Fizzy_Image_Adapter_GD
*/
public function setRawImage($image)
{
$this->_image = $image;
return $this;
}
/**
* Returns the raw image resource.
* @return Resource
*/
public function getRawImage()
{
return $this->_image;
}
/**
* Creates a canvas from an existing image transfering all properties to the
* new resource. This optionally takes a width and height paramter for the
* new canvas.
* This will not copy the image data to the new canvas.
* @param Resource $image
* @param int $width
* @param int $height
* @param Resource $background
* @return Resource
*/
protected function _createCanvasFromImage($image, $width = null, $height = null, $background = null)
{
if(null === $width) {
$width = imagesx($image);
}
if(null === $height) {
$height = imagesy($image);
}
$canvas = null;
if(imageistruecolor($image)) {
$canvas = imagecreatetruecolor($width, $height);
$transparentColorIndex = imagecolortransparent($image);
if($transparentColorIndex >= 0) {
imagecolortransparent($canvas, imagecolorsforindex($image, $transparentColorIndex));
}
imagealphablending($canvas, false);
imagesavealpha($canvas, true);
} else {
$canvas = imagecreate($width, $height);
}
if(null !== $background) {
imagefill($canvas, 0, 0, $background);
}
return $canvas;
}
/**
* Copy the image resource data to a new image resource.
* @param Resource $image
* @return Resource
*/
protected function _copyImage($image)
{
if(null === $this->_image) {
throw new Fizzy_Image_Exception('Cannot copy the contents of an empty image resource.');
}
// Turn the contents of the image resource into a string
ob_start();
imagegd2($this->_image);
$imageData = ob_get_clean();
// Create a new image resource from the data string
$imageCopy = imagecreatefromstring($imageData);
return $imageCopy;
}
public function __clone()
{
$this->_image = $this->_copyImage($this->_image);
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Sizer.php b/application/library/Fizzy/Image/Sizer.php
index b2bc331..2620480 100644
--- a/application/library/Fizzy/Image/Sizer.php
+++ b/application/library/Fizzy/Image/Sizer.php
@@ -1,157 +1,204 @@
<?php
/**
* Class Fizzy_Image_Sizer
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Class for creating multiple sizes of an image.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Image_Sizer
{
/**
* Original image object.
* @var Fizzy_Image
*/
protected $_image = null;
/**
* Target path where resized images will be stored.
* @var string
*/
protected $_targetPath = '';
/**
* Type of the resized images.
* @var string
*/
protected $_imageType = 'png';
/**
* Name template for resized images.
* @var string
*/
- protected $_nameTemplate = 'resized-%width%x%height%.%type%';
+ protected $_nameTemplate = 'resized-%time%-%width%x%height%.%type%';
+
+ /**
+ * Time the creation process is started.
+ * @var string
+ */
+ protected $_time = null;
/** **/
/**
* Constructor.
* @param Fizzy_Image $image
*/
public function __construct(Fizzy_Image $image)
{
$this->setImage($image);
}
/**
* Set the base image.
* @param Fizzy_Image $image
* @return Fizzy_Image_Sizer
*/
public function setImage(Fizzy_Image $image)
{
$this->_image = $image;
return $this;
}
/**
* Set the type for the resized images.
* @param string $type
* @return Fizzy_ImagE_Sizer
*/
public function setImageType($type)
{
$this->_imageType = $type;
return $this;
}
+ /**
+ * Set the name template for the resized images. Parameters that can be
+ * used in the template are:
+ * <ul>
+ * <li>%time% - the time the image is generated</li>
+ * <li>%width% - the width of the resized image</li>
+ * <li>%height% - the height of the resized image</li>
+ * <li>%type% - the extension that is used for generating</li>
+ * </ul>
+ * @param string $template
+ * @return Fizzy_Image_Sizer
+ */
public function setNameTemplate($template)
{
$this->_nameTemplate = $template;
return $this;
}
+ /**
+ * Set the target path where the resized images should be saved.
+ * @param string $path
+ * @return Fizzy_Image_Sizer
+ */
public function setTargetPath($path)
{
$realpath = realpath($path);
if(false === $realpath) {
throw new Exception("Path '{$realpath}' could not be found.");
}
$this->_targetPath = $realpath;
return $this;
}
+ /**
+ * Creates one or more sizes of the original, based on the parameters, and
+ * saves them to the target path.
+ * @param array $sizes
+ */
public function createSizes(array $sizes)
{
$image = $this->_image;
+ $this->_time = time();
foreach($sizes as $size) {
list($width, $height) = $this->_getDimensions($size);
$this->_createResize($image, intval($width), intval($height));
}
}
+ /**
+ * Returns a dimensions array. When a string is passed in an array will be
+ * created with the value as the width and height parameter. The same goes
+ * for an array with only one value.
+ * If the array contains two values they are checked.
+ * @param array|string $dimensions
+ * @return array
+ */
protected function _getDimensions($dimensions)
{
if (is_array($dimensions)) {
+ list($width, $height) = $dimensions;
+ if(!is_numeric($width)) {
+ throw new Exception("Value {$width} is not a valid height dimension.");
+ }
+ if(!isset($height) || null === $height) {
+ $height = $width;
+ } else if(!is_numeric($height)) {
+ throw new Exception("Value {$height} is not a valid height dimension.");
+ }
-
+ $dimensions = array(intval($width), intval($height));
}
else if (is_string($dimensions)) {
$size = intval($dimensions);
if(!is_numeric($size)) {
throw new Exception("Value {$size} is not a valid dimension.");
}
$dimensions = array($size, $size);
}
return $dimensions;
}
/**
*
* @param Fizzy_Image $image
* @param int $width
* @param int $height
*/
protected function _createResize(Fizzy_Image $image, $width, $height)
{
if($image->getWidth() > $image->getHeight()) {
$image = $image->resizeMaxHeight((int) $height);
}
else {
$image = $image->resizeMaxWidth((int) $width);
}
// Crop to the center area of the image
$image = $image->cropCentered($width, $height);
$filename = $this->_nameTemplate;
+ $filename = str_replace('%time%', $this->_time, $filename);
$filename = str_replace('%width%', $width, $filename);
$filename = str_replace('%height%', $height, $filename);
$filename = str_replace('%type%', $this->_imageType, $filename);
$image->save($this->_targetPath . DIRECTORY_SEPARATOR . $filename);
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
01e16280ab391881bd9b11435449a040da29b557
|
Fizzy_Image
|
diff --git a/application/library/Fizzy/Image.php b/application/library/Fizzy/Image.php
new file mode 100644
index 0000000..090c264
--- /dev/null
+++ b/application/library/Fizzy/Image.php
@@ -0,0 +1,281 @@
+<?php
+/**
+ * Class Fizzy_Image
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * This represents an image that can be manipulated. It uses a backend to
+ * perform the manipulations and save them to a file.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Image
+{
+ /**
+ * The adapter to use for image transformations.
+ * @var Fizzy_Image_Adapter_Abstract
+ */
+ protected $_adapter = null;
+
+ /** **/
+
+ /**
+ * Constructor
+ * @param Fizzy_Image_Adapter_Interface|string $adapter
+ * @param string $source
+ */
+ public function __construct($adapter, $source = null)
+ {
+ $this->setAdapter($adapter);
+
+ if(null !== $source) {
+ $this->load($source);
+ }
+ }
+
+ /**
+ * Sets the adapter for image manipulation.
+ * @param Fizzy_Image_Adapter_Interface|string $adapter
+ * @return Fizzy_Image
+ */
+ public function setAdapter($adapter)
+ {
+ if($adapter instanceof Fizzy_Image_Adapter_Interface) {
+ $this->_adapter = $adapter;
+ }
+ else if(is_string($adapter)) {
+ $adapter = trim($adapter);
+ // Just create the class, autoloading will take care of the existence
+ $this->_adapter = new $adapter;
+ }
+ else {
+ throw new Fizzy_Image_Exception('Adapter must be a string or an instance of Fizzy_Image_Adapter_Interface.');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the adapeter for image manipulation. Checks the if an adapter is
+ * set and if it implements Fizzy_Image_Adapter_Interface.
+ * @throws Fizzy_Image_Exception
+ * @return Fizzy_Image_Adapter_Interface
+ */
+ public function getAdapter()
+ {
+ if(null === $this->_adapter) {
+ throw new Fizzy_Image_Exception('No adapter was set.');
+ }
+ if(!($this->_adapter instanceof Fizzy_Image_Adapter_Interface)) {
+ throw new Fizzy_Image_Exception('Adapter ' . get_class($this->_adapter) . ' does not implement Fizzy_Image_Adapter_Interface.');
+ }
+
+ return $this->_adapter;
+ }
+
+ /**
+ * Returns the width of the image.
+ * @return int
+ */
+ public function getWidth()
+ {
+ return $this->_adapter->getImageWidth();
+ }
+
+ /**
+ * Returns the height of the image.
+ * @return int
+ */
+ public function getHeight()
+ {
+ return $this->_adapter->getImageHeight();
+ }
+
+ /**
+ * Returns a copy of the image object.
+ * @return Fizzy_Image
+ */
+ public function getCopy()
+ {
+ $adapter = $this->_getAdapterClone();
+ return new self($adapter);
+ }
+
+ /**
+ * Load an image source.
+ * @param string $source
+ * @return Fizzy_Image
+ * @todo Add checks to see if the image file exists.
+ */
+ public function load($source)
+ {
+ $this->getAdapter()->load($source);
+
+ return $this;
+ }
+
+ /**
+ * Save the image to a destination.
+ * @param string $destination
+ */
+ public function save($destination)
+ {
+ if(empty($destination)) {
+ throw new Fizzy_Image_Exception('Save path cannot be empty.');
+ }
+
+ $this->getAdapter()->save($destination);
+ return $this;
+ }
+
+ /**
+ * Outputs the image data to the browser.
+ * @return mixed
+ */
+ public function output()
+ {
+ throw new Fizzy_Image_Exception('Not implemented');
+ }
+
+ /**
+ * Resize the image
+ * @param int $width
+ * @param int $height
+ * @return Fizzy_Image
+ */
+ public function resize($width, $height)
+ {
+ $adapter = $this->_getAdapterClone();
+ $adapter->resize($width, $height);
+ $image = new self($adapter);
+
+ return $image;
+ }
+
+ /**
+ * Resize the image to a maximum width maintaining the heights aspect ratio.
+ * @param int $width
+ * @return Fizzy_Image
+ */
+ public function resizeMaxWidth($width)
+ {
+ $heightRatio = $this->getHeight() / $this->getWidth();
+ $height = round($width * $heightRatio);
+ return $this->resize((int) $width, (int) $height);
+ }
+
+ /**
+ * Resize the image to a maximum height maintaining the widths aspect ratio.
+ * @param int $height
+ * @return Fizzy_Image
+ */
+ public function resizeMaxHeight($height)
+ {
+ $widthRatio = $this->getWidth() / $this->getHeight();
+ $width = round($height * $widthRatio);
+ return $this->resize((int) $width, (int) $height);
+ }
+
+ /**
+ * Crop the image
+ * @param int $startx
+ * @param int $starty
+ * @param int $width
+ * @param int $height
+ * @return Fizzy_Image
+ */
+ public function crop($startx, $starty, $width, $height)
+ {
+ $adapter = $this->_getAdapterClone();
+ $adapter->crop($startx, $starty, $width, $height);
+ $image = new self($adapter);
+
+ return $image;
+ }
+
+ /**
+ * Crops the image to an area around the center of the image.
+ * @param int $width
+ * @param int $height
+ */
+ public function cropCentered($width, $height)
+ {
+ $centerX = round($this->getWidth() / 2);
+ $centerY = round($this->getHeight() / 2);
+
+ $startX = $centerX - round($width / 2);
+ $startY = $centerY - round($height / 2);
+
+ return $this->crop($startX, $startY, $width, $height);
+ }
+
+ /**
+ * Returns a clone of the adapter.
+ * @return Fizzy_Image_Adapter_Interface
+ */
+ protected function _getAdapterClone()
+ {
+ return clone $this->_adapter;
+ }
+
+ /**
+ * Scales the image to precentage of the original.
+ * @param string $percent
+ * @return Fizzy_Image
+ */
+ public function scale($percent)
+ {
+ throw new Fizzy_Image_Exception('Not implemented');
+ }
+
+ /**
+ * Rotates the image given degree in given direction.
+ * Direction can be:
+ * <ul>
+ * <li>right</li>
+ * <li>left</li>
+ * <li>cw (clockwise)</li>
+ * <li>ccw (counter clockwise)</li>
+ * </ul>
+ * @param int $degree
+ * @param string $direction
+ * @return Fizzy_Image
+ */
+ public function rotate($degree, $direction)
+ {
+ throw new Fizzy_Image_Exception('Not implemented');
+ }
+
+ /**
+ * Flips the image around the horizontal axis.
+ * @return Fizzy_Image
+ */
+ public function flipHorizontal()
+ {
+ throw new Fizzy_Image_Exception('Not implemented');
+ }
+
+ /**
+ * Flips the image around the vertical axis.
+ * @return Fizzy_Image
+ */
+ public function flipVertical()
+ {
+ throw new Fizzy_Image_Exception('Not implemented');
+ }
+
+}
diff --git a/application/library/Fizzy/Image/Adapter/Abstract.php b/application/library/Fizzy/Image/Adapter/Abstract.php
new file mode 100644
index 0000000..fdcb42c
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/Abstract.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Class Fizzy_Image_Adapter_Abstract
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Abstract class with base functionality for Fizzy_Image adapters.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+abstract class Fizzy_Image_Adapter_Abstract implements Fizzy_Image_Adapter_Interface
+{
+ /**
+ * Image extensions supported by the adapter.
+ * @var array
+ */
+ protected $_supportedExtensions = array();
+
+ /** **/
+
+ /**
+ * Returns the extensions that are supported by the adapter.
+ * @return string
+ */
+ public function getSupportedExtensions()
+ {
+ return $this->_supportedExtensions;
+ }
+
+ /**
+ * Checks if an extension is supported by the adapter
+ * @param string $extension
+ * @return boolean
+ */
+ public function isSupportedExtension($extension)
+ {
+ return (boolean) in_array(strtolower($extension), $this->_supportedExtensions);
+ }
+
+ /**
+ * Sets the extenions supported by the adapter.
+ * @param array $extensions
+ * @return Fizzy_Image_Adapter_Abstract
+ */
+ public function setSupportedExtensions(array $extensions)
+ {
+ $this->_supportedExtensions = $extensions;
+ return $this;
+ }
+
+ /**
+ * Returns the extension for a file path
+ * @param string $path
+ * @return string
+ */
+ public function _getExtension($path)
+ {
+ if(false === strrpos($path, '.')) {
+ return '';
+ }
+
+ return substr($path, strrpos($path, '.') + 1);
+ }
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Adapter/Cairo.php b/application/library/Fizzy/Image/Adapter/Cairo.php
new file mode 100644
index 0000000..bc5a5a8
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/Cairo.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Class Fizzy_Image_Adapter_Cairo
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Fizzy_Image adapter for Cairo.
+ */
+class Fizzy_Image_Adapter_Cairo extends Fizzy_Image_Adapter_Abstract
+{
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Adapter/GD.php b/application/library/Fizzy/Image/Adapter/GD.php
new file mode 100644
index 0000000..2a2df98
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/GD.php
@@ -0,0 +1,219 @@
+<?php
+/**
+ * Class Fizzy_Image_Adapter_GD
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Fizzy_Image adapter using the GD library for image manipulation.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Image_Adapter_GD extends Fizzy_Image_Adapter_Abstract
+{
+ /**
+ * The image resource the adapter works on
+ * @var Resource
+ */
+ protected $_image = null;
+
+ /** **/
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return Fizzy_Image_Adapter_Abstract
+ */
+ public function load($sourcePath)
+ {
+ if(!is_file($sourcePath)) {
+ throw new Fizzy_Image_Exception("Path {$sourcePath} is not a file.");
+ }
+ else if(!is_readable($sourcePath)) {
+ throw new Fizzy_Image_Exception("File {$sourcePath} could not be read,");
+ }
+
+ $imageData = file_get_contents($sourcePath);
+ $this->_image = imagecreatefromstring($imageData);
+
+ return $this;
+ }
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return boolean
+ */
+ public function save($destination)
+ {
+ $destinationInfo = pathinfo($destination);
+ $function = 'image' . $destinationInfo['extension'];
+ if(!function_exists($function)) {
+ throw new Fizzy_Image_Exception('Cannot create image of type ' . $extension);
+ }
+
+ $success = $function($this->_image, $destination);
+
+ return $success;
+ }
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return Fizzy_Image_Adapter_Abstract
+ */
+ public function resize($width, $height)
+ {
+ // Get the original image
+ $originalImage = $this->_image;
+ // Create a canvas for the resize image
+ $targetImage = $this->_createCanvasFromImage($originalImage, $width, $height);
+ imagefill($targetImage, 0, 0, imagecolorallocate($targetImage, 255, 255, 255));
+ // Resize the image
+ imagecopyresampled($targetImage, $originalImage, 0, 0, 0, 0, $width, $height, imagesx($originalImage), imagesy($originalImage));
+ // Replace the original image with the resized image
+ $this->_image = $targetImage;
+ // Destroy the original canvas
+ imagedestroy($originalImage);
+
+ return $this;
+ }
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return Fizzy_Image_Adapter_Adapter
+ */
+ public function crop($sourcex, $sourcey, $width, $height)
+ {
+ $originalImage = $this->_image;
+
+ $targetImage = imagecreatetruecolor($width, $height);
+ imagefill($targetImage, 0, 0, imagecolorallocate($targetImage, 255, 255, 255));
+
+ imagecopyresampled($targetImage, $originalImage, 0, 0, $sourcex, $sourcey, $width, $height, $width, $height);
+
+ $this->_image = $targetImage;
+
+ imagedestroy($originalImage);
+
+ return $this;
+ }
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return int
+ */
+ public function getImageWidth()
+ {
+ return imagesx($this->_image);
+ }
+
+ /**
+ * @see Fizzy_Image_Adapter_Interface
+ * @return int
+ */
+ public function getImageHeight()
+ {
+ return imagesy($this->_image);
+ }
+
+ /**
+ * Set the raw image resource.
+ * @param Resource $image
+ * @return Fizzy_Image_Adapter_GD
+ */
+ public function setRawImage($image)
+ {
+ $this->_image = $image;
+ return $this;
+ }
+
+ /**
+ * Returns the raw image resource.
+ * @return Resource
+ */
+ public function getRawImage()
+ {
+ return $this->_image;
+ }
+
+
+
+ /**
+ * Creates a canvas from an existing image transfering all properties to the
+ * new resource. This optionally takes a width and height paramter for the
+ * new canvas.
+ * This will not copy the image data to the new canvas.
+ * @param Resource $image
+ * @param int $width
+ * @param int $height
+ * @param Resource $background
+ * @return Resource
+ */
+ protected function _createCanvasFromImage($image, $width = null, $height = null, $background = null)
+ {
+ if(null === $width) {
+ $width = imagesx($image);
+ }
+ if(null === $height) {
+ $height = imagesy($image);
+ }
+
+ $canvas = null;
+ if(imageistruecolor($image)) {
+ $canvas = imagecreatetruecolor($width, $height);
+ $transparentColorIndex = imagecolortransparent($image);
+ if($transparentColorIndex >= 0) {
+ imagecolortransparent($canvas, imagecolorsforindex($image, $transparentColorIndex));
+ }
+ imagealphablending($canvas, false);
+ imagesavealpha($canvas, true);
+ } else {
+ $canvas = imagecreate($width, $height);
+ }
+
+ if(null !== $background) {
+ imagefill($canvas, 0, 0, $background);
+ }
+
+ return $canvas;
+ }
+
+ /**
+ * Copy the image resource data to a new image resource.
+ * @param Resource $image
+ * @return Resource
+ */
+ protected function _copyImage($image)
+ {
+ if(null === $this->_image) {
+ throw new Fizzy_Image_Exception('Cannot copy the contents of an empty image resource.');
+ }
+
+ // Turn the contents of the image resource into a string
+ ob_start();
+ imagegd2($this->_image);
+ $imageData = ob_get_clean();
+
+ // Create a new image resource from the data string
+ $imageCopy = imagecreatefromstring($imageData);
+
+ return $imageCopy;
+ }
+
+ public function __clone()
+ {
+ $this->_image = $this->_copyImage($this->_image);
+ }
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Adapter/Gmagick.php b/application/library/Fizzy/Image/Adapter/Gmagick.php
new file mode 100644
index 0000000..6b5634b
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/Gmagick.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Class Fizzy_Image_Adapter_Gmagick
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Fizzy_Image adapter for Gmagick.
+ */
+class Fizzy_Image_Adapter_Gmagick extends Fizzy_Image_Adapter_Abstract
+{
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Adapter/ImageMagick.php b/application/library/Fizzy/Image/Adapter/ImageMagick.php
new file mode 100644
index 0000000..7303edd
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/ImageMagick.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Class Fizzy_Image_Adapter_ImageMagick
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Fizzy_Image adapter for ImageMagick.
+ */
+class FIzzy_Image_Adapter_ImageMagick extends Fizzy_Image_Adapter_Abstract
+{
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Adapter/Interface.php b/application/library/Fizzy/Image/Adapter/Interface.php
new file mode 100644
index 0000000..644c84c
--- /dev/null
+++ b/application/library/Fizzy/Image/Adapter/Interface.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Interface Fizzy_Image_Adapter_Interface
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Interface for Fizzy_Image adapters.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+interface Fizzy_Image_Adapter_Interface
+{
+
+ /**
+ * Load image data from a source path.
+ * @param <type> $sourcePath
+ */
+ public function load($sourcePath);
+
+ /**
+ * Save the image data to file (destination).
+ * @param string $destination
+ */
+ public function save($destination);
+
+ /**
+ * Resize the image
+ * @param int $width
+ * @param int $height
+ */
+ public function resize($width, $height);
+
+ /**
+ * Crop the image.
+ * @param int $startx
+ * @param int $starty
+ * @param int $width
+ * @param int $height
+ */
+ public function crop($startx, $starty, $width, $height);
+
+ /**
+ * Returns the image width.
+ * @return int
+ */
+ public function getImageWidth();
+
+ /**
+ * Returns the image height.
+ * @return int
+ */
+ public function getImageHeight();
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Exception.php b/application/library/Fizzy/Image/Exception.php
new file mode 100644
index 0000000..0f899e3
--- /dev/null
+++ b/application/library/Fizzy/Image/Exception.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Class Fizzy_Image_Exception
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Exception for Fizzy_Image package
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Image_Exception extends Fizzy_Exception
+{}
\ No newline at end of file
diff --git a/application/library/Fizzy/Image/Sizer.php b/application/library/Fizzy/Image/Sizer.php
new file mode 100644
index 0000000..b2bc331
--- /dev/null
+++ b/application/library/Fizzy/Image/Sizer.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * Class Fizzy_Image_Sizer
+ * @package Fizzy
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/**
+ * Class for creating multiple sizes of an image.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Image_Sizer
+{
+
+ /**
+ * Original image object.
+ * @var Fizzy_Image
+ */
+ protected $_image = null;
+
+ /**
+ * Target path where resized images will be stored.
+ * @var string
+ */
+ protected $_targetPath = '';
+
+ /**
+ * Type of the resized images.
+ * @var string
+ */
+ protected $_imageType = 'png';
+
+ /**
+ * Name template for resized images.
+ * @var string
+ */
+ protected $_nameTemplate = 'resized-%width%x%height%.%type%';
+
+ /** **/
+
+ /**
+ * Constructor.
+ * @param Fizzy_Image $image
+ */
+ public function __construct(Fizzy_Image $image)
+ {
+ $this->setImage($image);
+ }
+
+ /**
+ * Set the base image.
+ * @param Fizzy_Image $image
+ * @return Fizzy_Image_Sizer
+ */
+ public function setImage(Fizzy_Image $image)
+ {
+ $this->_image = $image;
+ return $this;
+ }
+
+ /**
+ * Set the type for the resized images.
+ * @param string $type
+ * @return Fizzy_ImagE_Sizer
+ */
+ public function setImageType($type)
+ {
+ $this->_imageType = $type;
+
+ return $this;
+ }
+
+ public function setNameTemplate($template)
+ {
+ $this->_nameTemplate = $template;
+
+ return $this;
+ }
+
+ public function setTargetPath($path)
+ {
+ $realpath = realpath($path);
+ if(false === $realpath) {
+ throw new Exception("Path '{$realpath}' could not be found.");
+ }
+
+ $this->_targetPath = $realpath;
+
+ return $this;
+ }
+
+ public function createSizes(array $sizes)
+ {
+ $image = $this->_image;
+ foreach($sizes as $size) {
+ list($width, $height) = $this->_getDimensions($size);
+ $this->_createResize($image, intval($width), intval($height));
+ }
+ }
+
+ protected function _getDimensions($dimensions)
+ {
+ if (is_array($dimensions)) {
+
+
+ }
+ else if (is_string($dimensions)) {
+ $size = intval($dimensions);
+ if(!is_numeric($size)) {
+ throw new Exception("Value {$size} is not a valid dimension.");
+ }
+ $dimensions = array($size, $size);
+ }
+
+ return $dimensions;
+ }
+
+ /**
+ *
+ * @param Fizzy_Image $image
+ * @param int $width
+ * @param int $height
+ */
+ protected function _createResize(Fizzy_Image $image, $width, $height)
+ {
+
+ if($image->getWidth() > $image->getHeight()) {
+ $image = $image->resizeMaxHeight((int) $height);
+ }
+ else {
+ $image = $image->resizeMaxWidth((int) $width);
+ }
+ // Crop to the center area of the image
+ $image = $image->cropCentered($width, $height);
+
+ $filename = $this->_nameTemplate;
+ $filename = str_replace('%width%', $width, $filename);
+ $filename = str_replace('%height%', $height, $filename);
+ $filename = str_replace('%type%', $this->_imageType, $filename);
+
+ $image->save($this->_targetPath . DIRECTORY_SEPARATOR . $filename);
+ }
+
+}
\ No newline at end of file
|
jtietema/Fizzy
|
9f09d3fc6f1e7018e25f2914f680b1df323932b3
|
removed the upload folder setting
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index cbc2ea2..d4e5380 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -1,645 +1,644 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Fizzy application class. Takes care of gathering all configuration,
* bootstrapping and dispatching requests.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
'contact' => array(
'route' => '/contact',
'defaults' => array(
'controller' => 'contact',
'action' => 'index'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
),
'models' => 'application/models',
'templates' => array (
'fizzy' => 'application/templates',
),
'assets' => 'application/assets',
'configs' => 'configs',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
- 'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::connection($this->_config->storage->dsn);
$manager->setAttribute('model_loading', 'conservative');
Doctrine::loadModels(ROOT_PATH . '/' .$this->_defaultConfig['paths']['models']);
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getFrontController();
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
diff --git a/application/modules/admin/controllers/MediaController.php b/application/modules/admin/controllers/MediaController.php
index feecbbc..df07330 100644
--- a/application/modules/admin/controllers/MediaController.php
+++ b/application/modules/admin/controllers/MediaController.php
@@ -1,172 +1,172 @@
<?php
/**
* Description of Media
*
* @author mattijs
*/
class Admin_MediaController extends Fizzy_SecuredController
{
protected $_sessionNamespace = 'fizzy';
protected $_redirect = '/fizzy/login';
-
+
/**
* @todo implement overwrite checkbox
*/
public function indexAction()
{
- $uploadFolder = Fizzy::getInstance()->getPath('uploads');
+ $uploadFolder = ROOT_PATH . '/public/uploads/';
$form = $this->_getForm($uploadFolder);
if($this->_request->isPost()) {
if($form->isValid($_POST) && $form->file->receive()) {
$this->addSuccessMessage('File was successfully uploaded.');
}
else {
foreach($form->getErrorMessages() as $message) {
$this->addErrorMessage($message);
}
}
$this->_redirect('/fizzy/media');
}
# Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
# Render the view
$this->view->uploadFolder = $uploadFolder;
$this->view->files = $files;
$this->view->form = $form;
$this->view->type = $this->_request->getParam('type', 'list');
$this->renderScript('media.phtml');
}
public function displayAction()
{
- $uploadFolder = Fizzy::getInstance()->getPath('uploads');
+ $uploadFolder = ROOT_PATH . '/public/uploads/';
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
$type = $this->_getParam('type', 'list');
if($type == 'thumbnail') {
$script = 'media/thumbnails.phtml';
} else {
$script = 'media/list.phtml';
}
$this->renderScript($script);
}
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
- $uploadFolder = Fizzy::getInstance()->getPath('uploads');
+ $uploadFolder = ROOT_PATH . '/public/uploads/';
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
$this->addSuccessMessage('File was successfully deleted.');
}
}
$this->_redirect($this->view->baseUrl('/fizzy/media'));
}
/**
* Returns the form for file uploads
* @param string $uploadFolder
* @return Zend_Form
*/
protected function _getForm($uploadFolder)
{
$formConfig = array (
'action' => $this->view->baseUrl('/fizzy/media'),
'enctype' => 'multipart/form-data',
'elements' => array(
'file' => array (
'type' => 'file',
'options' => array (
'label' => 'File',
'description' => 'Choose a file to upload. The maximun file size is ' . str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), ini_get('upload_max_filesize')) . '.',
'required' => true,
'destination' => $uploadFolder,
)
),
/*'overwrite' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Overwrite existing?',
'description' => 'If this is checked any existing file with the same name will be overridden.',
'required' => false,
)
),*/
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Upload',
'ignore' => true,
)
)
),
);
return new Zend_Form(new Zend_Config($formConfig));
}
public function galleryAction()
{
- $uploadFolder = Fizzy::getInstance()->getPath('uploads');
+ $uploadFolder = ROOT_PATH . '/public/uploads/';
// Parse all files in the upload directory
$files = array();
$imageTypes = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
if (in_array($fileInfo['type'], $imageTypes)) {
$files[] = (object) $fileInfo;
}
}
}
// Render the view
$this->view->files = $files;
$this->_helper->layout->disableLayout();
}
}
|
jtietema/Fizzy
|
fa8c097f92cad73b3e32eeac8c92f2a458c81c37
|
auth namespace support in securedcontroller
|
diff --git a/application/library/Fizzy/SecuredController.php b/application/library/Fizzy/SecuredController.php
index 3767378..b4a60c9 100644
--- a/application/library/Fizzy/SecuredController.php
+++ b/application/library/Fizzy/SecuredController.php
@@ -1,53 +1,69 @@
<?php
/**
* Class Fizzy_SecuredController
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Controller */
require_once 'Fizzy/Controller.php';
class Fizzy_SecuredController extends Fizzy_Controller
{
/**
* Identity object for the autheticated user.
* @var mixed
*/
protected $_identity = null;
+ /**
+ * The session namespace used for the security credentials
+ * @var string
+ */
+ protected $_sessionNamespace = null;
+
+ /**
+ * Url to redirect to when not logged in
+ * @var string
+ */
+ protected $_redirect = null;
/** **/
/**
* Check for authentication identity
*/
public function preDispatch()
{
- if (!Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/fizzy/login', array('prependBase' => true));
+ if ($this->_sessionNamespace === null || $this->_redirect === null) {
+ throw new Fizzy_Exception('Please provide a $_sessionNamespace and $_redirect in your Fizzy_SecuredController subclass.');
+ }
+ $auth = Zend_Auth::getInstance();
+ $auth->setStorage(new Zend_Auth_Storage_Session($this->_sessionNamespace));
+ if (!$auth->hasIdentity()) {
+ $this->_redirect($this->_redirect, array('prependBase' => true));
}
$this->_identity = Zend_Auth::getInstance()->getIdentity();
}
/**
* Returns the identity for the authenticated user.
* @return mixed
*/
public function getIdentity()
{
return $this->_identity;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
index be40bfc..c154b52 100644
--- a/application/modules/admin/controllers/AuthController.php
+++ b/application/modules/admin/controllers/AuthController.php
@@ -1,69 +1,73 @@
<?php
class Admin_AuthController extends Fizzy_Controller
{
public function loginAction()
{
$form = $this->_getForm();
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$authAdapter = new Fizzy_Doctrine_AuthAdapter(
$form->username->getValue(), $form->password->getValue()
);
- $result = Zend_Auth::getInstance()->authenticate($authAdapter);
+ $auth = Zend_Auth::getInstance();
+ $auth->setStorage(new Zend_Auth_Storage_Session('fizzy'));
+ $result = $auth->authenticate($authAdapter);
if($result->isValid()) {
$this->_redirect('/fizzy', array('prependBase' => true));
}
$messages = $result->getMessages();
$this->addErrorMessage(array_shift($messages));
$this->_redirect('/fizzy/login', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('login.phtml');
}
public function logoutAction()
{
- Zend_Auth::getInstance()->clearIdentity();
+ $auth = Zend_Auth::getInstance();
+ $auth->setStorage(new Zend_Auth_Storage_Session('fizzy'));
+ $auth->clearIdentity();
$this->_redirect('/fizzy', array('prependBase' => true));
}
protected function _getForm()
{
$formConfig = array (
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true
),
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Login',
'ignore' => true
)
)
)
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
public function postDispatch()
{
$this->_helper->layout->setLayout('login');
}
}
diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php
index 4ac1477..ee02248 100644
--- a/application/modules/admin/controllers/IndexController.php
+++ b/application/modules/admin/controllers/IndexController.php
@@ -1,20 +1,23 @@
<?php
class Admin_IndexController extends Fizzy_SecuredController
{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
/**
* Default action redirects to Pages overview.
*/
public function indexAction()
{
$this->_redirect('/fizzy/pages');
}
public function configurationAction()
{
$this->view->config = Fizzy::getInstance()->getConfig()->toArray();
$this->renderScript('configuration.phtml');
}
}
diff --git a/application/modules/admin/controllers/MediaController.php b/application/modules/admin/controllers/MediaController.php
index 130af58..feecbbc 100644
--- a/application/modules/admin/controllers/MediaController.php
+++ b/application/modules/admin/controllers/MediaController.php
@@ -1,169 +1,172 @@
<?php
/**
* Description of Media
*
* @author mattijs
*/
class Admin_MediaController extends Fizzy_SecuredController
{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
+
/**
* @todo implement overwrite checkbox
*/
public function indexAction()
{
$uploadFolder = Fizzy::getInstance()->getPath('uploads');
$form = $this->_getForm($uploadFolder);
if($this->_request->isPost()) {
if($form->isValid($_POST) && $form->file->receive()) {
$this->addSuccessMessage('File was successfully uploaded.');
}
else {
foreach($form->getErrorMessages() as $message) {
$this->addErrorMessage($message);
}
}
$this->_redirect('/fizzy/media');
}
# Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
# Render the view
$this->view->uploadFolder = $uploadFolder;
$this->view->files = $files;
$this->view->form = $form;
$this->view->type = $this->_request->getParam('type', 'list');
$this->renderScript('media.phtml');
}
public function displayAction()
{
$uploadFolder = Fizzy::getInstance()->getPath('uploads');
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file) {
if($file->isFile()) {
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
$type = $this->_getParam('type', 'list');
if($type == 'thumbnail') {
$script = 'media/thumbnails.phtml';
} else {
$script = 'media/list.phtml';
}
$this->renderScript($script);
}
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = Fizzy::getInstance()->getPath('uploads');
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
$this->addSuccessMessage('File was successfully deleted.');
}
}
$this->_redirect($this->view->baseUrl('/fizzy/media'));
}
/**
* Returns the form for file uploads
* @param string $uploadFolder
* @return Zend_Form
*/
protected function _getForm($uploadFolder)
{
$formConfig = array (
'action' => $this->view->baseUrl('/fizzy/media'),
'enctype' => 'multipart/form-data',
'elements' => array(
'file' => array (
'type' => 'file',
'options' => array (
'label' => 'File',
'description' => 'Choose a file to upload. The maximun file size is ' . str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), ini_get('upload_max_filesize')) . '.',
'required' => true,
'destination' => $uploadFolder,
)
),
/*'overwrite' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Overwrite existing?',
'description' => 'If this is checked any existing file with the same name will be overridden.',
'required' => false,
)
),*/
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Upload',
'ignore' => true,
)
)
),
);
return new Zend_Form(new Zend_Config($formConfig));
}
public function galleryAction()
{
$uploadFolder = Fizzy::getInstance()->getPath('uploads');
// Parse all files in the upload directory
$files = array();
$imageTypes = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
if (in_array($fileInfo['type'], $imageTypes)) {
$files[] = (object) $fileInfo;
}
}
}
// Render the view
$this->view->files = $files;
$this->_helper->layout->disableLayout();
}
}
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index 78c57c5..b371df3 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,176 +1,178 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$query = Doctrine_Query::create()->from('Page');
$pages = $query->fetchArray();
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page['id']), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$page->save();
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
$page = $query->fetchOne();
if(null !== $page) {
$page->delete();
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $page['id'],
)
),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
$form = new Fizzy_Form();
$form->setOptions($formConfig);
return $form;
}
}
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index 7fd8fbb..a4a90a2 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,135 +1,137 @@
<?php
class Admin_UserController extends Fizzy_SecuredController
{
+ protected $_sessionNamespace = 'fizzy';
+ protected $_redirect = '/fizzy/login';
public function indexAction()
{
$query = Doctrine_Query::create()->from('User');
$users = $query->fetchArray();
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->id), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null !== $user) {
$user->delete();
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
$passwordConfirm = new Fizzy_Validate_EqualsField();
$passwordConfirm->setOppositeField('password_confirm');
$passwordConfirm->setFieldName('Password');
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $user->id
)
),
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
'validators' => array (
'usernameUnique'
)
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
'validators' => array (
$passwordConfirm
)
),
),
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
}
|
jtietema/Fizzy
|
a1153144185dd934b2e0ee91b3111b157e0fff0a
|
doctrine cli now uses fizzy config
|
diff --git a/doctrine b/doctrine
index c6d9ab7..8cd6a3d 100755
--- a/doctrine
+++ b/doctrine
@@ -1,26 +1,31 @@
#!/usr/bin/env php
<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
define('LIBRARY_PATH', realpath(APPLICATION_PATH . '/library'));
set_include_path(LIBRARY_PATH . PATH_SEPARATOR . APPLICATION_PATH . '/models/doctrine/generated' . PATH_SEPARATOR . get_include_path());
require_once 'Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
+require_once 'Zend/Loader/Autoloader.php';
+$autoloader = Zend_Loader_Autoloader::getInstance();
+
+$config = new Zend_Config_Ini('configs/fizzy.ini', 'storage');
+
$manager = Doctrine_Manager::getInstance();
-Doctrine_Manager::connection('mysql://root@localhost/fizzy', 'doctrine');
+Doctrine_Manager::connection($config->dsn, 'doctrine');
$manager->setAttribute('model_loading', 'conservative');
$cli_config = array(
'models_path' => APPLICATION_PATH . '/models',
'sql_path' => APPLICATION_PATH . '/../database/sql',
'yaml_schema_path' => APPLICATION_PATH . '/../database/schema',
'migrations_path' => APPLICATION_PATH . '/../database/migrations',
'data_fixtures_path' => APPLICATION_PATH . '/../database/fixtures'
);
$cli = new Doctrine_Cli($cli_config);
$cli->run($_SERVER['argv']);
|
jtietema/Fizzy
|
917345f420836a5a48bf7bc244213af226895637
|
Refactored password confirm validator to generic field validator
|
diff --git a/application/library/Fizzy/Validate/PasswordConfirm.php b/application/library/Fizzy/Validate/EqualsField.php
similarity index 87%
rename from application/library/Fizzy/Validate/PasswordConfirm.php
rename to application/library/Fizzy/Validate/EqualsField.php
index 8ba652f..768bed4 100644
--- a/application/library/Fizzy/Validate/PasswordConfirm.php
+++ b/application/library/Fizzy/Validate/EqualsField.php
@@ -1,81 +1,90 @@
<?php
/**
* Class Fizzy_Validate_PasswordConfirm
* @category Fizzy
* @package Fizzy_Validate
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
* Validator to check if a password field has the same value as another field
* in the same form.
*
* @author Mattijs Hoitink <[email protected]>
*/
-class Fizzy_Validate_PasswordConfirm extends Zend_Validate_Abstract
+class Fizzy_Validate_EqualsField extends Zend_Validate_Abstract
{
const NOT_MATCH = 'notMatch';
protected $_messageTemplates = array(
self::NOT_MATCH => 'Password confirmation does not match'
);
/**
* The opposite field name to check against.
* @var string
*/
protected $_oppositeField = 'password_confirm';
/** **/
/**
* Set the field to check against.
* @param string $field
* @return Zend_Validate_Abstract
*/
public function setOppositeField($field)
{
$this->_oppositeField = $field;
return $this;
}
+ /**
+ * Sets the fieldname shown in the error
+ * @param string $name
+ */
+ public function setFieldName($name)
+ {
+ $this->setMessage($name . ' confirmation does not match', self::NOT_MATCH);
+ }
+
/**
* Check if the field value is the same as the opposite field value.
* @param string $value
* @param mixed $context
* @return boolean
*/
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
if(is_array($context)) {
if(isset($context[$this->_oppositeField]) && ($value == $context[$this->_oppositeField])) {
return true;
}
}
else if (is_string($context) && ($value == $context)) {
return true;
}
$this->_error(self::NOT_MATCH);
return false;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index 80792ff..7fd8fbb 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,131 +1,135 @@
<?php
class Admin_UserController extends Fizzy_SecuredController
{
public function indexAction()
{
$query = Doctrine_Query::create()->from('User');
$users = $query->fetchArray();
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->id), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$user->save();
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
$user = $query->fetchOne();
if(null !== $user) {
$user->delete();
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
+ $passwordConfirm = new Fizzy_Validate_EqualsField();
+ $passwordConfirm->setOppositeField('password_confirm');
+ $passwordConfirm->setFieldName('Password');
+
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
'value' => $user->id
)
),
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
'validators' => array (
'usernameUnique'
)
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
'validators' => array (
- 'passwordConfirm'
+ $passwordConfirm
)
),
),
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
}
|
jtietema/Fizzy
|
5e1ed942c72fee1f62f49f8d6373d401af0f23d2
|
Fixed typo in setModelClass function
|
diff --git a/application/library/Fizzy/Doctrine/AuthAdapter.php b/application/library/Fizzy/Doctrine/AuthAdapter.php
index d741a79..ac44fde 100644
--- a/application/library/Fizzy/Doctrine/AuthAdapter.php
+++ b/application/library/Fizzy/Doctrine/AuthAdapter.php
@@ -1,71 +1,71 @@
<?php
/**
* Auth adapter for Doctrine backend
**/
class Fizzy_Doctrine_AuthAdapter implements Zend_Auth_Adapter_Interface
{
protected $_username = null;
protected $_password = null;
protected $_modelClass = 'User';
public function __construct($username = null, $password = null)
{
if (null !== $username) {
$this->setUsername($username);
}
if (null !== $password) {
$this->setPassword($password);
}
}
public function setUsername($username)
{
$this->_username = $username;
return $this;
}
public function setPassword($password)
{
$this->_password = $password;
return $this;
}
public function setModelClass($modelClass)
{
- $this->_modelClass = $modeClass;
+ $this->_modelClass = $modelClass;
return $this;
}
public function authenticate()
{
# Check the username
$query = Doctrine_Query::create()->from($this->_modelClass)->where('username = ?', $this->_username);
$users = $query->fetchArray();
if(0 === count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null, array('Username not found.'));
}
else if(1 < count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS,
null, array('Username did not match one instance.'));
}
$user = $users[0];
# Check the password
$password = $this->_password;
$encryption = strtolower($user['encryption']);
if(!empty($encryption) && 'plain' !== $encryption && in_array($encryption, array('md5', 'sha1'))) {
$password = $encryption($password);
}
if($password !== $user['password']) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
null, array('Invalid password.'));
}
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);
}
}
|
jtietema/Fizzy
|
fec174f355f95f37fef7ac6b8075819ee86df12a
|
implemented contact form
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index 27850c2..cbc2ea2 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -1,582 +1,589 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Fizzy application class. Takes care of gathering all configuration,
* bootstrapping and dispatching requests.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
+ 'contact' => array(
+ 'route' => '/contact',
+ 'defaults' => array(
+ 'controller' => 'contact',
+ 'action' => 'index'
+ )
+ ),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
),
'models' => 'application/models',
'templates' => array (
'fizzy' => 'application/templates',
),
'assets' => 'application/assets',
'configs' => 'configs',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::connection($this->_config->storage->dsn);
$manager->setAttribute('model_loading', 'conservative');
Doctrine::loadModels(ROOT_PATH . '/' .$this->_defaultConfig['paths']['models']);
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getFrontController();
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
diff --git a/application/modules/default/controllers/ContactController.php b/application/modules/default/controllers/ContactController.php
new file mode 100644
index 0000000..f4b0e56
--- /dev/null
+++ b/application/modules/default/controllers/ContactController.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Contact form controller
+ **/
+class ContactController extends Zend_Controller_Action
+{
+ public function indexAction()
+ {
+ $form = $this->_getForm();
+ if ($this->_request->isPost()) {
+ if ($form->isValid($_POST)) {
+ $mail = new Zend_Mail();
+ $mail->setBodyText($form->feedback->getValue());
+ $mail->setFrom($form->email->getValue(), $form->name->getValue());
+ $application = Zend_Registry::get('config')->application->toArray();
+ $mail->addTo($application['contactEmail']);
+ $mail->send();
+ $this->renderScript('contact/thankyou.phtml');
+ return;
+ }
+ }
+ $this->view->form = $form;
+ }
+
+ protected function _getForm()
+ {
+ $form = new Zend_Form();
+ $form->setAction($this->view->baseUrl('/contact'));
+ $form->addElement(new Zend_Form_Element_Text('name', array(
+ 'label' => 'Name',
+ 'required' => true
+ )));
+ $form->addElement(new Zend_Form_Element_Text('email', array(
+ 'label' => 'E-mail',
+ 'required' => true
+ )));
+ $form->addElement(new Zend_Form_Element_Textarea('feedback', array(
+ 'label' => 'Question / feedback',
+ 'required' => true
+ )));
+ $form->addElement(new Zend_Form_Element_Submit('submit', array(
+ 'label' => 'Send',
+ )));
+ return $form;
+ }
+}
diff --git a/application/modules/default/views/scripts/contact/index.phtml b/application/modules/default/views/scripts/contact/index.phtml
new file mode 100644
index 0000000..b13fd4e
--- /dev/null
+++ b/application/modules/default/views/scripts/contact/index.phtml
@@ -0,0 +1,2 @@
+<h1>Contact</h1>
+<?= $this->form ?>
diff --git a/application/modules/default/views/scripts/contact/thankyou.phtml b/application/modules/default/views/scripts/contact/thankyou.phtml
new file mode 100644
index 0000000..27b313a
--- /dev/null
+++ b/application/modules/default/views/scripts/contact/thankyou.phtml
@@ -0,0 +1 @@
+Thank you for your feedback. We will get back to you shortly!
diff --git a/configs/fizzy.default.ini b/configs/fizzy.default.ini
index 48f8745..1a84297 100644
--- a/configs/fizzy.default.ini
+++ b/configs/fizzy.default.ini
@@ -1,2 +1,5 @@
[storage]
dsn = "mysql://root@localhost/fizzy"
+
+[application]
+contactEmail = "[email protected]"
|
jtietema/Fizzy
|
9ba48dea17724b7143abe7b856afb22bbcc2473d
|
fixed pages controller frontend
|
diff --git a/application/modules/default/controllers/PagesController.php b/application/modules/default/controllers/PagesController.php
index 0bf6b34..a0bec2d 100644
--- a/application/modules/default/controllers/PagesController.php
+++ b/application/modules/default/controllers/PagesController.php
@@ -1,34 +1,35 @@
<?php
/**
* Description of Pages
*
* @author mattijs
*/
class PagesController extends Fizzy_Controller
{
public function slugAction()
{
$slug = $this->_getParam('slug', null);
if(null === $slug) {
- # Redirect to 404
+ # Get default homepage
+ $query = Doctrine_Query::create()->from('Page')->where('homepage = ?', true);
+ $page = $query->fetchOne();
+ } else {
+ $query = Doctrine_Query::create()->from('Page')->where('slug = ?', $slug);
+ $page = $query->fetchOne();
}
- $storage = Zend_Registry::get('storage');
- $pages = $storage->fetchByField('Page', array('slug' => $slug));
- if(1 < count($pages)) {
+ if($page === null) {
# Log user exception viewable in the backend
}
- $page = array_shift($pages);
-
$config = Zend_Registry::get('config');
$templatePaths = $config->paths->templates->toArray();
$this->view->setScriptPath($templatePaths);
$this->_helper->layout->setLayout($page->getLayout());
$this->view->page = $page;
$this->renderScript($page->getTemplate());
}
-}
\ No newline at end of file
+}
diff --git a/application/modules/default/views/layouts/default.phtml b/application/modules/default/views/layouts/default.phtml
index f2c2c07..a911864 100644
--- a/application/modules/default/views/layouts/default.phtml
+++ b/application/modules/default/views/layouts/default.phtml
@@ -1,66 +1,66 @@
<?php
/**
* Default layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<html>
<head>
<?php
$application = Fizzy::getInstance();
$title = $application->getTitle();
?>
<title><?= $title; ?></title>
<link href="<?= $this->baseUrl("/css/default.css") ?>" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div class="container">
<!-- HEADER -->
<div id="header" class="span-24 last">
<h1>Fizzy<span>CMS</span></h1>
</div>
<!-- NAVIGATION -->
<div id="navigation" class="span-24 last">
<ul>
<li><a href="<?= $this->baseUrl('/') ?>">Home</a></li>
<li><a href="<?= $this->baseUrl('/about'); ?>">About</a></li>
<li><a href="<?= $this->baseUrl('/configuration'); ?>">Configuration</a></li>
<li><a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">More</a></li>
</ul>
</div>
<!-- CONTENT -->
<div id="main-wrapper" class="span-24 last">
<div id="content" class="span-24">
<div class="content-block">
- <?= $this->content; ?>
+ <?= $this->layout()->content; ?>
</div>
</div>
</div>
<!-- FOOTER -->
<div id="footer" class="span-24 last">
(c) 2009 <a href="http://www.voidwalkers.nl" title="The Voidwalkers">Voidwalkers</a> - <a href="http://www.voidwalkers.nl/license/bsd-license" title="Fizzy license">license</a>
</div>
</div>
</body>
</html>
|
jtietema/Fizzy
|
b9b692363e80f40556278ee3b2347c0469b99f5e
|
removed commented code
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index 503dbef..27850c2 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -21,628 +21,618 @@ class Fizzy
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
),
'models' => 'application/models',
'templates' => array (
'fizzy' => 'application/templates',
),
'assets' => 'application/assets',
'configs' => 'configs',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::connection($this->_config->storage->dsn);
$manager->setAttribute('model_loading', 'conservative');
Doctrine::loadModels(ROOT_PATH . '/' .$this->_defaultConfig['paths']['models']);
-
- /*
- $storage = null;
- if(isset($this->_config->storage)) {
- $storage = new Fizzy_Storage($this->_config->storage->toArray());
- Zend_Registry::set('storage', $storage);
- }
-
- return $storage;
- */
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getFrontController();
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
|
jtietema/Fizzy
|
9c3fb09a04d73b8f0b36d19609aecc108a6fc97c
|
ported backend to Doctrine
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index 9b18e32..503dbef 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -10,625 +10,639 @@ require_once 'Zend/Config.php';
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
),
'models' => 'application/models',
'templates' => array (
'fizzy' => 'application/templates',
),
'assets' => 'application/assets',
'configs' => 'configs',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
+ require_once 'Doctrine.php';
+ $autoloader = Zend_Loader_Autoloader::getInstance();
+ $autoloader->pushAutoloader(array('Doctrine', 'autoload'));
+
+ $manager = Doctrine_Manager::getInstance();
+
+ Doctrine_Manager::connection($this->_config->storage->dsn);
+
+ $manager->setAttribute('model_loading', 'conservative');
+
+ Doctrine::loadModels(ROOT_PATH . '/' .$this->_defaultConfig['paths']['models']);
+
+ /*
$storage = null;
if(isset($this->_config->storage)) {
$storage = new Fizzy_Storage($this->_config->storage->toArray());
Zend_Registry::set('storage', $storage);
}
return $storage;
+ */
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layout = Zend_Layout::startMvc(array (
'layout' => 'default',
));
$front = $this->getFrontController();
$front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
diff --git a/application/library/Fizzy/Doctrine/AuthAdapter.php b/application/library/Fizzy/Doctrine/AuthAdapter.php
new file mode 100644
index 0000000..d741a79
--- /dev/null
+++ b/application/library/Fizzy/Doctrine/AuthAdapter.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Auth adapter for Doctrine backend
+ **/
+class Fizzy_Doctrine_AuthAdapter implements Zend_Auth_Adapter_Interface
+{
+ protected $_username = null;
+ protected $_password = null;
+ protected $_modelClass = 'User';
+
+ public function __construct($username = null, $password = null)
+ {
+ if (null !== $username) {
+ $this->setUsername($username);
+ }
+
+ if (null !== $password) {
+ $this->setPassword($password);
+ }
+ }
+
+ public function setUsername($username)
+ {
+ $this->_username = $username;
+
+ return $this;
+ }
+
+ public function setPassword($password)
+ {
+ $this->_password = $password;
+
+ return $this;
+ }
+
+ public function setModelClass($modelClass)
+ {
+ $this->_modelClass = $modeClass;
+
+ return $this;
+ }
+
+ public function authenticate()
+ {
+ # Check the username
+ $query = Doctrine_Query::create()->from($this->_modelClass)->where('username = ?', $this->_username);
+ $users = $query->fetchArray();
+ if(0 === count($users)) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
+ null, array('Username not found.'));
+ }
+ else if(1 < count($users)) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS,
+ null, array('Username did not match one instance.'));
+ }
+ $user = $users[0];
+
+ # Check the password
+ $password = $this->_password;
+ $encryption = strtolower($user['encryption']);
+ if(!empty($encryption) && 'plain' !== $encryption && in_array($encryption, array('md5', 'sha1'))) {
+ $password = $encryption($password);
+ }
+ if($password !== $user['password']) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
+ null, array('Invalid password.'));
+ }
+
+ return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);
+ }
+}
diff --git a/application/library/Fizzy/Validate/SlugUnique.php b/application/library/Fizzy/Validate/SlugUnique.php
index 06f3f52..f6f16f4 100644
--- a/application/library/Fizzy/Validate/SlugUnique.php
+++ b/application/library/Fizzy/Validate/SlugUnique.php
@@ -1,73 +1,67 @@
<?php
/**
* Class Fizzy_Validate_SlugUnique
* @category Fizzy
* @package Fizzy_Validate
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
* Form validator to check if a page slug is unique. Advises the Fizzy_Storage
* to check this.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Validate_SlugUnique extends Zend_Validate_Abstract
{
const NOT_UNIQUE = 'notUnique';
protected $_messageTemplates = array (
self::NOT_UNIQUE => 'Slug is not unique.'
);
/** **/
/**
* Check if a username is valid (unique).
* @param string $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
- $storage = Fizzy::getInstance()->getStorage();
- $pages = $storage->fetchAll('Page');
- $slugs = array();
- foreach($pages as $page) {
- $slugs[$page->getId()] = $page->slug;
- }
+ $query = Doctrine_Query::create()->from('Page')->where('slug = ?', $value);
+ $pages = $query->fetchArray();
- # Check if we are editing the page the slug belongs to
- $editingOriginal = false;
- if(is_array($context) && isset($context['id'])) {
- $id = $context['id'];
- if(array_key_exists($id, $slugs) && $value == $slugs[$id]) {
- $editingOriginal = true;
- }
+ // we already have multiple items with this slug (should never occur).
+ if (count($pages) > 1){
+ $this->_error(self::NOT_UNIQUE);
+ return false;
}
-
- if(in_array($value, $slugs) && !$editingOriginal) {
+
+ // check if the found slug belongs to the current document. If not return false.
+ if (count($pages) === 1 && $context['id'] !== $pages[0]['id']) {
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
-}
\ No newline at end of file
+}
diff --git a/application/library/Fizzy/Validate/UsernameUnique.php b/application/library/Fizzy/Validate/UsernameUnique.php
index a165938..9b965e3 100644
--- a/application/library/Fizzy/Validate/UsernameUnique.php
+++ b/application/library/Fizzy/Validate/UsernameUnique.php
@@ -1,73 +1,65 @@
<?php
/**
* Class Fizzy_Validate_UsernameUnique
* @category Fizzy
* @package Fizzy_Validate
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
* Form validator to check if a username is unique. Advises the Fizzy_Storage
* to check this.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Validate_UsernameUnique extends Zend_Validate_Abstract
{
const NOT_UNIQUE = 'notUnique';
protected $_messageTemplates = array (
self::NOT_UNIQUE => 'Username is not unique.'
);
/** **/
/**
* Check if a username is valid (unique).
* @param string $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
- $storage = Fizzy::getInstance()->getStorage();
- $users = $storage->fetchAll('User');
- $usernames = array();
- foreach($users as $user) {
- $usernames[$user->getId()] = $user->username;
- }
+ $query = Doctrine_Query::create()->from('User')->where('username = ?', $value);
+ $users = $query->fetchArray();
- # Check if we are editing the page the slug belongs to
- $editingOriginal = false;
- if(is_array($context) && isset($context['id'])) {
- $id = $context['id'];
- if(array_key_exists($id, $usernames) && $value === $usernames[$id]) {
- $editingOriginal = true;
- }
+ if (count($users) > 1) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
}
- if(in_array($value, $usernames) && !$editingOriginal) {
+ if (count($users) === 1 && $context['id'] !== $users[0]['id']) {
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
-}
\ No newline at end of file
+}
diff --git a/application/models/Page.php b/application/models/Page.php
index 9012546..1b3cece 100644
--- a/application/models/Page.php
+++ b/application/models/Page.php
@@ -1,77 +1,56 @@
<?php
-/**
- * Class Page
- * @package Fizzy
- * @subpackage Model
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.voidwalkers.nl/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to [email protected] so we can send you a copy immediately.
- *
- * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
- * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
- */
-
-/** Fizzy_Storage_Model */
-require_once 'Fizzy/Storage/Model.php';
+require_once 'generated/BasePage.php';
/**
- * Represents a user contributed page.
- * @author Mattijs Hoitink <[email protected]>
+ * Page
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
-class Page extends Fizzy_Storage_Model
+class Page extends BasePage
{
- /**
- * @see Fizzy_Storage_Model
- */
- protected $_containerName = 'page';
-
- /**
- * Template for the page.
- * @var string
- */
- public $template = null;
-
- /**
- * Layout for the page.
- * @var string
- */
- public $layout = null;
-
- /** **/
-
- /**
- * Override to return the default template if none is set.
- * @return string
- */
public function getTemplate()
{
if(empty($this->template)) {
$application = Zend_Registry::get('config')->application->toArray();
$this->template = $application['defaultTemplate'];
}
-
+
return $this->template;
}
/**
* Override to return the default layout if none is set.
* @return string
*/
public function getLayout()
{
if(empty($this->layout)) {
$application = Zend_Registry::get('config')->application->toArray();
$this->layout = $application['defaultLayout'];
}
return $this->layout;
}
+ public function populate($array)
+ {
+ $this->title = $array['title'];
+ $this->slug = $array['slug'];
+ $this->body = $array['body'];
+ $this->homepage = (boolean) $array['homepage'];
+
+ if ('default' !== $array['template'])
+ $this->template = $array['template'];
+
+ if ('default' !== $array['layout'])
+ $this->layout = $array['layout'];
+
+ return $this;
+ }
+
}
diff --git a/application/models/User.php b/application/models/User.php
index e5305bb..61033b8 100644
--- a/application/models/User.php
+++ b/application/models/User.php
@@ -1,36 +1,23 @@
<?php
-/**
- * User model.
- * @package Fizzy
- * @subpackage Model
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.voidwalkers.nl/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to [email protected] so we can send you a copy immediately.
- *
- * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
- * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
- */
-
-/** Fizzy_Storage_Model */
-require_once 'Fizzy/Storage/Model.php';
+require_once 'generated/BaseUser.php';
/**
- * User model, represents an user in the CMS
- *
- * @author Jeroen Tietema <[email protected]>
+ * User
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
-class User extends Fizzy_Storage_Model
+class User extends BaseUser
{
- /**
- * @see Fizzy_Storage_Model
- */
- protected $_containerName = 'user';
-
+ public function populate($array)
+ {
+ $this->username = $array['username'];
+ $this->password = $array['password'];
+ $this->encryption = $array['encryption'];
+ return $this;
+ }
}
diff --git a/application/models/generated/BasePage.php b/application/models/generated/BasePage.php
new file mode 100644
index 0000000..d9088a2
--- /dev/null
+++ b/application/models/generated/BasePage.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * BasePage
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $title
+ * @property string $slug
+ * @property string $body
+ * @property boolean $homepage
+ * @property string $layout
+ * @property string $template
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BasePage extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('page');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('title', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('slug', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => '255',
+ ));
+ $this->hasColumn('body', 'string', null, array(
+ 'type' => 'string',
+ ));
+ $this->hasColumn('homepage', 'boolean', null, array(
+ 'type' => 'boolean',
+ ));
+ $this->hasColumn('layout', 'string', 150, array(
+ 'type' => 'string',
+ 'length' => '150',
+ ));
+ $this->hasColumn('template', 'string', 150, array(
+ 'type' => 'string',
+ 'length' => '150',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ }
+}
\ No newline at end of file
diff --git a/application/models/generated/BaseUser.php b/application/models/generated/BaseUser.php
new file mode 100644
index 0000000..a11fdd6
--- /dev/null
+++ b/application/models/generated/BaseUser.php
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * BaseUser
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @property integer $id
+ * @property string $username
+ * @property string $password
+ * @property string $encryption
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
+ */
+abstract class BaseUser extends Doctrine_Record
+{
+ public function setTableDefinition()
+ {
+ $this->setTableName('user');
+ $this->hasColumn('id', 'integer', 4, array(
+ 'type' => 'integer',
+ 'primary' => true,
+ 'autoincrement' => true,
+ 'length' => '4',
+ ));
+ $this->hasColumn('username', 'string', 150, array(
+ 'type' => 'string',
+ 'length' => '150',
+ ));
+ $this->hasColumn('password', 'string', 150, array(
+ 'type' => 'string',
+ 'length' => '150',
+ ));
+ $this->hasColumn('encryption', 'string', 10, array(
+ 'type' => 'string',
+ 'length' => '10',
+ ));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ }
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
index a036b8f..be40bfc 100644
--- a/application/modules/admin/controllers/AuthController.php
+++ b/application/modules/admin/controllers/AuthController.php
@@ -1,69 +1,69 @@
<?php
class Admin_AuthController extends Fizzy_Controller
{
public function loginAction()
{
$form = $this->_getForm();
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
- $authAdapter = new Fizzy_Storage_AuthAdapter(
+ $authAdapter = new Fizzy_Doctrine_AuthAdapter(
$form->username->getValue(), $form->password->getValue()
);
$result = Zend_Auth::getInstance()->authenticate($authAdapter);
if($result->isValid()) {
$this->_redirect('/fizzy', array('prependBase' => true));
}
$messages = $result->getMessages();
$this->addErrorMessage(array_shift($messages));
$this->_redirect('/fizzy/login', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('login.phtml');
}
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('/fizzy', array('prependBase' => true));
}
protected function _getForm()
{
$formConfig = array (
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true
),
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Login',
'ignore' => true
)
)
)
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
public function postDispatch()
{
$this->_helper->layout->setLayout('login');
}
-}
\ No newline at end of file
+}
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index 08e698d..78c57c5 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,176 +1,176 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
- $storage = Zend_Registry::get('storage');
- $pages = $storage->fetchAll('Page');
+ $query = Doctrine_Query::create()->from('Page');
+ $pages = $query->fetchArray();
+
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
- $storage = Zend_Registry::get('storage');
- $storage->persist($page);
-
+ $page->save();
+
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
- $storage = Zend_Registry::get('storage');
- $page = $storage->fetchByID('Page', $id);
+ $query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
+ $page = $query->fetchOne();
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
- $form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page->getId()), $page);
+ $form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page['id']), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
- $storage->persist($page);
+ $page->save();
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
- $storage = Zend_Registry::get('storage');
- $page = $storage->fetchByID('Page', $id);
+ $query = Doctrine_Query::create()->from('Page')->where('id = ?', $id);
+ $page = $query->fetchOne();
if(null !== $page) {
- $storage->delete($page);
+ $page->delete();
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
- 'value' => $page->getId(),
+ 'value' => $page['id'],
)
),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
$form = new Fizzy_Form();
$form->setOptions($formConfig);
return $form;
}
-}
\ No newline at end of file
+}
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index 174c6f3..80792ff 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,132 +1,131 @@
<?php
class Admin_UserController extends Fizzy_SecuredController
{
public function indexAction()
{
- $storage = Zend_Registry::get('storage');
- $users = $storage->fetchAll('User');
+ $query = Doctrine_Query::create()->from('User');
+ $users = $query->fetchArray();
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
- $storage = Zend_Registry::get('storage');
- $storage->persist($user);
+ $user->save();
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
- $storage = Zend_Registry::get('storage');
- $user = $storage->fetchByID('User', $id);
+ $query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
+ $user = $query->fetchOne();
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
- $form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->getId()), $user);
+ $form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->id), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
- $storage->persist($user);
+ $user->save();
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
- $storage = Zend_Registry::get('storage');
- $user = $storage->fetchByID('User', $id);
+ $query = Doctrine_Query::create()->from('User')->where('id = ?', $id);
+ $user = $query->fetchOne();
if(null !== $user) {
- $storage->delete($user);
+ $user->delete();
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
$formConfig = array (
'action' => $action,
'elements' => array (
'id' => array (
'type' => 'hidden',
'options' => array (
'required' => false,
- 'value' => $user->getId()
+ 'value' => $user->id
)
),
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
'validators' => array (
'usernameUnique'
)
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
'validators' => array (
'passwordConfirm'
)
),
),
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
return new Fizzy_Form(new Zend_Config($formConfig));
}
-}
\ No newline at end of file
+}
diff --git a/application/modules/admin/views/scripts/pages/index.phtml b/application/modules/admin/views/scripts/pages/index.phtml
index 2c6d211..99012bb 100644
--- a/application/modules/admin/views/scripts/pages/index.phtml
+++ b/application/modules/admin/views/scripts/pages/index.phtml
@@ -1,29 +1,29 @@
<h1>Pages</h1>
<div>
<table class="data-table">
<thead>
<tr>
<td>Title</td>
<td>Slug</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->pages as $page) : ?>
<tr>
- <td><?= $page->title ?></td>
- <td><?= $page->slug ?></td>
+ <td><?= $page['title'] ?></td>
+ <td><?= $page['slug'] ?></td>
<td style="width: 100px;">
- <?= $this->link("/pages/{$page->slug}", $this->img('/fizzy_assets/images/icon/view.png', array('alt' => 'View icon')), array('target' => '_blanc')); ?>
- <?= $this->link("/fizzy/pages/edit/{$page->getId()}", $this->img('/fizzy_assets/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
- <?= $this->linkConfirm("/fizzy/pages/delete/{$page->getId()}", $this->img('/fizzy_assets/images/icon/sign_remove.png', array('alt' => 'remove icon')), 'Are you sure?'); ?>
+ <?= $this->link("/pages/{$page['slug']}", $this->img('/fizzy_assets/images/icon/view.png', array('alt' => 'View icon')), array('target' => '_blanc')); ?>
+ <?= $this->link("/fizzy/pages/edit/{$page['id']}", $this->img('/fizzy_assets/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
+ <?= $this->linkConfirm("/fizzy/pages/delete/{$page['id']}", $this->img('/fizzy_assets/images/icon/sign_remove.png', array('alt' => 'remove icon')), 'Are you sure?'); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
<?= $this->link('/fizzy/pages/add', $this->img('/fizzy_assets/images/icon/add.png', array('alt' => 'add icon')) . ' Add Page'); ?>
</p>
-</div>
\ No newline at end of file
+</div>
diff --git a/application/modules/admin/views/scripts/user/list.phtml b/application/modules/admin/views/scripts/user/list.phtml
index c2f425a..aab51cf 100644
--- a/application/modules/admin/views/scripts/user/list.phtml
+++ b/application/modules/admin/views/scripts/user/list.phtml
@@ -1,26 +1,26 @@
<h1 class="header">Users</h1>
<div>
<table class="data-table">
<thead>
<tr>
<td>Username</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->users as $user) : ?>
<tr>
- <td><?= $user->username; ?></td>
+ <td><?= $user['username'] ?></td>
<td style="width: 100px;">
- <?= $this->link("/fizzy/user/edit/{$user->getId()}", $this->img('/fizzy_assets/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
- <?= $this->linkConfirm("/fizzy/user/delete/{$user->getId()}", $this->img('/fizzy_assets/images/icon/sign_remove.png', array('alt' => 'remove icon')), 'Are you sure you want to delete user ' . $user->username .'?'); ?>
+ <?= $this->link("/fizzy/user/edit/{$user['id']}", $this->img('/fizzy_assets/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
+ <?= $this->linkConfirm("/fizzy/user/delete/{$user['id']}", $this->img('/fizzy_assets/images/icon/sign_remove.png', array('alt' => 'remove icon')), 'Are you sure you want to delete user ' . $user['username'] .'?'); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
<?= $this->link('/fizzy/user/add', $this->img('/fizzy_assets/images/icon/add.png', array('alt' => 'add icon')) . ' Add User'); ?>
</p>
-</div>
\ No newline at end of file
+</div>
diff --git a/configs/fizzy.default.ini b/configs/fizzy.default.ini
index b6d8a2a..48f8745 100644
--- a/configs/fizzy.default.ini
+++ b/configs/fizzy.default.ini
@@ -1,2 +1,2 @@
[storage]
-dsn = "xml:data"
+dsn = "mysql://root@localhost/fizzy"
diff --git a/database/fixtures/pages.yml b/database/fixtures/pages.yml
new file mode 100644
index 0000000..07287cd
--- /dev/null
+++ b/database/fixtures/pages.yml
@@ -0,0 +1,48 @@
+Page:
+ Home:
+ title: Congratulations
+ slug: home
+ body: |
+ <p>
+ <img src="/fizzy.git/public/uploads/pastedpic_04222008_234311.png" alt="" width="80" />
+ </p>
+ <p>
+ This is the default layout for <a>Fizzy</a>. You are seeing this page because you did not configure a default layout and template. See the <a href="/fizzy.git/public/fizzy/pages/edit/configuration">Configuration</a> page for more information about configuring Fizzy.
+ </p>
+ <p>
+ If you want to know more about Fizzy, check the <a href="/fizzy.git/public/fizzy/pages/edit/about">About</a> page or visit the <a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">project website</a> by clicking the more link.
+ </p>
+ <p>
+ You can administer your website by going to the <a href="/fizzy.git/public/fizzy/pages/edit/admin">administrator page</a>. There you can change the content of your site and add users. The default username and password for the administrator section is "admin". Please change this to something more appropriate.
+ </p>
+ homepage: true
+ Configuration:
+ title: Configuration
+ slug: configuration
+ body: |
+ <p>
+ Configuring Fizzy done in two locations.
+ </p>
+ <h2>Configuration file</h2>
+ <p>
+ To change the systems configuration the fizzy.xml file in the configs directory under the root of the application can be changed. For a complete list of the configuration options visit the project website.
+ </p>
+ <h2>Customized templates & Layouts</h2>
+ <p>
+ Fizzy pages can be enriched with templates and layouts. These templates can be selected when adding or editing a page in the administrator section. <br />
+ </p>
+ <p>
+ New templates and layouts can be placed in the custom directory under the application root. For a complete overview of templating and layout options visit the <a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">project website</a>.
+ </p>
+ homepage: false
+ About:
+ title: About Fizzy
+ slug: about
+ body: |
+ <p>
+ Fizzy is a lightweight, easy to deploy Content Management System to administer paginated content on a website. The system allows users to create, update and delete content on their site with ease.
+ </p>
+ <p>
+ The dependencies for Fizzy are kept to a minimum, but can be extended by any PHP programmer. In it's most basic form Fizzy does not require a database and stores all its data in <a href="http://en.wikipedia.org/wiki/XML">XML</a> files.
+ </p>
+ homepage: false
diff --git a/database/fixtures/users.yml b/database/fixtures/users.yml
new file mode 100644
index 0000000..97a3b43
--- /dev/null
+++ b/database/fixtures/users.yml
@@ -0,0 +1,4 @@
+User:
+ Admin:
+ username: admin
+ password: admin
diff --git a/database/schema/schema.yml b/database/schema/schema.yml
new file mode 100644
index 0000000..5c0d9b5
--- /dev/null
+++ b/database/schema/schema.yml
@@ -0,0 +1,31 @@
+User:
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ username:
+ type: string(150)
+ password:
+ type: string(150)
+ encryption:
+ type: string(10)
+
+Page:
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ title:
+ type: string(255)
+ slug:
+ type: string(255)
+ body:
+ type: string
+ homepage:
+ type: boolean
+ layout:
+ type: string(150)
+ template:
+ type: string(150)
diff --git a/doctrine b/doctrine
new file mode 100755
index 0000000..c6d9ab7
--- /dev/null
+++ b/doctrine
@@ -0,0 +1,26 @@
+#!/usr/bin/env php
+<?php
+
+define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
+define('LIBRARY_PATH', realpath(APPLICATION_PATH . '/library'));
+
+set_include_path(LIBRARY_PATH . PATH_SEPARATOR . APPLICATION_PATH . '/models/doctrine/generated' . PATH_SEPARATOR . get_include_path());
+
+require_once 'Doctrine.php';
+spl_autoload_register(array('Doctrine', 'autoload'));
+
+$manager = Doctrine_Manager::getInstance();
+
+Doctrine_Manager::connection('mysql://root@localhost/fizzy', 'doctrine');
+
+$manager->setAttribute('model_loading', 'conservative');
+
+$cli_config = array(
+ 'models_path' => APPLICATION_PATH . '/models',
+ 'sql_path' => APPLICATION_PATH . '/../database/sql',
+ 'yaml_schema_path' => APPLICATION_PATH . '/../database/schema',
+ 'migrations_path' => APPLICATION_PATH . '/../database/migrations',
+ 'data_fixtures_path' => APPLICATION_PATH . '/../database/fixtures'
+);
+$cli = new Doctrine_Cli($cli_config);
+$cli->run($_SERVER['argv']);
|
jtietema/Fizzy
|
8f0d4df33fe06884f914f30250105691a5ff3ce3
|
added default page template
|
diff --git a/application/templates/page.phtml b/application/templates/page.phtml
new file mode 100644
index 0000000..28f317e
--- /dev/null
+++ b/application/templates/page.phtml
@@ -0,0 +1,4 @@
+<h1><?= $this->page->title ?></h1>
+<div>
+<?= $this->page->body ?>
+</div>
|
jtietema/Fizzy
|
23157d7c4be35bcd19ebe450d507f594ac9d1c8a
|
styling frontend now works again
|
diff --git a/application/modules/default/views/layouts/default.phtml b/application/modules/default/views/layouts/default.phtml
index e69de29..f2c2c07 100644
--- a/application/modules/default/views/layouts/default.phtml
+++ b/application/modules/default/views/layouts/default.phtml
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Default layout
+ * @package Fizzy
+ * @subpackage Views
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+ ?>
+<html>
+ <head>
+ <?php
+ $application = Fizzy::getInstance();
+ $title = $application->getTitle();
+ ?>
+ <title><?= $title; ?></title>
+ <link href="<?= $this->baseUrl("/css/default.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ </head>
+ <body>
+
+ <div class="container">
+
+ <!-- HEADER -->
+ <div id="header" class="span-24 last">
+ <h1>Fizzy<span>CMS</span></h1>
+ </div>
+
+ <!-- NAVIGATION -->
+ <div id="navigation" class="span-24 last">
+ <ul>
+ <li><a href="<?= $this->baseUrl('/') ?>">Home</a></li>
+ <li><a href="<?= $this->baseUrl('/about'); ?>">About</a></li>
+ <li><a href="<?= $this->baseUrl('/configuration'); ?>">Configuration</a></li>
+ <li><a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">More</a></li>
+ </ul>
+ </div>
+
+ <!-- CONTENT -->
+ <div id="main-wrapper" class="span-24 last">
+ <div id="content" class="span-24">
+ <div class="content-block">
+ <?= $this->content; ?>
+ </div>
+ </div>
+ </div>
+
+ <!-- FOOTER -->
+ <div id="footer" class="span-24 last">
+ (c) 2009 <a href="http://www.voidwalkers.nl" title="The Voidwalkers">Voidwalkers</a> - <a href="http://www.voidwalkers.nl/license/bsd-license" title="Fizzy license">license</a>
+ </div>
+
+ </div>
+
+ </body>
+</html>
diff --git a/public/css/default.css b/public/css/default.css
new file mode 100644
index 0000000..cf46073
--- /dev/null
+++ b/public/css/default.css
@@ -0,0 +1,146 @@
+@import 'screen.css';
+
+body {
+ margin: 0;
+ padding: 0;
+ background: #e2e6e9;
+ font-family: Verdana, Arial, Sans-Serif;
+}
+
+a:link {
+ color: #273A4D;
+ text-decoration: none;
+}
+a:visited {
+ color: #273A4D;
+ text-decoration: none;
+}
+a:hover, a:active {
+ color: #ffffff;
+ background-color: #343838;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-weight: normal;
+ margin: 1em 0;
+ padding: 0;
+}
+h1 { font-size: 200%; color: #293138;}
+h2 { font-size: 150%; color: #353F47;}
+h3 { font-size: 125%; color: #3f4f5c;}
+h4 { font-size: 115%; color: #3f4f5c; }
+h5 { font-size: 110%; color: #3f4f5c;}
+h6 {
+ font-size: 100%;
+ text-transform: uppercase;
+ margin: 5px 0;
+ font-weight: bold;
+}
+
+/* HEADER */
+
+#header {
+
+}
+#header h1 {
+ color: #191a1a;
+ font-weight: bold;
+ margin-bottom: 0.5em;
+}
+
+#header h1 a {
+ width:750px;
+ height: 200px;
+ background: transparent;
+}
+
+#header h1 a:link,
+#header h1 a:visited {
+ color: #333333;
+}
+
+#header h1 a:hover,
+#header h1 a:active {
+ color: #000000;
+ background-color: transparent;
+}
+#header h1 span {color:#5b5c5c;}
+
+/* NAVIGATION */
+
+#navigation {
+ background-color: #282d2d;
+ text-transform: uppercase;
+ font-size: 110%;
+}
+
+#navigation ul {
+ margin: 0 5px;
+ padding: 0px 0;
+ list-style-type: none;
+}
+
+#navigation li {
+ float: left;
+ margin: 0 0 0 5px;
+ padding: 0;
+}
+
+#navigation a:link,
+#navigation a:visited {
+ float: left;
+ display: block;
+ color: #c6c6c6;
+ padding: 0.5em 1em;
+
+}
+
+#navigation ul li.current_page_item a:link,
+#navigation ul li.current_page_item a:visited,
+#navigation ul li.current_page_item a:hover,
+#navigation ul li.current_page_item a:active {
+ color: #ffffff;
+ background-color: #414646;
+ border-left: solid #6b7070 1px;
+ border-right: solid #6b7070 1px;
+}
+
+/* CONTENT */
+
+#main-wrapper {
+ background-color: #FFFFFF;
+}
+
+/* content */
+#content {}
+.content-block {
+ margin: 1em 1.5em;
+}
+
+/* sidebar */
+
+#sidebar {}
+
+.sidebar-block {
+ margin: 2em 1em;
+}
+.sidebar-block h3 {
+ color:#5b5c5c;
+ text-transform: uppercase;
+ border-bottom: solid #5b5c5c 2px;
+ padding-bottom: 0.3em;
+ margin: 0;
+}
+.sidebar-block-content {
+ background-color: #F3F2F2;
+ border: solid #E6E4E4 1px;
+ padding: 0.5em;
+}
+
+/* FOOTER */
+#footer {
+ color: #555555;
+ text-align: center;
+ padding: 1em 0;
+ background: #cfcfcf;
+}
\ No newline at end of file
diff --git a/public/css/ie.css b/public/css/ie.css
new file mode 100644
index 0000000..f336f0e
--- /dev/null
+++ b/public/css/ie.css
@@ -0,0 +1,35 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 0.9
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* ie.css */
+body {text-align:center;}
+.container {text-align:left;}
+* html .column, * html div.span-1, * html div.span-2, * html div.span-3, * html div.span-4, * html div.span-5, * html div.span-6, * html div.span-7, * html div.span-8, * html div.span-9, * html div.span-10, * html div.span-11, * html div.span-12, * html div.span-13, * html div.span-14, * html div.span-15, * html div.span-16, * html div.span-17, * html div.span-18, * html div.span-19, * html div.span-20, * html div.span-21, * html div.span-22, * html div.span-23, * html div.span-24 {display:inline;overflow-x:hidden;}
+* html legend {margin:0px -8px 16px 0;padding:0;}
+sup {vertical-align:text-top;}
+sub {vertical-align:text-bottom;}
+html>body p code {*white-space:normal;}
+hr {margin:-8px auto 11px;}
+img {-ms-interpolation-mode:bicubic;}
+.clearfix, .container {display:inline-block;}
+* html .clearfix, * html .container {height:1%;}
+fieldset {padding-top:0;}
+textarea {overflow:auto;}
+input.text, input.title, textarea {background-color:#fff;border:1px solid #bbb;}
+input.text:focus, input.title:focus {border-color:#666;}
+input.text, input.title, textarea, select {margin:0.5em 0;}
+input.checkbox, input.radio {position:relative;top:.25em;}
+form.inline div, form.inline p {vertical-align:middle;}
+form.inline label {position:relative;top:-0.25em;}
+form.inline input.checkbox, form.inline input.radio, form.inline input.button, form.inline button {margin:0.5em 0;}
+button, input.button {position:relative;top:0.25em;}
\ No newline at end of file
diff --git a/public/css/print.css b/public/css/print.css
new file mode 100644
index 0000000..fdb8220
--- /dev/null
+++ b/public/css/print.css
@@ -0,0 +1,29 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 0.9
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* print.css */
+body {line-height:1.5;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;color:#000;background:none;font-size:10pt;}
+.container {background:none;}
+hr {background:#ccc;color:#ccc;width:100%;height:2px;margin:2em 0;padding:0;border:none;}
+hr.space {background:#fff;color:#fff;visibility:hidden;}
+h1, h2, h3, h4, h5, h6 {font-family:"Helvetica Neue", Arial, "Lucida Grande", sans-serif;}
+code {font:.9em "Courier New", Monaco, Courier, monospace;}
+a img {border:none;}
+p img.top {margin-top:0;}
+blockquote {margin:1.5em;padding:1em;font-style:italic;font-size:.9em;}
+.small {font-size:.9em;}
+.large {font-size:1.1em;}
+.quiet {color:#999;}
+.hide {display:none;}
+a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;}
+a:link:after, a:visited:after {content:" (" attr(href) ")";font-size:90%;}
\ No newline at end of file
diff --git a/public/css/screen.css b/public/css/screen.css
new file mode 100644
index 0000000..518685c
--- /dev/null
+++ b/public/css/screen.css
@@ -0,0 +1,257 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 0.9
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* reset.css */
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
+body {line-height:1.5;}
+table {border-collapse:separate;border-spacing:0;}
+caption, th, td {text-align:left;font-weight:normal;}
+table, td, th {vertical-align:middle;}
+blockquote:before, blockquote:after, q:before, q:after {content:"";}
+blockquote, q {quotes:"" "";}
+a img {border:none;}
+
+/* typography.css */
+html {font-size:100.01%;}
+body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;}
+h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
+h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
+h2 {font-size:2em;margin-bottom:0.75em;}
+h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
+h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;}
+h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
+h6 {font-size:1em;font-weight:bold;}
+h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;}
+p {margin:0 0 1.5em;}
+p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
+p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
+a:focus, a:hover {color:#000;}
+a {color:#009;text-decoration:underline;}
+blockquote {margin:1.5em;color:#666;font-style:italic;}
+strong {font-weight:bold;}
+em, dfn {font-style:italic;}
+dfn {font-weight:bold;}
+sup, sub {line-height:0;}
+abbr, acronym {border-bottom:1px dotted #666;}
+address {margin:0 0 1.5em;font-style:italic;}
+del {color:#666;}
+pre {margin:1.5em 0;white-space:pre;}
+pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;}
+li ul, li ol {margin:0;}
+ul, ol {margin:0 1.5em 1.5em 0;padding-left:3.333em;}
+ul {list-style-type:disc;}
+ol {list-style-type:decimal;}
+dl {margin:0 0 1.5em 0;}
+dl dt {font-weight:bold;}
+dd {margin-left:1.5em;}
+table {margin-bottom:1.4em;width:100%;}
+th {font-weight:bold;}
+thead th {background:#c3d9ff;}
+th, td, caption {padding:4px 10px 4px 5px;}
+tr.even td {background:#e5ecf9;}
+tfoot {font-style:italic;}
+caption {background:#eee;}
+.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;}
+.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;}
+.hide {display:none;}
+.quiet {color:#666;}
+.loud {color:#000;}
+.highlight {background:#ff0;}
+.added {background:#060;color:#fff;}
+.removed {background:#900;color:#fff;}
+.first {margin-left:0;padding-left:0;}
+.last {margin-right:0;padding-right:0;}
+.top {margin-top:0;padding-top:0;}
+.bottom {margin-bottom:0;padding-bottom:0;}
+
+/* forms.css */
+label {font-weight:bold;}
+fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;}
+legend {font-weight:bold;font-size:1.2em;}
+input[type=text], input[type=password], input.text, input.title, textarea, select {background-color:#fff;border:1px solid #bbb;}
+input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus, select:focus {border-color:#666;}
+input[type=text], input[type=password], input.text, input.title, textarea, select {margin:0.5em 0;}
+input.text, input.title {width:300px;padding:5px;}
+input.title {font-size:1.5em;}
+textarea {width:390px;height:250px;padding:5px;}
+input[type=checkbox], input[type=radio], input.checkbox, input.radio {position:relative;top:.25em;}
+form.inline {line-height:3;}
+form.inline p {margin-bottom:0;}
+.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;}
+.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
+.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;}
+.success {background:#E6EFC2;color:#264409;border-color:#C6D880;}
+.error a {color:#8a1f11;}
+.notice a {color:#514721;}
+.success a {color:#264409;}
+
+/* grid.css */
+.container {width:710px;margin:0 auto;}
+.showgrid {background:url(src/grid.png);}
+.column, div.span-1, div.span-2, div.span-3, div.span-4, div.span-5, div.span-6, div.span-7, div.span-8, div.span-9, div.span-10, div.span-11, div.span-12, div.span-13, div.span-14, div.span-15, div.span-16, div.span-17, div.span-18, div.span-19, div.span-20, div.span-21, div.span-22, div.span-23, div.span-24 {float:left;margin-right:10px;}
+.last, div.last {margin-right:0;}
+.span-1 {width:20px;}
+.span-2 {width:50px;}
+.span-3 {width:80px;}
+.span-4 {width:110px;}
+.span-5 {width:140px;}
+.span-6 {width:170px;}
+.span-7 {width:200px;}
+.span-8 {width:230px;}
+.span-9 {width:260px;}
+.span-10 {width:290px;}
+.span-11 {width:320px;}
+.span-12 {width:350px;}
+.span-13 {width:380px;}
+.span-14 {width:410px;}
+.span-15 {width:440px;}
+.span-16 {width:470px;}
+.span-17 {width:500px;}
+.span-18 {width:530px;}
+.span-19 {width:560px;}
+.span-20 {width:590px;}
+.span-21 {width:620px;}
+.span-22 {width:650px;}
+.span-23 {width:680px;}
+.span-24, div.span-24 {width:710px;margin-right:0;}
+input.span-1, textarea.span-1, input.span-2, textarea.span-2, input.span-3, textarea.span-3, input.span-4, textarea.span-4, input.span-5, textarea.span-5, input.span-6, textarea.span-6, input.span-7, textarea.span-7, input.span-8, textarea.span-8, input.span-9, textarea.span-9, input.span-10, textarea.span-10, input.span-11, textarea.span-11, input.span-12, textarea.span-12, input.span-13, textarea.span-13, input.span-14, textarea.span-14, input.span-15, textarea.span-15, input.span-16, textarea.span-16, input.span-17, textarea.span-17, input.span-18, textarea.span-18, input.span-19, textarea.span-19, input.span-20, textarea.span-20, input.span-21, textarea.span-21, input.span-22, textarea.span-22, input.span-23, textarea.span-23, input.span-24, textarea.span-24 {border-left-width:1px!important;border-right-width:1px!important;padding-left:5px!important;padding-right:5px!important;}
+input.span-1, textarea.span-1 {width:8px!important;}
+input.span-2, textarea.span-2 {width:38px!important;}
+input.span-3, textarea.span-3 {width:68px!important;}
+input.span-4, textarea.span-4 {width:98px!important;}
+input.span-5, textarea.span-5 {width:128px!important;}
+input.span-6, textarea.span-6 {width:158px!important;}
+input.span-7, textarea.span-7 {width:188px!important;}
+input.span-8, textarea.span-8 {width:218px!important;}
+input.span-9, textarea.span-9 {width:248px!important;}
+input.span-10, textarea.span-10 {width:278px!important;}
+input.span-11, textarea.span-11 {width:308px!important;}
+input.span-12, textarea.span-12 {width:338px!important;}
+input.span-13, textarea.span-13 {width:368px!important;}
+input.span-14, textarea.span-14 {width:398px!important;}
+input.span-15, textarea.span-15 {width:428px!important;}
+input.span-16, textarea.span-16 {width:458px!important;}
+input.span-17, textarea.span-17 {width:488px!important;}
+input.span-18, textarea.span-18 {width:518px!important;}
+input.span-19, textarea.span-19 {width:548px!important;}
+input.span-20, textarea.span-20 {width:578px!important;}
+input.span-21, textarea.span-21 {width:608px!important;}
+input.span-22, textarea.span-22 {width:638px!important;}
+input.span-23, textarea.span-23 {width:668px!important;}
+input.span-24, textarea.span-24 {width:698px!important;}
+.append-1 {padding-right:30px;}
+.append-2 {padding-right:60px;}
+.append-3 {padding-right:90px;}
+.append-4 {padding-right:120px;}
+.append-5 {padding-right:150px;}
+.append-6 {padding-right:180px;}
+.append-7 {padding-right:210px;}
+.append-8 {padding-right:240px;}
+.append-9 {padding-right:270px;}
+.append-10 {padding-right:300px;}
+.append-11 {padding-right:330px;}
+.append-12 {padding-right:360px;}
+.append-13 {padding-right:390px;}
+.append-14 {padding-right:420px;}
+.append-15 {padding-right:450px;}
+.append-16 {padding-right:480px;}
+.append-17 {padding-right:510px;}
+.append-18 {padding-right:540px;}
+.append-19 {padding-right:570px;}
+.append-20 {padding-right:600px;}
+.append-21 {padding-right:630px;}
+.append-22 {padding-right:660px;}
+.append-23 {padding-right:690px;}
+.prepend-1 {padding-left:30px;}
+.prepend-2 {padding-left:60px;}
+.prepend-3 {padding-left:90px;}
+.prepend-4 {padding-left:120px;}
+.prepend-5 {padding-left:150px;}
+.prepend-6 {padding-left:180px;}
+.prepend-7 {padding-left:210px;}
+.prepend-8 {padding-left:240px;}
+.prepend-9 {padding-left:270px;}
+.prepend-10 {padding-left:300px;}
+.prepend-11 {padding-left:330px;}
+.prepend-12 {padding-left:360px;}
+.prepend-13 {padding-left:390px;}
+.prepend-14 {padding-left:420px;}
+.prepend-15 {padding-left:450px;}
+.prepend-16 {padding-left:480px;}
+.prepend-17 {padding-left:510px;}
+.prepend-18 {padding-left:540px;}
+.prepend-19 {padding-left:570px;}
+.prepend-20 {padding-left:600px;}
+.prepend-21 {padding-left:630px;}
+.prepend-22 {padding-left:660px;}
+.prepend-23 {padding-left:690px;}
+div.border {padding-right:4px;margin-right:5px;border-right:1px solid #eee;}
+div.colborder {padding-right:19px;margin-right:20px;border-right:1px solid #eee;}
+.pull-1 {margin-left:-30px;}
+.pull-2 {margin-left:-60px;}
+.pull-3 {margin-left:-90px;}
+.pull-4 {margin-left:-120px;}
+.pull-5 {margin-left:-150px;}
+.pull-6 {margin-left:-180px;}
+.pull-7 {margin-left:-210px;}
+.pull-8 {margin-left:-240px;}
+.pull-9 {margin-left:-270px;}
+.pull-10 {margin-left:-300px;}
+.pull-11 {margin-left:-330px;}
+.pull-12 {margin-left:-360px;}
+.pull-13 {margin-left:-390px;}
+.pull-14 {margin-left:-420px;}
+.pull-15 {margin-left:-450px;}
+.pull-16 {margin-left:-480px;}
+.pull-17 {margin-left:-510px;}
+.pull-18 {margin-left:-540px;}
+.pull-19 {margin-left:-570px;}
+.pull-20 {margin-left:-600px;}
+.pull-21 {margin-left:-630px;}
+.pull-22 {margin-left:-660px;}
+.pull-23 {margin-left:-690px;}
+.pull-24 {margin-left:-720px;}
+.pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;}
+.push-1 {margin:0 -30px 1.5em 30px;}
+.push-2 {margin:0 -60px 1.5em 60px;}
+.push-3 {margin:0 -90px 1.5em 90px;}
+.push-4 {margin:0 -120px 1.5em 120px;}
+.push-5 {margin:0 -150px 1.5em 150px;}
+.push-6 {margin:0 -180px 1.5em 180px;}
+.push-7 {margin:0 -210px 1.5em 210px;}
+.push-8 {margin:0 -240px 1.5em 240px;}
+.push-9 {margin:0 -270px 1.5em 270px;}
+.push-10 {margin:0 -300px 1.5em 300px;}
+.push-11 {margin:0 -330px 1.5em 330px;}
+.push-12 {margin:0 -360px 1.5em 360px;}
+.push-13 {margin:0 -390px 1.5em 390px;}
+.push-14 {margin:0 -420px 1.5em 420px;}
+.push-15 {margin:0 -450px 1.5em 450px;}
+.push-16 {margin:0 -480px 1.5em 480px;}
+.push-17 {margin:0 -510px 1.5em 510px;}
+.push-18 {margin:0 -540px 1.5em 540px;}
+.push-19 {margin:0 -570px 1.5em 570px;}
+.push-20 {margin:0 -600px 1.5em 600px;}
+.push-21 {margin:0 -630px 1.5em 630px;}
+.push-22 {margin:0 -660px 1.5em 660px;}
+.push-23 {margin:0 -690px 1.5em 690px;}
+.push-24 {margin:0 -720px 1.5em 720px;}
+.push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;}
+.prepend-top {margin-top:1.5em;}
+.append-bottom {margin-bottom:1.5em;}
+.box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;}
+hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;}
+hr.space {background:#fff;color:#fff;visibility:hidden;}
+.clearfix:after, .container:after {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;}
+.clearfix, .container {display:block;}
+.clear {clear:both;}
\ No newline at end of file
|
jtietema/Fizzy
|
52a8ee4322f5f9c33484835892991112e7d5b669
|
MySQL schema and some fixes in SQLite backend
|
diff --git a/application/library/Fizzy/Storage/Backend/Sqlite.php b/application/library/Fizzy/Storage/Backend/Sqlite.php
index 808f950..e0bcb79 100644
--- a/application/library/Fizzy/Storage/Backend/Sqlite.php
+++ b/application/library/Fizzy/Storage/Backend/Sqlite.php
@@ -1,58 +1,58 @@
<?php
/**
* Class Fizzy_Storage_Backend_Sqlite
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Pdo */
require_once 'Fizzy/Storage/Backend/Pdo.php';
/**
* Storage backend based on PDO_SQLite
*
* @author Jeroen Tietema <[email protected]>
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage_Backend_Sqlite extends Fizzy_Storage_Backend_Pdo
{
/**
* Constructor. Will check the dsn for relative paths and prefix them with
* the application base path.
* @param array $options
*/
public function __construct($options = array())
{
parent::__construct($options);
$dsn = $this->getDsn();
list($protocol, $dataPath) = explode(':', $dsn);
// Change path to system directory separator
$dataPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $dataPath);
// Add a trailing slash
$dataPath = rtrim($dataPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
// Check if path is relative within the web application root
if(0 !== strpos($dataPath, DIRECTORY_SEPARATOR))
{
- $basePath = Fizzy_Config::getInstance()->getSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath');
+ $basePath = Fizzy::getInstance()->getSectionValue(Fizzy::SECTION_APPLICATION, 'basePath');
$dataPath = $basePath . $dataPath;
}
// Set the dsn with the corrected absolute or relative path
$this->setDsn($protocol . ':' . $dataPath);
}
-}
\ No newline at end of file
+}
diff --git a/data/database.sql b/data/database.sql
new file mode 100644
index 0000000..230987f
--- /dev/null
+++ b/data/database.sql
@@ -0,0 +1,20 @@
+CREATE TABLE user (
+ id int(10) NOT NULL AUTO_INCREMENT,
+ username VARCHAR(255) NOT NULL,
+ password VARCHAR(255) NOT NULL,
+ encryption VARCHAR(25) NULL,
+ PRIMARY KEY (id)
+ );
+
+INSERT INTO user (username, password, encryption) VALUES
+('admin','admin',NULL),
+('jeroen','324905aefb58c08771149a326741025c', 'md5');
+
+CREATE TABLE page (
+ id int(10) NOT NULL AUTO_INCREMENT,
+ title VARCHAR(255) NULL,
+ slug VARCHAR(255) NOT NULL,
+ body TEXT NULL,
+ homepage TINYINT(1),
+ PRIMARY KEY (id)
+ );
|
jtietema/Fizzy
|
e899d13e6c283d1686ca48c21e1419e323cbb9b4
|
Layouts loaded based on requested module
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index 02b2e34..9b18e32 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -1,642 +1,634 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Fizzy application class. Takes care of gathering all configuration,
* bootstrapping and dispatching requests.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
- 'view' => null,
+# 'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
- 'defaultLayout' => 'fizzy',
+ 'defaultLayout' => 'default',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'admin_media_gallery' => array(
'route' => '/fizzy/media/gallery',
'defaults' => array(
'controller' => 'media',
'action' => 'gallery',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/logout',
'defaults' => array (
'controller' => 'auth',
'action' => 'logout',
'module' => 'admin'
)
),
'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/login',
'defaults' => array (
'controller' => 'auth',
'action' => 'login',
'module' => 'admin'
)
),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
- 'custom' => 'custom/controllers',
),
'models' => 'application/models',
- 'views' => array(
- 'fizzy' => 'application/views',
- 'custom' => 'custom/views'
- ),
- 'layouts' => array(
- 'fizzy' => 'application/layouts',
- 'custom' => 'custom/layouts',
- ),
'templates' => array (
'fizzy' => 'application/templates',
- 'custom' => 'custom/templates'
),
'assets' => 'application/assets',
'configs' => 'configs',
- 'custom' => 'custom',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
$storage = null;
if(isset($this->_config->storage)) {
$storage = new Fizzy_Storage($this->_config->storage->toArray());
Zend_Registry::set('storage', $storage);
}
return $storage;
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
- $layoutPaths = $this->getPath('layouts');
- $layout = new Zend_Layout($layoutPaths['fizzy'], true);
- $layout->setLayout($this->_config->application->defaultLayout);
-
+ $layout = Zend_Layout::startMvc(array (
+ 'layout' => 'default',
+ ));
+
+ $front = $this->getFrontController();
+ $front->registerPlugin(new Fizzy_Layout_ControllerPlugin());
+
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
diff --git a/application/library/Fizzy/Bootstrap.php b/application/library/Fizzy/Bootstrap.php
deleted file mode 100644
index 1e438a7..0000000
--- a/application/library/Fizzy/Bootstrap.php
+++ /dev/null
@@ -1,567 +0,0 @@
-<?php
-
-/** Zend_Config */
-require_once 'Zend/Config.php';
-
-/**
- * Bootstrap class for Fizzy.
- *
- * @todo find a better way to support environments
- *
- * @author Mattijs Hoitink <[email protected]>
- */
-class Fizzy_Bootstrap
-{
-
- /**
- * The bootstrap stages in order of execution and their return values.
- * @var array
- */
- protected $_bootstrap = array (
- 'autoLoader' => null,
- 'registry' => null,
-# 'logger' => null,
- 'session' => null,
- 'frontController' => null,
- 'router' => null,
- 'storage' => null,
- 'view' => null,
- 'layout' => null,
- );
-
- /**
- * The final configuration for Fizzy created from merging the default
- * configuration with the custom configuration.
- * @var Zend_Config
- */
- protected $_config = null;
-
- /**
- * Default Fizzy config
- * @var array
- */
- protected $_defaultConfig = array (
- 'application' => array(
- 'title' => 'Fizzy',
- 'basePath' => '',
- 'defaultLayout' => 'fizzy',
- 'defaultTemplate' => 'page.phtml',
- 'defaultController' => 'index',
- 'defaultAction' => 'index',
- ),
- 'routes' => array (
- # Catch all for pages slugs
- 'page_by_slug' => array (
- 'route' => '/:slug',
- 'defaults' => array (
- 'controller' => 'pages',
- 'action' => 'slug'
- )
- ),
- # Admin pages control
- 'admin_pages' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/fizzy/pages',
- 'defaults' => array (
- 'controller' => 'pages',
- 'action' => 'index',
- 'module' => 'admin'
- )
- ),
- 'admin_pages_add' => array(
- 'route' => '/fizzy/pages/add',
- 'defaults' => array (
- 'controller' => 'pages',
- 'action' => 'add',
- 'module' => 'admin'
- )
- ),
- 'admin_pages_edit' => array(
- 'route' => '/fizzy/pages/edit/:id',
- 'defaults' => array (
- 'controller' => 'pages',
- 'action' => 'edit',
- 'module' => 'admin'
- )
- ),
- 'admin_pages_delete' => array(
- 'route' => '/fizzy/pages/delete/:id',
- 'defaults' => array (
- 'controller' => 'pages',
- 'action' => 'delete',
- 'module' => 'admin'
- )
- ),
- # Admin media
- /*'admin_media_delete' => array(
- 'route' => '/admin/media/delete/:name',
- 'defaults' => array (
- 'controller' => 'admin_media',
- 'action' => 'delete'
- )
- ),*/
- 'admin_media' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/fizzy/media',
- 'defaults' => array (
- 'controller' => 'media',
- 'module' => 'admin'
- )
- ),
- # Admin users
- /*'admin_users' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'rule' => '/admin/users',
- 'defaults' => array (
- 'controller' => 'admin_users',
- 'action' => 'index'
- )
- ),*/
- /*'admin_users_add' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'rule' => '/admin/users/add',
- 'defaults' => array (
- 'controller' => 'admin_users',
- 'action' => 'add'
- )
- ),*/
- /*'admin_users_edit' => array(
- 'rule' => '/admin/users/edit/:id',
- 'defaults' => array (
- 'controller' => 'admin_users',
- 'action' => 'edit'
- )
- ),*/
- /*'admin_users_delete' => array(
- 'rule' => '/admin/users/delete/:id',
- 'defaults' => array (
- 'controller' => 'admin_users',
- 'action' => 'delete'
- )
- ),*/
- # Static admin routes
- /*'admin_configuration' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/admin/configuration',
- 'defaults' => array (
- 'controller' => 'admin',
- 'action' => 'configuration'
- )
- ),*/
- /*'admin_logout' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/admin/logout',
- 'defaults' => array (
- 'controller' => 'admin',
- 'action' => 'logout'
- )
- ),*/
- /*'admin_login' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/admin/login',
- 'defaults' => array (
- 'controller' => 'admin',
- 'action' => 'login'
- )
- ),*/
- 'admin' => array (
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/fizzy',
- 'defaults' => array (
- 'controller' => 'index',
- 'action' => 'index',
- 'module' => 'admin'
- )
- ),
- ),
- 'paths' => array(
- 'application' => 'application',
- 'controllers' => array (
- 'default' => 'application/modules/default/controllers',
- 'admin' => 'application/modules/admin/controllers',
- 'custom' => 'custom/controllers',
- ),
- 'models' => 'application/models',
- 'views' => array(
- 'fizzy' => 'application/views',
- 'custom' => 'custom/views'
- ),
- 'layouts' => array(
- 'fizzy' => 'application/layouts',
- 'custom' => 'custom/layouts',
- ),
- 'templates' => array (
- 'fizzy' => 'application/templates',
- 'custom' => 'custom/templates'
- ),
- 'assets' => 'application/assets',
- 'configs' => 'configs',
- 'custom' => 'custom',
- 'data' => 'data',
- 'log' => 'data/fizzy.log',
- 'library' => 'library',
- 'public' => 'public',
- 'uploads' => 'public/uploads',
- ),
- );
-
- /**
- * The environment to run the application in.
- * @var string
- */
- protected $_environment = 'production';
-
- /** **/
-
- /**
- * Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
- * to override or complement the default configuration.
- * @param mixed $config
- * @param string $environment
- */
- public function __construct($config = null, $environment = 'production')
- {
- $finalConfig = new Zend_Config($this->_defaultConfig, true);
- # Set default basePath in case none is available in the custom config
- $finalConfig->application->basePath = realpath(dirname(__FILE__) . '/../../../');
-
- # Merge the custom configuration with the defaults
- if(null !== $config) {
- if(is_array($config)) {
- $customConfig = new Zend_Config($config);
- }
- else if($config instanceof Zend_Config) {
- $customConfig = $config;
- }
- else if(is_string($config)) {
- $customConfig = $this->_loadConfigFromFile($config);
- }
- $finalConfig = $finalConfig->merge($customConfig);
- unset($customConfig, $config);
- }
- $this->_config = $finalConfig;
-
- # Correct realtive paths in config
- $paths = $this->_correctPaths($this->_config->paths->toArray());
- $this->_config->paths = new Zend_Config($paths, true);
- unset($paths);
-
- # Load a clean PHP environment
- $this->_environment = $environment;
- $this->_loadEnvironment();
- }
-
- /**
- * Loads configuration from a file. INI and XML files are supported through
- * Zend_Config_Ini and Zend_Config_XML.
- * @param string $path
- * @return Zend_Config
- */
- protected function _loadConfigFromFile($path)
- {
- if(!is_file($path) || !is_readable($path)) {
- require_once 'Fizzy/Exception.php';
- throw new Fizzy_Exception('Could not read config from ' . $path);
- }
-
- # Check extension
- $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
- switch ($extension) {
- case 'ini':
- require_once 'Zend/Config/Ini.php';
- $config = new Zend_Config_Ini($path);
- break;
- case 'xml':
- require_once 'Zend/Config/Xml.php';
- $config = new Zend_Config_Xml($path);
- break;
- default:
- require_once 'Fizzy/Exception.php';
- throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
- }
-
- return $config;
- }
-
- /**
- * Corrects relative paths by prefixing them with the configured base path.
- *
- * @param array|string $value
- * @return array|string
- */
- protected function _correctPaths($value)
- {
- if(is_array($value)) {
- foreach($value as $childKey => $childValue) {
- $value[$childKey] = $this->_correctPaths($childValue);
- }
- }
- else {
- if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
- $value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
- }
- }
-
- return $value;
- }
-
- /**
- * Returns the configuration for Fizzy.
- * @return Zend_Config
- */
- public function getConfig()
- {
- return $this->_config;
- }
-
- /**
- * Shortcut to get a path by it's key from the configuration.
- * @param strubg $key
- * @return string|null
- */
- public function getPath($key)
- {
- $section = $this->_config->paths->get($key, null);
- if(null === $section) {
- return null;
- }
-
- if($section instanceof Zend_Config) {
- $section = $section->toArray();
- }
-
- return $section;
- }
-
- /**
- * Returns the bootstrap environment.
- * @return string
- */
- public function getEnvironment()
- {
- return $this->_environment;
- }
-
- /**
- * Initializes the PHP environment.
- */
- protected function _loadEnvironment()
- {
- # Strip all injected slashes by magic_quotes_gpc
- if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
- stripslashes_deep($_GET);
- stripslashes_deep($_POST);
- stripslashes_deep($_REQUEST);
- stripslashes_deep($_COOKIE);
- }
-
- if('development' === $this->_environment)
- {
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_errors', true);
- }
- else {
- error_reporting(0);
- ini_set('display_errors', false);
- }
- }
-
- /**
- * Recursively strip slashes from array values.
- * @param string $value
- * @return array|string
- */
- protected function _stripslashesDeep(&$value)
- {
- $value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
- return $value;
- }
-
- /**
- * Initializes the autoloader. The default namespaces registered are Zend_
- * and ZendX_. This stage adds the Fizzy_ namespace to that.
- * An Autoloader is added to the stack for Fizzy models.
- * @see Fizzy_Autoloader
- * @return Zend_Loader_Autoloader
- */
- protected function _initAutoLoader()
- {
- require_once 'Zend/Loader/Autoloader.php';
- $autoloader = Zend_Loader_Autoloader::getInstance();
- $autoloader->registerNamespace('Fizzy_');
-
- # Autoloading for models
- $autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
-
- return $autoloader;
- }
-
- /**
- * Registers a new Zend_Registry instance.
- * @return Zend_Registry
- */
- protected function _initRegistry()
- {
- $registry = Zend_Registry::getInstance();
- # Add config to the registry
- Zend_Registry::set('config', $this->_config);
-
- return $registry;
- }
-
- /**
- * Initializes a logger.
- * @todo implement with Zend_Log
- * @return Zend_Log
- */
- protected function _initLogger()
- {
-
- }
-
- protected function _initSession()
- {
- Zend_Session::start();
- return null;
- }
-
- /**
- * Initializes the front controller
- * @return Zend_Controller_Front
- */
- protected function _initFrontController()
- {
- $frontController = Zend_Controller_Front::getInstance();
-
- # Add configuration
- $frontController->setDefaultControllerName($this->_config->application->defaultController)
- ->setDefaultAction($this->_config->application->defaultAction);
-
- # Add module directory for Fizzy core
- $frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
-
- # Add custom folder as module
- $frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
-
- # Set error handling
- if('development' === $this->_environment) {
- # Allow exceptions and unregister the error handler plugin
- $frontController->throwExceptions(true);
- $frontController->unregisterPlugin('ErrorHandler');
- }
- else {
- $errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
- 'controller' => 'error',
- 'action' => 'error',
- 'module' => 'default'
- ));
- }
-
- return $frontController;
- }
-
- /**
- * Loads the configured routes into the router.
- * @return Zend_Router
- */
- protected function _initRouter()
- {
- $router = Zend_Controller_Front::getInstance()->getRouter();
-
- $routes = $this->_config->routes;
- $router->clearParams()
- ->addConfig($routes);
-
- return $router;
- }
-
- /**
- * Initializes the Fizzy storage backend
- * @return Fizzy_Storage
- */
- protected function _initStorage()
- {
- $storage = null;
- if(isset($this->_config->storage)) {
- $storage = new Fizzy_Storage($this->_config->storage->toArray());
- Zend_Registry::set('storage', $storage);
- }
-
- return $storage;
- }
-
- /**
- * Initializes a new view object and loads the view directories into it.
- * @return Zend_View
- */
- protected function _initView()
- {
- $view = new Zend_View();
- foreach($this->getPath('views') as $path) {
- $view->addBasePath($path);
- }
-
- $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
- $viewRenderer->setView($view);
- Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
-
- return $view;
- }
-
- /**
- * Starts Zend_Layout in MVC mode.
- * @todo add custom front controller plugin for layout allow multiple layouts
- * @return Zend_Layout
- */
- protected function _initLayout()
- {
- $layoutPaths = $this->getPath('layouts');
- $layout = new Zend_Layout($layoutPaths['fizzy'], true);
- $layout->setLayout($this->_config->application->defaultLayout);
-
- return $layout;
- }
-
- /**
- * Run the bootstrap sequence.
- * @param boolean $dispatch Dispatch immediately after bootstrapping is done.
- */
- public function run($dispatch = true)
- {
- # Run the bootstrap sequence
- foreach($this->_bootstrap as $stage => $value) {
- $methodName = '_init' . ucfirst($stage);
- if(is_callable(array($this, $methodName))) {
- $this->_bootstrap[$stage] = $this->$methodName();
- }
- }
-
- # Dispatch the request
- if($dispatch) {
- $this->_bootstrap['frontController']->dispatch();
- }
- }
-
- /**
- * Catch getXYZ calls and check if the result of a bootstrap stage is
- * requested.
- * @param string $name
- * @param array $arguments
- * @return mixed
- */
- public function __call($name, $arguments)
- {
- if(0 === strpos($name, 'get')) {
- # Strip get from the method name
- $step = str_replace('get', '', $name);
- # Lowercase the first character
- $step = strtolower(substr($step, 0, 1)) . substr($step, 1);
-
- # Search for the bootstrap step
- if(array_key_exists($step, $this->_bootstrap)) {
- return $this->_bootstrap[$step];
- }
- }
- }
-
-}
diff --git a/application/library/Fizzy/Layout/ControllerPlugin.php b/application/library/Fizzy/Layout/ControllerPlugin.php
new file mode 100644
index 0000000..9e0d24f
--- /dev/null
+++ b/application/library/Fizzy/Layout/ControllerPlugin.php
@@ -0,0 +1,23 @@
+<?php
+
+/** Zend_Controller_Plugin_Abstract */
+require_once 'Zend/Controller/Plugin/Abstract.php';
+
+class Fizzy_Layout_ControllerPlugin extends Zend_Controller_Plugin_Abstract
+{
+
+ public function preDispatch(Zend_Controller_Request_Abstract $request)
+ {
+ $moduleName = $this->getRequest()->getModuleName();
+ if(empty($moduleName)) {
+ $moduleName = 'default';
+ }
+
+ $layoutPath = Fizzy::getInstance()->getPath('application') . '/modules/' . $moduleName . '/views/layouts/';
+
+ $layout = Zend_Layout::getMvcInstance();
+
+ $layout->setLayoutPath($layoutPath);
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/admin/views/layouts/default.phtml b/application/modules/admin/views/layouts/default.phtml
new file mode 100644
index 0000000..f074cde
--- /dev/null
+++ b/application/modules/admin/views/layouts/default.phtml
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Fizzy layout
+ * @package Fizzy
+ * @subpackage Views
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+ ?>
+ <!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">
+ <head>
+ <title>Fizzy</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ <script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
+ <script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
+ <script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
+ </head>
+ <body>
+ <div id="header">
+ <div class="container">
+ <div id="navigation" class="span-24 last">
+ <ul>
+ <li><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
+ <li><a href="<?= $this->baseUrl("/fizzy/media") ?>">Media</a></li>
+ <li><a href="<?= $this->baseUrl("/fizzy/users") ?>">Users</a></li>
+ <li><a href="<?= $this->baseUrl("/fizzy/configuration") ?>">Configuration</a></li>
+ <li class="link-logout"><a href="<?= $this->baseUrl("/fizzy/logout") ?>">Logout</a></li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+
+ <?= $this->render('flashMessages.phtml'); ?>
+
+ <div id="content" class="span-24 last content-container">
+ <div id="content-wrapper">
+ <?= $this->layout()->content; ?>
+ </div>
+ </div>
+
+ <div id="footer" class="span-24 last">
+ (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
+ </div>
+ </div>
+
+ <div class="clear"></div>
+ </body>
+</html>
diff --git a/application/modules/default/views/layouts/default.phtml b/application/modules/default/views/layouts/default.phtml
new file mode 100644
index 0000000..e69de29
|
jtietema/Fizzy
|
726864f8b9bf633e2643ffe2aa4d88c558b4259b
|
Style update for flashmessages
|
diff --git a/application/assets/css/fizzy.css b/application/assets/css/fizzy.css
index 2109d82..77d67fd 100644
--- a/application/assets/css/fizzy.css
+++ b/application/assets/css/fizzy.css
@@ -1,363 +1,363 @@
@import 'screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
.error, .notice, .success, .info { padding: .8em; margin-bottom: 1em; border: 2px solid #ddd; }
.error { background: #FBE3E4; color: #8a1f11; border-color: #FBC2C4; }
.notice { background: #FFF6BF; color: #514721; border-color: #FFD324; }
.success { background: #E6EFC2; color: #264409; border-color: #C6D880; }
.info { background: #648ADC; color: #193D88; border-color: #1B51C2; }
.error a { color: #8a1f11; }
.notice a { color: #514721; }
.success a { color: #264409; }
.info a { color: #193D88; }
#messages {
- min-height: 2em;
+ min-height: 3.75em;
line-height: 2em;
margin: 1em 0 0 0;
}
#messages ul {
margin: 0 0 0 1em;
}
#messages .message {
margin: 0 0 1em 8px;
padding: 2px 0;
background-repeat: no-repeat;
background-position: 8px 6px;
position: relative;
}
.message-close {
position: absolute;
right: 10px;
top: 6px;
}
#messages .info {
background-image: url('../images/icon/sign_info.png');
}
#messages .success {
background-image: url('../images/icon/sign_tick.png');
}
#messages .warning {
background-image: url('../images/icon/sign_warning.png');
}
#messages .error {
background-image: url('../images/icon/sign_error.png');
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
display: block;
color: #555555;
font-weight: bold;
}
.form-container dt {
padding: 0.5em 0.5em 0 0.5em;
}
.form-container dd {
margin: 0;
padding: 0 .5em .5em .5em;
border-bottom: 1px #CCCCCC dotted;
}
.form-container p.hint {
margin-bottom: 0;
font-size: .8em;
}
.form-container #submit-label { display: none; }
.form-container #submit-element {
border: 0;
padding: 0.5em;
}
.form-container textarea {
width: 99%;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
height: 3.1em;
background: #2E3132 url('/images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
#content {
line-height: 1.7em;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
|
jtietema/Fizzy
|
f619628706979a3861206c04b64ccf575cfb76fe
|
Flash message support
|
diff --git a/application/assets/css/fizzy.css b/application/assets/css/fizzy.css
index 6c1ab8a..2109d82 100644
--- a/application/assets/css/fizzy.css
+++ b/application/assets/css/fizzy.css
@@ -1,346 +1,363 @@
@import 'screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
+.error, .notice, .success, .info { padding: .8em; margin-bottom: 1em; border: 2px solid #ddd; }
+.error { background: #FBE3E4; color: #8a1f11; border-color: #FBC2C4; }
+.notice { background: #FFF6BF; color: #514721; border-color: #FFD324; }
+.success { background: #E6EFC2; color: #264409; border-color: #C6D880; }
+.info { background: #648ADC; color: #193D88; border-color: #1B51C2; }
+.error a { color: #8a1f11; }
+.notice a { color: #514721; }
+.success a { color: #264409; }
+.info a { color: #193D88; }
+
#messages {
min-height: 2em;
line-height: 2em;
- margin: 1em 0;
+ margin: 1em 0 0 0;
}
#messages ul {
margin: 0 0 0 1em;
}
-.message {
- margin: 0 0 0 4px;
+#messages .message {
+ margin: 0 0 1em 8px;
padding: 2px 0;
background-repeat: no-repeat;
background-position: 8px 6px;
+ position: relative;
+}
+.message-close {
+ position: absolute;
+ right: 10px;
+ top: 6px;
}
-.message .info {
+
+#messages .info {
background-image: url('../images/icon/sign_info.png');
}
-.message .success {
+#messages .success {
background-image: url('../images/icon/sign_tick.png');
}
-.message .warning {
+#messages .warning {
background-image: url('../images/icon/sign_warning.png');
}
-.message .error {
+#messages .error {
background-image: url('../images/icon/sign_error.png');
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
display: block;
color: #555555;
font-weight: bold;
}
.form-container dt {
padding: 0.5em 0.5em 0 0.5em;
}
.form-container dd {
margin: 0;
padding: 0 .5em .5em .5em;
border-bottom: 1px #CCCCCC dotted;
}
.form-container p.hint {
margin-bottom: 0;
font-size: .8em;
}
.form-container #submit-label { display: none; }
.form-container #submit-element {
border: 0;
padding: 0.5em;
}
.form-container textarea {
width: 99%;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
height: 3.1em;
background: #2E3132 url('/images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
#content {
line-height: 1.7em;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
diff --git a/application/layouts/fizzy.phtml b/application/layouts/fizzy.phtml
index 4ed02a1..f074cde 100644
--- a/application/layouts/fizzy.phtml
+++ b/application/layouts/fizzy.phtml
@@ -1,69 +1,65 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!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">
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="header">
<div class="container">
<div id="navigation" class="span-24 last">
<ul>
<li><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/media") ?>">Media</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/users") ?>">Users</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/configuration") ?>">Configuration</a></li>
<li class="link-logout"><a href="<?= $this->baseUrl("/fizzy/logout") ?>">Logout</a></li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>
<div class="container">
- <div id="messages" class="span-24 last">
- <div class="message">
- <?= $this->fizzyMessages(); ?>
- </div>
- </div>
+ <?= $this->render('flashMessages.phtml'); ?>
<div id="content" class="span-24 last content-container">
<div id="content-wrapper">
<?= $this->layout()->content; ?>
</div>
</div>
<div id="footer" class="span-24 last">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
</div>
<div class="clear"></div>
</body>
</html>
diff --git a/application/library/Fizzy/Validate/SlugUnique.php b/application/library/Fizzy/Validate/SlugUnique.php
index 133311d..06f3f52 100644
--- a/application/library/Fizzy/Validate/SlugUnique.php
+++ b/application/library/Fizzy/Validate/SlugUnique.php
@@ -1,73 +1,73 @@
<?php
/**
* Class Fizzy_Validate_SlugUnique
* @category Fizzy
* @package Fizzy_Validate
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
* Form validator to check if a page slug is unique. Advises the Fizzy_Storage
* to check this.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Validate_SlugUnique extends Zend_Validate_Abstract
{
const NOT_UNIQUE = 'notUnique';
protected $_messageTemplates = array (
self::NOT_UNIQUE => 'Slug is not unique.'
);
/** **/
/**
* Check if a username is valid (unique).
* @param string $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
$storage = Fizzy::getInstance()->getStorage();
$pages = $storage->fetchAll('Page');
$slugs = array();
foreach($pages as $page) {
$slugs[$page->getId()] = $page->slug;
}
# Check if we are editing the page the slug belongs to
$editingOriginal = false;
if(is_array($context) && isset($context['id'])) {
$id = $context['id'];
- if(array_key_exists($id, $slugs) && $value === $slugs[$id]) {
+ if(array_key_exists($id, $slugs) && $value == $slugs[$id]) {
$editingOriginal = true;
}
}
if(in_array($value, $slugs) && !$editingOriginal) {
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index e786601..08e698d 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,169 +1,176 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$storage = Zend_Registry::get('storage');
$pages = $storage->fetchAll('Page');
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage = Zend_Registry::get('storage');
$storage->persist($page);
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page->getId()), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage->persist($page);
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null !== $page) {
$storage->delete($page);
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$formConfig = array (
'action' => $action,
'elements' => array (
+ 'id' => array (
+ 'type' => 'hidden',
+ 'options' => array (
+ 'required' => false,
+ 'value' => $page->getId(),
+ )
+ ),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
$form = new Fizzy_Form();
$form->setOptions($formConfig);
return $form;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/views/helpers/FizzyMessages.php b/application/modules/admin/views/helpers/FizzyMessages.php
index b2257b6..b2c2039 100644
--- a/application/modules/admin/views/helpers/FizzyMessages.php
+++ b/application/modules/admin/views/helpers/FizzyMessages.php
@@ -1,68 +1,70 @@
<?php
/**
* Checks the session for message placed by Fizzy.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Admin_View_Helper_FizzyMessages extends Zend_View_Helper_Abstract
{
protected $_translator = null;
/**
* A formatted list of status messages from Fizzy.
* @return string
*/
public function fizzyMessages($translator = null)
{
$this->_translator = $translator;
$output = '';
$messages = $this->_getMessages();
if(0 < $messages) {
$statusMessages = array();
# Filter out the Fizzy messages
foreach($messages as $message) {
if(is_array($message)) {
$statusMessages[$message['type']][] = $this->_translateMessage($message['message']);
}
}
# Format the messages for the statusses
foreach($statusMessages as $type => $messages) {
$output .= "<div class=\"message {$type}\">\n<ul>\n";
foreach($messages as $message) {
$output .= "<li>{$message}</li>\n";
}
- $output .= "\n</ul>\n</div>";
+
+ $output .= "\n</ul>\n";
+ $output .= "</div>";
}
}
return $output;
}
/**
* Gets the messages array from the Flash Messenger controller plugin.
* @return array
*/
protected function _getMessages()
{
return Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->getMessages();
}
/**
* Tries to translate a message with the provided translator.
* @param string $message
* @return string
*/
protected function _translateMessage($message)
{
if(null !== $this->_translator) {
$message = $this->_translator->_($message);
}
return $message;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/flashMessages.phtml b/application/modules/admin/views/scripts/flashMessages.phtml
new file mode 100644
index 0000000..4e7201c
--- /dev/null
+++ b/application/modules/admin/views/scripts/flashMessages.phtml
@@ -0,0 +1,23 @@
+<div id="messages" class="span-24 last">
+ <?= $this->fizzyMessages(); ?>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ $('#messages > .message').each(function(index, element) {
+ // Create a button
+ var button = $("<a></a>").attr('href','#').attr('class', 'message-close');
+ // Add close image to the button
+ var i = new Image();
+ $(i).attr('src', "<?= $this->baseUrl('/fizzy_assets/images/icon/cross.png'); ?>");
+ button.html(i);
+ // fade on click
+ button.click(function() {
+ $(element).slideUp('fast');
+ });
+
+ // Add the button to the container
+ $(element).append(button);
+ });
+ });
+
+ </script>
+</div>
|
jtietema/Fizzy
|
14cd3ef8eee9efdcab1ac485f1297e1f4d95b248
|
integrate wysiwyg into custom form element
|
diff --git a/application/assets/js/fizzy.js b/application/assets/js/fizzy.js
index e69de29..5b8482f 100644
--- a/application/assets/js/fizzy.js
+++ b/application/assets/js/fizzy.js
@@ -0,0 +1,39 @@
+var Fizzy = function(){
+ var _editors = [];
+
+ return {
+ "wysiwyg" : {
+ "count" : function(){
+ return _editors.length;
+ },
+ "register" : function(id){
+ _editors.push(id);
+ },
+ "editors" : function(){
+ return _editors;
+ },
+ "init" : function() {
+ // init all the editors
+ var editors = fizzy.wysiwyg.editors().join(",");
+ tinyMCE.init({
+ mode : "exact",
+ elements: editors,
+ theme : "advanced",
+ plugins: "fizzymedia",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_toolbar_align : "left",
+ theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo,fizzymedia",
+ theme_advanced_buttons2 : "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
+ theme_advanced_buttons3: "",
+ theme_advanced_statusbar_location : "bottom",
+ theme_advanced_resizing : true,
+ theme_advanced_resize_horizontal : false,
+ relative_urls : false
+ });
+ }
+ }
+ }
+}
+var fizzy = Fizzy();
+
+window.onload = fizzy.wysiwyg.init;
diff --git a/application/layouts/fizzy.phtml b/application/layouts/fizzy.phtml
index a54bdd2..4ed02a1 100644
--- a/application/layouts/fizzy.phtml
+++ b/application/layouts/fizzy.phtml
@@ -1,69 +1,69 @@
<?php
/**
* Fizzy layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!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">
<head>
<title>Fizzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="<?= $this->baseUrl("/fizzy_assets/js/jquery-1.3.2.min.js"); ?>"></script>
<script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/tiny_mce/tiny_mce.js'); ?>"></script>
- <script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/wysiwyg.js'); ?>"></script>
+ <script type="text/javascript" src="<?= $this->baseUrl('/fizzy_assets/js/fizzy.js'); ?>"></script>
</head>
<body>
<div id="header">
<div class="container">
<div id="navigation" class="span-24 last">
<ul>
<li><a href="<?= $this->baseUrl("/fizzy/pages") ?>">Pages</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/media") ?>">Media</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/users") ?>">Users</a></li>
<li><a href="<?= $this->baseUrl("/fizzy/configuration") ?>">Configuration</a></li>
<li class="link-logout"><a href="<?= $this->baseUrl("/fizzy/logout") ?>">Logout</a></li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>
<div class="container">
<div id="messages" class="span-24 last">
<div class="message">
<?= $this->fizzyMessages(); ?>
</div>
</div>
<div id="content" class="span-24 last content-container">
<div id="content-wrapper">
<?= $this->layout()->content; ?>
</div>
</div>
<div id="footer" class="span-24 last">
(c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
</div>
<div class="clear"></div>
</body>
</html>
diff --git a/application/library/Fizzy/Form.php b/application/library/Fizzy/Form.php
index ec7a609..405c54c 100644
--- a/application/library/Fizzy/Form.php
+++ b/application/library/Fizzy/Form.php
@@ -1,43 +1,42 @@
<?php
/**
* Class Fizzy_Form
* @category Fizzy
* @package Fizzy_Form
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Form */
require_once 'Zend/Form.php';
/**
* Fizzy form is an extension of the standard Zend_Form to load Fizzy
* form elements, decorators and validators.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Form extends Zend_Form
{
/**
* Hook into the init mehtod call to load Fizzy form elements, decorators and
* validators.
*/
public function init()
{
- $this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::ELEMENT);
- $this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::DECORATOR);
+ $this->addPrefixPath('Fizzy_Form', 'Fizzy/Form');
$this->addElementPrefixPath('Fizzy_Validate', 'Fizzy/Validate', 'validate');
$this->addElementPrefixPath('Fizzy_Filter', 'Fizzy/Filter', 'filter');
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/View/Helper/Wysiwyg.php b/application/library/Fizzy/View/Helper/Wysiwyg.php
index 2027247..d22280f 100644
--- a/application/library/Fizzy/View/Helper/Wysiwyg.php
+++ b/application/library/Fizzy/View/Helper/Wysiwyg.php
@@ -1,100 +1,100 @@
<?php
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a wysiwyg textarea element
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_View_Helper_Wysiwyg extends Zend_View_Helper_FormElement
{
/**
* The default number of rows for a textarea.
*
* @access public
*
* @var int
*/
public $rows = 24;
/**
* The default number of columns for a textarea.
*
* @access public
*
* @var int
*/
public $cols = 80;
public $_tinyMceConfig = array (
'mode' => "exact",
'elements' => "body",
'theme' => "advanced",
'theme_advanced_toolbar_location' => "top",
'theme_advanced_toolbar_align' => "left",
'theme_advanced_buttons1' => "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
'theme_advanced_buttons2' => "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
'theme_advanced_buttons3' => "",
'theme_advanced_statusbar_location' => "bottom",
'theme_advanced_resizing' => true,
'theme_advanced_resize_horizontal' => false
);
/**
* Generates a 'textarea' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function wysiwyg($name, $value = null, $attribs = null, $enabled = true)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
if ($disable) {
// disabled.
$disabled = ' disabled="disabled"';
}
// Make sure that there are 'rows' and 'cols' values
// as required by the spec. noted by Orjan Persson.
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
// build the element
$xhtml = '<div class="wysiwyg">'
. '<div class="wysiwyg-editor">'
. '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>'
. '</div>'
. '<div class="wysiwyg-toggle"></div>'
. '<script type="text/javascript">'
-
+ . 'fizzy.wysiwyg.register("body");'
. '</script>'
. '</div>';
return $xhtml;
}
}
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index 860218b..e786601 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,174 +1,169 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$storage = Zend_Registry::get('storage');
$pages = $storage->fetchAll('Page');
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage = Zend_Registry::get('storage');
$storage->persist($page);
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page->getId()), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage->persist($page);
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null !== $page) {
$storage->delete($page);
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$formConfig = array (
'action' => $action,
'elements' => array (
- 'id' => array (
- 'type' => 'hidden',
- 'options' => array (
- 'required' => false,
- 'value' => $page->getId()
- )
- ),
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
'filters' => array (
'slugify'
),
'validators' => array (
'slugUnique'
)
)
),
'body' => array (
- 'type' => 'textarea',
+ 'type' => 'wysiwyg',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
- return new Fizzy_Form(new Zend_Config($formConfig));
+ $form = new Fizzy_Form();
+ $form->setOptions($formConfig);
+ return $form;
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
3211be001327571db0ab0c874a8baaa3cd70ff9e
|
New Validator and Filter for page form
|
diff --git a/application/library/Fizzy/Filter/Slugify.php b/application/library/Fizzy/Filter/Slugify.php
new file mode 100644
index 0000000..34bd554
--- /dev/null
+++ b/application/library/Fizzy/Filter/Slugify.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Class Fizzy_Filter_Slugify
+ * @category Fizzy
+ * @package Fizzy_Filter
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Filter_Interface */
+require_once 'Zend/Filter/Interface.php';
+
+/**
+ * Filter to change a value to a slugified version. This replaces all non
+ * letters and digits by a '-'.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Filter_Slugify implements Zend_Filter_Interface
+{
+ /**
+ * Filters the value and returns a slugified version.
+ * @param string $value
+ */
+ public function filter($value)
+ {
+ # Replace all non letters or digits by -
+ $value = preg_replace('/\W+/', '-', $value);
+ $value = strtolower(trim($value, '-'));
+
+ return $value;
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Form.php b/application/library/Fizzy/Form.php
index db6d76d..ec7a609 100644
--- a/application/library/Fizzy/Form.php
+++ b/application/library/Fizzy/Form.php
@@ -1,42 +1,43 @@
<?php
/**
* Class Fizzy_Form
* @category Fizzy
* @package Fizzy_Form
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Form */
require_once 'Zend/Form.php';
/**
* Fizzy form is an extension of the standard Zend_Form to load Fizzy
* form elements, decorators and validators.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Form extends Zend_Form
{
/**
* Hook into the init mehtod call to load Fizzy form elements, decorators and
* validators.
*/
public function init()
{
$this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::ELEMENT);
$this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::DECORATOR);
$this->addElementPrefixPath('Fizzy_Validate', 'Fizzy/Validate', 'validate');
+ $this->addElementPrefixPath('Fizzy_Filter', 'Fizzy/Filter', 'filter');
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/SlugUnique.php b/application/library/Fizzy/Validate/SlugUnique.php
new file mode 100644
index 0000000..5f36e45
--- /dev/null
+++ b/application/library/Fizzy/Validate/SlugUnique.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Class Fizzy_Validate_SlugUnique
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/**
+ * Form validator to check if a page slug is unique. Advises the Fizzy_Storage
+ * to check this.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_SlugUnique extends Zend_Validate_Abstract
+{
+ const NOT_UNIQUE = 'notUnique';
+
+ protected $_messageTemplates = array (
+ self::NOT_UNIQUE => 'Slug is not unique.'
+ );
+
+ /** **/
+
+ /**
+ * Check if a username is valid (unique).
+ * @param string $value
+ * @return boolean
+ */
+ public function isValid($value)
+ {
+ $value = (string) $value;
+ $this->_setValue($value);
+
+ $storage = Fizzy::getInstance()->getStorage();
+ $pages = $storage->fetchAll('Page');
+ $slugs = array();
+ foreach($pages as $page) {
+ $slugs[] = $page->slug;
+ }
+
+ if(in_array($value, $slugs)) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/UsernameUnique.php b/application/library/Fizzy/Validate/UsernameUnique.php
index 81bbd3b..5fce5b9 100644
--- a/application/library/Fizzy/Validate/UsernameUnique.php
+++ b/application/library/Fizzy/Validate/UsernameUnique.php
@@ -1,64 +1,64 @@
<?php
/**
* Class Fizzy_Validate_UsernameUnique
* @category Fizzy
* @package Fizzy_Validate
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
- * Form validator to check if a username is unique. Advbises the Fizzy_Storage
+ * Form validator to check if a username is unique. Advises the Fizzy_Storage
* to check this.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Validate_UsernameUnique extends Zend_Validate_Abstract
{
const NOT_UNIQUE = 'notUnique';
protected $_messageTemplates = array (
self::NOT_UNIQUE => 'Username is not unique.'
);
/** **/
/**
* Check if a username is valid (unique).
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$value = (string) $value;
$this->_setValue($value);
$storage = Fizzy::getInstance()->getStorage();
$users = $storage->fetchAll('User');
$usernames = array();
foreach($users as $user) {
$usernames[] = $user->username;
}
if(in_array($value, $usernames)) {
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/PagesController.php b/application/modules/admin/controllers/PagesController.php
index 1535370..f28e779 100644
--- a/application/modules/admin/controllers/PagesController.php
+++ b/application/modules/admin/controllers/PagesController.php
@@ -1,163 +1,167 @@
<?php
class Admin_PagesController extends Fizzy_SecuredController
{
/**
* Shows a list of pages managed by Fizzy.
*/
public function indexAction()
{
$storage = Zend_Registry::get('storage');
$pages = $storage->fetchAll('Page');
$this->view->pages = $pages;
}
/**
* Adds a page.
*/
public function addAction()
{
$page = new Page();
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/add'), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage = Zend_Registry::get('storage');
$storage->persist($page);
$this->addSuccessMessage("Page {$page->title} was saved successfully.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null === $page) {
$this->addErrorMessage("Page with ID {$id} could not be found.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/pages/edit/' . $page->getId()), $page);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$page->populate($form->getValues());
$storage->persist($page);
$this->addSuccessMessage("Page \"<strong>{$page->title}</strong>\" was successfully saved.");
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('pages/form.phtml');
}
/**
* Delete a page
*/
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$storage = Zend_Registry::get('storage');
$page = $storage->fetchByID('Page', $id);
if(null !== $page) {
$storage->delete($page);
$this->addSuccessMessage("Page {$page->title} was successfully deleted.");
}
}
$this->_redirect('/fizzy/pages', array('prependBase' => true));
}
/**
* Builds the form for adding or editing a page.
* @param string $action
* @param Page $page
* @return Zend_Form
*/
protected function _getForm($action, $page)
{
$formConfig = array (
'action' => $action,
'elements' => array (
'title' => array (
'type' => 'text',
'options' => array (
'label' => 'Title',
'required' => true,
'value' => $page->title,
)
),
'slug' => array (
'type' => 'text',
'options' => array (
'label' => 'Slug',
'required' => true,
'value' => $page->slug,
+ 'filters' => array (
+ 'slugify'
+ ),
+ 'validators' => array (
+ 'slugUnique'
+ )
)
),
'body' => array (
'type' => 'textarea',
'options' => array (
'label' => 'Body',
'required' => true,
'value' => $page->body,
)
),
'template' => array (
'type' => 'select',
'options' => array (
'label' => 'Template',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getTemplate(),
)
),
'layout' => array (
'type' => 'select',
'options' => array (
'label' => 'Layout',
'required' => true,
'multiOptions' => array('default' => 'Default'),
'value' => $page->getLayout(),
)
),
'homepage' => array (
'type' => 'checkbox',
'options' => array (
'label' => 'Is Homepage',
'required' => false,
'value' => (int) $page->homepage,
'checked' => ((boolean) $page->homepage) ? 'checked' : ''
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
- $form = new Zend_Form();
- $form->setOptions($formConfig);
- return $form;
+ return new Fizzy_Form(new Zend_Config($formConfig));
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
9e501173bbccd3f0afc45317242c9d75c4a77790
|
Added doxygen configuration
|
diff --git a/.gitignore b/.gitignore
index 641dfb1..dc71e5b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
configs/fizzy.ini
data/*.xml
+data/docs
diff --git a/data/doxygen.conf b/data/doxygen.conf
new file mode 100644
index 0000000..45d147d
--- /dev/null
+++ b/data/doxygen.conf
@@ -0,0 +1,259 @@
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = Fizzy
+PROJECT_NUMBER =
+OUTPUT_DIRECTORY = data/docs
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+QT_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = YES
+OPTIMIZE_OUTPUT_JAVA = YES
+OPTIMIZE_FOR_FORTRAN = NO
+OPTIMIZE_OUTPUT_VHDL = NO
+EXTENSION_MAPPING =
+BUILTIN_STL_SUPPORT = NO
+CPP_CLI_SUPPORT = NO
+SIP_SUPPORT = NO
+IDL_PROPERTY_SUPPORT = YES
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+TYPEDEF_HIDES_STRUCT = NO
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = YES
+EXTRACT_ANON_NSPACES = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = NO
+HIDE_SCOPE_NAMES = YES
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_GROUP_NAMES = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = NO
+SHOW_FILES = YES
+SHOW_NAMESPACES = YES
+FILE_VERSION_FILTER =
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = YES
+WARNINGS = NO
+WARN_IF_UNDOCUMENTED = NO
+WARN_IF_DOC_ERROR = NO
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = application/library/Fizzy
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.php
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = YES
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = NO
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = YES
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+HTML_DYNAMIC_SECTIONS = NO
+GENERATE_DOCSET = NO
+DOCSET_FEEDNAME = "Doxygen generated docs"
+DOCSET_BUNDLE_ID = org.doxygen.Fizzy
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+CHM_INDEX_ENCODING =
+BINARY_TOC = NO
+TOC_EXPAND = NO
+GENERATE_QHP = NO
+QCH_FILE =
+QHP_NAMESPACE =
+QHP_VIRTUAL_FOLDER = doc
+QHP_CUST_FILTER_NAME =
+QHP_CUST_FILTER_ATTRS =
+QHP_SECT_FILTER_ATTRS =
+QHG_LOCATION =
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = ALL
+TREEVIEW_WIDTH = 250
+FORMULA_FONTSIZE = 10
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+MSCGEN_PATH =
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = YES
+DOT_FONTNAME = FreeSans
+DOT_FONTSIZE = 10
+DOT_FONTPATH =
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = YES
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = YES
+CALLER_GRAPH = YES
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+DOT_GRAPH_MAX_NODES = 50
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Options related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = YES
\ No newline at end of file
|
jtietema/Fizzy
|
61e33f46c138515207569469aa8d444de462d60b
|
Form controlls
|
diff --git a/application/library/Fizzy/Form.php b/application/library/Fizzy/Form.php
new file mode 100644
index 0000000..db6d76d
--- /dev/null
+++ b/application/library/Fizzy/Form.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Class Fizzy_Form
+ * @category Fizzy
+ * @package Fizzy_Form
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Form */
+require_once 'Zend/Form.php';
+
+/**
+ * Fizzy form is an extension of the standard Zend_Form to load Fizzy
+ * form elements, decorators and validators.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Form extends Zend_Form
+{
+ /**
+ * Hook into the init mehtod call to load Fizzy form elements, decorators and
+ * validators.
+ */
+ public function init()
+ {
+ $this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::ELEMENT);
+ $this->addPrefixPath('Fizzy_Form', 'Fizzy/Form', self::DECORATOR);
+ $this->addElementPrefixPath('Fizzy_Validate', 'Fizzy/Validate', 'validate');
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Form/Element/Wysiwyg.php b/application/library/Fizzy/Form/Element/Wysiwyg.php
index 2bf1fe1..66e6947 100644
--- a/application/library/Fizzy/Form/Element/Wysiwyg.php
+++ b/application/library/Fizzy/Form/Element/Wysiwyg.php
@@ -1,16 +1,34 @@
<?php
+/**
+ * Class Fizzy_Form_Element_Wysiwyg
+ * @category Fizzy
+ * @package Fizzy_Form_Element_Wysiwig
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
class Fizzy_Form_Element_Wysiwyg extends Zend_Form_Element_Xhtml
{
/**
* Use formTextarea view helper by default
* @var string
*/
public $helper = 'wysiwyg';
public function init()
{
$view = $this->getView();
$view->addHelperPath('Fizzy/View/Helper', 'Fizzy_View_Helper');
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Storage/AuthAdapter.php b/application/library/Fizzy/Storage/AuthAdapter.php
index 2963b05..a85ec8b 100644
--- a/application/library/Fizzy/Storage/AuthAdapter.php
+++ b/application/library/Fizzy/Storage/AuthAdapter.php
@@ -1,117 +1,135 @@
<?php
+/**
+ * Class Fizzy_Storage_AuthAdapter
+ * @category Fizzy
+ * @package Fizzy_Storage_AuthAdapter
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
/**
* Authentication adapter for Fizzy_Storage.
* Takes a model class and tries to authenticate with a username and password
* against the model class.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage_AuthAdapter implements Zend_Auth_Adapter_Interface
{
/**
* Model class to use for authentication.
* @var string
*/
protected $_modelClass = 'User';
/**
* Username for authentication.
* @var string
*/
protected $_username = null;
/**
* Password for authentication
* @var string
*/
protected $_password = null;
/** **/
/**
* Constructor for auth adapter based on Fizzy_Storage.
* @param string $username
* @param string $password
*/
public function __construct($username = null, $password = null)
{
if(null !== $username) {
$this->setUsername($username);
}
if(null !== $password) {
$this->setPassword($password);
}
}
/**
* Set the model class to authenticate against.
* @param string $modelClass
* @return Fizzy_Storage_AuthAdapter
*/
public function setModelClass($modelClass)
{
$this->_modelClass = $modeClass;
return $this;
}
/**
* Set the username used when authenticating
* @param string $username
* @return Fizzy_Storage_AuthAdapter
*/
public function setUsername($username)
{
$this->_username = $username;
return $this;
}
/**
* Set the password used when authenticating.
* @param string $password
* @return Fizzy_Storage_AuthAdapter
*/
public function setPassword($password)
{
$this->_password = $password;
return $this;
}
/**
* Autheticate against Fizzy_Storage
* @return Zend_Auth_Result
*/
public function authenticate()
{
# Check the username
$storage = Fizzy::getInstance()->getStorage();
$users = $storage->fetchByField($this->_modelClass, array('username' => $this->_username));
if(0 === count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null, array('Username not found.'));
}
else if(1 < count($users)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS,
null, array('Username did not match one instance.'));
}
$user = array_shift($users);
# Check the password
$password = $this->_password;
$encryption = strtolower($user->getEncryption());
if(!empty($encryption) && 'plain' !== $encryption && in_array($encryption, array('md5', 'sha1'))) {
$password = $encryption($password);
}
if($password !== $user->getPassword()) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
null, array('Invalid password.'));
}
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/PasswordConfirm.php b/application/library/Fizzy/Validate/PasswordConfirm.php
new file mode 100644
index 0000000..8ba652f
--- /dev/null
+++ b/application/library/Fizzy/Validate/PasswordConfirm.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * Class Fizzy_Validate_PasswordConfirm
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/**
+ * Validator to check if a password field has the same value as another field
+ * in the same form.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_PasswordConfirm extends Zend_Validate_Abstract
+{
+ const NOT_MATCH = 'notMatch';
+
+ protected $_messageTemplates = array(
+ self::NOT_MATCH => 'Password confirmation does not match'
+ );
+
+ /**
+ * The opposite field name to check against.
+ * @var string
+ */
+ protected $_oppositeField = 'password_confirm';
+
+ /** **/
+
+ /**
+ * Set the field to check against.
+ * @param string $field
+ * @return Zend_Validate_Abstract
+ */
+ public function setOppositeField($field)
+ {
+ $this->_oppositeField = $field;
+
+ return $this;
+ }
+
+ /**
+ * Check if the field value is the same as the opposite field value.
+ * @param string $value
+ * @param mixed $context
+ * @return boolean
+ */
+ public function isValid($value, $context = null)
+ {
+ $value = (string) $value;
+ $this->_setValue($value);
+
+ if(is_array($context)) {
+ if(isset($context[$this->_oppositeField]) && ($value == $context[$this->_oppositeField])) {
+ return true;
+ }
+ }
+ else if (is_string($context) && ($value == $context)) {
+ return true;
+ }
+
+ $this->_error(self::NOT_MATCH);
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Validate/UsernameUnique.php b/application/library/Fizzy/Validate/UsernameUnique.php
new file mode 100644
index 0000000..81bbd3b
--- /dev/null
+++ b/application/library/Fizzy/Validate/UsernameUnique.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Class Fizzy_Validate_UsernameUnique
+ * @category Fizzy
+ * @package Fizzy_Validate
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/**
+ * Form validator to check if a username is unique. Advbises the Fizzy_Storage
+ * to check this.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Validate_UsernameUnique extends Zend_Validate_Abstract
+{
+ const NOT_UNIQUE = 'notUnique';
+
+ protected $_messageTemplates = array (
+ self::NOT_UNIQUE => 'Username is not unique.'
+ );
+
+ /** **/
+
+ /**
+ * Check if a username is valid (unique).
+ * @param string $value
+ * @return boolean
+ */
+ public function isValid($value)
+ {
+ $value = (string) $value;
+ $this->_setValue($value);
+
+ $storage = Fizzy::getInstance()->getStorage();
+ $users = $storage->fetchAll('User');
+ $usernames = array();
+ foreach($users as $user) {
+ $usernames[] = $user->username;
+ }
+
+ if(in_array($value, $usernames)) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
index 8fcbfa0..a036b8f 100644
--- a/application/modules/admin/controllers/AuthController.php
+++ b/application/modules/admin/controllers/AuthController.php
@@ -1,69 +1,69 @@
<?php
class Admin_AuthController extends Fizzy_Controller
{
public function loginAction()
{
$form = $this->_getForm();
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$authAdapter = new Fizzy_Storage_AuthAdapter(
$form->username->getValue(), $form->password->getValue()
);
$result = Zend_Auth::getInstance()->authenticate($authAdapter);
if($result->isValid()) {
$this->_redirect('/fizzy', array('prependBase' => true));
}
$messages = $result->getMessages();
$this->addErrorMessage(array_shift($messages));
$this->_redirect('/fizzy/login', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('login.phtml');
}
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('/fizzy', array('prependBase' => true));
}
protected function _getForm()
{
$formConfig = array (
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true
- )
+ ),
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Login',
'ignore' => true
)
)
)
);
- return new Zend_Form(new Zend_Config($formConfig));
+ return new Fizzy_Form(new Zend_Config($formConfig));
}
public function postDispatch()
{
$this->_helper->layout->setLayout('login');
}
}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/UserController.php b/application/modules/admin/controllers/UserController.php
index b9fc51a..a85cb3d 100644
--- a/application/modules/admin/controllers/UserController.php
+++ b/application/modules/admin/controllers/UserController.php
@@ -1,122 +1,125 @@
<?php
class Admin_UserController extends Fizzy_SecuredController
{
public function indexAction()
{
$storage = Zend_Registry::get('storage');
$users = $storage->fetchAll('User');
$this->view->users = $users;
$this->renderScript('/user/list.phtml');
}
public function addAction()
{
$user = new User();
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/add'), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$storage = Zend_Registry::get('storage');
$storage->persist($user);
$this->addSuccessMessage("User {$user->username} was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('/user/form.phtml');
}
public function editAction()
{
$id = $this->_getParam('id', null);
if(null === $id) {
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$storage = Zend_Registry::get('storage');
$user = $storage->fetchByID('User', $id);
if(null === $user) {
$this->addErrorMessage("User with ID {$id} could not be found.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
$form = $this->_getForm($this->view->baseUrl('/fizzy/user/edit/' . $user->getId()), $user);
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$user->populate($form->getValues());
$storage->persist($user);
$this->addSuccessMessage("User <strong>{$user->username}</strong> was successfully saved.");
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('user/form.phtml');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
if(null !== $id) {
$storage = Zend_Registry::get('storage');
$user = $storage->fetchByID('User', $id);
if(null !== $user) {
$storage->delete($user);
$this->addSuccessMessage("User {$user->username} was successfully deleted.");
}
$this->_redirect('/fizzy/users', array('prependBase' => true));
}
}
protected function _getForm($action, User $user)
{
$formConfig = array (
'action' => $action,
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true,
'value' => $user->username,
+ 'validators' => array (
+ 'usernameUnique'
+ )
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true,
+ 'validators' => array (
+ 'passwordConfirm'
+ )
),
),
- /**
- * @todo create(/find) custom validator to validate passwords are the same
'password_confirm' => array (
'type' => 'password',
'options' => array (
'label' => 'Confirm password',
'required' => true,
'ignore' => true,
)
),
- */
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Save',
'ignore' => true
)
),
),
);
- return new Zend_Form(new Zend_Config($formConfig));
+ return new Fizzy_Form(new Zend_Config($formConfig));
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
f20985f95fb92f1d3dfb29f15acdbad6ddd7d372
|
Added layout for login page
|
diff --git a/application/assets/css/fizzy.css b/application/assets/css/fizzy.css
index 47795c0..6c1ab8a 100644
--- a/application/assets/css/fizzy.css
+++ b/application/assets/css/fizzy.css
@@ -1,345 +1,346 @@
@import 'screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
#messages {
min-height: 2em;
line-height: 2em;
margin: 1em 0;
}
#messages ul {
margin: 0 0 0 1em;
}
.message {
margin: 0 0 0 4px;
padding: 2px 0;
background-repeat: no-repeat;
background-position: 8px 6px;
}
.message .info {
background-image: url('../images/icon/sign_info.png');
}
.message .success {
background-image: url('../images/icon/sign_tick.png');
}
.message .warning {
background-image: url('../images/icon/sign_warning.png');
}
.message .error {
background-image: url('../images/icon/sign_error.png');
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
display: block;
color: #555555;
font-weight: bold;
}
.form-container dt {
padding: 0.5em 0.5em 0 0.5em;
}
.form-container dd {
margin: 0;
padding: 0 .5em .5em .5em;
border-bottom: 1px #CCCCCC dotted;
}
.form-container p.hint {
margin-bottom: 0;
font-size: .8em;
}
.form-container #submit-label { display: none; }
.form-container #submit-element {
border: 0;
padding: 0.5em;
}
.form-container textarea {
width: 99%;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
+ height: 3.1em;
background: #2E3132 url('/images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
#content {
line-height: 1.7em;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
diff --git a/application/layouts/login.phtml b/application/layouts/login.phtml
new file mode 100644
index 0000000..4180780
--- /dev/null
+++ b/application/layouts/login.phtml
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Fizzy login layout
+ * @package Fizzy
+ * @subpackage Views
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+ ?>
+ <!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">
+ <head>
+ <title>Fizzy</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <link href="<?= $this->baseUrl("/fizzy_assets/css/fizzy.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ </head>
+ <body>
+ <div id="header">
+ </div>
+
+ <div class="container">
+
+ <div id="messages" class="span-24 last">
+ <div class="message">
+ <?= $this->fizzyMessages(); ?>
+ </div>
+ </div>
+
+ <div id="content" class="span-24 last content-container">
+ <div id="content-wrapper">
+ <?= $this->layout()->content; ?>
+ </div>
+ </div>
+
+ <div id="footer" class="span-24 last">
+ (c) 2009-<?= date('Y'); ?> Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
+ </div>
+ </div>
+
+ <div class="clear"></div>
+ </body>
+</html>
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
index 6c9b178..8fcbfa0 100644
--- a/application/modules/admin/controllers/AuthController.php
+++ b/application/modules/admin/controllers/AuthController.php
@@ -1,64 +1,69 @@
<?php
class Admin_AuthController extends Fizzy_Controller
{
public function loginAction()
{
$form = $this->_getForm();
if($this->_request->isPost()) {
if($form->isValid($_POST)) {
$authAdapter = new Fizzy_Storage_AuthAdapter(
$form->username->getValue(), $form->password->getValue()
);
$result = Zend_Auth::getInstance()->authenticate($authAdapter);
if($result->isValid()) {
$this->_redirect('/fizzy', array('prependBase' => true));
}
$messages = $result->getMessages();
$this->addErrorMessage(array_shift($messages));
$this->_redirect('/fizzy/login', array('prependBase' => true));
}
}
$this->view->form = $form;
$this->renderScript('login.phtml');
}
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('/fizzy', array('prependBase' => true));
}
protected function _getForm()
{
$formConfig = array (
'elements' => array (
'username' => array (
'type' => 'text',
'options' => array (
'label' => 'Username',
'required' => true
)
),
'password' => array (
'type' => 'password',
'options' => array (
'label' => 'Password',
'required' => true
)
),
'submit' => array (
'type' => 'submit',
'options' => array (
'label' => 'Login',
'ignore' => true
)
)
)
);
return new Zend_Form(new Zend_Config($formConfig));
}
+ public function postDispatch()
+ {
+ $this->_helper->layout->setLayout('login');
+ }
+
}
\ No newline at end of file
|
jtietema/Fizzy
|
31926552854d056fba1679ff0ca1e5617c9337c3
|
Fizzy_Storage auth adapter
|
diff --git a/application/library/Fizzy.php b/application/library/Fizzy.php
index cdeac28..e8942aa 100644
--- a/application/library/Fizzy.php
+++ b/application/library/Fizzy.php
@@ -1,632 +1,634 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Fizzy application class. Takes care of gathering all configuration,
* bootstrapping and dispatching requests.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy
{
private static $_instance = null;
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
# 'logger' => null,
'session' => null,
'frontController' => null,
'router' => null,
'storage' => null,
'view' => null,
'layout' => null,
);
/*
* Has Fizzy been bootstrapped.
* @var boolean
*/
protected $_bootstrapped = false;
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => '',
'defaultLayout' => 'fizzy',
'defaultTemplate' => 'page.phtml',
'defaultController' => 'index',
'defaultAction' => 'index',
'backendPrefix' => 'fizzy'
),
'routes' => array (
# Catch all for pages slugs
'page_by_slug' => array (
'route' => '/:slug',
'defaults' => array (
'controller' => 'pages',
'action' => 'slug'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/pages',
'defaults' => array (
'controller' => 'pages',
'action' => 'index',
'module' => 'admin'
)
),
'admin_pages_add' => array(
'route' => '/fizzy/pages/add',
'defaults' => array (
'controller' => 'pages',
'action' => 'add',
'module' => 'admin'
)
),
'admin_pages_edit' => array(
'route' => '/fizzy/pages/edit/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'edit',
'module' => 'admin'
)
),
'admin_pages_delete' => array(
'route' => '/fizzy/pages/delete/:id',
'defaults' => array (
'controller' => 'pages',
'action' => 'delete',
'module' => 'admin'
)
),
# Admin media
'admin_media_delete' => array(
'route' => '/fizzy/media/delete/:name',
'defaults' => array (
'controller' => 'media',
'action' => 'delete',
'module' => 'admin'
)
),
'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/media',
'defaults' => array (
'controller' => 'media',
'module' => 'admin'
)
),
'fizzy_users' => array(
'route' => '/fizzy/users',
'defaults' => array (
'controller' => 'user',
'module' => 'admin'
)
),
'fizzy_user_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/user/add',
'defaults' => array (
'controller' => 'user',
'action' => 'add',
'module' => 'admin'
)
),
'fizzy_user_edit' => array(
'route' => '/fizzy/user/edit/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'edit',
'module' => 'admin'
)
),
'fizzy_user_delete' => array(
'route' => '/fizzy/user/delete/:id',
'defaults' => array (
'controller' => 'user',
'action' => 'delete',
'module' => 'admin'
)
),
# Static admin routes
'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy/configuration',
'defaults' => array (
'controller' => 'index',
'action' => 'configuration',
'module' => 'admin'
)
),
- /*'admin_logout' => array(
+ 'fizzy_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/admin/logout',
+ 'route' => '/fizzy/logout',
'defaults' => array (
- 'controller' => 'admin',
- 'action' => 'logout'
+ 'controller' => 'auth',
+ 'action' => 'logout',
+ 'module' => 'admin'
)
- ),*/
- /*'admin_login' => array(
+ ),
+ 'fizzy_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
- 'route' => '/admin/login',
+ 'route' => '/fizzy/login',
'defaults' => array (
- 'controller' => 'admin',
- 'action' => 'login'
+ 'controller' => 'auth',
+ 'action' => 'login',
+ 'module' => 'admin'
)
- ),*/
+ ),
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/fizzy',
'defaults' => array (
'controller' => 'index',
'action' => 'index',
'module' => 'admin'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'default' => 'application/modules/default/controllers',
'admin' => 'application/modules/admin/controllers',
'custom' => 'custom/controllers',
),
'models' => 'application/models',
'views' => array(
'fizzy' => 'application/views',
'custom' => 'custom/views'
),
'layouts' => array(
'fizzy' => 'application/layouts',
'custom' => 'custom/layouts',
),
'templates' => array (
'fizzy' => 'application/templates',
'custom' => 'custom/templates'
),
'assets' => 'application/assets',
'configs' => 'configs',
'custom' => 'custom',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct()
{
$this->_config = new Zend_Config($this->_defaultConfig, true);
}
/**
* Returns the active instance of the Fizzy application.
* @return Fizzy
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Add configuration to the Fizzy application. The config is merged with
* the already present config. Configuration can only be added before the
* bootstrap sequence.
* @param array|string|Zend_Config $config
* @return Fizzy
*/
public function addConfig($config)
{
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
# Merge configs
$this->_config->merge($customConfig);
}
return $this;
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Corrects relative paths by prefixing them with the configured base path.
*
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = $this->_config->application->basePath . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Shortcut to get a path by it's key from the configuration.
* @param string $key
* @return string|null
*/
public function getPath($key)
{
$section = $this->_config->paths->get($key, null);
if(null === $section) {
return null;
}
if($section instanceof Zend_Config) {
$section = $section->toArray();
}
return $section;
}
/**
* Sets the environment the Fizzy application runs in. This can only be
* set if Fizzy has not been bootstrapped.
* @return Fizzy
*/
public function setEnvironment($environment)
{
if(!$this->isBootstrapped()) {
$this->_environment = $environment;
}
return $this;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$this->_stripslashesDeep($_GET);
$this->_stripslashesDeep($_POST);
$this->_stripslashesDeep($_REQUEST);
$this->_stripslashesDeep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader. The default namespaces registered are Zend_
* and ZendX_. This stage adds the Fizzy_ namespace to that.
* An Autoloader is added to the stack for Fizzy models.
* @see Fizzy_Autoloader
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
protected function _initSession()
{
Zend_Session::start();
return null;
}
/**
* Initializes the front controller
* @return Zend_Controller_Front
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction);
# Add module directory for Fizzy core
$frontController->addModuleDirectory($this->getPath('application') . DIRECTORY_SEPARATOR . 'modules');
# Add custom folder as module
$frontController->addControllerDirectory($this->getPath('custom') . DIRECTORY_SEPARATOR . 'controllers', 'custom');
# Set error handling
if('development' === $this->_environment) {
# Allow exceptions and unregister the error handler plugin
$frontController->throwExceptions(true);
$frontController->unregisterPlugin('ErrorHandler');
}
else {
$errorHandler = new Zend_Controller_Plugin_ErrorHandler(array (
'controller' => 'error',
'action' => 'error',
'module' => 'default'
));
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @todo Add support for changing the backend prefix and parsing the routes
* @return Zend_Router
*/
protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$routes = $this->_config->routes;
$router->clearParams()
->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
$storage = null;
if(isset($this->_config->storage)) {
$storage = new Fizzy_Storage($this->_config->storage->toArray());
Zend_Registry::set('storage', $storage);
}
return $storage;
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$view = new Zend_View();
foreach($this->getPath('views') as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layoutPaths = $this->getPath('layouts');
$layout = new Zend_Layout($layoutPaths['fizzy'], true);
$layout->setLayout($this->_config->application->defaultLayout);
return $layout;
}
/**
* Returns if the Fizzy application has been bootstrapped.
* @return boolean
*/
public function isBootstrapped()
{
return $this->_boolean;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping.
*/
public function bootstrap($dispatch = true)
{
# Load the php environment
$this->_loadEnvironment();
$config = $this->_config;
# Check for basePath configuration
$basePath = $config->application->get('basePath', null);
if(empty($basePath)) {
$config->application->basePath = realpath(dirname(__FILE__) . '/../../');
}
# Correct realtive paths in configuration
$correctedPaths = $this->_correctPaths($config->paths->toArray());
$config->paths = new Zend_Config($correctedPaths, true);
unset($correctedPaths);
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
$this->_bootstrapped = true;
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
diff --git a/application/library/Fizzy/SecuredController.php b/application/library/Fizzy/SecuredController.php
index 549b565..3767378 100644
--- a/application/library/Fizzy/SecuredController.php
+++ b/application/library/Fizzy/SecuredController.php
@@ -1,24 +1,53 @@
<?php
/**
* Class Fizzy_SecuredController
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Controller */
require_once 'Fizzy/Controller.php';
class Fizzy_SecuredController extends Fizzy_Controller
-{}
\ No newline at end of file
+{
+ /**
+ * Identity object for the autheticated user.
+ * @var mixed
+ */
+ protected $_identity = null;
+
+ /** **/
+
+ /**
+ * Check for authentication identity
+ */
+ public function preDispatch()
+ {
+ if (!Zend_Auth::getInstance()->hasIdentity()) {
+ $this->_redirect('/fizzy/login', array('prependBase' => true));
+ }
+
+ $this->_identity = Zend_Auth::getInstance()->getIdentity();
+ }
+
+ /**
+ * Returns the identity for the authenticated user.
+ * @return mixed
+ */
+ public function getIdentity()
+ {
+ return $this->_identity;
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Storage/AuthAdapter.php b/application/library/Fizzy/Storage/AuthAdapter.php
new file mode 100644
index 0000000..2963b05
--- /dev/null
+++ b/application/library/Fizzy/Storage/AuthAdapter.php
@@ -0,0 +1,117 @@
+<?php
+
+/**
+ * Authentication adapter for Fizzy_Storage.
+ * Takes a model class and tries to authenticate with a username and password
+ * against the model class.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class Fizzy_Storage_AuthAdapter implements Zend_Auth_Adapter_Interface
+{
+ /**
+ * Model class to use for authentication.
+ * @var string
+ */
+ protected $_modelClass = 'User';
+
+ /**
+ * Username for authentication.
+ * @var string
+ */
+ protected $_username = null;
+
+ /**
+ * Password for authentication
+ * @var string
+ */
+ protected $_password = null;
+
+ /** **/
+
+ /**
+ * Constructor for auth adapter based on Fizzy_Storage.
+ * @param string $username
+ * @param string $password
+ */
+ public function __construct($username = null, $password = null)
+ {
+ if(null !== $username) {
+ $this->setUsername($username);
+ }
+
+ if(null !== $password) {
+ $this->setPassword($password);
+ }
+ }
+
+ /**
+ * Set the model class to authenticate against.
+ * @param string $modelClass
+ * @return Fizzy_Storage_AuthAdapter
+ */
+ public function setModelClass($modelClass)
+ {
+ $this->_modelClass = $modeClass;
+
+ return $this;
+ }
+
+ /**
+ * Set the username used when authenticating
+ * @param string $username
+ * @return Fizzy_Storage_AuthAdapter
+ */
+ public function setUsername($username)
+ {
+ $this->_username = $username;
+
+ return $this;
+ }
+
+ /**
+ * Set the password used when authenticating.
+ * @param string $password
+ * @return Fizzy_Storage_AuthAdapter
+ */
+ public function setPassword($password)
+ {
+ $this->_password = $password;
+
+ return $this;
+ }
+
+ /**
+ * Autheticate against Fizzy_Storage
+ * @return Zend_Auth_Result
+ */
+ public function authenticate()
+ {
+ # Check the username
+ $storage = Fizzy::getInstance()->getStorage();
+ $users = $storage->fetchByField($this->_modelClass, array('username' => $this->_username));
+ if(0 === count($users)) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
+ null, array('Username not found.'));
+ }
+ else if(1 < count($users)) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS,
+ null, array('Username did not match one instance.'));
+ }
+ $user = array_shift($users);
+
+ # Check the password
+ $password = $this->_password;
+ $encryption = strtolower($user->getEncryption());
+ if(!empty($encryption) && 'plain' !== $encryption && in_array($encryption, array('md5', 'sha1'))) {
+ $password = $encryption($password);
+ }
+ if($password !== $user->getPassword()) {
+ return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
+ null, array('Invalid password.'));
+ }
+
+ return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user);
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/admin/controllers/AuthController.php b/application/modules/admin/controllers/AuthController.php
new file mode 100644
index 0000000..6c9b178
--- /dev/null
+++ b/application/modules/admin/controllers/AuthController.php
@@ -0,0 +1,64 @@
+<?php
+
+class Admin_AuthController extends Fizzy_Controller
+{
+
+ public function loginAction()
+ {
+ $form = $this->_getForm();
+ if($this->_request->isPost()) {
+ if($form->isValid($_POST)) {
+ $authAdapter = new Fizzy_Storage_AuthAdapter(
+ $form->username->getValue(), $form->password->getValue()
+ );
+ $result = Zend_Auth::getInstance()->authenticate($authAdapter);
+ if($result->isValid()) {
+ $this->_redirect('/fizzy', array('prependBase' => true));
+ }
+ $messages = $result->getMessages();
+ $this->addErrorMessage(array_shift($messages));
+ $this->_redirect('/fizzy/login', array('prependBase' => true));
+ }
+ }
+ $this->view->form = $form;
+ $this->renderScript('login.phtml');
+ }
+
+ public function logoutAction()
+ {
+ Zend_Auth::getInstance()->clearIdentity();
+ $this->_redirect('/fizzy', array('prependBase' => true));
+ }
+
+ protected function _getForm()
+ {
+ $formConfig = array (
+ 'elements' => array (
+ 'username' => array (
+ 'type' => 'text',
+ 'options' => array (
+ 'label' => 'Username',
+ 'required' => true
+ )
+ ),
+ 'password' => array (
+ 'type' => 'password',
+ 'options' => array (
+ 'label' => 'Password',
+ 'required' => true
+ )
+ ),
+ 'submit' => array (
+ 'type' => 'submit',
+ 'options' => array (
+ 'label' => 'Login',
+ 'ignore' => true
+ )
+ )
+ )
+ );
+
+ return new Zend_Form(new Zend_Config($formConfig));
+ }
+
+}
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/login.phtml b/application/modules/admin/views/scripts/login.phtml
new file mode 100644
index 0000000..bd1811b
--- /dev/null
+++ b/application/modules/admin/views/scripts/login.phtml
@@ -0,0 +1,4 @@
+<h1 class="header">Login</h1>
+<div class="form-container">
+ <?= $this->form; ?>
+</div>
\ No newline at end of file
|
jtietema/Fizzy
|
b4898142fc06438a139a2722a0954cfb4b937251
|
added default uploads folder to default config
|
diff --git a/configs/fizzy.xml.default b/configs/fizzy.xml.default
index b826cc0..113a78b 100644
--- a/configs/fizzy.xml.default
+++ b/configs/fizzy.xml.default
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<fizzy version="1.1">
<application>
<title>Fizzy</title>
<environment>production</environment>
</application>
<router>
<defaultController>default</defaultController>
<defaultAction>default</defaultAction>
</router>
<storage>
<dsn>xml:data</dsn>
</storage>
+ <paths>
+ <uploads>public/uploads</uploads>
+ </paths>
</fizzy>
|
jtietema/Fizzy
|
d8acc0b68f91dcc35184eb00ba4d807b1e0944e7
|
saving an existing page now updates correctly
|
diff --git a/application/library/Fizzy/Storage.php b/application/library/Fizzy/Storage.php
index 8e5c5e8..a9bc663 100644
--- a/application/library/Fizzy/Storage.php
+++ b/application/library/Fizzy/Storage.php
@@ -1,303 +1,303 @@
<?php
/**
* Class Fizzy_Storage
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Xml */
require_once 'Fizzy/Storage/Backend/Xml.php';
/** Fizzy_Storage_Backend_Sqlite */
require_once 'Fizzy/Storage/Backend/Sqlite.php';
/** Fizzy_Storage_Backend_Mysql */
require_once 'Fizzy/Storage/Backend/Mysql.php';
/**
* Main storage Class. You should only use this class to communicate with the
* persistence layer.
*
* @author Jeroen Tietema <[email protected]>
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage
{
/** Constants for storage backend */
const MYSQL = 'mysql';
const SQLITE = 'sqlite';
const XML = 'xml';
/**
* The storage configuration.
* @var array
*/
protected $_config = null;
/**
* The persistence driver used.
* @var Fizzy_Storage_Driver_Interface
*/
protected $_backend = null;
/** **/
/**
* Constructor. Loads the configuration and instanciates the driver.
* @param array $config
*/
public function __construct(array $config)
{
if(!isset($config['dsn'])) {
require_once 'Fizzy/Storage/Exception/InvalidConfig.php';
throw new Fizzy_Storage_Exception_InvalidConfig('No DSN specified in storage configuration.');
}
$this->_loadBackend($config);
}
/**
* Loads a backend driver based on the DSN.
*
* @param array $config
*/
protected function _loadBackend(array $config)
{
$backendString = array_shift(explode(':', $config['dsn']));
switch(strtolower($backendString))
{
case self::XML:
$this->_backend = new Fizzy_Storage_Backend_Xml($config);
break;
case self::SQLITE:
$this->_backend = new Fizzy_Storage_Backend_Sqlite($config);
break;
case self::MYSQL:
$this->_backend = new Fizzy_Storage_Backend_Mysql($config);
break;
default:
require_once 'Fizzy/Storage/Exception/InvalidConfig.php';
throw new Fizzy_Storage_Exception_InvalidConfig("Unsupported backend:" . $backendString);
}
}
/**
* Sets the storage backend.
* @param Fizzy_Storage_Backend_Interface $backend
* @return Fizzy_Storage
*/
public function setBackend($backend)
{
$this->_backend = $backend;
return $this;
}
/**
* Returns the storage backend.
* @return Fizzy_Storage_Backend_Interface
*/
public function getBackend()
{
return $this->_backend;
}
/**
* Persists a model in it's container.
* @param Fizzy_Storage_Model $model
* @return boolean
*/
public function persist(Fizzy_Storage_Model $model)
{
$container = $this->_getContainerName($model);
$data = $model->toArray();
- $id = $this->_backend->persist($container, $data, $identifier);
+ $id = $this->_backend->persist($container, $data, $model->getId());
if(false === $id) {
return false;
}
if(null === $model->getId()) {
$model->setId($id);
}
return true;
}
/**
* Deletes a model from storage.
* @paran Fizzy_Storage_Model $model
*/
public function delete(Fizzy_Storage_Model $model)
{
$container = $this->_getContainerName($model);
return $this->_backend->delete($container, $model->getId());
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchOne($class, $identifier)
{
$container = $this->_getContainerName($class);
$data = $this->_backend->fetchOne($container, $identifier);
if ($data === null) {
return null;
}
return $this->_buildModel($class, $data);
}
/**
* Fetches all items for a model class.
* @param object|string $class
* @return array
*/
public function fetchAll($class)
{
$container = $this->_getContainerName($class);
$data = $this->_backend->fetchAll($container);
$models = array();
foreach ($data as $identifier => $modelData) {
$model = $this->_buildModel($class, $modelData);
$model->setId($identifier);
$models[$identifier] = $model;
}
return $models;
}
/**
* Fetches items for a model class by the specified fields.
* @param object|string $class
* @param array $fields
* @return array
*/
public function fetchByField($class, $fields)
{
$container = $this->_getContainerName($class);
$data = $this->_backend->fetchByColumn($container, $fields);
$models = array();
foreach ($data as $identifier => $modelData) {
$model = $this->_buildModel($class, $modelData);
$models[$identifier] = $model;
}
return $models;
}
/**
* Fetches an item by its identifier.
* @param string $class
* @param mixed $identifier
* @return Fizzy_Storage_Model
*/
public function fetchByIdentifier($class, $identifier)
{
$container = $this->_getContainerName($class);
$data = $this->_backend->fetchByIdentifier($container, $identifier);
if(!is_array($data) || 1 !== count($data)) {
return null;
}
$identifier = array_shift(array_keys($data));
$model = $this->_buildModel($class, array_shift($data));
$model->setId($identifier);
return $model;
}
/**
* Alias of {@see fetchByIdentifier}.
*/
public function fetchByID($class, $identifierValue)
{
return $this->fetchByIdentifier($class, $identifierValue);
}
/**
* Instanciates a Model for the given type and populates it with the given
* array.
*
* @param string $class
* @param array $data
* @return Fizzy_Storage_Model
*/
protected function _buildModel($class, array $data)
{
$class = $this->_buildClassname($class);
$model = new $class($data);
return $model;
}
/**
* Builds a classname for given type
*
* @param string $type
* @return string
*/
protected function _buildClassname($type)
{
return ucfirst($type);
}
/**
* Returns the container name for a model
* @param object|string $class
* @return string
*/
protected function _getContainerName($class)
{
// Check if it's a Fizzy_Stroage_Model and has a container name specified
if($class instanceof Fizzy_Storage_Model) {
if(is_callable(array($class, 'getContainerName'))) {
$containerName = $class->getContainerName();
if(null !== $containerName) {
return $containerName;
}
} else {
$class = get_class($class);
}
}
// Check if $class is a string, or was converted to a string
if(is_string($class)) {
$reflectionClass = new ReflectionClass($class);
if($reflectionClass->hasMethod('getContainerName')) {
$instance = $reflectionClass->newInstance();
$containerName = $instance->getContainerName();
if(null !== $containerName) {
return $containerName;
}
}
}
// No previous solution worked, do it the ugly way
if(strpos($class, 's') !== strlen($class)) {
return strtolower($class) . 's';
} else {
return strtolower($class);
}
}
}
|
jtietema/Fizzy
|
021b9bc0a6cef66d22e4f11d90ae567d984ae190
|
added upload path to default xml
|
diff --git a/configs/fizzy.xml.default b/configs/fizzy.xml.default
index b826cc0..113a78b 100644
--- a/configs/fizzy.xml.default
+++ b/configs/fizzy.xml.default
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<fizzy version="1.1">
<application>
<title>Fizzy</title>
<environment>production</environment>
</application>
<router>
<defaultController>default</defaultController>
<defaultAction>default</defaultAction>
</router>
<storage>
<dsn>xml:data</dsn>
</storage>
+ <paths>
+ <uploads>public/uploads</uploads>
+ </paths>
</fizzy>
|
jtietema/Fizzy
|
2069128c51f079518efb2d878db7661f53975ad0
|
Media Controller
|
diff --git a/application/configs/application.ini b/application/configs/application.ini
deleted file mode 100644
index e69de29..0000000
diff --git a/application/configs/routes.ini b/application/configs/routes.ini
deleted file mode 100644
index 48f3e4a..0000000
--- a/application/configs/routes.ini
+++ /dev/null
@@ -1,39 +0,0 @@
-; This file contains the default configuration for Fizzy.
-; The configuration is made up of three sections. These sections and their
-; configuration can be overridden from the custom configuration file in the
-; configs directory.
-;
-; Realtive paths will be prefixed with the basePath configuration. The basePath
-; is detemined by default on bootstrap when no explicit basePath is set in the
-; custom configuration.
-
-[application]
-title = "Fizzy"
-environment = "production"
-basePath = ""
-defaultLayout = "layout"
-defaultTemplate = "page"
-defaultController = "IndexController"
-defaultAction = "IndexController"
-
-[paths]
-application = "application"
-controllers.fizzy = "application/controllers",
-controllers.custom = "custom/controllers"
-models = "application/models"
-views.fizzy = "application/views/scripts"
-views.custom = "custom/views"
-layouts.fizzy = "application/views/layouts"
-layouts.custom = "custom/layouts"
-templates.fizzy = "application/views/scripts"
-templates.custo' = "custom/templates"
-assets = "application/views/assets"
-configs = "configs"
-custom = "custom"
-data = "data"
-library = "library"
-public = "public"
-uploads = "public/uploads"
-
-[routes]
-
diff --git a/application/controllers/Admin/MediaController.php b/application/controllers/Admin/MediaController.php
index f26eae2..ec89894 100644
--- a/application/controllers/Admin/MediaController.php
+++ b/application/controllers/Admin/MediaController.php
@@ -1,138 +1,138 @@
<?php
/**
- * Class AdminMediaController
+ * Class Admin_MediaController
* @package Fizzy
* @subpackage Controller
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** SecureController */
-require_once 'Fizzy/Controller.php';
+require_once 'Fizzy/SecuredController.php';
/**
* Controller for media inside Fizzy. Enables basic upload and deletion of files.
* @author Mattijs Hoitink <[email protected]>
*/
-class Admin_MediaController extends Fizzy_Controller
+class Admin_MediaController extends Fizzy_SecuredController
{
public function indexAction()
{
- $uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
+ $uploadFolder = Zend_Registry::get('config')->paths->uploads;
- if($this->getRequest()->getMethod() === Fizzy_Request::METHOD_POST)
+ if($this->_request->isPost())
{
if(isset($_FILES) && !empty($_FILES['upload'])) {
$overwrite = ((boolean) isset($_POST['overwrite']) && !empty($_POST['overwrite']));
$messages = $this->_handleUpload('upload', $uploadFolder, $overwrite);
- $this->getView()->messages = $messages;
+ $this->view->messages = $messages;
}
}
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
-s );
+ );
$files[] = (object) $fileInfo;
}
}
// Render the view
- $this->getView()->uploadFolder = $uploadFolder;
- $this->getView()->files = $files;
- $this->getView()->post_max_size = ini_get('post_max_size');
- $this->getView()->upload_max_filesize = ini_get('upload_max_filesize');
- $this->getView()->setScript('/admin/media/list.phtml');
+ $this->view->uploadFolder = $uploadFolder;
+ $this->view->files = $files;
+ $this->view->post_max_size = ini_get('post_max_size');
+ $this->view->upload_max_filesize = ini_get('upload_max_filesize');
+ $this->renderScript('/admin/media/list.phtml');
}
/**
* Deletes an uploaded file.
*/
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
- $uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
+ $uploadFolder = Zend_Registry::get('config')->paths->uploads;
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
}
}
$this->_redirect('/admin/media');
}
public function uploadAction()
{
$this->_redirect('/admin/media');
}
/**
* Handles a file upload.
* @param string $name
* @param string $uploadFolder
* @return array
*/
protected function _handleUpload($name, $uploadFolder, $overwrite = false)
{
$file = $_FILES[$name];
if ($file['error'] == UPLOAD_ERR_OK) {
$target = $file["tmp_name"];
$destination = $uploadFolder . DIRECTORY_SEPARATOR . $file["name"];
if(!file_exists($destination) || $overwrite)
{
move_uploaded_file($target, $destination);
}
else
{
unlink($target);
}
return array();
}
else {
switch($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('The uploaded file exceeds the Maximum upload filesize.');
break;
case UPLOAD_ERR_PARTIAL:
return array('The uploaded file was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
return array('No file was uploaded.');
break;
default:
return array('An internal server error occurred.');
}
}
}
}
diff --git a/application/library/Fizzy/Bootstrap.php b/application/library/Fizzy/Bootstrap.php
index 0fd9a08..ea25220 100644
--- a/application/library/Fizzy/Bootstrap.php
+++ b/application/library/Fizzy/Bootstrap.php
@@ -1,524 +1,516 @@
<?php
/** Zend_Config */
require_once 'Zend/Config.php';
/**
* Bootstrap class for Fizzy.
*
* @todo find a better way to support environments
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Bootstrap
{
/**
* The bootstrap stages in order of execution and their return values.
* @var array
*/
protected $_bootstrap = array (
'autoLoader' => null,
'registry' => null,
'logger' => null,
'frontController' => null,
'router' => null,
'storage' => null,
'view' => null,
'layout' => null,
);
/**
* The final configuration for Fizzy created from merging the default
* configuration with the custom configuration.
* @var Zend_Config
*/
protected $_config = null;
/**
* Default Fizzy config
* @var array
*/
protected $_defaultConfig = array (
'application' => array(
'title' => 'Fizzy',
'basePath' => ROOT_PATH,
'defaultLayout' => 'default',
'defaultTemplate' => 'page',
'defaultController' => 'index',
'defaultAction' => 'index',
),
'routes' => array (
# Admin assets control
'admin_assets' => array(
'route' => '/admin/:namespace/*',
'defaults' => array (
'controller' => 'admin_assets',
'action' => 'serve'
)
),
# Admin pages control
'admin_pages' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/admin/pages',
'defaults' => array (
'controller' => 'admin_pages',
'action' => 'list'
)
),
'admin_pages_add' => array(
'route' => '/admin/pages/add',
'defaults' => array (
'controller' => 'admin_pages',
'action' => 'add'
)
),
'admin_pages_edit' => array(
'route' => '/admin/pages/edit/:id',
'defaults' => array (
'controller' => 'admin_pages',
'action' => 'edit'
)
),
'admin_pages_delete' => array(
'route' => '/admin/pages/delete/:id',
'defaults' => array (
'controller' => 'admin_pages',
'action' => 'delete'
)
),
# Admin media
- /*'admin_media' => array(
- 'type' => 'Zend_Controller_Router_Route_Static',
- 'rule' => '/admin/media',
+ 'admin_media_delete' => array(
+ 'route' => '/admin/media/delete/:name',
'defaults' => array (
'controller' => 'admin_media',
- 'action' => 'index'
+ 'action' => 'delete'
)
- ),*/
- /*'admin_media_upload' => array(
+ ),
+ 'admin_media' => array(
'type' => 'Zend_Controller_Router_Route_Static',
- 'rule' => '/admin/media/upload',
+ 'route' => '/admin/media',
'defaults' => array (
'controller' => 'admin_media',
- 'action' => 'upload'
- )
- ),*/
- /*'admin_media_delete' => array(
- 'rule' => '/admin/media/delete/:name',
- 'defaults' => array (
- 'controller' => 'admin_media',
- 'action' => 'delete'
+ 'action' => 'index'
)
- ),*/
+ ),
# Admin users
/*'admin_users' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'rule' => '/admin/users',
'defaults' => array (
'controller' => 'admin_users',
'action' => 'index'
)
),*/
/*'admin_users_add' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'rule' => '/admin/users/add',
'defaults' => array (
'controller' => 'admin_users',
'action' => 'add'
)
),*/
/*'admin_users_edit' => array(
'rule' => '/admin/users/edit/:id',
'defaults' => array (
'controller' => 'admin_users',
'action' => 'edit'
)
),*/
/*'admin_users_delete' => array(
'rule' => '/admin/users/delete/:id',
'defaults' => array (
'controller' => 'admin_users',
'action' => 'delete'
)
),*/
# Static admin routes
/*'admin_configuration' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/admin/configuration',
'defaults' => array (
'controller' => 'admin',
'action' => 'configuration'
)
),*/
/*'admin_logout' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/admin/logout',
'defaults' => array (
'controller' => 'admin',
'action' => 'logout'
)
),*/
/*'admin_login' => array(
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/admin/login',
'defaults' => array (
'controller' => 'admin',
'action' => 'login'
)
),*/
'admin' => array (
'type' => 'Zend_Controller_Router_Route_Static',
'route' => '/admin',
'defaults' => array (
'controller' => 'admin',
'action' => 'index'
)
),
),
'paths' => array(
'application' => 'application',
'controllers' => array (
'fizzy' => 'application/controllers',
'custom' => 'custom/controllers',
),
'models' => 'application/models',
'views' => array(
'fizzy' => 'application/views',
'custom' => 'custom/views'
),
'layouts' => array(
'fizzy' => 'application/views/layouts',
'custom' => 'custom/layouts',
),
'templates' => array (
'fizzy' => 'application/views/scripts',
'custom' => 'custom/templates'
),
'assets' => 'application/views/assets',
'configs' => 'configs',
'custom' => 'custom',
'data' => 'data',
'log' => 'data/fizzy.log',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/**
* The environment to run the application in.
* @var string
*/
protected $_environment = 'production';
/** **/
/**
* Constructs a new bootstrap for Fizzy. A config for Fizzy can be provided
* to override or complement the default configuration.
* @param mixed $config
* @param string $environment
*/
public function __construct($config = null, $environment = 'production')
{
$finalConfig = new Zend_Config($this->_defaultConfig, true);
# Merge the custom configuration with the defaults
if(null !== $config) {
if(is_array($config)) {
$customConfig = new Zend_Config($config);
}
else if($config instanceof Zend_Config) {
$customConfig = $config;
}
else if(is_string($config)) {
$customConfig = $this->_loadConfigFromFile($config);
}
$finalConfig = $finalConfig->merge($customConfig);
unset($customConfig, $config);
}
$this->_config = $finalConfig;
# Correct realtive paths in config
$paths = $this->_correctPaths($this->_config->paths->toArray());
$this->_config->paths = new Zend_Config($paths, true);
unset($paths);
# Load a clean PHP environment
$this->_environment = $environment;
$this->_loadEnvironment();
}
/**
* Loads configuration from a file. INI and XML files are supported through
* Zend_Config_Ini and Zend_Config_XML.
* @param string $path
* @return Zend_Config
*/
protected function _loadConfigFromFile($path)
{
if(!is_file($path) || !is_readable($path)) {
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Could not read config from ' . $path);
}
# Check extension
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($extension) {
case 'ini':
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini($path);
break;
case 'xml':
require_once 'Zend/Config/Xml.php';
$config = new Zend_Config_Xml($path);
break;
default:
require_once 'Fizzy/Exception.php';
throw new Fizzy_Exception('Config type ' . $extension . ' not supported.');
}
return $config;
}
/**
* Returns the configuration for Fizzy.
* @return Zend_Config
*/
public function getConfig()
{
return $this->_config;
}
/**
* Returns the bootstrap environment.
* @return string
*/
public function getEnvironment()
{
return $this->_environment;
}
/**
* Initializes the PHP environment.
*/
protected function _loadEnvironment()
{
# Strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
stripslashes_deep($_GET);
stripslashes_deep($_POST);
stripslashes_deep($_REQUEST);
stripslashes_deep($_COOKIE);
}
if('development' === $this->_environment)
{
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
}
else {
error_reporting(0);
ini_set('display_errors', false);
}
}
/**
* Recursively strip slashes from array values.
* @param string $value
* @return array|string
*/
protected function _stripslashesDeep(&$value)
{
$value = is_array($value) ? array_map(array($this, '_stripslashesDeep'), $value) : stripslashes($value);
return $value;
}
/**
* Initializes the autoloader and registers the Fizzy_ namespace.
* @return Zend_Loader_Autoloader
*/
protected function _initAutoLoader()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fizzy_');
# Autoloading for models
$autoloader->pushAutoloader(array('Fizzy_Autoloader', 'models'));
return $autoloader;
}
/**
* Registers a new Zend_Registry instance.
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = Zend_Registry::getInstance();
# Add config to the registry
Zend_Registry::set('config', $this->_config);
return $registry;
}
/**
* Initializes a logger.
* @todo implement with Zend_Log
* @return Zend_Log
*/
protected function _initLogger()
{
}
/**
* Corrects relative paths by prefixing them with the configured base path.
* @todo Remove ROOT_PATH constant and use configurable basePath as prefix
* @param array|string $value
* @return array|string
*/
protected function _correctPaths($value)
{
if(is_array($value)) {
foreach($value as $childKey => $childValue) {
$value[$childKey] = $this->_correctPaths($childValue);
}
}
else {
if(0 !== strpos($value, DIRECTORY_SEPARATOR)) {
$value = ROOT_PATH . DIRECTORY_SEPARATOR . $value;
}
}
return $value;
}
/**
* Initializes the front controller
*/
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
if('production' !== $this->_environment) {
$frontController->throwExceptions(true);
}
# Add configuration
$frontController->setDefaultControllerName($this->_config->application->defaultController)
->setDefaultAction($this->_config->application->defaultAction)
->setDefaultModule('fizzy');
$controllers = $this->_config->paths->controllers->toArray();
foreach($controllers as $module => $path) {
$frontController->addControllerDirectory($path, $module);
}
return $frontController;
}
/**
* Loads the configured routes into the router.
* @return Zend_Router
*/
protected function _initRouter()
{
$front = Zend_Controller_Front::getInstance();
$routes = $this->_config->routes;
$front->getRouter()->clearParams();
$router = $front->getRouter()->addConfig($routes);
return $router;
}
/**
* Initializes the Fizzy storage backend
* @return Fizzy_Storage
*/
protected function _initStorage()
{
if(isset($this->_config->storage)) {
$storage = new Fizzy_Storage($this->_config->storage->toArray());
Zend_Registry::set('storage', $storage);
}
return $storage;
}
/**
* Initializes a new view object and loads the view directories into it.
* @return Zend_View
*/
protected function _initView()
{
$viewPaths = $this->_config->paths->views->toArray();
$view = new Zend_View();
foreach($viewPaths as $path) {
$view->addBasePath($path);
}
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $view;
}
/**
* Starts Zend_Layout in MVC mode.
* @todo add custom front controller plugin for layout allow multiple layouts
* @return Zend_Layout
*/
protected function _initLayout()
{
$layoutPaths = $this->_config->paths->layouts->toArray();
$layout = new Zend_Layout($layoutPaths['fizzy'], true);
$layout->setLayout('admin');
return $layout;
}
/**
* Run the bootstrap sequence.
* @param boolean $dispatch Dispatch immediately after bootstrapping is done.
*/
public function run($dispatch = true)
{
# Run the bootstrap sequence
foreach($this->_bootstrap as $stage => $value) {
$methodName = '_init' . ucfirst($stage);
if(is_callable(array($this, $methodName))) {
$this->_bootstrap[$stage] = $this->$methodName();
}
}
# Dispatch the request
if($dispatch) {
$this->_bootstrap['frontController']->dispatch();
}
}
/**
* Catch getXYZ calls and check if the result of a bootstrap stage is
* requested.
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
# Strip get from the method name
$step = str_replace('get', '', $name);
# Lowercase the first character
$step = strtolower(substr($step, 0, 1)) . substr($step, 1);
# Search for the bootstrap step
if(array_key_exists($step, $this->_bootstrap)) {
return $this->_bootstrap[$step];
}
}
}
}
\ No newline at end of file
diff --git a/application/views/helpers/LinkConfirm.php b/application/views/helpers/LinkConfirm.php
new file mode 100644
index 0000000..f7ddf7d
--- /dev/null
+++ b/application/views/helpers/LinkConfirm.php
@@ -0,0 +1,15 @@
+<?php
+
+class Zend_View_Helper_LinkConfirm extends Zend_View_Helper_HtmlElement
+{
+
+ public function linkConfirm($url, $text, $confirm, array $attribs = array())
+ {
+ $html = '<a href="%s" onClick="return confirm(\'%s\');"%s>%s</a>';
+
+ $attributes = $this->_htmlAttribs($attribs);
+
+ return sprintf($html, $url, $confirm, $attribs, $text);
+ }
+
+}
\ No newline at end of file
diff --git a/application/views/scripts/admin/media/list.phtml b/application/views/scripts/admin/media/list.phtml
index 2cddb5d..2d9d11a 100644
--- a/application/views/scripts/admin/media/list.phtml
+++ b/application/views/scripts/admin/media/list.phtml
@@ -1,118 +1,118 @@
<?php
// file type image declarations
$types = array(
- 'png' => $this->url('/images/icon/page_white_picture.png'),
- 'jpg' => $this->url('/images/icon/page_white_picture.png'),
- 'jpeg' => $this->url('/images/icon/page_white_picture.png'),
- 'bmp' => $this->url('/images/icon/page_white_picture.png'),
- 'gif' => $this->url('/images/icon/page_white_picture.png'),
- 'doc' => $this->url('/images/icon/page_white_word.png'),
- 'docx' => $this->url('/images/icon/page_white_word.png'),
- 'xls' => $this->url('/images/icon/page_white_excel.png'),
- 'ppt' => $this->url('/images/icon/page_white_powerpoint.png'),
- 'pdf' => $this->url('/images/icon/page_white_text.png'),
- 'flv' => $this->url('/images/icon/page_white_flash.png'),
- 'zip' => $this->url('/images/icon/page_white_zip.png'),
- 'rar' => $this->url('/images/icon/page_white_zip.png'),
- 'txt' => $this->url('/images/icon/page_white_text.png'),
+ 'png' => $this->baseUrl('/admin/images/icon/page_white_picture.png'),
+ 'jpg' => $this->baseUrl('/admin/images/icon/page_white_picture.png'),
+ 'jpeg' => $this->baseUrl('/admin/images/icon/page_white_picture.png'),
+ 'bmp' => $this->baseUrl('/admin/images/icon/page_white_picture.png'),
+ 'gif' => $this->baseUrl('/admin/images/icon/page_white_picture.png'),
+ 'doc' => $this->baseUrl('/admin/images/icon/page_white_word.png'),
+ 'docx' => $this->baseUrl('/admin/images/icon/page_white_word.png'),
+ 'xls' => $this->baseUrl('/admin/images/icon/page_white_excel.png'),
+ 'ppt' => $this->baseUrl('/admin/images/icon/page_white_powerpoint.png'),
+ 'pdf' => $this->baseUrl('/admin/images/icon/page_white_text.png'),
+ 'flv' => $this->baseUrl('/admin/images/icon/page_white_flash.png'),
+ 'zip' => $this->baseUrl('/admin/images/icon/page_white_zip.png'),
+ 'rar' => $this->baseUrl('/admin/images/icon/page_white_zip.png'),
+ 'txt' => $this->baseUrl('/admin/images/icon/page_white_text.png'),
);
?>
<h1 class="header">Media</h1>
<p>
On this page you find the media available within Fizzy. With the form on the
bottom of the page you are able to add files to Fizzy that you can use in
your pages.
</p>
<div id="uploaded-files">
<h2>Files overview</h2>
<div class="files-container">
<table class="files-table">
<?php if(0 < count($this->files)) : ?>
<thead>
<tr>
<td colspan="2">Filename</td>
<td>Size</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->files as $fileInfo) : ?>
<tr>
- <td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/images/icon/page.png'); ?>" alt="" /></td>
+ <td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->baseUrl('/images/icon/page.png'); ?>" alt="" /></td>
<td class="filename"><?= $fileInfo->basename; ?></td>
<td class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
<td class="controls">
- <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/images/icon/view.png'); ?></a>
+ <a href="<?= $this->baseUrl('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/admin/images/icon/view.png'); ?></a>
<?php if(is_writable($this->uploadFolder)) : ?>
- <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?= $this->linkConfirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/admin/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php else : ?>
<tr>
<td>
No uploaded files were found. Use the form at the bottom to
add new files.
</td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
<div id="upload-form">
<h2 class="header">Upload</h2>
<p>
Upload a new file by selecting it on your machine. Check the box if
you want to overwrite a file that already exists with the same name.
<br />
</p>
<?php if(is_writable($this->uploadFolder)) : ?>
- <form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
+ <form action="<?= $this->baseUrl('/admin/media'); ?>" method="post" enctype="multipart/form-data">
<?php if(isset($this->messages) && !empty($this->messages)) : ?>
<div class="message error">
<ul>
<?php foreach($this->messages as $message) : ?>
<li><?= $message ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div>
<input name="upload" type="file" /><br />
<small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
</div>
<div>
<label for="overwrite">Overwrite existing file?</label>
<input type="checkbox" name="overwrite" value="1" />
</div>
<div>
<input type="submit" value="Upload" />
</div>
</form>
<?php else : ?>
<div class="message notice">
<p>
The upload directory found in the Fizzy configuration is not
writable. Upload functionality will be disabled until it is made
writable.
</p>
</div>
<?php endif; ?>
</div>
|
jtietema/Fizzy
|
eef95006ff454ac3b095e4c444ce0567951ee5d3
|
edit support in WYSIWYG Fizzy Media plugin
|
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
index ab2bfb3..4782a6e 100644
--- a/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
@@ -1,43 +1,67 @@
tinyMCEPopup.requireLangPack();
var selectedImage = null;
var selectedElement = null;
function select(image, element){
selectedImage = image;
if (selectedElement != null){
selectedElement.style.background = '#ffffff';
}
selectedElement = element;
selectedElement.style.background = '#5555ff';
}
var FizzymediaDialog = {
- init : function() {
+ init : function(ed) {
+ var f = document.forms[0],
+ nl = f.elements,
+ ed = tinyMCEPopup.editor,
+ dom = ed.dom,
+ n = ed.selection.getNode();
+ /* check if there is an image selected. If so we edit that image
+ instead of inserting a new one */
+ if (n.nodeName == 'IMG'){
+ // set the image properties
+ nl.width.value = dom.getAttrib(n, 'width');
+ nl.height.value = dom.getAttrib(n, 'height');
+ nl.alt.value = dom.getAttrib(n, 'alt');
+ nl.insert.value = ed.getLang('update');
+
+ // select the image
+ var src = dom.getAttrib(n, 'src');
+ var image = document.getElementById(src);
+ select(src, image);
+ }
},
insert : function() {
+ if (selectedImage === null){
+ alert('Please select an Image!');
+ return;
+ }
// Insert the contents from the input into the document
var width = document.getElementById('width').value;
var height = document.getElementById('height').value;
- var border = document.getElementById('border').value;
+ //var border = document.getElementById('border').value;
- var description = document.getElementById('description').value;
+ var description = document.getElementById('alt').value;
var imageTag = '<img src="' + selectedImage + '" alt="' + description + '" ';
if (width != ''){
imageTag += 'width="' + width +'" ';
}
if (height != ''){
imageTag += 'height="' + height + '" ';
}
+ /*
if (border != ''){
imageTag += 'style="border: solid ' + border + 'px black;" ';
- }
+ }*/
imageTag += '/>';
tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageTag);
tinyMCEPopup.close();
}
};
tinyMCEPopup.onInit.add(FizzymediaDialog.init, FizzymediaDialog);
diff --git a/application/views/scripts/admin/media/gallery.phtml b/application/views/scripts/admin/media/gallery.phtml
index d983221..831f100 100644
--- a/application/views/scripts/admin/media/gallery.phtml
+++ b/application/views/scripts/admin/media/gallery.phtml
@@ -1,53 +1,55 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#fizzymedia_dlg.title}</title>
<link href="<?= $this->url("/admin/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../../admin/js/tiny_mce/tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../admin/js/tiny_mce/plugins/fizzymedia/js/dialog.js"></script>
</head>
<body>
<div class="files-container">
<?php foreach($this->files as $fileInfo) : ?>
- <div class="thumbnail" onclick="select('<?= $this->url('/uploads/' . $fileInfo->basename); ?>', this);">
+ <div class="thumbnail" id="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" onclick="select('<?= $this->url('/uploads/' . $fileInfo->basename); ?>', this);">
<img class="thumbnail" src="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
<div class="filename">
<?php if (strlen($fileInfo->basename) > 14):?>
<?= substr($fileInfo->basename, 0, 14); ?>...
<?php else: ?>
<?= $fileInfo->basename ?>
<?php endif; ?>
</div>
<div class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<form onsubmit="FizzymediaDialog.insert();return false;" action="#">
<div>
<label>Description:</label>
- <input type="text" name="alt" id="description" />
+ <input type="text" name="alt" id="alt" />
<label>Width</label>
<input type="text" name="width" id="width" />
<label>Height</label>
<input type="text" name="height" id="height" />
+<!--
<label>Border</label>
<input type="text" name="border" id="border" />
+-->
<div class="clear"></div>
<input type="button" name="insert" value="{#insert}" onclick="FizzymediaDialog.insert();" />
<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>
\ No newline at end of file
|
jtietema/Fizzy
|
17b715901863fcad63daaa5955d63d6ccfbbd22b
|
initial version WYSIWYG integration
|
diff --git a/application/controllers/AdminMediaController.php b/application/controllers/AdminMediaController.php
index f21a2b8..61fdca8 100644
--- a/application/controllers/AdminMediaController.php
+++ b/application/controllers/AdminMediaController.php
@@ -1,157 +1,195 @@
<?php
/**
* Class AdminMediaController
* @package Fizzy
* @subpackage Controller
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** SecureController */
require_once 'SecureController.php';
/**
* Controller for media inside Fizzy. Enables basic upload and deletion of files.
* @author Mattijs Hoitink <[email protected]>
*/
class AdminMediaController extends SecureController
{
/**
* All common code for defaultAction and thumbnailsAction
*/
protected function _show()
{
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if($this->getRequest()->getMethod() === Fizzy_Request::METHOD_POST)
{
if(isset($_FILES) && !empty($_FILES['upload'])) {
$overwrite = ((boolean) isset($_POST['overwrite']) && !empty($_POST['overwrite']));
$messages = $this->_handleUpload('upload', $uploadFolder, $overwrite);
$this->getView()->messages = $messages;
}
}
// check if the uploads folder exists and is writable
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if (!is_dir($uploadFolder) || !is_writable($uploadFolder))
{
$this->getView()->setScript('/admin/media/foldererror.phtml');
return;
}
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
);
$files[] = (object) $fileInfo;
}
}
// Render the view
$this->getView()->uploadFolder = $uploadFolder;
$this->getView()->files = $files;
$this->getView()->post_max_size = ini_get('post_max_size');
$this->getView()->upload_max_filesize = ini_get('upload_max_filesize');
}
public function defaultAction()
{
$this->_show();
$this->getView()->setScript('/admin/media/list.phtml');
}
public function thumbnailsAction()
{
$this->_show();
$this->getView()->setScript('/admin/media/thumbnails.phtml');
}
/**
* Deletes an uploaded file.
*/
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
}
}
$this->_redirect('/admin/media');
}
public function uploadAction()
{
$this->_redirect('/admin/media');
}
/**
* Handles a file upload.
* @param string $name
* @param string $uploadFolder
* @return array
*/
protected function _handleUpload($name, $uploadFolder, $overwrite = false)
{
$file = $_FILES[$name];
if ($file['error'] == UPLOAD_ERR_OK) {
$target = $file["tmp_name"];
$destination = $uploadFolder . DIRECTORY_SEPARATOR . $file["name"];
if(!file_exists($destination) || $overwrite)
{
move_uploaded_file($target, $destination);
}
else
{
unlink($target);
}
return array();
}
else {
switch($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('The uploaded file exceeds the Maximum upload filesize.');
break;
case UPLOAD_ERR_PARTIAL:
return array('The uploaded file was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
return array('No file was uploaded.');
break;
default:
return array('An internal server error occurred.');
}
}
}
+ public function galleryAction()
+ {
+ $this->getView()->setLayout('nolayout');
+ $uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
+
+ // check if the uploads folder exists and is writable
+ $uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
+ if (!is_dir($uploadFolder) || !is_writable($uploadFolder))
+ {
+ $this->getView()->setScript('/admin/media/foldererror.phtml');
+ return;
+ }
+ // Parse all files in the upload directory
+ $files = array();
+ $imageTypes = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
+ foreach(new DirectoryIterator($uploadFolder) as $file)
+ {
+ if($file->isFile())
+ {
+ $fileInfo = array(
+ 'type' => substr(strrchr($file->getBaseName(), '.'), 1),
+ 'basename' => $file->getBaseName(),
+ 'path' => $file->getPath(),
+ 'size' => $file->getSize(),
+ );
+ if (in_array($fileInfo['type'], $imageTypes)) {
+ $files[] = (object) $fileInfo;
+ }
+ }
+ }
+
+ // Render the view
+ $this->getView()->files = $files;
+ $this->getView()->disable();
+ $this->getView()->setScript('/admin/media/gallery.phtml');
+ echo $this->getView()->render();
+ }
+
}
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
new file mode 100644
index 0000000..70f6160
--- /dev/null
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin.js
@@ -0,0 +1 @@
+(function(){tinymce.PluginManager.requireLangPack('fizzymedia');tinymce.create('tinymce.plugins.FizzymediaPlugin',{init:function(ed,url){ed.addCommand('fizzyMedia',function(){ed.windowManager.open({file:url+'../../../../../media/gallery',width:640+parseInt(ed.getLang('fizzymedia.delta_width',0)),height:480+parseInt(ed.getLang('fizzymedia.delta_height',0)),inline:1},{plugin_url:url,some_custom_arg:'custom arg'})});ed.addButton('fizzymedia',{title:'fizzymedia.desc',cmd:'fizzyMedia',image:url+'/img/example.gif'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('fizzymedia',n.nodeName=='IMG')})},createControl:function(n,cm){return null},getInfo:function(){return{longname:'Fizzy Media plugin',author:'Jeroen Tietema',authorurl:'http://www.voidwalkers.nl',infourl:'http://project.voidwalkers.nl/projects/show/fizzy',version:"1.0"}}});tinymce.PluginManager.add('fizzymedia',tinymce.plugins.FizzymediaPlugin)})();
\ No newline at end of file
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js
new file mode 100644
index 0000000..04459f0
--- /dev/null
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/editor_plugin_src.js
@@ -0,0 +1,82 @@
+/**
+ * TinyMCE plugin for the Fizzy Media Library
+ *
+ * @author Jeroen Tietema <[email protected]>
+ * @copyright Copyright 2009, Voidwalkers, All rights reserved.
+ */
+
+(function() {
+ // Load plugin specific language pack
+ tinymce.PluginManager.requireLangPack('fizzymedia');
+
+ tinymce.create('tinymce.plugins.FizzymediaPlugin', {
+ /**
+ * Initializes the plugin, this will be executed after the plugin has been created.
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
+ * of the editor instance to intercept that event.
+ *
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+ * @param {string} url Absolute URL to where the plugin is located.
+ */
+ init : function(ed, url) {
+ // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
+ ed.addCommand('fizzyMedia', function() {
+ ed.windowManager.open({
+ //
+ file : url + '../../../../../media/gallery',
+ width : 640 + parseInt(ed.getLang('fizzymedia.delta_width', 0)),
+ height : 480 + parseInt(ed.getLang('fizzymedia.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url, // Plugin absolute URL
+ some_custom_arg : 'custom arg' // Custom argument
+ });
+ });
+
+ // Register example button
+ ed.addButton('fizzymedia', {
+ title : 'fizzymedia.desc',
+ cmd : 'fizzyMedia',
+ image : url + '/img/example.gif'
+ });
+
+ // Add a node change handler, selects the button in the UI when a image is selected
+ ed.onNodeChange.add(function(ed, cm, n) {
+ cm.setActive('fizzymedia', n.nodeName == 'IMG');
+ });
+ },
+
+ /**
+ * Creates control instances based in the incomming name. This method is normally not
+ * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
+ * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
+ * method can be used to create those.
+ *
+ * @param {String} n Name of the control to create.
+ * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
+ * @return {tinymce.ui.Control} New control instance or null if no control was created.
+ */
+ createControl : function(n, cm) {
+ return null;
+ },
+
+ /**
+ * Returns information about the plugin as a name/value array.
+ * The current keys are longname, author, authorurl, infourl and version.
+ *
+ * @return {Object} Name/value array containing information about the plugin.
+ */
+ getInfo : function() {
+ return {
+ longname : 'Fizzy Media plugin',
+ author : 'Jeroen Tietema',
+ authorurl : 'http://www.voidwalkers.nl',
+ infourl : 'http://project.voidwalkers.nl/projects/show/fizzy',
+ version : "1.0"
+ };
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('fizzymedia', tinymce.plugins.FizzymediaPlugin);
+})();
\ No newline at end of file
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/img/example.gif b/application/views/assets/js/tiny_mce/plugins/fizzymedia/img/example.gif
new file mode 100644
index 0000000..1ab5da4
Binary files /dev/null and b/application/views/assets/js/tiny_mce/plugins/fizzymedia/img/example.gif differ
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
new file mode 100644
index 0000000..ab2bfb3
--- /dev/null
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/js/dialog.js
@@ -0,0 +1,43 @@
+tinyMCEPopup.requireLangPack();
+
+var selectedImage = null;
+var selectedElement = null;
+
+function select(image, element){
+ selectedImage = image;
+ if (selectedElement != null){
+ selectedElement.style.background = '#ffffff';
+ }
+ selectedElement = element;
+ selectedElement.style.background = '#5555ff';
+}
+
+var FizzymediaDialog = {
+ init : function() {
+
+ },
+
+ insert : function() {
+ // Insert the contents from the input into the document
+ var width = document.getElementById('width').value;
+ var height = document.getElementById('height').value;
+ var border = document.getElementById('border').value;
+
+ var description = document.getElementById('description').value;
+ var imageTag = '<img src="' + selectedImage + '" alt="' + description + '" ';
+ if (width != ''){
+ imageTag += 'width="' + width +'" ';
+ }
+ if (height != ''){
+ imageTag += 'height="' + height + '" ';
+ }
+ if (border != ''){
+ imageTag += 'style="border: solid ' + border + 'px black;" ';
+ }
+ imageTag += '/>';
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, imageTag);
+ tinyMCEPopup.close();
+ }
+};
+
+tinyMCEPopup.onInit.add(FizzymediaDialog.init, FizzymediaDialog);
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en.js
new file mode 100644
index 0000000..5df5063
--- /dev/null
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en.js
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('en.fizzymedia',{
+ desc : 'Insert Media from the Fizzy Media Library'
+});
diff --git a/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en_dlg.js
new file mode 100644
index 0000000..dcb23c3
--- /dev/null
+++ b/application/views/assets/js/tiny_mce/plugins/fizzymedia/langs/en_dlg.js
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('en.fizzymedia_dlg',{
+ title : 'Fizzy Media Library'
+});
diff --git a/application/views/layouts/nolayout.phtml b/application/views/layouts/nolayout.phtml
new file mode 100644
index 0000000..92b0796
--- /dev/null
+++ b/application/views/layouts/nolayout.phtml
@@ -0,0 +1,6 @@
+<!--
+The no layout layout =)
+
+Can safely be removed after the move to Zend Framework
+-->
+<?= $this->content ?>
\ No newline at end of file
diff --git a/application/views/scripts/admin/media/gallery.phtml b/application/views/scripts/admin/media/gallery.phtml
new file mode 100644
index 0000000..d983221
--- /dev/null
+++ b/application/views/scripts/admin/media/gallery.phtml
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#fizzymedia_dlg.title}</title>
+ <link href="<?= $this->url("/admin/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ <script type="text/javascript" src="../../admin/js/tiny_mce/tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="../../admin/js/tiny_mce/plugins/fizzymedia/js/dialog.js"></script>
+</head>
+<body>
+<div class="files-container">
+ <?php foreach($this->files as $fileInfo) : ?>
+ <div class="thumbnail" onclick="select('<?= $this->url('/uploads/' . $fileInfo->basename); ?>', this);">
+ <img class="thumbnail" src="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
+
+ <div class="filename">
+ <?php if (strlen($fileInfo->basename) > 14):?>
+ <?= substr($fileInfo->basename, 0, 14); ?>...
+ <?php else: ?>
+ <?= $fileInfo->basename ?>
+ <?php endif; ?>
+ </div>
+ <div class="size">
+ <?php if($fileInfo->size < 1024) : ?>
+ <?= round($fileInfo->size, 2); ?> b
+ <?php elseif((1024*1024) > $fileInfo->size) : ?>
+ <?= round($fileInfo->size / 1024, 2); ?> KB
+ <?php else : ?>
+ <?= round($fileInfo->size / (1024*1024), 2); ?> MB
+ <?php endif; ?>
+ </div>
+ </div>
+ <?php endforeach; ?>
+
+
+</div>
+<form onsubmit="FizzymediaDialog.insert();return false;" action="#">
+<div>
+<label>Description:</label>
+ <input type="text" name="alt" id="description" />
+<label>Width</label>
+ <input type="text" name="width" id="width" />
+<label>Height</label>
+ <input type="text" name="height" id="height" />
+<label>Border</label>
+ <input type="text" name="border" id="border" />
+<div class="clear"></div>
+ <input type="button" name="insert" value="{#insert}" onclick="FizzymediaDialog.insert();" />
+ <input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+</div>
+</form>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/application/views/scripts/admin/page/form.phtml b/application/views/scripts/admin/page/form.phtml
index a64dff7..055a034 100644
--- a/application/views/scripts/admin/page/form.phtml
+++ b/application/views/scripts/admin/page/form.phtml
@@ -1,132 +1,134 @@
<?php
/**
* Admin page form view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<h1>Page</h1>
<div class="form-container">
<form action="<?= $this->url("/admin/page/$this->action") ?>" method="post" name="PageForm" id="PageForm">
<?php if ($this->action === 'edit'): ?>
<input type="hidden" name="id" value="<?= $this->page->getId() ?>">
<?php endif; ?>
<div class="form-row">
<label for="title">Title</label>
<input type="text" name="title" id="title" value="<?= $this->page->getTitle() ?>" />
</div>
<div class="form-row">
<label for="slug">Slug</label>
<input type="text" name="slug" id="slug" value="<?= $this->page->getSlug() ?>" />
</div>
<div class="form-row yui-skin-sam">
<label for="body">Body</label>
<div>
<textarea name="body" id="body" style="width: 100%;"><?= $this->page->getBody() ?></textarea>
</div>
<div class="clear"></div>
<div style="text-align: right;" id="editor-toggle"></div>
</div>
<?php if(0 < count($this->availableTemplates)) : ?>
<div class="form-row">
<label for="template">Template</label>
<select name="template" id="template">
<option value="null">Default</option>
<?php foreach($this->availableTemplates as $template) : ?>
<option value="<?= $template; ?>" <?= $this->page->getTemplate() === $template ? 'selected="selected"' : '' ?>>
<?= $template; ?>
</option>
<?php endforeach;?>
</select>
</div>
<?php endif;?>
<?php if(0 < count($this->availableLayouts)) : ?>
<div class="form-row">
<label for="template">Layout</label>
<select name="layout" id="layout">
<option value="null">Default</option>
<?php foreach($this->availableLayouts as $template) : ?>
<option value="<?= $template; ?>" <?= $this->page->getLayout() === $template ? 'selected="selected"' : '' ?>>
<?= $template; ?>
</option>
<?php endforeach;?>
</select>
</div>
<?php endif; ?>
<div class="form-row">
<label for="homepage">Homepage?</label>
<input type="checkbox" name="homepage" id="homepage" value="1" <?= $this->page->getHomepage() !== null ? 'checked="checked"' : '' ?> />
</div>
<div class="form-row form-row-last">
<input type="submit" name="PageFormSubmit" id="PageFormSubmit" value="Save" /> or <a href="/admin/pages">cancel</a>
</div>
</form>
</div>
<script type="text/javascript">
YUI().use('node-base', 'event', function(Y) {
var toggleButton;
// init tinyMCE
function init() {
tinyMCE.init({
mode : "exact",
elements: "body",
theme : "advanced",
+ plugins: "fizzymedia",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
- theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
+ theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo,fizzymedia",
theme_advanced_buttons2 : "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
theme_advanced_buttons3: "",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
- theme_advanced_resize_horizontal : false
+ theme_advanced_resize_horizontal : false,
+ relative_urls : false
});
toggleButton = Y.Node.create('<a href="#" id="toggleButton">hide editor</a>');
toggleButton.on('click', toggleEditor);
Y.Node.one('#editor-toggle').insert(toggleButton);
}
var toggleEditor = function(id) {
tinyMCE.execCommand('mceToggleEditor', false, 'body');
if(tinyMCE.getInstanceById('body').isHidden()) {
toggleButton.setContent('show editor');
}
else {
toggleButton.setContent('hide editor');
}
}
// Wait for DOM to finish
Y.on("domready", init);
});
</script>
diff --git a/configs/routes.xml b/configs/routes.xml
index 5d64e54..68c3d7f 100644
--- a/configs/routes.xml
+++ b/configs/routes.xml
@@ -1,138 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<fizzy version="0.4">
<routes>
<!--
Pages frontend
-->
<short_slug type="simple">
<rule>/:slug</rule>
<controller>page</controller>
<action>show</action>
</short_slug>
<homepage type="static">
<rule>/</rule>
<controller>page</controller>
<action>homepage</action>
</homepage>
<page_by_slug type="simple">
<rule>page/:slug</rule>
<controller>page</controller>
<action>show</action>
</page_by_slug>
<pages type="static">
<rule>pages</rule>
<controller>page</controller>
<action>list</action>
</pages>
<pages_all type="static">
<rule>pages/all</rule>
<controller>page</controller>
<action>list</action>
</pages_all>
<page_by_id type="regex">
<rule>pages/(\d+)/(\+d)</rule>
<controller>page</controller>
<action>show</action>
<parameters>
<param>id</param>
<param>user</param>
</parameters>
</page_by_id>
<!-- Admin sections -->
<admin type="static">
<rule>/admin</rule>
<controller>Admin</controller>
<action>default</action>
</admin>
<admin_logout type="static">
<rule>/admin/logout</rule>
<controller>Admin</controller>
<action>logout</action>
</admin_logout>
<admin_configuration type="static">
<rule>/admin/configuration</rule>
<controller>Admin</controller>
<action>configuration</action>
</admin_configuration>
<admin_assets type="simple">
<rule>/admin/:namespace/:asset</rule>
<controller>AdminAssets</controller>
<action>serve</action>
</admin_assets>
<!-- Pages admin section -->
<admin_pages type="static">
<rule>/admin/pages</rule>
<controller>AdminPages</controller>
<action>list</action>
</admin_pages>
<add_page type="static">
<rule>/admin/page/add</rule>
<controller>AdminPages</controller>
<action>add</action>
</add_page>
<admin_page_by_id type="simple">
<rule>/admin/page/edit/:id</rule>
<controller>AdminPages</controller>
<action>edit</action>
</admin_page_by_id>
<admin_delete_page_by_id type="simple">
<rule>/admin/page/delete/:id</rule>
<controller>AdminPages</controller>
<action>delete</action>
</admin_delete_page_by_id>
<!-- Media admin sections -->
<admin_media type="static">
<rule>/admin/media</rule>
<controller>AdminMedia</controller>
<action>default</action>
</admin_media>
<admin_media_thumbnails type="static">
<rule>/admin/media/thumbnails</rule>
<controller>AdminMedia</controller>
<action>thumbnails</action>
</admin_media_thumbnails>
<admin_media_upload type="static">
<rule>/admin/media/upload</rule>
<controller>AdminMedia</controller>
<action>upload</action>
</admin_media_upload>
<admin_media_delete type="simple">
<rule>/admin/media/delete/:name</rule>
<controller>AdminMedia</controller>
<action>delete</action>
</admin_media_delete>
+ <admin_media_gallery type="static">
+ <rule>/admin/media/gallery</rule>
+ <controller>AdminMedia</controller>
+ <action>gallery</action>
+ </admin_media_gallery>
<!-- Menu admin sections -->
<admin_menu type="static">
<rule>/admin/menu</rule>
<controller>AdminMenu</controller>
<action>show</action>
</admin_menu>
<!-- Users admin section -->
<admin_users type="static">
<rule>admin/users</rule>
<controller>AdminUsers</controller>
<action>list</action>
</admin_users>
<admin_add_user type="static">
<rule>admin/user/add</rule>
<controller>AdminUsers</controller>
<action>add</action>
</admin_add_user>
<admin_edit_user type="simple">
<rule>admin/user/edit/:id</rule>
<controller>AdminUsers</controller>
<action>edit</action>
</admin_edit_user>
<admin_delete_user type="simple">
<rule>/admin/user/delete/:id</rule>
<controller>AdminUsers</controller>
<action>delete</action>
</admin_delete_user>
</routes>
</fizzy>
|
jtietema/Fizzy
|
cef8572f460c309258a10d1f6c2019788f6a7860
|
fixes icons in user view
|
diff --git a/application/views/scripts/admin/users.phtml b/application/views/scripts/admin/users.phtml
index 0f079bd..10b3387 100644
--- a/application/views/scripts/admin/users.phtml
+++ b/application/views/scripts/admin/users.phtml
@@ -1,46 +1,46 @@
<?php
/**
* Admin users view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<h1>Users</h1>
<div>
<table class="data-table">
<thead>
<tr>
<td>Username</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->users as $user) : ?>
<tr>
<td><?= $user->username; ?></td>
<td>
- <a href="<?= $this->url("/admin/user/edit/$user->getId()") ?>" title="Edit user"><img src="<?= $this->url("/images/icon/edit.png") ?>" alt="edit icon" /></a>
- <a href="<?= $this->url("/admin/user/delete/$user->getId()") ?>" title="Delete user"><img src="<?= $this->url("/images/icon/sign_remove.png") ?>" alt="delete icon" /></a>
+ <a href="<?= $this->url("/admin/user/edit/$user->getId()") ?>" title="Edit user"><img src="<?= $this->url("/admin/images/icon/edit.png") ?>" alt="edit icon" /></a>
+ <a href="<?= $this->url("/admin/user/delete/$user->getId()") ?>" title="Delete user"><img src="<?= $this->url("/admin/images/icon/sign_remove.png") ?>" alt="delete icon" /></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
- <?= $this->link('/admin/user/add', $this->img('/images/icon/add.png') . ' Add User'); ?>
+ <?= $this->link('/admin/user/add', $this->img('/admin/images/icon/add.png') . ' Add User'); ?>
</p>
</div>
|
jtietema/Fizzy
|
7a5ec7c63031d3798d3ce8b282e3fb549d5145c3
|
fixes icons in user view
|
diff --git a/application/views/scripts/admin/users.phtml b/application/views/scripts/admin/users.phtml
index 0f079bd..10b3387 100644
--- a/application/views/scripts/admin/users.phtml
+++ b/application/views/scripts/admin/users.phtml
@@ -1,46 +1,46 @@
<?php
/**
* Admin users view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<h1>Users</h1>
<div>
<table class="data-table">
<thead>
<tr>
<td>Username</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->users as $user) : ?>
<tr>
<td><?= $user->username; ?></td>
<td>
- <a href="<?= $this->url("/admin/user/edit/$user->getId()") ?>" title="Edit user"><img src="<?= $this->url("/images/icon/edit.png") ?>" alt="edit icon" /></a>
- <a href="<?= $this->url("/admin/user/delete/$user->getId()") ?>" title="Delete user"><img src="<?= $this->url("/images/icon/sign_remove.png") ?>" alt="delete icon" /></a>
+ <a href="<?= $this->url("/admin/user/edit/$user->getId()") ?>" title="Edit user"><img src="<?= $this->url("/admin/images/icon/edit.png") ?>" alt="edit icon" /></a>
+ <a href="<?= $this->url("/admin/user/delete/$user->getId()") ?>" title="Delete user"><img src="<?= $this->url("/admin/images/icon/sign_remove.png") ?>" alt="delete icon" /></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
- <?= $this->link('/admin/user/add', $this->img('/images/icon/add.png') . ' Add User'); ?>
+ <?= $this->link('/admin/user/add', $this->img('/admin/images/icon/add.png') . ' Add User'); ?>
</p>
</div>
|
jtietema/Fizzy
|
256aa1441bcb14edf90de0cd968c3300a98b6bf3
|
fixed icons in Media Gallery
|
diff --git a/application/views/assets/images/icon/page_white_text.png b/application/views/assets/images/icon/page_white_text.png
new file mode 100644
index 0000000..6a890d5
Binary files /dev/null and b/application/views/assets/images/icon/page_white_text.png differ
diff --git a/application/views/scripts/admin/media/list.phtml b/application/views/scripts/admin/media/list.phtml
index d2a5d01..8b5548c 100644
--- a/application/views/scripts/admin/media/list.phtml
+++ b/application/views/scripts/admin/media/list.phtml
@@ -1,119 +1,119 @@
<?php
// file type image declarations
$types = array(
- 'png' => $this->url('/images/icon/page_white_picture.png'),
- 'jpg' => $this->url('/images/icon/page_white_picture.png'),
- 'jpeg' => $this->url('/images/icon/page_white_picture.png'),
- 'bmp' => $this->url('/images/icon/page_white_picture.png'),
- 'gif' => $this->url('/images/icon/page_white_picture.png'),
- 'doc' => $this->url('/images/icon/page_white_word.png'),
- 'docx' => $this->url('/images/icon/page_white_word.png'),
- 'xls' => $this->url('/images/icon/page_white_excel.png'),
- 'ppt' => $this->url('/images/icon/page_white_powerpoint.png'),
- 'pdf' => $this->url('/images/icon/page_white_text.png'),
- 'flv' => $this->url('/images/icon/page_white_flash.png'),
- 'zip' => $this->url('/images/icon/page_white_zip.png'),
- 'rar' => $this->url('/images/icon/page_white_zip.png'),
- 'txt' => $this->url('/images/icon/page_white_text.png'),
+ 'png' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpeg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'bmp' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'gif' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'doc' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'docx' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'xls' => $this->url('/admin/images/icon/page_white_excel.png'),
+ 'ppt' => $this->url('/admin/images/icon/page_white_powerpoint.png'),
+ 'pdf' => $this->url('/admin/images/icon/page_white_text.png'),
+ 'flv' => $this->url('/admin/images/icon/page_white_flash.png'),
+ 'zip' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'rar' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'txt' => $this->url('/admin/images/icon/page_white_text.png'),
);
?>
<h1 class="header">Media</h1>
<p>
On this page you find the media available within Fizzy. With the form on the
bottom of the page you are able to add files to Fizzy that you can use in
your pages.
</p>
<div id="uploaded-files">
<h2>Files overview</h2>
<div class="files-container">
<table class="files-table">
<?php if(0 < count($this->files)) : ?>
<thead>
<tr>
<td colspan="2">Filename</td>
<td>Size</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->files as $fileInfo) : ?>
<tr>
- <td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/images/icon/page.png'); ?>" alt="" /></td>
+ <td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/admin/images/icon/page.png'); ?>" alt="" /></td>
<td class="filename"><?= $fileInfo->basename; ?></td>
<td class="size">
<?php if($fileInfo->size < 1024) : ?>
<?= round($fileInfo->size, 2); ?> b
<?php elseif((1024*1024) > $fileInfo->size) : ?>
<?= round($fileInfo->size / 1024, 2); ?> KB
<?php else : ?>
<?= round($fileInfo->size / (1024*1024), 2); ?> MB
<?php endif; ?>
</td>
<td class="controls">
- <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/images/icon/view.png'); ?></a>
+ <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/admin/images/icon/view.png'); ?></a>
<?php if(is_writable($this->uploadFolder)) : ?>
- <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/admin/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php else : ?>
<tr>
<td>
No uploaded files were found. Use the form at the bottom to
add new files.
</td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
<div id="upload-form">
<h2 class="header">Upload</h2>
<p>
Upload a new file by selecting it on your machine. Check the box if
you want to overwrite a file that already exists with the same name.
<br />
</p>
<?php if(is_writable($this->uploadFolder)) : ?>
<form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
<?php if(isset($this->messages) && !empty($this->messages)) : ?>
<div class="message error">
<ul>
<?php foreach($this->messages as $message) : ?>
<li><?= $message ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div>
<input name="upload" type="file" /><br />
<small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
</div>
<div>
<label for="overwrite">Overwrite existing file?</label>
<input type="checkbox" name="overwrite" value="1" />
</div>
<div>
<input type="submit" value="Upload" />
</div>
</form>
<?php else : ?>
<div class="message notice">
<p>
The upload directory found in the Fizzy configuration is not
writable. Upload functionality will be disabled until it is made
writable.
</p>
</div>
<?php endif; ?>
</div>
|
jtietema/Fizzy
|
31fc422c9abf66d02dd446324ce514c04fe7a714
|
menubar background is now shown correctly
|
diff --git a/application/views/assets/css/admin.css b/application/views/assets/css/admin.css
index d04094a..ade8b57 100644
--- a/application/views/assets/css/admin.css
+++ b/application/views/assets/css/admin.css
@@ -1,314 +1,314 @@
@import 'admin-screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
.message { margin: 0; padding: 0; }
.message p { margin: 1em; }
.notice {
background-image: url('../images/icon/dialog-warning.png');
background-repeat: no-repeat;
background-position: .7em;
}
.error {
background-image: url('../images/icon/dialog-error.png');
background-repeat: no-repeat;
background-position: .7em;
}
.notice p, .error p {
margin-left: 4em;
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
padding: 1px 3px;
display: block;
color: #555555;
font-weight: bold;
width: 100px;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
- background: #2E3132 url('/images/menubg.png') repeat-x top left;
+ background: #2E3132 url('../images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
margin-top: 45px;
}
#content {
line-height: 1.7em;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
|
jtietema/Fizzy
|
0bf93ab3ea719d00645819266151570e2423a576
|
closed td properly
|
diff --git a/application/views/scripts/admin/media/list.phtml b/application/views/scripts/admin/media/list.phtml
index 2cddb5d..d2a5d01 100644
--- a/application/views/scripts/admin/media/list.phtml
+++ b/application/views/scripts/admin/media/list.phtml
@@ -1,118 +1,119 @@
<?php
// file type image declarations
$types = array(
'png' => $this->url('/images/icon/page_white_picture.png'),
'jpg' => $this->url('/images/icon/page_white_picture.png'),
'jpeg' => $this->url('/images/icon/page_white_picture.png'),
'bmp' => $this->url('/images/icon/page_white_picture.png'),
'gif' => $this->url('/images/icon/page_white_picture.png'),
'doc' => $this->url('/images/icon/page_white_word.png'),
'docx' => $this->url('/images/icon/page_white_word.png'),
'xls' => $this->url('/images/icon/page_white_excel.png'),
'ppt' => $this->url('/images/icon/page_white_powerpoint.png'),
'pdf' => $this->url('/images/icon/page_white_text.png'),
'flv' => $this->url('/images/icon/page_white_flash.png'),
'zip' => $this->url('/images/icon/page_white_zip.png'),
'rar' => $this->url('/images/icon/page_white_zip.png'),
'txt' => $this->url('/images/icon/page_white_text.png'),
);
?>
<h1 class="header">Media</h1>
<p>
On this page you find the media available within Fizzy. With the form on the
bottom of the page you are able to add files to Fizzy that you can use in
your pages.
</p>
<div id="uploaded-files">
<h2>Files overview</h2>
<div class="files-container">
<table class="files-table">
<?php if(0 < count($this->files)) : ?>
<thead>
<tr>
<td colspan="2">Filename</td>
<td>Size</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->files as $fileInfo) : ?>
<tr>
<td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/images/icon/page.png'); ?>" alt="" /></td>
<td class="filename"><?= $fileInfo->basename; ?></td>
<td class="size">
- <?php if($fileInfo->size < 1024) : ?>
- <?= round($fileInfo->size, 2); ?> b
- <?php elseif((1024*1024) > $fileInfo->size) : ?>
- <?= round($fileInfo->size / 1024, 2); ?> KB
- <?php else : ?>
- <?= round($fileInfo->size / (1024*1024), 2); ?> MB
- <?php endif; ?>
+ <?php if($fileInfo->size < 1024) : ?>
+ <?= round($fileInfo->size, 2); ?> b
+ <?php elseif((1024*1024) > $fileInfo->size) : ?>
+ <?= round($fileInfo->size / 1024, 2); ?> KB
+ <?php else : ?>
+ <?= round($fileInfo->size / (1024*1024), 2); ?> MB
+ <?php endif; ?>
+ </td>
<td class="controls">
<a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/images/icon/view.png'); ?></a>
<?php if(is_writable($this->uploadFolder)) : ?>
<?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php else : ?>
<tr>
<td>
No uploaded files were found. Use the form at the bottom to
add new files.
</td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
<div id="upload-form">
<h2 class="header">Upload</h2>
<p>
Upload a new file by selecting it on your machine. Check the box if
you want to overwrite a file that already exists with the same name.
<br />
</p>
<?php if(is_writable($this->uploadFolder)) : ?>
<form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
<?php if(isset($this->messages) && !empty($this->messages)) : ?>
<div class="message error">
<ul>
<?php foreach($this->messages as $message) : ?>
<li><?= $message ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div>
<input name="upload" type="file" /><br />
<small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
</div>
<div>
<label for="overwrite">Overwrite existing file?</label>
<input type="checkbox" name="overwrite" value="1" />
</div>
<div>
<input type="submit" value="Upload" />
</div>
</form>
<?php else : ?>
<div class="message notice">
<p>
The upload directory found in the Fizzy configuration is not
writable. Upload functionality will be disabled until it is made
writable.
</p>
</div>
<?php endif; ?>
</div>
|
jtietema/Fizzy
|
de1f6c8f0102c30f91bed2631a5d191bc62629c1
|
removed lost character in AdminMediaController
|
diff --git a/application/controllers/AdminMediaController.php b/application/controllers/AdminMediaController.php
index 37e47d3..0f4e9eb 100644
--- a/application/controllers/AdminMediaController.php
+++ b/application/controllers/AdminMediaController.php
@@ -1,144 +1,144 @@
<?php
/**
* Class AdminMediaController
* @package Fizzy
* @subpackage Controller
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** SecureController */
require_once 'SecureController.php';
/**
* Controller for media inside Fizzy. Enables basic upload and deletion of files.
* @author Mattijs Hoitink <[email protected]>
*/
class AdminMediaController extends SecureController
{
public function defaultAction()
{
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if($this->getRequest()->getMethod() === Fizzy_Request::METHOD_POST)
{
if(isset($_FILES) && !empty($_FILES['upload'])) {
$overwrite = ((boolean) isset($_POST['overwrite']) && !empty($_POST['overwrite']));
$messages = $this->_handleUpload('upload', $uploadFolder, $overwrite);
$this->getView()->messages = $messages;
}
}
// check if the uploads folder exists and is writable
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if (!is_dir($uploadFolder) || !is_writable($uploadFolder))
{
$this->getView()->setScript('/admin/media/foldererror.phtml');
return;
}
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
-s );
+ );
$files[] = (object) $fileInfo;
}
}
// Render the view
$this->getView()->uploadFolder = $uploadFolder;
$this->getView()->files = $files;
$this->getView()->post_max_size = ini_get('post_max_size');
$this->getView()->upload_max_filesize = ini_get('upload_max_filesize');
$this->getView()->setScript('/admin/media/list.phtml');
}
/**
* Deletes an uploaded file.
*/
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
}
}
$this->_redirect('/admin/media');
}
public function uploadAction()
{
$this->_redirect('/admin/media');
}
/**
* Handles a file upload.
* @param string $name
* @param string $uploadFolder
* @return array
*/
protected function _handleUpload($name, $uploadFolder, $overwrite = false)
{
$file = $_FILES[$name];
if ($file['error'] == UPLOAD_ERR_OK) {
$target = $file["tmp_name"];
$destination = $uploadFolder . DIRECTORY_SEPARATOR . $file["name"];
if(!file_exists($destination) || $overwrite)
{
move_uploaded_file($target, $destination);
}
else
{
unlink($target);
}
return array();
}
else {
switch($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('The uploaded file exceeds the Maximum upload filesize.');
break;
case UPLOAD_ERR_PARTIAL:
return array('The uploaded file was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
return array('No file was uploaded.');
break;
default:
return array('An internal server error occurred.');
}
}
}
}
|
jtietema/Fizzy
|
8991ac214647fe7ee3d904a76f6f7143848ebf3a
|
implements thumbnail view in media gallery
|
diff --git a/application/controllers/AdminAssetsController.php b/application/controllers/AdminAssetsController.php
index 237abb2..daba226 100644
--- a/application/controllers/AdminAssetsController.php
+++ b/application/controllers/AdminAssetsController.php
@@ -1,136 +1,138 @@
<?php
/**
* Class AdminAssetsController
* @package Fizzy
* @subpackage Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Controller */
require_once 'Fizzy/Controller.php';
/**
* Controller for admin assets. Controls css, javascript and images.
*
* @author Mattijs Hoitink <[email protected]>
*/
class AdminAssetsController extends Fizzy_Controller
{
public function serveAction()
{
$namespaces = array('css' => 'css', 'js' => 'js', 'image' => 'images', 'images' => 'images');
$namespace = strtolower($this->_getParam('namespace'));
+
+ // Disable view rendering
+ $this->getView()->disable();
+
// Check for valid namespace
if(!array_key_exists($namespace, $namespaces))
{
$this->_return404();
return;
}
// Get the absolute file path
$asset = $this->_getAssetPath($this->getRequest()->getPath(), $namespaces[$namespace]);
-
+
// Check if the asset is valid
if(!$this->_isValidAsset($asset))
{
$this->_return404();
return;
}
- // Disable view rendering
- $this->getView()->disable();
-
$contentType = $this->_getContentType($asset);
if(null !== $contentType)
{
header('Content-Type: ' . $contentType);
}
echo file_get_contents($asset);
+ return;
}
/**
* Returns the absolute path for a requested asset.
* @param string $url
* @param string $assetType
* @return string
*/
protected function _getAssetPath($url, $assetType)
{
$assetUrl = '/admin/' . $assetType;
- $file = str_replace($assetUrl, '', $url);
-
+ $file = trim(str_replace($assetUrl, '', $url), DIRECTORY_SEPARATOR);
+
$assetsPath = Fizzy_Config::getInstance()->getPath('assets');
$assetsPath = rtrim($assetsPath, DIRECTORY_SEPARATOR);
- $filePath = $assetsPath . DIRECTORY_SEPARATOR . $assetType . DIRECTORY_SEPARATOR . $file;
+ $filePath = $assetsPath . DIRECTORY_SEPARATOR . rtrim($assetType, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
return realpath($filePath);
}
/**
* Checks if an asset file is valid. It checks if it exists and if it's
* within the assets folder.
* @param string $asset
* @return boolean
*/
protected function _isValidAsset($asset)
{
return (is_file($asset) && 0 === strpos(realpath($asset), realpath(Fizzy_Config::getInstance()->getPath('assets'))));
}
/**
* Returns the content type for an asset file path. The mime-type is
* only detemined by the file extension as the fileinfor PECL extension
* can not be considered installed.
* @param string $asset
* @return string
*/
protected function _getContentType($asset)
{
$extension = strtolower(substr(strrchr($asset, '.'), 1));
$mimeTypes = array(
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'ico' => 'image/x-icon',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'pdf' => 'application/pdf',
'png' => 'image/png',
'svg' => 'image/svg+xml',
'txt' => 'text/plain',
);
if(array_key_exists($extension, $mimeTypes))
{
return $mimeTypes[$extension];
}
return null;
}
/**
* Returns the response with a 404 header and exits.
*/
protected function _return404()
{
header($this->getRequest()->getProtocol() . " 404 Not Found");
}
}
\ No newline at end of file
diff --git a/application/controllers/AdminMediaController.php b/application/controllers/AdminMediaController.php
index 37e47d3..f21a2b8 100644
--- a/application/controllers/AdminMediaController.php
+++ b/application/controllers/AdminMediaController.php
@@ -1,144 +1,157 @@
<?php
/**
* Class AdminMediaController
* @package Fizzy
* @subpackage Controller
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** SecureController */
require_once 'SecureController.php';
/**
* Controller for media inside Fizzy. Enables basic upload and deletion of files.
* @author Mattijs Hoitink <[email protected]>
*/
class AdminMediaController extends SecureController
{
-
- public function defaultAction()
+ /**
+ * All common code for defaultAction and thumbnailsAction
+ */
+ protected function _show()
{
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if($this->getRequest()->getMethod() === Fizzy_Request::METHOD_POST)
{
if(isset($_FILES) && !empty($_FILES['upload'])) {
$overwrite = ((boolean) isset($_POST['overwrite']) && !empty($_POST['overwrite']));
$messages = $this->_handleUpload('upload', $uploadFolder, $overwrite);
$this->getView()->messages = $messages;
}
}
// check if the uploads folder exists and is writable
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if (!is_dir($uploadFolder) || !is_writable($uploadFolder))
{
$this->getView()->setScript('/admin/media/foldererror.phtml');
return;
}
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
-s );
+ );
$files[] = (object) $fileInfo;
}
}
// Render the view
$this->getView()->uploadFolder = $uploadFolder;
$this->getView()->files = $files;
$this->getView()->post_max_size = ini_get('post_max_size');
$this->getView()->upload_max_filesize = ini_get('upload_max_filesize');
+ }
+
+ public function defaultAction()
+ {
+ $this->_show();
$this->getView()->setScript('/admin/media/list.phtml');
}
+ public function thumbnailsAction()
+ {
+ $this->_show();
+ $this->getView()->setScript('/admin/media/thumbnails.phtml');
+ }
+
/**
* Deletes an uploaded file.
*/
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
}
}
$this->_redirect('/admin/media');
}
public function uploadAction()
{
$this->_redirect('/admin/media');
}
/**
* Handles a file upload.
* @param string $name
* @param string $uploadFolder
* @return array
*/
protected function _handleUpload($name, $uploadFolder, $overwrite = false)
{
$file = $_FILES[$name];
if ($file['error'] == UPLOAD_ERR_OK) {
$target = $file["tmp_name"];
$destination = $uploadFolder . DIRECTORY_SEPARATOR . $file["name"];
if(!file_exists($destination) || $overwrite)
{
move_uploaded_file($target, $destination);
}
else
{
unlink($target);
}
return array();
}
else {
switch($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('The uploaded file exceeds the Maximum upload filesize.');
break;
case UPLOAD_ERR_PARTIAL:
return array('The uploaded file was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
return array('No file was uploaded.');
break;
default:
return array('An internal server error occurred.');
}
}
}
}
diff --git a/application/views/assets/css/admin.css b/application/views/assets/css/admin.css
index d04094a..da50e88 100644
--- a/application/views/assets/css/admin.css
+++ b/application/views/assets/css/admin.css
@@ -1,314 +1,363 @@
@import 'admin-screen.css';
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
.message { margin: 0; padding: 0; }
.message p { margin: 1em; }
.notice {
background-image: url('../images/icon/dialog-warning.png');
background-repeat: no-repeat;
background-position: .7em;
}
.error {
background-image: url('../images/icon/dialog-error.png');
background-repeat: no-repeat;
background-position: .7em;
}
.notice p, .error p {
margin-left: 4em;
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
padding: 1px 3px;
display: block;
color: #555555;
font-weight: bold;
width: 100px;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
- background: #2E3132 url('/images/menubg.png') repeat-x top left;
+ background: #2E3132 url('../images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
margin-top: 45px;
}
#content {
line-height: 1.7em;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
+/* Media Thumbnails view */
+.files-container div.thumbnail {
+ float:left;
+ margin: 1em 0 0 1em;
+ padding: 5px 10px;
+ text-align: center;
+ border: solid 1px black;
+ background-color: white;
+ width: 140px;
+ height: 140px;
+}
+.files-container div.thumbnail img.thumbnail {
+ max-width: 120px;
+ max-height: 80px;
+}
+.files-container div.thumbnail img.icon {
+ margin: 32px 52px;
+}
+.files-container div.thumbnail div.controls {
+ text-align: right;
+}
+.files-menubar {
+ background: #2E3132 url('../images/menubg.png') repeat-x top left;
+ border-bottom: 2px solid #353535;
+ border-left: 1px #656565 solid;
+}
+.files-menubar ul {
+ list-style-image: none;
+ list-style-position: outside;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+.files-menubar ul li {
+ float: left;
+ margin-right: 0;
+ position: relative;
+}
+.files-menubar ul li a {
+ display: block;
+ padding: 3px 8px;
+ text-align: center;
+ color: #FFFFFF;
+ text-decoration: none;
+ border-right: 1px #656565 solid;
+}
+.files-menubar ul li a:hover {
+ background: #424242;
+}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
diff --git a/application/views/assets/images/icon/page_white_text.png b/application/views/assets/images/icon/page_white_text.png
new file mode 100644
index 0000000..6a890d5
Binary files /dev/null and b/application/views/assets/images/icon/page_white_text.png differ
diff --git a/application/views/scripts/admin/media/list.phtml b/application/views/scripts/admin/media/list.phtml
index 2cddb5d..8e2120a 100644
--- a/application/views/scripts/admin/media/list.phtml
+++ b/application/views/scripts/admin/media/list.phtml
@@ -1,118 +1,126 @@
<?php
// file type image declarations
$types = array(
- 'png' => $this->url('/images/icon/page_white_picture.png'),
- 'jpg' => $this->url('/images/icon/page_white_picture.png'),
- 'jpeg' => $this->url('/images/icon/page_white_picture.png'),
- 'bmp' => $this->url('/images/icon/page_white_picture.png'),
- 'gif' => $this->url('/images/icon/page_white_picture.png'),
- 'doc' => $this->url('/images/icon/page_white_word.png'),
- 'docx' => $this->url('/images/icon/page_white_word.png'),
- 'xls' => $this->url('/images/icon/page_white_excel.png'),
- 'ppt' => $this->url('/images/icon/page_white_powerpoint.png'),
- 'pdf' => $this->url('/images/icon/page_white_text.png'),
- 'flv' => $this->url('/images/icon/page_white_flash.png'),
- 'zip' => $this->url('/images/icon/page_white_zip.png'),
- 'rar' => $this->url('/images/icon/page_white_zip.png'),
- 'txt' => $this->url('/images/icon/page_white_text.png'),
+ 'png' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpeg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'bmp' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'gif' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'doc' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'docx' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'xls' => $this->url('/admin/images/icon/page_white_excel.png'),
+ 'ppt' => $this->url('/admin/images/icon/page_white_powerpoint.png'),
+ 'pdf' => $this->url('/admin/images/icon/page_white_text.png'),
+ 'flv' => $this->url('/admin/images/icon/page_white_flash.png'),
+ 'zip' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'rar' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'txt' => $this->url('/admin/images/icon/page_white_text.png'),
);
?>
<h1 class="header">Media</h1>
<p>
On this page you find the media available within Fizzy. With the form on the
bottom of the page you are able to add files to Fizzy that you can use in
your pages.
</p>
<div id="uploaded-files">
<h2>Files overview</h2>
+ <div class="files-menubar">
+ <ul>
+ <li><a href="<?= $this->url('/admin/media/thumbnails') ?>">Thumbnail view</a></li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+
<div class="files-container">
<table class="files-table">
<?php if(0 < count($this->files)) : ?>
<thead>
<tr>
<td colspan="2">Filename</td>
<td>Size</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->files as $fileInfo) : ?>
<tr>
<td class="icon"><img src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/images/icon/page.png'); ?>" alt="" /></td>
<td class="filename"><?= $fileInfo->basename; ?></td>
<td class="size">
- <?php if($fileInfo->size < 1024) : ?>
- <?= round($fileInfo->size, 2); ?> b
- <?php elseif((1024*1024) > $fileInfo->size) : ?>
- <?= round($fileInfo->size / 1024, 2); ?> KB
- <?php else : ?>
- <?= round($fileInfo->size / (1024*1024), 2); ?> MB
- <?php endif; ?>
+ <?php if($fileInfo->size < 1024) : ?>
+ <?= round($fileInfo->size, 2); ?> b
+ <?php elseif((1024*1024) > $fileInfo->size) : ?>
+ <?= round($fileInfo->size / 1024, 2); ?> KB
+ <?php else : ?>
+ <?= round($fileInfo->size / (1024*1024), 2); ?> MB
+ <?php endif; ?>
+ </td>
<td class="controls">
- <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/images/icon/view.png'); ?></a>
+ <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/admin/images/icon/view.png'); ?></a>
<?php if(is_writable($this->uploadFolder)) : ?>
- <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/admin/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php else : ?>
<tr>
<td>
No uploaded files were found. Use the form at the bottom to
add new files.
</td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
<div id="upload-form">
<h2 class="header">Upload</h2>
<p>
Upload a new file by selecting it on your machine. Check the box if
you want to overwrite a file that already exists with the same name.
<br />
</p>
<?php if(is_writable($this->uploadFolder)) : ?>
<form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
<?php if(isset($this->messages) && !empty($this->messages)) : ?>
<div class="message error">
<ul>
<?php foreach($this->messages as $message) : ?>
<li><?= $message ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div>
<input name="upload" type="file" /><br />
<small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
</div>
<div>
<label for="overwrite">Overwrite existing file?</label>
<input type="checkbox" name="overwrite" value="1" />
</div>
<div>
<input type="submit" value="Upload" />
</div>
</form>
<?php else : ?>
<div class="message notice">
<p>
The upload directory found in the Fizzy configuration is not
writable. Upload functionality will be disabled until it is made
writable.
</p>
</div>
<?php endif; ?>
</div>
diff --git a/application/views/scripts/admin/media/thumbnails.phtml b/application/views/scripts/admin/media/thumbnails.phtml
new file mode 100644
index 0000000..e67777b
--- /dev/null
+++ b/application/views/scripts/admin/media/thumbnails.phtml
@@ -0,0 +1,120 @@
+<?php
+// file type image declarations
+
+$images = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
+
+$types = array(
+ 'png' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'jpeg' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'bmp' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'gif' => $this->url('/admin/images/icon/page_white_picture.png'),
+ 'doc' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'docx' => $this->url('/admin/images/icon/page_white_word.png'),
+ 'xls' => $this->url('/admin/images/icon/page_white_excel.png'),
+ 'ppt' => $this->url('/admin/images/icon/page_white_powerpoint.png'),
+ 'pdf' => $this->url('/admin/images/icon/page_white_text.png'),
+ 'flv' => $this->url('/admin/images/icon/page_white_flash.png'),
+ 'zip' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'rar' => $this->url('/admin/images/icon/page_white_zip.png'),
+ 'txt' => $this->url('/admin/images/icon/page_white_text.png'),
+);
+?>
+<h1 class="header">Media</h1>
+
+<p>
+ On this page you find the media available within Fizzy. With the form on the
+ bottom of the page you are able to add files to Fizzy that you can use in
+ your pages.
+</p>
+
+<div id="uploaded-files">
+ <h2>Files overview</h2>
+
+ <div class="files-menubar">
+ <ul>
+ <li><a href="<?= $this->url('/admin/media') ?>">List view</a></li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+ <div class="files-container">
+ <?php foreach($this->files as $fileInfo) : ?>
+ <div class="thumbnail">
+ <div class="controls">
+ <a href="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" target="_blank" title="View file"><?= $this->img('/admin/images/icon/view.png'); ?></a>
+ <?php if(is_writable($this->uploadFolder)) : ?>
+ <?= $this->link_confirm('/admin/media/delete/' . urlencode($fileInfo->basename), $this->img('/admin/images/icon/delete.png'), "Are you sure you want to delete {$fileInfo->basename}?", array('title' => 'Delete file')); ?>
+ <?php endif; ?>
+ </div>
+ <?php if (in_array($fileInfo->type, $images)): ?>
+ <img class="thumbnail" src="<?= $this->url('/uploads/' . $fileInfo->basename); ?>" alt="<?= $fileInfo->basename ?>" />
+ <?php else: ?>
+ <img class="icon" src="<?= (array_key_exists($fileInfo->type, $types)) ? $types[$fileInfo->type] : $this->url('/admin/images/icon/page.png'); ?>" alt="" />
+ <?php endif; ?>
+
+ <div class="filename">
+ <?php if (strlen($fileInfo->basename) > 14):?>
+ <?= substr($fileInfo->basename, 0, 14); ?>...
+ <?php else: ?>
+ <?= $fileInfo->basename ?>
+ <?php endif; ?>
+ </div>
+ <div class="size">
+ <?php if($fileInfo->size < 1024) : ?>
+ <?= round($fileInfo->size, 2); ?> b
+ <?php elseif((1024*1024) > $fileInfo->size) : ?>
+ <?= round($fileInfo->size / 1024, 2); ?> KB
+ <?php else : ?>
+ <?= round($fileInfo->size / (1024*1024), 2); ?> MB
+ <?php endif; ?>
+ </div>
+ </div>
+ <?php endforeach; ?>
+
+
+ </div>
+</div>
+
+<div id="upload-form">
+ <h2 class="header">Upload</h2>
+ <p>
+ Upload a new file by selecting it on your machine. Check the box if
+ you want to overwrite a file that already exists with the same name.
+ <br />
+
+ </p>
+ <?php if(is_writable($this->uploadFolder)) : ?>
+ <form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
+ <?php if(isset($this->messages) && !empty($this->messages)) : ?>
+ <div class="message error">
+ <ul>
+ <?php foreach($this->messages as $message) : ?>
+ <li><?= $message ?></li>
+ <?php endforeach; ?>
+ </ul>
+
+ </div>
+ <?php endif; ?>
+
+ <div>
+ <input name="upload" type="file" /><br />
+ <small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
+ </div>
+ <div>
+ <label for="overwrite">Overwrite existing file?</label>
+ <input type="checkbox" name="overwrite" value="1" />
+ </div>
+ <div>
+ <input type="submit" value="Upload" />
+ </div>
+ </form>
+ <?php else : ?>
+ <div class="message notice">
+ <p>
+ The upload directory found in the Fizzy configuration is not
+ writable. Upload functionality will be disabled until it is made
+ writable.
+ </p>
+ </div>
+ <?php endif; ?>
+</div>
diff --git a/application/views/scripts/admin/media/upload.phtml b/application/views/scripts/admin/media/upload.phtml
new file mode 100644
index 0000000..783ecc0
--- /dev/null
+++ b/application/views/scripts/admin/media/upload.phtml
@@ -0,0 +1,43 @@
+<div id="upload-form">
+ <h2 class="header">Upload</h2>
+ <p>
+ Upload a new file by selecting it on your machine. Check the box if
+ you want to overwrite a file that already exists with the same name.
+ <br />
+
+ </p>
+ <?php if(is_writable($this->uploadFolder)) : ?>
+ <form action="<?= $this->url('/admin/media'); ?>" method="post" enctype="multipart/form-data">
+ <?php if(isset($this->messages) && !empty($this->messages)) : ?>
+ <div class="message error">
+ <ul>
+ <?php foreach($this->messages as $message) : ?>
+ <li><?= $message ?></li>
+ <?php endforeach; ?>
+ </ul>
+
+ </div>
+ <?php endif; ?>
+
+ <div>
+ <input name="upload" type="file" /><br />
+ <small>The maximum size for a file upload is <strong><?= str_replace(array('K', 'M', 'G'), array(' KB', ' MB', ' GB'), $this->upload_max_filesize); ?></strong>.</small>
+ </div>
+ <div>
+ <label for="overwrite">Overwrite existing file?</label>
+ <input type="checkbox" name="overwrite" value="1" />
+ </div>
+ <div>
+ <input type="submit" value="Upload" />
+ </div>
+ </form>
+ <?php else : ?>
+ <div class="message notice">
+ <p>
+ The upload directory found in the Fizzy configuration is not
+ writable. Upload functionality will be disabled until it is made
+ writable.
+ </p>
+ </div>
+ <?php endif; ?>
+</div>
\ No newline at end of file
diff --git a/configs/routes.xml b/configs/routes.xml
index d8bb194..5d64e54 100644
--- a/configs/routes.xml
+++ b/configs/routes.xml
@@ -1,133 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<fizzy version="0.4">
<routes>
<!--
Pages frontend
-->
<short_slug type="simple">
<rule>/:slug</rule>
<controller>page</controller>
<action>show</action>
</short_slug>
<homepage type="static">
<rule>/</rule>
<controller>page</controller>
<action>homepage</action>
</homepage>
<page_by_slug type="simple">
<rule>page/:slug</rule>
<controller>page</controller>
<action>show</action>
</page_by_slug>
<pages type="static">
<rule>pages</rule>
<controller>page</controller>
<action>list</action>
</pages>
<pages_all type="static">
<rule>pages/all</rule>
<controller>page</controller>
<action>list</action>
</pages_all>
<page_by_id type="regex">
<rule>pages/(\d+)/(\+d)</rule>
<controller>page</controller>
<action>show</action>
<parameters>
<param>id</param>
<param>user</param>
</parameters>
</page_by_id>
<!-- Admin sections -->
<admin type="static">
<rule>/admin</rule>
<controller>Admin</controller>
<action>default</action>
</admin>
<admin_logout type="static">
<rule>/admin/logout</rule>
<controller>Admin</controller>
<action>logout</action>
</admin_logout>
<admin_configuration type="static">
<rule>/admin/configuration</rule>
<controller>Admin</controller>
<action>configuration</action>
</admin_configuration>
<admin_assets type="simple">
<rule>/admin/:namespace/:asset</rule>
<controller>AdminAssets</controller>
<action>serve</action>
</admin_assets>
<!-- Pages admin section -->
<admin_pages type="static">
<rule>/admin/pages</rule>
<controller>AdminPages</controller>
<action>list</action>
</admin_pages>
<add_page type="static">
<rule>/admin/page/add</rule>
<controller>AdminPages</controller>
<action>add</action>
</add_page>
<admin_page_by_id type="simple">
<rule>/admin/page/edit/:id</rule>
<controller>AdminPages</controller>
<action>edit</action>
</admin_page_by_id>
<admin_delete_page_by_id type="simple">
<rule>/admin/page/delete/:id</rule>
<controller>AdminPages</controller>
<action>delete</action>
</admin_delete_page_by_id>
<!-- Media admin sections -->
<admin_media type="static">
<rule>/admin/media</rule>
<controller>AdminMedia</controller>
<action>default</action>
</admin_media>
+ <admin_media_thumbnails type="static">
+ <rule>/admin/media/thumbnails</rule>
+ <controller>AdminMedia</controller>
+ <action>thumbnails</action>
+ </admin_media_thumbnails>
<admin_media_upload type="static">
<rule>/admin/media/upload</rule>
<controller>AdminMedia</controller>
<action>upload</action>
</admin_media_upload>
<admin_media_delete type="simple">
<rule>/admin/media/delete/:name</rule>
<controller>AdminMedia</controller>
<action>delete</action>
</admin_media_delete>
<!-- Menu admin sections -->
<admin_menu type="static">
<rule>/admin/menu</rule>
<controller>AdminMenu</controller>
<action>show</action>
</admin_menu>
<!-- Users admin section -->
<admin_users type="static">
<rule>admin/users</rule>
<controller>AdminUsers</controller>
<action>list</action>
</admin_users>
<admin_add_user type="static">
<rule>admin/user/add</rule>
<controller>AdminUsers</controller>
<action>add</action>
</admin_add_user>
<admin_edit_user type="simple">
<rule>admin/user/edit/:id</rule>
<controller>AdminUsers</controller>
<action>edit</action>
</admin_edit_user>
<admin_delete_user type="simple">
<rule>/admin/user/delete/:id</rule>
<controller>AdminUsers</controller>
<action>delete</action>
</admin_delete_user>
</routes>
</fizzy>
|
jtietema/Fizzy
|
3c7ee4f3927a1df470e488611f68b212f70f691a
|
bugfixes and update README and CHANGELOG
|
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
new file mode 100644
index 0000000..33f3229
--- /dev/null
+++ b/CHANGELOG.txt
@@ -0,0 +1,26 @@
+Version 1.1.0
+=============
+There has been some major improvements in the storage backend. New is MySQL
+support and improved SQLite support. Also the WYSIWYG editor changed to
+TinyMCE. The Media Library also debutes in this version.
+
+Below the list of changes. For more detail consult the git log.
+ * Issue #83: XML dsn
+ * Issue #120: Polish the XML backend
+ * Issue #133: Fizzy configuration
+ * Issue #138: Improve directory layout for symlinking the core
+ * Issue #141: Proper HTML
+ * Issue #142: PDO Backend support
+ * Issue #143: MySQL backend
+ * Issue #144: Improved SQLite backend
+ * Issue #243: Wysiwyg editor
+ * Feature #121: Stabalize the SQLite backend
+ * Feature #131: Password encryption
+ * Feature #132: Move admin assets
+ * Feature #139: Remove the need of the basePath config option
+ * Feature #152: Media Library
+ * Task #140: Make the repository publicly readable
+
+Version 1.0.0
+=============
+The initial release
\ No newline at end of file
diff --git a/README.txt b/README.txt
index 3758c24..4b4af8c 100644
--- a/README.txt
+++ b/README.txt
@@ -1,59 +1,67 @@
Welcome to Fizzy!
=================
Introduction
------------
Fizzy is a small PHP 5 Content Management System. It is designed to be portable.
-It doesn't require MySQL so it is ideal for small shared hosting accounts or
-low memory VPS systems. It's flexible MVC architecture allows for quick
-development and it storage backend ensures you don't have to worry about SQL
-queries and alike.
+It addition to MySQL it supports XML and SQLite. This makes it is ideal for
+small shared hosting accounts or low memory VPS systems. It's flexible MVC
+architecture allows for quick development and it storage backend ensures you
+don't have to worry about SQL queries and alike.
For more information, see http://project.voidwalkers.nl/projects/show/fizzy
Requirements
------------
To get Fizzy running you need the following:
- Apache mod_rewrite support (or equivalent)
- PHP 5.2+
- DOM XML extension
- SimpleXML extension
If you want to use the SQLite backend, the following PHP extensions are required:
- PDO
- PDO SQLite extension
+For MySQL you need:
+- PDO
+- PDO MySQL extension
+
Getting started
---------------
-First copy configs/fizzy.xml.default to configs/fizzy.xml and modify the basePath and the xml path.
+First copy configs/fizzy.xml.default to configs/fizzy.xml and modify the xml
+path.
+
Then copy all the files to your webserver and you are good to go. It is
recommended not to copy Fizzy to your web root. Only the files from the public
-folder need to be in your webroot. The data folder and all its files need to be
-writeable for the webserver. Also make sure the public/uploads folder exists and is writable by
-the webserver if you want to upload files.
+folder need to be in your webroot.
+
+The data folder and all its files need to be writeable for the webserver. Also
+make sure the public/uploads folder exists and is writable by the webserver if
+you want to upload files.
Visit http://<your-site> for the demo site.
Visit http://<your-site>/admin for the admin interface.
The default user is admin with password admin. Be sure to change that after the
first login.
Getting Help
------------
If you need help with Fizzy, you can get help from the following sources:
- Wiki: http://project.voidwalkers.nl/wiki/fizzy
If you discover any bugs, please report them here:
http://project.voidwalkers.nl/projects/fizzy/issues
License
-------
The files in this archive are released under the new BSD license.
You can find a copy of this license in LICENSE.txt.
diff --git a/application/controllers/AdminAssetsController.php b/application/controllers/AdminAssetsController.php
index c3a1432..237abb2 100644
--- a/application/controllers/AdminAssetsController.php
+++ b/application/controllers/AdminAssetsController.php
@@ -1,136 +1,136 @@
<?php
/**
* Class AdminAssetsController
* @package Fizzy
* @subpackage Admin
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Controller */
require_once 'Fizzy/Controller.php';
/**
* Controller for admin assets. Controls css, javascript and images.
*
* @author Mattijs Hoitink <[email protected]>
*/
class AdminAssetsController extends Fizzy_Controller
{
public function serveAction()
{
$namespaces = array('css' => 'css', 'js' => 'js', 'image' => 'images', 'images' => 'images');
$namespace = strtolower($this->_getParam('namespace'));
// Check for valid namespace
if(!array_key_exists($namespace, $namespaces))
{
$this->_return404();
+ return;
}
// Get the absolute file path
$asset = $this->_getAssetPath($this->getRequest()->getPath(), $namespaces[$namespace]);
-
+
// Check if the asset is valid
if(!$this->_isValidAsset($asset))
{
$this->_return404();
+ return;
}
// Disable view rendering
$this->getView()->disable();
$contentType = $this->_getContentType($asset);
if(null !== $contentType)
{
header('Content-Type: ' . $contentType);
}
echo file_get_contents($asset);
- return;
}
/**
* Returns the absolute path for a requested asset.
* @param string $url
* @param string $assetType
* @return string
*/
protected function _getAssetPath($url, $assetType)
{
- $assetUrl = $this->getRequest()->getBaseUrl() . '/admin/' . $assetType;
+ $assetUrl = '/admin/' . $assetType;
$file = str_replace($assetUrl, '', $url);
$assetsPath = Fizzy_Config::getInstance()->getPath('assets');
$assetsPath = rtrim($assetsPath, DIRECTORY_SEPARATOR);
$filePath = $assetsPath . DIRECTORY_SEPARATOR . $assetType . DIRECTORY_SEPARATOR . $file;
return realpath($filePath);
}
/**
* Checks if an asset file is valid. It checks if it exists and if it's
* within the assets folder.
* @param string $asset
* @return boolean
*/
protected function _isValidAsset($asset)
{
return (is_file($asset) && 0 === strpos(realpath($asset), realpath(Fizzy_Config::getInstance()->getPath('assets'))));
}
/**
* Returns the content type for an asset file path. The mime-type is
* only detemined by the file extension as the fileinfor PECL extension
* can not be considered installed.
* @param string $asset
* @return string
*/
protected function _getContentType($asset)
{
$extension = strtolower(substr(strrchr($asset, '.'), 1));
$mimeTypes = array(
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'ico' => 'image/x-icon',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'pdf' => 'application/pdf',
'png' => 'image/png',
'svg' => 'image/svg+xml',
'txt' => 'text/plain',
);
if(array_key_exists($extension, $mimeTypes))
{
return $mimeTypes[$extension];
}
return null;
}
/**
* Returns the response with a 404 header and exits.
*/
protected function _return404()
{
header($this->getRequest()->getProtocol() . " 404 Not Found");
- exit;
}
}
\ No newline at end of file
diff --git a/application/controllers/AdminMediaController.php b/application/controllers/AdminMediaController.php
index 65cc1e8..37e47d3 100644
--- a/application/controllers/AdminMediaController.php
+++ b/application/controllers/AdminMediaController.php
@@ -1,138 +1,144 @@
<?php
/**
* Class AdminMediaController
* @package Fizzy
* @subpackage Controller
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** SecureController */
require_once 'SecureController.php';
/**
* Controller for media inside Fizzy. Enables basic upload and deletion of files.
* @author Mattijs Hoitink <[email protected]>
*/
class AdminMediaController extends SecureController
{
public function defaultAction()
{
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
if($this->getRequest()->getMethod() === Fizzy_Request::METHOD_POST)
{
if(isset($_FILES) && !empty($_FILES['upload'])) {
$overwrite = ((boolean) isset($_POST['overwrite']) && !empty($_POST['overwrite']));
$messages = $this->_handleUpload('upload', $uploadFolder, $overwrite);
$this->getView()->messages = $messages;
}
}
-
+ // check if the uploads folder exists and is writable
+ $uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
+ if (!is_dir($uploadFolder) || !is_writable($uploadFolder))
+ {
+ $this->getView()->setScript('/admin/media/foldererror.phtml');
+ return;
+ }
// Parse all files in the upload directory
$files = array();
foreach(new DirectoryIterator($uploadFolder) as $file)
{
if($file->isFile())
{
$fileInfo = array(
'type' => substr(strrchr($file->getBaseName(), '.'), 1),
'basename' => $file->getBaseName(),
'path' => $file->getPath(),
'size' => $file->getSize(),
s );
$files[] = (object) $fileInfo;
}
}
// Render the view
$this->getView()->uploadFolder = $uploadFolder;
$this->getView()->files = $files;
$this->getView()->post_max_size = ini_get('post_max_size');
$this->getView()->upload_max_filesize = ini_get('upload_max_filesize');
$this->getView()->setScript('/admin/media/list.phtml');
}
/**
* Deletes an uploaded file.
*/
public function deleteAction()
{
$name = $this->_getParam('name');
if(null !== $name)
{
$name = basename(urldecode($name));
$uploadFolder = Fizzy_Config::getInstance()->getPath('uploads');
$file = $uploadFolder . DIRECTORY_SEPARATOR . $name;
if(is_file($file))
{
unlink($file);
}
}
$this->_redirect('/admin/media');
}
public function uploadAction()
{
$this->_redirect('/admin/media');
}
/**
* Handles a file upload.
* @param string $name
* @param string $uploadFolder
* @return array
*/
protected function _handleUpload($name, $uploadFolder, $overwrite = false)
{
$file = $_FILES[$name];
if ($file['error'] == UPLOAD_ERR_OK) {
$target = $file["tmp_name"];
$destination = $uploadFolder . DIRECTORY_SEPARATOR . $file["name"];
if(!file_exists($destination) || $overwrite)
{
move_uploaded_file($target, $destination);
}
else
{
unlink($target);
}
return array();
}
else {
switch($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('The uploaded file exceeds the Maximum upload filesize.');
break;
case UPLOAD_ERR_PARTIAL:
return array('The uploaded file was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
return array('No file was uploaded.');
break;
default:
return array('An internal server error occurred.');
}
}
}
}
diff --git a/application/views/scripts/admin/media/foldererror.phtml b/application/views/scripts/admin/media/foldererror.phtml
new file mode 100644
index 0000000..589fcc4
--- /dev/null
+++ b/application/views/scripts/admin/media/foldererror.phtml
@@ -0,0 +1,5 @@
+<h1 class="header">Error</h1>
+
+<div class="error">
+ <p>The uploads folder (<fizzy root>/public/uploads) <b>does not exist</b> or <b>is not writable</b> by the webserver.</p>
+</div>
\ No newline at end of file
|
jtietema/Fizzy
|
21f6f02a100879f7bc18428b01bc006b208b13c5
|
Admin assets
|
diff --git a/application/controllers/AdminAssetsController.php b/application/controllers/AdminAssetsController.php
new file mode 100644
index 0000000..c3a1432
--- /dev/null
+++ b/application/controllers/AdminAssetsController.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Class AdminAssetsController
+ * @package Fizzy
+ * @subpackage Admin
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.voidwalkers.nl/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to [email protected] so we can send you a copy immediately.
+ *
+ * @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
+ * @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
+ */
+
+/** Fizzy_Controller */
+require_once 'Fizzy/Controller.php';
+
+/**
+ * Controller for admin assets. Controls css, javascript and images.
+ *
+ * @author Mattijs Hoitink <[email protected]>
+ */
+class AdminAssetsController extends Fizzy_Controller
+{
+
+ public function serveAction()
+ {
+ $namespaces = array('css' => 'css', 'js' => 'js', 'image' => 'images', 'images' => 'images');
+ $namespace = strtolower($this->_getParam('namespace'));
+ // Check for valid namespace
+ if(!array_key_exists($namespace, $namespaces))
+ {
+ $this->_return404();
+ }
+
+ // Get the absolute file path
+ $asset = $this->_getAssetPath($this->getRequest()->getPath(), $namespaces[$namespace]);
+
+ // Check if the asset is valid
+ if(!$this->_isValidAsset($asset))
+ {
+ $this->_return404();
+ }
+
+ // Disable view rendering
+ $this->getView()->disable();
+
+ $contentType = $this->_getContentType($asset);
+ if(null !== $contentType)
+ {
+ header('Content-Type: ' . $contentType);
+ }
+ echo file_get_contents($asset);
+ return;
+ }
+
+ /**
+ * Returns the absolute path for a requested asset.
+ * @param string $url
+ * @param string $assetType
+ * @return string
+ */
+ protected function _getAssetPath($url, $assetType)
+ {
+ $assetUrl = $this->getRequest()->getBaseUrl() . '/admin/' . $assetType;
+ $file = str_replace($assetUrl, '', $url);
+
+ $assetsPath = Fizzy_Config::getInstance()->getPath('assets');
+ $assetsPath = rtrim($assetsPath, DIRECTORY_SEPARATOR);
+
+ $filePath = $assetsPath . DIRECTORY_SEPARATOR . $assetType . DIRECTORY_SEPARATOR . $file;
+ return realpath($filePath);
+ }
+
+ /**
+ * Checks if an asset file is valid. It checks if it exists and if it's
+ * within the assets folder.
+ * @param string $asset
+ * @return boolean
+ */
+ protected function _isValidAsset($asset)
+ {
+ return (is_file($asset) && 0 === strpos(realpath($asset), realpath(Fizzy_Config::getInstance()->getPath('assets'))));
+ }
+
+ /**
+ * Returns the content type for an asset file path. The mime-type is
+ * only detemined by the file extension as the fileinfor PECL extension
+ * can not be considered installed.
+ * @param string $asset
+ * @return string
+ */
+ protected function _getContentType($asset)
+ {
+ $extension = strtolower(substr(strrchr($asset, '.'), 1));
+
+ $mimeTypes = array(
+ 'bmp' => 'image/bmp',
+ 'css' => 'text/css',
+ 'gif' => 'image/gif',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'ico' => 'image/x-icon',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'js' => 'application/x-javascript',
+ 'pdf' => 'application/pdf',
+ 'png' => 'image/png',
+ 'svg' => 'image/svg+xml',
+ 'txt' => 'text/plain',
+ );
+
+ if(array_key_exists($extension, $mimeTypes))
+ {
+ return $mimeTypes[$extension];
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the response with a 404 header and exits.
+ */
+ protected function _return404()
+ {
+ header($this->getRequest()->getProtocol() . " 404 Not Found");
+ exit;
+ }
+
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Config.php b/application/library/Fizzy/Config.php
index 6c7f41d..c8ddc2b 100644
--- a/application/library/Fizzy/Config.php
+++ b/application/library/Fizzy/Config.php
@@ -1,443 +1,444 @@
<?php
/**
* Class Fizzy_Config
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Config class for Fizzy.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Config
{
/*
* Constants for default sections.
*/
const SECTION_APPLICATION = 'application';
const SECTION_PATHS = 'paths';
const SECTION_ROUTER = 'router';
/**
* Fizzy_Config instance.
* @var Fizzy_Config
*/
protected static $_instance = null;
/**
* Configuration for Fizzy containing default values.
* @var array
*/
protected $_configuration = array(
self::SECTION_APPLICATION => array(
'title' => 'Fizzy',
'environment' => 'production',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page',
),
self::SECTION_ROUTER => array (
'defaultController' => 'default',
'defaultAction' => 'default',
'routes' => array(),
),
self::SECTION_PATHS => array(
'application' => 'application',
'controllers' => 'application/controllers',
'models' => 'application/models',
'views' => array(
'application' => 'application/views/scripts',
'custom' => 'custom/views'
),
'layouts' => array(
'application' => 'application/views/layouts',
'custom' => 'custom/layouts',
),
'templates' => array (
'application' => 'application/views/scripts',
'custom' => 'custom/templates'
),
+ 'assets' => 'application/views/assets',
'configs' => 'configs',
'custom' => 'custom',
'data' => 'data',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/** **/
/**
* Fizzy_Config is a singleton, use Fizzy_Config::getInstance() to obtain
* an instance.
*/
protected function __construct()
{}
/**
* Returns the active Fizzy_Config instance.
* @return Fizzy_Config
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Returns the complete configuration as an array.
* @return array
*/
public function getConfiguration()
{
return $this->_configuration;
}
/**
* Sets the configuration section with the given data. Overrides any
* existent data in the section.
* @param string $section
* @param mixed $data
* @return Fizzy_Config
*/
public function setSection($section, $data)
{
$this->_configuration[$section] = $data;
return $this;
}
/**
* Merges values from a section with given key => value array.
* @param string $section
* @param array $data
* @return Fizzy_Config
*/
public function mergeSection($section, array $data)
{
$sectionData = $this->getSection($section);
if(null === $sectionData) {
$sectionData = $data;
} else {
$sectionData = $this->_arrayMergeRecursive($sectionData, $data);
}
return $this->setSection($section, $sectionData);
}
/**
* Sets a value inside a section. The section is created if it does not
* exist.
* @param string $section
* @param string $key
* @param mixed $value
* @return Fizzy_Config
*/
public function setSectionValue($section, $key, $value)
{
$sectionData = $this->getSection($section);
if(null === $sectionData) {
$sectionData = array();
}
$sectionData[$key] = $value;
$this->setSection($section, $sectionData);
return $this;
}
/**
* Returns a configuration section by name.
* @param string $section
* @return array|null
*/
public function getSection($section)
{
if(array_key_exists($section, $this->_configuration)) {
return $this->_configuration[$section];
}
return null;
}
/**
* Gets a value from a section with the given key.
* @param string $section
* @param string $key
* @return mixed|null
*/
public function getSectionValue($section, $key)
{
if(array_key_exists($section, $this->_configuration) && is_array($this->_configuration[$section]) && array_key_exists($key, $this->_configuration[$section])) {
return $this->_configuration[$section][$key];
}
return null;
}
/**
* Sets a path within the application. Paths must be set relative to the
* application root. The configured base path will be stripped from
* set paths.
* @param string $alias
* @param string|array $path
* @return Fizzy_Config
*/
public function setPath($alias, $path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
if(is_array($path)) {
$path = array_walk($path, array($this, '_removeBasePath'));
}
else if('base' !== $alias) {
$path = $this->_removeBasePath($path);
}
$this->_configuration[self::SECTION_PATHS][$alias] = $path;
return $this;
}
/**
* Returns a set path by name. Paths are returned include the set base path.
* Use getApplicationPath($alias) to get the path relative to the
* application root.
* @param string $alias
* @return string|null
*/
public function getPath($alias)
{
if(!array_key_exists($alias, $this->_configuration[self::SECTION_PATHS])) {
return null;
}
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$path = $this->_configuration[self::SECTION_PATHS][$alias];
if(is_array($path)) {
array_walk($path, array($this, '_addBasePath'));
}
else {
$path = $this->_addBasePath($path);
}
return $path;
}
/**
* Adds the base path to an application path.
* @param string $path
* @return string
*/
protected function _addBasePath(&$path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$basePath = $this->_cleanPath($basePath);
if(0 !== strpos($path, $basePath)) {
$path = $this->_createPath($basePath, $path);
}
return $path;
}
/**
* Removes the base path from an application path.
* @param string $path
* @return string
*/
protected function _removeBasePath(&$path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$basePath = $this->_cleanPath($basePath);
if(0 === strpos($path, $basePath)) {
$path = str_replace($basePath, '', $path);
}
return $path;
}
/**
* Cleans a path making sure it starts with a DIRECTORY_SEPARATOR and does
* not end with a DIRECTORY_SEPARATOR
* @param string $path
* @return string
*/
protected function _cleanPath($path)
{
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
if(0 !== strpos($path, DIRECTORY_SEPARATOR)) {
$path = DIRECTORY_SEPARATOR . $path;
}
$path = rtrim($path, DIRECTORY_SEPARATOR);
return $path;
}
/**
* Creates a path from multiple elements. Any number of elements can be
* supplied.
* @return <type>
*/
public function _createPath()
{
if(0 === func_num_args()) {
return null;
}
$elements = func_get_args();
$elements = array_map(array($this, '_cleanPath'), $elements);
return implode('', $elements);
}
/**
* Merges given paths with existent paths.
* @param array $paths
* @return Fizzy_Config
*/
public function addPaths(array $paths)
{
return $this->mergeSection(self::SECTION_PATHS, $paths);
}
/**
* Loads configuration from a SimpleXMLElement.
* @param SimpleXMLElement $element
* @return Fizzy_Config
*/
public function loadConfiguration(SimpleXMLElement $element)
{
// Parse the config element
$dataArray = array();
foreach($element->children() as $sectionName => $sectionData) {
$dataArray[$sectionName] = $this->_elementToArray($sectionData);
}
$this->_configuration = $this->_arrayMergeRecursive($this->_configuration, $dataArray);
return $this;
}
/**
* Loads routes configuration from a SimpleXMLElement. Merges the routes
* with the router section of the configuration.
* @param SimpleXMLElement $routes
* @return Fizzy_Config
*/
public function loadRoutes(SimpleXMLElement $routes)
{
$routesArray = array();
foreach($routes->children() as $routeName => $routeData) {
$routesArray[$routeName] = $this->_elementToArray($routeData);
}
$routerConfig = $this->getSection(self::SECTION_ROUTER);
$routerConfig = $this->_arrayMergeRecursive($routerConfig, $routesArray);
$this->setSection(self::SECTION_ROUTER, $routerConfig);
return $this;
}
/**
* Converts a SimpleXMLElement to an array.
* @param SimpleXMLElement $element
* @return array
*/
protected function _elementToArray(SimpleXMLElement $element)
{
$data = array();
if(count($element->children()) > 0) {
foreach($element->children() as $childKey => $childValue) {
if(count($childValue->children()) > 0) {
$value = $this->_elementToArray($childValue);
}
else {
$value = (string) $childValue;
}
// account for attributes
if(count($childValue->attributes()) > 0) {
$attributesArray = array();
foreach($childValue->attributes() as $attributeKey => $attributeValue) {
$attributesArray[$attributeKey] = (string) $attributeValue;
}
if(!is_array($value)) {
$value = array('value' => $value);
}
$value = array_merge($value, $attributesArray);
}
$data[$childKey] = $value;
}
}
else {
$data = (string) $element;
}
return $data;
}
/**
* Merges values from $valueArray into $baseArray recursively overwriting
* values in $baseArray.
*
* @param mixed $baseArray
* @param mixed $valueArray
* @return array
*/
protected function _arrayMergeRecursive($baseArray, $valueArray)
{
if(is_array($baseArray) && is_array($valueArray)) {
foreach($valueArray as $key => $value) {
if(isset($baseArray[$key])) {
$baseArray[$key] = $this->_arrayMergeRecursive($baseArray[$key], $value);
} else {
if($key === 0) {
$baseArray = array(0 => $this->_arrayMergeRecursive($baseArray, $value));
} else {
$baseArray[$key] = $value;
}
}
}
} else {
$baseArray = $valueArray;
}
return $baseArray;
}
/**
* Override to call configuration sections dynamically.
* @param string $name
* @param array $arguments
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
$section = str_replace('get', '', $name);
$section = strtolower(substr($section, 0, 1)) . substr($section, 1, strlen($section));
return $this->getSection($section);
}
}
}
diff --git a/application/library/Fizzy/Storage/Backend/Xml.php b/application/library/Fizzy/Storage/Backend/Xml.php
index 28e6cb8..8616b0d 100644
--- a/application/library/Fizzy/Storage/Backend/Xml.php
+++ b/application/library/Fizzy/Storage/Backend/Xml.php
@@ -1,309 +1,309 @@
<?php
/**
* Class Fizzy_Storage_Backend_Xml
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Abstract */
require_once 'Fizzy/Storage/Backend/Abstract.php';
/** Fizzy_Storage_Backend_Xml_DOMDocument */
require_once 'Fizzy/Storage/Backend/Xml/DOMDocument.php';
/**
* Storage backend for Fizzy based on XML files.
*
* @author Jeroen Tietema <[email protected]>
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage_Backend_Xml extends Fizzy_Storage_Backend_Abstract
{
/**
* @see Fizzy_Storage_Backend_Abstract
*/
protected $_identifierField = 'uid';
/**
* The path to the container store.
* @var string
*/
protected $_dataPath = null;
/**
* References to the XML documents for the containers.
* @var array
*/
protected $_xmlDocuments = array();
/** **/
/**
* Constructor
* @todo Add check for relative paths.
* @param array $options
* @throws Fizzy_Storage_Exception
*/
public function __construct($options = array())
{
parent::__construct($options);
$dsn = $this->getDsn();
list($protocol, $dataPath) = explode(':', $dsn);
// Change path to system directory separator
$dataPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $dataPath);
// Add a trailing slash
$dataPath = rtrim($dataPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
// Check if path is relative within the web application root
if(0 !== strpos($dataPath, DIRECTORY_SEPARATOR))
{
$basePath = Fizzy_Config::getInstance()->getSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath');
- $dataPath = $basePath . $dataPath;
+ $dataPath = $basePath . DIRECTORY_SEPARATOR . $dataPath;
}
// Set the dsn with the corrected absolute or relative path
$this->setDsn($protocol . ':' . $dataPath);
if(!is_dir($dataPath) || !is_writable($dataPath)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception(
"Data directory {$dataPath} does not exist or is not writable."
);
}
$this->_dataPath = $dataPath;
}
/**
* Returns the XML Document for a container.
* @param string $container
* @return Fizzy_Storage_Backend_XmlDocument
*/
protected function _getXmlDocument($container)
{
$container = strtolower(trim($container));
if(!array_key_exists($container, $this->_xmlDocuments)) {
$documentPath = $this->_dataPath . $container . '.xml';
if(!is_file($documentPath)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception("Container {$documentPath} could not be found.");
}
$this->_xmlDocuments[$container] = $this->_loadXmlDocument($documentPath);
}
return $this->_xmlDocuments[$container];
}
/**
* Loads an XML document from a path.
* @param string $path
*/
protected function _loadXmlDocument($path)
{
return new Fizzy_Storage_Backend_Xml_DOMDocument($path);
}
/**
* Parses a DOMNodeList and resturns an array.
* @param DOMNodeList $nodeList
* @return array
*/
protected function _parseNodeList($nodeList)
{
$elements = array();
foreach($nodeList as $node) {
$simpleXMLElement = simplexml_import_dom($node);
$elementArray = $this->_elementToArray($simpleXMLElement);
// Remove the identifier from the data
$identifier = $elementArray[$this->_identifierField];
unset($elementArray[$this->_identifierField]);
$elements[$identifier] = $elementArray;
}
return $elements;
}
/**
* Creates a DOMNodeList from an array naming the nodes like $nodeName.
* @param array $dataArray
* @param string $nodeName
* @return DOMNodeList
*/
protected function _createNodeList(array $dataArray, $document, $nodeName = 'item')
{
$root = $document->createElement('container');
foreach($dataArray as $identifier => $data)
{
// Create the element
$child = $document->createElement($nodeName);
// Add the identifier as attribute
$child->setAttribute($this->_identifierField, $identifier);
// Loop the data columns and add them as CDATA nodes
foreach($data as $key => $value)
{
$dataElement = $document->createElement($key);
$cdataElement = $document->createCDATASection($value);
$dataElement->appendChild($cdataElement);
$child->appendChild($dataElement);
}
$root->appendChild($child);
}
$nodeList = $root->childNodes;
return $nodeList;
}
/**
* Converts a SimpleXMLElement to an array.
* @param SimpleXMLElement $element
* @return array
*/
protected function _elementToArray(SimpleXMLElement $element)
{
$data = array();
if(count($element->children()) > 0) {
foreach($element->children() as $childKey => $childValue) {
$value = $this->_elementToArray($childValue);
$data[$childKey] = $value;
}
}
else {
$data = (string) $element;
}
// account for attributes
if(count($element->attributes()) > 0) {
$attributesArray = array();
foreach($element->attributes() as $attributeKey => $attributeValue) {
$attributesArray[$attributeKey] = (string) $attributeValue;
}
if(!is_array($data)) {
$data = array('data' => $data);
}
$data = array_merge($data, $attributesArray);
}
return $data;
}
/* Implementation of Fizzy_Storage_Backend_Interface */
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function persist($container, $data, $identifier = null)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
// Create a new identifier if empty
if(null === $identifier)
{
list($micro, $seconds) = explode(' ', microtime());
$identifier = $seconds . substr(strrchr($micro, '.'), 1);
}
$elements[$identifier] = $data;
// Create a new node list from the data
$nodeList = $this->_createNodeList($elements, $document, $container);
// Write the entire node list to the container file.
$success = $document->writeNodeList($nodeList);
return ((boolean) false !== $success);
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function delete($container, $identifier)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
// Unset the element
unset($elements[$identifier]);
// Create a new node list from the data
$nodeList = $this->_createNodeList($elements, $document, $container);
// Write the entire node list to the container file.
$success = $document->writeNodeList($nodeList);
return ((boolean) false !== $success);
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchAll($container)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByIdentifier($container, $identifier)
{
if(empty($identifier)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception('Identifier cannot be empty.');
}
$document = $this->_getXmlDocument($container);
$nodeList = $document->getElementsByXpath("/container/{$container}[@uid='{$identifier}']");
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByColumn($container, array $columns)
{
$document = $this->_getXmlDocument(strtolower($container));
$whereColumns = array();
foreach($columns as $key => $value) {
$whereColumns[$key] = "{$key}='{$value}'";
}
$nodeList = $document->getElementsByXpath("/container/{$container}[" . implode(' and ', $whereColumns) . "]");
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
}
\ No newline at end of file
diff --git a/public/css/admin-screen.css b/application/views/assets/css/admin-screen.css
similarity index 100%
rename from public/css/admin-screen.css
rename to application/views/assets/css/admin-screen.css
diff --git a/public/css/admin.css b/application/views/assets/css/admin.css
similarity index 99%
rename from public/css/admin.css
rename to application/views/assets/css/admin.css
index 411d2c3..d04094a 100644
--- a/public/css/admin.css
+++ b/application/views/assets/css/admin.css
@@ -1,312 +1,314 @@
+@import 'admin-screen.css';
+
html, body {
margin: 0;
padding: 0;
background-color: #777777;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #006EBF;
}
h1 { font-size: 2em; }
h1.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h2 { font-size: 1.5em; }
h2.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
h3 {}
h3.header {
padding-bottom: 2px;
border-bottom: 1px solid #555555;
}
.code-inline {
font-family: monospace;
font-size: 120%;
}
/** messages **/
.message { margin: 0; padding: 0; }
.message p { margin: 1em; }
.notice {
background-image: url('../images/icon/dialog-warning.png');
background-repeat: no-repeat;
background-position: .7em;
}
.error {
background-image: url('../images/icon/dialog-error.png');
background-repeat: no-repeat;
background-position: .7em;
}
.notice p, .error p {
margin-left: 4em;
}
/** tables **/
table.data-table {
width: 920px;
margin: 7px 0;
border: 1px #E5E5E5 solid;
}
table.data-table thead tr td {
padding: 3px;
border-bottom: 1px #D8D8D8 solid;
background: #F1F1F1;
font-style: italic;
color: #444444;
font-size: 13px;
}
table.data-table td {
padding: 3px 5px;
color: #666666;
vertical-align: top;
}
table.data-table tr.alt td {
background: #F3F3F3;
}
table.data-table tbody tr:hover td {
background: #FFFAC0;
}
/** forms **/
form {
margin: 0;
padding: 0;
border: 0;
}
fieldset {
margin: 10px;
padding: 5px;
border: 1px #E5E5E5 solid;
}
input, textarea {
background: #E9EEF1;
border: 1px #ccc solid;
padding: 2px;
margin: 2px 1px 1px;
color: #555555;
width: 300px;
font: 12px/16px "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif;
}
input[type='submit'] {
width: auto;
}
input[type='checkbox'] {
margin: 0.8em 0.5em 0.5em 0;
position: inherit;
top: auto;
}
label {
padding: 1px 3px;
display: block;
color: #555555;
font-weight: bold;
width: 100px;
}
.form-row, .form-row-last {
padding:7px;
border-bottom:1px #ccc dotted;
}
.form-row-last {
padding-left: 10px;
border: 0;
}
.form-row input[type="submit"] {
width: auto;
padding: 5px;
}
/* Header */
#header {
background: #2E3132 url('/images/menubg.png') repeat-x top left;
border-bottom: 2px solid #353535;
}
#header #navigation {
border-left: 1px #656565 solid;
}
#header #navigation ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin: 0;
padding: 0;
}
#header #navigation ul li {
float: left;
margin-right: 0;
position: relative;
}
#header #navigation ul li a {
display: block;
padding: 10px 16px;
text-align: center;
color: #FFFFFF;
text-decoration: none;
border-right: 1px #656565 solid;
}
#header #navigation ul li a:hover {
background: #424242;
}
#header #navigation ul li.link-logout {
float: right;
}
#header #navigation ul li.link-logout a {
border: 0;
}
#header #navigation ul li.link-logout a:hover {
background: inherit;
}
.content-container {
background: #FFFFFF;
border: 5px solid #555555;
margin-top: 45px;
}
#content {
line-height: 1.7em;
}
#content-wrapper {
margin: 15px;
}
#footer {
padding: 5px;
color: #555555;
text-align: right;
margin-bottom: 22px;
}
#footer a {
color: #555555;
}
/* Login window */
.login-container {}
.login-container .form-row {
border: 0;
}
.login-container label {
width: auto;
text-align: left;
margin: 4px 10px 0 0;
}
.login-container input[type='text'], .login-container input[type='password'] {
width: 200px;
}
.clear {
font-size: 0;
line-height: 0;
height: 0;
clear: both;
}
/* Media */
#upload-form {
margin-top: 2em;
margin-bottom: 1em;
}
#upload-form label {
display: inline-block;
margin: 0;
padding: 0;
width: auto;
}
#upload-form input {
width: auto;
}
.files-container {
padding: 10px;
background-color: #CCCCCC;
border-top: 2px solid #555555;
border-left: 2px solid #555555;
border-right: 2px solid #B5B5B5;
border-bottom: 1px solid #B5B5B5;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
}
.files-table { margin-bottom: 0; }
.files-table thead tr td, .files-table tbody tr td {
line-height: 16px;
padding: 5px 5px 5px 10px;
}
.files-table thead tr td {
background-color: #bbbbbb;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
border-left: 1px solid #cccccc;
}
.files-table tbody tr:hover td {
background-color: #dddddd;
}
.files-table .icon { width: 20px; text-align: center; }
.files-table .filename {}
.files-table .size { width: 75px; }
.files-table .controls {
width: 50px;
text-align: center;
}
/* Menu ordering */
.menu-container {
display: inline-block;
float: left;
width: 300px;
}
.item-list-container {
border: 1px solid #CCCCCC;
margin: 0 10px 10px 10px;
}
#menu-items-container {
background-color: #72FF7F;
}
#available-items-container {
background-color: #FF7279;
}
.sortable-list {
min-height: 100px;
list-style-type: none;
margin: 0;
padding: 10px;
}
.sortable-list li {
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
.sortable-list .ui-state-default {
height: 1.5em;
line-height: 1.2em;
background-color: #F0F0F0;
border: 1px solid #AAAAAA;
}
.sortable-list .ui-state-highlight {
height: 1.5em;
line-height: 1.2em;
background-color: #FFE995;
border: 1px dashed #FFD073;
}
diff --git a/public/images/icon/accept.png b/application/views/assets/images/icon/accept.png
similarity index 100%
rename from public/images/icon/accept.png
rename to application/views/assets/images/icon/accept.png
diff --git a/public/images/icon/add.png b/application/views/assets/images/icon/add.png
similarity index 100%
rename from public/images/icon/add.png
rename to application/views/assets/images/icon/add.png
diff --git a/public/images/icon/cross.png b/application/views/assets/images/icon/cross.png
similarity index 100%
rename from public/images/icon/cross.png
rename to application/views/assets/images/icon/cross.png
diff --git a/public/images/icon/cross_octagon.png b/application/views/assets/images/icon/cross_octagon.png
similarity index 100%
rename from public/images/icon/cross_octagon.png
rename to application/views/assets/images/icon/cross_octagon.png
diff --git a/public/images/icon/delete.png b/application/views/assets/images/icon/delete.png
similarity index 100%
rename from public/images/icon/delete.png
rename to application/views/assets/images/icon/delete.png
diff --git a/public/images/icon/dialog-error.png b/application/views/assets/images/icon/dialog-error.png
similarity index 100%
rename from public/images/icon/dialog-error.png
rename to application/views/assets/images/icon/dialog-error.png
diff --git a/public/images/icon/dialog-information.png b/application/views/assets/images/icon/dialog-information.png
similarity index 100%
rename from public/images/icon/dialog-information.png
rename to application/views/assets/images/icon/dialog-information.png
diff --git a/public/images/icon/dialog-warning.png b/application/views/assets/images/icon/dialog-warning.png
similarity index 100%
rename from public/images/icon/dialog-warning.png
rename to application/views/assets/images/icon/dialog-warning.png
diff --git a/public/images/icon/disk.png b/application/views/assets/images/icon/disk.png
similarity index 100%
rename from public/images/icon/disk.png
rename to application/views/assets/images/icon/disk.png
diff --git a/public/images/icon/doc_access.png b/application/views/assets/images/icon/doc_access.png
similarity index 100%
rename from public/images/icon/doc_access.png
rename to application/views/assets/images/icon/doc_access.png
diff --git a/public/images/icon/doc_excel_csv.png b/application/views/assets/images/icon/doc_excel_csv.png
similarity index 100%
rename from public/images/icon/doc_excel_csv.png
rename to application/views/assets/images/icon/doc_excel_csv.png
diff --git a/public/images/icon/doc_excel_table.png b/application/views/assets/images/icon/doc_excel_table.png
similarity index 100%
rename from public/images/icon/doc_excel_table.png
rename to application/views/assets/images/icon/doc_excel_table.png
diff --git a/public/images/icon/doc_film.png b/application/views/assets/images/icon/doc_film.png
similarity index 100%
rename from public/images/icon/doc_film.png
rename to application/views/assets/images/icon/doc_film.png
diff --git a/public/images/icon/doc_illustrator.png b/application/views/assets/images/icon/doc_illustrator.png
similarity index 100%
rename from public/images/icon/doc_illustrator.png
rename to application/views/assets/images/icon/doc_illustrator.png
diff --git a/public/images/icon/doc_music.png b/application/views/assets/images/icon/doc_music.png
similarity index 100%
rename from public/images/icon/doc_music.png
rename to application/views/assets/images/icon/doc_music.png
diff --git a/public/images/icon/doc_pdf.png b/application/views/assets/images/icon/doc_pdf.png
similarity index 100%
rename from public/images/icon/doc_pdf.png
rename to application/views/assets/images/icon/doc_pdf.png
diff --git a/public/images/icon/doc_photoshop.png b/application/views/assets/images/icon/doc_photoshop.png
similarity index 100%
rename from public/images/icon/doc_photoshop.png
rename to application/views/assets/images/icon/doc_photoshop.png
diff --git a/public/images/icon/edit.png b/application/views/assets/images/icon/edit.png
similarity index 100%
rename from public/images/icon/edit.png
rename to application/views/assets/images/icon/edit.png
diff --git a/public/images/icon/email.png b/application/views/assets/images/icon/email.png
similarity index 100%
rename from public/images/icon/email.png
rename to application/views/assets/images/icon/email.png
diff --git a/public/images/icon/error.png b/application/views/assets/images/icon/error.png
similarity index 100%
rename from public/images/icon/error.png
rename to application/views/assets/images/icon/error.png
diff --git a/public/images/icon/exclamation.png b/application/views/assets/images/icon/exclamation.png
similarity index 100%
rename from public/images/icon/exclamation.png
rename to application/views/assets/images/icon/exclamation.png
diff --git a/public/images/icon/feed.png b/application/views/assets/images/icon/feed.png
similarity index 100%
rename from public/images/icon/feed.png
rename to application/views/assets/images/icon/feed.png
diff --git a/public/images/icon/page.png b/application/views/assets/images/icon/page.png
similarity index 100%
rename from public/images/icon/page.png
rename to application/views/assets/images/icon/page.png
diff --git a/public/images/icon/page_2.png b/application/views/assets/images/icon/page_2.png
similarity index 100%
rename from public/images/icon/page_2.png
rename to application/views/assets/images/icon/page_2.png
diff --git a/public/images/icon/page_2_copy.png b/application/views/assets/images/icon/page_2_copy.png
similarity index 100%
rename from public/images/icon/page_2_copy.png
rename to application/views/assets/images/icon/page_2_copy.png
diff --git a/public/images/icon/page_code.png b/application/views/assets/images/icon/page_code.png
similarity index 100%
rename from public/images/icon/page_code.png
rename to application/views/assets/images/icon/page_code.png
diff --git a/public/images/icon/page_copy.png b/application/views/assets/images/icon/page_copy.png
similarity index 100%
rename from public/images/icon/page_copy.png
rename to application/views/assets/images/icon/page_copy.png
diff --git a/public/images/icon/page_excel.png b/application/views/assets/images/icon/page_excel.png
similarity index 100%
rename from public/images/icon/page_excel.png
rename to application/views/assets/images/icon/page_excel.png
diff --git a/public/images/icon/page_lightning.png b/application/views/assets/images/icon/page_lightning.png
similarity index 100%
rename from public/images/icon/page_lightning.png
rename to application/views/assets/images/icon/page_lightning.png
diff --git a/public/images/icon/page_paste.png b/application/views/assets/images/icon/page_paste.png
similarity index 100%
rename from public/images/icon/page_paste.png
rename to application/views/assets/images/icon/page_paste.png
diff --git a/public/images/icon/page_red.png b/application/views/assets/images/icon/page_red.png
similarity index 100%
rename from public/images/icon/page_red.png
rename to application/views/assets/images/icon/page_red.png
diff --git a/public/images/icon/page_refresh.png b/application/views/assets/images/icon/page_refresh.png
similarity index 100%
rename from public/images/icon/page_refresh.png
rename to application/views/assets/images/icon/page_refresh.png
diff --git a/public/images/icon/page_save.png b/application/views/assets/images/icon/page_save.png
similarity index 100%
rename from public/images/icon/page_save.png
rename to application/views/assets/images/icon/page_save.png
diff --git a/public/images/icon/page_white_cplusplus.png b/application/views/assets/images/icon/page_white_cplusplus.png
similarity index 100%
rename from public/images/icon/page_white_cplusplus.png
rename to application/views/assets/images/icon/page_white_cplusplus.png
diff --git a/public/images/icon/page_white_csharp.png b/application/views/assets/images/icon/page_white_csharp.png
similarity index 100%
rename from public/images/icon/page_white_csharp.png
rename to application/views/assets/images/icon/page_white_csharp.png
diff --git a/public/images/icon/page_white_cup.png b/application/views/assets/images/icon/page_white_cup.png
similarity index 100%
rename from public/images/icon/page_white_cup.png
rename to application/views/assets/images/icon/page_white_cup.png
diff --git a/public/images/icon/page_white_database.png b/application/views/assets/images/icon/page_white_database.png
similarity index 100%
rename from public/images/icon/page_white_database.png
rename to application/views/assets/images/icon/page_white_database.png
diff --git a/public/images/icon/page_white_delete.png b/application/views/assets/images/icon/page_white_delete.png
similarity index 100%
rename from public/images/icon/page_white_delete.png
rename to application/views/assets/images/icon/page_white_delete.png
diff --git a/public/images/icon/page_white_dvd.png b/application/views/assets/images/icon/page_white_dvd.png
similarity index 100%
rename from public/images/icon/page_white_dvd.png
rename to application/views/assets/images/icon/page_white_dvd.png
diff --git a/public/images/icon/page_white_edit.png b/application/views/assets/images/icon/page_white_edit.png
similarity index 100%
rename from public/images/icon/page_white_edit.png
rename to application/views/assets/images/icon/page_white_edit.png
diff --git a/public/images/icon/page_white_error.png b/application/views/assets/images/icon/page_white_error.png
similarity index 100%
rename from public/images/icon/page_white_error.png
rename to application/views/assets/images/icon/page_white_error.png
diff --git a/public/images/icon/page_white_excel.png b/application/views/assets/images/icon/page_white_excel.png
similarity index 100%
rename from public/images/icon/page_white_excel.png
rename to application/views/assets/images/icon/page_white_excel.png
diff --git a/public/images/icon/page_white_find.png b/application/views/assets/images/icon/page_white_find.png
similarity index 100%
rename from public/images/icon/page_white_find.png
rename to application/views/assets/images/icon/page_white_find.png
diff --git a/public/images/icon/page_white_flash.png b/application/views/assets/images/icon/page_white_flash.png
similarity index 100%
rename from public/images/icon/page_white_flash.png
rename to application/views/assets/images/icon/page_white_flash.png
diff --git a/public/images/icon/page_white_freehand.png b/application/views/assets/images/icon/page_white_freehand.png
similarity index 100%
rename from public/images/icon/page_white_freehand.png
rename to application/views/assets/images/icon/page_white_freehand.png
diff --git a/public/images/icon/page_white_gear.png b/application/views/assets/images/icon/page_white_gear.png
similarity index 100%
rename from public/images/icon/page_white_gear.png
rename to application/views/assets/images/icon/page_white_gear.png
diff --git a/public/images/icon/page_white_get.png b/application/views/assets/images/icon/page_white_get.png
similarity index 100%
rename from public/images/icon/page_white_get.png
rename to application/views/assets/images/icon/page_white_get.png
diff --git a/public/images/icon/page_white_paintbrush.png b/application/views/assets/images/icon/page_white_paintbrush.png
similarity index 100%
rename from public/images/icon/page_white_paintbrush.png
rename to application/views/assets/images/icon/page_white_paintbrush.png
diff --git a/public/images/icon/page_white_paste.png b/application/views/assets/images/icon/page_white_paste.png
similarity index 100%
rename from public/images/icon/page_white_paste.png
rename to application/views/assets/images/icon/page_white_paste.png
diff --git a/public/images/icon/page_white_php.png b/application/views/assets/images/icon/page_white_php.png
similarity index 100%
rename from public/images/icon/page_white_php.png
rename to application/views/assets/images/icon/page_white_php.png
diff --git a/public/images/icon/page_white_picture.png b/application/views/assets/images/icon/page_white_picture.png
similarity index 100%
rename from public/images/icon/page_white_picture.png
rename to application/views/assets/images/icon/page_white_picture.png
diff --git a/public/images/icon/page_white_powerpoint.png b/application/views/assets/images/icon/page_white_powerpoint.png
similarity index 100%
rename from public/images/icon/page_white_powerpoint.png
rename to application/views/assets/images/icon/page_white_powerpoint.png
diff --git a/public/images/icon/page_white_put.png b/application/views/assets/images/icon/page_white_put.png
similarity index 100%
rename from public/images/icon/page_white_put.png
rename to application/views/assets/images/icon/page_white_put.png
diff --git a/public/images/icon/page_white_ruby.png b/application/views/assets/images/icon/page_white_ruby.png
similarity index 100%
rename from public/images/icon/page_white_ruby.png
rename to application/views/assets/images/icon/page_white_ruby.png
diff --git a/public/images/icon/page_white_stack.png b/application/views/assets/images/icon/page_white_stack.png
similarity index 100%
rename from public/images/icon/page_white_stack.png
rename to application/views/assets/images/icon/page_white_stack.png
diff --git a/public/images/icon/page_white_vector.png b/application/views/assets/images/icon/page_white_vector.png
similarity index 100%
rename from public/images/icon/page_white_vector.png
rename to application/views/assets/images/icon/page_white_vector.png
diff --git a/public/images/icon/page_white_visualstudio.png b/application/views/assets/images/icon/page_white_visualstudio.png
similarity index 100%
rename from public/images/icon/page_white_visualstudio.png
rename to application/views/assets/images/icon/page_white_visualstudio.png
diff --git a/public/images/icon/page_white_word.png b/application/views/assets/images/icon/page_white_word.png
similarity index 100%
rename from public/images/icon/page_white_word.png
rename to application/views/assets/images/icon/page_white_word.png
diff --git a/public/images/icon/picture.png b/application/views/assets/images/icon/picture.png
similarity index 100%
rename from public/images/icon/picture.png
rename to application/views/assets/images/icon/picture.png
diff --git a/public/images/icon/save.png b/application/views/assets/images/icon/save.png
similarity index 100%
rename from public/images/icon/save.png
rename to application/views/assets/images/icon/save.png
diff --git a/public/images/icon/sign_add.png b/application/views/assets/images/icon/sign_add.png
similarity index 100%
rename from public/images/icon/sign_add.png
rename to application/views/assets/images/icon/sign_add.png
diff --git a/public/images/icon/sign_cancel.png b/application/views/assets/images/icon/sign_cancel.png
similarity index 100%
rename from public/images/icon/sign_cancel.png
rename to application/views/assets/images/icon/sign_cancel.png
diff --git a/public/images/icon/sign_deny.png b/application/views/assets/images/icon/sign_deny.png
similarity index 100%
rename from public/images/icon/sign_deny.png
rename to application/views/assets/images/icon/sign_deny.png
diff --git a/public/images/icon/sign_error.png b/application/views/assets/images/icon/sign_error.png
similarity index 100%
rename from public/images/icon/sign_error.png
rename to application/views/assets/images/icon/sign_error.png
diff --git a/public/images/icon/sign_explain.png b/application/views/assets/images/icon/sign_explain.png
similarity index 100%
rename from public/images/icon/sign_explain.png
rename to application/views/assets/images/icon/sign_explain.png
diff --git a/public/images/icon/sign_info.png b/application/views/assets/images/icon/sign_info.png
similarity index 100%
rename from public/images/icon/sign_info.png
rename to application/views/assets/images/icon/sign_info.png
diff --git a/public/images/icon/sign_question.png b/application/views/assets/images/icon/sign_question.png
similarity index 100%
rename from public/images/icon/sign_question.png
rename to application/views/assets/images/icon/sign_question.png
diff --git a/public/images/icon/sign_remove.png b/application/views/assets/images/icon/sign_remove.png
similarity index 100%
rename from public/images/icon/sign_remove.png
rename to application/views/assets/images/icon/sign_remove.png
diff --git a/public/images/icon/sign_tick.png b/application/views/assets/images/icon/sign_tick.png
similarity index 100%
rename from public/images/icon/sign_tick.png
rename to application/views/assets/images/icon/sign_tick.png
diff --git a/public/images/icon/sign_warning.png b/application/views/assets/images/icon/sign_warning.png
similarity index 100%
rename from public/images/icon/sign_warning.png
rename to application/views/assets/images/icon/sign_warning.png
diff --git a/public/images/icon/magnifier.png b/application/views/assets/images/icon/view.png
similarity index 100%
rename from public/images/icon/magnifier.png
rename to application/views/assets/images/icon/view.png
diff --git a/public/images/menubg.png b/application/views/assets/images/menubg.png
similarity index 100%
rename from public/images/menubg.png
rename to application/views/assets/images/menubg.png
diff --git a/public/images/wrapper.png b/application/views/assets/images/wrapper.png
similarity index 100%
rename from public/images/wrapper.png
rename to application/views/assets/images/wrapper.png
diff --git a/public/js/tiny_mce/langs/en.js b/application/views/assets/js/tiny_mce/langs/en.js
similarity index 100%
rename from public/js/tiny_mce/langs/en.js
rename to application/views/assets/js/tiny_mce/langs/en.js
diff --git a/public/js/tiny_mce/license.txt b/application/views/assets/js/tiny_mce/license.txt
similarity index 100%
rename from public/js/tiny_mce/license.txt
rename to application/views/assets/js/tiny_mce/license.txt
diff --git a/public/js/tiny_mce/plugins/advhr/css/advhr.css b/application/views/assets/js/tiny_mce/plugins/advhr/css/advhr.css
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/css/advhr.css
rename to application/views/assets/js/tiny_mce/plugins/advhr/css/advhr.css
diff --git a/public/js/tiny_mce/plugins/advhr/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/advhr/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/advhr/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/advhr/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/advhr/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/advhr/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/advhr/js/rule.js b/application/views/assets/js/tiny_mce/plugins/advhr/js/rule.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/js/rule.js
rename to application/views/assets/js/tiny_mce/plugins/advhr/js/rule.js
diff --git a/public/js/tiny_mce/plugins/advhr/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/advhr/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/advhr/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/advhr/rule.htm b/application/views/assets/js/tiny_mce/plugins/advhr/rule.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/advhr/rule.htm
rename to application/views/assets/js/tiny_mce/plugins/advhr/rule.htm
diff --git a/public/js/tiny_mce/plugins/advimage/css/advimage.css b/application/views/assets/js/tiny_mce/plugins/advimage/css/advimage.css
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/css/advimage.css
rename to application/views/assets/js/tiny_mce/plugins/advimage/css/advimage.css
diff --git a/public/js/tiny_mce/plugins/advimage/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/advimage/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/advimage/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/advimage/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/advimage/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/advimage/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/advimage/image.htm b/application/views/assets/js/tiny_mce/plugins/advimage/image.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/image.htm
rename to application/views/assets/js/tiny_mce/plugins/advimage/image.htm
diff --git a/public/js/tiny_mce/plugins/advimage/img/sample.gif b/application/views/assets/js/tiny_mce/plugins/advimage/img/sample.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/img/sample.gif
rename to application/views/assets/js/tiny_mce/plugins/advimage/img/sample.gif
diff --git a/public/js/tiny_mce/plugins/advimage/js/image.js b/application/views/assets/js/tiny_mce/plugins/advimage/js/image.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/js/image.js
rename to application/views/assets/js/tiny_mce/plugins/advimage/js/image.js
diff --git a/public/js/tiny_mce/plugins/advimage/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/advimage/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advimage/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/advimage/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/advlink/css/advlink.css b/application/views/assets/js/tiny_mce/plugins/advlink/css/advlink.css
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/css/advlink.css
rename to application/views/assets/js/tiny_mce/plugins/advlink/css/advlink.css
diff --git a/public/js/tiny_mce/plugins/advlink/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/advlink/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/advlink/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/advlink/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/advlink/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/advlink/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/advlink/js/advlink.js b/application/views/assets/js/tiny_mce/plugins/advlink/js/advlink.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/js/advlink.js
rename to application/views/assets/js/tiny_mce/plugins/advlink/js/advlink.js
diff --git a/public/js/tiny_mce/plugins/advlink/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/advlink/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/advlink/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/advlink/link.htm b/application/views/assets/js/tiny_mce/plugins/advlink/link.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/advlink/link.htm
rename to application/views/assets/js/tiny_mce/plugins/advlink/link.htm
diff --git a/public/js/tiny_mce/plugins/autoresize/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/autoresize/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/autoresize/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/autoresize/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/autoresize/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/autoresize/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/autoresize/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/autoresize/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/autosave/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/autosave/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/autosave/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/autosave/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/autosave/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/autosave/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/autosave/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/autosave/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/bbcode/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/bbcode/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/bbcode/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/bbcode/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/bbcode/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/contextmenu/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/contextmenu/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/contextmenu/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/contextmenu/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/directionality/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/directionality/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/directionality/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/directionality/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/directionality/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/directionality/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/directionality/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/directionality/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/emotions/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/emotions/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/emotions/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/emotions/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/emotions/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/emotions/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/emotions/emotions.htm b/application/views/assets/js/tiny_mce/plugins/emotions/emotions.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/emotions.htm
rename to application/views/assets/js/tiny_mce/plugins/emotions/emotions.htm
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-cool.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-cool.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-cool.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-cool.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-cry.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-cry.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-cry.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-cry.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-embarassed.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-embarassed.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-embarassed.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-embarassed.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-frown.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-frown.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-frown.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-frown.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-innocent.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-innocent.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-innocent.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-innocent.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-kiss.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-kiss.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-kiss.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-kiss.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-money-mouth.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-money-mouth.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-money-mouth.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-money-mouth.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-sealed.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-sealed.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-sealed.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-sealed.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-smile.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-smile.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-smile.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-smile.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-surprised.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-surprised.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-surprised.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-surprised.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-tongue-out.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-tongue-out.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-tongue-out.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-tongue-out.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-undecided.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-undecided.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-undecided.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-undecided.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-wink.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-wink.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-wink.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-wink.gif
diff --git a/public/js/tiny_mce/plugins/emotions/img/smiley-yell.gif b/application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-yell.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/img/smiley-yell.gif
rename to application/views/assets/js/tiny_mce/plugins/emotions/img/smiley-yell.gif
diff --git a/public/js/tiny_mce/plugins/emotions/js/emotions.js b/application/views/assets/js/tiny_mce/plugins/emotions/js/emotions.js
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/js/emotions.js
rename to application/views/assets/js/tiny_mce/plugins/emotions/js/emotions.js
diff --git a/public/js/tiny_mce/plugins/emotions/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/emotions/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/emotions/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/emotions/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/example/dialog.htm b/application/views/assets/js/tiny_mce/plugins/example/dialog.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/example/dialog.htm
rename to application/views/assets/js/tiny_mce/plugins/example/dialog.htm
diff --git a/public/js/tiny_mce/plugins/example/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/example/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/example/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/example/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/example/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/example/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/example/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/example/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/example/img/example.gif b/application/views/assets/js/tiny_mce/plugins/example/img/example.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/example/img/example.gif
rename to application/views/assets/js/tiny_mce/plugins/example/img/example.gif
diff --git a/public/js/tiny_mce/plugins/example/js/dialog.js b/application/views/assets/js/tiny_mce/plugins/example/js/dialog.js
similarity index 100%
rename from public/js/tiny_mce/plugins/example/js/dialog.js
rename to application/views/assets/js/tiny_mce/plugins/example/js/dialog.js
diff --git a/public/js/tiny_mce/plugins/example/langs/en.js b/application/views/assets/js/tiny_mce/plugins/example/langs/en.js
similarity index 100%
rename from public/js/tiny_mce/plugins/example/langs/en.js
rename to application/views/assets/js/tiny_mce/plugins/example/langs/en.js
diff --git a/public/js/tiny_mce/plugins/example/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/example/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/example/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/example/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/fullpage/css/fullpage.css b/application/views/assets/js/tiny_mce/plugins/fullpage/css/fullpage.css
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/css/fullpage.css
rename to application/views/assets/js/tiny_mce/plugins/fullpage/css/fullpage.css
diff --git a/public/js/tiny_mce/plugins/fullpage/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/fullpage/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/fullpage/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/fullpage/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/fullpage/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/fullpage/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/fullpage/fullpage.htm b/application/views/assets/js/tiny_mce/plugins/fullpage/fullpage.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/fullpage.htm
rename to application/views/assets/js/tiny_mce/plugins/fullpage/fullpage.htm
diff --git a/public/js/tiny_mce/plugins/fullpage/js/fullpage.js b/application/views/assets/js/tiny_mce/plugins/fullpage/js/fullpage.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/js/fullpage.js
rename to application/views/assets/js/tiny_mce/plugins/fullpage/js/fullpage.js
diff --git a/public/js/tiny_mce/plugins/fullpage/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/fullpage/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullpage/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/fullpage/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/fullscreen/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/fullscreen/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullscreen/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/fullscreen/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/fullscreen/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/fullscreen/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/fullscreen/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/fullscreen/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/fullscreen/fullscreen.htm b/application/views/assets/js/tiny_mce/plugins/fullscreen/fullscreen.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/fullscreen/fullscreen.htm
rename to application/views/assets/js/tiny_mce/plugins/fullscreen/fullscreen.htm
diff --git a/public/js/tiny_mce/plugins/iespell/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/iespell/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/iespell/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/iespell/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/iespell/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/iespell/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/iespell/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/iespell/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/inlinepopups/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/inlinepopups/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/inlinepopups/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/inlinepopups/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif
diff --git a/public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css b/application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css
diff --git a/public/js/tiny_mce/plugins/inlinepopups/template.htm b/application/views/assets/js/tiny_mce/plugins/inlinepopups/template.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/inlinepopups/template.htm
rename to application/views/assets/js/tiny_mce/plugins/inlinepopups/template.htm
diff --git a/public/js/tiny_mce/plugins/insertdatetime/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/insertdatetime/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/insertdatetime/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/insertdatetime/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/layer/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/layer/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/layer/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/layer/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/layer/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/layer/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/layer/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/layer/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/media/css/content.css b/application/views/assets/js/tiny_mce/plugins/media/css/content.css
similarity index 100%
rename from public/js/tiny_mce/plugins/media/css/content.css
rename to application/views/assets/js/tiny_mce/plugins/media/css/content.css
diff --git a/public/js/tiny_mce/plugins/media/css/media.css b/application/views/assets/js/tiny_mce/plugins/media/css/media.css
similarity index 100%
rename from public/js/tiny_mce/plugins/media/css/media.css
rename to application/views/assets/js/tiny_mce/plugins/media/css/media.css
diff --git a/public/js/tiny_mce/plugins/media/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/media/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/media/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/media/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/media/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/media/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/media/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/media/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/media/img/flash.gif b/application/views/assets/js/tiny_mce/plugins/media/img/flash.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/flash.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/flash.gif
diff --git a/public/js/tiny_mce/plugins/media/img/flv_player.swf b/application/views/assets/js/tiny_mce/plugins/media/img/flv_player.swf
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/flv_player.swf
rename to application/views/assets/js/tiny_mce/plugins/media/img/flv_player.swf
diff --git a/public/js/tiny_mce/plugins/media/img/quicktime.gif b/application/views/assets/js/tiny_mce/plugins/media/img/quicktime.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/quicktime.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/quicktime.gif
diff --git a/public/js/tiny_mce/plugins/media/img/realmedia.gif b/application/views/assets/js/tiny_mce/plugins/media/img/realmedia.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/realmedia.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/realmedia.gif
diff --git a/public/js/tiny_mce/plugins/media/img/shockwave.gif b/application/views/assets/js/tiny_mce/plugins/media/img/shockwave.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/shockwave.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/shockwave.gif
diff --git a/public/js/tiny_mce/plugins/media/img/trans.gif b/application/views/assets/js/tiny_mce/plugins/media/img/trans.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/trans.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/trans.gif
diff --git a/public/js/tiny_mce/plugins/media/img/windowsmedia.gif b/application/views/assets/js/tiny_mce/plugins/media/img/windowsmedia.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/media/img/windowsmedia.gif
rename to application/views/assets/js/tiny_mce/plugins/media/img/windowsmedia.gif
diff --git a/public/js/tiny_mce/plugins/media/js/embed.js b/application/views/assets/js/tiny_mce/plugins/media/js/embed.js
similarity index 100%
rename from public/js/tiny_mce/plugins/media/js/embed.js
rename to application/views/assets/js/tiny_mce/plugins/media/js/embed.js
diff --git a/public/js/tiny_mce/plugins/media/js/media.js b/application/views/assets/js/tiny_mce/plugins/media/js/media.js
similarity index 100%
rename from public/js/tiny_mce/plugins/media/js/media.js
rename to application/views/assets/js/tiny_mce/plugins/media/js/media.js
diff --git a/public/js/tiny_mce/plugins/media/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/media/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/media/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/media/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/media/media.htm b/application/views/assets/js/tiny_mce/plugins/media/media.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/media/media.htm
rename to application/views/assets/js/tiny_mce/plugins/media/media.htm
diff --git a/public/js/tiny_mce/plugins/nonbreaking/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/nonbreaking/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/nonbreaking/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/nonbreaking/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/nonbreaking/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/nonbreaking/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/nonbreaking/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/nonbreaking/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/noneditable/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/noneditable/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/noneditable/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/noneditable/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/noneditable/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/noneditable/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/noneditable/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/noneditable/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/pagebreak/css/content.css b/application/views/assets/js/tiny_mce/plugins/pagebreak/css/content.css
similarity index 100%
rename from public/js/tiny_mce/plugins/pagebreak/css/content.css
rename to application/views/assets/js/tiny_mce/plugins/pagebreak/css/content.css
diff --git a/public/js/tiny_mce/plugins/pagebreak/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/pagebreak/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/pagebreak/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/pagebreak/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/pagebreak/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/pagebreak/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/pagebreak/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/pagebreak/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/pagebreak/img/pagebreak.gif b/application/views/assets/js/tiny_mce/plugins/pagebreak/img/pagebreak.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/pagebreak/img/pagebreak.gif
rename to application/views/assets/js/tiny_mce/plugins/pagebreak/img/pagebreak.gif
diff --git a/public/js/tiny_mce/plugins/pagebreak/img/trans.gif b/application/views/assets/js/tiny_mce/plugins/pagebreak/img/trans.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/pagebreak/img/trans.gif
rename to application/views/assets/js/tiny_mce/plugins/pagebreak/img/trans.gif
diff --git a/public/js/tiny_mce/plugins/paste/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/paste/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/paste/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/paste/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/paste/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/paste/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/paste/js/pastetext.js b/application/views/assets/js/tiny_mce/plugins/paste/js/pastetext.js
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/js/pastetext.js
rename to application/views/assets/js/tiny_mce/plugins/paste/js/pastetext.js
diff --git a/public/js/tiny_mce/plugins/paste/js/pasteword.js b/application/views/assets/js/tiny_mce/plugins/paste/js/pasteword.js
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/js/pasteword.js
rename to application/views/assets/js/tiny_mce/plugins/paste/js/pasteword.js
diff --git a/public/js/tiny_mce/plugins/paste/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/paste/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/paste/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/paste/pastetext.htm b/application/views/assets/js/tiny_mce/plugins/paste/pastetext.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/pastetext.htm
rename to application/views/assets/js/tiny_mce/plugins/paste/pastetext.htm
diff --git a/public/js/tiny_mce/plugins/paste/pasteword.htm b/application/views/assets/js/tiny_mce/plugins/paste/pasteword.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/paste/pasteword.htm
rename to application/views/assets/js/tiny_mce/plugins/paste/pasteword.htm
diff --git a/public/js/tiny_mce/plugins/preview/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/preview/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/preview/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/preview/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/preview/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/preview/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/preview/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/preview/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/preview/example.html b/application/views/assets/js/tiny_mce/plugins/preview/example.html
similarity index 100%
rename from public/js/tiny_mce/plugins/preview/example.html
rename to application/views/assets/js/tiny_mce/plugins/preview/example.html
diff --git a/public/js/tiny_mce/plugins/preview/jscripts/embed.js b/application/views/assets/js/tiny_mce/plugins/preview/jscripts/embed.js
similarity index 100%
rename from public/js/tiny_mce/plugins/preview/jscripts/embed.js
rename to application/views/assets/js/tiny_mce/plugins/preview/jscripts/embed.js
diff --git a/public/js/tiny_mce/plugins/preview/preview.html b/application/views/assets/js/tiny_mce/plugins/preview/preview.html
similarity index 100%
rename from public/js/tiny_mce/plugins/preview/preview.html
rename to application/views/assets/js/tiny_mce/plugins/preview/preview.html
diff --git a/public/js/tiny_mce/plugins/print/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/print/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/print/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/print/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/print/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/print/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/print/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/print/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/safari/blank.htm b/application/views/assets/js/tiny_mce/plugins/safari/blank.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/safari/blank.htm
rename to application/views/assets/js/tiny_mce/plugins/safari/blank.htm
diff --git a/public/js/tiny_mce/plugins/safari/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/safari/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/safari/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/safari/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/safari/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/safari/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/safari/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/safari/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/save/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/save/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/save/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/save/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/save/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/save/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/save/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/save/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/searchreplace/css/searchreplace.css b/application/views/assets/js/tiny_mce/plugins/searchreplace/css/searchreplace.css
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/css/searchreplace.css
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/css/searchreplace.css
diff --git a/public/js/tiny_mce/plugins/searchreplace/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/searchreplace/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/searchreplace/js/searchreplace.js b/application/views/assets/js/tiny_mce/plugins/searchreplace/js/searchreplace.js
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/js/searchreplace.js
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/js/searchreplace.js
diff --git a/public/js/tiny_mce/plugins/searchreplace/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/searchreplace/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/searchreplace/searchreplace.htm b/application/views/assets/js/tiny_mce/plugins/searchreplace/searchreplace.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/searchreplace/searchreplace.htm
rename to application/views/assets/js/tiny_mce/plugins/searchreplace/searchreplace.htm
diff --git a/public/js/tiny_mce/plugins/spellchecker/css/content.css b/application/views/assets/js/tiny_mce/plugins/spellchecker/css/content.css
similarity index 100%
rename from public/js/tiny_mce/plugins/spellchecker/css/content.css
rename to application/views/assets/js/tiny_mce/plugins/spellchecker/css/content.css
diff --git a/public/js/tiny_mce/plugins/spellchecker/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/spellchecker/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/spellchecker/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/spellchecker/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/spellchecker/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/spellchecker/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/spellchecker/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/spellchecker/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/spellchecker/img/wline.gif b/application/views/assets/js/tiny_mce/plugins/spellchecker/img/wline.gif
similarity index 100%
rename from public/js/tiny_mce/plugins/spellchecker/img/wline.gif
rename to application/views/assets/js/tiny_mce/plugins/spellchecker/img/wline.gif
diff --git a/public/js/tiny_mce/plugins/style/css/props.css b/application/views/assets/js/tiny_mce/plugins/style/css/props.css
similarity index 100%
rename from public/js/tiny_mce/plugins/style/css/props.css
rename to application/views/assets/js/tiny_mce/plugins/style/css/props.css
diff --git a/public/js/tiny_mce/plugins/style/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/style/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/style/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/style/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/style/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/style/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/style/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/style/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/style/js/props.js b/application/views/assets/js/tiny_mce/plugins/style/js/props.js
similarity index 100%
rename from public/js/tiny_mce/plugins/style/js/props.js
rename to application/views/assets/js/tiny_mce/plugins/style/js/props.js
diff --git a/public/js/tiny_mce/plugins/style/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/style/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/style/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/style/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/style/props.htm b/application/views/assets/js/tiny_mce/plugins/style/props.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/style/props.htm
rename to application/views/assets/js/tiny_mce/plugins/style/props.htm
diff --git a/public/js/tiny_mce/plugins/tabfocus/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/tabfocus/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/tabfocus/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/tabfocus/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/table/cell.htm b/application/views/assets/js/tiny_mce/plugins/table/cell.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/table/cell.htm
rename to application/views/assets/js/tiny_mce/plugins/table/cell.htm
diff --git a/public/js/tiny_mce/plugins/table/css/cell.css b/application/views/assets/js/tiny_mce/plugins/table/css/cell.css
similarity index 100%
rename from public/js/tiny_mce/plugins/table/css/cell.css
rename to application/views/assets/js/tiny_mce/plugins/table/css/cell.css
diff --git a/public/js/tiny_mce/plugins/table/css/row.css b/application/views/assets/js/tiny_mce/plugins/table/css/row.css
similarity index 100%
rename from public/js/tiny_mce/plugins/table/css/row.css
rename to application/views/assets/js/tiny_mce/plugins/table/css/row.css
diff --git a/public/js/tiny_mce/plugins/table/css/table.css b/application/views/assets/js/tiny_mce/plugins/table/css/table.css
similarity index 100%
rename from public/js/tiny_mce/plugins/table/css/table.css
rename to application/views/assets/js/tiny_mce/plugins/table/css/table.css
diff --git a/public/js/tiny_mce/plugins/table/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/table/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/table/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/table/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/table/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/table/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/table/js/cell.js b/application/views/assets/js/tiny_mce/plugins/table/js/cell.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/js/cell.js
rename to application/views/assets/js/tiny_mce/plugins/table/js/cell.js
diff --git a/public/js/tiny_mce/plugins/table/js/merge_cells.js b/application/views/assets/js/tiny_mce/plugins/table/js/merge_cells.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/js/merge_cells.js
rename to application/views/assets/js/tiny_mce/plugins/table/js/merge_cells.js
diff --git a/public/js/tiny_mce/plugins/table/js/row.js b/application/views/assets/js/tiny_mce/plugins/table/js/row.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/js/row.js
rename to application/views/assets/js/tiny_mce/plugins/table/js/row.js
diff --git a/public/js/tiny_mce/plugins/table/js/table.js b/application/views/assets/js/tiny_mce/plugins/table/js/table.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/js/table.js
rename to application/views/assets/js/tiny_mce/plugins/table/js/table.js
diff --git a/public/js/tiny_mce/plugins/table/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/table/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/table/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/table/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/table/merge_cells.htm b/application/views/assets/js/tiny_mce/plugins/table/merge_cells.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/table/merge_cells.htm
rename to application/views/assets/js/tiny_mce/plugins/table/merge_cells.htm
diff --git a/public/js/tiny_mce/plugins/table/row.htm b/application/views/assets/js/tiny_mce/plugins/table/row.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/table/row.htm
rename to application/views/assets/js/tiny_mce/plugins/table/row.htm
diff --git a/public/js/tiny_mce/plugins/table/table.htm b/application/views/assets/js/tiny_mce/plugins/table/table.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/table/table.htm
rename to application/views/assets/js/tiny_mce/plugins/table/table.htm
diff --git a/public/js/tiny_mce/plugins/template/blank.htm b/application/views/assets/js/tiny_mce/plugins/template/blank.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/template/blank.htm
rename to application/views/assets/js/tiny_mce/plugins/template/blank.htm
diff --git a/public/js/tiny_mce/plugins/template/css/template.css b/application/views/assets/js/tiny_mce/plugins/template/css/template.css
similarity index 100%
rename from public/js/tiny_mce/plugins/template/css/template.css
rename to application/views/assets/js/tiny_mce/plugins/template/css/template.css
diff --git a/public/js/tiny_mce/plugins/template/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/template/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/template/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/template/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/template/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/template/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/template/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/template/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/template/js/template.js b/application/views/assets/js/tiny_mce/plugins/template/js/template.js
similarity index 100%
rename from public/js/tiny_mce/plugins/template/js/template.js
rename to application/views/assets/js/tiny_mce/plugins/template/js/template.js
diff --git a/public/js/tiny_mce/plugins/template/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/template/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/template/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/template/langs/en_dlg.js
diff --git a/public/js/tiny_mce/plugins/template/template.htm b/application/views/assets/js/tiny_mce/plugins/template/template.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/template/template.htm
rename to application/views/assets/js/tiny_mce/plugins/template/template.htm
diff --git a/public/js/tiny_mce/plugins/visualchars/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/visualchars/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/visualchars/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/visualchars/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/visualchars/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/visualchars/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/visualchars/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/visualchars/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/wordcount/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/wordcount/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/wordcount/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/wordcount/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/wordcount/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/wordcount/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/wordcount/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/wordcount/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/abbr.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/abbr.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/abbr.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/abbr.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/acronym.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/acronym.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/acronym.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/acronym.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/attributes.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/attributes.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/attributes.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/attributes.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/cite.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/cite.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/cite.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/cite.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/css/attributes.css b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/css/attributes.css
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/css/attributes.css
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/css/attributes.css
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/css/popup.css b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/css/popup.css
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/css/popup.css
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/css/popup.css
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/del.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/del.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/del.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/del.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/editor_plugin.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/editor_plugin.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/editor_plugin.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/editor_plugin.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/ins.htm b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/ins.htm
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/ins.htm
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/ins.htm
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/abbr.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/abbr.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/abbr.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/abbr.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/acronym.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/acronym.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/acronym.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/acronym.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/attributes.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/attributes.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/attributes.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/attributes.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/cite.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/cite.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/cite.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/cite.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/del.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/del.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/del.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/del.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/element_common.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/element_common.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/element_common.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/element_common.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/js/ins.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/ins.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/js/ins.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/js/ins.js
diff --git a/public/js/tiny_mce/plugins/xhtmlxtras/langs/en_dlg.js b/application/views/assets/js/tiny_mce/plugins/xhtmlxtras/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/plugins/xhtmlxtras/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/plugins/xhtmlxtras/langs/en_dlg.js
diff --git a/public/js/tiny_mce/themes/advanced/about.htm b/application/views/assets/js/tiny_mce/themes/advanced/about.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/about.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/about.htm
diff --git a/public/js/tiny_mce/themes/advanced/anchor.htm b/application/views/assets/js/tiny_mce/themes/advanced/anchor.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/anchor.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/anchor.htm
diff --git a/public/js/tiny_mce/themes/advanced/charmap.htm b/application/views/assets/js/tiny_mce/themes/advanced/charmap.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/charmap.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/charmap.htm
diff --git a/public/js/tiny_mce/themes/advanced/color_picker.htm b/application/views/assets/js/tiny_mce/themes/advanced/color_picker.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/color_picker.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/color_picker.htm
diff --git a/public/js/tiny_mce/themes/advanced/editor_template.js b/application/views/assets/js/tiny_mce/themes/advanced/editor_template.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/editor_template.js
rename to application/views/assets/js/tiny_mce/themes/advanced/editor_template.js
diff --git a/public/js/tiny_mce/themes/advanced/editor_template_src.js b/application/views/assets/js/tiny_mce/themes/advanced/editor_template_src.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/editor_template_src.js
rename to application/views/assets/js/tiny_mce/themes/advanced/editor_template_src.js
diff --git a/public/js/tiny_mce/themes/advanced/image.htm b/application/views/assets/js/tiny_mce/themes/advanced/image.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/image.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/image.htm
diff --git a/public/js/tiny_mce/themes/advanced/img/colorpicker.jpg b/application/views/assets/js/tiny_mce/themes/advanced/img/colorpicker.jpg
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/img/colorpicker.jpg
rename to application/views/assets/js/tiny_mce/themes/advanced/img/colorpicker.jpg
diff --git a/public/js/tiny_mce/themes/advanced/img/icons.gif b/application/views/assets/js/tiny_mce/themes/advanced/img/icons.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/img/icons.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/img/icons.gif
diff --git a/public/js/tiny_mce/themes/advanced/js/about.js b/application/views/assets/js/tiny_mce/themes/advanced/js/about.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/about.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/about.js
diff --git a/public/js/tiny_mce/themes/advanced/js/anchor.js b/application/views/assets/js/tiny_mce/themes/advanced/js/anchor.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/anchor.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/anchor.js
diff --git a/public/js/tiny_mce/themes/advanced/js/charmap.js b/application/views/assets/js/tiny_mce/themes/advanced/js/charmap.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/charmap.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/charmap.js
diff --git a/public/js/tiny_mce/themes/advanced/js/color_picker.js b/application/views/assets/js/tiny_mce/themes/advanced/js/color_picker.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/color_picker.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/color_picker.js
diff --git a/public/js/tiny_mce/themes/advanced/js/image.js b/application/views/assets/js/tiny_mce/themes/advanced/js/image.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/image.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/image.js
diff --git a/public/js/tiny_mce/themes/advanced/js/link.js b/application/views/assets/js/tiny_mce/themes/advanced/js/link.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/link.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/link.js
diff --git a/public/js/tiny_mce/themes/advanced/js/source_editor.js b/application/views/assets/js/tiny_mce/themes/advanced/js/source_editor.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/js/source_editor.js
rename to application/views/assets/js/tiny_mce/themes/advanced/js/source_editor.js
diff --git a/public/js/tiny_mce/themes/advanced/langs/en.js b/application/views/assets/js/tiny_mce/themes/advanced/langs/en.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/langs/en.js
rename to application/views/assets/js/tiny_mce/themes/advanced/langs/en.js
diff --git a/public/js/tiny_mce/themes/advanced/langs/en_dlg.js b/application/views/assets/js/tiny_mce/themes/advanced/langs/en_dlg.js
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/langs/en_dlg.js
rename to application/views/assets/js/tiny_mce/themes/advanced/langs/en_dlg.js
diff --git a/public/js/tiny_mce/themes/advanced/link.htm b/application/views/assets/js/tiny_mce/themes/advanced/link.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/link.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/link.htm
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/content.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/content.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/content.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/content.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/dialog.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/dialog.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/dialog.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/dialog.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/buttons.png b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/buttons.png
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/buttons.png
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/buttons.png
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/items.gif b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/items.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/items.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/items.gif
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/menu_check.gif b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/menu_check.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/menu_check.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/menu_check.gif
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/progress.gif b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/progress.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/progress.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/progress.gif
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/img/tabs.gif b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/tabs.gif
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/img/tabs.gif
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/img/tabs.gif
diff --git a/public/js/tiny_mce/themes/advanced/skins/default/ui.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/default/ui.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/default/ui.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/default/ui.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/content.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/content.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/content.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/content.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/dialog.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/dialog.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/dialog.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/dialog.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/ui.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/ui.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/ui_black.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui_black.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/ui_black.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui_black.css
diff --git a/public/js/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css b/application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css
rename to application/views/assets/js/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css
diff --git a/public/js/tiny_mce/themes/advanced/source_editor.htm b/application/views/assets/js/tiny_mce/themes/advanced/source_editor.htm
similarity index 100%
rename from public/js/tiny_mce/themes/advanced/source_editor.htm
rename to application/views/assets/js/tiny_mce/themes/advanced/source_editor.htm
diff --git a/public/js/tiny_mce/themes/simple/editor_template.js b/application/views/assets/js/tiny_mce/themes/simple/editor_template.js
similarity index 100%
rename from public/js/tiny_mce/themes/simple/editor_template.js
rename to application/views/assets/js/tiny_mce/themes/simple/editor_template.js
diff --git a/public/js/tiny_mce/themes/simple/editor_template_src.js b/application/views/assets/js/tiny_mce/themes/simple/editor_template_src.js
similarity index 100%
rename from public/js/tiny_mce/themes/simple/editor_template_src.js
rename to application/views/assets/js/tiny_mce/themes/simple/editor_template_src.js
diff --git a/public/js/tiny_mce/themes/simple/img/icons.gif b/application/views/assets/js/tiny_mce/themes/simple/img/icons.gif
similarity index 100%
rename from public/js/tiny_mce/themes/simple/img/icons.gif
rename to application/views/assets/js/tiny_mce/themes/simple/img/icons.gif
diff --git a/public/js/tiny_mce/themes/simple/langs/en.js b/application/views/assets/js/tiny_mce/themes/simple/langs/en.js
similarity index 100%
rename from public/js/tiny_mce/themes/simple/langs/en.js
rename to application/views/assets/js/tiny_mce/themes/simple/langs/en.js
diff --git a/public/js/tiny_mce/themes/simple/skins/default/content.css b/application/views/assets/js/tiny_mce/themes/simple/skins/default/content.css
similarity index 100%
rename from public/js/tiny_mce/themes/simple/skins/default/content.css
rename to application/views/assets/js/tiny_mce/themes/simple/skins/default/content.css
diff --git a/public/js/tiny_mce/themes/simple/skins/default/ui.css b/application/views/assets/js/tiny_mce/themes/simple/skins/default/ui.css
similarity index 100%
rename from public/js/tiny_mce/themes/simple/skins/default/ui.css
rename to application/views/assets/js/tiny_mce/themes/simple/skins/default/ui.css
diff --git a/public/js/tiny_mce/themes/simple/skins/o2k7/content.css b/application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/content.css
similarity index 100%
rename from public/js/tiny_mce/themes/simple/skins/o2k7/content.css
rename to application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/content.css
diff --git a/public/js/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png b/application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png
similarity index 100%
rename from public/js/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png
rename to application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png
diff --git a/public/js/tiny_mce/themes/simple/skins/o2k7/ui.css b/application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/ui.css
similarity index 100%
rename from public/js/tiny_mce/themes/simple/skins/o2k7/ui.css
rename to application/views/assets/js/tiny_mce/themes/simple/skins/o2k7/ui.css
diff --git a/public/js/tiny_mce/tiny_mce.js b/application/views/assets/js/tiny_mce/tiny_mce.js
similarity index 100%
rename from public/js/tiny_mce/tiny_mce.js
rename to application/views/assets/js/tiny_mce/tiny_mce.js
diff --git a/public/js/tiny_mce/tiny_mce_popup.js b/application/views/assets/js/tiny_mce/tiny_mce_popup.js
similarity index 100%
rename from public/js/tiny_mce/tiny_mce_popup.js
rename to application/views/assets/js/tiny_mce/tiny_mce_popup.js
diff --git a/public/js/tiny_mce/tiny_mce_src.js b/application/views/assets/js/tiny_mce/tiny_mce_src.js
similarity index 100%
rename from public/js/tiny_mce/tiny_mce_src.js
rename to application/views/assets/js/tiny_mce/tiny_mce_src.js
diff --git a/public/js/tiny_mce/utils/editable_selects.js b/application/views/assets/js/tiny_mce/utils/editable_selects.js
similarity index 100%
rename from public/js/tiny_mce/utils/editable_selects.js
rename to application/views/assets/js/tiny_mce/utils/editable_selects.js
diff --git a/public/js/tiny_mce/utils/form_utils.js b/application/views/assets/js/tiny_mce/utils/form_utils.js
similarity index 100%
rename from public/js/tiny_mce/utils/form_utils.js
rename to application/views/assets/js/tiny_mce/utils/form_utils.js
diff --git a/public/js/tiny_mce/utils/mctabs.js b/application/views/assets/js/tiny_mce/utils/mctabs.js
similarity index 100%
rename from public/js/tiny_mce/utils/mctabs.js
rename to application/views/assets/js/tiny_mce/utils/mctabs.js
diff --git a/public/js/tiny_mce/utils/validate.js b/application/views/assets/js/tiny_mce/utils/validate.js
similarity index 100%
rename from public/js/tiny_mce/utils/validate.js
rename to application/views/assets/js/tiny_mce/utils/validate.js
diff --git a/public/js/yui-min.js b/application/views/assets/js/yui-min.js
similarity index 100%
rename from public/js/yui-min.js
rename to application/views/assets/js/yui-min.js
diff --git a/application/views/layouts/admin.phtml b/application/views/layouts/admin.phtml
index dbdae7f..528d704 100644
--- a/application/views/layouts/admin.phtml
+++ b/application/views/layouts/admin.phtml
@@ -1,66 +1,65 @@
<?php
/**
* Admin layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<!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">
<head>
<title>Fizzy Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link href="<?= $this->url("/css/admin-screen.css") ?>" rel="stylesheet" type="text/css" media="screen" />
- <link href="<?= $this->url("/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
- <script type="text/javascript" src="<?= $this->url("/js/yui-min.js"); ?>"></script>
+ <link href="<?= $this->url("/admin/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ <script type="text/javascript" src="<?= $this->url("/admin/js/yui-min.js"); ?>"></script>
+ <script type="text/javascript" src="<?= $this->url('/admin/js/tiny_mce/tiny_mce.js'); ?>"></script>
</head>
<body>
-
<div id="header">
<div class="container">
<div id="navigation" class="span-24 last">
<ul>
<li><a href="<?= $this->url("/admin/pages") ?>">Pages</a></li>
<li><a href="<?= $this->url("/admin/media") ?>">Media</a></li>
<!-- not implemented yet
<li><a href="<?= $this->url("/admin/menu") ?>">Menu</a></li>
-->
<li><a href="<?= $this->url("/admin/users") ?>">Users</a></li>
<li><a href="<?= $this->url("/admin/configuration") ?>">Configuration</a></li>
<li class="link-logout"><a href="<?= $this->url("/admin/logout") ?>">Logout</a></li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>
<div class="container">
<div id="content" class="span-24 last content-container">
<div id="content-wrapper">
<?= $this->content ?>
</div>
</div>
<div id="footer" class="span-24 last">
(c) 2009 Voidwalkers - <a href="http://www.voidwalkers.nl/license/new-bsd">license</a>
</div>
</div>
<div class="clear"></div>
</body>
</html>
diff --git a/application/views/layouts/default.phtml b/application/views/layouts/default.phtml
index 00b453a..c84dc45 100644
--- a/application/views/layouts/default.phtml
+++ b/application/views/layouts/default.phtml
@@ -1,67 +1,66 @@
<?php
/**
* Default layout
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<html>
<head>
<?php
$application = Fizzy_Config::getInstance()->getSection(Fizzy_Config::SECTION_APPLICATION);
$title = $application['title'];
?>
<title><?= $title; ?></title>
- <link href="<?= $this->url("/css/default-screen.css") ?>" rel="stylesheet" type="text/css" media="screen" />
<link href="<?= $this->url("/css/default.css") ?>" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div class="container">
<!-- HEADER -->
<div id="header" class="span-24 last">
<h1>Fizzy<span>CMS</span></h1>
</div>
<!-- NAVIGATION -->
<div id="navigation" class="span-24 last">
<ul>
<li><a href="<?= $this->url('/') ?>">Home</a></li>
<li><a href="<?= $this->url('/about'); ?>">About</a></li>
<li><a href="<?= $this->url('/configuration'); ?>">Configuration</a></li>
<li><a href="http://project.voidwalkers.nl/projects/show/fizzy" target="_blanc">More</a></li>
</ul>
</div>
<!-- CONTENT -->
<div id="main-wrapper" class="span-24 last">
<div id="content" class="span-24">
<div class="content-block">
<?= $this->content; ?>
</div>
</div>
</div>
<!-- FOOTER -->
<div id="footer" class="span-24 last">
(c) 2009 <a href="http://www.voidwalkers.nl" title="The Voidwalkers">Voidwalkers</a> - <a href="http://www.voidwalkers.nl/license/bsd-license" title="Fizzy license">license</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
diff --git a/application/views/scripts/admin/page/form.phtml b/application/views/scripts/admin/page/form.phtml
index 5bea1b1..a64dff7 100644
--- a/application/views/scripts/admin/page/form.phtml
+++ b/application/views/scripts/admin/page/form.phtml
@@ -1,130 +1,132 @@
<?php
/**
* Admin page form view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<h1>Page</h1>
<div class="form-container">
<form action="<?= $this->url("/admin/page/$this->action") ?>" method="post" name="PageForm" id="PageForm">
<?php if ($this->action === 'edit'): ?>
<input type="hidden" name="id" value="<?= $this->page->getId() ?>">
<?php endif; ?>
<div class="form-row">
<label for="title">Title</label>
<input type="text" name="title" id="title" value="<?= $this->page->getTitle() ?>" />
</div>
<div class="form-row">
<label for="slug">Slug</label>
<input type="text" name="slug" id="slug" value="<?= $this->page->getSlug() ?>" />
</div>
<div class="form-row yui-skin-sam">
<label for="body">Body</label>
<div>
<textarea name="body" id="body" style="width: 100%;"><?= $this->page->getBody() ?></textarea>
</div>
<div class="clear"></div>
<div style="text-align: right;" id="editor-toggle"></div>
</div>
<?php if(0 < count($this->availableTemplates)) : ?>
<div class="form-row">
<label for="template">Template</label>
<select name="template" id="template">
<option value="null">Default</option>
<?php foreach($this->availableTemplates as $template) : ?>
<option value="<?= $template; ?>" <?= $this->page->getTemplate() === $template ? 'selected="selected"' : '' ?>>
<?= $template; ?>
</option>
<?php endforeach;?>
</select>
</div>
<?php endif;?>
<?php if(0 < count($this->availableLayouts)) : ?>
<div class="form-row">
<label for="template">Layout</label>
<select name="layout" id="layout">
<option value="null">Default</option>
<?php foreach($this->availableLayouts as $template) : ?>
<option value="<?= $template; ?>" <?= $this->page->getLayout() === $template ? 'selected="selected"' : '' ?>>
<?= $template; ?>
</option>
<?php endforeach;?>
</select>
</div>
<?php endif; ?>
<div class="form-row">
<label for="homepage">Homepage?</label>
<input type="checkbox" name="homepage" id="homepage" value="1" <?= $this->page->getHomepage() !== null ? 'checked="checked"' : '' ?> />
</div>
<div class="form-row form-row-last">
<input type="submit" name="PageFormSubmit" id="PageFormSubmit" value="Save" /> or <a href="/admin/pages">cancel</a>
</div>
</form>
</div>
-<script type="text/javascript" src="<?= $this->url('/js/tiny_mce/tiny_mce.js'); ?>"></script>
+
<script type="text/javascript">
YUI().use('node-base', 'event', function(Y) {
var toggleButton;
// init tinyMCE
function init() {
tinyMCE.init({
mode : "exact",
elements: "body",
theme : "advanced",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,separator,forecolor,backcolor,separator,removeformat,undo,redo",
theme_advanced_buttons2 : "bold,italic,underline,sub,sup,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,blockquote,separator,link,unlink,image,separator,charmap,code,cleanup",
theme_advanced_buttons3: "",
- theme_advanced_statusbar_location : "bottom"
+ theme_advanced_statusbar_location : "bottom",
+ theme_advanced_resizing : true,
+ theme_advanced_resize_horizontal : false
});
toggleButton = Y.Node.create('<a href="#" id="toggleButton">hide editor</a>');
toggleButton.on('click', toggleEditor);
Y.Node.one('#editor-toggle').insert(toggleButton);
}
var toggleEditor = function(id) {
tinyMCE.execCommand('mceToggleEditor', false, 'body');
if(tinyMCE.getInstanceById('body').isHidden()) {
toggleButton.setContent('show editor');
}
else {
toggleButton.setContent('hide editor');
}
}
// Wait for DOM to finish
Y.on("domready", init);
});
</script>
diff --git a/application/views/scripts/admin/pages.phtml b/application/views/scripts/admin/pages.phtml
index badfa1b..821fe51 100644
--- a/application/views/scripts/admin/pages.phtml
+++ b/application/views/scripts/admin/pages.phtml
@@ -1,49 +1,49 @@
<?php
/**
* Admin pages view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<h1>Pages</h1>
<div>
<table class="data-table">
<thead>
<tr>
<td>Title</td>
<td>Slug</td>
<td> </td>
</tr>
</thead>
<tbody>
<?php foreach($this->pages as $page) : ?>
<tr>
<td><?= $page->title ?></td>
<td><?= $page->slug ?></td>
<td style="width: 100px;">
- <?= $this->link("/page/{$page->slug}", $this->img('/images/icon/view.png', array('alt' => 'View icon')), array('target' => '_blanc')); ?>
- <?= $this->link("/admin/page/edit/{$page->getId()}", $this->img('/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
- <?= $this->link("/admin/page/delete/{$page->getId()}", $this->img('/images/icon/sign_remove.png', array('alt' => 'remove icon'))); ?>
+ <?= $this->link("/page/{$page->slug}", $this->img('/admin/images/icon/view.png', array('alt' => 'View icon')), array('target' => '_blanc')); ?>
+ <?= $this->link("/admin/page/edit/{$page->getId()}", $this->img('/admin/images/icon/edit.png', array('alt' => 'edit icon'))); ?>
+ <?= $this->link("/admin/page/delete/{$page->getId()}", $this->img('/admin/images/icon/sign_remove.png', array('alt' => 'remove icon'))); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
- <?= $this->link('/admin/page/add', $this->img('/images/icon/add.png', array('alt' => 'add icon')) . ' Add Page'); ?>
+ <?= $this->link('/admin/page/add', $this->img('/admin/images/icon/add.png', array('alt' => 'add icon')) . ' Add Page'); ?>
</p>
</div>
diff --git a/application/views/scripts/login.phtml b/application/views/scripts/login.phtml
index e75343d..181c3b1 100644
--- a/application/views/scripts/login.phtml
+++ b/application/views/scripts/login.phtml
@@ -1,66 +1,65 @@
<?php
/**
* Login view
* @package Fizzy
* @subpackage Views
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
?>
<html>
<head>
<title>Fizzy - Login</title>
- <link href="<?= $this->url("/css/admin-screen.css") ?>" rel="stylesheet" type="text/css" media="screen" />
- <link href="<?= $this->url("/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
+ <link href="<?= $this->url("/admin/css/admin.css") ?>" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div class="span-12 push-10 container last">
<div id="content" class="content-container login-container">
<div id="content-wrapper">
<h1>Fizzy</h1>
<div class="form-container">
<?php if (!empty($this->message)) : ?>
<span class="error"><?= $this->message ?></span>
<?php endif; ?>
<form action="<?= $this->url ?>" method="POST">
<div class="form-row">
<label for="username">username</label>
<input type="text" name="username" />
</div>
<div class="form-row">
<label for="password">password</label>
<input type="password" name="password" />
</div>
<div class="form-row">
<input type="submit" value="Login" />
</div>
</form>
</div>
</div>
</div>
<div id="footer">
Copyright (c) 2009 <a href="http://www.voidwalkers.nl" title="Voidwalkers website">Voidwalkers</a> - <a href="http://www.voidwalkers.nl/license/new-bsd" title="Fizzy license">license</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
diff --git a/configs/routes.xml b/configs/routes.xml
index cc2575b..d8bb194 100644
--- a/configs/routes.xml
+++ b/configs/routes.xml
@@ -1,128 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<fizzy version="0.4">
<routes>
<!--
Pages frontend
-->
<short_slug type="simple">
<rule>/:slug</rule>
<controller>page</controller>
<action>show</action>
</short_slug>
<homepage type="static">
<rule>/</rule>
<controller>page</controller>
<action>homepage</action>
</homepage>
<page_by_slug type="simple">
<rule>page/:slug</rule>
<controller>page</controller>
<action>show</action>
</page_by_slug>
<pages type="static">
<rule>pages</rule>
<controller>page</controller>
<action>list</action>
</pages>
<pages_all type="static">
<rule>pages/all</rule>
<controller>page</controller>
<action>list</action>
</pages_all>
<page_by_id type="regex">
<rule>pages/(\d+)/(\+d)</rule>
<controller>page</controller>
<action>show</action>
<parameters>
<param>id</param>
<param>user</param>
</parameters>
</page_by_id>
<!-- Admin sections -->
<admin type="static">
<rule>/admin</rule>
<controller>Admin</controller>
<action>default</action>
</admin>
<admin_logout type="static">
<rule>/admin/logout</rule>
<controller>Admin</controller>
<action>logout</action>
</admin_logout>
<admin_configuration type="static">
<rule>/admin/configuration</rule>
<controller>Admin</controller>
<action>configuration</action>
</admin_configuration>
+ <admin_assets type="simple">
+ <rule>/admin/:namespace/:asset</rule>
+ <controller>AdminAssets</controller>
+ <action>serve</action>
+ </admin_assets>
<!-- Pages admin section -->
<admin_pages type="static">
<rule>/admin/pages</rule>
<controller>AdminPages</controller>
<action>list</action>
</admin_pages>
<add_page type="static">
<rule>/admin/page/add</rule>
<controller>AdminPages</controller>
<action>add</action>
</add_page>
<admin_page_by_id type="simple">
<rule>/admin/page/edit/:id</rule>
<controller>AdminPages</controller>
<action>edit</action>
</admin_page_by_id>
<admin_delete_page_by_id type="simple">
<rule>/admin/page/delete/:id</rule>
<controller>AdminPages</controller>
<action>delete</action>
</admin_delete_page_by_id>
<!-- Media admin sections -->
<admin_media type="static">
<rule>/admin/media</rule>
<controller>AdminMedia</controller>
<action>default</action>
</admin_media>
<admin_media_upload type="static">
<rule>/admin/media/upload</rule>
<controller>AdminMedia</controller>
<action>upload</action>
</admin_media_upload>
<admin_media_delete type="simple">
<rule>/admin/media/delete/:name</rule>
<controller>AdminMedia</controller>
<action>delete</action>
</admin_media_delete>
<!-- Menu admin sections -->
<admin_menu type="static">
<rule>/admin/menu</rule>
<controller>AdminMenu</controller>
<action>show</action>
</admin_menu>
<!-- Users admin section -->
<admin_users type="static">
<rule>admin/users</rule>
<controller>AdminUsers</controller>
<action>list</action>
</admin_users>
<admin_add_user type="static">
<rule>admin/user/add</rule>
<controller>AdminUsers</controller>
<action>add</action>
</admin_add_user>
<admin_edit_user type="simple">
<rule>admin/user/edit/:id</rule>
<controller>AdminUsers</controller>
<action>edit</action>
</admin_edit_user>
<admin_delete_user type="simple">
<rule>/admin/user/delete/:id</rule>
<controller>AdminUsers</controller>
<action>delete</action>
</admin_delete_user>
</routes>
</fizzy>
diff --git a/public/css/default.css b/public/css/default.css
index d9891e9..cf46073 100644
--- a/public/css/default.css
+++ b/public/css/default.css
@@ -1,144 +1,146 @@
+@import 'screen.css';
+
body {
margin: 0;
padding: 0;
background: #e2e6e9;
font-family: Verdana, Arial, Sans-Serif;
}
a:link {
color: #273A4D;
text-decoration: none;
}
a:visited {
color: #273A4D;
text-decoration: none;
}
a:hover, a:active {
color: #ffffff;
background-color: #343838;
}
h1, h2, h3, h4, h5, h6 {
font-weight: normal;
margin: 1em 0;
padding: 0;
}
h1 { font-size: 200%; color: #293138;}
h2 { font-size: 150%; color: #353F47;}
h3 { font-size: 125%; color: #3f4f5c;}
h4 { font-size: 115%; color: #3f4f5c; }
h5 { font-size: 110%; color: #3f4f5c;}
h6 {
font-size: 100%;
text-transform: uppercase;
margin: 5px 0;
font-weight: bold;
}
/* HEADER */
#header {
}
#header h1 {
color: #191a1a;
font-weight: bold;
margin-bottom: 0.5em;
}
#header h1 a {
width:750px;
height: 200px;
background: transparent;
}
#header h1 a:link,
#header h1 a:visited {
color: #333333;
}
#header h1 a:hover,
#header h1 a:active {
color: #000000;
background-color: transparent;
}
#header h1 span {color:#5b5c5c;}
/* NAVIGATION */
#navigation {
background-color: #282d2d;
text-transform: uppercase;
font-size: 110%;
}
#navigation ul {
margin: 0 5px;
padding: 0px 0;
list-style-type: none;
}
#navigation li {
float: left;
margin: 0 0 0 5px;
padding: 0;
}
#navigation a:link,
#navigation a:visited {
float: left;
display: block;
color: #c6c6c6;
padding: 0.5em 1em;
}
#navigation ul li.current_page_item a:link,
#navigation ul li.current_page_item a:visited,
#navigation ul li.current_page_item a:hover,
#navigation ul li.current_page_item a:active {
color: #ffffff;
background-color: #414646;
border-left: solid #6b7070 1px;
border-right: solid #6b7070 1px;
}
/* CONTENT */
#main-wrapper {
background-color: #FFFFFF;
}
/* content */
#content {}
.content-block {
margin: 1em 1.5em;
}
/* sidebar */
#sidebar {}
.sidebar-block {
margin: 2em 1em;
}
.sidebar-block h3 {
color:#5b5c5c;
text-transform: uppercase;
border-bottom: solid #5b5c5c 2px;
padding-bottom: 0.3em;
margin: 0;
}
.sidebar-block-content {
background-color: #F3F2F2;
border: solid #E6E4E4 1px;
padding: 0.5em;
}
/* FOOTER */
#footer {
color: #555555;
text-align: center;
padding: 1em 0;
background: #cfcfcf;
}
\ No newline at end of file
diff --git a/public/css/default-screen.css b/public/css/screen.css
similarity index 100%
rename from public/css/default-screen.css
rename to public/css/screen.css
diff --git a/public/images/icon/alarm.png b/public/images/icon/alarm.png
deleted file mode 100644
index f5069d6..0000000
Binary files a/public/images/icon/alarm.png and /dev/null differ
diff --git a/public/images/icon/anchor.png b/public/images/icon/anchor.png
deleted file mode 100644
index 7896268..0000000
Binary files a/public/images/icon/anchor.png and /dev/null differ
diff --git a/public/images/icon/application.png b/public/images/icon/application.png
deleted file mode 100644
index 38ee47d..0000000
Binary files a/public/images/icon/application.png and /dev/null differ
diff --git a/public/images/icon/application2.png b/public/images/icon/application2.png
deleted file mode 100644
index ac7ab16..0000000
Binary files a/public/images/icon/application2.png and /dev/null differ
diff --git a/public/images/icon/application_add.png b/public/images/icon/application_add.png
deleted file mode 100644
index 79891cd..0000000
Binary files a/public/images/icon/application_add.png and /dev/null differ
diff --git a/public/images/icon/application_cascade.png b/public/images/icon/application_cascade.png
deleted file mode 100644
index 18946e7..0000000
Binary files a/public/images/icon/application_cascade.png and /dev/null differ
diff --git a/public/images/icon/application_delete.png b/public/images/icon/application_delete.png
deleted file mode 100644
index d73ed7f..0000000
Binary files a/public/images/icon/application_delete.png and /dev/null differ
diff --git a/public/images/icon/application_double.png b/public/images/icon/application_double.png
deleted file mode 100644
index ab5d5e0..0000000
Binary files a/public/images/icon/application_double.png and /dev/null differ
diff --git a/public/images/icon/application_edit.png b/public/images/icon/application_edit.png
deleted file mode 100644
index e30c60f..0000000
Binary files a/public/images/icon/application_edit.png and /dev/null differ
diff --git a/public/images/icon/application_error.png b/public/images/icon/application_error.png
deleted file mode 100644
index c55ee1c..0000000
Binary files a/public/images/icon/application_error.png and /dev/null differ
diff --git a/public/images/icon/application_form.png b/public/images/icon/application_form.png
deleted file mode 100644
index cbeff70..0000000
Binary files a/public/images/icon/application_form.png and /dev/null differ
diff --git a/public/images/icon/application_get.png b/public/images/icon/application_get.png
deleted file mode 100644
index 94e9b85..0000000
Binary files a/public/images/icon/application_get.png and /dev/null differ
diff --git a/public/images/icon/application_go.png b/public/images/icon/application_go.png
deleted file mode 100644
index 0d154d5..0000000
Binary files a/public/images/icon/application_go.png and /dev/null differ
diff --git a/public/images/icon/application_home.png b/public/images/icon/application_home.png
deleted file mode 100644
index 613ddf6..0000000
Binary files a/public/images/icon/application_home.png and /dev/null differ
diff --git a/public/images/icon/application_key.png b/public/images/icon/application_key.png
deleted file mode 100644
index bc365c1..0000000
Binary files a/public/images/icon/application_key.png and /dev/null differ
diff --git a/public/images/icon/application_lightning.png b/public/images/icon/application_lightning.png
deleted file mode 100644
index 3f51846..0000000
Binary files a/public/images/icon/application_lightning.png and /dev/null differ
diff --git a/public/images/icon/application_link.png b/public/images/icon/application_link.png
deleted file mode 100644
index d009760..0000000
Binary files a/public/images/icon/application_link.png and /dev/null differ
diff --git a/public/images/icon/application_osx.png b/public/images/icon/application_osx.png
deleted file mode 100644
index 76abbf9..0000000
Binary files a/public/images/icon/application_osx.png and /dev/null differ
diff --git a/public/images/icon/application_osx_terminal.png b/public/images/icon/application_osx_terminal.png
deleted file mode 100644
index 07ee877..0000000
Binary files a/public/images/icon/application_osx_terminal.png and /dev/null differ
diff --git a/public/images/icon/application_put.png b/public/images/icon/application_put.png
deleted file mode 100644
index 77b6dcd..0000000
Binary files a/public/images/icon/application_put.png and /dev/null differ
diff --git a/public/images/icon/application_side_boxes.png b/public/images/icon/application_side_boxes.png
deleted file mode 100644
index 16db7e5..0000000
Binary files a/public/images/icon/application_side_boxes.png and /dev/null differ
diff --git a/public/images/icon/application_side_contract.png b/public/images/icon/application_side_contract.png
deleted file mode 100644
index 8d34e24..0000000
Binary files a/public/images/icon/application_side_contract.png and /dev/null differ
diff --git a/public/images/icon/application_side_expand.png b/public/images/icon/application_side_expand.png
deleted file mode 100644
index 0c47966..0000000
Binary files a/public/images/icon/application_side_expand.png and /dev/null differ
diff --git a/public/images/icon/application_side_list.png b/public/images/icon/application_side_list.png
deleted file mode 100644
index e3a1361..0000000
Binary files a/public/images/icon/application_side_list.png and /dev/null differ
diff --git a/public/images/icon/application_side_tree.png b/public/images/icon/application_side_tree.png
deleted file mode 100644
index 9378342..0000000
Binary files a/public/images/icon/application_side_tree.png and /dev/null differ
diff --git a/public/images/icon/application_split.png b/public/images/icon/application_split.png
deleted file mode 100644
index 378290d..0000000
Binary files a/public/images/icon/application_split.png and /dev/null differ
diff --git a/public/images/icon/application_tile_horizontal.png b/public/images/icon/application_tile_horizontal.png
deleted file mode 100644
index ce5e1fe..0000000
Binary files a/public/images/icon/application_tile_horizontal.png and /dev/null differ
diff --git a/public/images/icon/application_tile_vertical.png b/public/images/icon/application_tile_vertical.png
deleted file mode 100644
index baf5275..0000000
Binary files a/public/images/icon/application_tile_vertical.png and /dev/null differ
diff --git a/public/images/icon/application_view_columns.png b/public/images/icon/application_view_columns.png
deleted file mode 100644
index ee42c97..0000000
Binary files a/public/images/icon/application_view_columns.png and /dev/null differ
diff --git a/public/images/icon/application_view_detail.png b/public/images/icon/application_view_detail.png
deleted file mode 100644
index e996302..0000000
Binary files a/public/images/icon/application_view_detail.png and /dev/null differ
diff --git a/public/images/icon/application_view_gallery.png b/public/images/icon/application_view_gallery.png
deleted file mode 100644
index 2af5c03..0000000
Binary files a/public/images/icon/application_view_gallery.png and /dev/null differ
diff --git a/public/images/icon/application_view_icons.png b/public/images/icon/application_view_icons.png
deleted file mode 100644
index aee6d7c..0000000
Binary files a/public/images/icon/application_view_icons.png and /dev/null differ
diff --git a/public/images/icon/application_view_list.png b/public/images/icon/application_view_list.png
deleted file mode 100644
index 065ec0c..0000000
Binary files a/public/images/icon/application_view_list.png and /dev/null differ
diff --git a/public/images/icon/application_view_tile.png b/public/images/icon/application_view_tile.png
deleted file mode 100644
index 257055a..0000000
Binary files a/public/images/icon/application_view_tile.png and /dev/null differ
diff --git a/public/images/icon/application_view_xp.png b/public/images/icon/application_view_xp.png
deleted file mode 100644
index 038292d..0000000
Binary files a/public/images/icon/application_view_xp.png and /dev/null differ
diff --git a/public/images/icon/application_view_xp_terminal.png b/public/images/icon/application_view_xp_terminal.png
deleted file mode 100644
index 4efd07a..0000000
Binary files a/public/images/icon/application_view_xp_terminal.png and /dev/null differ
diff --git a/public/images/icon/arrow_branch.png b/public/images/icon/arrow_branch.png
deleted file mode 100644
index 2d7ae63..0000000
Binary files a/public/images/icon/arrow_branch.png and /dev/null differ
diff --git a/public/images/icon/arrow_divide.png b/public/images/icon/arrow_divide.png
deleted file mode 100644
index d9f5c1e..0000000
Binary files a/public/images/icon/arrow_divide.png and /dev/null differ
diff --git a/public/images/icon/arrow_in.png b/public/images/icon/arrow_in.png
deleted file mode 100644
index f774b67..0000000
Binary files a/public/images/icon/arrow_in.png and /dev/null differ
diff --git a/public/images/icon/arrow_inout.png b/public/images/icon/arrow_inout.png
deleted file mode 100644
index 091a63a..0000000
Binary files a/public/images/icon/arrow_inout.png and /dev/null differ
diff --git a/public/images/icon/arrow_join.png b/public/images/icon/arrow_join.png
deleted file mode 100644
index e8aec7c..0000000
Binary files a/public/images/icon/arrow_join.png and /dev/null differ
diff --git a/public/images/icon/arrow_left.png b/public/images/icon/arrow_left.png
deleted file mode 100644
index b44e93a..0000000
Binary files a/public/images/icon/arrow_left.png and /dev/null differ
diff --git a/public/images/icon/arrow_merge.png b/public/images/icon/arrow_merge.png
deleted file mode 100644
index 5fdad32..0000000
Binary files a/public/images/icon/arrow_merge.png and /dev/null differ
diff --git a/public/images/icon/arrow_out.png b/public/images/icon/arrow_out.png
deleted file mode 100644
index bc30caa..0000000
Binary files a/public/images/icon/arrow_out.png and /dev/null differ
diff --git a/public/images/icon/arrow_redo.png b/public/images/icon/arrow_redo.png
deleted file mode 100644
index 364ef1a..0000000
Binary files a/public/images/icon/arrow_redo.png and /dev/null differ
diff --git a/public/images/icon/arrow_refresh.png b/public/images/icon/arrow_refresh.png
deleted file mode 100644
index 9af2755..0000000
Binary files a/public/images/icon/arrow_refresh.png and /dev/null differ
diff --git a/public/images/icon/arrow_right.png b/public/images/icon/arrow_right.png
deleted file mode 100644
index d690cb6..0000000
Binary files a/public/images/icon/arrow_right.png and /dev/null differ
diff --git a/public/images/icon/arrow_undo.png b/public/images/icon/arrow_undo.png
deleted file mode 100644
index 0444265..0000000
Binary files a/public/images/icon/arrow_undo.png and /dev/null differ
diff --git a/public/images/icon/asterisk_orange.png b/public/images/icon/asterisk_orange.png
deleted file mode 100644
index c2b31c2..0000000
Binary files a/public/images/icon/asterisk_orange.png and /dev/null differ
diff --git a/public/images/icon/attach.png b/public/images/icon/attach.png
deleted file mode 100644
index 4ccebe7..0000000
Binary files a/public/images/icon/attach.png and /dev/null differ
diff --git a/public/images/icon/attach_2.png b/public/images/icon/attach_2.png
deleted file mode 100644
index c4156af..0000000
Binary files a/public/images/icon/attach_2.png and /dev/null differ
diff --git a/public/images/icon/award_star_gold.png b/public/images/icon/award_star_gold.png
deleted file mode 100644
index 4a20e07..0000000
Binary files a/public/images/icon/award_star_gold.png and /dev/null differ
diff --git a/public/images/icon/bandaid.png b/public/images/icon/bandaid.png
deleted file mode 100644
index db53007..0000000
Binary files a/public/images/icon/bandaid.png and /dev/null differ
diff --git a/public/images/icon/basket.png b/public/images/icon/basket.png
deleted file mode 100644
index c152b5c..0000000
Binary files a/public/images/icon/basket.png and /dev/null differ
diff --git a/public/images/icon/bell.png b/public/images/icon/bell.png
deleted file mode 100644
index 0363d6d..0000000
Binary files a/public/images/icon/bell.png and /dev/null differ
diff --git a/public/images/icon/bin_closed.png b/public/images/icon/bin_closed.png
deleted file mode 100644
index cdf2054..0000000
Binary files a/public/images/icon/bin_closed.png and /dev/null differ
diff --git a/public/images/icon/blog.png b/public/images/icon/blog.png
deleted file mode 100644
index 7ca718e..0000000
Binary files a/public/images/icon/blog.png and /dev/null differ
diff --git a/public/images/icon/blueprint.png b/public/images/icon/blueprint.png
deleted file mode 100644
index af93551..0000000
Binary files a/public/images/icon/blueprint.png and /dev/null differ
diff --git a/public/images/icon/blueprint_horizontal.png b/public/images/icon/blueprint_horizontal.png
deleted file mode 100644
index 0e47cfc..0000000
Binary files a/public/images/icon/blueprint_horizontal.png and /dev/null differ
diff --git a/public/images/icon/bluetooth.png b/public/images/icon/bluetooth.png
deleted file mode 100644
index 7d57665..0000000
Binary files a/public/images/icon/bluetooth.png and /dev/null differ
diff --git a/public/images/icon/bomb.png b/public/images/icon/bomb.png
deleted file mode 100644
index b776f98..0000000
Binary files a/public/images/icon/bomb.png and /dev/null differ
diff --git a/public/images/icon/book.png b/public/images/icon/book.png
deleted file mode 100644
index 5c9efdc..0000000
Binary files a/public/images/icon/book.png and /dev/null differ
diff --git a/public/images/icon/book_addresses.png b/public/images/icon/book_addresses.png
deleted file mode 100644
index 5f830cf..0000000
Binary files a/public/images/icon/book_addresses.png and /dev/null differ
diff --git a/public/images/icon/book_next.png b/public/images/icon/book_next.png
deleted file mode 100644
index 08456c7..0000000
Binary files a/public/images/icon/book_next.png and /dev/null differ
diff --git a/public/images/icon/book_open.png b/public/images/icon/book_open.png
deleted file mode 100644
index c982859..0000000
Binary files a/public/images/icon/book_open.png and /dev/null differ
diff --git a/public/images/icon/book_previous.png b/public/images/icon/book_previous.png
deleted file mode 100644
index b88c57f..0000000
Binary files a/public/images/icon/book_previous.png and /dev/null differ
diff --git a/public/images/icon/bookmark.png b/public/images/icon/bookmark.png
deleted file mode 100644
index f0f0ad5..0000000
Binary files a/public/images/icon/bookmark.png and /dev/null differ
diff --git a/public/images/icon/bookmark_book.png b/public/images/icon/bookmark_book.png
deleted file mode 100644
index c3cbf93..0000000
Binary files a/public/images/icon/bookmark_book.png and /dev/null differ
diff --git a/public/images/icon/bookmark_book_open.png b/public/images/icon/bookmark_book_open.png
deleted file mode 100644
index a942cf7..0000000
Binary files a/public/images/icon/bookmark_book_open.png and /dev/null differ
diff --git a/public/images/icon/bookmark_document.png b/public/images/icon/bookmark_document.png
deleted file mode 100644
index 47585a4..0000000
Binary files a/public/images/icon/bookmark_document.png and /dev/null differ
diff --git a/public/images/icon/bookmark_folder.png b/public/images/icon/bookmark_folder.png
deleted file mode 100644
index c147c85..0000000
Binary files a/public/images/icon/bookmark_folder.png and /dev/null differ
diff --git a/public/images/icon/books.png b/public/images/icon/books.png
deleted file mode 100644
index 937ea14..0000000
Binary files a/public/images/icon/books.png and /dev/null differ
diff --git a/public/images/icon/box.png b/public/images/icon/box.png
deleted file mode 100644
index 08c6f6f..0000000
Binary files a/public/images/icon/box.png and /dev/null differ
diff --git a/public/images/icon/brick.png b/public/images/icon/brick.png
deleted file mode 100644
index 67244e1..0000000
Binary files a/public/images/icon/brick.png and /dev/null differ
diff --git a/public/images/icon/bricks.png b/public/images/icon/bricks.png
deleted file mode 100644
index 4eff81b..0000000
Binary files a/public/images/icon/bricks.png and /dev/null differ
diff --git a/public/images/icon/briefcase.png b/public/images/icon/briefcase.png
deleted file mode 100644
index cffe6d8..0000000
Binary files a/public/images/icon/briefcase.png and /dev/null differ
diff --git a/public/images/icon/bug.png b/public/images/icon/bug.png
deleted file mode 100644
index 97e348c..0000000
Binary files a/public/images/icon/bug.png and /dev/null differ
diff --git a/public/images/icon/buildings.png b/public/images/icon/buildings.png
deleted file mode 100644
index 2ae4636..0000000
Binary files a/public/images/icon/buildings.png and /dev/null differ
diff --git a/public/images/icon/bullet_add_1.png b/public/images/icon/bullet_add_1.png
deleted file mode 100644
index 59de162..0000000
Binary files a/public/images/icon/bullet_add_1.png and /dev/null differ
diff --git a/public/images/icon/bullet_add_2.png b/public/images/icon/bullet_add_2.png
deleted file mode 100644
index 263a711..0000000
Binary files a/public/images/icon/bullet_add_2.png and /dev/null differ
diff --git a/public/images/icon/bullet_key.png b/public/images/icon/bullet_key.png
deleted file mode 100644
index f048df6..0000000
Binary files a/public/images/icon/bullet_key.png and /dev/null differ
diff --git a/public/images/icon/cake.png b/public/images/icon/cake.png
deleted file mode 100644
index 57d1084..0000000
Binary files a/public/images/icon/cake.png and /dev/null differ
diff --git a/public/images/icon/calculator.png b/public/images/icon/calculator.png
deleted file mode 100644
index 90f10d9..0000000
Binary files a/public/images/icon/calculator.png and /dev/null differ
diff --git a/public/images/icon/calendar_1.png b/public/images/icon/calendar_1.png
deleted file mode 100644
index 5fc6ed7..0000000
Binary files a/public/images/icon/calendar_1.png and /dev/null differ
diff --git a/public/images/icon/calendar_2.png b/public/images/icon/calendar_2.png
deleted file mode 100644
index 7acf778..0000000
Binary files a/public/images/icon/calendar_2.png and /dev/null differ
diff --git a/public/images/icon/camera.png b/public/images/icon/camera.png
deleted file mode 100644
index d47499a..0000000
Binary files a/public/images/icon/camera.png and /dev/null differ
diff --git a/public/images/icon/cancel.png b/public/images/icon/cancel.png
deleted file mode 100644
index 7640cd5..0000000
Binary files a/public/images/icon/cancel.png and /dev/null differ
diff --git a/public/images/icon/car.png b/public/images/icon/car.png
deleted file mode 100644
index 1a0e1d9..0000000
Binary files a/public/images/icon/car.png and /dev/null differ
diff --git a/public/images/icon/cart.png b/public/images/icon/cart.png
deleted file mode 100644
index b7f73bf..0000000
Binary files a/public/images/icon/cart.png and /dev/null differ
diff --git a/public/images/icon/cd.png b/public/images/icon/cd.png
deleted file mode 100644
index a6e6f00..0000000
Binary files a/public/images/icon/cd.png and /dev/null differ
diff --git a/public/images/icon/chart_bar.png b/public/images/icon/chart_bar.png
deleted file mode 100644
index 2cec9fd..0000000
Binary files a/public/images/icon/chart_bar.png and /dev/null differ
diff --git a/public/images/icon/chart_curve.png b/public/images/icon/chart_curve.png
deleted file mode 100644
index f8642be..0000000
Binary files a/public/images/icon/chart_curve.png and /dev/null differ
diff --git a/public/images/icon/chart_line.png b/public/images/icon/chart_line.png
deleted file mode 100644
index cd273e8..0000000
Binary files a/public/images/icon/chart_line.png and /dev/null differ
diff --git a/public/images/icon/chart_organisation.png b/public/images/icon/chart_organisation.png
deleted file mode 100644
index bdd84a7..0000000
Binary files a/public/images/icon/chart_organisation.png and /dev/null differ
diff --git a/public/images/icon/chart_pie.png b/public/images/icon/chart_pie.png
deleted file mode 100644
index 1f898bd..0000000
Binary files a/public/images/icon/chart_pie.png and /dev/null differ
diff --git a/public/images/icon/clipboard_paste_image.png b/public/images/icon/clipboard_paste_image.png
deleted file mode 100644
index 10ea5f8..0000000
Binary files a/public/images/icon/clipboard_paste_image.png and /dev/null differ
diff --git a/public/images/icon/clipboard_sign.png b/public/images/icon/clipboard_sign.png
deleted file mode 100644
index 2a1dbc4..0000000
Binary files a/public/images/icon/clipboard_sign.png and /dev/null differ
diff --git a/public/images/icon/clipboard_text.png b/public/images/icon/clipboard_text.png
deleted file mode 100644
index 0c895d8..0000000
Binary files a/public/images/icon/clipboard_text.png and /dev/null differ
diff --git a/public/images/icon/clock.png b/public/images/icon/clock.png
deleted file mode 100644
index 0d2cab1..0000000
Binary files a/public/images/icon/clock.png and /dev/null differ
diff --git a/public/images/icon/cog.png b/public/images/icon/cog.png
deleted file mode 100644
index aa65d2f..0000000
Binary files a/public/images/icon/cog.png and /dev/null differ
diff --git a/public/images/icon/coins.png b/public/images/icon/coins.png
deleted file mode 100644
index 84b94dc..0000000
Binary files a/public/images/icon/coins.png and /dev/null differ
diff --git a/public/images/icon/color_swatch_1.png b/public/images/icon/color_swatch_1.png
deleted file mode 100644
index 28126ef..0000000
Binary files a/public/images/icon/color_swatch_1.png and /dev/null differ
diff --git a/public/images/icon/color_swatch_2.png b/public/images/icon/color_swatch_2.png
deleted file mode 100644
index 6655991..0000000
Binary files a/public/images/icon/color_swatch_2.png and /dev/null differ
diff --git a/public/images/icon/comment.png b/public/images/icon/comment.png
deleted file mode 100644
index 296b830..0000000
Binary files a/public/images/icon/comment.png and /dev/null differ
diff --git a/public/images/icon/compass.png b/public/images/icon/compass.png
deleted file mode 100644
index e963868..0000000
Binary files a/public/images/icon/compass.png and /dev/null differ
diff --git a/public/images/icon/compress.png b/public/images/icon/compress.png
deleted file mode 100644
index e606b6d..0000000
Binary files a/public/images/icon/compress.png and /dev/null differ
diff --git a/public/images/icon/computer.png b/public/images/icon/computer.png
deleted file mode 100644
index 2833558..0000000
Binary files a/public/images/icon/computer.png and /dev/null differ
diff --git a/public/images/icon/connect.png b/public/images/icon/connect.png
deleted file mode 100644
index 632f852..0000000
Binary files a/public/images/icon/connect.png and /dev/null differ
diff --git a/public/images/icon/content.png b/public/images/icon/content.png
deleted file mode 120000
index 3ef634f..0000000
--- a/public/images/icon/content.png
+++ /dev/null
@@ -1 +0,0 @@
-blueprint.png
\ No newline at end of file
diff --git a/public/images/icon/contractor.png b/public/images/icon/contractor.png
deleted file mode 100644
index 0ac1ddb..0000000
Binary files a/public/images/icon/contractor.png and /dev/null differ
diff --git a/public/images/icon/contrast.png b/public/images/icon/contrast.png
deleted file mode 100644
index 4ad7f1f..0000000
Binary files a/public/images/icon/contrast.png and /dev/null differ
diff --git a/public/images/icon/control_eject.png b/public/images/icon/control_eject.png
deleted file mode 100644
index fcc53ff..0000000
Binary files a/public/images/icon/control_eject.png and /dev/null differ
diff --git a/public/images/icon/control_end.png b/public/images/icon/control_end.png
deleted file mode 100644
index ccba53f..0000000
Binary files a/public/images/icon/control_end.png and /dev/null differ
diff --git a/public/images/icon/control_equalizer.png b/public/images/icon/control_equalizer.png
deleted file mode 100644
index 9d776e3..0000000
Binary files a/public/images/icon/control_equalizer.png and /dev/null differ
diff --git a/public/images/icon/control_fastforward.png b/public/images/icon/control_fastforward.png
deleted file mode 100644
index 3d6b1ce..0000000
Binary files a/public/images/icon/control_fastforward.png and /dev/null differ
diff --git a/public/images/icon/control_pause.png b/public/images/icon/control_pause.png
deleted file mode 100644
index d021703..0000000
Binary files a/public/images/icon/control_pause.png and /dev/null differ
diff --git a/public/images/icon/control_play.png b/public/images/icon/control_play.png
deleted file mode 100644
index bf042bc..0000000
Binary files a/public/images/icon/control_play.png and /dev/null differ
diff --git a/public/images/icon/control_repeat.png b/public/images/icon/control_repeat.png
deleted file mode 100644
index 634a48a..0000000
Binary files a/public/images/icon/control_repeat.png and /dev/null differ
diff --git a/public/images/icon/control_rewind.png b/public/images/icon/control_rewind.png
deleted file mode 100644
index 8707d39..0000000
Binary files a/public/images/icon/control_rewind.png and /dev/null differ
diff --git a/public/images/icon/control_start.png b/public/images/icon/control_start.png
deleted file mode 100644
index bfe43ce..0000000
Binary files a/public/images/icon/control_start.png and /dev/null differ
diff --git a/public/images/icon/control_stop.png b/public/images/icon/control_stop.png
deleted file mode 100644
index 20509ba..0000000
Binary files a/public/images/icon/control_stop.png and /dev/null differ
diff --git a/public/images/icon/control_wheel.png b/public/images/icon/control_wheel.png
deleted file mode 100644
index 1283e02..0000000
Binary files a/public/images/icon/control_wheel.png and /dev/null differ
diff --git a/public/images/icon/counter.png b/public/images/icon/counter.png
deleted file mode 100644
index cecc175..0000000
Binary files a/public/images/icon/counter.png and /dev/null differ
diff --git a/public/images/icon/counter_count.png b/public/images/icon/counter_count.png
deleted file mode 100644
index 0b63d70..0000000
Binary files a/public/images/icon/counter_count.png and /dev/null differ
diff --git a/public/images/icon/counter_count_up.png b/public/images/icon/counter_count_up.png
deleted file mode 100644
index 3ca8136..0000000
Binary files a/public/images/icon/counter_count_up.png and /dev/null differ
diff --git a/public/images/icon/counter_reset.png b/public/images/icon/counter_reset.png
deleted file mode 100644
index 65d6283..0000000
Binary files a/public/images/icon/counter_reset.png and /dev/null differ
diff --git a/public/images/icon/counter_stop.png b/public/images/icon/counter_stop.png
deleted file mode 100644
index a9b0c86..0000000
Binary files a/public/images/icon/counter_stop.png and /dev/null differ
diff --git a/public/images/icon/cross_octagon_fram.png b/public/images/icon/cross_octagon_fram.png
deleted file mode 100644
index 0311347..0000000
Binary files a/public/images/icon/cross_octagon_fram.png and /dev/null differ
diff --git a/public/images/icon/cross_shield.png b/public/images/icon/cross_shield.png
deleted file mode 100644
index aa3e91e..0000000
Binary files a/public/images/icon/cross_shield.png and /dev/null differ
diff --git a/public/images/icon/cross_shield_2.png b/public/images/icon/cross_shield_2.png
deleted file mode 100644
index ea95d91..0000000
Binary files a/public/images/icon/cross_shield_2.png and /dev/null differ
diff --git a/public/images/icon/crown.png b/public/images/icon/crown.png
deleted file mode 100644
index 4e33059..0000000
Binary files a/public/images/icon/crown.png and /dev/null differ
diff --git a/public/images/icon/crown_bronze.png b/public/images/icon/crown_bronze.png
deleted file mode 100644
index f4433ea..0000000
Binary files a/public/images/icon/crown_bronze.png and /dev/null differ
diff --git a/public/images/icon/crown_silver.png b/public/images/icon/crown_silver.png
deleted file mode 100644
index 9916fbd..0000000
Binary files a/public/images/icon/crown_silver.png and /dev/null differ
diff --git a/public/images/icon/css.png b/public/images/icon/css.png
deleted file mode 100644
index 2f89269..0000000
Binary files a/public/images/icon/css.png and /dev/null differ
diff --git a/public/images/icon/cursor.png b/public/images/icon/cursor.png
deleted file mode 100644
index 2556b2f..0000000
Binary files a/public/images/icon/cursor.png and /dev/null differ
diff --git a/public/images/icon/cut.png b/public/images/icon/cut.png
deleted file mode 100644
index 8dda4d5..0000000
Binary files a/public/images/icon/cut.png and /dev/null differ
diff --git a/public/images/icon/dashboard.png b/public/images/icon/dashboard.png
deleted file mode 100644
index d48144d..0000000
Binary files a/public/images/icon/dashboard.png and /dev/null differ
diff --git a/public/images/icon/data.png b/public/images/icon/data.png
deleted file mode 100644
index 2cc81ca..0000000
Binary files a/public/images/icon/data.png and /dev/null differ
diff --git a/public/images/icon/database.png b/public/images/icon/database.png
deleted file mode 100644
index a1d556d..0000000
Binary files a/public/images/icon/database.png and /dev/null differ
diff --git a/public/images/icon/databases.png b/public/images/icon/databases.png
deleted file mode 100644
index bbee967..0000000
Binary files a/public/images/icon/databases.png and /dev/null differ
diff --git a/public/images/icon/delivery.png b/public/images/icon/delivery.png
deleted file mode 100644
index 07e238f..0000000
Binary files a/public/images/icon/delivery.png and /dev/null differ
diff --git a/public/images/icon/desktop.png b/public/images/icon/desktop.png
deleted file mode 100644
index c2e6319..0000000
Binary files a/public/images/icon/desktop.png and /dev/null differ
diff --git a/public/images/icon/desktop_empty.png b/public/images/icon/desktop_empty.png
deleted file mode 100644
index e2c2188..0000000
Binary files a/public/images/icon/desktop_empty.png and /dev/null differ
diff --git a/public/images/icon/direction.png b/public/images/icon/direction.png
deleted file mode 100644
index a01513d..0000000
Binary files a/public/images/icon/direction.png and /dev/null differ
diff --git a/public/images/icon/disconnect.png b/public/images/icon/disconnect.png
deleted file mode 100644
index ac1a557..0000000
Binary files a/public/images/icon/disconnect.png and /dev/null differ
diff --git a/public/images/icon/doc_break.png b/public/images/icon/doc_break.png
deleted file mode 100644
index 35b9fcd..0000000
Binary files a/public/images/icon/doc_break.png and /dev/null differ
diff --git a/public/images/icon/doc_convert.png b/public/images/icon/doc_convert.png
deleted file mode 100644
index 5043147..0000000
Binary files a/public/images/icon/doc_convert.png and /dev/null differ
diff --git a/public/images/icon/doc_music_playlist.png b/public/images/icon/doc_music_playlist.png
deleted file mode 100644
index 7a3fd7e..0000000
Binary files a/public/images/icon/doc_music_playlist.png and /dev/null differ
diff --git a/public/images/icon/doc_offlice.png b/public/images/icon/doc_offlice.png
deleted file mode 100644
index b484f9a..0000000
Binary files a/public/images/icon/doc_offlice.png and /dev/null differ
diff --git a/public/images/icon/doc_page.png b/public/images/icon/doc_page.png
deleted file mode 100644
index ee70bc0..0000000
Binary files a/public/images/icon/doc_page.png and /dev/null differ
diff --git a/public/images/icon/doc_page_previous.png b/public/images/icon/doc_page_previous.png
deleted file mode 100644
index a15c2d6..0000000
Binary files a/public/images/icon/doc_page_previous.png and /dev/null differ
diff --git a/public/images/icon/doc_resize.png b/public/images/icon/doc_resize.png
deleted file mode 100644
index db8645e..0000000
Binary files a/public/images/icon/doc_resize.png and /dev/null differ
diff --git a/public/images/icon/doc_resize_actual.png b/public/images/icon/doc_resize_actual.png
deleted file mode 100644
index 6d17bf2..0000000
Binary files a/public/images/icon/doc_resize_actual.png and /dev/null differ
diff --git a/public/images/icon/doc_shred.png b/public/images/icon/doc_shred.png
deleted file mode 100644
index 7c290ac..0000000
Binary files a/public/images/icon/doc_shred.png and /dev/null differ
diff --git a/public/images/icon/doc_stand.png b/public/images/icon/doc_stand.png
deleted file mode 100644
index 646985c..0000000
Binary files a/public/images/icon/doc_stand.png and /dev/null differ
diff --git a/public/images/icon/doc_table.png b/public/images/icon/doc_table.png
deleted file mode 100644
index 0ae672b..0000000
Binary files a/public/images/icon/doc_table.png and /dev/null differ
diff --git a/public/images/icon/doc_tag.png b/public/images/icon/doc_tag.png
deleted file mode 100644
index 858525e..0000000
Binary files a/public/images/icon/doc_tag.png and /dev/null differ
diff --git a/public/images/icon/doc_text_image.png b/public/images/icon/doc_text_image.png
deleted file mode 100644
index b8f2788..0000000
Binary files a/public/images/icon/doc_text_image.png and /dev/null differ
diff --git a/public/images/icon/door.png b/public/images/icon/door.png
deleted file mode 100644
index 6198ef9..0000000
Binary files a/public/images/icon/door.png and /dev/null differ
diff --git a/public/images/icon/door_in.png b/public/images/icon/door_in.png
deleted file mode 100644
index 3120f55..0000000
Binary files a/public/images/icon/door_in.png and /dev/null differ
diff --git a/public/images/icon/drawer.png b/public/images/icon/drawer.png
deleted file mode 100644
index 1b5cd0c..0000000
Binary files a/public/images/icon/drawer.png and /dev/null differ
diff --git a/public/images/icon/drink.png b/public/images/icon/drink.png
deleted file mode 100644
index e147b0c..0000000
Binary files a/public/images/icon/drink.png and /dev/null differ
diff --git a/public/images/icon/drink_empty.png b/public/images/icon/drink_empty.png
deleted file mode 100644
index f397c8b..0000000
Binary files a/public/images/icon/drink_empty.png and /dev/null differ
diff --git a/public/images/icon/drive.png b/public/images/icon/drive.png
deleted file mode 100644
index bda43d1..0000000
Binary files a/public/images/icon/drive.png and /dev/null differ
diff --git a/public/images/icon/drive_burn.png b/public/images/icon/drive_burn.png
deleted file mode 100644
index c5c12f4..0000000
Binary files a/public/images/icon/drive_burn.png and /dev/null differ
diff --git a/public/images/icon/drive_cd.png b/public/images/icon/drive_cd.png
deleted file mode 100644
index 20bc918..0000000
Binary files a/public/images/icon/drive_cd.png and /dev/null differ
diff --git a/public/images/icon/drive_cd_empty.png b/public/images/icon/drive_cd_empty.png
deleted file mode 100644
index b44bada..0000000
Binary files a/public/images/icon/drive_cd_empty.png and /dev/null differ
diff --git a/public/images/icon/drive_delete.png b/public/images/icon/drive_delete.png
deleted file mode 100644
index e9db99a..0000000
Binary files a/public/images/icon/drive_delete.png and /dev/null differ
diff --git a/public/images/icon/drive_disk.png b/public/images/icon/drive_disk.png
deleted file mode 100644
index bc3a2fe..0000000
Binary files a/public/images/icon/drive_disk.png and /dev/null differ
diff --git a/public/images/icon/drive_error.png b/public/images/icon/drive_error.png
deleted file mode 100644
index ed427e3..0000000
Binary files a/public/images/icon/drive_error.png and /dev/null differ
diff --git a/public/images/icon/drive_go.png b/public/images/icon/drive_go.png
deleted file mode 100644
index 15746db..0000000
Binary files a/public/images/icon/drive_go.png and /dev/null differ
diff --git a/public/images/icon/drive_link.png b/public/images/icon/drive_link.png
deleted file mode 100644
index c9199ec..0000000
Binary files a/public/images/icon/drive_link.png and /dev/null differ
diff --git a/public/images/icon/drive_network.png b/public/images/icon/drive_network.png
deleted file mode 100644
index 2945bd3..0000000
Binary files a/public/images/icon/drive_network.png and /dev/null differ
diff --git a/public/images/icon/drive_rename.png b/public/images/icon/drive_rename.png
deleted file mode 100644
index 1c00ee8..0000000
Binary files a/public/images/icon/drive_rename.png and /dev/null differ
diff --git a/public/images/icon/duration.png b/public/images/icon/duration.png
deleted file mode 100644
index 23548d2..0000000
Binary files a/public/images/icon/duration.png and /dev/null differ
diff --git a/public/images/icon/dvd.png b/public/images/icon/dvd.png
deleted file mode 100644
index 83a6f86..0000000
Binary files a/public/images/icon/dvd.png and /dev/null differ
diff --git a/public/images/icon/email_open.png b/public/images/icon/email_open.png
deleted file mode 100644
index 2b28759..0000000
Binary files a/public/images/icon/email_open.png and /dev/null differ
diff --git a/public/images/icon/email_open_image.png b/public/images/icon/email_open_image.png
deleted file mode 100644
index c9256ea..0000000
Binary files a/public/images/icon/email_open_image.png and /dev/null differ
diff --git a/public/images/icon/emoticon_evilgrin.png b/public/images/icon/emoticon_evilgrin.png
deleted file mode 100644
index f7771e8..0000000
Binary files a/public/images/icon/emoticon_evilgrin.png and /dev/null differ
diff --git a/public/images/icon/emoticon_grin.png b/public/images/icon/emoticon_grin.png
deleted file mode 100644
index fc62ac4..0000000
Binary files a/public/images/icon/emoticon_grin.png and /dev/null differ
diff --git a/public/images/icon/emoticon_happy.png b/public/images/icon/emoticon_happy.png
deleted file mode 100644
index 3a88e9b..0000000
Binary files a/public/images/icon/emoticon_happy.png and /dev/null differ
diff --git a/public/images/icon/emoticon_smile.png b/public/images/icon/emoticon_smile.png
deleted file mode 100644
index e74154c..0000000
Binary files a/public/images/icon/emoticon_smile.png and /dev/null differ
diff --git a/public/images/icon/emoticon_surprised.png b/public/images/icon/emoticon_surprised.png
deleted file mode 100644
index 6706cc3..0000000
Binary files a/public/images/icon/emoticon_surprised.png and /dev/null differ
diff --git a/public/images/icon/emoticon_tongue.png b/public/images/icon/emoticon_tongue.png
deleted file mode 100644
index 1ee2721..0000000
Binary files a/public/images/icon/emoticon_tongue.png and /dev/null differ
diff --git a/public/images/icon/emoticon_unhappy.png b/public/images/icon/emoticon_unhappy.png
deleted file mode 100644
index 8e2dfa9..0000000
Binary files a/public/images/icon/emoticon_unhappy.png and /dev/null differ
diff --git a/public/images/icon/emoticon_waii.png b/public/images/icon/emoticon_waii.png
deleted file mode 100644
index 84bd2b6..0000000
Binary files a/public/images/icon/emoticon_waii.png and /dev/null differ
diff --git a/public/images/icon/emoticon_wink.png b/public/images/icon/emoticon_wink.png
deleted file mode 100644
index aade1b7..0000000
Binary files a/public/images/icon/emoticon_wink.png and /dev/null differ
diff --git a/public/images/icon/envelope.png b/public/images/icon/envelope.png
deleted file mode 100644
index 5f59313..0000000
Binary files a/public/images/icon/envelope.png and /dev/null differ
diff --git a/public/images/icon/envelope_2.png b/public/images/icon/envelope_2.png
deleted file mode 100644
index 903e335..0000000
Binary files a/public/images/icon/envelope_2.png and /dev/null differ
diff --git a/public/images/icon/exclamation_octagon_fram.png b/public/images/icon/exclamation_octagon_fram.png
deleted file mode 100644
index 46834b9..0000000
Binary files a/public/images/icon/exclamation_octagon_fram.png and /dev/null differ
diff --git a/public/images/icon/eye.png b/public/images/icon/eye.png
deleted file mode 100644
index 3af02f4..0000000
Binary files a/public/images/icon/eye.png and /dev/null differ
diff --git a/public/images/icon/feed_ballon.png b/public/images/icon/feed_ballon.png
deleted file mode 100644
index 6bc7953..0000000
Binary files a/public/images/icon/feed_ballon.png and /dev/null differ
diff --git a/public/images/icon/feed_document.png b/public/images/icon/feed_document.png
deleted file mode 100644
index 20da336..0000000
Binary files a/public/images/icon/feed_document.png and /dev/null differ
diff --git a/public/images/icon/female.png b/public/images/icon/female.png
deleted file mode 100644
index 963af91..0000000
Binary files a/public/images/icon/female.png and /dev/null differ
diff --git a/public/images/icon/film.png b/public/images/icon/film.png
deleted file mode 100644
index 6a382dc..0000000
Binary files a/public/images/icon/film.png and /dev/null differ
diff --git a/public/images/icon/films.png b/public/images/icon/films.png
deleted file mode 100644
index f916219..0000000
Binary files a/public/images/icon/films.png and /dev/null differ
diff --git a/public/images/icon/find.png b/public/images/icon/find.png
deleted file mode 100644
index baf7667..0000000
Binary files a/public/images/icon/find.png and /dev/null differ
diff --git a/public/images/icon/flag_blue.png b/public/images/icon/flag_blue.png
deleted file mode 100644
index 80acb5c..0000000
Binary files a/public/images/icon/flag_blue.png and /dev/null differ
diff --git a/public/images/icon/folder.png b/public/images/icon/folder.png
deleted file mode 100644
index 3417c82..0000000
Binary files a/public/images/icon/folder.png and /dev/null differ
diff --git a/public/images/icon/font.png b/public/images/icon/font.png
deleted file mode 100644
index 2c24792..0000000
Binary files a/public/images/icon/font.png and /dev/null differ
diff --git a/public/images/icon/funnel.png b/public/images/icon/funnel.png
deleted file mode 100644
index a79ba10..0000000
Binary files a/public/images/icon/funnel.png and /dev/null differ
diff --git a/public/images/icon/grid.png b/public/images/icon/grid.png
deleted file mode 100644
index 57d8224..0000000
Binary files a/public/images/icon/grid.png and /dev/null differ
diff --git a/public/images/icon/grid_dot.png b/public/images/icon/grid_dot.png
deleted file mode 100644
index 796a1cb..0000000
Binary files a/public/images/icon/grid_dot.png and /dev/null differ
diff --git a/public/images/icon/group.png b/public/images/icon/group.png
deleted file mode 100644
index 0ee7cf5..0000000
Binary files a/public/images/icon/group.png and /dev/null differ
diff --git a/public/images/icon/hammer.png b/public/images/icon/hammer.png
deleted file mode 100644
index 6018bc4..0000000
Binary files a/public/images/icon/hammer.png and /dev/null differ
diff --git a/public/images/icon/hammer_screwdriver.png b/public/images/icon/hammer_screwdriver.png
deleted file mode 100644
index 013f021..0000000
Binary files a/public/images/icon/hammer_screwdriver.png and /dev/null differ
diff --git a/public/images/icon/hand.png b/public/images/icon/hand.png
deleted file mode 100644
index 5dc71fd..0000000
Binary files a/public/images/icon/hand.png and /dev/null differ
diff --git a/public/images/icon/hand_point.png b/public/images/icon/hand_point.png
deleted file mode 100644
index 31c4813..0000000
Binary files a/public/images/icon/hand_point.png and /dev/null differ
diff --git a/public/images/icon/heart.png b/public/images/icon/heart.png
deleted file mode 100644
index becdbfc..0000000
Binary files a/public/images/icon/heart.png and /dev/null differ
diff --git a/public/images/icon/heart_break.png b/public/images/icon/heart_break.png
deleted file mode 100644
index 0101d9a..0000000
Binary files a/public/images/icon/heart_break.png and /dev/null differ
diff --git a/public/images/icon/heart_empty.png b/public/images/icon/heart_empty.png
deleted file mode 100644
index e87d194..0000000
Binary files a/public/images/icon/heart_empty.png and /dev/null differ
diff --git a/public/images/icon/heart_half.png b/public/images/icon/heart_half.png
deleted file mode 100644
index 77ef489..0000000
Binary files a/public/images/icon/heart_half.png and /dev/null differ
diff --git a/public/images/icon/heart_small.png b/public/images/icon/heart_small.png
deleted file mode 100644
index 1c20ddc..0000000
Binary files a/public/images/icon/heart_small.png and /dev/null differ
diff --git a/public/images/icon/help.png b/public/images/icon/help.png
deleted file mode 100644
index 1d15c7b..0000000
Binary files a/public/images/icon/help.png and /dev/null differ
diff --git a/public/images/icon/highlighter.png b/public/images/icon/highlighter.png
deleted file mode 100644
index 7d875fa..0000000
Binary files a/public/images/icon/highlighter.png and /dev/null differ
diff --git a/public/images/icon/home.png b/public/images/icon/home.png
deleted file mode 100644
index 8df234f..0000000
Binary files a/public/images/icon/home.png and /dev/null differ
diff --git a/public/images/icon/house.png b/public/images/icon/house.png
deleted file mode 100644
index 8df234f..0000000
Binary files a/public/images/icon/house.png and /dev/null differ
diff --git a/public/images/icon/html.png b/public/images/icon/html.png
deleted file mode 100644
index 7ec46a5..0000000
Binary files a/public/images/icon/html.png and /dev/null differ
diff --git a/public/images/icon/image_1.png b/public/images/icon/image_1.png
deleted file mode 100644
index d70d959..0000000
Binary files a/public/images/icon/image_1.png and /dev/null differ
diff --git a/public/images/icon/image_2.png b/public/images/icon/image_2.png
deleted file mode 100644
index 5a83605..0000000
Binary files a/public/images/icon/image_2.png and /dev/null differ
diff --git a/public/images/icon/images.png b/public/images/icon/images.png
deleted file mode 100644
index 55ff685..0000000
Binary files a/public/images/icon/images.png and /dev/null differ
diff --git a/public/images/icon/inbox.png b/public/images/icon/inbox.png
deleted file mode 100644
index 18c273e..0000000
Binary files a/public/images/icon/inbox.png and /dev/null differ
diff --git a/public/images/icon/invoice.png b/public/images/icon/invoice.png
deleted file mode 100644
index 395c0de..0000000
Binary files a/public/images/icon/invoice.png and /dev/null differ
diff --git a/public/images/icon/ipod.png b/public/images/icon/ipod.png
deleted file mode 100644
index d6705d7..0000000
Binary files a/public/images/icon/ipod.png and /dev/null differ
diff --git a/public/images/icon/ipod_cast.png b/public/images/icon/ipod_cast.png
deleted file mode 100644
index 20c45e5..0000000
Binary files a/public/images/icon/ipod_cast.png and /dev/null differ
diff --git a/public/images/icon/job.png b/public/images/icon/job.png
deleted file mode 100644
index af93551..0000000
Binary files a/public/images/icon/job.png and /dev/null differ
diff --git a/public/images/icon/joystick.png b/public/images/icon/joystick.png
deleted file mode 100644
index 83afbf4..0000000
Binary files a/public/images/icon/joystick.png and /dev/null differ
diff --git a/public/images/icon/key.png b/public/images/icon/key.png
deleted file mode 100644
index 529fce2..0000000
Binary files a/public/images/icon/key.png and /dev/null differ
diff --git a/public/images/icon/keyboard.png b/public/images/icon/keyboard.png
deleted file mode 100644
index 501bcf6..0000000
Binary files a/public/images/icon/keyboard.png and /dev/null differ
diff --git a/public/images/icon/layer_treansparent.png b/public/images/icon/layer_treansparent.png
deleted file mode 100644
index a43e31a..0000000
Binary files a/public/images/icon/layer_treansparent.png and /dev/null differ
diff --git a/public/images/icon/layers.png b/public/images/icon/layers.png
deleted file mode 100644
index 5865f59..0000000
Binary files a/public/images/icon/layers.png and /dev/null differ
diff --git a/public/images/icon/layout.png b/public/images/icon/layout.png
deleted file mode 100644
index 07b76a0..0000000
Binary files a/public/images/icon/layout.png and /dev/null differ
diff --git a/public/images/icon/layout_header_footer_3.png b/public/images/icon/layout_header_footer_3.png
deleted file mode 100644
index 6b2d501..0000000
Binary files a/public/images/icon/layout_header_footer_3.png and /dev/null differ
diff --git a/public/images/icon/layout_header_footer_3_mix.png b/public/images/icon/layout_header_footer_3_mix.png
deleted file mode 100644
index c99aa88..0000000
Binary files a/public/images/icon/layout_header_footer_3_mix.png and /dev/null differ
diff --git a/public/images/icon/layout_join.png b/public/images/icon/layout_join.png
deleted file mode 100644
index dc407a2..0000000
Binary files a/public/images/icon/layout_join.png and /dev/null differ
diff --git a/public/images/icon/layout_join_vertical.png b/public/images/icon/layout_join_vertical.png
deleted file mode 100644
index a92b719..0000000
Binary files a/public/images/icon/layout_join_vertical.png and /dev/null differ
diff --git a/public/images/icon/layout_select.png b/public/images/icon/layout_select.png
deleted file mode 100644
index 47a0051..0000000
Binary files a/public/images/icon/layout_select.png and /dev/null differ
diff --git a/public/images/icon/layout_select_content.png b/public/images/icon/layout_select_content.png
deleted file mode 100644
index 6fb29ea..0000000
Binary files a/public/images/icon/layout_select_content.png and /dev/null differ
diff --git a/public/images/icon/layout_select_footer.png b/public/images/icon/layout_select_footer.png
deleted file mode 100644
index 4306ed9..0000000
Binary files a/public/images/icon/layout_select_footer.png and /dev/null differ
diff --git a/public/images/icon/layout_select_sidebar.png b/public/images/icon/layout_select_sidebar.png
deleted file mode 100644
index a13f11a..0000000
Binary files a/public/images/icon/layout_select_sidebar.png and /dev/null differ
diff --git a/public/images/icon/layout_split.png b/public/images/icon/layout_split.png
deleted file mode 100644
index a4918b5..0000000
Binary files a/public/images/icon/layout_split.png and /dev/null differ
diff --git a/public/images/icon/layout_split_vertical.png b/public/images/icon/layout_split_vertical.png
deleted file mode 100644
index 72a2b99..0000000
Binary files a/public/images/icon/layout_split_vertical.png and /dev/null differ
diff --git a/public/images/icon/lifebuoy.png b/public/images/icon/lifebuoy.png
deleted file mode 100644
index ed703b3..0000000
Binary files a/public/images/icon/lifebuoy.png and /dev/null differ
diff --git a/public/images/icon/lightbulb.png b/public/images/icon/lightbulb.png
deleted file mode 100644
index 3e8743b..0000000
Binary files a/public/images/icon/lightbulb.png and /dev/null differ
diff --git a/public/images/icon/lightbulb_off.png b/public/images/icon/lightbulb_off.png
deleted file mode 100644
index 8d47dce..0000000
Binary files a/public/images/icon/lightbulb_off.png and /dev/null differ
diff --git a/public/images/icon/lightning.png b/public/images/icon/lightning.png
deleted file mode 100644
index 67ec9d6..0000000
Binary files a/public/images/icon/lightning.png and /dev/null differ
diff --git a/public/images/icon/link.png b/public/images/icon/link.png
deleted file mode 100644
index 54e626d..0000000
Binary files a/public/images/icon/link.png and /dev/null differ
diff --git a/public/images/icon/link_break.png b/public/images/icon/link_break.png
deleted file mode 100644
index aa3c8ab..0000000
Binary files a/public/images/icon/link_break.png and /dev/null differ
diff --git a/public/images/icon/lock.png b/public/images/icon/lock.png
deleted file mode 100644
index 3a52863..0000000
Binary files a/public/images/icon/lock.png and /dev/null differ
diff --git a/public/images/icon/lock_unlock.png b/public/images/icon/lock_unlock.png
deleted file mode 100644
index 535dc1d..0000000
Binary files a/public/images/icon/lock_unlock.png and /dev/null differ
diff --git a/public/images/icon/logs.png b/public/images/icon/logs.png
deleted file mode 120000
index 14bcc7c..0000000
--- a/public/images/icon/logs.png
+++ /dev/null
@@ -1 +0,0 @@
-clipboard_text.png
\ No newline at end of file
diff --git a/public/images/icon/magnet.png b/public/images/icon/magnet.png
deleted file mode 100644
index 26c7dcf..0000000
Binary files a/public/images/icon/magnet.png and /dev/null differ
diff --git a/public/images/icon/magnifier_zoom_in.png b/public/images/icon/magnifier_zoom_in.png
deleted file mode 100644
index 23f2d4d..0000000
Binary files a/public/images/icon/magnifier_zoom_in.png and /dev/null differ
diff --git a/public/images/icon/male.png b/public/images/icon/male.png
deleted file mode 100644
index 507a132..0000000
Binary files a/public/images/icon/male.png and /dev/null differ
diff --git a/public/images/icon/map.png b/public/images/icon/map.png
deleted file mode 100644
index 9ecb79a..0000000
Binary files a/public/images/icon/map.png and /dev/null differ
diff --git a/public/images/icon/marker.png b/public/images/icon/marker.png
deleted file mode 100644
index ba50fbb..0000000
Binary files a/public/images/icon/marker.png and /dev/null differ
diff --git a/public/images/icon/medal_bronze_1.png b/public/images/icon/medal_bronze_1.png
deleted file mode 100644
index ec57559..0000000
Binary files a/public/images/icon/medal_bronze_1.png and /dev/null differ
diff --git a/public/images/icon/medal_gold_1.png b/public/images/icon/medal_gold_1.png
deleted file mode 100644
index 6cfd769..0000000
Binary files a/public/images/icon/medal_gold_1.png and /dev/null differ
diff --git a/public/images/icon/media_player_small_blue.png b/public/images/icon/media_player_small_blue.png
deleted file mode 100644
index 3176b48..0000000
Binary files a/public/images/icon/media_player_small_blue.png and /dev/null differ
diff --git a/public/images/icon/microphone.png b/public/images/icon/microphone.png
deleted file mode 100644
index 12db59e..0000000
Binary files a/public/images/icon/microphone.png and /dev/null differ
diff --git a/public/images/icon/mini_add.png b/public/images/icon/mini_add.png
deleted file mode 100644
index 14d9f09..0000000
Binary files a/public/images/icon/mini_add.png and /dev/null differ
diff --git a/public/images/icon/mini_deny.png b/public/images/icon/mini_deny.png
deleted file mode 100644
index 6dedd5a..0000000
Binary files a/public/images/icon/mini_deny.png and /dev/null differ
diff --git a/public/images/icon/mini_edit.png b/public/images/icon/mini_edit.png
deleted file mode 100644
index e2d6127..0000000
Binary files a/public/images/icon/mini_edit.png and /dev/null differ
diff --git a/public/images/icon/mini_error.png b/public/images/icon/mini_error.png
deleted file mode 100644
index 4983fa2..0000000
Binary files a/public/images/icon/mini_error.png and /dev/null differ
diff --git a/public/images/icon/mini_remove.png b/public/images/icon/mini_remove.png
deleted file mode 100644
index ddef040..0000000
Binary files a/public/images/icon/mini_remove.png and /dev/null differ
diff --git a/public/images/icon/mini_save.png b/public/images/icon/mini_save.png
deleted file mode 100644
index 0c8ed7e..0000000
Binary files a/public/images/icon/mini_save.png and /dev/null differ
diff --git a/public/images/icon/mini_search.png b/public/images/icon/mini_search.png
deleted file mode 100644
index 51de6e8..0000000
Binary files a/public/images/icon/mini_search.png and /dev/null differ
diff --git a/public/images/icon/mini_warning.png b/public/images/icon/mini_warning.png
deleted file mode 100644
index fbe5a07..0000000
Binary files a/public/images/icon/mini_warning.png and /dev/null differ
diff --git a/public/images/icon/mobile_phone.png b/public/images/icon/mobile_phone.png
deleted file mode 100644
index e01762a..0000000
Binary files a/public/images/icon/mobile_phone.png and /dev/null differ
diff --git a/public/images/icon/module.png b/public/images/icon/module.png
deleted file mode 120000
index ea459ba..0000000
--- a/public/images/icon/module.png
+++ /dev/null
@@ -1 +0,0 @@
-brick.png
\ No newline at end of file
diff --git a/public/images/icon/modules.png b/public/images/icon/modules.png
deleted file mode 120000
index d87013f..0000000
--- a/public/images/icon/modules.png
+++ /dev/null
@@ -1 +0,0 @@
-bricks.png
\ No newline at end of file
diff --git a/public/images/icon/money.png b/public/images/icon/money.png
deleted file mode 100644
index bc627a2..0000000
Binary files a/public/images/icon/money.png and /dev/null differ
diff --git a/public/images/icon/money_dollar.png b/public/images/icon/money_dollar.png
deleted file mode 100644
index e4df250..0000000
Binary files a/public/images/icon/money_dollar.png and /dev/null differ
diff --git a/public/images/icon/money_euro.png b/public/images/icon/money_euro.png
deleted file mode 100644
index 395c0de..0000000
Binary files a/public/images/icon/money_euro.png and /dev/null differ
diff --git a/public/images/icon/money_pound.png b/public/images/icon/money_pound.png
deleted file mode 100644
index ea10e54..0000000
Binary files a/public/images/icon/money_pound.png and /dev/null differ
diff --git a/public/images/icon/money_yen.png b/public/images/icon/money_yen.png
deleted file mode 100644
index 1279135..0000000
Binary files a/public/images/icon/money_yen.png and /dev/null differ
diff --git a/public/images/icon/monitor.png b/public/images/icon/monitor.png
deleted file mode 100644
index 592e480..0000000
Binary files a/public/images/icon/monitor.png and /dev/null differ
diff --git a/public/images/icon/mouse.png b/public/images/icon/mouse.png
deleted file mode 100644
index 0ea8ede..0000000
Binary files a/public/images/icon/mouse.png and /dev/null differ
diff --git a/public/images/icon/music.png b/public/images/icon/music.png
deleted file mode 100644
index 5553371..0000000
Binary files a/public/images/icon/music.png and /dev/null differ
diff --git a/public/images/icon/music_beam.png b/public/images/icon/music_beam.png
deleted file mode 100644
index 1839156..0000000
Binary files a/public/images/icon/music_beam.png and /dev/null differ
diff --git a/public/images/icon/neutral.png b/public/images/icon/neutral.png
deleted file mode 100644
index c803a69..0000000
Binary files a/public/images/icon/neutral.png and /dev/null differ
diff --git a/public/images/icon/new.png b/public/images/icon/new.png
deleted file mode 100644
index e1b4317..0000000
Binary files a/public/images/icon/new.png and /dev/null differ
diff --git a/public/images/icon/newspaper.png b/public/images/icon/newspaper.png
deleted file mode 100644
index 08cbd6c..0000000
Binary files a/public/images/icon/newspaper.png and /dev/null differ
diff --git a/public/images/icon/note.png b/public/images/icon/note.png
deleted file mode 100644
index 6f78202..0000000
Binary files a/public/images/icon/note.png and /dev/null differ
diff --git a/public/images/icon/nuclear.png b/public/images/icon/nuclear.png
deleted file mode 100644
index ab319f7..0000000
Binary files a/public/images/icon/nuclear.png and /dev/null differ
diff --git a/public/images/icon/package.png b/public/images/icon/package.png
deleted file mode 100644
index e24a47c..0000000
Binary files a/public/images/icon/package.png and /dev/null differ
diff --git a/public/images/icon/page_white_star.png b/public/images/icon/page_white_star.png
deleted file mode 100644
index 38ad812..0000000
Binary files a/public/images/icon/page_white_star.png and /dev/null differ
diff --git a/public/images/icon/page_white_swoosh.png b/public/images/icon/page_white_swoosh.png
deleted file mode 100644
index 78dbd4b..0000000
Binary files a/public/images/icon/page_white_swoosh.png and /dev/null differ
diff --git a/public/images/icon/page_white_text.png b/public/images/icon/page_white_text.png
deleted file mode 100644
index 6a890d5..0000000
Binary files a/public/images/icon/page_white_text.png and /dev/null differ
diff --git a/public/images/icon/page_white_text_width.png b/public/images/icon/page_white_text_width.png
deleted file mode 100644
index 84f9b30..0000000
Binary files a/public/images/icon/page_white_text_width.png and /dev/null differ
diff --git a/public/images/icon/page_white_tux.png b/public/images/icon/page_white_tux.png
deleted file mode 100644
index 6f0f9f5..0000000
Binary files a/public/images/icon/page_white_tux.png and /dev/null differ
diff --git a/public/images/icon/page_white_width.png b/public/images/icon/page_white_width.png
deleted file mode 100644
index 11b1817..0000000
Binary files a/public/images/icon/page_white_width.png and /dev/null differ
diff --git a/public/images/icon/page_white_world.png b/public/images/icon/page_white_world.png
deleted file mode 100644
index 94b2082..0000000
Binary files a/public/images/icon/page_white_world.png and /dev/null differ
diff --git a/public/images/icon/page_white_wrench.png b/public/images/icon/page_white_wrench.png
deleted file mode 100644
index 9be431c..0000000
Binary files a/public/images/icon/page_white_wrench.png and /dev/null differ
diff --git a/public/images/icon/page_white_zip.png b/public/images/icon/page_white_zip.png
deleted file mode 100644
index 66f2a65..0000000
Binary files a/public/images/icon/page_white_zip.png and /dev/null differ
diff --git a/public/images/icon/paintbrush.png b/public/images/icon/paintbrush.png
deleted file mode 100644
index 72000c2..0000000
Binary files a/public/images/icon/paintbrush.png and /dev/null differ
diff --git a/public/images/icon/paintcan.png b/public/images/icon/paintcan.png
deleted file mode 100644
index d2edf4c..0000000
Binary files a/public/images/icon/paintcan.png and /dev/null differ
diff --git a/public/images/icon/palette.png b/public/images/icon/palette.png
deleted file mode 100644
index be07a79..0000000
Binary files a/public/images/icon/palette.png and /dev/null differ
diff --git a/public/images/icon/paper_bag.png b/public/images/icon/paper_bag.png
deleted file mode 100644
index 3eae92d..0000000
Binary files a/public/images/icon/paper_bag.png and /dev/null differ
diff --git a/public/images/icon/paste_plain.png b/public/images/icon/paste_plain.png
deleted file mode 100644
index 9379f7d..0000000
Binary files a/public/images/icon/paste_plain.png and /dev/null differ
diff --git a/public/images/icon/paste_word.png b/public/images/icon/paste_word.png
deleted file mode 100644
index 2af3f48..0000000
Binary files a/public/images/icon/paste_word.png and /dev/null differ
diff --git a/public/images/icon/pencil.png b/public/images/icon/pencil.png
deleted file mode 100644
index 407a627..0000000
Binary files a/public/images/icon/pencil.png and /dev/null differ
diff --git a/public/images/icon/photo.png b/public/images/icon/photo.png
deleted file mode 100644
index 5bd86dc..0000000
Binary files a/public/images/icon/photo.png and /dev/null differ
diff --git a/public/images/icon/photo_album.png b/public/images/icon/photo_album.png
deleted file mode 100644
index b282ec8..0000000
Binary files a/public/images/icon/photo_album.png and /dev/null differ
diff --git a/public/images/icon/photos.png b/public/images/icon/photos.png
deleted file mode 100644
index 336386c..0000000
Binary files a/public/images/icon/photos.png and /dev/null differ
diff --git a/public/images/icon/piano.png b/public/images/icon/piano.png
deleted file mode 100644
index 3053cf8..0000000
Binary files a/public/images/icon/piano.png and /dev/null differ
diff --git a/public/images/icon/pilcrow.png b/public/images/icon/pilcrow.png
deleted file mode 100644
index ca645d9..0000000
Binary files a/public/images/icon/pilcrow.png and /dev/null differ
diff --git a/public/images/icon/pill.png b/public/images/icon/pill.png
deleted file mode 100644
index 20b9a64..0000000
Binary files a/public/images/icon/pill.png and /dev/null differ
diff --git a/public/images/icon/pin.png b/public/images/icon/pin.png
deleted file mode 100644
index 9c37976..0000000
Binary files a/public/images/icon/pin.png and /dev/null differ
diff --git a/public/images/icon/pipette.png b/public/images/icon/pipette.png
deleted file mode 100644
index 0280dcc..0000000
Binary files a/public/images/icon/pipette.png and /dev/null differ
diff --git a/public/images/icon/plaing_card.png b/public/images/icon/plaing_card.png
deleted file mode 100644
index 1eec689..0000000
Binary files a/public/images/icon/plaing_card.png and /dev/null differ
diff --git a/public/images/icon/plug.png b/public/images/icon/plug.png
deleted file mode 100644
index 729f936..0000000
Binary files a/public/images/icon/plug.png and /dev/null differ
diff --git a/public/images/icon/plugin.png b/public/images/icon/plugin.png
deleted file mode 100644
index 096e098..0000000
Binary files a/public/images/icon/plugin.png and /dev/null differ
diff --git a/public/images/icon/printer.png b/public/images/icon/printer.png
deleted file mode 100644
index e5c8128..0000000
Binary files a/public/images/icon/printer.png and /dev/null differ
diff --git a/public/images/icon/projection_screen.png b/public/images/icon/projection_screen.png
deleted file mode 100644
index 43d65bd..0000000
Binary files a/public/images/icon/projection_screen.png and /dev/null differ
diff --git a/public/images/icon/projection_screen_present.png b/public/images/icon/projection_screen_present.png
deleted file mode 100644
index bc9b019..0000000
Binary files a/public/images/icon/projection_screen_present.png and /dev/null differ
diff --git a/public/images/icon/rainbow.png b/public/images/icon/rainbow.png
deleted file mode 100644
index 55e0cdb..0000000
Binary files a/public/images/icon/rainbow.png and /dev/null differ
diff --git a/public/images/icon/rate.png b/public/images/icon/rate.png
deleted file mode 100644
index 90f10d9..0000000
Binary files a/public/images/icon/rate.png and /dev/null differ
diff --git a/public/images/icon/report.png b/public/images/icon/report.png
deleted file mode 100644
index 3f8afb5..0000000
Binary files a/public/images/icon/report.png and /dev/null differ
diff --git a/public/images/icon/rocket.png b/public/images/icon/rocket.png
deleted file mode 100644
index 8ad03f4..0000000
Binary files a/public/images/icon/rocket.png and /dev/null differ
diff --git a/public/images/icon/rosette.png b/public/images/icon/rosette.png
deleted file mode 100644
index 542c03f..0000000
Binary files a/public/images/icon/rosette.png and /dev/null differ
diff --git a/public/images/icon/rss.png b/public/images/icon/rss.png
deleted file mode 100644
index bbd005e..0000000
Binary files a/public/images/icon/rss.png and /dev/null differ
diff --git a/public/images/icon/ruby.png b/public/images/icon/ruby.png
deleted file mode 100644
index bc61afa..0000000
Binary files a/public/images/icon/ruby.png and /dev/null differ
diff --git a/public/images/icon/ruler_1.png b/public/images/icon/ruler_1.png
deleted file mode 100644
index 17da72c..0000000
Binary files a/public/images/icon/ruler_1.png and /dev/null differ
diff --git a/public/images/icon/ruler_2.png b/public/images/icon/ruler_2.png
deleted file mode 100644
index 646c950..0000000
Binary files a/public/images/icon/ruler_2.png and /dev/null differ
diff --git a/public/images/icon/ruler_crop.png b/public/images/icon/ruler_crop.png
deleted file mode 100644
index 69bfe42..0000000
Binary files a/public/images/icon/ruler_crop.png and /dev/null differ
diff --git a/public/images/icon/ruler_triangle.png b/public/images/icon/ruler_triangle.png
deleted file mode 100644
index 041e71a..0000000
Binary files a/public/images/icon/ruler_triangle.png and /dev/null differ
diff --git a/public/images/icon/safe.png b/public/images/icon/safe.png
deleted file mode 100644
index ed69a1e..0000000
Binary files a/public/images/icon/safe.png and /dev/null differ
diff --git a/public/images/icon/script.png b/public/images/icon/script.png
deleted file mode 100644
index 6d450a0..0000000
Binary files a/public/images/icon/script.png and /dev/null differ
diff --git a/public/images/icon/selection.png b/public/images/icon/selection.png
deleted file mode 100644
index 9d7618b..0000000
Binary files a/public/images/icon/selection.png and /dev/null differ
diff --git a/public/images/icon/selection_select.png b/public/images/icon/selection_select.png
deleted file mode 100644
index 93412b9..0000000
Binary files a/public/images/icon/selection_select.png and /dev/null differ
diff --git a/public/images/icon/server.png b/public/images/icon/server.png
deleted file mode 100644
index e0e5d15..0000000
Binary files a/public/images/icon/server.png and /dev/null differ
diff --git a/public/images/icon/settings.png b/public/images/icon/settings.png
deleted file mode 100644
index aa65d2f..0000000
Binary files a/public/images/icon/settings.png and /dev/null differ
diff --git a/public/images/icon/shading.png b/public/images/icon/shading.png
deleted file mode 100644
index c52f12b..0000000
Binary files a/public/images/icon/shading.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_bottom.png b/public/images/icon/shape_aling_bottom.png
deleted file mode 100644
index 2e50492..0000000
Binary files a/public/images/icon/shape_aling_bottom.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_center.png b/public/images/icon/shape_aling_center.png
deleted file mode 100644
index 44f3a30..0000000
Binary files a/public/images/icon/shape_aling_center.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_left.png b/public/images/icon/shape_aling_left.png
deleted file mode 100644
index 3c7d2d2..0000000
Binary files a/public/images/icon/shape_aling_left.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_middle.png b/public/images/icon/shape_aling_middle.png
deleted file mode 100644
index 4120600..0000000
Binary files a/public/images/icon/shape_aling_middle.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_right.png b/public/images/icon/shape_aling_right.png
deleted file mode 100644
index 851c4ed..0000000
Binary files a/public/images/icon/shape_aling_right.png and /dev/null differ
diff --git a/public/images/icon/shape_aling_top.png b/public/images/icon/shape_aling_top.png
deleted file mode 100644
index cfed3e7..0000000
Binary files a/public/images/icon/shape_aling_top.png and /dev/null differ
diff --git a/public/images/icon/shape_flip_horizontal.png b/public/images/icon/shape_flip_horizontal.png
deleted file mode 100644
index 627dfe0..0000000
Binary files a/public/images/icon/shape_flip_horizontal.png and /dev/null differ
diff --git a/public/images/icon/shape_flip_vertical.png b/public/images/icon/shape_flip_vertical.png
deleted file mode 100644
index 9b3edb2..0000000
Binary files a/public/images/icon/shape_flip_vertical.png and /dev/null differ
diff --git a/public/images/icon/shape_group.png b/public/images/icon/shape_group.png
deleted file mode 100644
index e34c1d0..0000000
Binary files a/public/images/icon/shape_group.png and /dev/null differ
diff --git a/public/images/icon/shape_handles.png b/public/images/icon/shape_handles.png
deleted file mode 100644
index 5b6a9ba..0000000
Binary files a/public/images/icon/shape_handles.png and /dev/null differ
diff --git a/public/images/icon/shape_move_back.png b/public/images/icon/shape_move_back.png
deleted file mode 100644
index f77a0bd..0000000
Binary files a/public/images/icon/shape_move_back.png and /dev/null differ
diff --git a/public/images/icon/shape_move_backwards.png b/public/images/icon/shape_move_backwards.png
deleted file mode 100644
index ce01fdd..0000000
Binary files a/public/images/icon/shape_move_backwards.png and /dev/null differ
diff --git a/public/images/icon/shape_move_forwards.png b/public/images/icon/shape_move_forwards.png
deleted file mode 100644
index ab9a7a6..0000000
Binary files a/public/images/icon/shape_move_forwards.png and /dev/null differ
diff --git a/public/images/icon/shape_move_front.png b/public/images/icon/shape_move_front.png
deleted file mode 100644
index 32c0998..0000000
Binary files a/public/images/icon/shape_move_front.png and /dev/null differ
diff --git a/public/images/icon/shape_square.png b/public/images/icon/shape_square.png
deleted file mode 100644
index 0773585..0000000
Binary files a/public/images/icon/shape_square.png and /dev/null differ
diff --git a/public/images/icon/shield.png b/public/images/icon/shield.png
deleted file mode 100644
index e51b5cf..0000000
Binary files a/public/images/icon/shield.png and /dev/null differ
diff --git a/public/images/icon/sign_copyright.png b/public/images/icon/sign_copyright.png
deleted file mode 100644
index 05eca43..0000000
Binary files a/public/images/icon/sign_copyright.png and /dev/null differ
diff --git a/public/images/icon/sitemap.png b/public/images/icon/sitemap.png
deleted file mode 100644
index eb0bbc9..0000000
Binary files a/public/images/icon/sitemap.png and /dev/null differ
diff --git a/public/images/icon/slide.png b/public/images/icon/slide.png
deleted file mode 100644
index b7dc483..0000000
Binary files a/public/images/icon/slide.png and /dev/null differ
diff --git a/public/images/icon/slides.png b/public/images/icon/slides.png
deleted file mode 100644
index 5359c11..0000000
Binary files a/public/images/icon/slides.png and /dev/null differ
diff --git a/public/images/icon/slides_stack.png b/public/images/icon/slides_stack.png
deleted file mode 100644
index 3b4ac4e..0000000
Binary files a/public/images/icon/slides_stack.png and /dev/null differ
diff --git a/public/images/icon/smiley_confuse.png b/public/images/icon/smiley_confuse.png
deleted file mode 100644
index d770221..0000000
Binary files a/public/images/icon/smiley_confuse.png and /dev/null differ
diff --git a/public/images/icon/smiley_cool.png b/public/images/icon/smiley_cool.png
deleted file mode 100644
index 0cf7c78..0000000
Binary files a/public/images/icon/smiley_cool.png and /dev/null differ
diff --git a/public/images/icon/smiley_cry.png b/public/images/icon/smiley_cry.png
deleted file mode 100644
index 6d56ae5..0000000
Binary files a/public/images/icon/smiley_cry.png and /dev/null differ
diff --git a/public/images/icon/smiley_fat.png b/public/images/icon/smiley_fat.png
deleted file mode 100644
index b31cc37..0000000
Binary files a/public/images/icon/smiley_fat.png and /dev/null differ
diff --git a/public/images/icon/smiley_mad.png b/public/images/icon/smiley_mad.png
deleted file mode 100644
index dce79de..0000000
Binary files a/public/images/icon/smiley_mad.png and /dev/null differ
diff --git a/public/images/icon/smiley_red.png b/public/images/icon/smiley_red.png
deleted file mode 100644
index 6a07413..0000000
Binary files a/public/images/icon/smiley_red.png and /dev/null differ
diff --git a/public/images/icon/smiley_roll.png b/public/images/icon/smiley_roll.png
deleted file mode 100644
index 6fc2ee3..0000000
Binary files a/public/images/icon/smiley_roll.png and /dev/null differ
diff --git a/public/images/icon/smiley_slim.png b/public/images/icon/smiley_slim.png
deleted file mode 100644
index b223991..0000000
Binary files a/public/images/icon/smiley_slim.png and /dev/null differ
diff --git a/public/images/icon/smiley_yell.png b/public/images/icon/smiley_yell.png
deleted file mode 100644
index 0355905..0000000
Binary files a/public/images/icon/smiley_yell.png and /dev/null differ
diff --git a/public/images/icon/socket.png b/public/images/icon/socket.png
deleted file mode 100644
index 0b44d0d..0000000
Binary files a/public/images/icon/socket.png and /dev/null differ
diff --git a/public/images/icon/sockets.png b/public/images/icon/sockets.png
deleted file mode 100644
index 2212c3e..0000000
Binary files a/public/images/icon/sockets.png and /dev/null differ
diff --git a/public/images/icon/sort.png b/public/images/icon/sort.png
deleted file mode 100644
index 2c5d751..0000000
Binary files a/public/images/icon/sort.png and /dev/null differ
diff --git a/public/images/icon/sort_alphabet.png b/public/images/icon/sort_alphabet.png
deleted file mode 100644
index 0b341fe..0000000
Binary files a/public/images/icon/sort_alphabet.png and /dev/null differ
diff --git a/public/images/icon/sort_date.png b/public/images/icon/sort_date.png
deleted file mode 100644
index 899cc02..0000000
Binary files a/public/images/icon/sort_date.png and /dev/null differ
diff --git a/public/images/icon/sort_disable.png b/public/images/icon/sort_disable.png
deleted file mode 100644
index aa686dd..0000000
Binary files a/public/images/icon/sort_disable.png and /dev/null differ
diff --git a/public/images/icon/sort_number.png b/public/images/icon/sort_number.png
deleted file mode 100644
index 2bc8574..0000000
Binary files a/public/images/icon/sort_number.png and /dev/null differ
diff --git a/public/images/icon/sort_price.png b/public/images/icon/sort_price.png
deleted file mode 100644
index 25ecc68..0000000
Binary files a/public/images/icon/sort_price.png and /dev/null differ
diff --git a/public/images/icon/sort_quantity.png b/public/images/icon/sort_quantity.png
deleted file mode 100644
index bf732bf..0000000
Binary files a/public/images/icon/sort_quantity.png and /dev/null differ
diff --git a/public/images/icon/sort_rating.png b/public/images/icon/sort_rating.png
deleted file mode 100644
index 3eb05c9..0000000
Binary files a/public/images/icon/sort_rating.png and /dev/null differ
diff --git a/public/images/icon/sound.png b/public/images/icon/sound.png
deleted file mode 100644
index 9801d63..0000000
Binary files a/public/images/icon/sound.png and /dev/null differ
diff --git a/public/images/icon/sound_note.png b/public/images/icon/sound_note.png
deleted file mode 100644
index f7cea2f..0000000
Binary files a/public/images/icon/sound_note.png and /dev/null differ
diff --git a/public/images/icon/spellcheck.png b/public/images/icon/spellcheck.png
deleted file mode 100644
index feb90a2..0000000
Binary files a/public/images/icon/spellcheck.png and /dev/null differ
diff --git a/public/images/icon/sport_8ball.png b/public/images/icon/sport_8ball.png
deleted file mode 100644
index d3737e6..0000000
Binary files a/public/images/icon/sport_8ball.png and /dev/null differ
diff --git a/public/images/icon/sport_basketball.png b/public/images/icon/sport_basketball.png
deleted file mode 100644
index a78e2dc..0000000
Binary files a/public/images/icon/sport_basketball.png and /dev/null differ
diff --git a/public/images/icon/sport_football.png b/public/images/icon/sport_football.png
deleted file mode 100644
index dbcaf92..0000000
Binary files a/public/images/icon/sport_football.png and /dev/null differ
diff --git a/public/images/icon/sport_golf.png b/public/images/icon/sport_golf.png
deleted file mode 100644
index b25ad2c..0000000
Binary files a/public/images/icon/sport_golf.png and /dev/null differ
diff --git a/public/images/icon/sport_raquet.png b/public/images/icon/sport_raquet.png
deleted file mode 100644
index 3f3a5bc..0000000
Binary files a/public/images/icon/sport_raquet.png and /dev/null differ
diff --git a/public/images/icon/sport_shuttlecock.png b/public/images/icon/sport_shuttlecock.png
deleted file mode 100644
index 32c20d5..0000000
Binary files a/public/images/icon/sport_shuttlecock.png and /dev/null differ
diff --git a/public/images/icon/sport_soccer.png b/public/images/icon/sport_soccer.png
deleted file mode 100644
index e27a242..0000000
Binary files a/public/images/icon/sport_soccer.png and /dev/null differ
diff --git a/public/images/icon/sport_tennis.png b/public/images/icon/sport_tennis.png
deleted file mode 100644
index f2906c0..0000000
Binary files a/public/images/icon/sport_tennis.png and /dev/null differ
diff --git a/public/images/icon/stamp.png b/public/images/icon/stamp.png
deleted file mode 100644
index 6c2a385..0000000
Binary files a/public/images/icon/stamp.png and /dev/null differ
diff --git a/public/images/icon/star_1.png b/public/images/icon/star_1.png
deleted file mode 100644
index 87cb771..0000000
Binary files a/public/images/icon/star_1.png and /dev/null differ
diff --git a/public/images/icon/star_2.png b/public/images/icon/star_2.png
deleted file mode 100644
index 9883e31..0000000
Binary files a/public/images/icon/star_2.png and /dev/null differ
diff --git a/public/images/icon/status_online.png b/public/images/icon/status_online.png
deleted file mode 100644
index 857beab..0000000
Binary files a/public/images/icon/status_online.png and /dev/null differ
diff --git a/public/images/icon/stop.png b/public/images/icon/stop.png
deleted file mode 100644
index d421f8f..0000000
Binary files a/public/images/icon/stop.png and /dev/null differ
diff --git a/public/images/icon/style.png b/public/images/icon/style.png
deleted file mode 100644
index e256494..0000000
Binary files a/public/images/icon/style.png and /dev/null differ
diff --git a/public/images/icon/sum.png b/public/images/icon/sum.png
deleted file mode 100644
index ce4e5a4..0000000
Binary files a/public/images/icon/sum.png and /dev/null differ
diff --git a/public/images/icon/sum_2.png b/public/images/icon/sum_2.png
deleted file mode 100644
index aa5db07..0000000
Binary files a/public/images/icon/sum_2.png and /dev/null differ
diff --git a/public/images/icon/switch.png b/public/images/icon/switch.png
deleted file mode 100644
index b29f2e5..0000000
Binary files a/public/images/icon/switch.png and /dev/null differ
diff --git a/public/images/icon/tab.png b/public/images/icon/tab.png
deleted file mode 100644
index 0a247b7..0000000
Binary files a/public/images/icon/tab.png and /dev/null differ
diff --git a/public/images/icon/table.png b/public/images/icon/table.png
deleted file mode 100644
index 50b4b0a..0000000
Binary files a/public/images/icon/table.png and /dev/null differ
diff --git a/public/images/icon/table_edit.png b/public/images/icon/table_edit.png
deleted file mode 100644
index bfcb024..0000000
Binary files a/public/images/icon/table_edit.png and /dev/null differ
diff --git a/public/images/icon/tag.png b/public/images/icon/tag.png
deleted file mode 100644
index 34e0a44..0000000
Binary files a/public/images/icon/tag.png and /dev/null differ
diff --git a/public/images/icon/tag_blue.png b/public/images/icon/tag_blue.png
deleted file mode 100644
index be0efda..0000000
Binary files a/public/images/icon/tag_blue.png and /dev/null differ
diff --git a/public/images/icon/target.png b/public/images/icon/target.png
deleted file mode 100644
index d27063a..0000000
Binary files a/public/images/icon/target.png and /dev/null differ
diff --git a/public/images/icon/telephone.png b/public/images/icon/telephone.png
deleted file mode 100644
index 2f4d3ed..0000000
Binary files a/public/images/icon/telephone.png and /dev/null differ
diff --git a/public/images/icon/television.png b/public/images/icon/television.png
deleted file mode 100644
index 0859833..0000000
Binary files a/public/images/icon/television.png and /dev/null differ
diff --git a/public/images/icon/text_align_center.png b/public/images/icon/text_align_center.png
deleted file mode 100644
index ecb655c..0000000
Binary files a/public/images/icon/text_align_center.png and /dev/null differ
diff --git a/public/images/icon/text_align_justify.png b/public/images/icon/text_align_justify.png
deleted file mode 100644
index 72eb6c5..0000000
Binary files a/public/images/icon/text_align_justify.png and /dev/null differ
diff --git a/public/images/icon/text_align_left.png b/public/images/icon/text_align_left.png
deleted file mode 100644
index 52d7f74..0000000
Binary files a/public/images/icon/text_align_left.png and /dev/null differ
diff --git a/public/images/icon/text_align_right.png b/public/images/icon/text_align_right.png
deleted file mode 100644
index c98d283..0000000
Binary files a/public/images/icon/text_align_right.png and /dev/null differ
diff --git a/public/images/icon/text_allcaps.png b/public/images/icon/text_allcaps.png
deleted file mode 100644
index ff3d0e1..0000000
Binary files a/public/images/icon/text_allcaps.png and /dev/null differ
diff --git a/public/images/icon/text_bold.png b/public/images/icon/text_bold.png
deleted file mode 100644
index a799e40..0000000
Binary files a/public/images/icon/text_bold.png and /dev/null differ
diff --git a/public/images/icon/text_columns.png b/public/images/icon/text_columns.png
deleted file mode 100644
index 174d89e..0000000
Binary files a/public/images/icon/text_columns.png and /dev/null differ
diff --git a/public/images/icon/text_dropcaps.png b/public/images/icon/text_dropcaps.png
deleted file mode 100644
index a07bc5f..0000000
Binary files a/public/images/icon/text_dropcaps.png and /dev/null differ
diff --git a/public/images/icon/text_heading_1.png b/public/images/icon/text_heading_1.png
deleted file mode 100644
index b1eaa1b..0000000
Binary files a/public/images/icon/text_heading_1.png and /dev/null differ
diff --git a/public/images/icon/text_horizontalrule.png b/public/images/icon/text_horizontalrule.png
deleted file mode 100644
index 477a26b..0000000
Binary files a/public/images/icon/text_horizontalrule.png and /dev/null differ
diff --git a/public/images/icon/text_indent.png b/public/images/icon/text_indent.png
deleted file mode 100644
index f5ba48c..0000000
Binary files a/public/images/icon/text_indent.png and /dev/null differ
diff --git a/public/images/icon/text_indent_remove.png b/public/images/icon/text_indent_remove.png
deleted file mode 100644
index 8661ee5..0000000
Binary files a/public/images/icon/text_indent_remove.png and /dev/null differ
diff --git a/public/images/icon/text_italic.png b/public/images/icon/text_italic.png
deleted file mode 100644
index 11cdd63..0000000
Binary files a/public/images/icon/text_italic.png and /dev/null differ
diff --git a/public/images/icon/text_kerning.png b/public/images/icon/text_kerning.png
deleted file mode 100644
index 3b06dab..0000000
Binary files a/public/images/icon/text_kerning.png and /dev/null differ
diff --git a/public/images/icon/text_letter_omega.png b/public/images/icon/text_letter_omega.png
deleted file mode 100644
index 52c6e62..0000000
Binary files a/public/images/icon/text_letter_omega.png and /dev/null differ
diff --git a/public/images/icon/text_letterspacing.png b/public/images/icon/text_letterspacing.png
deleted file mode 100644
index c547677..0000000
Binary files a/public/images/icon/text_letterspacing.png and /dev/null differ
diff --git a/public/images/icon/text_linespacing.png b/public/images/icon/text_linespacing.png
deleted file mode 100644
index 2d898a1..0000000
Binary files a/public/images/icon/text_linespacing.png and /dev/null differ
diff --git a/public/images/icon/text_list_bullets.png b/public/images/icon/text_list_bullets.png
deleted file mode 100644
index bd9f3af..0000000
Binary files a/public/images/icon/text_list_bullets.png and /dev/null differ
diff --git a/public/images/icon/text_list_numbers.png b/public/images/icon/text_list_numbers.png
deleted file mode 100644
index a535e3f..0000000
Binary files a/public/images/icon/text_list_numbers.png and /dev/null differ
diff --git a/public/images/icon/text_lowercase.png b/public/images/icon/text_lowercase.png
deleted file mode 100644
index 00728d7..0000000
Binary files a/public/images/icon/text_lowercase.png and /dev/null differ
diff --git a/public/images/icon/text_padding_bottom.png b/public/images/icon/text_padding_bottom.png
deleted file mode 100644
index eed7012..0000000
Binary files a/public/images/icon/text_padding_bottom.png and /dev/null differ
diff --git a/public/images/icon/text_padding_left.png b/public/images/icon/text_padding_left.png
deleted file mode 100644
index 4a5a1b2..0000000
Binary files a/public/images/icon/text_padding_left.png and /dev/null differ
diff --git a/public/images/icon/text_padding_right.png b/public/images/icon/text_padding_right.png
deleted file mode 100644
index 8b022ae..0000000
Binary files a/public/images/icon/text_padding_right.png and /dev/null differ
diff --git a/public/images/icon/text_padding_top.png b/public/images/icon/text_padding_top.png
deleted file mode 100644
index 6fe0610..0000000
Binary files a/public/images/icon/text_padding_top.png and /dev/null differ
diff --git a/public/images/icon/text_signature.png b/public/images/icon/text_signature.png
deleted file mode 100644
index a9d47e1..0000000
Binary files a/public/images/icon/text_signature.png and /dev/null differ
diff --git a/public/images/icon/text_smallcaps.png b/public/images/icon/text_smallcaps.png
deleted file mode 100644
index a7e3d7b..0000000
Binary files a/public/images/icon/text_smallcaps.png and /dev/null differ
diff --git a/public/images/icon/text_strikethrough.png b/public/images/icon/text_strikethrough.png
deleted file mode 100644
index 49ad88b..0000000
Binary files a/public/images/icon/text_strikethrough.png and /dev/null differ
diff --git a/public/images/icon/text_subscript.png b/public/images/icon/text_subscript.png
deleted file mode 100644
index 0668e54..0000000
Binary files a/public/images/icon/text_subscript.png and /dev/null differ
diff --git a/public/images/icon/textfield.png b/public/images/icon/textfield.png
deleted file mode 100644
index 977c820..0000000
Binary files a/public/images/icon/textfield.png and /dev/null differ
diff --git a/public/images/icon/textfield_rename.png b/public/images/icon/textfield_rename.png
deleted file mode 100644
index e858154..0000000
Binary files a/public/images/icon/textfield_rename.png and /dev/null differ
diff --git a/public/images/icon/ticket.png b/public/images/icon/ticket.png
deleted file mode 100644
index 0a93c90..0000000
Binary files a/public/images/icon/ticket.png and /dev/null differ
diff --git a/public/images/icon/timeline_marker.png b/public/images/icon/timeline_marker.png
deleted file mode 100644
index 8431fe4..0000000
Binary files a/public/images/icon/timeline_marker.png and /dev/null differ
diff --git a/public/images/icon/traffic.png b/public/images/icon/traffic.png
deleted file mode 100644
index d09b26f..0000000
Binary files a/public/images/icon/traffic.png and /dev/null differ
diff --git a/public/images/icon/transmit.png b/public/images/icon/transmit.png
deleted file mode 100644
index f36d87e..0000000
Binary files a/public/images/icon/transmit.png and /dev/null differ
diff --git a/public/images/icon/trophy.png b/public/images/icon/trophy.png
deleted file mode 100644
index f114e3d..0000000
Binary files a/public/images/icon/trophy.png and /dev/null differ
diff --git a/public/images/icon/trophy_bronze.png b/public/images/icon/trophy_bronze.png
deleted file mode 100644
index 9822bfc..0000000
Binary files a/public/images/icon/trophy_bronze.png and /dev/null differ
diff --git a/public/images/icon/trophy_silver.png b/public/images/icon/trophy_silver.png
deleted file mode 100644
index cc8b67b..0000000
Binary files a/public/images/icon/trophy_silver.png and /dev/null differ
diff --git a/public/images/icon/ui_combo_box.png b/public/images/icon/ui_combo_box.png
deleted file mode 100644
index 64e1b63..0000000
Binary files a/public/images/icon/ui_combo_box.png and /dev/null differ
diff --git a/public/images/icon/ui_saccordion.png b/public/images/icon/ui_saccordion.png
deleted file mode 100644
index 2b3b5a7..0000000
Binary files a/public/images/icon/ui_saccordion.png and /dev/null differ
diff --git a/public/images/icon/ui_slider_1.png b/public/images/icon/ui_slider_1.png
deleted file mode 100644
index d7a5843..0000000
Binary files a/public/images/icon/ui_slider_1.png and /dev/null differ
diff --git a/public/images/icon/ui_slider_2.png b/public/images/icon/ui_slider_2.png
deleted file mode 100644
index 37bead5..0000000
Binary files a/public/images/icon/ui_slider_2.png and /dev/null differ
diff --git a/public/images/icon/ui_tab_bottom.png b/public/images/icon/ui_tab_bottom.png
deleted file mode 100644
index c681f0d..0000000
Binary files a/public/images/icon/ui_tab_bottom.png and /dev/null differ
diff --git a/public/images/icon/ui_tab_content.png b/public/images/icon/ui_tab_content.png
deleted file mode 100644
index 009c7d3..0000000
Binary files a/public/images/icon/ui_tab_content.png and /dev/null differ
diff --git a/public/images/icon/ui_tab_disable.png b/public/images/icon/ui_tab_disable.png
deleted file mode 100644
index c55062c..0000000
Binary files a/public/images/icon/ui_tab_disable.png and /dev/null differ
diff --git a/public/images/icon/ui_tab_side.png b/public/images/icon/ui_tab_side.png
deleted file mode 100644
index c63ea4c..0000000
Binary files a/public/images/icon/ui_tab_side.png and /dev/null differ
diff --git a/public/images/icon/ui_text_field_hidden.png b/public/images/icon/ui_text_field_hidden.png
deleted file mode 100644
index c106f60..0000000
Binary files a/public/images/icon/ui_text_field_hidden.png and /dev/null differ
diff --git a/public/images/icon/ui_text_field_password.png b/public/images/icon/ui_text_field_password.png
deleted file mode 100644
index f168289..0000000
Binary files a/public/images/icon/ui_text_field_password.png and /dev/null differ
diff --git a/public/images/icon/umbrella.png b/public/images/icon/umbrella.png
deleted file mode 100644
index 7de30ff..0000000
Binary files a/public/images/icon/umbrella.png and /dev/null differ
diff --git a/public/images/icon/user.png b/public/images/icon/user.png
deleted file mode 100644
index c4b84e2..0000000
Binary files a/public/images/icon/user.png and /dev/null differ
diff --git a/public/images/icon/user_black_female.png b/public/images/icon/user_black_female.png
deleted file mode 100644
index 9b4ea46..0000000
Binary files a/public/images/icon/user_black_female.png and /dev/null differ
diff --git a/public/images/icon/user_business.png b/public/images/icon/user_business.png
deleted file mode 100644
index 6f7995d..0000000
Binary files a/public/images/icon/user_business.png and /dev/null differ
diff --git a/public/images/icon/user_business_boss.png b/public/images/icon/user_business_boss.png
deleted file mode 100644
index 0ac1ddb..0000000
Binary files a/public/images/icon/user_business_boss.png and /dev/null differ
diff --git a/public/images/icon/user_female.png b/public/images/icon/user_female.png
deleted file mode 100644
index 3692996..0000000
Binary files a/public/images/icon/user_female.png and /dev/null differ
diff --git a/public/images/icon/user_silhouette.png b/public/images/icon/user_silhouette.png
deleted file mode 100644
index 7477dcd..0000000
Binary files a/public/images/icon/user_silhouette.png and /dev/null differ
diff --git a/public/images/icon/user_thief.png b/public/images/icon/user_thief.png
deleted file mode 100644
index 144cf38..0000000
Binary files a/public/images/icon/user_thief.png and /dev/null differ
diff --git a/public/images/icon/user_thief_baldie.png b/public/images/icon/user_thief_baldie.png
deleted file mode 100644
index 5e35ae5..0000000
Binary files a/public/images/icon/user_thief_baldie.png and /dev/null differ
diff --git a/public/images/icon/vcard.png b/public/images/icon/vcard.png
deleted file mode 100644
index 0f0e7a9..0000000
Binary files a/public/images/icon/vcard.png and /dev/null differ
diff --git a/public/images/icon/vector.png b/public/images/icon/vector.png
deleted file mode 100644
index b6a4728..0000000
Binary files a/public/images/icon/vector.png and /dev/null differ
diff --git a/public/images/icon/view.png b/public/images/icon/view.png
deleted file mode 120000
index fb4ce28..0000000
--- a/public/images/icon/view.png
+++ /dev/null
@@ -1 +0,0 @@
-magnifier.png
\ No newline at end of file
diff --git a/public/images/icon/wait.png b/public/images/icon/wait.png
deleted file mode 100644
index 23548d2..0000000
Binary files a/public/images/icon/wait.png and /dev/null differ
diff --git a/public/images/icon/wall.png b/public/images/icon/wall.png
deleted file mode 100644
index 27ac2c9..0000000
Binary files a/public/images/icon/wall.png and /dev/null differ
diff --git a/public/images/icon/wall_break.png b/public/images/icon/wall_break.png
deleted file mode 100644
index 2577017..0000000
Binary files a/public/images/icon/wall_break.png and /dev/null differ
diff --git a/public/images/icon/wall_brick.png b/public/images/icon/wall_brick.png
deleted file mode 100644
index b00e0f6..0000000
Binary files a/public/images/icon/wall_brick.png and /dev/null differ
diff --git a/public/images/icon/wall_disable.png b/public/images/icon/wall_disable.png
deleted file mode 100644
index ae5c2dc..0000000
Binary files a/public/images/icon/wall_disable.png and /dev/null differ
diff --git a/public/images/icon/wand.png b/public/images/icon/wand.png
deleted file mode 100644
index c9f4896..0000000
Binary files a/public/images/icon/wand.png and /dev/null differ
diff --git a/public/images/icon/weather_clouds.png b/public/images/icon/weather_clouds.png
deleted file mode 100644
index b869b56..0000000
Binary files a/public/images/icon/weather_clouds.png and /dev/null differ
diff --git a/public/images/icon/weather_cloudy.png b/public/images/icon/weather_cloudy.png
deleted file mode 100644
index 95d8af6..0000000
Binary files a/public/images/icon/weather_cloudy.png and /dev/null differ
diff --git a/public/images/icon/weather_lightning.png b/public/images/icon/weather_lightning.png
deleted file mode 100644
index e38e5ad..0000000
Binary files a/public/images/icon/weather_lightning.png and /dev/null differ
diff --git a/public/images/icon/weather_rain.png b/public/images/icon/weather_rain.png
deleted file mode 100644
index 2a9cdea..0000000
Binary files a/public/images/icon/weather_rain.png and /dev/null differ
diff --git a/public/images/icon/weather_snow.png b/public/images/icon/weather_snow.png
deleted file mode 100644
index d982948..0000000
Binary files a/public/images/icon/weather_snow.png and /dev/null differ
diff --git a/public/images/icon/weather_sun.png b/public/images/icon/weather_sun.png
deleted file mode 100644
index 5729b6b..0000000
Binary files a/public/images/icon/weather_sun.png and /dev/null differ
diff --git a/public/images/icon/webcam.png b/public/images/icon/webcam.png
deleted file mode 100644
index 6de3913..0000000
Binary files a/public/images/icon/webcam.png and /dev/null differ
diff --git a/public/images/icon/worklog.png b/public/images/icon/worklog.png
deleted file mode 100644
index 0d2cab1..0000000
Binary files a/public/images/icon/worklog.png and /dev/null differ
diff --git a/public/images/icon/world.png b/public/images/icon/world.png
deleted file mode 100644
index 160e86b..0000000
Binary files a/public/images/icon/world.png and /dev/null differ
diff --git a/public/images/icon/zone.png b/public/images/icon/zone.png
deleted file mode 100644
index 3d60661..0000000
Binary files a/public/images/icon/zone.png and /dev/null differ
diff --git a/public/images/icon/zone_money.png b/public/images/icon/zone_money.png
deleted file mode 100644
index 4103199..0000000
Binary files a/public/images/icon/zone_money.png and /dev/null differ
diff --git a/public/images/icon/zones.png b/public/images/icon/zones.png
deleted file mode 100644
index e97a104..0000000
Binary files a/public/images/icon/zones.png and /dev/null differ
|
jtietema/Fizzy
|
08cfbe9512f8d9bb5de0ff16f075d6c8da4d379a
|
Default configuration
|
diff --git a/configs/fizzy.xml.default b/configs/fizzy.xml.default
index 2345380..b826cc0 100644
--- a/configs/fizzy.xml.default
+++ b/configs/fizzy.xml.default
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<fizzy version="0.4">
+<fizzy version="1.1">
<application>
<title>Fizzy</title>
- <environment>development</environment>
- <basePath>/absolute/path/to/your/fizzy</basePath>
+ <environment>production</environment>
</application>
<router>
<defaultController>default</defaultController>
<defaultAction>default</defaultAction>
</router>
<storage>
- <dsn>xml:/absolute/path/to/your/fizzy/data</dsn>
+ <dsn>xml:data</dsn>
</storage>
</fizzy>
|
jtietema/Fizzy
|
d817e07995ba4ca8c3a4296ae4b34367d42e8940
|
Storage backend relative paths:
|
diff --git a/application/library/Fizzy/Storage/Backend/Pdo.php b/application/library/Fizzy/Storage/Backend/Pdo.php
index 9fe4c9e..dbaca8c 100644
--- a/application/library/Fizzy/Storage/Backend/Pdo.php
+++ b/application/library/Fizzy/Storage/Backend/Pdo.php
@@ -1,269 +1,267 @@
<?php
/**
* Class Fizzy_Storage_Backend_Pdo
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Abstract */
require_once 'Fizzy/Storage/Backend/Abstract.php';
/**
* Storage backend based on the PDO extension.
*
* @author Mattijs Hoitink <[email protected]>
*/
abstract class Fizzy_Storage_Backend_Pdo extends Fizzy_Storage_Backend_Abstract
{
/**
* Username for the database connection.
* @var string
*/
protected $_username = '';
/**
* Password for the database connection.
* @var string
*/
protected $_password = '';
/**
* The connection to the database.
* @var PDO
*/
protected $_connection = null;
/** **/
- public function __construct($options = array())
- {
- parent::__construct($options);
-
- // Make a new PDO connection
- try {
- $this->_connection = new PDO($this->_dsn, $this->_username, $this->_password);
- }
- catch(PDOException $exception) {
- require_once 'Fizzy/Storage/Exception.php';
- throw new Fizzy_Storage_Exception($exception->getMessage());
- }
- }
-
/**
* Sets the username for the database connection.
* @param string $username
* @return Fizzy_Storage_Backend_Mysql
*/
public function setUsername($username)
{
$this->_username = $username;
return $this;
}
/**
* Returns the username for the database.
* @return string
*/
public function getUsername()
{
return $this->_username;
}
/**
* Sets the password for the database connection.
* @param string $password
* @return Fizzy_Storage_Backend_Mysql
*/
public function setPassword($password)
{
$this->_password = $password;
return $this;
}
/**
* Returns the password for the database connection.
* @return string
*/
public function getPassword()
{
return $this->_password;
}
/**
* Returns the PDO connection object.
* @return PDO
*/
public function getConnection()
{
+ if(null === $this->_connection)
+ {
+ // Make a new PDO connection
+ try {
+ $this->_connection = new PDO($this->_dsn, $this->_username, $this->_password);
+ }
+ catch(PDOException $exception) {
+ require_once 'Fizzy/Storage/Exception.php';
+ throw new Fizzy_Storage_Exception($exception->getMessage());
+ }
+ }
+
return $this->_connection;
}
/**
* Creates a prepared statement for the query.
* @param string $query
* @return PDOStatement|null
*/
protected function _createStatement($query)
{
- $statement = $this->_connection->prepare($query);
+ $statement = $this->getConnection()->prepare($query);
if(false === $statement) {
require_once 'Fizzy/Storage/Exception.php';
- throw new Fizzy_Storage_Exception(implode(';', $this->_connection->errorInfo()));
+ throw new Fizzy_Storage_Exception(implode(';', $this->getConnection()->errorInfo()));
}
return $statement;
}
/**
* Executes a statement
* @param PDOStatement $sql
*/
protected function _executeStatement(PDOStatement $statement)
{
$success = $statement->execute();
if(false === $success) {
require_once 'Fizzy/Storage/Exception.php';
- throw new Fizzy_Storage_Exception(implode(';', $this->_connection->errorInfo()));
+ throw new Fizzy_Storage_Exception(implode(';', $this->getConnection()->errorInfo()));
}
return $statement;
}
/* Implementation of Fizzy_Storage_Backend_Interface */
/**
* FetchAll for PDO enabled drivers
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchAll($container)
{
// Prepare statement
$statement = $this->_createStatement("SELECT * FROM `{$container}`");
$executed = $this->_executeStatement($statement);
$rows = $executed->fetchAll(PDO::FETCH_ASSOC);
return $rows;
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByIdentifier($container, $identifier)
{
$statement = $this->_createStatement("SELECT * FROM `{$container}` WHERE {$this->_identifierField} = :{$this->_identifierField}");
$statement->bindValue(":{$this->_identifierField}", $identifier, PDO::PARAM_STR);
$executed = $this->_executeStatement($statement);
// Fetch row from the executed statement
$row = $executed->fetch(PDO::FETCH_ASSOC);
if(empty($row)) {
return null;
}
$identifier = $row[$this->_identifierField];
unset($row[$this->_identifierField]);
return array($identifier => $row);
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByColumn($container, array $columns)
{
if(0 === count($columns)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception('No columns specified.');
}
$query = "SELECT * FROM `{$container}` WHERE ";
$whereClause = array();
foreach($columns as $column => $value) {
$whereClause[] = "`{$column}` = :{$column}";
}
$query .= implode(' AND ', $whereClause);
$statement = $this->_createStatement($query);
foreach($columns as $column => $value) {
$statement->bindValue(":{$column}", $value, PDO::PARAM_STR);
}
$executed = $this->_executeStatement($statement);
$rows = $executed->fetchAll(PDO::FETCH_ASSOC);
if(!empty($rows)) {
return $rows;
}
return array();
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function delete($container, $identifier)
{
// Check if the model is in persistence
if(null === $identifier) {
return true;
}
$statement = $this->_createStatement("DELETE FROM `{$container}` WHERE `{$this->_identifierField}` = :{$this->_identifierField}");
$statement->bindValue(":{$this->_identifierField}", $identifier);
$executed = $this->_executeStatement($statement);
return true;
}
/**
* @see Fizzy_Storage_Driver_Interface
*/
public function persist($container, $data, $identifier = null)
{
$columns = array_keys($data);
$setClause = array();
foreach($columns as $column) {
$setClause[$column] = "`{$column}` = :{$column}";
}
$setClause = implode(', ', $setClause);
if (null !== $identifier) {
$query = "UPDATE `{$container}` SET {$setClause} WHERE `{$this->_identifierField}` = :{$this->_identifierField}";
}
else {
$query = "INSERT INTO `{$container}` SET {$setClause};";
}
$statement = $this->_createStatement($query);
if(null !== $identifier) {
$statement->bindValue(":{$this->_identifierField}", $identifier, PDO::PARAM_STR);
}
foreach($data as $column => $value) {
$statement->bindValue(":{$column}", $value, PDO::PARAM_STR);
}
$executed = $this->_executeStatement($statement);
// Return the id for the data set
- return $this->_connection->lastInsertId();
+ return $this->getConnection()->lastInsertId();
}
}
\ No newline at end of file
diff --git a/application/library/Fizzy/Storage/Backend/Sqlite.php b/application/library/Fizzy/Storage/Backend/Sqlite.php
index d2e99c7..808f950 100644
--- a/application/library/Fizzy/Storage/Backend/Sqlite.php
+++ b/application/library/Fizzy/Storage/Backend/Sqlite.php
@@ -1,31 +1,58 @@
<?php
/**
* Class Fizzy_Storage_Backend_Sqlite
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Pdo */
require_once 'Fizzy/Storage/Backend/Pdo.php';
/**
* Storage backend based on PDO_SQLite
*
* @author Jeroen Tietema <[email protected]>
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage_Backend_Sqlite extends Fizzy_Storage_Backend_Pdo
-{}
\ No newline at end of file
+{
+ /**
+ * Constructor. Will check the dsn for relative paths and prefix them with
+ * the application base path.
+ * @param array $options
+ */
+ public function __construct($options = array())
+ {
+ parent::__construct($options);
+
+ $dsn = $this->getDsn();
+ list($protocol, $dataPath) = explode(':', $dsn);
+
+ // Change path to system directory separator
+ $dataPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $dataPath);
+ // Add a trailing slash
+ $dataPath = rtrim($dataPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+ // Check if path is relative within the web application root
+ if(0 !== strpos($dataPath, DIRECTORY_SEPARATOR))
+ {
+ $basePath = Fizzy_Config::getInstance()->getSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath');
+ $dataPath = $basePath . $dataPath;
+ }
+
+ // Set the dsn with the corrected absolute or relative path
+ $this->setDsn($protocol . ':' . $dataPath);
+ }
+}
\ No newline at end of file
diff --git a/application/library/Fizzy/Storage/Backend/Xml.php b/application/library/Fizzy/Storage/Backend/Xml.php
index 000054d..28e6cb8 100644
--- a/application/library/Fizzy/Storage/Backend/Xml.php
+++ b/application/library/Fizzy/Storage/Backend/Xml.php
@@ -1,300 +1,309 @@
<?php
/**
* Class Fizzy_Storage_Backend_Xml
* @package Fizzy
* @subpackage Storage
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/** Fizzy_Storage_Backend_Abstract */
require_once 'Fizzy/Storage/Backend/Abstract.php';
/** Fizzy_Storage_Backend_Xml_DOMDocument */
require_once 'Fizzy/Storage/Backend/Xml/DOMDocument.php';
/**
* Storage backend for Fizzy based on XML files.
*
* @author Jeroen Tietema <[email protected]>
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Storage_Backend_Xml extends Fizzy_Storage_Backend_Abstract
{
/**
* @see Fizzy_Storage_Backend_Abstract
*/
protected $_identifierField = 'uid';
/**
* The path to the container store.
* @var string
*/
protected $_dataPath = null;
/**
* References to the XML documents for the containers.
* @var array
*/
protected $_xmlDocuments = array();
/** **/
/**
* Constructor
* @todo Add check for relative paths.
* @param array $options
* @throws Fizzy_Storage_Exception
*/
public function __construct($options = array())
{
parent::__construct($options);
$dsn = $this->getDsn();
- list(,$dataPath) = explode(':', $dsn);
-
+ list($protocol, $dataPath) = explode(':', $dsn);
+
// Change path to system directory separator
$dataPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $dataPath);
// Add a trailing slash
$dataPath = rtrim($dataPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+ // Check if path is relative within the web application root
+ if(0 !== strpos($dataPath, DIRECTORY_SEPARATOR))
+ {
+ $basePath = Fizzy_Config::getInstance()->getSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath');
+ $dataPath = $basePath . $dataPath;
+ }
+ // Set the dsn with the corrected absolute or relative path
+ $this->setDsn($protocol . ':' . $dataPath);
+
if(!is_dir($dataPath) || !is_writable($dataPath)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception(
"Data directory {$dataPath} does not exist or is not writable."
);
}
$this->_dataPath = $dataPath;
}
/**
* Returns the XML Document for a container.
* @param string $container
* @return Fizzy_Storage_Backend_XmlDocument
*/
protected function _getXmlDocument($container)
{
$container = strtolower(trim($container));
if(!array_key_exists($container, $this->_xmlDocuments)) {
$documentPath = $this->_dataPath . $container . '.xml';
if(!is_file($documentPath)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception("Container {$documentPath} could not be found.");
}
$this->_xmlDocuments[$container] = $this->_loadXmlDocument($documentPath);
}
return $this->_xmlDocuments[$container];
}
/**
* Loads an XML document from a path.
* @param string $path
*/
protected function _loadXmlDocument($path)
{
return new Fizzy_Storage_Backend_Xml_DOMDocument($path);
}
/**
* Parses a DOMNodeList and resturns an array.
* @param DOMNodeList $nodeList
* @return array
*/
protected function _parseNodeList($nodeList)
{
$elements = array();
foreach($nodeList as $node) {
$simpleXMLElement = simplexml_import_dom($node);
$elementArray = $this->_elementToArray($simpleXMLElement);
// Remove the identifier from the data
$identifier = $elementArray[$this->_identifierField];
unset($elementArray[$this->_identifierField]);
$elements[$identifier] = $elementArray;
}
return $elements;
}
/**
* Creates a DOMNodeList from an array naming the nodes like $nodeName.
* @param array $dataArray
* @param string $nodeName
* @return DOMNodeList
*/
protected function _createNodeList(array $dataArray, $document, $nodeName = 'item')
{
$root = $document->createElement('container');
foreach($dataArray as $identifier => $data)
{
// Create the element
$child = $document->createElement($nodeName);
// Add the identifier as attribute
$child->setAttribute($this->_identifierField, $identifier);
// Loop the data columns and add them as CDATA nodes
foreach($data as $key => $value)
{
$dataElement = $document->createElement($key);
$cdataElement = $document->createCDATASection($value);
$dataElement->appendChild($cdataElement);
$child->appendChild($dataElement);
}
$root->appendChild($child);
}
$nodeList = $root->childNodes;
return $nodeList;
}
/**
* Converts a SimpleXMLElement to an array.
* @param SimpleXMLElement $element
* @return array
*/
protected function _elementToArray(SimpleXMLElement $element)
{
$data = array();
if(count($element->children()) > 0) {
foreach($element->children() as $childKey => $childValue) {
$value = $this->_elementToArray($childValue);
$data[$childKey] = $value;
}
}
else {
$data = (string) $element;
}
// account for attributes
if(count($element->attributes()) > 0) {
$attributesArray = array();
foreach($element->attributes() as $attributeKey => $attributeValue) {
$attributesArray[$attributeKey] = (string) $attributeValue;
}
if(!is_array($data)) {
$data = array('data' => $data);
}
$data = array_merge($data, $attributesArray);
}
return $data;
}
/* Implementation of Fizzy_Storage_Backend_Interface */
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function persist($container, $data, $identifier = null)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
// Create a new identifier if empty
if(null === $identifier)
{
list($micro, $seconds) = explode(' ', microtime());
$identifier = $seconds . substr(strrchr($micro, '.'), 1);
}
$elements[$identifier] = $data;
// Create a new node list from the data
$nodeList = $this->_createNodeList($elements, $document, $container);
// Write the entire node list to the container file.
$success = $document->writeNodeList($nodeList);
return ((boolean) false !== $success);
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function delete($container, $identifier)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
// Unset the element
unset($elements[$identifier]);
// Create a new node list from the data
$nodeList = $this->_createNodeList($elements, $document, $container);
// Write the entire node list to the container file.
$success = $document->writeNodeList($nodeList);
return ((boolean) false !== $success);
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchAll($container)
{
$document = $this->_getXmlDocument($container);
$nodeList = $document->getAllNodes();
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByIdentifier($container, $identifier)
{
if(empty($identifier)) {
require_once 'Fizzy/Storage/Exception.php';
throw new Fizzy_Storage_Exception('Identifier cannot be empty.');
}
$document = $this->_getXmlDocument($container);
$nodeList = $document->getElementsByXpath("/container/{$container}[@uid='{$identifier}']");
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
/**
* @see Fizzy_Storage_Backend_Interface
*/
public function fetchByColumn($container, array $columns)
{
$document = $this->_getXmlDocument(strtolower($container));
$whereColumns = array();
foreach($columns as $key => $value) {
$whereColumns[$key] = "{$key}='{$value}'";
}
$nodeList = $document->getElementsByXpath("/container/{$container}[" . implode(' and ', $whereColumns) . "]");
$elements = $this->_parseNodeList($nodeList);
return $elements;
}
}
\ No newline at end of file
|
jtietema/Fizzy
|
79048c33e7dc852911ee91108ac9863e37f205d2
|
Base path:
|
diff --git a/application/Fizzy.php b/application/Fizzy.php
index dcde28e..47c935b 100644
--- a/application/Fizzy.php
+++ b/application/Fizzy.php
@@ -1,54 +1,62 @@
<?php
/**
* Fizzy bootstrap file.
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*
* @author Mattijs Hoitink <[email protected]>
*/
define('APPLICATION_PATH', realpath(dirname(__FILE__)));
define('APPLICATION_LIBRARY_PATH', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'library');
define('ROOT_PATH', realpath(APPLICATION_PATH . DIRECTORY_SEPARATOR . '..'));
define('LIBRARY_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
define('CONFIG_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'configs');
set_include_path(LIBRARY_PATH . PATH_SEPARATOR . APPLICATION_LIBRARY_PATH . DIRECTORY_SEPARATOR . get_include_path());
function stripslashes_deep(&$value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
// strip all injected slashes by magic_quotes_gpc
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
stripslashes_deep($_GET);
stripslashes_deep($_POST);
stripslashes_deep($_REQUEST);
stripslashes_deep($_COOKIE);
}
require_once 'Fizzy/Config.php';
require_once 'Fizzy/FrontController.php';
$config = Fizzy_Config::getInstance()
->loadConfiguration(simplexml_load_file(CONFIG_PATH .'/fizzy.xml'))
->loadRoutes(simplexml_load_file(CONFIG_PATH .'/routes.xml'));
+$basePath = $config->getSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath');
+if(empty($basePath))
+{
+ // Set a default base path
+ $config->setSectionValue(Fizzy_Config::SECTION_APPLICATION, 'basePath', ROOT_PATH);
+}
+
+// Dispatch the request
$frontController = new Fizzy_FrontController($config);
$frontController->dispatch();
\ No newline at end of file
diff --git a/application/library/Fizzy/Config.php b/application/library/Fizzy/Config.php
index 8801e45..6c7f41d 100644
--- a/application/library/Fizzy/Config.php
+++ b/application/library/Fizzy/Config.php
@@ -1,428 +1,443 @@
<?php
/**
* Class Fizzy_Config
* @package Fizzy
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.voidwalkers.nl/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @copyright Copyright (c) 2009 Voidwalkers (http://www.voidwalkers.nl)
* @license http://www.voidwalkers.nl/license/new-bsd The New BSD License
*/
/**
* Config class for Fizzy.
*
* @author Mattijs Hoitink <[email protected]>
*/
class Fizzy_Config
{
/*
* Constants for default sections.
*/
const SECTION_APPLICATION = 'application';
const SECTION_PATHS = 'paths';
const SECTION_ROUTER = 'router';
/**
* Fizzy_Config instance.
* @var Fizzy_Config
*/
protected static $_instance = null;
/**
* Configuration for Fizzy containing default values.
* @var array
*/
protected $_configuration = array(
self::SECTION_APPLICATION => array(
'title' => 'Fizzy',
'environment' => 'production',
'basePath' => '',
'defaultLayout' => 'default',
'defaultTemplate' => 'page',
),
self::SECTION_ROUTER => array (
'defaultController' => 'default',
'defaultAction' => 'default',
'routes' => array(),
),
self::SECTION_PATHS => array(
'application' => 'application',
'controllers' => 'application/controllers',
'models' => 'application/models',
'views' => array(
'application' => 'application/views/scripts',
'custom' => 'custom/views'
),
'layouts' => array(
'application' => 'application/views/layouts',
'custom' => 'custom/layouts',
),
'templates' => array (
'application' => 'application/views/scripts',
'custom' => 'custom/templates'
),
'configs' => 'configs',
'custom' => 'custom',
'data' => 'data',
'library' => 'library',
'public' => 'public',
'uploads' => 'public/uploads',
),
);
/** **/
/**
* Fizzy_Config is a singleton, use Fizzy_Config::getInstance() to obtain
* an instance.
*/
protected function __construct()
{}
/**
* Returns the active Fizzy_Config instance.
* @return Fizzy_Config
*/
public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Returns the complete configuration as an array.
* @return array
*/
public function getConfiguration()
{
return $this->_configuration;
}
/**
* Sets the configuration section with the given data. Overrides any
* existent data in the section.
* @param string $section
* @param mixed $data
* @return Fizzy_Config
*/
public function setSection($section, $data)
{
$this->_configuration[$section] = $data;
return $this;
}
/**
* Merges values from a section with given key => value array.
* @param string $section
* @param array $data
* @return Fizzy_Config
*/
public function mergeSection($section, array $data)
{
$sectionData = $this->getSection($section);
if(null === $sectionData) {
$sectionData = $data;
} else {
$sectionData = $this->_arrayMergeRecursive($sectionData, $data);
}
return $this->setSection($section, $sectionData);
}
/**
* Sets a value inside a section. The section is created if it does not
* exist.
* @param string $section
* @param string $key
* @param mixed $value
* @return Fizzy_Config
*/
public function setSectionValue($section, $key, $value)
{
$sectionData = $this->getSection($section);
if(null === $sectionData) {
$sectionData = array();
}
$sectionData[$key] = $value;
$this->setSection($section, $sectionData);
return $this;
}
/**
* Returns a configuration section by name.
* @param string $section
* @return array|null
*/
public function getSection($section)
{
if(array_key_exists($section, $this->_configuration)) {
return $this->_configuration[$section];
}
return null;
}
+ /**
+ * Gets a value from a section with the given key.
+ * @param string $section
+ * @param string $key
+ * @return mixed|null
+ */
+ public function getSectionValue($section, $key)
+ {
+ if(array_key_exists($section, $this->_configuration) && is_array($this->_configuration[$section]) && array_key_exists($key, $this->_configuration[$section])) {
+ return $this->_configuration[$section][$key];
+ }
+
+ return null;
+ }
+
/**
* Sets a path within the application. Paths must be set relative to the
* application root. The configured base path will be stripped from
* set paths.
* @param string $alias
* @param string|array $path
* @return Fizzy_Config
*/
public function setPath($alias, $path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
if(is_array($path)) {
$path = array_walk($path, array($this, '_removeBasePath'));
}
else if('base' !== $alias) {
$path = $this->_removeBasePath($path);
}
$this->_configuration[self::SECTION_PATHS][$alias] = $path;
return $this;
}
/**
* Returns a set path by name. Paths are returned include the set base path.
* Use getApplicationPath($alias) to get the path relative to the
* application root.
* @param string $alias
* @return string|null
*/
public function getPath($alias)
{
if(!array_key_exists($alias, $this->_configuration[self::SECTION_PATHS])) {
return null;
}
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$path = $this->_configuration[self::SECTION_PATHS][$alias];
if(is_array($path)) {
array_walk($path, array($this, '_addBasePath'));
}
else {
$path = $this->_addBasePath($path);
}
return $path;
}
/**
* Adds the base path to an application path.
* @param string $path
* @return string
*/
protected function _addBasePath(&$path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$basePath = $this->_cleanPath($basePath);
if(0 !== strpos($path, $basePath)) {
$path = $this->_createPath($basePath, $path);
}
return $path;
}
/**
* Removes the base path from an application path.
* @param string $path
* @return string
*/
protected function _removeBasePath(&$path)
{
$basePath = $this->_configuration[self::SECTION_APPLICATION]['basePath'];
$basePath = $this->_cleanPath($basePath);
if(0 === strpos($path, $basePath)) {
$path = str_replace($basePath, '', $path);
}
return $path;
}
/**
* Cleans a path making sure it starts with a DIRECTORY_SEPARATOR and does
* not end with a DIRECTORY_SEPARATOR
* @param string $path
* @return string
*/
protected function _cleanPath($path)
{
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
if(0 !== strpos($path, DIRECTORY_SEPARATOR)) {
$path = DIRECTORY_SEPARATOR . $path;
}
$path = rtrim($path, DIRECTORY_SEPARATOR);
return $path;
}
/**
* Creates a path from multiple elements. Any number of elements can be
* supplied.
* @return <type>
*/
public function _createPath()
{
if(0 === func_num_args()) {
return null;
}
$elements = func_get_args();
$elements = array_map(array($this, '_cleanPath'), $elements);
return implode('', $elements);
}
/**
* Merges given paths with existent paths.
* @param array $paths
* @return Fizzy_Config
*/
public function addPaths(array $paths)
{
return $this->mergeSection(self::SECTION_PATHS, $paths);
}
/**
* Loads configuration from a SimpleXMLElement.
* @param SimpleXMLElement $element
* @return Fizzy_Config
*/
public function loadConfiguration(SimpleXMLElement $element)
{
// Parse the config element
$dataArray = array();
foreach($element->children() as $sectionName => $sectionData) {
$dataArray[$sectionName] = $this->_elementToArray($sectionData);
}
$this->_configuration = $this->_arrayMergeRecursive($this->_configuration, $dataArray);
return $this;
}
/**
* Loads routes configuration from a SimpleXMLElement. Merges the routes
* with the router section of the configuration.
* @param SimpleXMLElement $routes
* @return Fizzy_Config
*/
public function loadRoutes(SimpleXMLElement $routes)
{
$routesArray = array();
foreach($routes->children() as $routeName => $routeData) {
$routesArray[$routeName] = $this->_elementToArray($routeData);
}
$routerConfig = $this->getSection(self::SECTION_ROUTER);
$routerConfig = $this->_arrayMergeRecursive($routerConfig, $routesArray);
$this->setSection(self::SECTION_ROUTER, $routerConfig);
return $this;
}
/**
* Converts a SimpleXMLElement to an array.
* @param SimpleXMLElement $element
* @return array
*/
protected function _elementToArray(SimpleXMLElement $element)
{
$data = array();
if(count($element->children()) > 0) {
foreach($element->children() as $childKey => $childValue) {
if(count($childValue->children()) > 0) {
$value = $this->_elementToArray($childValue);
}
else {
$value = (string) $childValue;
}
// account for attributes
if(count($childValue->attributes()) > 0) {
$attributesArray = array();
foreach($childValue->attributes() as $attributeKey => $attributeValue) {
$attributesArray[$attributeKey] = (string) $attributeValue;
}
if(!is_array($value)) {
$value = array('value' => $value);
}
$value = array_merge($value, $attributesArray);
}
$data[$childKey] = $value;
}
}
else {
$data = (string) $element;
}
return $data;
}
/**
* Merges values from $valueArray into $baseArray recursively overwriting
* values in $baseArray.
*
* @param mixed $baseArray
* @param mixed $valueArray
* @return array
*/
protected function _arrayMergeRecursive($baseArray, $valueArray)
{
if(is_array($baseArray) && is_array($valueArray)) {
foreach($valueArray as $key => $value) {
if(isset($baseArray[$key])) {
$baseArray[$key] = $this->_arrayMergeRecursive($baseArray[$key], $value);
} else {
if($key === 0) {
$baseArray = array(0 => $this->_arrayMergeRecursive($baseArray, $value));
} else {
$baseArray[$key] = $value;
}
}
}
} else {
$baseArray = $valueArray;
}
return $baseArray;
}
/**
* Override to call configuration sections dynamically.
* @param string $name
* @param array $arguments
*/
public function __call($name, $arguments)
{
if(0 === strpos($name, 'get')) {
$section = str_replace('get', '', $name);
$section = strtolower(substr($section, 0, 1)) . substr($section, 1, strlen($section));
return $this->getSection($section);
}
}
}
|
danieljfarrell/website-2.0
|
06cf392f258fac2fee97246a5085cbcec7a2f9f6
|
Swapped the order of the items in the experience section on the front page
|
diff --git a/index.html b/index.html
index dc93877..615b66e 100644
--- a/index.html
+++ b/index.html
@@ -1,88 +1,88 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<meta name="microid" content="mailto+http:sha1:ab095e627455a292fb5fd60550b0fa4a2105ae79">
<link rel="openid.server" href="http://openid.claimid.com/server">
<link rel="openid.delegate" href="http://daniel.farrell.name">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="#" title="home" class="current"><span>home</span></a>
</li>
<li class="green">
<a href="research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<div class="span-6 append-1">
<img src="img/daniel_j_farrell.jpg" class="top push-0 shadow" alt="test" width="240">
</div>
<h6>
About
</h6>
<p>
I'm Daniel Farrell, a post doctoral researcher in the Experimental Solid State Physics group at Imperial College London. I research photovoltaic energy conversion, I'm particularly interested in hot-carrier solar cells and spectral modification with luminescent materials.
</p>
<hr class="space">
<h6>
Experience
</h6>
<ul>
- <li>2009 - present, Research Associate â Imperial College London. Fabricated, characterised and simulated the first quantum dot based luminescent solar concentrator tandem. Wrote optical Monte-Carlo software: <a href="freebies/">pvtrace</a>.
+ <li>2009 - present, Research Associate â Imperial College London. Developed and co-invented a new concept based around photovoltaic conversion with hot-carriers resulting in 3 patents. Developed a rate model for the hot-carrier solar cell. Performed perturbation theory analysis on cooling in quantum dots.
</li>
- <li>2004 - 2009, Postgraduate Student â Imperial College London. Developed a rate model for the hot-carrier solar cell. Performed perturbation theory analysis on cooling in quantum dots.
+ <li>2004 - 2009, Postgraduate Student â Imperial College London. Fabricated, characterised and simulated the first quantum dot based luminescent solar concentrator tandem. Wrote optical Monte-Carlo software: <a href="freebies/">pvtrace</a>.
</li>
</ul>
</div>
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<div class="span-13 last">
<hr>
<h5>Recent publications and talks</h5>
<ul class="publist">
<li class="pub">D J Farrell and N J Ekins-Daukes, <em>"Photovoltaic technology: Relay dye boosts efficiency"</em>, <strong>Nature Photonics</strong>, 2009, 3: 373 - 374. <a href="http://doi:10.1038/nphoton.2009.108">doi:10.1038/nphoton.2009.108</a>
</li>
<li class="pub">D J Farrell, W G J H M van Sark, S T Velthuijsen and R E I Schropp, R, 2010, <em>"Using amorphous silicon solar cells to boost the viability of luminescent solar concentrators"</em>. <strong>Physica Status Solidi (c)</strong>, 7: 1045â1048. <a href="http://dx.doi.org/10.1002/pssc.200982866">doi:10.1002/pssc.200982866</a>
</li>
<li class="publist">D J Farrell, <em>The next generation of Building Integrated Photovoltaics.</em>", presented to <a class="loud" href="http://www.arup.com">Arup Associates</a>, London 2009.
</li>
</ul>
</div>
</div>
</body>
</html>
|
danieljfarrell/website-2.0
|
958a024bc1b5bfe3318b1cd935be574afdb308ab
|
Bringing over some files from the online version.
|
diff --git a/contact/index.html b/contact/index.html
index 94c6dec..85daf83 100644
--- a/contact/index.html
+++ b/contact/index.html
@@ -1,90 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green">
<a href="../../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="../../research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="../../freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="#" title="contact" class="current" ><span>contact</span></a>
</li>
</ul>
</div>
<hr class="space">
<div class="span-13 colborder">
<div class="span-6 ">
<h6>
Imperial College London — <a href="http://www.imperial.ac.uk/qpv">Quantum Photovoltaics Group</a>
</h6>
<hr class="space">
<a href="http://maps.google.co.uk/maps/place?cid=17449252295702573143&q=imperial+college+london+physics+department&hl=en&gl=uk"><img src="ic.jpg" alt="Location of Imperial College Department of Physics" width="200"></a>
<hr class="space">
<p>
Dr. Daniel J Farrell<br>
Experimental Solid State Physics<br>
Blackett Laboratory,<br>
Imperial College London,<br>
Prince Consort Road,<br>
London SW7 2AZ.<br>
U.K.<br>
e-mail: <a href="mailto:[email protected]">[email protected]</a><br>
tel: (+44) - (0)20 7594 7305
</p>
</div>
<div class="span-3 push-2 ">
<h6>
On Skype
</h6>
<hr class="space">
<!--
Skype 'My status' button
http://www.skype.com/go/skypebuttons
-->
<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js">
</script> <a href="skype:daniel.james.farrell?call"><img src="http://mystatus.skype.com/balloon/daniel%2Ejames.farrell" style="border: none;" width="150" height="60" alt="My status"></a>
</div>
</div>
<div class="span-6 last">
<div>
<h3><span class="alt">Follow me here...</span></h3>
<a href="http://twitter.com/danieljfarrell"> <img src="../img/twitter.jpg" width="35"/></a>
<a href="http://linkedin.com/in/danieljfarrell"> <img src="../img/linkedin.jpg" width="33"/></a>
<a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"/></a>
</div>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/index.html b/freebies/index.html
index d15583b..bcd709a 100644
--- a/freebies/index.html
+++ b/freebies/index.html
@@ -1,113 +1,128 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="../research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="#" title="freebies" class="current"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<!-- Body -->
<div class="span-13 colborder">
<h3>
Freebies â everyone likes freebies!
</h3>
<p>
A collection of interesting things related to photovoltaics and my research.
</p>
<hr class="space">
<h5>PVTrace</h5>
<div class="span-6">
<a href="pvtrace/"><img src="pvtrace/pvtrace.jpg" width="200" class="push-0 " alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a>
<p class="pcaption">
PVTrace: Optical monte-carlo simulation of luminescent photovoltaic devices
</p>
</div>
<p>
- <strong>PVTrace</strong> will soon become open-source software for academic use. PVTrace can be licensed for commercial applications or I can be hired for consulting projects. Interested in knowing more, <a href="../contact/"> get in contact</a>.
+ <strong>PVTrace</strong> will soon become open-source software for academic use. PVTrace can be licensed for commercial applications or I can be hired for consulting projects. Interested in knowing more? <a href="../contact/"> Please get in contact</a>.
</p>
<hr class="">
<h5>Quantum of Sol</h5>
<div class="span-6">
<a href="quantumofsol/"><img src="qos.png" width="200" class="push-0 " alt="Quantum of Sol: the next generation of solar cells in a WebApp."></a>
<p class="pcaption">
Quantum of Sol: Now a Webapp!
</p>
</div>
<p>
- <strong>Quantum of Sol</strong> was our highly successful outreach adventure at the prestigious <a href="http://royalsociety.org/quantum-of-sol---the-next-generation-of-solar-cells/">Royal Summer Science Exhibition 2009</a>. Imperial College Physic students Matthias Kraft and Aidan Taylor joined me for their summer research project 2010 and made a <a href="quantumofsol/">Web app</a> to explained solar energy conversion. Their work illustrates the current/voltage trade off with conversional solar cells, and highlights how this can be circumvented by using the hot-carrier approach.
+ <strong>Quantum of Sol</strong> was our highly successful outreach adventure at the prestigious <a href="http://royalsociety.org/quantum-of-sol---the-next-generation-of-solar-cells/">Royal Summer Science Exhibition 2009</a>. Imperial College Physics students Matthias Kraft and Aidan Taylor joined me for their summer research project in 2010 and made a <a href="quantumofsol/">Web app</a> to explain solar energy conversion. Their work illustrates the current/voltage trade off with conversional solar cells, and highlights how this can be circumvented by using the hot-carrier approach.
</p>
<hr class="">
<h5>pydaq</h5>
<div class="span-5 append-1">
<img src="DAQ.png" width="200" class="push-0" alt="Python software to control the analogue ports of National instruments DAQ 6008.">
<p class="pcaption">
Python control of USB NI-DAQ.
</p>
</div>
<p>
<strong>National instruments</strong> make a very versatile USB Data Acquisition (DAQ) box. Let's face it, using the NI C API and programming on Windows are not the most inspiring tasks. I wrote a small python class that makes using this DAQ on Windows a bit more fun! You can find the pydaq project <a href="http://github.com/danieljfarrell/pydaq"> here on github.com</a>. It makes it simple to access the current and voltage values on any of the port:
<div class="span-6">
<script src="http://gist.github.com/518737.js?file=gistfile1.py"></script>
</div>
</p>
</div>
<div>
<h3><span class="alt">Follow me here...</span></h3>
<a href="http://twitter.com/danieljfarrell"> <img src="../img/twitter.jpg" width="35"/></a>
<a href="http://linkedin.com/in/danieljfarrell"> <img src="../img/linkedin.jpg" width="33"/></a>
<a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"/></a>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/pvtrace/index.html b/freebies/pvtrace/index.html
index 77514df..756e518 100644
--- a/freebies/pvtrace/index.html
+++ b/freebies/pvtrace/index.html
@@ -1,116 +1,131 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London" />
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated" />
<meta name="author" content="Daniel J Farrell" />
<title>Daniel J Farrell</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="../../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../../blueprint/print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection" />
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">Daniel J Farrell</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green"><a href="../../" title="home" ><span>home</span></a></li>
<li class="green"><a href="../../research/" title="research"><span>research</span></a></li>
<li class="green"><a href="../" title="freebies" class="current"><span>freebies</span></a></li>
<li class="green" ><a href="../../contact/" title="contact"><span>contact</span></a></li>
</ul>
</div>
</div>
<hr class="space">
<!-- Body -->
<div class="span-12 colborder">
<h3>PVTrace</h3>
<h3 class="alt">Optical monte-carlo simulation of luminescent photovoltaic devices</h3>
<p>PVTrace builds on over 3 years of research and development of Monte-Carlo simulation codes at Imperial College. It is the latest version of my luminescent concentrator simulation software and brings together some advanced concepts including:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Constructive_solid_geometry">Constructive Solid Geometry</a></li>
<li>Generalised 3D ray intersections (ray optics):
<ul>
<li>ray-box</li>
<li>ray-cylinder</li>
<li>ray-CSG object</li>
</ul></li>
<li>Arbitrary 3D object transformations:
<ul>
<li>translation</li>
<li>rotation</li>
<li>scaling and skewing</li>
</ul></li>
<li>Photon path visualiser</li>
<li>Statistical collection of photonic properties:
<ul>
<li>wavelength</li>
<li>direction</li>
<li>polarisation (no appear soon)</li>
</ul></li>
<li>Fresnel reflection and refraction</li>
<li>Sampling from overlapping statistical distributions.</li>
</ul>
<p>The complex solid geometry feature means that we are no limited to simulation of primitive shapes. Any shape that can be made using a union, difference or intersection operation can be made. In principle any shape can be simulated.</p>
<p>PVTrace is entirely written in Python. Using the <a href="http://numpy.scipy.org">numpy</a> and <a href="http://www.scipy.org">scipy</a> libraries. The philosophy here is to use a programming language that allows for rapid development rather than speed of execution. On a single core machine PVTrace only takes a few minutes to produce sensible results which for me is an acceptable trade-off considering the pleasure it is to write and debug in Python!</p>
</div>
<!-- Column -->
<div class="span-6 last">
<div class="success">
<strong>PVTrace</strong> is become open-source for the benefit of the PV community! PVTrace can be licensed for commercial work or consulting projects. Become a developer soon...
</div>
<hr class="space">
<hr class="space">
<div>
<a href="pvtrace.jpg"><img src="pvtrace.jpg" width="230" class="push-0 shadow" alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a><p class="pcaption">Screenshot of pvtrace running.</p>
</div>
<hr class="space">
<hr class="space">
<div>
<img src="http://upload.wikimedia.org/wikipedia/commons/8/8b/Csg_tree.png" width="240" class="push-0 shadow" alt="Constructive solid geometry. "><p class="pcaption">Constructive solid geometry operations.</p>
</div>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/quantumofsol/index.html b/freebies/quantumofsol/index.html
index 8e8b264..08b442d 100755
--- a/freebies/quantumofsol/index.html
+++ b/freebies/quantumofsol/index.html
@@ -1,71 +1,87 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
NewApplication
Created by You on April 9, 2010.
Copyright 2010, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>NewApplication</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading NewApplication...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
+
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/googlecb21ac6f6f994c68.html b/googlecb21ac6f6f994c68.html
new file mode 100644
index 0000000..2fa168a
--- /dev/null
+++ b/googlecb21ac6f6f994c68.html
@@ -0,0 +1 @@
+google-site-verification: googlecb21ac6f6f994c68.html
\ No newline at end of file
diff --git a/research/index.html b/research/index.html
index 32271ce..ea189f1 100644
--- a/research/index.html
+++ b/research/index.html
@@ -1,156 +1,171 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell â research
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="#" title="research" class="current"><span>research</span></a>
</li>
<li class="green">
<a href="../freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<h3>
Research interests
</h3>
<p>
- Efficiency and cost drive photovoltaic research. During my PhD I worked on a novel optical concentrator with the aim of reducing cost. Then during my postdoc I switched gears an looked at what is ultimately possible in terms of high efficiency. Below I briefly discuss my experience in these areas.
+ Efficiency and cost drive photovoltaic research. During my PhD I worked on a novel optical concentrator with the aim of reducing cost. Then during my postdoc I switched gears and looked at what is ultimately possible in terms of high efficiency. Below I briefly discuss my experience in these areas.
</p>
<h5>
Luminescent solar concentrators
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>The first quantum dot based luminescent concentrator tandem
</li>
<li>State of the art optical Monte-Carlo model: <a href="../freebies/">PVTrace</a>.
</li>
</ul>
</div>
<p>
One purely optical approach to the reduction of costs is the Luminescent Solar Concentrator (LSC).
</p>
<p>
- Cost reduction is achieved by replacing the light harvesting area of conventional solar panels by low-cost, planar luminescent waveguides. A small area of solar cells attached to the edges, therefore reducing the cost of the whole device.
+ Cost reduction is achieved by replacing the light harvesting area of conventional solar panels by low-cost, planar luminescent waveguides. A small strips of solar cells are attached to the edges therefore reducing the cost of the whole device.
</p>
<p>
What I call âfirst generationâ luminescent concentrators were devised in the late 1970s and offered realistic savings when the cost-per-Watt of flat-plate silicon was ~30$/W. Research into LSCs has continued to the present day; focusing on how new materials such as colloidal nano-structures and photonic structures can augment traditional designs. However, the best of these structures are still only capable of transporting ~10% of incident photons to the cells. In these devices, photon transport towards the cells is severely hindered by multiple reabsorption events that redirect photons out of waveguide modes, and limit devices to low efficiency.
</p>
<p>
Research interests are now focusing on âsecond generationâ approaches, which attempt to enhance the optical transport, and should enable high power conversion efficiency at low cost, provided the optical properties can be pushed to the limit. If this is achieved, the theoretical efficiency limits of luminescent concentrators are the same as conventional solar cells, ~30%.
</p>
<h5>
Hot-carrier solar cells
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>Rate model for the hot-carrier solar cell
</li>
<li>Perturbation theory analysis of cooling.
</li>
</ul>
</div>
<p>
The hot-carrier solar cell is one of the most ambitious attempts at making the ultimate photovoltaic converter. It has the potential to reach 84% power conversion efficiency.
</p>
<p>
- In this concept, thermalisation losses are eliminated using a mechanism which prevents charge carriers from interacting with the lattice. Energy that would otherwise transfer to the lattice, and lost, is stored in the carrier population as excess heat. In theory this enables very high conversion efficiencies because a low bandgap material can be chosen to maximise absorption across the spectrum, and yet still achieve high voltage per carrier.
+ In this concept, thermalisation losses are eliminated using a mechanism which prevents charge carriers from interacting with the lattice. Energy that would otherwise transfer to the lattice, and be lost, is stored in the carrier population as excess heat. In theory this enables very high conversion efficiency because a low bandgap material can be chosen to maximise absorption across the spectrum, and yet still achieve high voltage per carrier.
</p>
<p>
- The good voltage performance is achieved using <em>'energy selective contacts'</em> (the 'pipes' that extract the electrons from the conduction band and holes from the valence band in the diagram). These contacts play 2 crucial roles: (1) they prevent the hot-carrier population from being cooled when in contact with the metal electrodes, and (2) the voltage of the solar cell is determined by the energy separation between the electron and hole contact. Thus the hot-carrier solar cell can the best of both worlds: a high current by using a low bandgap absorber, and a high voltage from using energy selective contacts.
+ The good voltage performance is achieved using <em>'energy selective contacts'</em> (the 'pipes' that extract the electrons from the conduction band and holes from the valence band in the diagram). These contacts play two crucial roles: (1) they prevent the hot-carrier population from being cooled when in contact with the metal electrodes, and (2) the voltage of the solar cell is determined by the energy separation between the electron and hole contact. Thus the hot-carrier solar cell can achieve the best of both worlds: a high current by using a low bandgap absorber, and a high voltage from using energy selective contacts.
</p>
<p>
- To better understand the current/voltage trade off that occurs in conventional solar cell, and how this is improved by using hot-carrier, try the <a href="../freebies/quantumofsol/">Quantum of Sol Web App</a>.
+ To better understand the current/voltage trade off that occurs in conventional solar cells, and how this can be improved by using hot-carrier, try the <a href="../freebies/quantumofsol/">Quantum of Sol Web App</a> (Firefox or Safari is needed.).
</p>
</div>
<div class="span-6 last">
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="../img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="../img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="../img/lsc.jpg" width="200" class="top push-0 shadow" alt="Luminescent solar concentrators.">
</p>
<div class="pcaption">
<p>
Luminescent solar concentrators.
</p>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="hccell.jpg" width="200" class="top push-0 shadow" alt="Hot-carrier solar cell.">
</p>
<div class="pcaption">
<p>
The hot-carrier solar cell.
</p>
</div>
</div>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/sitemap.xml b/sitemap.xml
new file mode 100644
index 0000000..3ec8f8a
--- /dev/null
+++ b/sitemap.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
+ xmlns="http://www.sitemaps.org/schemas/sitemap-image/1.1"
+ xmlns="http://www.sitemaps.org/schemas/sitemap-video/1.1">
+ <url>
+ <loc>http://daniel.farrell.name/index.html</loc>
+ <image:image>
+ <image:loc>http://daniel.farrell.name/img/daniel_j_farrell.jpg</image:loc>
+ </image:image>
+ </url>
+ <url>
+ <loc>http://daniel.farrell.name/research/index.html</loc>
+ </url>
+ <url>
+ <loc>http://daniel.farrell.name/freebies/index.html</loc>
+ </url>
+ <url>
+ <loc>http://daniel.farrell.name/freebies/pvtrace/index.html</loc>
+ <image:image>
+ <image:loc>http://daniel.farrell.name/freebies/pvtrace/pvtrace.jpg</image:loc>
+ </image:image>
+ </url>
+ <url>
+ <loc>http://daniel.farrell.name/freebies/quantumofsol/index.html</loc>
+ <image:image>
+ <image:loc>http://daniel.farrell.name/freebies/qos.jpg</image:loc>
+ </image:image>
+ </url>
+ <url>
+ <loc>http://daniel.farrell.name/contact/index.html</loc>
+ </url>
+</urlset>
\ No newline at end of file
|
danieljfarrell/website-2.0
|
ffe76e2d605f9a0bff7d92fdcb631b36d947fc62
|
Added Google Analytics and removed lightbox (because it didn't work).
|
diff --git a/contact/index.html b/contact/index.html
index 94c6dec..85daf83 100644
--- a/contact/index.html
+++ b/contact/index.html
@@ -1,90 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green">
<a href="../../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="../../research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="../../freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="#" title="contact" class="current" ><span>contact</span></a>
</li>
</ul>
</div>
<hr class="space">
<div class="span-13 colborder">
<div class="span-6 ">
<h6>
Imperial College London — <a href="http://www.imperial.ac.uk/qpv">Quantum Photovoltaics Group</a>
</h6>
<hr class="space">
<a href="http://maps.google.co.uk/maps/place?cid=17449252295702573143&q=imperial+college+london+physics+department&hl=en&gl=uk"><img src="ic.jpg" alt="Location of Imperial College Department of Physics" width="200"></a>
<hr class="space">
<p>
Dr. Daniel J Farrell<br>
Experimental Solid State Physics<br>
Blackett Laboratory,<br>
Imperial College London,<br>
Prince Consort Road,<br>
London SW7 2AZ.<br>
U.K.<br>
e-mail: <a href="mailto:[email protected]">[email protected]</a><br>
tel: (+44) - (0)20 7594 7305
</p>
</div>
<div class="span-3 push-2 ">
<h6>
On Skype
</h6>
<hr class="space">
<!--
Skype 'My status' button
http://www.skype.com/go/skypebuttons
-->
<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js">
</script> <a href="skype:daniel.james.farrell?call"><img src="http://mystatus.skype.com/balloon/daniel%2Ejames.farrell" style="border: none;" width="150" height="60" alt="My status"></a>
</div>
</div>
<div class="span-6 last">
<div>
<h3><span class="alt">Follow me here...</span></h3>
<a href="http://twitter.com/danieljfarrell"> <img src="../img/twitter.jpg" width="35"/></a>
<a href="http://linkedin.com/in/danieljfarrell"> <img src="../img/linkedin.jpg" width="33"/></a>
<a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"/></a>
</div>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/index.html b/freebies/index.html
index 51e68b0..bcd709a 100644
--- a/freebies/index.html
+++ b/freebies/index.html
@@ -1,113 +1,128 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="../research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="#" title="freebies" class="current"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<!-- Body -->
<div class="span-13 colborder">
<h3>
Freebies â everyone likes freebies!
</h3>
<p>
A collection of interesting things related to photovoltaics and my research.
</p>
<hr class="space">
<h5>PVTrace</h5>
<div class="span-6">
<a href="pvtrace/"><img src="pvtrace/pvtrace.jpg" width="200" class="push-0 " alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a>
<p class="pcaption">
PVTrace: Optical monte-carlo simulation of luminescent photovoltaic devices
</p>
</div>
<p>
<strong>PVTrace</strong> will soon become open-source software for academic use. PVTrace can be licensed for commercial applications or I can be hired for consulting projects. Interested in knowing more? <a href="../contact/"> Please get in contact</a>.
</p>
<hr class="">
<h5>Quantum of Sol</h5>
<div class="span-6">
<a href="quantumofsol/"><img src="qos.png" width="200" class="push-0 " alt="Quantum of Sol: the next generation of solar cells in a WebApp."></a>
<p class="pcaption">
Quantum of Sol: Now a Webapp!
</p>
</div>
<p>
<strong>Quantum of Sol</strong> was our highly successful outreach adventure at the prestigious <a href="http://royalsociety.org/quantum-of-sol---the-next-generation-of-solar-cells/">Royal Summer Science Exhibition 2009</a>. Imperial College Physics students Matthias Kraft and Aidan Taylor joined me for their summer research project in 2010 and made a <a href="quantumofsol/">Web app</a> to explain solar energy conversion. Their work illustrates the current/voltage trade off with conversional solar cells, and highlights how this can be circumvented by using the hot-carrier approach.
</p>
<hr class="">
<h5>pydaq</h5>
<div class="span-5 append-1">
<img src="DAQ.png" width="200" class="push-0" alt="Python software to control the analogue ports of National instruments DAQ 6008.">
<p class="pcaption">
Python control of USB NI-DAQ.
</p>
</div>
<p>
<strong>National instruments</strong> make a very versatile USB Data Acquisition (DAQ) box. Let's face it, using the NI C API and programming on Windows are not the most inspiring tasks. I wrote a small python class that makes using this DAQ on Windows a bit more fun! You can find the pydaq project <a href="http://github.com/danieljfarrell/pydaq"> here on github.com</a>. It makes it simple to access the current and voltage values on any of the port:
<div class="span-6">
<script src="http://gist.github.com/518737.js?file=gistfile1.py"></script>
</div>
</p>
</div>
<div>
<h3><span class="alt">Follow me here...</span></h3>
<a href="http://twitter.com/danieljfarrell"> <img src="../img/twitter.jpg" width="35"/></a>
<a href="http://linkedin.com/in/danieljfarrell"> <img src="../img/linkedin.jpg" width="33"/></a>
<a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"/></a>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/pvtrace/index.html b/freebies/pvtrace/index.html
index dd95e8d..756e518 100644
--- a/freebies/pvtrace/index.html
+++ b/freebies/pvtrace/index.html
@@ -1,122 +1,131 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London" />
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated" />
<meta name="author" content="Daniel J Farrell" />
<title>Daniel J Farrell</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="../../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../../blueprint/print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection" />
-
- <!-- Lightbox -->
- <script type="text/javascript" src="js/prototype.js"></script>
- <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
- <script type="text/javascript" src="js/lightbox.js"></script>
- <link rel="stylesheet" href="../../blueprint/plugins/lightbox.css" type="text/css" media="screen" />
-
+
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">Daniel J Farrell</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green"><a href="../../" title="home" ><span>home</span></a></li>
<li class="green"><a href="../../research/" title="research"><span>research</span></a></li>
<li class="green"><a href="../" title="freebies" class="current"><span>freebies</span></a></li>
<li class="green" ><a href="../../contact/" title="contact"><span>contact</span></a></li>
</ul>
</div>
</div>
<hr class="space">
<!-- Body -->
<div class="span-12 colborder">
<h3>PVTrace</h3>
<h3 class="alt">Optical monte-carlo simulation of luminescent photovoltaic devices</h3>
<p>PVTrace builds on over 3 years of research and development of Monte-Carlo simulation codes at Imperial College. It is the latest version of my luminescent concentrator simulation software and brings together some advanced concepts including:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Constructive_solid_geometry">Constructive Solid Geometry</a></li>
<li>Generalised 3D ray intersections (ray optics):
<ul>
<li>ray-box</li>
<li>ray-cylinder</li>
<li>ray-CSG object</li>
</ul></li>
<li>Arbitrary 3D object transformations:
<ul>
<li>translation</li>
<li>rotation</li>
<li>scaling and skewing</li>
</ul></li>
<li>Photon path visualiser</li>
<li>Statistical collection of photonic properties:
<ul>
<li>wavelength</li>
<li>direction</li>
<li>polarisation (no appear soon)</li>
</ul></li>
<li>Fresnel reflection and refraction</li>
<li>Sampling from overlapping statistical distributions.</li>
</ul>
<p>The complex solid geometry feature means that we are no limited to simulation of primitive shapes. Any shape that can be made using a union, difference or intersection operation can be made. In principle any shape can be simulated.</p>
<p>PVTrace is entirely written in Python. Using the <a href="http://numpy.scipy.org">numpy</a> and <a href="http://www.scipy.org">scipy</a> libraries. The philosophy here is to use a programming language that allows for rapid development rather than speed of execution. On a single core machine PVTrace only takes a few minutes to produce sensible results which for me is an acceptable trade-off considering the pleasure it is to write and debug in Python!</p>
</div>
<!-- Column -->
<div class="span-6 last">
<div class="success">
<strong>PVTrace</strong> is become open-source for the benefit of the PV community! PVTrace can be licensed for commercial work or consulting projects. Become a developer soon...
</div>
<hr class="space">
<hr class="space">
<div>
- <a href="pvtrace.jpg" rel="lightbox" title="PVTrace: Optical monte-carlo simulation of luminescent photovoltaic devices"><img src="pvtrace.jpg" width="230" class="push-0 shadow" alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a><p class="pcaption">Screenshot of pvtrace running.</p>
+ <a href="pvtrace.jpg"><img src="pvtrace.jpg" width="230" class="push-0 shadow" alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a><p class="pcaption">Screenshot of pvtrace running.</p>
</div>
<hr class="space">
<hr class="space">
<div>
<img src="http://upload.wikimedia.org/wikipedia/commons/8/8b/Csg_tree.png" width="240" class="push-0 shadow" alt="Constructive solid geometry. "><p class="pcaption">Constructive solid geometry operations.</p>
</div>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/freebies/quantumofsol/index.html b/freebies/quantumofsol/index.html
index 8e8b264..08b442d 100755
--- a/freebies/quantumofsol/index.html
+++ b/freebies/quantumofsol/index.html
@@ -1,71 +1,87 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
NewApplication
Created by You on April 9, 2010.
Copyright 2010, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>NewApplication</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading NewApplication...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
+
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/index.html b/index.html
index 1078b17..c55f16a 100644
--- a/index.html
+++ b/index.html
@@ -1,88 +1,104 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<meta name="microid" content="mailto+http:sha1:ab095e627455a292fb5fd60550b0fa4a2105ae79">
<link rel="openid.server" href="http://openid.claimid.com/server">
<link rel="openid.delegate" href="http://daniel.farrell.name">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
+
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="#" title="home" class="current"><span>home</span></a>
</li>
<li class="green">
<a href="research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<div class="span-6 append-1">
<img src="img/daniel_j_farrell.jpg" class="top push-0 shadow" alt="test" width="240">
</div>
<h6>
About
</h6>
<p>
I'm Daniel Farrell, a post doctoral researcher in the Experimental Solid State Physics group at Imperial College London. I work on photovoltaic energy conversion, and I'm particularly interested in hot-carrier solar cells and spectral modification with luminescent materials.
</p>
<hr class="space">
<h6>
Experience
</h6>
<ul>
<li>2009 - present, Research Associate â Imperial College London. Fabricated, characterised and simulated the first quantum dot based luminescent solar concentrator tandem. Wrote optical Monte-Carlo software: <a href="freebies/">pvtrace</a>.
</li>
<li>2004 - 2009, Postgraduate Student â Imperial College London. Developed a rate model for the hot-carrier solar cell. Performed perturbation theory analysis on cooling in quantum dots.
</li>
</ul>
</div>
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<div class="span-13 last">
<hr>
<h5>Recent publications and talks</h5>
<ul class="publist">
<li class="pub">D J Farrell and N J Ekins-Daukes, <em>"Photovoltaic technology: Relay dye boosts efficiency"</em>, <strong>Nature Photonics</strong>, 2009, 3: 373 - 374. <a href="http://doi:10.1038/nphoton.2009.108">doi:10.1038/nphoton.2009.108</a>
</li>
<li class="pub">D J Farrell, W G J H M van Sark, S T Velthuijsen and R E I Schropp, R, 2010, <em>"Using amorphous silicon solar cells to boost the viability of luminescent solar concentrators"</em>. <strong>Physica Status Solidi (c)</strong>, 7: 1045â1048. <a href="http://dx.doi.org/10.1002/pssc.200982866">doi:10.1002/pssc.200982866</a>
</li>
<li class="publist">D J Farrell, <em>The next generation of Building Integrated Photovoltaics.</em>", presented to <a class="loud" href="http://www.arup.com">Arup Associates</a>, London 2009.
</li>
</ul>
</div>
</div>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
diff --git a/research/index.html b/research/index.html
index 99c26ed..ea189f1 100644
--- a/research/index.html
+++ b/research/index.html
@@ -1,156 +1,171 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell â research
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="#" title="research" class="current"><span>research</span></a>
</li>
<li class="green">
<a href="../freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<h3>
Research interests
</h3>
<p>
Efficiency and cost drive photovoltaic research. During my PhD I worked on a novel optical concentrator with the aim of reducing cost. Then during my postdoc I switched gears and looked at what is ultimately possible in terms of high efficiency. Below I briefly discuss my experience in these areas.
</p>
<h5>
Luminescent solar concentrators
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>The first quantum dot based luminescent concentrator tandem
</li>
<li>State of the art optical Monte-Carlo model: <a href="../freebies/">PVTrace</a>.
</li>
</ul>
</div>
<p>
One purely optical approach to the reduction of costs is the Luminescent Solar Concentrator (LSC).
</p>
<p>
Cost reduction is achieved by replacing the light harvesting area of conventional solar panels by low-cost, planar luminescent waveguides. A small strips of solar cells are attached to the edges therefore reducing the cost of the whole device.
</p>
<p>
What I call âfirst generationâ luminescent concentrators were devised in the late 1970s and offered realistic savings when the cost-per-Watt of flat-plate silicon was ~30$/W. Research into LSCs has continued to the present day; focusing on how new materials such as colloidal nano-structures and photonic structures can augment traditional designs. However, the best of these structures are still only capable of transporting ~10% of incident photons to the cells. In these devices, photon transport towards the cells is severely hindered by multiple reabsorption events that redirect photons out of waveguide modes, and limit devices to low efficiency.
</p>
<p>
Research interests are now focusing on âsecond generationâ approaches, which attempt to enhance the optical transport, and should enable high power conversion efficiency at low cost, provided the optical properties can be pushed to the limit. If this is achieved, the theoretical efficiency limits of luminescent concentrators are the same as conventional solar cells, ~30%.
</p>
<h5>
Hot-carrier solar cells
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>Rate model for the hot-carrier solar cell
</li>
<li>Perturbation theory analysis of cooling.
</li>
</ul>
</div>
<p>
The hot-carrier solar cell is one of the most ambitious attempts at making the ultimate photovoltaic converter. It has the potential to reach 84% power conversion efficiency.
</p>
<p>
In this concept, thermalisation losses are eliminated using a mechanism which prevents charge carriers from interacting with the lattice. Energy that would otherwise transfer to the lattice, and be lost, is stored in the carrier population as excess heat. In theory this enables very high conversion efficiency because a low bandgap material can be chosen to maximise absorption across the spectrum, and yet still achieve high voltage per carrier.
</p>
<p>
The good voltage performance is achieved using <em>'energy selective contacts'</em> (the 'pipes' that extract the electrons from the conduction band and holes from the valence band in the diagram). These contacts play two crucial roles: (1) they prevent the hot-carrier population from being cooled when in contact with the metal electrodes, and (2) the voltage of the solar cell is determined by the energy separation between the electron and hole contact. Thus the hot-carrier solar cell can achieve the best of both worlds: a high current by using a low bandgap absorber, and a high voltage from using energy selective contacts.
</p>
<p>
To better understand the current/voltage trade off that occurs in conventional solar cells, and how this can be improved by using hot-carrier, try the <a href="../freebies/quantumofsol/">Quantum of Sol Web App</a> (Firefox or Safari is needed.).
</p>
</div>
<div class="span-6 last">
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="../img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="../img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="../img/lsc.jpg" width="200" class="top push-0 shadow" alt="Luminescent solar concentrators.">
</p>
<div class="pcaption">
<p>
Luminescent solar concentrators.
</p>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="hccell.jpg" width="200" class="top push-0 shadow" alt="Hot-carrier solar cell.">
</p>
<div class="pcaption">
<p>
The hot-carrier solar cell.
</p>
</div>
</div>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17989763-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
</body>
</html>
|
danieljfarrell/website-2.0
|
7949a9dabd65feaff52e736007c0266d342f5740
|
Fixing some typos
|
diff --git a/blueprint/.DS_Store b/blueprint/.DS_Store
index 34cc118..83ad512 100644
Binary files a/blueprint/.DS_Store and b/blueprint/.DS_Store differ
diff --git a/blueprint/plugins/.DS_Store b/blueprint/plugins/.DS_Store
index 32ccb90..216fcd2 100644
Binary files a/blueprint/plugins/.DS_Store and b/blueprint/plugins/.DS_Store differ
diff --git a/freebies/index.html b/freebies/index.html
index d15583b..51e68b0 100644
--- a/freebies/index.html
+++ b/freebies/index.html
@@ -1,113 +1,113 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="../research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="#" title="freebies" class="current"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<!-- Body -->
<div class="span-13 colborder">
<h3>
Freebies â everyone likes freebies!
</h3>
<p>
A collection of interesting things related to photovoltaics and my research.
</p>
<hr class="space">
<h5>PVTrace</h5>
<div class="span-6">
<a href="pvtrace/"><img src="pvtrace/pvtrace.jpg" width="200" class="push-0 " alt="pvtrace: optical monte-carlo simulation of luminescent photovoltaic devices."></a>
<p class="pcaption">
PVTrace: Optical monte-carlo simulation of luminescent photovoltaic devices
</p>
</div>
<p>
- <strong>PVTrace</strong> will soon become open-source software for academic use. PVTrace can be licensed for commercial applications or I can be hired for consulting projects. Interested in knowing more, <a href="../contact/"> get in contact</a>.
+ <strong>PVTrace</strong> will soon become open-source software for academic use. PVTrace can be licensed for commercial applications or I can be hired for consulting projects. Interested in knowing more? <a href="../contact/"> Please get in contact</a>.
</p>
<hr class="">
<h5>Quantum of Sol</h5>
<div class="span-6">
<a href="quantumofsol/"><img src="qos.png" width="200" class="push-0 " alt="Quantum of Sol: the next generation of solar cells in a WebApp."></a>
<p class="pcaption">
Quantum of Sol: Now a Webapp!
</p>
</div>
<p>
- <strong>Quantum of Sol</strong> was our highly successful outreach adventure at the prestigious <a href="http://royalsociety.org/quantum-of-sol---the-next-generation-of-solar-cells/">Royal Summer Science Exhibition 2009</a>. Imperial College Physic students Matthias Kraft and Aidan Taylor joined me for their summer research project 2010 and made a <a href="quantumofsol/">Web app</a> to explained solar energy conversion. Their work illustrates the current/voltage trade off with conversional solar cells, and highlights how this can be circumvented by using the hot-carrier approach.
+ <strong>Quantum of Sol</strong> was our highly successful outreach adventure at the prestigious <a href="http://royalsociety.org/quantum-of-sol---the-next-generation-of-solar-cells/">Royal Summer Science Exhibition 2009</a>. Imperial College Physics students Matthias Kraft and Aidan Taylor joined me for their summer research project in 2010 and made a <a href="quantumofsol/">Web app</a> to explain solar energy conversion. Their work illustrates the current/voltage trade off with conversional solar cells, and highlights how this can be circumvented by using the hot-carrier approach.
</p>
<hr class="">
<h5>pydaq</h5>
<div class="span-5 append-1">
<img src="DAQ.png" width="200" class="push-0" alt="Python software to control the analogue ports of National instruments DAQ 6008.">
<p class="pcaption">
Python control of USB NI-DAQ.
</p>
</div>
<p>
<strong>National instruments</strong> make a very versatile USB Data Acquisition (DAQ) box. Let's face it, using the NI C API and programming on Windows are not the most inspiring tasks. I wrote a small python class that makes using this DAQ on Windows a bit more fun! You can find the pydaq project <a href="http://github.com/danieljfarrell/pydaq"> here on github.com</a>. It makes it simple to access the current and voltage values on any of the port:
<div class="span-6">
<script src="http://gist.github.com/518737.js?file=gistfile1.py"></script>
</div>
</p>
</div>
<div>
<h3><span class="alt">Follow me here...</span></h3>
<a href="http://twitter.com/danieljfarrell"> <img src="../img/twitter.jpg" width="35"/></a>
<a href="http://linkedin.com/in/danieljfarrell"> <img src="../img/linkedin.jpg" width="33"/></a>
<a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"/></a>
</div>
</div>
</body>
</html>
diff --git a/index.html b/index.html
index dc93877..1078b17 100644
--- a/index.html
+++ b/index.html
@@ -1,88 +1,88 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<meta name="microid" content="mailto+http:sha1:ab095e627455a292fb5fd60550b0fa4a2105ae79">
<link rel="openid.server" href="http://openid.claimid.com/server">
<link rel="openid.delegate" href="http://daniel.farrell.name">
<title>
Daniel J Farrell
</title><!-- Framework CSS -->
<link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="#" title="home" class="current"><span>home</span></a>
</li>
<li class="green">
<a href="research/" title="research"><span>research</span></a>
</li>
<li class="green">
<a href="freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<div class="span-6 append-1">
<img src="img/daniel_j_farrell.jpg" class="top push-0 shadow" alt="test" width="240">
</div>
<h6>
About
</h6>
<p>
- I'm Daniel Farrell, a post doctoral researcher in the Experimental Solid State Physics group at Imperial College London. I research photovoltaic energy conversion, I'm particularly interested in hot-carrier solar cells and spectral modification with luminescent materials.
+ I'm Daniel Farrell, a post doctoral researcher in the Experimental Solid State Physics group at Imperial College London. I work on photovoltaic energy conversion, and I'm particularly interested in hot-carrier solar cells and spectral modification with luminescent materials.
</p>
<hr class="space">
<h6>
Experience
</h6>
<ul>
<li>2009 - present, Research Associate â Imperial College London. Fabricated, characterised and simulated the first quantum dot based luminescent solar concentrator tandem. Wrote optical Monte-Carlo software: <a href="freebies/">pvtrace</a>.
</li>
<li>2004 - 2009, Postgraduate Student â Imperial College London. Developed a rate model for the hot-carrier solar cell. Performed perturbation theory analysis on cooling in quantum dots.
</li>
</ul>
</div>
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<div class="span-13 last">
<hr>
<h5>Recent publications and talks</h5>
<ul class="publist">
<li class="pub">D J Farrell and N J Ekins-Daukes, <em>"Photovoltaic technology: Relay dye boosts efficiency"</em>, <strong>Nature Photonics</strong>, 2009, 3: 373 - 374. <a href="http://doi:10.1038/nphoton.2009.108">doi:10.1038/nphoton.2009.108</a>
</li>
<li class="pub">D J Farrell, W G J H M van Sark, S T Velthuijsen and R E I Schropp, R, 2010, <em>"Using amorphous silicon solar cells to boost the viability of luminescent solar concentrators"</em>. <strong>Physica Status Solidi (c)</strong>, 7: 1045â1048. <a href="http://dx.doi.org/10.1002/pssc.200982866">doi:10.1002/pssc.200982866</a>
</li>
<li class="publist">D J Farrell, <em>The next generation of Building Integrated Photovoltaics.</em>", presented to <a class="loud" href="http://www.arup.com">Arup Associates</a>, London 2009.
</li>
</ul>
</div>
</div>
</body>
</html>
diff --git a/research/index.html b/research/index.html
index 32271ce..99c26ed 100644
--- a/research/index.html
+++ b/research/index.html
@@ -1,156 +1,156 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Description of Daniel J Farrell's research at Imperial College London">
<meta name="keywords" content="physics photovoltaics solar cells energy luminescent concentrators hot-carriers PV building integrated">
<meta name="author" content="Daniel J Farrell">
<title>
Daniel J Farrell â research
</title><!-- Framework CSS -->
<link rel="stylesheet" href="../blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/print.css" type="text/css" media="print"><!--[if IE]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin -->
<link rel="stylesheet" href="../blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../blueprint/plugins/navigation/sliding.css" type="text/css" media="screen, projection">
</head>
<body>
<hr class="space">
<div class="container">
<div class="span-21 header">
<div class="span-6">
<h1 class="light">
Daniel J Farrell
</h1>
</div>
<div class="push-1 span-13 last">
<ul class="green">
<li class="green">
<a href="../" title="home"><span>home</span></a>
</li>
<li class="green">
<a href="#" title="research" class="current"><span>research</span></a>
</li>
<li class="green">
<a href="../freebies/" title="freebies"><span>freebies</span></a>
</li>
<li class="green">
<a href="../contact/" title="contact"><span>contact</span></a>
</li>
</ul>
</div>
</div>
<hr class="space">
<div class="span-13 colborder">
<h3>
Research interests
</h3>
<p>
- Efficiency and cost drive photovoltaic research. During my PhD I worked on a novel optical concentrator with the aim of reducing cost. Then during my postdoc I switched gears an looked at what is ultimately possible in terms of high efficiency. Below I briefly discuss my experience in these areas.
+ Efficiency and cost drive photovoltaic research. During my PhD I worked on a novel optical concentrator with the aim of reducing cost. Then during my postdoc I switched gears and looked at what is ultimately possible in terms of high efficiency. Below I briefly discuss my experience in these areas.
</p>
<h5>
Luminescent solar concentrators
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>The first quantum dot based luminescent concentrator tandem
</li>
<li>State of the art optical Monte-Carlo model: <a href="../freebies/">PVTrace</a>.
</li>
</ul>
</div>
<p>
One purely optical approach to the reduction of costs is the Luminescent Solar Concentrator (LSC).
</p>
<p>
- Cost reduction is achieved by replacing the light harvesting area of conventional solar panels by low-cost, planar luminescent waveguides. A small area of solar cells attached to the edges, therefore reducing the cost of the whole device.
+ Cost reduction is achieved by replacing the light harvesting area of conventional solar panels by low-cost, planar luminescent waveguides. A small strips of solar cells are attached to the edges therefore reducing the cost of the whole device.
</p>
<p>
What I call âfirst generationâ luminescent concentrators were devised in the late 1970s and offered realistic savings when the cost-per-Watt of flat-plate silicon was ~30$/W. Research into LSCs has continued to the present day; focusing on how new materials such as colloidal nano-structures and photonic structures can augment traditional designs. However, the best of these structures are still only capable of transporting ~10% of incident photons to the cells. In these devices, photon transport towards the cells is severely hindered by multiple reabsorption events that redirect photons out of waveguide modes, and limit devices to low efficiency.
</p>
<p>
Research interests are now focusing on âsecond generationâ approaches, which attempt to enhance the optical transport, and should enable high power conversion efficiency at low cost, provided the optical properties can be pushed to the limit. If this is achieved, the theoretical efficiency limits of luminescent concentrators are the same as conventional solar cells, ~30%.
</p>
<h5>
Hot-carrier solar cells
</h5>
<div class="span-5 success ">
<h6>
Key Contributions
</h6>
<ul>
<li>Rate model for the hot-carrier solar cell
</li>
<li>Perturbation theory analysis of cooling.
</li>
</ul>
</div>
<p>
The hot-carrier solar cell is one of the most ambitious attempts at making the ultimate photovoltaic converter. It has the potential to reach 84% power conversion efficiency.
</p>
<p>
- In this concept, thermalisation losses are eliminated using a mechanism which prevents charge carriers from interacting with the lattice. Energy that would otherwise transfer to the lattice, and lost, is stored in the carrier population as excess heat. In theory this enables very high conversion efficiencies because a low bandgap material can be chosen to maximise absorption across the spectrum, and yet still achieve high voltage per carrier.
+ In this concept, thermalisation losses are eliminated using a mechanism which prevents charge carriers from interacting with the lattice. Energy that would otherwise transfer to the lattice, and be lost, is stored in the carrier population as excess heat. In theory this enables very high conversion efficiency because a low bandgap material can be chosen to maximise absorption across the spectrum, and yet still achieve high voltage per carrier.
</p>
<p>
- The good voltage performance is achieved using <em>'energy selective contacts'</em> (the 'pipes' that extract the electrons from the conduction band and holes from the valence band in the diagram). These contacts play 2 crucial roles: (1) they prevent the hot-carrier population from being cooled when in contact with the metal electrodes, and (2) the voltage of the solar cell is determined by the energy separation between the electron and hole contact. Thus the hot-carrier solar cell can the best of both worlds: a high current by using a low bandgap absorber, and a high voltage from using energy selective contacts.
+ The good voltage performance is achieved using <em>'energy selective contacts'</em> (the 'pipes' that extract the electrons from the conduction band and holes from the valence band in the diagram). These contacts play two crucial roles: (1) they prevent the hot-carrier population from being cooled when in contact with the metal electrodes, and (2) the voltage of the solar cell is determined by the energy separation between the electron and hole contact. Thus the hot-carrier solar cell can achieve the best of both worlds: a high current by using a low bandgap absorber, and a high voltage from using energy selective contacts.
</p>
<p>
- To better understand the current/voltage trade off that occurs in conventional solar cell, and how this is improved by using hot-carrier, try the <a href="../freebies/quantumofsol/">Quantum of Sol Web App</a>.
+ To better understand the current/voltage trade off that occurs in conventional solar cells, and how this can be improved by using hot-carrier, try the <a href="../freebies/quantumofsol/">Quantum of Sol Web App</a> (Firefox or Safari is needed.).
</p>
</div>
<div class="span-6 last">
<div>
<h3>
<span class="alt">Follow me here...</span>
</h3><a href="http://twitter.com/danieljfarrell"><img src="../img/twitter.jpg" width="35"></a> <a href="http://linkedin.com/in/danieljfarrell"><img src="../img/linkedin.jpg" width="33"></a> <a href="http://www.mendeley.com/profiles/daniel-farrell/"><img border="0" src="http://www.mendeley.com/embed/icon/1/blue/small" alt="Daniel Farrell's bibliography"></a>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="../img/lsc.jpg" width="200" class="top push-0 shadow" alt="Luminescent solar concentrators.">
</p>
<div class="pcaption">
<p>
Luminescent solar concentrators.
</p>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
<p>
<img src="hccell.jpg" width="200" class="top push-0 shadow" alt="Hot-carrier solar cell.">
</p>
<div class="pcaption">
<p>
The hot-carrier solar cell.
</p>
</div>
</div>
</div>
<hr class="space">
<hr class="space">
<hr class="space">
<hr class="space">
</body>
</html>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.