historical commit of site
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__));
|
||||
require_once PENGUINCODER_BASE . '/lib/base.php';
|
||||
|
||||
if (!Auth::isAdmin("penguincoder:admin")) {
|
||||
Horde::authenticationFailureRedirect();
|
||||
}
|
||||
|
||||
require_once 'Horde/Variables.php';
|
||||
require_once 'Horde/Form.php';
|
||||
require_once 'Horde/Form/Renderer.php';
|
||||
require_once 'Horde/UI/Tabs.php';
|
||||
|
||||
class DataForm extends Horde_Form
|
||||
{
|
||||
function DataForm(&$vars)
|
||||
{
|
||||
parent::Horde_Form($vars);
|
||||
|
||||
$this->addHidden('', 'actionId', 'text', true);
|
||||
$this->addHidden('', 'data_id', 'int', false);
|
||||
$this->addVariable(_("Title"), 'title', 'text', true);
|
||||
$this->addVariable(_("Type"), 'type', 'text', true);
|
||||
$this->addVariable(_("Info"), 'info', 'longText', true);
|
||||
}
|
||||
}
|
||||
|
||||
class JournalForm extends Horde_Form
|
||||
{
|
||||
function JournalForm(&$vars)
|
||||
{
|
||||
parent::Horde_Form($vars);
|
||||
|
||||
$this->addHidden('', 'actionId', 'text', true);
|
||||
$this->addVariable(_("Title"), 'title', 'text', true);
|
||||
$this->addVariable(_("Entry"), 'entry', 'longText', true);
|
||||
}
|
||||
}
|
||||
|
||||
$title = _("Master Blaster");
|
||||
|
||||
$vars = &Variables::getDefaultVariables();
|
||||
$tabs = &new Horde_UI_Tabs('actionId', $vars);
|
||||
$tabs->addTab(_("List Data"), 'admin.php', 'list');
|
||||
$tabs->addTab(_("Add Data"), 'admin.php', 'add');
|
||||
$tabs->addTab(_("Post Journal"), 'admin.php', 'post');
|
||||
|
||||
$renderer = &new Horde_Form_Renderer();
|
||||
global $pdata;
|
||||
global $pjournal;
|
||||
$data_id = Util::getFormData('data_id');
|
||||
$vars->set('actionId', Util::getFormData('actionId'));
|
||||
|
||||
switch ($vars->get('actionId')) {
|
||||
case 'post':
|
||||
$form = &Horde_Form::singleton('JournalForm', $vars);
|
||||
$valid = $form->validate($vars);
|
||||
if ($valid) {
|
||||
$result = $pjournal->add($vars->get('title'), $vars->get('entry'));
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
$notification->push(sprintf(
|
||||
_("There was a problem saving the post: %s"),
|
||||
$result->getMessage()), 'horde.error');
|
||||
} else {
|
||||
$notification->push(_("Success"), 'horde.success');
|
||||
header('Location: ' . Horde::selfUrl());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
case 'edit':
|
||||
$form = &Horde_Form::singleton('DataForm', $vars);
|
||||
$valid = $form->validate($vars);
|
||||
if ($valid) {
|
||||
switch ($vars->get('actionId')) {
|
||||
case 'add':
|
||||
$result = $pdata->add($vars->get('title'), $vars->get('type'),
|
||||
$vars->get('info'));
|
||||
break;
|
||||
case 'edit':
|
||||
$result = $pdata->update($vars->get('data_id'), $vars->get('title'),
|
||||
$vars->get('type'), $vars->get('info'));
|
||||
break;
|
||||
}
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
$notification->push(sprintf(
|
||||
_("There was a problem with the data persistence: %s"),
|
||||
$result->getMessage()), 'horde.error');
|
||||
} else {
|
||||
$notification->push(_("Success"), 'horde.success');
|
||||
header('Location: ' . Horde::selfUrl());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($vars->get('actionId') == 'edit' && !$valid) {
|
||||
$item = $pdata->retrieveById($data_id);
|
||||
if (is_a($item, 'PEAR_Error')) {
|
||||
$notification->push(sprintf(
|
||||
_("There was a problem with the data persistence: %s"),
|
||||
$item->getMessage()), 'horde.error');
|
||||
} else {
|
||||
$vars->set('data_id', $data_id);
|
||||
$vars->set('title', $item['title']);
|
||||
$vars->set('type', $item['type']);
|
||||
$vars->set('info', $item['info']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (isset($data_id)) {
|
||||
$result = $pdata->delete($data_id);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
$notification->push(sprintf(
|
||||
_("There was a problem with the data persistence: %s"),
|
||||
$result->getMessage()), 'horde.error');
|
||||
} else {
|
||||
$notification->push(_("Success"), 'horde.success');
|
||||
}
|
||||
}
|
||||
case 'list':
|
||||
default:
|
||||
$result = $pdata->retrieve();
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
$notification->push(sprintf(
|
||||
_("There was a problem with the data persistence: %s"),
|
||||
$result->getMessage()), 'horde.error');
|
||||
}
|
||||
$data = $pdata->listData();
|
||||
break;
|
||||
}
|
||||
|
||||
require_once PENGUINCODER_TEMPLATES . '/common-header.inc';
|
||||
require_once PENGUINCODER_TEMPLATES . '/menu/menu.inc';
|
||||
echo '<table style="margin-left: 15%;" width="75%"><tr><td>';
|
||||
echo $tabs->render();
|
||||
if (isset($form)) {
|
||||
$form->renderActive($renderer, $vars, 'admin.php', 'post');
|
||||
} else {
|
||||
require PENGUINCODER_TEMPLATES . '/admin/header.inc';
|
||||
$style = 'item1';
|
||||
foreach ($data as $d) {
|
||||
if ($style == 'item1') {$style = 'item0';}
|
||||
else {$style = 'item1';}
|
||||
include PENGUINCODER_TEMPLATES . '/admin/entry.inc';
|
||||
}
|
||||
require PENGUINCODER_TEMPLATES . '/admin/footer.inc';
|
||||
}
|
||||
echo '</td></tr></table>';
|
||||
require $registry->get('templates', 'horde') . '/common-footer.inc';
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- $Id: conf.xml,v 1.1.1.1 2004/08/16 20:52:48 penguinc Exp $ -->
|
||||
<configuration>
|
||||
|
||||
<configtab name="general" desc="General">
|
||||
<configsection name="storage" desc="Storage Settings">
|
||||
<configheader>Storage Driver Settings</configheader>
|
||||
<configswitch name="driver" desc="Storage Driver">sql
|
||||
<case name="sql" desc="SQL">
|
||||
<configsection name="params" desc="Storage Parameters">
|
||||
<configsql switchname="driverconfig">
|
||||
</configsql>
|
||||
</configsection>
|
||||
</case>
|
||||
</configswitch>
|
||||
</configsection>
|
||||
</configtab>
|
||||
|
||||
<configtab name="menu" desc="Menu">
|
||||
<configsection name="menu" desc="Menu Settings">
|
||||
<configmultienum name="apps" desc="Select any applications that should be linked in PenguinCoder's menu">
|
||||
<values>
|
||||
<configspecial name="list-horde-apps" />
|
||||
</values>
|
||||
</configmultienum>
|
||||
</configsection>
|
||||
</configtab>
|
||||
</configuration>
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__));
|
||||
require PENGUINCODER_BASE . '/lib/base.php';
|
||||
|
||||
$category = Util::getFormData('category');
|
||||
$title = Util::getFormData('title');
|
||||
if (empty($category) || empty($title)) {
|
||||
header('Location: ' . Horde::applicationUrl('index.php', true));
|
||||
}
|
||||
|
||||
$admin = Auth::getAuth('penguincoder:admin');
|
||||
$adminDelete = Auth::getAuth('penguincoder:admin', PERMS_DELETE);
|
||||
$appUrl = Horde::applicationUrl('journal.php');
|
||||
|
||||
global $pdata;
|
||||
$data = $pdata->getByCategory($category);
|
||||
if (is_a($data, 'PEAR_Error')) {
|
||||
$notification->push("There was a problem getting the information: " .
|
||||
$data->getMessage(), 'horde.error');
|
||||
} elseif (!count($data)) {
|
||||
$notification->push("No content was found, try again later (:^)");
|
||||
}
|
||||
|
||||
require PENGUINCODER_TEMPLATES . '/common-header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/menu/menu.inc';
|
||||
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $entry) {
|
||||
require PENGUINCODER_TEMPLATES . '/data/header.inc';
|
||||
if($admin) {
|
||||
require PENGUINCODER_TEMPLATES . '/actions/header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/admin.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/footer.inc';
|
||||
}
|
||||
require PENGUINCODER_TEMPLATES . '/data/data.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/data/footer.inc';
|
||||
}
|
||||
}
|
||||
echo '<p> </p>';
|
||||
require $registry->get('templates', 'horde') . '/common-footer.inc';
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__));
|
||||
|
||||
require PENGUINCODER_BASE . '/lib/base.php';
|
||||
|
||||
$title = _("Home");
|
||||
|
||||
global $pdata;
|
||||
$entries = $pdata->getNewestJournals();
|
||||
$maxJournalId = $pdata->getMaxJournalId();
|
||||
$minJournalId = $pdata->getMinJournalId();
|
||||
$admin = Auth::isAdmin('penguincoder:admin');
|
||||
$adminDelete = Auth::isAdmin('penguincoder:admin', PERMS_DELETE);
|
||||
$goodEntry = true;
|
||||
|
||||
if (is_a($entries, 'PEAR_Error')) {
|
||||
$goodEntry = false;
|
||||
$notification->push(_("There was a problem getting the Journal: ") .
|
||||
$entry->getMessage(), 'horde.error');
|
||||
}
|
||||
|
||||
require PENGUINCODER_TEMPLATES . '/common-header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/menu/menu.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/frontpage.inc';
|
||||
|
||||
if ($goodEntry) {
|
||||
$baseUrl = Util::addParameter(Horde::applicationUrl('journal.php'),
|
||||
'actionId', 'show');
|
||||
$appUrl = Horde::applicationUrl('journal.php');
|
||||
foreach ($entries as $entry) {
|
||||
$commentcount = $registry->call('forums/numMessages', array(
|
||||
$entry['id'], 'penguincoder'));
|
||||
if (is_a($commentcount, 'PEAR_Error')) {
|
||||
$commentcount = 0;
|
||||
}
|
||||
include PENGUINCODER_TEMPLATES . '/data/header.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/actions/header.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/actions/main.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/actions/admin.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/actions/footer.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/data/data.inc';
|
||||
include PENGUINCODER_TEMPLATES . '/data/footer.inc';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<p> </p>';
|
||||
require $registry->get('templates', 'horde') . '/common-footer.inc';
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__));
|
||||
require PENGUINCODER_BASE . '/lib/base.php';
|
||||
|
||||
global $pdata;
|
||||
|
||||
// page variables
|
||||
$actionId = Util::getFormData('actionId');
|
||||
$id = Util::getFormData('id');
|
||||
$category = Util::getFormData('category');
|
||||
$admin = Auth::getAuth('penguincoder:admin');
|
||||
$adminDelete = Auth::getAuth('penguincoder:admin', PERMS_DELETE);
|
||||
$goodEntry = true;
|
||||
|
||||
// sorting variables, only for list showing and determining which
|
||||
// direction to fetch the next journal from (previous, next)
|
||||
// direction is sort direction, either resolves to true (ascending) or
|
||||
// false (descending)
|
||||
$direction = Util::getFormData('direction');
|
||||
if ($direction == '1') {
|
||||
$direction = true;
|
||||
} elseif ($direction == '0') {
|
||||
$direction = false;
|
||||
} else {
|
||||
$direction = null;
|
||||
}
|
||||
|
||||
// order is the field to order the entries by, true is date otherwise it
|
||||
// is defaulted to the entry title
|
||||
$order = Util::getFormData('order');
|
||||
if ($order !== 'title') {
|
||||
$order = 'id';
|
||||
}
|
||||
|
||||
switch ($actionId) {
|
||||
case 'post':
|
||||
case 'edit':
|
||||
require_once PENGUINCODER_BASE . '/lib/DataForm.php';
|
||||
if (!$admin) {
|
||||
// only admins can edit
|
||||
header('Location: ' . Horde::selfUrl());
|
||||
break;
|
||||
}
|
||||
$vars = &Variables::getDefaultVariables();
|
||||
$vars->set('id', $id);
|
||||
$vars->set('actionId', $actionId);
|
||||
$vars->set('category', $category);
|
||||
$form = &Horde_Form::singleton('PDataForm', &$vars);
|
||||
if ($form->validate($vars)) {
|
||||
$vals = array(
|
||||
'title' => $vars->get('title'),
|
||||
'info' => $vars->get('info'),
|
||||
'category' => $vars->get('category'),
|
||||
'attributes' => serialize(array()),
|
||||
);
|
||||
if ($actionId == 'edit') {
|
||||
$vals['time_modified'] = time();
|
||||
$result = $pdata->update($id, $vals);
|
||||
} else {
|
||||
$vals['time_created'] = time();
|
||||
$result = $pdata->add($vals);
|
||||
}
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
$notification->push(_("There was a problem saving the entry: ") .
|
||||
$result->getMessage(), 'horde.error');
|
||||
} else {
|
||||
$notification->push(_("Success!"), 'horde.success');
|
||||
$goodEntry = false;
|
||||
}
|
||||
} elseif ($actionId == 'edit') {
|
||||
$entry = $pdata->getById($id);
|
||||
if (is_a($entry, 'PEAR_Error')) {
|
||||
$goodEntry = false;
|
||||
$notification->push(_("There was a problem fetching the data: ") .
|
||||
$entry->getMessage(), 'horde.error');
|
||||
} else {
|
||||
$vars->set('time_created', $entry['time_created']);
|
||||
$vars->set('category', $entry['category']);
|
||||
$vars->set('title', $entry['title']);
|
||||
$vars->set('info', $entry['info']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
// base url for generation later
|
||||
$baseUrl = Util::addParameter(Horde::selfUrl(), 'actionId', 'show');
|
||||
$appUrl = Horde::selfUrl();
|
||||
|
||||
// get the maximum journal id
|
||||
$maxJournalId = $pdata->getMaxJournalId();
|
||||
$minJournalId = $pdata->getMinJournalId();
|
||||
|
||||
// if no direction has been specified, then you want this id, fetch it
|
||||
if (is_null($direction)) {
|
||||
$entry = $pdata->getById($id);
|
||||
} elseif ($direction) {
|
||||
$entry = $pdata->getJournalById($id, '>', 'ASC');
|
||||
} else {
|
||||
$entry = $pdata->getJournalById($id, '<', 'DESC');
|
||||
}
|
||||
|
||||
// check the fetched entry
|
||||
if (is_a($entry, 'PEAR_Error')) {
|
||||
$goodEntry = false;
|
||||
$notification->push("There was a problem getting the journal entry: " .
|
||||
$entry->getMessage(), 'horde.error');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($direction) {
|
||||
$direction = 'ASC';
|
||||
} else {
|
||||
$direction = 'DESC';
|
||||
}
|
||||
$entries = $pdata->getByCategory('Journal', $order, $direction);
|
||||
if (is_a($entries, 'PEAR_Error')) {
|
||||
$goodEntry = false;
|
||||
$notification->push("There was a problem getting the information: " .
|
||||
$entries->getMessage(), 'horde.error');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
require PENGUINCODER_TEMPLATES . '/common-header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/menu/menu.inc';
|
||||
|
||||
switch ($actionId) {
|
||||
case 'post':
|
||||
case 'edit':
|
||||
if (!is_null($form)) {
|
||||
$renderer = &new Horde_Form_Renderer();
|
||||
if ($goodEntry) {
|
||||
$form->renderActive($renderer, $vars, Horde::selfUrl(), 'post');
|
||||
} else {
|
||||
$form->renderInactive($renderer, $vars, Horde::selfUrl(), 'post');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$commentcount = $registry->call('forums/numMessages', array(
|
||||
$entry['id'], 'penguincoder'));
|
||||
if (is_a($commentcount, 'PEAR_Error')) {
|
||||
$commentcount = 0;
|
||||
}
|
||||
if (!is_a($entry, 'PEAR_Error')) {
|
||||
require PENGUINCODER_TEMPLATES . '/data/header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/header.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/main.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/nav.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/admin.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/actions/footer.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/data/data.inc';
|
||||
require PENGUINCODER_TEMPLATES . '/data/footer.inc';
|
||||
}
|
||||
$comments = $registry->call('forums/postMessage', array(
|
||||
'penguincoder', $entry['id'], 'commentCallback'
|
||||
));
|
||||
$threads = $registry->call('forums/renderThreads', array(
|
||||
$entry['id'], true, 'penguincoder'));
|
||||
if (is_a($threads, 'PEAR_Error')) {
|
||||
$threads = $threads->getMessage();
|
||||
}
|
||||
if (is_a($comments, 'PEAR_Error')) {
|
||||
$comments = $comments->getMessage();
|
||||
}
|
||||
if (!empty($threads)) {
|
||||
echo '<br />' . $threads;
|
||||
}
|
||||
if (!empty($comments)) {
|
||||
echo '<br />' . $comments;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!is_a($entries, 'PEAR_Error') && count($entries)) {
|
||||
if ($direction == 'DESC') {
|
||||
$direction = 0;
|
||||
} else {
|
||||
$direction = 1;
|
||||
}
|
||||
require PENGUINCODER_TEMPLATES . '/journal/listheader.inc';
|
||||
$style = 'item0';
|
||||
$counter = 0;
|
||||
foreach ($entries as $entry) {
|
||||
if ($style === 'item1') {$style = 'item0';}
|
||||
else {$style = 'item1';}
|
||||
include PENGUINCODER_TEMPLATES . '/journal/listentry.inc';
|
||||
$counter++;
|
||||
}
|
||||
include PENGUINCODER_TEMPLATES . '/journal/listfooter.inc';
|
||||
}
|
||||
break;
|
||||
}
|
||||
echo '<p> </p>';
|
||||
require $registry->get('templates', 'horde') . '/common-footer.inc';
|
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
class PData
|
||||
{
|
||||
var $_db;
|
||||
var $_connected;
|
||||
var $_params;
|
||||
|
||||
function PData($params)
|
||||
{
|
||||
$this->_params = $params;
|
||||
}
|
||||
|
||||
function &singleton()
|
||||
{
|
||||
// array of instances
|
||||
static $instances;
|
||||
|
||||
// driver configuration
|
||||
$driver = $GLOBALS['conf']['storage']['driver'];
|
||||
$params = Horde::getDriverConfig('storage', $driver);
|
||||
|
||||
if (!isset($instances)) {
|
||||
$instances = array();
|
||||
}
|
||||
|
||||
// set up this driver configuration
|
||||
$signature = serialize(array($driver, $params));
|
||||
if (!isset($instances[$signature])) {
|
||||
$instances[$signature] = &new PData($params);
|
||||
}
|
||||
|
||||
return $instances[$signature];
|
||||
}
|
||||
|
||||
function getByCategoryAndLimit($category, $limit)
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
// Build up the query
|
||||
$query = sprintf('SELECT * FROM penguin_data WHERE category=%s ' .
|
||||
'LIMIT %d', $this->_db->quote($category));
|
||||
|
||||
// Log and submit query
|
||||
Horde::logMessage(sprintf('PData::getByCategoryAndLimit %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getAll($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getByTitle($title)
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
// Build up the query
|
||||
$query = sprintf('SELECT * FROM penguin_data WHERE title=%s',
|
||||
$this->_db->quote($category));
|
||||
|
||||
// Log and submit query
|
||||
Horde::logMessage(sprintf('PData::getByTitle %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getAll($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getByCategory($category, $order = 'id', $direction = 'ASC')
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
// Build up the query
|
||||
$query = sprintf('SELECT * FROM penguin_data WHERE category=%s ORDER ' .
|
||||
'BY %s %s', $this->_db->quote($category), $order, $direction);
|
||||
|
||||
// Log and submit query
|
||||
Horde::logMessage(sprintf('PData::getByCategory %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getAll($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getById($id)
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
// Build up the query
|
||||
$query = sprintf('SELECT * FROM penguin_data WHERE id=%d', $id);
|
||||
|
||||
// Log and submit query
|
||||
Horde::logMessage(sprintf('PData::getById %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getRow($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getJournalById($id, $oper, $order)
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
// Build up the query
|
||||
$query = sprintf('SELECT * FROM penguin_data WHERE id%s%d AND ' .
|
||||
'category="Journal" ORDER BY id %s LIMIT 1', $oper, $id,
|
||||
$order);
|
||||
|
||||
// Log and submit query
|
||||
Horde::logMessage(sprintf('PData::getJournalById %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getRow($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getNewestJournals()
|
||||
{
|
||||
$this->_connect();
|
||||
$query = 'SELECT * FROM penguin_data WHERE category = "Journal" ORDER '
|
||||
. 'BY id DESC LIMIT 5';
|
||||
|
||||
// db log/query
|
||||
Horde::logMessage(sprintf('PData::getNewestJournal %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->getAll($query, array(), DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
function getMaxJournalId()
|
||||
{
|
||||
$this->_connect();
|
||||
$query = 'SELECT MAX(id) FROM penguin_data WHERE category = "Journal"';
|
||||
|
||||
Horde::logMessage(sprintf('PDATA::getMaxJournalId %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$result = $this->_db->getRow($query);
|
||||
if(is_a('PEAR_Error', $result)) {
|
||||
$result = -1;
|
||||
} else {
|
||||
$result = $result[0];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getMinJournalId()
|
||||
{
|
||||
$this->_connect();
|
||||
$query = 'SELECT MIN(id) FROM penguin_data WHERE category = "Journal"';
|
||||
|
||||
Horde::logMessage(sprintf('PDATA::getMinJournalId %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$result = $this->_db->getRow($query);
|
||||
if(is_a('PEAR_Error', $result)) {
|
||||
$result = -1;
|
||||
} else {
|
||||
$result = $result[0];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function add($values = array())
|
||||
{
|
||||
// sanity checks
|
||||
if (!isset($values['title'])) {
|
||||
return PEAR::raiseError(_("No title is set!"));
|
||||
}
|
||||
if (!isset($values['info'])) { $values['info'] = ''; }
|
||||
if (!isset($values['attributes']) || !is_array($values['attributes'])) {
|
||||
$values['attributes'] = array();
|
||||
}
|
||||
|
||||
// db init
|
||||
$this->_connect();
|
||||
require_once 'Horde/SQL.php';
|
||||
$query = sprintf('INSERT INTO penguin_data %s', Horde_SQL::insertValues(
|
||||
$this->_db, $values));
|
||||
|
||||
// db log/query
|
||||
Horde::logMessage(sprintf('PData::add %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->query($query);
|
||||
}
|
||||
|
||||
function update($id, $values = array())
|
||||
{
|
||||
// sanity checks
|
||||
if (isset($values['id'])) { unset($values['id']); }
|
||||
|
||||
// db init
|
||||
$this->_connect();
|
||||
require_once 'Horde/SQL.php';
|
||||
$query = sprintf('UPDATE penguin_data SET %s WHERE id=%d',
|
||||
Horde_SQL::updateValues($this->_db, $values), $id);
|
||||
|
||||
// db log/query
|
||||
Horde::logMessage(sprintf('PData::update %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->query($query);
|
||||
}
|
||||
|
||||
function delete($id)
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
$query = sprintf('DELETE FROM penguin_data WHERE id=%d', $id);
|
||||
Horde::logMessage(sprintf('PData::delete %s', $query),
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
return $this->_db->query($query);
|
||||
}
|
||||
|
||||
function _connect()
|
||||
{
|
||||
// yay persistent connections
|
||||
if (!$this->_connected) {
|
||||
Horde::assertDriverConfig($this->_params, 'storage',
|
||||
array('phptype', 'hostspec', 'username', 'database',
|
||||
'charset'));
|
||||
|
||||
require_once 'DB.php';
|
||||
$this->_db = &DB::connect($this->_params,
|
||||
array('persistent' => !empty(
|
||||
$this->_params['persistent'])));
|
||||
if (is_a($this->_db, 'PEAR_Error')) {
|
||||
Horde::fatal($this->_db, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
$this->_db->setOption('optimize', 'portability');
|
||||
$this->_connected = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require_once 'Horde/Variables.php';
|
||||
require_once 'Horde/Form.php';
|
||||
require_once 'Horde/Form/Renderer.php';
|
||||
|
||||
class PDataForm extends Horde_Form
|
||||
{
|
||||
|
||||
function PDataForm(&$vars)
|
||||
{
|
||||
parent::Horde_Form($vars);
|
||||
|
||||
$this->setButtons(_("Save"));
|
||||
$this->addHidden('', 'actionId', 'text', true, false);
|
||||
$this->addHidden('', 'id', 'int', false, false);
|
||||
$this->addVariable(_("Data ID"), 'id', 'int', false, true);
|
||||
$this->addVariable(_("Time Posted"), 'time_created', 'time',
|
||||
false, true);
|
||||
$this->addVariable(_("Title"), 'title', 'text', true, false);
|
||||
$this->addVariable(_("Category"), 'category', 'text', true, false);
|
||||
$this->addVariable(_("Info"), 'info', 'longText', true, false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
class PenguinCoder
|
||||
{
|
||||
function getMenu($returnType = 'object')
|
||||
{
|
||||
global $registry, $conf;
|
||||
require_once 'Horde/Menu.php';
|
||||
$menu = &new Menu();
|
||||
|
||||
$menu->add(Horde::applicationUrl('index.php', true, 1.), _("/home"), 'home.png');
|
||||
$menu->add(Horde::applicationUrl('journal.php', true, 1.), _("Archive"), 'journal.png');
|
||||
$menu->add(Util::addParameter(Util::addParameter(Horde::applicationUrl('data.php', true, 1.), 'category', 'Machine'), 'title', _("Machines")), _("Machines"), 'machine.png');
|
||||
$menu->add(Util::addParameter(Util::addParameter(Horde::applicationUrl('data.php', true, 1.), 'category', 'About'), 'title', _("About")), _("About"), 'about.png');
|
||||
$menu->add(Horde::applicationUrl('rss.php', true), _("RSS"), 'rss.png');
|
||||
|
||||
if ($returnType == 'object') {
|
||||
return $menu;
|
||||
}
|
||||
return $menu->render();
|
||||
}
|
||||
|
||||
function fileUrl($filename)
|
||||
{
|
||||
if(is_null($filename) || !file_exists(escapeshellcmd($filename)))
|
||||
return '';
|
||||
return Horde::url($registry->get('webroot') . '/fileset/' .
|
||||
escapeshellcmd($filename), true, -1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
$_services['commentCallback'] = array(
|
||||
'args' => array('id' => 'string'),
|
||||
'type' => 'boolean'
|
||||
);
|
||||
|
||||
|
||||
function _penguincoder_commentCallback($entry_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
@define('HORDE_BASE', dirname(__FILE__) . '/../../');
|
||||
require HORDE_BASE . '/lib/core.php';
|
||||
|
||||
$registry = &Registry::singleton();
|
||||
if (is_a(($pushed = $registry->pushApp('penguincoder',
|
||||
!defined('AUTH_HANDLER'))), 'PEAR_Error')) {
|
||||
if ($pushed->getCode() == 'permission_denied') {
|
||||
Horde::authenticationFailureRedirect();
|
||||
}
|
||||
Horde::fatal($pushed, __FILE__, __LINE__, false);
|
||||
}
|
||||
$conf = &$GLOBALS['conf'];
|
||||
|
||||
@define('PENGUINCODER_TEMPLATES', $registry->get('templates'));
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__) . '/..');
|
||||
|
||||
$notification = &Notification::singleton();
|
||||
$notification->attach('status');
|
||||
|
||||
Horde::compressOutput();
|
||||
|
||||
require PENGUINCODER_BASE . '/lib/PenguinCoder.php';
|
||||
require PENGUINCODER_BASE . '/lib/Data.php';
|
||||
|
||||
$GLOBALS['pdata'] = &PData::singleton();
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
@define('PENGUINCODER_BASE', dirname(__FILE__));
|
||||
|
||||
require PENGUINCODER_BASE . '/lib/base.php';
|
||||
|
||||
require_once 'Horde/Template.php';
|
||||
$template = &new Horde_Template();
|
||||
|
||||
global $pdata;
|
||||
$entries = $pdata->getNewestJournals();
|
||||
|
||||
if (is_a($entries, 'PEAR_Error')) {
|
||||
exit("There was a problem fetching the entries: " . $entries->getMessage());
|
||||
}
|
||||
|
||||
$template->set('charset', NLS::getCharset());
|
||||
$template->set('channel_name', _("Penguin Coder"), NLS::getCharset());
|
||||
$template->set('channel_desc', _("The ramblings of a computer geek..."),
|
||||
NLS::getCharset());
|
||||
$template->set('channel_updated', @htmlspecialchars(date('r',
|
||||
($entries[0]['time_modified'] > 0 ? $entries[0]['time_modified'] :
|
||||
$entries[0]['time_created']))), NLS::getCharset());
|
||||
$template->set('channel_url', Horde::applicationUrl('index.php', true));
|
||||
|
||||
$baseUrl = Util::addParameter(Horde::applicationUrl('journal.php', true),
|
||||
'actionId', 'show');
|
||||
foreach ($entries as $key => $entry) {
|
||||
$entries[$key]['link'] = Util::addParameter($baseUrl, 'id', $entry['id']);
|
||||
}
|
||||
$template->set('entries', $entries);
|
||||
|
||||
header('Content-Type: text/xml');
|
||||
echo $template->fetch(PENGUINCODER_TEMPLATES . '/journal/rss.xml');
|
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE `penguin_data` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`time_created` int(11) NOT NULL default '0',
|
||||
`time_modified` int(11) NOT NULL default '0',
|
||||
`title` varchar(255) default NULL,
|
||||
`category` varchar(255) NOT NULL default 'Journal',
|
||||
`info` longtext,
|
||||
`attributes` longtext,
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
|
@ -0,0 +1,7 @@
|
|||
<?php $base_url = Util::addParameter(Horde::applicationUrl('admin.php', true), 'data_id', $d['id']); ?>
|
||||
<tr class="<?php echo $style ?>">
|
||||
<td align="center"><?php echo Horde::link(Util::addParameter($base_url, 'actionId', 'delete')) . Horde::img('delete.png', _("Delete Data Item"), 'height="16" width="16"', $registry->getImageDir('horde')) . '</a>'; ?></td>
|
||||
<td align="center"><?php echo Horde::link(Util::addParameter($base_url, 'actionId', 'edit'), _("Edit Data Item")) . $d['id'] . '</a>' ?></td>
|
||||
<td><?php echo $d['title'] ?></td>
|
||||
<td><?php echo $d['type'] ?></td>
|
||||
</tr>
|
|
@ -0,0 +1 @@
|
|||
</table>
|
|
@ -0,0 +1,7 @@
|
|||
<table width="100%" cellpadding="1" cellspacing="2" border="0">
|
||||
<tr class="smallheader">
|
||||
<td> </td>
|
||||
<td align="center">ID</td>
|
||||
<td>Title</td>
|
||||
<td>Type</td>
|
||||
</tr>
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
if (isset($language)) {
|
||||
header('Content-type: text/html; charset=' . NLS::getCharset());
|
||||
header('Vary: Accept-Language');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
|
||||
<?php echo !empty($language) ? '<html lang="' . strtr($language, '_', '-') . '">' : '<html>' ?>
|
||||
<head>
|
||||
<?php
|
||||
|
||||
$page_title = $registry->get('name');
|
||||
if (!empty($title)) $page_title .= ' :: ' . $title;
|
||||
if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) {
|
||||
echo "<meta http-equiv=\"refresh\" content=\"$refresh_time;url=$refresh_url\">\n";
|
||||
}
|
||||
|
||||
Horde::includeScriptFiles();
|
||||
?>
|
||||
<title><?php echo $page_title ?></title>
|
||||
<?php echo Horde::stylesheetLink('horde') ?>
|
||||
</head>
|
||||
|
||||
<body<?php if (Util::nonInputVar('bodyClass')) echo ' class="' . $bodyClass . '"' ?>>
|
|
@ -0,0 +1 @@
|
|||
<div class="item" style="padding: 3px;"><?php echo nl2br($entry['info']) ?></div>
|
|
@ -0,0 +1 @@
|
|||
</div><br />
|
|
@ -0,0 +1 @@
|
|||
<div class="solidbox" style="margin-right: 10%;margin-left: 10%;"><div class="header"><span class="header"><?php echo $entry['title'] ?></span><?php if(!empty($entry['time_created'])): ?> <span class="small">[Posted <?php echo date("r", $entry['time_created']) ?>]</span><?php endif; ?><?php if(!empty($entry['time_modified']) && $entry['time_modified'] != $entry['time_created']): ?> <span class="small">[Last Modified <?php echo date("r", $entry['time_modified']) ?>]</span><?php endif; ?></div>
|
|
@ -0,0 +1,6 @@
|
|||
<div align="center">
|
||||
<table style="border: 1px solid black;"><tr><td class="item">
|
||||
<pre>Who is driving?
|
||||
OMG Bear is driving, how can this be?!</pre>
|
||||
</td></tr></table></div>
|
||||
<br />
|
|
@ -0,0 +1 @@
|
|||
<tr style="padding: 0px;" onmouseover="className='selected';tdDate<?php echo $counter ?>.className='selected';tdInfo<?php echo $counter ?>.className='selected';" onmouseout="className='<?php echo $style ?>';" class="<?php echo $style ?>"><td style="width: 20%;" align="right" name="tdDate<?php echo $counter ?>"><?php echo strftime('%d %B %Y', $entry['time_created']) ?></td><td align="left" width="80%" name="tdInfo<?php echo $counter ?>"><?php echo Horde::link(Util::addParameter(Util::addParameter(Horde::applicationUrl('journal.php'), 'actionId', 'show'), 'id', $entry['id']))?><?php echo $entry['title'] ?></a></td></tr>
|
|
@ -0,0 +1 @@
|
|||
</table><br />
|
|
@ -0,0 +1,2 @@
|
|||
<table class="solidbox" style="margin-left: 10%;width: 80%;" cellspacing="0">
|
||||
<tr class="header"><td class="header" style="width: 20%;" align="right"><?php echo Horde::link(Util::addParameter(Util::addParameter(Horde::selfUrl(), 'order', 'date'), 'direction', ($direction ? '0' : '1')), _("Change Sort On Date"), 'header')?>Date Posted</a></td><td class="header"><?php echo Horde::link(Util::addParameter(Util::addParameter(Horde::selfUrl(), 'order', 'title'), 'direction', ($direction ? '0' : '1')), _("Change Sort On Title"), 'header')?>Title</a></td></tr>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="<tag:charset />"?>
|
||||
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<title><tag:channel_name /></title>
|
||||
<description><tag:channel_desc /></description>
|
||||
<link><tag:channel_url /></link>
|
||||
<pubDate><tag:channel_updated /></pubDate>
|
||||
<loop:entries>
|
||||
<item>
|
||||
<title><tag:entries.title /></title>
|
||||
<link><tag:entries.link /></link>
|
||||
</item>
|
||||
</loop:entries>
|
||||
</channel>
|
||||
</rss>
|
|
@ -0,0 +1,5 @@
|
|||
<table id="menu" width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr><td align="center"><?php echo Horde::img('banner.png', _("Banner")) ?></td></tr>
|
||||
<tr><td><?php echo PenguinCoder::getMenu('string') ?></td></tr></table>
|
||||
<br class="spacer"/>
|
||||
<?php $GLOBALS['notification']->notify(array('listeners' => 'status')) ?>
|
After Width: | Height: | Size: 659 B |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 49 B |
After Width: | Height: | Size: 859 B |
After Width: | Height: | Size: 667 B |
After Width: | Height: | Size: 803 B |
After Width: | Height: | Size: 802 B |
After Width: | Height: | Size: 760 B |
After Width: | Height: | Size: 942 B |
After Width: | Height: | Size: 981 B |