Skip to content

Commit

Permalink
sorting out frontend for cms plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 18, 2010
1 parent 5ac9388 commit 9ec6677
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 52 deletions.
7 changes: 3 additions & 4 deletions infinitas/cms/controllers/contents_controller.php
Expand Up @@ -37,8 +37,8 @@ function index() {
$this->set('contents', $this->paginate());
}

function view($slug = null) {
if (!$slug) {
function view() {
if (!isset($this->params['slug'])) {
$this->Session->setFlash( __('Invalid content selected', true) );
$this->redirect($this->referer());
}
Expand All @@ -48,8 +48,7 @@ function view($slug = null) {
array(
'conditions' => array(
'or' => array(
'Content.slug' => $slug,
'Content.id' => $slug
'Content.slug' => $this->params['slug']
),
'Content.active' => 1
)
Expand Down
58 changes: 53 additions & 5 deletions infinitas/cms/controllers/frontpages_controller.php
Expand Up @@ -30,7 +30,55 @@ class FrontpagesController extends CmsAppController {

function index() {
$this->Frontpage->recursive = 0;
$this->set('frontpages', $this->paginate());

$this->paginate = array(
'fields' => array(
'Frontpage.id',
'Frontpage.content_id',
'Frontpage.ordering',
'Frontpage.created',
'Frontpage.modified'
),
'contain' => array(
'Content' => array(
'fields' => array(
'Content.id',
'Content.title',
'Content.slug',
'Content.introduction',
'Content.active',
'Content.created',
'Content.modified',
),
'Author' => array(
'fields' => array(
'Author.id',
'Author.username'
)
),
'Editor' => array(
'fields' => array(
'Editor.id',
'Editor.username'
)
),
'Category' => array(
'fields' => array(
'Category.id',
'Category.title',
'Category.slug'
)
),
'ContentConfig',
'Feature'
)
)
);

$frontpages = $this->paginate();

$this->set('frontpages', $frontpages);
$this->set('filterOptions', $this->Filter->filterOptions);
}

function admin_index() {
Expand All @@ -43,23 +91,23 @@ function admin_index() {
'Frontpage.ordering',
'Frontpage.created',
'Frontpage.modified'
),
),
'contain' => array(
'Content' => array(
'fields' => array(
'Content.id',
'Content.title',
'Content.active',
),
),
'Category' => array(
'fields' => array(
'Category.id',
'Category.title'
)
)
)
)
);
)
);

$frontpages = $this->paginate();

Expand Down
11 changes: 7 additions & 4 deletions infinitas/cms/models/content.php
Expand Up @@ -32,18 +32,21 @@ class Content extends CmsAppModel {
var $order = array(
'Content.category_id' => 'ASC',
'Content.ordering' => 'ASC'
);
);

var $validate = array(
'title' => array(
'notempty' => array('rule' => array('notempty')),
'notempty' => array(
'rule' => array( 'notempty' ),
'message' => 'Please enter the title of your page'
),
);
)
);

var $actsAs = array(
'Libs.Sluggable',
'Libs.Viewable'
);
);

var $belongsTo = array(
'Author' => array(
Expand Down
52 changes: 28 additions & 24 deletions infinitas/cms/models/frontpage.php
@@ -1,32 +1,36 @@
<?php
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://www.dogmatic.co.za
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://www.dogmatic.co.za
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

class Frontpage extends CmsAppModel {
var $name = 'Frontpage';
class Frontpage extends CmsAppModel {
var $name = 'Frontpage';

var $actsAs = array(
'Libs.Ordered'
var $actsAs = array(
'Libs.Ordered'
);

var $belongsTo = array(
'Cms.Content'
var $order = array(
'Frontpage.order_id' => 'ASC',
'Frontpage.ordering' => 'ASC'
);
}

var $belongsTo = array(
'Cms.Content'
);
}
?>
4 changes: 2 additions & 2 deletions infinitas/cms/views/elements/admin/actions.ctp
Expand Up @@ -36,8 +36,8 @@
</ul>
<h3><?php __( 'Front Pages' ); ?></h3>
<ul class="nav">
<li><?php echo $this->Html->link( __( 'All', true ), array( 'plugin' => 'cms', 'controller' => 'contentFrontpages', 'action' => 'index' ) ); ?></li>
<li><?php echo $this->Html->link( __( 'New', true ), array( 'plugin' => 'cms', 'controller' => 'contentFrontpages', 'action' => 'add' ) ); ?></li>
<li><?php echo $this->Html->link( __( 'All', true ), array( 'plugin' => 'cms', 'controller' => 'frontpages', 'action' => 'index' ) ); ?></li>
<li><?php echo $this->Html->link( __( 'New', true ), array( 'plugin' => 'cms', 'controller' => 'frontpages', 'action' => 'add' ) ); ?></li>
</ul>
<h3><?php __( 'Featured Pages' ); ?></h3>
<ul class="nav">
Expand Down
2 changes: 1 addition & 1 deletion infinitas/cms/views/frontpages/admin_add.ctp
Expand Up @@ -21,7 +21,7 @@
<div class="sections form">
<?php
echo $this->Cms->adminOtherHead( $this );
echo $this->Form->create( 'ContentFrontpage' );
echo $this->Form->create( 'Frontpage' );
echo $this->Form->input( 'content_id', array( 'label' => __( 'Content Item', true ), 'type' => 'select', 'options' => $contents ) );
echo $this->Form->end( __( 'Submit', true ) );
?>
Expand Down
20 changes: 10 additions & 10 deletions infinitas/cms/views/frontpages/admin_index.ctp
Expand Up @@ -18,7 +18,7 @@
* @since 0.5a
*/

echo $this->Form->create( 'ContentFrontpage', array( 'url' => array( 'controller' => 'contentFrontpages', 'action' => 'mass', 'admin' => 'true' ) ) );
echo $this->Form->create( 'Frontpage', array( 'url' => array( 'controller' => 'frontpages', 'action' => 'mass', 'admin' => 'true' ) ) );
$massActions = $this->Cms->massActionButtons(
array(
'add',
Expand Down Expand Up @@ -56,34 +56,34 @@
);

$i = 0;
foreach ( $contentFrontpages as $contentFrontpage )
foreach ( $frontpages as $frontpage )
{
?>
<tr class="<?php echo $this->Cms->rowClass( $i ); ?>">
<td><?php echo $this->Form->checkbox( $contentFrontpage['ContentFrontpage']['id'] ); ?>&nbsp;</td>
<td><?php echo $this->Form->checkbox( $frontpage['Frontpage']['id'] ); ?>&nbsp;</td>
<td>
<?php echo $this->Html->link( $contentFrontpage['Content']['title'], array('controller' => 'contents', 'action' => 'view', $contentFrontpage['Content']['id'])); ?>
<?php echo $this->Html->link( $frontpage['Content']['title'], array('controller' => 'contents', 'action' => 'view', $frontpage['Content']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link( $contentFrontpage['Content']['Category']['title'], array( 'controller' => 'categories', 'action' => 'edit', $contentFrontpage['Content']['Category']['id'] ) ); ?>
<?php echo $this->Html->link( $frontpage['Content']['Category']['title'], array( 'controller' => 'categories', 'action' => 'edit', $frontpage['Content']['Category']['id'] ) ); ?>
</td>
<td>
<?php echo $this->Time->niceShort( $contentFrontpage['ContentFrontpage']['created'] ); ?>
<?php echo $this->Time->niceShort( $frontpage['Frontpage']['created'] ); ?>
</td>
<td>
<?php echo $this->Time->niceShort( $contentFrontpage['ContentFrontpage']['modified'] ); ?>
<?php echo $this->Time->niceShort( $frontpage['Frontpage']['modified'] ); ?>
</td>
<td>
<?php
echo $this->Cms->ordering(
$contentFrontpage['ContentFrontpage']['content_id'],
$contentFrontpage['ContentFrontpage']['ordering']
$frontpage['Frontpage']['content_id'],
$frontpage['Frontpage']['ordering']
);
?>
</td>
<td>
<?php
echo $this->Status->toggle( $contentFrontpage['Content']['active'], $contentFrontpage['Content']['id'], array( 'controller' => 'contents', 'action' => 'toggle' ) );
echo $this->Status->toggle( $frontpage['Content']['active'], $frontpage['Content']['id'], array( 'controller' => 'contents', 'action' => 'toggle' ) );
?>
</td>
</tr>
Expand Down
102 changes: 100 additions & 2 deletions infinitas/cms/views/frontpages/index.ctp
Expand Up @@ -18,6 +18,104 @@
* @since 0.5a
*/
?>
<h2>Welcome to <?php echo Configure::read('Website.name'); ?></h2>
<?php
pr( $frontpages );
?>
$i = 0;
foreach($frontpages as $frontpage ){
if ($i >= 2) {
echo '<div style="width:50%; float:left;">';
}
$frontpage['Content']['Author']['username'] = $frontpage['Content']['Editor']['username'] = 'Admin';
?>
<div class="introduction">
<h3><?php echo $frontpage['Content']['title']; ?></h3>
<div class="stats">
<div><?php echo __('Written by', true), ': ', $frontpage['Content']['Author']['username']; ?></div>
<div><?php echo $this->Time->niceShort( $frontpage['Content']['created'] ); ?></div>
</div>
<div class="body">
<?php
echo $frontpage['Content']['introduction'];
?>
</div>
<div class="footer">
<span><?php echo __('Last updated on', true), ': ', $this->Time->niceShort( $frontpage['Content']['modified'] ); ?></span>
<span><?php echo '('.$frontpage['Content']['Editor']['username'].')'; ?></span>
<div class="read-more">
<?php
echo $this->Html->link(
Configure::read('Website.read_more'),
array(
'plugin' => 'cms',
'controller' => 'contents',
'action' => 'view',
'id' => $frontpage['Content']['id'],
'slug' => $frontpage['Content']['slug'],
'category' => $frontpage['Content']['Category']['slug']
)
);
?>
</div>
</div>
</div>
<?php
if ($i >= 2) {
echo '</div>';
}
$i++;
}
?>
<style>
.cms h3{
font-size:110%;
color:#1E379C;
padding-bottom:5px;
}

.cms big{
font-size:120%;
}
.cms ol,
.cms ul {
list-style:lower-greek outside none;
}

.cms .heading{
margin-bottom:20px;
}

.cms .heading h2{
font-size:130%;
color:#1E379C;
padding-bottom:5px;
}

.cms .stats{
border-top:1px dotted #E4E4E4;
}

.cms .stats div{
float:left;
padding-right:20px;
font-size:80%;
padding-top:3px;
}

.cms .introduction{
font-style: italic;
color: #8F8F8F;
}

.cms p{
margin-bottom:10px;
}

.cms .body{
color:#535D6F;
line-height:110%;
clear:both;
}
.cms .body .stats div{
float:right;
}
</style>

0 comments on commit 9ec6677

Please sign in to comment.