[geeklog-cvs] Geeklog-2.x/plugins/content/views ContentEditorView.php, NONE, 1.1 UserContentView.php, NONE, 1.1 ContentMainView.php, NONE, 1.1 ContentAdminView.php, NONE, 1.1 ContentView.php, NONE, 1.1
Damien Hodgkin
dhodgkin at qs1489.pair.com
Wed Aug 8 16:23:47 EDT 2007
- Previous message (by thread): [geeklog-cvs] Geeklog-2.x/plugins/content/themes/default ContentEditor.thtml, NONE, 1.1 ContentMainView.thtml, NONE, 1.1 ContentManager.thtml, NONE, 1.1 ContentView.thtml, NONE, 1.1 PluginSubMenu.thtml, NONE, 1.1 UserContentView.thtml, NONE, 1.1
- Next message (by thread): [geeklog-cvs] Geeklog-2.x/plugins/content/sql NamedQueries.xml, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/geeklog2/Geeklog-2.x/plugins/content/views
In directory qs1489.pair.com:/tmp/cvs-serv13905/plugins/content/views
Added Files:
ContentEditorView.php UserContentView.php ContentMainView.php
ContentAdminView.php ContentView.php
Log Message:
Second commit
--- NEW FILE: ContentEditorView.php ---
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Geeklog 2
*
* License details are yet to be determined.
*
*/
/**
* Bring in BaseViewFlexy
*/
require getOption('path_views') . 'BaseViewFlexyPlugin.php';
/**
* Content model object
*/
require_once(getOption('path_plugins') . 'content/models/Gl2Content.php');
/**
* Item model object
*/
require_once(getOption('path_models') . 'Gl2Item.php');
/**
* Content editor view
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @copyright Geeklog 2 Development Team 2005
* @version $Id: ContentEditorView.php,v 1.1 2007/08/08 20:23:44 dhodgkin Exp $
* @package net.geeklog.views
*
*/
class content_ContentEditorView extends Geeklog_BaseViewFlexyPlugin {
/**
* Provides a more readable way to access the content ID from the URL arguments
* @const A_ID
* @var int
*/
const A_ID = 2;
/**
* Gives the Flexy template a handle to the content object
* @access public
* @var Gl2Content
*/
public $content = null;
/**
* Gives the Flexy template a handle to the item object
* @access public
* @var GL2Item
*/
public $item = null;
public $blah = null;
/**
* Registers the 'edit' action for the content plugin.
*
* @access public
* @static
* @return array Array of action names.
*
*/
public static function getActions()
{
return array('contentEdit');
}
public static function getIsDefaultAction() {
return false;
}
public static function getForwards() {
return array();
}
/**
* Constructor
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function __construct($urlArgs)
{
$this->setUserRequired(false);
parent::__construct($urlArgs);
}
/**
* Ensure the user is authorized to view the acontent
*
* This is a pretty simple methd that check the content ID we got and ensures the user has
* sufficient rights to access it. A lot of the work is done by
* Geeklog_BaseViewFlexyPlugin::authorizedToView()
*
* @author Tony Bibbs <tony at geeklog.net>
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access protected
* @return boolean True if the user can view the page, otherwise false
*
*/
protected function authorizedToView()
{
if (!empty($_REQUEST['content'])) {
$this->content = $_REQUEST['content'];
unset($_REQUEST['content']);
$foo = $this->content->getContentId();
$this->item = $this->content->getGl2ItemAcl();
if (!empty($foo)) {
return parent::authorizedToView($this->content);
} else {
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
$this->content = $dao->find('getMaxContentId');
$this->blah = $this->content->getContentId() + 1;
}
return true;
} else {
if (empty($this->urlArgs[content_ContentEditorView::A_ID])) {
// Do some sort of security check.
$this->content = new Gl2Content();
$this->item = new Gl2Item();
$this->content->setGl2Item($this->item);
$this->item->setGl2User($this->user);
// Default date created to current time
$this->item->setDateCreated(time());
return true;
} else {
$this->content = new Gl2Content();
$id = $this->urlArgs[content_ContentEditorView::A_ID];
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
if (is_numeric($id)) {
$this->content = $dao->find('getContentById', array($id));
} else {
$this->content = $dao->find('getContents', array($id));
}
$this->content = $this->content[0];
if (is_object($this->content)) {
$this->item = $this->content->getGl2Item();
} else {
throw new Exception("Content with id of {$this->urlArgs[content_ContentEditorView::A_ID]}
does not exist! Please note that all attempts to access non-existent contents are
recorded.");
}
if (parent::authorizedToView($this->content)) {
$_REQUEST['content'] = $this->content;
return true;
}
}
}
return false;
}
/**
* Shows the content editor.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function processView()
{
$this->setPageTitle('Geeklog 2: Content Editor');
$this->showHeader();
$foo = $this->content->getContentId();
if (empty($foo)) {
$this->content->setContentId($this->blah);
}
// Create flexy elements to correspond to each field
$this->flexyElements['Gl2Item->expirationDate'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Item->expirationDate']->setValue($this->item->getExpirationDate());
$this->flexyElements['Gl2Content->ContentId'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentId']->setValue($this->content->getContentId());
$this->flexyElements['Gl2Content->ContentAuthor'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentAuthor']->setValue($this->content->getContentAuthor());
$this->flexyElements['Gl2Content->ContentTitle'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentTitle']->setValue($this->content->getContentTitle());
$this->flexyElements['Gl2Content->Description'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->Description']->setValue($this->content->getDescription());
$this->flexyElements['Gl2Content->ContentBody'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentBody']->setValue($this->content->getContentBody());
$this->flexyElements['Gl2Content->ContentUrl'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentUrl']->setValue($this->content->getContentUrl());
$this->flexyElements['Gl2Item->rewriteId'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Item->rewriteId']->setValue($this->item->getRewriteId());
$this->flexyElements['Gl2Content->ContentType'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentType']->setOptions( array( 38 => 'Article',
39 => 'Static Page',
40 => 'Flexy Content'));
$this->flexyElements['Gl2Content->ContentType']->setValue('article');
// Compile the template and show it
$this->flexyHandle->compile('ContentEditor.thtml');
$this->flexyHandle->outputObject($this, $this->flexyElements);
$this->showFooter();
}
public function numRights()
{
return count($this->rights);
}
public function getPathToPluginJS($pluginName = '') {
$path = getOption('path_plugin_assets') . $pluginName;
return $path;
}
public function getCSSEntries()
{
$entries = parent::getCSSEntries();
$entries .= '<link rel="stylesheet" type="text/css" href="' . $this->baseUrl . '/javascript/geeklog2/cal.css" />';
return $entries;
}
public function getJavaScriptEntries($withAjax = true)
{
$entries = parent::getJavaScriptEntries($withAjax);
$entries .= '<script src="' . $this->baseUrl
. '/javascript/geeklog2/gl2ItemSecurity.js" type="text/javascript"></script>'
. '<script src="' . $this->baseUrl
. '/javascript/geeklog2/calendar.js" type="text/javascript"></script>'
. '<script src="' . $this->baseUrl
. '/assets/plugins/content/jscripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>';
return $entries;
}
public function fckeditor() {
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = $this->baseUrl . '/assets/plugins/content/fckeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create() ;
}
}
?>
--- NEW FILE: UserContentView.php ---
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Geeklog 2
*
* License details are yet to be determined.
*
*/
/**
* Bring in BaseViewFlexy
*/
require getOption('path_views') . 'BaseViewFlexyPlugin.php';
/**
* Content model object
*/
require_once(getOption('path_plugins') . 'content/models/Gl2Content.php');
/**
* User contents view
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @copyright 2007
* @version $Id: UserContentView.php,v 1.1 2007/08/08 20:23:44 dhodgkin Exp $
* @package net.geeklog.views
*
*/
class content_UserContentView extends Geeklog_BaseViewFlexyPlugin {
public static function getActions() {
return array('myContents', 'myArticles', 'myPages');
}
public static function getIsDefaultAction() {
return false;
}
public static function getForwards() {
return array();
}
/**
* Constructor
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function __construct($urlArgs) {
$this->setUserRequired(false);
parent::__construct($urlArgs);
}
protected function authorizedToView() {
return true;
}
/**
* Shows the user contents view
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function processView() {
// Get any error or status messages
$this->getMessages();
// Show the page
$this->setPageTitle('Geeklog 2: Contents');
$this->showHeader();
$pageToGet = $_GET['page'];
if (empty($pageToGet)) {
$pageToGet = 1;
}
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
$this->flexyElements['query'] = new HTML_Template_Flexy_Element;
if (!empty($_GET['query'])) {
$this->contents = $dao->find('getContentsByAuthor', array('%' . $_GET['query'] . '%'), $pageToGet, $contentConf['contents_per_page_admin']);
$this->flexyElements['query']->setValue($_GET['query']);
} else {
$this->contents = $dao->find('getContents', null, $pageToGet, getOption('contents_per_page_admin','content'));
$this->contents = $this->contents['RESULTS'];
}
$this->flexyHandle->compile('UserContentView.thtml');
$this->flexyHandle->outputObject($this);
$this->showFooter();
}
/**
* Gets the number of contents that will be displayed
*
* NOTE: this isn't the total number of pages (remember, this can be paged). This is the total
* on the current page.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @return int number of contents to display
*
*/
public function numContents()
{
return count($this->contents);
}
}
?>
--- NEW FILE: ContentView.php ---
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Geeklog 2
*
* License details are yet to be determined.
*
*/
/**
* Bring in BaseViewFlexy
*/
require getOption('path_views') . 'BaseViewFlexyPlugin.php';
/**
* Content model object
*/
require_once(getOption('path_plugins') . 'content/models/Gl2Content.php');
/**
* Shows the content plugin's homepage
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @copyright Geeklog 2 Development Team 2005
* @version $Id: ContentView.php,v 1.1 2007/08/08 20:23:44 dhodgkin Exp $
* @package net.geeklog.views
*
*/
class content_ContentView extends Geeklog_BaseViewFlexyPlugin {
/**
* Gives the Flexy template a handle to the content object
* @access public
* @var Gl2Content
*/
public $content = null;
const A_ID = 2;
public static function getActions()
{
return array('contentDisplay');
}
public static function getIsDefaultAction() {
return false;
}
public static function getForwards() {
return array();
}
protected function authorizedToView() {
return true;
}
/**
* Constructor
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function __construct($urlArgs) {
$this->setUserRequired(false);
parent::__construct($urlArgs);
}
/**
* Shows the content.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function processView() {
// Get any error or status messages
$this->getMessages();
// Show the page
$this->setPageTitle('Geeklog 2: Content');
$this->showHeader();
$this->content = new Gl2Content();
$id = $this->urlArgs[content_ContentView::A_ID];
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
if (is_numeric($id)) {
$this->content = $dao->find('getContentById', array($id));
} else {
throw new Exception("Content with id of {$this->urlArgs[content_ContentView::A_ID]}
does not exist! Please note that all attempts to access non-existent contents are
recorded.");
}
$this->content = $this->content[0];
// Create flexy elements to correspond to each field
$this->flexyElements['Gl2Content->ContentAuthor'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentAuthor']->setValue($this->content->getContentAuthor());
$this->flexyElements['Gl2Content->ContentTitle'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentTitle']->setValue($this->content->getContentTitle());
$this->flexyElements['Gl2Content->Description'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->Description']->setValue($this->content->getDescription());
$this->flexyElements['Gl2Content->ContentBody'] = new HTML_Template_Flexy_Element;
$this->flexyElements['Gl2Content->ContentBody']->setValue($this->content->getContentBody());
$this->flexyHandle->compile('ContentView.thtml');
$this->flexyHandle->outputObject($this);
$this->showFooter();
}
}
?>
--- NEW FILE: ContentMainView.php ---
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Geeklog 2
*
* License details are yet to be determined.
*
*/
/**
* Bring in BaseViewFlexy
*/
require getOption('path_views') . 'BaseViewFlexyPlugin.php';
/**
* Content model object
*/
require_once(getOption('path_plugins') . 'content/models/Gl2Content.php');
/**
* Shows the content main page
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @copyright Geeklog 2 Development Team 2005
* @version $Id: ContentMainView.php,v 1.1 2007/08/08 20:23:44 dhodgkin Exp $
* @package net.geeklog.views
*
*/
class content_ContentMainView extends Geeklog_BaseViewFlexyPlugin {
public $contents = null;
public static function getActions() {
return array('showMain');
}
public static function getIsDefaultAction() {
return true;
}
public static function getForwards() {
return array();
}
protected function authorizedToView() {
return true;
}
/**
* Constructor
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function __construct($urlArgs)
{
$this->setUserRequired(false);
parent::__construct($urlArgs);
}
/**
* Shows the main page of the content plugin.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function processView() {
// Get any error or status messages
$this->getMessages();
// Show the page
$this->setPageTitle('Geeklog 2: Contents');
$this->showHeader();
$pageToGet = $_GET['page'];
if (empty($pageToGet)) {
$pageToGet = 1;
}
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
$this->contents = $dao->find('getContents', null, $pageToGet, getOption('contents_per_page_admin','content'));
$this->contents = $this->contents['RESULTS'];
$this->flexyHandle->compile('ContentMainView.thtml');
$this->flexyHandle->outputObject($this);
$this->showFooter();
}
/**
* Gets the number of contents that will be displayed
*
* NOTE: this isn't the total number of pages (remember, this can be paged). This is the total
* on the current page.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @return int number of contents to display
*
*/
public function numContents()
{
return count($this->contents);
}
}
?>
--- NEW FILE: ContentAdminView.php ---
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
/**
* Geeklog 2
*
* License details are yet to be determined.
*
*/
/**
* Bring in BaseViewFlexy
*/
require getOption('path_views') . 'BaseViewFlexyPlugin.php';
/**
* Link model object
*/
require_once(getOption('path_plugins') . 'content/models/Gl2Content.php');
/**
* Shows the content administration homepage
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @copyright Geeklog 2 Development Team 2005
* @version $Id: ContentAdminView.php,v 1.1 2007/08/08 20:23:44 dhodgkin Exp $
* @package net.geeklog.views
*
*/
class content_ContentsAdminView extends Geeklog_BaseViewFlexyPlugin {
public $contents = null;
public static function getActions() {
return array('contentAdmin');
}
public static function getIsDefaultAction() {
return false;
}
public static function getForwards() {
return array();
}
/**
* Constructor
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function __construct($urlArgs)
{
$this->setUserRequired(false);
parent::__construct($urlArgs);
}
protected function authorizedToView()
{
return true;
}
/**
* Shows the Content manager.
*
* @author Damien Hodgkin <dracul01 at gmail.com>
* @access public
*
*/
public function processView()
{
$this->setPageTitle('Geeklog 2: Content Manager');
$pageToGet = $_GET['page'];
if (empty($pageToGet)) {
$pageToGet = 1;
}
$dao = Geeklog_DAO_DAOFactory::getDAO('content');
$this->flexyElements['query'] = new HTML_Template_Flexy_Element;
if (!empty($_GET['query'])) {
$this->contents = $dao->find('getContentsByKeyword', array($_GET['query'] . '%', '%' . $_GET['query'] . '%'), $pageToGet, $contentConf['contents_per_page_admin']);
$this->flexyElements['query']->setValue($_GET['query']);
} else {
$this->contents = $dao->find('getContents', null, $pageToGet, getOption('contents_per_page_admin','content'));
$this->contents = $this->contents['RESULTS'];
}
$this->showHeader();
// Compile the template and show it
$this->flexyHandle->compile('ContentManager.thtml');
$this->flexyHandle->outputObject($this, $this->flexyElements);
$this->showFooter();
}
/**
* Returns the rewrite ID or the link ID in the case one is available
*
* @param unknown_type $link
* @return unknown
*
*/
public function getRewriteId($content)
{
$item = $content->getGl2Item();
$rewriteId = $item->getRewriteId();
if (empty($rewriteId)) {
return $content->getContentId();
} else {
return $rewriteId;
}
}
public function getPagerControl()
{
require_once 'Controls/Pager.php';
if (empty($curPage)) $curPage = 1;
if (empty($_GET['query'])) {
$pager = new Geeklog_Pager($this->baseUrl . '/index.php/content/admin',$curPage,1,count($this->contents));
} else {
$pager = new Geeklog_Pager($this->baseUrl . '/index.php/content/admin',$curPage,1,count($this->contents),"?query={$_GET['query']}");
}
return $pager->getStockControl();
}
public function numContents()
{
return count($this->contents);
}
/**
* Brings in the YUI script tags.
*
* @author Tony Bibbs <tony at geeklog.net>
* @access public
* @return string HTML for the script entries
*
*/
public function getJavaScriptEntries()
{
$entries = parent::getJavaScriptEntries();
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/yahoo/yahoo.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/dom/dom.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/event/event.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/animation/animation.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/autocomplete/autocomplete.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/yui/build/connection/connection.js"></script>' . "\n";
$entries .= '<script src="' . $this->baseUrl . '/javascript/json.js"></script>' . "\n";
return $entries;
}
public function getDraggableScript($content)
{
return parent::getDraggableScript('content_' . $content->getContentId());
}
}
?>
- Previous message (by thread): [geeklog-cvs] Geeklog-2.x/plugins/content/themes/default ContentEditor.thtml, NONE, 1.1 ContentMainView.thtml, NONE, 1.1 ContentManager.thtml, NONE, 1.1 ContentView.thtml, NONE, 1.1 PluginSubMenu.thtml, NONE, 1.1 UserContentView.thtml, NONE, 1.1
- Next message (by thread): [geeklog-cvs] Geeklog-2.x/plugins/content/sql NamedQueries.xml, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list