[pLog-svn] r6306 - in plugins/branches/lifetype-1.2: . crystalpoll crystalpoll/class crystalpoll/class/action crystalpoll/class/dao crystalpoll/class/styles crystalpoll/class/view crystalpoll/imgs crystalpoll/js crystalpoll/locale crystalpoll/templates
reto at devel.lifetype.net
reto at devel.lifetype.net
Sat Apr 12 05:51:55 EDT 2008
Author: reto
Date: 2008-04-12 05:51:54 -0400 (Sat, 12 Apr 2008)
New Revision: 6306
Added:
plugins/branches/lifetype-1.2/crystalpoll/
plugins/branches/lifetype-1.2/crystalpoll/class/
plugins/branches/lifetype-1.2/crystalpoll/class/action/
plugins/branches/lifetype-1.2/crystalpoll/class/action/addvoteaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/adminaddpollaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/admindeletepollsaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollsaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/adminnewpollaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/adminpollsettingsaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollsettingsaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/action/readpollaction.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/dao/
plugins/branches/lifetype-1.2/crystalpoll/class/dao/poll.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/dao/polls.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/styles/
plugins/branches/lifetype-1.2/crystalpoll/class/styles/pollstyles.properties.php
plugins/branches/lifetype-1.2/crystalpoll/class/view/
plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollsview.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollview.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/view/adminnewpollview.class.php
plugins/branches/lifetype-1.2/crystalpoll/class/view/adminpollsettingsview.class.php
plugins/branches/lifetype-1.2/crystalpoll/imgs/
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_1.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_10.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_11.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_12.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_13.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_2.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_3.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_4.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_5.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_6.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_7.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_8.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_9.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_1.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_10.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_11.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_12.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_13.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_2.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_3.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_4.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_5.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_6.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_7.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_8.jpg
plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_9.jpg
plugins/branches/lifetype-1.2/crystalpoll/js/
plugins/branches/lifetype-1.2/crystalpoll/js/choices.js
plugins/branches/lifetype-1.2/crystalpoll/js/crystalPollAjax.js
plugins/branches/lifetype-1.2/crystalpoll/locale/
plugins/branches/lifetype-1.2/crystalpoll/locale/locale_ar_SA.php
plugins/branches/lifetype-1.2/crystalpoll/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/crystalpoll/plugincrystalpoll.class.php
plugins/branches/lifetype-1.2/crystalpoll/readme.txt
plugins/branches/lifetype-1.2/crystalpoll/templates/
plugins/branches/lifetype-1.2/crystalpoll/templates/chart.template
plugins/branches/lifetype-1.2/crystalpoll/templates/editpoll.template
plugins/branches/lifetype-1.2/crystalpoll/templates/editpolls.template
plugins/branches/lifetype-1.2/crystalpoll/templates/newpoll.template
plugins/branches/lifetype-1.2/crystalpoll/templates/pollsettings.template
Log:
First commit of Ahmad Saleh's CrystalPoll plugin. Thank you very much Ahmad! Looks nice :)
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/addvoteaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/addvoteaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/addvoteaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,47 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+
+ /**
+ * Adds new vote action
+ */
+ class AddVoteAction extends BlogAction
+ {
+
+ function AddVoteAction( $actionInfo, $request )
+ {
+ $this->BlogAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ // Get poll Id and the selected choice
+ $pollId = $this->_request->getValue( 'pollId' );
+ $choice = $this->_request->getValue( 'choice' );
+
+ // Check if selected choice and poll id passed successfully
+ // If choice key = 0 (that mean the first choice was selected) or choice key grater than 0
+ if( ($choice > 0 || $choice === '0') && $pollId ) {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/net/client.class.php" );
+
+ // Get client host Ip address
+ $clientIp = Client::getIp();
+
+ $polls = new Polls();
+ // Check if there is any vote came from this IP on this poll
+ if( !$polls->validateVoteByIp( $clientIp, $pollId) ) {
+ $poll = $polls->getPoll( $pollId );
+
+ if( $poll ) {
+ $polls->addPollVote( $pollId, $choice, $clientIp, date( 'Y-m-d' ) );
+ echo 1;
+ exit;
+ }
+ }
+ }
+ echo 0;
+ exit;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/adminaddpollaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/adminaddpollaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/adminaddpollaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,62 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/adminnewpollview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+
+ /**
+ * Adds new poll action
+ */
+ class AdminAddPollAction extends AdminAction
+ {
+ function AdminAddPollAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // Validation
+ $this->registerFieldValidator( 'pollText', new StringValidator() );
+ $this->registerFieldValidator( 'choice', new ArrayValidator() );
+
+ // Create error view object
+ $view = new AdminNewPollView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( 'error_adding_poll' ));
+ $this->setValidationErrorView( $view );
+
+ // Check permissions
+ $this->requirePermission( 'manage_admin_plugins' );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/poll.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+ // Create view
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+
+ // Text filtering
+ $pollText = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML( $this->_request->getValue('pollText') )));
+ $choices = $this->_request->getValue( 'choice' );
+ foreach( $choices as $key => $value ) {
+ $choices[$key] = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML( $value )));
+ }
+
+ $polls = new Polls();
+
+ // Add poll
+ $poll = new Poll( $pollText, $this->_blogInfo->getId(), $choices );
+ if( !$polls->addPoll( $poll ) ) {
+ $this->_view->setErrorMessage( $this->_locale->tr( 'error_adding_poll' ) );
+ $this->setCommonData();
+ return false;
+ }
+
+ $this->_view->setSuccessMessage( $this->_locale->tr( 'poll_added_ok' ) );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/admindeletepollsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/admindeletepollsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/admindeletepollsaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,79 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+
+ /**
+ * Delete polls action
+ */
+ class AdminDeletePollsAction extends AdminAction
+ {
+ var $_pollIds;
+
+ function AdminDeletePollsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ if( !$request['pollId'] ) {
+ $this->registerFieldValidator( 'pollIds', new ArrayValidator() );
+ $this->_pollIds = $this->_request->getValue( 'pollIds' );
+ } else {
+ $this->_pollIds = array( $this->_request->getValue( 'pollId' ) );
+ }
+
+ // Create errors view object
+ $view = new AdminEditPollsView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( 'error_deleting_polls' ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/poll.class.php" );
+
+ // Create view object
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+
+ $polls = new Polls();
+
+ foreach( $this->_pollIds as $pollId ) {
+ $poll = $polls->getPoll( $pollId );
+ // Check if poll exist
+ if( !$poll ) {
+ $errorMessage .= $this->_locale->pr( "error_deleting_poll2", $pollId );
+ } else {
+ // Save poll text before delete for messages (error or success)
+ $pollText = $poll->getText();
+ // Check if this poll belong to this blog
+ if( $poll->getBlogId() != $this->_blogInfo->getId() ) {
+ $errorMessage .= $this->_locale->pr( "error_deleting_poll2", $pollId );
+
+ } elseif( !$polls->deletePoll($pollId) ) {
+ $this->_view->setErrorMessage( $this->_locale->pr( "error_deleting_poll", $pollText ) );
+
+ } else {
+
+ $totalOk++;
+ if( $totalOk < 2 ) {
+ $successMessage .= $this->_locale->pr( "poll_deleted_ok", $pollText )."<br/>";
+ } else {
+ $successMessage = $this->_locale->pr( "polls_deleted_ok", $totalOk );
+ }
+ }
+ }
+ }
+ if( $errorMessage ) {
+ $this->_view->setErrorMessage( $errorMessage );
+ }
+ if( $successMessage ) {
+ $this->_view->setSuccessMessage( $successMessage );
+ }
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,59 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+
+ /**
+ * Edit polls action
+ */
+ class AdminEditPollAction extends AdminAction
+ {
+ function AdminEditPollAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // Validation
+ $this->registerFieldValidator( "pollId", new IntegerValidator() );
+
+ // Create error view object
+ $view = new AdminEditPollsView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_editing_poll" ));
+ $this->setValidationErrorView( $view );
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollview.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+
+ // Get parameters
+ $pollId = $this->_request->getValue( 'pollId' );
+
+ $polls = new Polls();
+ $poll = $polls->getPoll( $pollId );
+
+ // Check if poll object exist
+ if( !$poll ) {
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_editing_poll" ) );
+ $this->setCommonData();
+ return false;
+ }
+ // Check if this poll belong to this blog
+ if( $poll->getBlogId() != $this->_blogInfo->getId() ) {
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_editing_poll" ) );
+ $this->setCommonData();
+ return false;
+ }
+
+ $this->_view = new AdminEditPollView( $this->_blogInfo );
+ $this->_view->setValue( "poll", $poll );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/admineditpollsaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,26 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+
+ /**
+ * Edit polls action
+ */
+ class AdminEditPollsAction extends AdminAction
+ {
+ function AdminEditPollsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ // initialize the view
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/adminnewpollaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/adminnewpollaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/adminnewpollaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,26 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/adminnewpollview.class.php" );
+
+ /**
+ * New poll action
+ */
+ class AdminNewPollAction extends AdminAction
+ {
+ function AdminNewPollAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ // initialize the view
+ $this->_view = new AdminNewPollView( $this->_blogInfo );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/adminpollsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/adminpollsettingsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/adminpollsettingsaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,26 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/adminpollsettingsview.class.php" );
+
+ /**
+ * Polls settings action
+ */
+ class AdminPollSettingsAction extends AdminAction
+ {
+ function AdminPollSettingsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ // initialize the view
+ $this->_view = new AdminPollSettingsView( $this->_blogInfo );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,82 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+
+ /**
+ * Update poll action
+ */
+ class AdminUpdatePollAction extends AdminAction
+ {
+ function AdminUpdatePollAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // validation
+ $this->registerFieldValidator('pollText', new StringValidator());
+ $this->registerFieldValidator('choice', new ArrayValidator());
+ $this->registerFieldValidator('pollId', new IntegerValidator());
+
+ // Create error view object
+ $view = new AdminEditPollView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_updating_poll" ));
+ $this->setValidationErrorView( $view );
+
+ // check for permission
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/poll.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+
+ // text filtering
+ $pollText = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML($this->_request->getValue('pollText'))));
+ $choices = $this->_request->getValue('choice');
+ foreach( $choices as $key => $value ) {
+ $choices[$key] = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML($value)));
+ }
+
+ // Get poll id from request
+ $pollId = $this->_request->getValue('pollId');
+ $polls = new Polls();
+
+ $poll = $polls->getPoll($pollId);
+
+ // Check if valid poll
+ if( !$poll ) {
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_poll") );
+ $this->setCommonData();
+ return false;
+ }
+
+ // Check if this poll belong to this blog
+ if( $poll->getBlogId() != $this->_blogInfo->getId() ) {
+ $this->_view->setErrorMessage( $this->_locale->pr( "error_updating_poll2", $pollId ) );
+ $this->setCommonData();
+ return false;
+ }
+
+ $poll->setText( $pollText );
+ $poll->setChoices( $choices );
+
+ if( !$polls->updatePoll($poll) ) {
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_updating_poll" ) );
+ $this->setCommonData();
+ return false;
+ }
+
+ $this->_view->setSuccessMessage( $this->_locale->tr( "poll_updated_ok" ) );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollsettingsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/adminupdatepollsettingsaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,74 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+
+ /**
+ * Update poll settings action
+ */
+ class AdminUpdatePollSettingsAction extends AdminAction
+ {
+ function AdminUpdatePollSettingsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->registerField('selectedPoll');
+ $this->registerField('styleId');
+
+ $this->requirePermission( "manage_admin_plugins" );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/view/admineditpollsview.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+
+ // Create view object
+ $this->_view = new AdminEditPollsView( $this->_blogInfo );
+
+ $selectedPoll = $this->_request->getValue( 'selectedPoll' );
+ $styleId = $this->_request->getValue( 'styleId' );
+
+ $polls = new Polls();
+ if( $selectedPoll ) {
+ $poll = $polls->getPoll( $selectedPoll );
+ // Check if selected poll exists
+ if( !$poll ) {
+ $this->_view->setErrorMessage( $this->_locale->tr( "error_updating_poll_settings" ) );
+ $this->setCommonData();
+ return false;
+ }
+ // Check if selected poll belong to this blog
+ if( $poll->getBlogId() != $this->_blogInfo->getId() ) {
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_poll_settings") );
+ $this->setCommonData();
+ return false;
+ }
+ }
+
+ // Get polls settings
+ $pollSettings = $polls->getPollsSettings( $this->_blogInfo->getId() );
+
+ // If there is no poll settings for this blog then we will create one else
+ // we well update it.
+ if( !$pollSettings ) {
+ $result = $polls->addPollsSettings( $this->_blogInfo->getId(), array( 'selected_poll' => $selectedPoll, 'poll_style' => $styleId ) );
+ if( !$result ) {
+ $this->_view->setErrorMessage( $this->_locale->tr("error_adding_poll_settings") );
+ $this->setCommonData();
+ return false;
+ }
+ } else {
+ $result = $polls->updatePollsSettings( $this->_blogInfo->getId(), array( 'selected_poll' => $selectedPoll, 'poll_style' => $styleId ) );
+ if( !$result ) {
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_poll_settings") );
+ $this->setCommonData();
+ return false;
+ }
+ }
+
+ $this->_view->setSuccessMessage( $this->_locale->tr("poll_settings_updated_ok") );
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/action/readpollaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/action/readpollaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/action/readpollaction.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,80 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+
+ /**
+ * Read poll action
+ */
+ class ReadPollAction extends BlogAction
+ {
+ function ReadPollAction( $actionInfo, $request )
+ {
+ $this->BlogAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/net/client.class.php" );
+
+ $polls = new Polls();
+ $locale = $this->_blogInfo->getLocale();
+
+ $pollSettings = $polls->getPollsSettings( $this->_blogInfo->getId());
+ if( $pollSettings['selected_poll'] ){
+ $poll = $polls->getPoll( $pollSettings['selected_poll'] );
+ }
+ if( $poll ){
+ $clientIp = Client::getIp();
+ $config = Config::getConfig();
+ $baseUrl = $config->getValue( 'base_url' );
+
+ if( $polls->validateVoteByIp( $clientIp, $poll->getId() ) ) {
+ include( PLOG_CLASS_PATH."plugins/crystalpoll/class/styles/pollstyles.properties.php" );
+
+ $pollStyleKey = $pollSettings['poll_style'];
+ if( !$pollStyleKey ) {
+ $pollStyleKey = 'default';
+ }
+ $pollStyle = $poll2dStyle[$pollStyleKey];
+ if( !$pollStyle ) {
+ $pollStyle = $poll3dStyle[$pollStyleKey];
+ }
+ $choices = $poll->getChoices();
+ $votes = $polls->getChoicesVotesCount( $poll->getId() );
+ $totalVotes = array_sum( $votes );
+
+ $html = "<div id='pollDiv'>";
+ $html .= "<label>".$poll->getText()."</label><br/><br/>";
+ foreach( $choices as $choiceId => $choiceText ) {
+ $html .= "<div>";
+ if( $votes[$choiceId] ) {
+ $percent = ($votes[$choiceId] / $totalVotes) * 100;
+ } else {
+ $percent = 0;
+ }
+ $html .= $choiceText.' ( '.number_format($percent, 1).' % )<br/>';
+ $percent = ( !$percent ? 1 : $percent );
+ $html .= '<img src="'.$baseUrl.'/'.$pollStyle.'" style="width:'.number_format((($percent/100) *80), 0).'%; height:10px; margin: 2px;"/>';
+ $html .= "</div>";
+ }
+ $html .= $locale->tr('totalVotes')." ($totalVotes)</div>";
+ } else {
+ $choices = $poll->getChoices();
+
+ $html = "<form id='poll'>
+ <div id=pollDiv><label>".$poll->getText()."</label><br/>";
+ foreach( $choices as $choiceKey => $choiceValue ) {
+ $html .= "<input type='radio' id='choice_$choiceKey' name='choice' value='$choiceKey' onClick='selectChoice(\"$choiceKey\");'/>
+ <label for='choice_$choiceKey'>$choiceValue</label><br/>";
+ }
+ $html .= "<input type='hidden' id='pollId' name='pollId' value='".$poll->getId()."'/>
+ <input id='vote' value='".$locale->tr('vote')."' type='button' onClick='addVote();'/>
+ </div></form>";
+ }
+ }
+ print $html;
+ exit;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/dao/poll.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/dao/poll.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/dao/poll.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,80 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
+
+ /**
+ * Poll Vote
+ */
+ class Poll extends DbObject
+ {
+
+ var $_id;
+ var $_text;
+ var $_blogId;
+ var $_choices;
+
+ function Poll( $text, $blogId, $choices = array(), $id = 0 )
+ {
+ $this->_text = $text;
+ $this->_blogId = $blogId;
+ $this->_id = $id;
+ $this->_choices = $choices;
+ $this->_pk = 'id';
+ $this->_fields = Array(
+ "id" => "getId",
+ "text" => "getText",
+ "blog_id" => "getBlogId",
+ "choices" => "getSerializedChoices"
+ );
+ }
+
+ /**
+ * Set methods
+ */
+ function setId( $id )
+ {
+ $this->_id = $id;
+ }
+ function setText( $text )
+ {
+ $this->_text = $text;
+ }
+ function setBlogId( $blogId )
+ {
+ $this->_blogId = $blogId;
+ }
+ function setChoices( $choices )
+ {
+ $this->_choices = $choices;
+ }
+ /**
+ * Get methods
+ */
+ function getId()
+ {
+ return $this->_id;
+ }
+ function getBlogId()
+ {
+ return $this->_blogId;
+ }
+ function getText()
+ {
+ return $this->_text;
+ }
+ function getChoices()
+ {
+ return $this->_choices;
+ }
+ function getSerializedChoices()
+ {
+ return serialize( $this->_choices );
+ }
+ function getChoicesVotesCount()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ $polls = new Polls();
+ return $polls->getChoicesVotesCount($this->_id);
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/dao/polls.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/dao/polls.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/dao/polls.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,297 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/poll.class.php" );
+
+ /**
+ * Polls
+ */
+ class Polls extends Model
+ {
+ /**
+ * Initialize variables
+ */
+ function Polls()
+ {
+ $this->Model();
+ $this->table = $this->getPrefix().'polls';
+ $this->pk = 'id';
+ }
+
+ /**
+ * Get poll object by it's id
+ *
+ * @param int $id
+ * @return Poll object
+ */
+ function getPoll( $id )
+ {
+ $query = "SELECT * FROM {$this->table} WHERE id = ".DB::qstr( $id );
+ return $this->_getPollFromQuery( $query );
+ }
+
+
+ /**
+ * Get all polls for specific blog
+ *
+ * @param int $blogId
+ * @return array of Polls
+ */
+ function getBlogPolls( $blogId )
+ {
+ $query = "SELECT * FROM {$this->table} WHERE blog_id = ".DB::qstr( $blogId );
+ return $this->_getPollsFromQuery( $query );
+ }
+
+ /**
+ * Get votes count for each choice in specific poll
+ *
+ * @param int $pollId
+ * @return array of votes counts
+ */
+ function getChoicesVotesCount($pollId)
+ {
+ $query = "SELECT choice_id, COUNT(*) as count FROM ".$this->getPrefix()."poll_votes
+ WHERE poll_id = ".DB::qstr( $pollId )." group by choice_id";
+ $result = $this->Execute( $query );
+ if( !$result ) {
+ return false;
+ }
+ $choices = array();
+ while( $row = $result->FetchRow() ) {
+ $choices[$row['choice_id']] = $row['count'];
+ }
+ return $choices;
+ }
+
+ /**
+ * Check if there is any vote for specific poll from specific IP address
+ *
+ * @param String $clientIp
+ * @param int $pollId
+ * @return true if vote exists or false if not
+ */
+ function validateVoteByIp( $clientIp, $pollId )
+ {
+ $query = "SELECT COUNT(*) as count FROM ".$this->getPrefix()."poll_votes
+ WHERE ip = '".DB::qstr( $clientIp )."' AND poll_id = ".DB::qstr( $pollId );
+ $result = $this->Execute( $query );
+ if( !$result ){
+ return false;
+ }
+ $row = $result->FetchRow();
+ return $row['count'];
+ }
+
+ /**
+ * Add vote to database
+ *
+ * @param int $pollId
+ * @param int $choiceId
+ * @param String $ip
+ * @param date $date
+ * @return true if added successfully
+ */
+ function addPollVote( $pollId, $choiceId, $ip, $date )
+ {
+ $query = "INSERT INTO ".$this->getPrefix()."poll_votes( poll_id, choice_id, ip, date )
+ VALUES( ".DB::qstr($pollId).", ".DB::qstr($choiceId).", '".DB::qstr($ip)."', '".DB::qstr($date)."')";
+ return $this->Execute( $query );
+ }
+
+ /**
+ * Add poll to database
+ *
+ * @param Poll $poll
+ * @return true if added successfully
+ */
+ function addPoll( &$poll )
+ {
+ return $this->add( $poll );
+ }
+
+ /**
+ * update poll
+ *
+ * @param Poll $poll
+ * @return true if updated successfully
+ */
+ function updatePoll( $poll )
+ {
+ if( !$this->update( $poll ) ) {
+ return false;
+ }
+ return $this->deletePollVotes($poll->getId());
+ }
+
+ /**
+ * Delete poll
+ *
+ * @param int $pollId
+ * @return true if deleted successfully
+ */
+ function deletePoll( $pollId )
+ {
+ if( !$this->delete( 'id', $pollId ) ) {
+ return false;
+ }
+ return $this->deletePollVotes($pollId);
+ }
+
+ /**
+ * Delete all votes for specific poll
+ *
+ * @param int $pollId
+ * @return true fi deleted successfully
+ */
+ function deletePollVotes( $pollId )
+ {
+ $query = "DELETE FROM ".$this->getPrefix()."poll_votes WHERE poll_id = ".DB::qstr( $pollId );
+ return $this->Execute($query);
+ }
+
+ /**
+ * Get blog polls settings
+ *
+ * @param int $blogId
+ * @return array of poll settings
+ */
+
+ function getPollsSettings( $blogId )
+ {
+ $query = "SELECT * FROM ".$this->getPrefix()."polls_settings WHERE blog_id = ".DB::qstr( $blogId );
+ $result = $this->Execute($query);
+ if( !$result ) {
+ return false;
+ }
+ if( $row = $result->FetchRow() ) {
+ return unserialize( $row['settings'] );
+ }
+ return false;
+ }
+
+ /**
+ * Add blog polls settings
+ *
+ * @param int $blogId
+ * @param array $settings
+ * @return true if added successfully
+ */
+ function addPollsSettings( $blogId, $settings = array() )
+ {
+ $query = "INSERT INTO ".$this->getPrefix()."polls_settings
+ VALUES( ".DB::qstr( $blogId ).", '".DB::qstr( serialize($settings) )."')";
+ return $this->Execute($query);
+ }
+
+ /**
+ * Update blog polls settings
+ *
+ * @param int $blogId
+ * @param array $settings
+ * @return true if updated successfully
+ */
+ function updatePollsSettings( $blogId, $settings = array() )
+ {
+ $query = "UPDATE ".$this->getPrefix()."polls_settings
+ SET settings = '".DB::qstr( serialize($settings) )."'
+ WHERE blog_id = ".DB::qstr( $blogId );
+ return $this->Execute($query);
+ }
+
+ function createTables()
+ {
+ $pollsTable = $this->getPrefix().'polls';
+ $votesTable = $this->getPrefix().'poll_votes';
+ $settingsTable = $this->getPrefix().'polls_settings';
+
+ $querys[] = "CREATE TABLE $pollsTable( id int(10) AUTO_INCREMENT PRIMARY KEY, text text, blog_id int(10), choices text )";
+ $querys[] = "CREATE INDEX blog_id ON $pollsTable( blog_id )";
+
+ $querys[] = "CREATE TABLE $votesTable( id int(10) AUTO_INCREMENT PRIMARY KEY, poll_id int(10), choice_id int(10) , ip varchar(20), date date )";
+ $querys[] = "CREATE INDEX poll_id On $votesTable( poll_id )";
+ $querys[] = "CREATE INDEX choice_id On $votesTable( choice_id )";
+
+ $querys[] = "CREATE TABLE $settingsTable( blog_id int(10) PRIMARY KEY, settings text)";
+
+ foreach($querys as $query) {
+ if( !$this->Execute( $query ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function tablesExists()
+ {
+ $pollsTable = $this->getPrefix().'polls';
+ $votesTable = $this->getPrefix().'poll_votes';
+ $settingsTable = $this->getPrefix().'polls_settings';
+
+ $querys[] = "show tables like '$pollsTable'";
+ $querys[] = "show tables like '$votesTable'";
+ $querys[] = "show tables like '$settingsTable'";
+
+ $returnValue = true;
+ foreach($querys as $query) {
+ $result = $this->Execute( $query );
+ if( $result ) {
+ $returnValue = ($returnValue && $result->RowCount());
+ } else {
+ return false;
+ }
+ }
+ return $returnValue;
+ }
+ /**
+ * @private
+ */
+
+ function _getPollsFromQuery( $query )
+ {
+ // we send the query and then fetch the first array with the result
+ $result = $this->Execute( $query );
+ if( !$result ) {
+ return false;
+ }
+
+ if ( $result->RecordCount() == 0) {
+ $result->Close();
+ return false;
+ }
+
+ $polls = array();
+ while( $row = $result->FetchRow( $result ) ) {
+ $polls[] = $this->mapRow( $row );
+ }
+ $result->Close();
+ return $polls;
+ }
+
+ function _getPollFromQuery( $query )
+ {
+ // we send the query and then fetch the first array with the result
+ $result = $this->Execute( $query );
+ if( !$result ) {
+ return false;
+ }
+
+ if ( $result->RecordCount() == 0) {
+ $result->Close();
+ return false;
+ }
+
+ $row = $result->FetchRow( $result );
+ $poll = $this->mapRow( $row );
+ $result->Close();
+
+ return $poll;
+ }
+
+ function mapRow( $row )
+ {
+ $choices = unserialize( $row["choices"] );
+ $poll = new Poll( $row["text"], $row["blog_id"], $choices, $row["id"] );
+ return $poll;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/styles/pollstyles.properties.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/styles/pollstyles.properties.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/styles/pollstyles.properties.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,31 @@
+<?php
+define('POLL_STYLES_PATH', 'plugins/crystalpoll/imgs/');
+
+$poll2dStyle['default'] = POLL_STYLES_PATH.'2d_1.jpg';
+$poll2dStyle['style2'] = POLL_STYLES_PATH.'2d_2.jpg';
+$poll2dStyle['style3'] = POLL_STYLES_PATH.'2d_3.jpg';
+$poll2dStyle['style4'] = POLL_STYLES_PATH.'2d_4.jpg';
+$poll2dStyle['style5'] = POLL_STYLES_PATH.'2d_5.jpg';
+$poll2dStyle['style6'] = POLL_STYLES_PATH.'2d_6.jpg';
+$poll2dStyle['style7'] = POLL_STYLES_PATH.'2d_7.jpg';
+$poll2dStyle['style8'] = POLL_STYLES_PATH.'2d_8.jpg';
+$poll2dStyle['style9'] = POLL_STYLES_PATH.'2d_9.jpg';
+$poll2dStyle['style10'] = POLL_STYLES_PATH.'2d_10.jpg';
+$poll2dStyle['style11'] = POLL_STYLES_PATH.'2d_11.jpg';
+$poll2dStyle['style12'] = POLL_STYLES_PATH.'2d_12.jpg';
+$poll2dStyle['style13'] = POLL_STYLES_PATH.'2d_13.jpg';
+
+$poll3dStyle['style14'] = POLL_STYLES_PATH.'3d_1.jpg';
+$poll3dStyle['style15'] = POLL_STYLES_PATH.'3d_2.jpg';
+$poll3dStyle['style16'] = POLL_STYLES_PATH.'3d_3.jpg';
+$poll3dStyle['style17'] = POLL_STYLES_PATH.'3d_4.jpg';
+$poll3dStyle['style18'] = POLL_STYLES_PATH.'3d_5.jpg';
+$poll3dStyle['style19'] = POLL_STYLES_PATH.'3d_6.jpg';
+$poll3dStyle['style20'] = POLL_STYLES_PATH.'3d_7.jpg';
+$poll3dStyle['style21'] = POLL_STYLES_PATH.'3d_8.jpg';
+$poll3dStyle['style22'] = POLL_STYLES_PATH.'3d_9.jpg';
+$poll3dStyle['style23'] = POLL_STYLES_PATH.'3d_10.jpg';
+$poll3dStyle['style24'] = POLL_STYLES_PATH.'3d_11.jpg';
+$poll3dStyle['style25'] = POLL_STYLES_PATH.'3d_12.jpg';
+$poll3dStyle['style26'] = POLL_STYLES_PATH.'3d_13.jpg';
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollsview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollsview.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,21 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ class AdminEditPollsView extends AdminPluginTemplatedView
+ {
+
+ function AdminEditPollsView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "crystalpoll", "editpolls" );
+ }
+
+ function render()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+ $polls = new Polls();
+ $this->setValue('polls', $polls->getBlogPolls( $this->_blogInfo->getId() ));
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/view/admineditpollview.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,18 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ class AdminEditPollView extends AdminPluginTemplatedView
+ {
+
+ function AdminEditPollView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "crystalpoll", "editpoll" );
+ }
+
+ function render()
+ {
+ parent::render();
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/view/adminnewpollview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/view/adminnewpollview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/view/adminnewpollview.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,18 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ class AdminNewPollView extends AdminPluginTemplatedView
+ {
+
+ function AdminNewPollView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "crystalpoll", "newpoll" );
+ }
+
+ function render()
+ {
+ parent::render();
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/class/view/adminpollsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/class/view/adminpollsettingsview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/class/view/adminpollsettingsview.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,32 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ class AdminPollSettingsView extends AdminPluginTemplatedView
+ {
+
+ function AdminPollSettingsView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "crystalpoll", "pollsettings" );
+ }
+
+ function render()
+ {
+ lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
+
+ include PLOG_CLASS_PATH."plugins/crystalpoll/class/styles/pollstyles.properties.php";
+ $polls = new Polls();
+ $this->setValue( 'polls', $polls->getBlogPolls( $this->_blogInfo->getId() ));
+ $this->setValue( 'poll2dstyles', $poll2dStyle );
+ $this->setValue( 'poll3dstyles', $poll3dStyle );
+
+ $pollSettings = $polls->getPollsSettings( $this->_blogInfo->getId() );
+ if( $pollSettings ) {
+ $this->setValue( 'selectedPoll', $pollSettings['selected_poll'] );
+ $this->setValue( 'styleId', $pollSettings['poll_style'] );
+ }
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_1.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_1.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_10.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_10.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_11.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_11.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_12.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_12.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_13.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_13.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_2.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_2.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_3.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_3.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_4.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_4.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_5.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_5.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_6.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_6.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_7.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_7.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_8.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_8.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_9.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/2d_9.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_1.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_1.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_10.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_10.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_11.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_11.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_12.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_12.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_13.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_13.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_2.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_2.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_3.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_3.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_4.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_4.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_5.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_5.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_6.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_6.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_7.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_7.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_8.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_8.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_9.jpg
===================================================================
(Binary files differ)
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/imgs/3d_9.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/branches/lifetype-1.2/crystalpoll/js/choices.js
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/js/choices.js (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/js/choices.js 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,24 @@
+counter = 0;
+function addChoice(deleteButtonText, defaultText)
+{
+ choicesDiv = document.getElementById( 'choices' );
+ counter++;
+ if( !deleteButtonText ) {
+ deleteButtonText = 'Delete';
+ }
+ if( !defaultText ) {
+ defaultText = '';
+ }
+ newDiv = document.createElement('div');
+ newDiv.id='choice_'+counter;
+ newDiv.innerHTML = '<input id="choiceText_'+counter+'" name="choice[]" style="width:50%" value="'+defaultText+'"/>'+
+ '<input type="button" value="'+deleteButtonText+'" class="button" id="deleteBtn" onclick="deleteChoice(\'choice_'+counter+'\');"/>';
+
+ choicesDiv.appendChild(newDiv);
+}
+function deleteChoice(choiceId)
+{
+ choicesDiv = document.getElementById( 'choices' );
+ choice = document.getElementById(choiceId);
+ choicesDiv.removeChild(choice);
+}
Property changes on: plugins/branches/lifetype-1.2/crystalpoll/js/choices.js
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.2/crystalpoll/js/crystalPollAjax.js
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/js/crystalPollAjax.js (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/js/crystalPollAjax.js 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,58 @@
+var selectedChoice;
+var animDiv;
+var opacityValue;
+
+function selectChoice(id)
+{
+ selectedChoice = id;
+}
+
+function getXmlHttpObject()
+{
+ var xmlHttp;
+ try {
+ xmlHttp = new XMLHttpRequest();
+ } catch (e) {
+ try {
+ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ return false;
+ }
+ }
+ }
+ return xmlHttp;
+}
+function addVote()
+{
+ pollId = document.getElementById("pollId");
+ pollId = pollId.value;
+ if(selectedChoice && pollId) {
+ xmlHttp = getXmlHttpObject();
+ xmlHttp.onreadystatechange = function() {
+ if(xmlHttp.readyState==4) {
+ div = document.getElementById("crystalPoll");
+ div.innerHTML = readPollAjax();
+ }
+ }
+ button = document.getElementById("vote");
+ button.style.display = 'none';
+ xmlHttp.open("GET", pollBaseUrl+"/index.php?op=addVote&choice="+selectedChoice+"&pollId="+pollId, true);
+ xmlHttp.send(null);
+ }
+}
+
+function readPollAjax()
+{
+ xmlHttp = getXmlHttpObject();
+ xmlHttp.onreadystatechange = function() {
+ if(xmlHttp.readyState==4) {
+ div = document.getElementById("crystalPoll");
+ div.innerHTML = xmlHttp.responseText;
+ }
+ }
+ xmlHttp.open("GET", pollBaseUrl+"/index.php?op=readPoll", true);
+ xmlHttp.send(null);
+}
Added: plugins/branches/lifetype-1.2/crystalpoll/locale/locale_ar_SA.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/locale/locale_ar_SA.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/locale/locale_ar_SA.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,75 @@
+<?php
+
+// New Poll Page
+$messages['newPoll'] = 'استطلاع جديد';
+$messages["poll_text"] = 'نص الاستطلاع';
+$messages['poll_text_help'] = 'اكتب هنا نص استطلاع الرأي الذي تريد';
+$messages['choices'] = 'خيارات';
+$messages['choices_help'] = 'اضغط على اضافة خيار جديد لاضافة الخيارات.';
+$messages['add_choice'] = 'اضافة خيار';
+$messages['error_adding_poll'] = 'حدث خطأ اثناء عملية اضافة الاستطلاع';
+$messages['error_missing_poll_text'] = 'رجاء اكتب نص الاستطلاع';
+$messages['error_missing_choices'] = 'اضف خيارا واحدا على الاقل';
+$messages['poll_added_ok'] = 'تمت عملية الضافة الاستطلاع بنجاح.';
+
+
+// Edit Polls Page
+$messages['votes'] = 'اصوات';
+$messages['editPolls'] = 'تعديل الاصوات';
+$messages['error_deleting_polls'] = 'حدث خطأ اثناء عملية حذف الاستطلاع';
+$messages['error_deleting_poll2'] = 'حدث خطأ اثناء عملية حذف الاستطلاع رقم "%s"';
+$messages['error_deleting_poll'] = 'حدث خطأ اثناء عملية حذف الاستطلاع "%s"';
+$messages['poll_deleted_ok'] = 'تم حذف الاستطلاع "%s" بنجاح.';
+$messages['polls_deleted_ok'] = '%s عدد الاستطلاعات التي حذفت بنجاح.';
+
+
+// Edit Poll Page
+$messages['editPoll'] = 'تعديل الاستطلاع';
+$messages['error_updating_poll'] = 'حدث خطأ اثناء عملية تعديل الاستطلاع';
+$messages['error_updating_poll2'] = 'حدث خطأ اثناء عملية تعديل الاستطلاع رقم "%s"';
+$messages['poll_updated_ok'] = 'تم تعديل الاسطلاع بنجاح.';
+
+
+// Polls Settings Page
+$messages['pollSettings'] = 'اعدادات الاستطلاعات';
+$messages['selectedPoll'] = 'الاستطلاع المختار';
+$messages['selected_poll_help'] = 'اختر الاستطلاع الذي تود عرضه على مدونتك';
+$messages['poll_styles'] = 'شكل الاستطلاع';
+$messages['poll_styles_help'] = 'اختر شكل الاستطلاع';
+$messages['error_updating_poll_settings'] = 'حدث خطأ اثناء عملية تعديل اعدادات الاستطلاع';
+$messages['error_adding_poll_settings'] = 'حدث خطأ اثناء عملية اضافة اعدادات للاستطلاع';
+$messages['poll_settings_updated_ok'] = 'تم تعديل اعدادات الاستطلاع بنجاح';
+$messages['default'] = 'احمر';
+$messages['style2'] = 'اسود';
+$messages['style3'] = 'زهري';
+$messages['style4'] = 'احمر داكن';
+$messages['style5'] = 'ازرف';
+$messages['style6'] = 'ازرق داكن';
+$messages['style7'] = 'بنفسجي';
+$messages['style8'] = 'ازرق فاتح';
+$messages['style9'] = 'اخضر داكن';
+$messages['style10'] = 'اخضر فاتح';
+$messages['style11'] = 'اخضر';
+$messages['style12'] = 'برتقالي';
+$messages['style13'] = 'بني';
+$messages['style14'] = '3D احمر';
+$messages['style15'] = '3D اسود';
+$messages['style16'] = '3D زهري';
+$messages['style17'] = '3D احمر داكن';
+$messages['style18'] = '3D ازرق';
+$messages['style19'] = '3D ازرق داكن';
+$messages['style20'] = '3D بنفسجي';
+$messages['style21'] = '3D ازرق فاتح';
+$messages['style22'] = '3D اخضر داكن';
+$messages['style23'] = '3D اخضر فاتح';
+$messages['style24'] = '3D اخضر';
+$messages['style25'] = '3D برتقالي';
+$messages['style26'] = '3D بني';
+
+//poll form
+$messages['crystalPoll'] = 'استطلاع الرأي';
+$messages['totalVotes'] = 'عدد التصويتات';
+$messages['vote'] = 'تصويت';
+$messages['poll'] = 'استطلاع الرأي';
+$messages['Polls'] = 'استطلاعات الرأي';
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/locale/locale_en_UK.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,76 @@
+<?php
+
+// New Poll Page
+$messages['newPoll'] = 'New Poll';
+$messages["poll_text"] = 'Poll Text';
+$messages['poll_text_help'] = 'Write here your poll question';
+$messages['choices'] = 'Choices';
+$messages['choices_help'] = 'Click Add Choice button to add new choice';
+$messages['add_choice'] = 'Add Choice';
+$messages['error_adding_poll'] = 'There was an error adding the poll';
+$messages['error_missing_poll_text'] = 'Please type a poll text';
+$messages['error_missing_choices'] = 'Add at least one choice';
+$messages['error_adding_poll'] = 'There was an error adding the poll';
+$messages['poll_added_ok'] = 'Poll added successfully.';
+
+
+// Edit Polls Page
+$messages['votes'] = 'Votes';
+$messages['editPolls'] = 'Edit Polls';
+$messages['error_deleting_polls'] = 'There was an error deleting selected polls';
+$messages['error_deleting_poll2'] = 'There was an error deleting the poll with identifier "%s"';
+$messages['error_deleting_poll'] = 'There was an error deleting poll "%s"';
+$messages['poll_deleted_ok'] = 'Poll "%s" deleted successfully.';
+$messages['polls_deleted_ok'] = '%s Polls deleted successfully.';
+
+
+// Edit Poll Page
+$messages['editPoll'] = 'Edit Poll';
+$messages['error_updating_poll'] = 'There was an error updating the poll';
+$messages['error_updating_poll2'] = 'There was an error updating the poll with identifier "%s"';
+$messages['poll_updated_ok'] = 'Poll updated successfully.';
+
+
+// Polls Settings Page
+$messages['pollSettings'] = 'Polls Settings';
+$messages['selectedPoll'] = 'Selected Poll';
+$messages['selected_poll_help'] = 'Select the poll which you want to view in your blog';
+$messages['poll_styles'] = 'Poll Styles';
+$messages['poll_styles_help'] = 'Select your bar style for your polls';
+$messages['error_updating_poll_settings'] = 'There was an error updating polls settings';
+$messages['error_adding_poll_settings'] = 'There was an error adding polls settings';
+$messages['poll_settings_updated_ok'] = 'Poll settings updated successfully.';
+$messages['default'] = 'Red';
+$messages['style2'] = 'Black';
+$messages['style3'] = 'Pink';
+$messages['style4'] = 'Dark Red';
+$messages['style5'] = 'Blue';
+$messages['style6'] = 'Dark Blue';
+$messages['style7'] = 'Mauve';
+$messages['style8'] = 'Light Blue';
+$messages['style9'] = 'Dark Green';
+$messages['style10'] = 'Light Green';
+$messages['style11'] = 'Green';
+$messages['style12'] = 'Orange';
+$messages['style13'] = 'Brown';
+$messages['style14'] = '3D Red';
+$messages['style15'] = '3D Black';
+$messages['style16'] = '3D Pink';
+$messages['style17'] = '3D Dark Red';
+$messages['style18'] = '3D Blue';
+$messages['style19'] = '3D Dark Blue';
+$messages['style20'] = '3D Mauve';
+$messages['style21'] = '3D Light Blue';
+$messages['style22'] = '3D Dark Green';
+$messages['style23'] = '3D Light Green';
+$messages['style24'] = '3D Green';
+$messages['style25'] = '3D Orange';
+$messages['style26'] = '3D Brown';
+
+//poll form
+$messages['crystalPoll'] = 'Crystal Poll';
+$messages['totalVotes'] = 'Total Votes';
+$messages['vote'] = 'Vote';
+$messages['poll'] = 'Poll';
+$messages['Polls'] = 'Polls';
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/plugincrystalpoll.class.php
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/plugincrystalpoll.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/plugincrystalpoll.class.php 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,75 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+
+ /**
+ * CrystalPoll class
+ */
+ class PluginCrystalPoll extends PluginBase
+ {
+ var $pluginEnabled;
+
+ function PluginCrystalPoll( $source = "" )
+ {
+ $this->PluginBase();
+ $this->id = "crystalpoll";
+ $this->desc = "This plugin offers you to create your own poll in your blog";
+ $this->author = "Ahmad Fathi Saleh (Al Bawaba Team)";
+ $this->locale = "locale_en_UK, locale_ar_SA";
+ $this->version = "20080129";
+ if( "admin" == $source ) {
+ $this->adminInit();
+ } elseif( "index" == $source ) {
+ $this->blogInit();
+ }
+ }
+
+ /**
+ * init admin actions
+ */
+ function adminInit()
+ {
+
+ $this->registerAdminAction( "addPoll", "AdminAddPollAction" );
+ $this->registerAdminAction( "updatePoll", "AdminUpdatePollAction" );
+ $this->registerAdminAction( "deletePolls", "AdminDeletePollsAction" );
+ $this->registerAdminAction( "newPoll", "AdminNewPollAction" );
+ $this->registerAdminAction( "editPolls", "AdminEditPollsAction" );
+ $this->registerAdminAction( "editPoll", "AdminEditPollAction" );
+ $this->registerAdminAction( "pollSettings", "AdminPollSettingsAction" );
+ $this->registerAdminAction( "updatePollSettings", "AdminUpdatePollSettingsAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/Manage/crystalPoll" ) ) {
+ $this->addMenuEntry( "/menu/Manage", "crystalPoll", "", null, true, false );
+ $this->addMenuEntry( "/menu/Manage/crystalPoll", "newPoll", "admin.php?op=newPoll", null, true, false );
+ $this->addMenuEntry( "/menu/Manage/crystalPoll", "editPolls", "admin.php?op=editPolls", null, true, false );
+ $this->addMenuEntry( "/menu/Manage/crystalPoll", "pollSettings", "admin.php?op=pollSettings", null, true, false);
+ }
+ }
+
+
+ /**
+ * init blog actions
+ */
+ function blogInit()
+ {
+ $this->registerBlogAction('addVote','AddVoteAction');
+ $this->registerBlogAction('readPoll','ReadPollAction');
+ }
+
+
+ function install()
+ {
+ lt_include(PLOG_CLASS_PATH.'plugins/crystalpoll/class/dao/polls.class.php');
+ $polls = new Polls();
+ if( !$polls->tablesExists() ) {
+ if( !$polls->createTables() ){
+ die( 'cannot create plugin tables' );
+ }
+ }
+ }
+
+ }
+?>
Added: plugins/branches/lifetype-1.2/crystalpoll/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/readme.txt 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,17 @@
+Plugin: Crystal Poll
+Author: Ahmad Fathi Saleh (Al Bawaba Team)
+Release Date: 2008/01/29
+Version: 20080129
+
+This plugin offers you to create your own poll in your blog.
+
+Install:
+
+Template code as follows:
+
+{if $crystalpoll}
+<div id="crystalPoll"></div>
+<script>pollBaseUrl = "{$url->getBaseUrl()}";</script>
+<script type="text/javascript" src={$url->getUrl("/plugins/crystalpoll/js/crystalPollAjax.js")}></script>
+<script>readPollAjax();</script>
+{/if}
Added: plugins/branches/lifetype-1.2/crystalpoll/templates/chart.template
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/templates/chart.template (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/templates/chart.template 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,13 @@
+{foreach from=$choices key=choiceId item=choice}
+ <div >
+ {if $votes[$choiceId]}
+ {$choice} ({$votes[$choiceId]} Vote)
+ ({math equation="(x / y) * 100" x=$votes[$choiceId] y=$totalVotes format="%.1f"} %)
+ <div style="width:{math equation="(((x / y) * 100) * 2) + 1" x=$votes[$choiceId] y=$totalVotes format="%.0f"}px; height:10px; border:1px black solid; background-color:red"></div>
+ {else}
+ {$choice} (0 Vote)
+ (0 %)
+ <div style="width:1px; height:10px; border:1px black solid; background-color:red"></div>
+ {/if}
+ </div>
+{/foreach}
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/crystalpoll/templates/editpoll.template
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/templates/editpoll.template (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/templates/editpoll.template 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,47 @@
+{include file="$admintemplatepath/header.template" selected="extras"}
+{include file="$admintemplatepath/navigation.template" showOpt=editPolls title=$locale->tr("editPolls")}
+
+
+<form name="editPoll" action="admin.php" method="post">
+ <fieldset class="inputField">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pollText">{$locale->tr("poll_text")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("poll_text_help")}</div>
+ <input type="text" id="pollText" style="width:45%" name="pollText" value="{$poll->getText()}" />
+ {include file="$admintemplatepath/validate.template" field=pollText message=$locale->tr("error_missing_poll_text")}
+
+ </div>
+
+ <div class="field">
+ <label for="choicesField">{$locale->tr("choices")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("choices_help")}</div>
+ <input type="button" class="button" name="AddChoice" value="{$locale->tr("add_choice")}" onclick="addChoice('{$locale->tr("delete")}');return false;"/>
+ <div id="choices">
+ </div>
+ <script type="text/javascript" src={$url->getUrl("/plugins/crystalpoll/js/choices.js")}></script>
+ <script type="text/javascript">
+ {if $poll}
+ {assign var=choices value=$poll->getChoices()}
+ {foreach from=$choices item=choice}
+ addChoice('{$locale->tr("delete")}','{$choice}');
+ {/foreach}
+ {/if}
+ </script>
+ {include file="$admintemplatepath/validate.template" field=choice message=$locale->tr("error_missing_choices")}
+ </div>
+ </fieldset>
+
+<div class="buttons">
+ <input type="hidden" name="op" value="updatePoll" />
+ <input type="hidden" name="pollId" value="{$poll->getId()}" />
+ <input type="reset" value="{$locale->tr("reset")}" name="reset"/>
+ <input type="submit" name="update" value="{$locale->tr("update")}"/>
+ </div>
+</form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
Added: plugins/branches/lifetype-1.2/crystalpoll/templates/editpolls.template
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/templates/editpolls.template (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/templates/editpolls.template 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,65 @@
+{include file="$admintemplatepath/header.template" selected="extras"}
+{include file="$admintemplatepath/navigation.template" showOpt=editPolls title=$locale->tr("editPolls")}
+
+<form id="editPolls" action="admin.php" method="post">
+ <div id="list">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <table id="list" class="info" summary="{$locale->tr("editPolls")}">
+ <thead>
+ <tr>
+ <th style="width:5%; border:none;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('editPolls');" /></th>
+ <th style="width:30%;" class="second-header">{$locale->tr("poll_text")}</th>
+ <th style="width:55%;">{$locale->tr("choices")}</th>
+ <th style="width:10%;">{$locale->tr("votes")}</th>
+ <th style="width:10%;" class="action">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {if $polls}
+ {foreach from=$polls item=poll}
+ {assign var=totalVotes value=0}
+ {assign var=choices value=$poll->getChoices()}
+ {assign var=votes value=$poll->getChoicesVotesCount()}
+ {foreach from=$votes item=vote}
+ {assign var=totalVotes value=$totalVotes+$vote}
+ {/foreach}
+ <tr>
+ <td style="border:none;">
+ <input class="checkbox" type="checkbox" name="pollIds[{$poll->getId()}]" id="checks_{$poll->getId()}" value="{$poll->getId()}" />
+ </td>
+ <td class="col_highlighted" style="border:none;">
+ <a href="?op=editPoll&pollId={$poll->getId()}">
+ {$poll->getText()|strip_tags}
+ </a>
+ </td>
+ <td>
+ {include file="chart.template" choices=$choices totalVotes=$totalVotes votes=$votes}
+ </td>
+ <td>
+ {$totalVotes}
+ </td>
+ <td class="action">
+ <div class="list_action_button">
+ <a href="?op=editPoll&pollId={$poll->getId()}" title="{$locale->tr("edit")}">
+ <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
+ </a>
+ <a href="?op=deletePolls&pollId={$poll->getId()}" title="{$locale->tr("delete")}">
+ <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
+ </a>
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+ {/if}
+ </tbody>
+ </table>
+ </div>
+ <div class="buttons">
+ <input type="submit" name="delete" value="{$locale->tr("delete")}" />
+ <input type="hidden" name="op" value="deletePolls" />
+ </div>
+
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
Added: plugins/branches/lifetype-1.2/crystalpoll/templates/newpoll.template
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/templates/newpoll.template (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/templates/newpoll.template 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,43 @@
+{include file="$admintemplatepath/header.template" selected="extras"}
+{include file="$admintemplatepath/navigation.template" showOpt=newPoll title=$locale->tr("newPoll")}
+
+<form name="newPoll" action="admin.php" method="post">
+ <fieldset class="inputField">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pollText">{$locale->tr("poll_text")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("poll_text_help")}</div>
+ <input type="text" id="pollText" name="pollText" value="{$pollText}" style="width:44%;" />
+ {include file="$admintemplatepath/validate.template" field=pollText message=$locale->tr("error_missing_poll_text")}
+
+ </div>
+
+ <div class="field">
+ <label for="choicesField">{$locale->tr("choices")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("choices_help")}</div>
+ <input type="button" style="width:100px;" name="AddChoice" value="{$locale->tr("add_choice")}" onclick="addChoice('{$locale->tr("delete")}');return false;"/>
+ <div id="choices">
+ </div>
+ <script type="text/javascript" src={$url->getUrl("/plugins/crystalpoll/js/choices.js")} />
+ <script type="text/javascript">
+ {if $choice}
+ {foreach from=$choice item=ch}
+ addChoice('{$locale->tr("delete")}','{$ch}');
+ {/foreach}
+ {/if}
+ </script>
+ {include file="$admintemplatepath/validate.template" field=choice message=$locale->tr("error_missing_choices")}
+ </div>
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="addPoll" />
+ <input type="reset" value="{$locale->tr("reset")}" name="reset"/>
+ <input type="submit" name="Add" value="{$locale->tr("add")}"/>
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
Added: plugins/branches/lifetype-1.2/crystalpoll/templates/pollsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/crystalpoll/templates/pollsettings.template (rev 0)
+++ plugins/branches/lifetype-1.2/crystalpoll/templates/pollsettings.template 2008-04-12 09:51:54 UTC (rev 6306)
@@ -0,0 +1,59 @@
+{include file="$admintemplatepath/header.template" selected="extras"}
+{include file="$admintemplatepath/navigation.template" showOpt=pollSettings title=$locale->tr("pollSettings")}
+
+<form name="pollSettings" action="admin.php" method="post">
+ <fieldset class="inputField">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="selectedPoll">{$locale->tr("selectedPoll")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("selected_poll_help")}</div>
+ <select id="selectedPoll" name="selectedPoll" style="width:45%;">
+ <option value="0" {if !$selectedPoll} selected="selected"{/if}>{$locale->tr("none")}</option>
+ {if $polls}
+ {foreach from=$polls item=poll}
+ <option value="{$poll->getId()}" {if $poll->getId() == $selectedPoll}selected="selected"{/if}>{$poll->getText()}</option>
+ {/foreach}
+ {/if}
+ </select>
+ </div>
+
+
+ <div class="field">
+ <label>{$locale->tr("poll_styles")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("poll_styles_help")}</div>
+ </div>
+ {if $poll2dstyles}
+ <div style="clear:both">
+ {foreach from=$poll2dstyles key=styleName item=style}
+ <div style="float:left;padding: 5px">
+ <img src="{$style}" style="width:150px; height:10px;"/>
+ <div><input type="radio" id="{$styleName}" name="styleId" value="{$styleName}" class="checkbox" {if $styleId == $styleName}checked="checked"{/if}/><label for="{$styleName}">{$locale->tr($styleName)}</label></div>
+ </div>
+ {/foreach}
+ </div>
+ {/if}
+
+ {if $poll3dstyles}
+ <div style="clear:both">
+ {foreach from=$poll3dstyles key=styleName item=style}
+ <div style="float:left;padding: 5px">
+ <img src="{$style}" style="width:150px; height:10px;"/>
+ <div><input type="radio" id="{$styleName}" name="styleId" value="{$styleName}" class="checkbox" {if $styleId == $styleName}checked="checked"{/if}/><label for="{$styleName}">{$locale->tr($styleName)}</label></div>
+ </div>
+ {/foreach}
+ </div>
+ {/if}
+ <div style="clear:both;"></div>
+ </fieldset>
+ <div class="buttons">
+ <input type="hidden" name="op" value="updatePollSettings" />
+ <input type="submit" name="update" value="{$locale->tr("update")}"/>
+ </div>
+
+</form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
More information about the pLog-svn
mailing list