[pLog-svn] r5271 - in plugins/branches/lifetype-1.2: . cssnaked cssnaked/class cssnaked/class/action cssnaked/class/view cssnaked/locale cssnaked/templates
reto at devel.lifetype.net
reto at devel.lifetype.net
Tue Apr 3 17:48:33 EDT 2007
Author: reto
Date: 2007-04-03 17:48:33 -0400 (Tue, 03 Apr 2007)
New Revision: 5271
Added:
plugins/branches/lifetype-1.2/cssnaked/
plugins/branches/lifetype-1.2/cssnaked/class/
plugins/branches/lifetype-1.2/cssnaked/class/action/
plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigaction.class.php
plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigupdateaction.class.php
plugins/branches/lifetype-1.2/cssnaked/class/view/
plugins/branches/lifetype-1.2/cssnaked/class/view/admincssnakedconfigview.class.php
plugins/branches/lifetype-1.2/cssnaked/locale/
plugins/branches/lifetype-1.2/cssnaked/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/cssnaked/plugincssnaked.class.php
plugins/branches/lifetype-1.2/cssnaked/readme.txt
plugins/branches/lifetype-1.2/cssnaked/templates/
plugins/branches/lifetype-1.2/cssnaked/templates/pluginsettings.template
Log:
adding cssnaked plugin.
participate and get naked, too! more info:
http://hugi.to/blog/archive/2007/04/03/getting-naked-on-the-5th-of-april
Added: plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigaction.class.php 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,24 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/cssnaked/class/view/admincssnakedconfigview.class.php" );
+
+ class AdminCssNakedConfigAction extends AdminAction
+ {
+ function AdminCssNakedConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_plugins" );
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminCssNakedConfigView ( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigupdateaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigupdateaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/class/action/admincssnakedconfigupdateaction.class.php 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,92 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/cssnaked/class/view/admincssnakedconfigview.class.php" );
+
+ class AdminCssNakedConfigUpdateAction extends AdminAction
+ {
+
+ var $_pluginEnabled;
+ var $_startDate;
+ var $_endDate;
+ var $_addNotice;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminCssNakedConfigUpdateAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ $this->_addNotice = $this->_request->getValue( "addNotice" );
+ $this->_addNotice = ($this->_addNotice != "" );
+
+ if ( ( $this->_startDate = strtotime($this->_request->getValue("startDate")) ) === false ) {
+
+ $this->_view = new AdminCssNakedConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("cssnaked_error_startDate"));
+ $this->setCommonData();
+ return false;
+ }
+
+ if ( ( $this->_endDate = strtotime($this->_request->getValue("endDate")) ) === false) {
+ $this->_view = new AdminCssNakedConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("cssnaked_error_endDate"));
+ $this->setCommonData();
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_cssnaked_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_cssnaked_startDate", $this->_startDate );
+ $blogSettings->setValue( "plugin_cssnaked_endDate", $this->_endDate );
+ $blogSettings->setValue( "plugin_cssnaked_addNotice", $this->_addNotice );
+
+ //TODO
+ //$blogSettings->setValue( "plugin_cssnaked_timeFrame", );
+
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo )) {
+ $this->_view = new AdminCssNakedConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new AdminCssNakedConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("cssnaked_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/cssnaked/class/view/admincssnakedconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/class/view/admincssnakedconfigview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/class/view/admincssnakedconfigview.class.php 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,46 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ define("DEFAULT_DATE", "2007-04-05");
+
+ /**
+ * implements the configuration view
+ */
+ class AdminCssNakedConfigView extends AdminPluginTemplatedView
+ {
+
+ function AdminCssNakedConfigView ( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "cssnaked", "pluginsettings" );
+ }
+
+ function render()
+ {
+ $default = strtotime(DEFAULT_DATE);
+
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+
+ $pluginEnabled = $blogSettings->getValue( "plugin_cssnaked_enabled" );
+ $addNotice = $blogSettings->getValue( "plugin_cssnaked_addNotice");
+
+ $startDate = date('Y-m-d', $blogSettings->getValue("plugin_cssnaked_startDate", $default));
+ $endDate = date('Y-m-d', $blogSettings->getValue("plugin_cssnaked_endDate", $default));
+
+
+ //TODO
+ //$timeFrame = $blogSettings->getValue( "plugin_cssnaked_timeFrame" );
+
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "startDate", $startDate );
+ $this->setValue( "endDate", $endDate );
+ $this->setValue( "addNotice", $addNotice );
+
+
+ parent::render();
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/cssnaked/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/locale/locale_en_UK.php 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,25 @@
+<?php
+$messages["manageAppearancePlugins"] = "Appearance Management";
+$messages['cssnaked'] = 'CSS Naked';
+$messages['cssnaked_plugin'] = 'CSS Naked';
+$messages['cssnaked_plugin_enabled'] = 'Enable the CSS Naked Plugin';
+
+$messages['label_cssnaked_addNotice'] = 'Add Notice';
+$messages['help_cssnaked_addNotice'] = 'Add the message below at the top of your page while your blog is naked. (The message can be edited in the locale files at ./plugins/cssnaked/locale).';
+
+$messages['label_cssnaked_startDate'] = 'Start Date';
+$messages['help_cssnaked_startDate'] = 'The day you want to start getting naked. [Default = 2007-04-05]';
+$messages['label_cssnaked_endDate'] = 'End Date';
+$messages['help_cssnaked_endDate'] = 'The day you\'d like to get dressed again (usually the same date). [Default = 2007-04-05]';
+
+
+$messages['cssnaked_settings_saved_ok'] = 'CSS Naked settings saved successfully!';
+
+$messages['cssnaked_error_startDate'] = 'Error setting the start date.';
+$messages['cssnaked_error_endDate'] = 'Error setting the end date.';
+
+$messages['cssnaked_notice'] = '<h3>What happened to the design?</h3>
+<p><em>To know more about why styles are disabled on this website visit the
+<a href="http://naked.dustindiaz.com" title="Web Standards Naked Day Host Website">
+Annual CSS Naked Day</a> website for more information.</em></p>';
+?>
Added: plugins/branches/lifetype-1.2/cssnaked/plugincssnaked.class.php
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/plugincssnaked.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/plugincssnaked.class.php 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,140 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+ class PluginCssNaked extends PluginBase
+ {
+
+ var $_pluginEnabled;
+ var $_startDate;
+ var $_endDate;
+ var $_timeFrame = 48;
+ var $_addNotice;
+ var $_notice;
+
+ function PluginCssNaked ( $source = '' )
+ {
+ $this->PluginBase( $source );
+
+ $this->id = "cssnaked";
+ $this->version = "20070403";
+ $this->author = "Reto Hugi";
+ $this->desc = "Deactivates all CSS Styles on the active template. This Template was written to easily participate at the <a href=\"http://naked.dustindiaz.com/\">CSS Naked Day</a>. The idea behind this event is to promote Web Standards. Plain and simple. This includes proper use of (x)html, semantic markup, a good hierarchy structure, and of course, a good 'ol play on words. It's time to show off your <body>.";
+
+ $this->locales = Array( "en_UK" );
+
+ if( $source == "admin" ) {
+
+ // register an action for the plugin configuration
+ $this->registerAdminAction( "cssnakedConfig", "AdminCssNakedConfigAction" );
+ $this->registerAdminAction( "cssnakedUpdateConfig", "AdminCssNakedConfigUpdateAction" );
+
+ // add a menu entry
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "" );
+ $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "cssnaked", "?op=cssnakedConfig");
+
+ }
+ else {
+
+ // hook up to our event if we are not in admin mode
+ $this->registerNotification( EVENT_PROCESS_BLOG_TEMPLATE_OUTPUT );
+ }
+ }
+
+ function register()
+ {
+ $config =& Config::getConfig();
+
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->_pluginEnabled = $blogSettings->getValue( "plugin_cssnaked_enabled" );
+ $this->_startDate = $blogSettings->getValue( "plugin_cssnaked_startDate" );
+ $this->_endDate = $blogSettings->getValue( "plugin_cssnaked_endDate" );
+ $this->_addNotice = $blogSettings->getValue( "plugin_cssnaked_addNotice" );
+
+ //get the notice from the locale
+ $locale =& $this->blogInfo->getLocale();
+ $this->_notice = $locale->tr('cssnaked_notice');
+
+ //TODO
+ //$this->_timeFrame = $blogSettings->getValue( "plugin_cssnaked_timeFrame" );
+ }
+
+ function getPluginConfigurationKeys()
+ {
+ return( Array(
+ Array( "name" => "plugin_cssnaked_enabled", "type" => "boolean" )
+ ));
+ }
+
+ function process( $event, $params )
+ {
+
+ // check if the plugin is enabled and do nothing if not.
+ if (!$this->_pluginEnabled) { return true; }
+
+ // check if today is a naked day ;)
+ if ( !$this->isNakedDay() ) { return true; }
+
+ // all checks passed, so let's get naked!
+ $content = $params["content"];
+ $content = $this->_strip($content);
+
+ // check if we want to add a notice at the top
+ if ($this->_addNotice) {
+ $content =& $this->_addNotice($content);
+ }
+
+ // write the naked content back to send the content to the browser
+ $params["content"] = $content;
+ }
+
+ // parts of this method where inspired by http://www.ajalapus.com
+ function isNakedDay() {
+
+ if ($this->_timeFrame === 48) {
+
+ // Start of the Day on GMT+12
+ $stime = gmmktime( -12, 0, 0, date('n',$this->_startDate), date('j',$this->_startDate) );
+ // End of the Day on GMT-12
+ $etime = gmmktime(36, 0, 0, date('n',$this->_endDate), date('j',$this->_endDate) );
+ }
+ else {
+ //TODO: other time frame than 48h and taking the blogs time offset into account
+
+ }
+
+ $ntime = time(); // Time now
+echo $stime.'-'.$etime.'-'.$ntime;
+ if ($ntime >= $stime && $ntime <= $etime) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ // parts of this method where inspired by http://www.ajalapus.com
+ function _strip(&$content) {
+
+ $pattern = array(
+ '/<\?xml-stylesheet.*\?>/sU', // x(ht)ml stylesheet directive
+ '/<link.*rel\s*=\s*["\'].*stylesheet.*>/sU', // (x)html stylesheet reference
+ '/<style.*<\/style>/sU', // (x)html embedded stylesheet
+ '/style\s*=\s*".*"/U', // (x)html inline stylesheet "
+ '/style\s*=\s*\'.*\'/U' // (x)html inline stylesheet '
+ );
+
+ return preg_replace($pattern, '', $content);
+ }
+
+
+ function _addNotice(&$content) {
+
+ $pattern = '/<body(.*)>/U';
+
+ return preg_replace($pattern, $this->_notice, $content);
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/cssnaked/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/readme.txt 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,11 @@
+Plugin: CSS Naked
+Author: Reto Hugi
+Release Date: 2007-04-03
+
+This plugin helps you easily getting naked on the CSS Naked Day (see http://naked.dustindiaz.com/ for more information)
+
+Installation:
+1. unzip and copy the cssnaked folder to your ./plugins directory
+2. login to your lifetype blog and to to Administration -> Plugin Centre to check if the plugin is listed
+3. go to Control Centre -> CSS Naked to enable the plugin
+4. that's it
Added: plugins/branches/lifetype-1.2/cssnaked/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/cssnaked/templates/pluginsettings.template (rev 0)
+++ plugins/branches/lifetype-1.2/cssnaked/templates/pluginsettings.template 2007-04-03 21:48:33 UTC (rev 5271)
@@ -0,0 +1,57 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=cssnakedPluginSettings title=$locale->tr("cssnaked_plugin")}
+
+
+<form name="cssnakedPluginSettings" method="post" action="admin.php">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+
+<!-- enable/disable -->
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled}checked="checked"{/if} value="1" {user_cannot_override key=plugin_cssnaked_enabled}disabled="disabled"{/user_cannot_override} />{$locale->tr("cssnaked_plugin_enabled")}
+ </div>
+ </div>
+
+<!-- Start Date -->
+ <div class="field" id="startDateContainer">
+ <label for="length">{$locale->tr("label_cssnaked_startDate")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("help_cssnaked_startDate")}</div>
+ <input class="text" type="text" name="startDate" id="startDate" value="{$startDate}" autocomplete="off" {user_cannot_override key=plugin_cssnaked_length}disabled="disabled"{/user_cannot_override} />
+ </div>
+
+
+<!-- End Date -->
+ <div class="field" id="endDateContainer">
+ <label for="length">{$locale->tr("label_cssnaked_endDate")}</label>
+ <div class="formHelp">{$locale->tr("help_cssnaked_endDate")}</div>
+ <input class="text" type="text" name="endDate" id="endDate" value="{$endDate}" autocomplete="off" {user_cannot_override key=plugin_cssnaked_length}disabled="disabled"{/user_cannot_override} />
+ </div>
+
+<!-- Add Notice -->
+ <div class="field">
+ <label for="addNotice">{$locale->tr("label_cssnaked_addNotice")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="addNotice" id="addNotice" {if $addNotice}checked="checked"{/if} value="1" />{$locale->tr("help_cssnaked_addNotice")}
+ </div>
+ <div style="margin:15px 100px 0px 100px;border:1px solid #ccc;padding:10px;">
+ {$locale->tr("cssnaked_notice")}
+ </div>
+
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="cssnakedUpdateConfig" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
More information about the pLog-svn
mailing list