Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getting the blog and cms stable with locking records code highlightin…
…g looking at form plugins
- Loading branch information
1 parent
54f3ab9
commit 0822f02
Showing
464 changed files
with
86,785 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Blog App Controller class file. | ||
* | ||
* The parent class that all the blog plugin controller classes extend from. | ||
* This is used to make functionality that is needed all over the blog | ||
* plugin. | ||
* | ||
* 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 blog | ||
* @subpackage blog.controllers.blogAppController | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
*/ | ||
class BlogAppController extends AppController | ||
{ | ||
/** | ||
* The helpers that the blog plugin needs to function | ||
*/ | ||
var $helpers = array( | ||
//cake helpers | ||
'Time', 'Text', 'Form', | ||
|
||
//core helpers | ||
'Core.TagCloud', | ||
|
||
//plugin helpers | ||
'Blog.Blog', 'Google.Chart', | ||
|
||
//layout helpers | ||
'Blog.PostLayout', 'Blog.CommentLayout' | ||
); | ||
|
||
/** | ||
* beforeFilter callback | ||
* | ||
* this method is run before any of the controllers in the blog plugin. | ||
* It is used to set up a cache config and some other variables that are | ||
* needed throughout the plugin. | ||
* | ||
* @param nothing | ||
* @return nothing | ||
*/ | ||
function beforeFilter() | ||
{ | ||
parent::beforeFilter(); | ||
|
||
$this->set( 'tagCount', ClassRegistry::init( 'Blog.Tag' )->getCount() ); | ||
|
||
$this->set( 'postDates', ClassRegistry::init( 'Blog.Post' )->getDates() ); | ||
$this->set( 'postLatest', ClassRegistry::init( 'Blog.Post' )->getLatest() ); | ||
$this->set( 'postPending', ClassRegistry::init( 'Blog.Post' )->getPending() ); | ||
$this->set( 'postPopular', ClassRegistry::init( 'Blog.Post' )->getPopular() ); | ||
|
||
$this->set( 'commentCount', ClassRegistry::init( 'Blog.Comment' )->getCounts() ); | ||
} | ||
|
||
/** | ||
* afterFilter callback. | ||
* | ||
* used to do stuff before the code is rendered but after all the | ||
* controllers have finnished. | ||
* | ||
* @param nothing | ||
* @return nothing | ||
*/ | ||
function afterFilter() | ||
{ | ||
parent::afterFilter(); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
class BlogAppModel extends AppModel | ||
{ | ||
var $useDbConfig = 'blog'; | ||
|
||
function beforeSave() | ||
{ | ||
parent::beforeSave(); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
function afterDelete() | ||
{ | ||
parent::afterDelete(); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
private function __clearCache() | ||
{ | ||
App::import( 'Folder' ); | ||
|
||
$Folder = new Folder( CACHE.'blog' ); | ||
|
||
$files = $Folder->read(); | ||
|
||
if ( empty( $files[1] ) ) | ||
{ | ||
return true; | ||
} | ||
|
||
foreach( $files[1] as $file ) | ||
{ | ||
unlink( CACHE.'blog'.DS.$file ); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
/** | ||
* Blog Comments Controller class file. | ||
* | ||
* This is the main controller for all the blog comments. It extends | ||
* {@see BlogAppController} for some functionality. | ||
* | ||
* 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 blog | ||
* @subpackage blog.controllers.comments | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
*/ | ||
class CommentsController extends BlogAppController | ||
{ | ||
var $name = 'Comments'; | ||
|
||
function add() | ||
{ | ||
if ( !empty( $this->data ) ) | ||
{ | ||
$this->Comment->create(); | ||
|
||
if ( $this->Comment->save( $this->data ) ) | ||
{ | ||
$this->Session->setFlash( 'Your comment has been submitted for review.' ); | ||
$this->redirect( $this->referer() ); | ||
} | ||
} | ||
} | ||
|
||
function admin_index( $active = null ) | ||
{ | ||
$conditions = array(); | ||
if ( $active !== null ) | ||
{ | ||
$conditions = array( 'Comment.active' => $active ); | ||
} | ||
|
||
$this->paginate = array( | ||
'fields' => array( | ||
'Comment.id', | ||
'Comment.name', | ||
'Comment.email', | ||
'Comment.website', | ||
'Comment.comment', | ||
'Comment.active', | ||
'Comment.post_id', | ||
'Comment.created', | ||
), | ||
'conditions' => $conditions, | ||
'order' => array( | ||
'Comment.active' => 'ASC', | ||
'Comment.created' => 'ASC', | ||
), | ||
'limit' => 20, | ||
'contain' => array( | ||
'Post' => array( | ||
'fields' => array( | ||
'Post.title', | ||
'Post.slug', | ||
) | ||
) | ||
) | ||
); | ||
|
||
$comments = $this->paginate( 'Comment' ); | ||
|
||
$this->set( compact( 'comments' ) ); | ||
} | ||
|
||
function admin_perge( $date = null ) | ||
{ | ||
if ( !$date ) | ||
{ | ||
$date = date( 'Y-m-d h:i:s', mktime( 0, 0, 0, date( 'm' ) -1, date( 'd' ), date( 'y' ) ) ); | ||
} | ||
|
||
$old = $this->Comment->find( | ||
'list', | ||
array( | ||
'fields' => array( | ||
'Comment.id', | ||
'Comment.id' | ||
), | ||
'conditions' => array( | ||
'Comment.created < ' => $date, | ||
'Comment.active' => 0 | ||
), | ||
'contain' => false | ||
) | ||
); | ||
|
||
if ( empty( $old ) ) | ||
{ | ||
$this->Session->setFlash( __( 'No old comments found', true ) ); | ||
$this->redirect( $this->referer() ); | ||
} | ||
|
||
$i = 0; | ||
foreach( $old as $id ) | ||
{ | ||
if ( $this->Comment->delete( $id ) ) | ||
{ | ||
$i++; | ||
} | ||
} | ||
|
||
$this->Session->setFlash( sprintf( '%s %s', $i, __( 'Comments deleted', true ) ) ); | ||
} | ||
|
||
} | ||
?> |
Oops, something went wrong.