Skip to content

Commit

Permalink
Commit for 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfieZero committed Jan 4, 2012
1 parent 1b5ad60 commit e80955e
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 149 deletions.
11 changes: 6 additions & 5 deletions config.php
Expand Up @@ -2,21 +2,22 @@

global $wpdb;

define('SP_VERSION', '1.');
define('SP_VERSION', '1.4');
define('SP_DEBUG', false);

define('SP_DIR', dirname(__FILE__).'/');
define('SP_URL', plugins_url('/', __FILE__));

define('SP_SUBMIT', 'lib/submit.php');
define('SP_DISPLAY', 'page/client/display.php');
define('SP_RESULTS', 'page/client/results.php');
define('SP_DISPLAY', 'view/client/display.php');
define('SP_RESULTS', 'view/client/results.php');
define('SP_ADMIN_FOLDER', 'view/admin');

define('SP_TABLE', $wpdb->get_blog_prefix().'sp_polls');

define('SP_DIRECT_ACCESS', 'I don\'t think you should be here?');

define('SP_CSS_CLIENT', plugins_url('css/default.css', __FILE__));
define('SP_CSS_ADMIN', plugins_url('css/admin.css', __FILE__));
define('SP_CSS_CLIENT', plugins_url('view/client/simply-poll.css', __FILE__));
define('SP_CSS_ADMIN', plugins_url('view/admin/admin-simply-poll.css', __FILE__));
define('SP_JS_CLIENT', plugins_url('script/simplypoll.js', __FILE__));
define('SP_JS_ADMIN', plugins_url('script/simplypoll-admin.js', __FILE__));
22 changes: 11 additions & 11 deletions lib/admin.php
Expand Up @@ -17,10 +17,10 @@ public function __construct(){
}

public function enqueueFiles() {
wp_enqueue_script('validator', plugins_url('/script/validator.min.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('jqPlotMain', plugins_url('/script/jqplot.min.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('jqPlotPie', plugins_url('/script/jqplot.pieRenderer.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('masonry', plugins_url('/script/masonry.min.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('validator', plugins_url('/script/validator.min.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('jqPlotMain', plugins_url('/script/jqplot.min.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('jqPlotPie', plugins_url('/script/jqplot.pieRenderer.js', dirname(__FILE__)), false, SP_VERSION);
wp_enqueue_script('masonry', plugins_url('/script/masonry.min.js', dirname(__FILE__)), false, SP_VERSION);

wp_enqueue_script('jSimplyPollAdmin', SP_JS_ADMIN, false, SP_VERSION);
wp_register_style('spAdminCSS', SP_CSS_ADMIN, false, SP_VERSION);
Expand Down Expand Up @@ -49,25 +49,25 @@ public function addSimplyPollMenu() {


public function getAdminPageMain(){
require(SP_DIR.'/page/admin/main.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/main.php');
}
public function getAdminPageSettings() {
require(SP_DIR.'/page/admin/settings.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/settings.php');
}
public function getAdminPageView(){
require(SP_DIR.'/page/admin/view.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/view.php');
}
public function getAdminPageAdd(){
require(SP_DIR.'/page/admin/edit.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/edit.php');
}
public function getAdminPageUpdate(){
require(SP_DIR.'/page/admin/edit.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/edit.php');
}
public function getAdminPageDelete(){
require(SP_DIR.'/page/admin/delete.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/delete.php');
}
public function getAdminPageReset(){
require(SP_DIR.'/page/admin/reset.php');
require(SP_DIR.'/'.SP_ADMIN_FOLDER.'/reset.php');
}


Expand Down
3 changes: 1 addition & 2 deletions lib/db.php
Expand Up @@ -2,11 +2,10 @@

class SimplyPollDB {


private $pollData;

public function __construct() {

return true;
}


Expand Down
42 changes: 29 additions & 13 deletions logger.php → lib/logger.php
@@ -1,20 +1,30 @@
<?php

define('LOG_FILE', 'log');
define('MODE', 'a');
define('DATE', 'H:i:s/m.d.y - ');
/**
* Logger
* A basic logging class to write logs to a file
*
* @author Neil Sweeney <neil@wolfiezero.com>
* @license Creative Commons Attribution-ShareAlike 3.0 Unported License
* @link https://github.com/WolfieZero/logger
*/

class logger {

private $fp;
private $logFile = 'log';
private $mode = 'a';
private $dateFormat = 'm.d.y @ H:i:s';
private $seperator = ' - ';

/**
* Logger
*
* @access public
* @param String $location Where the log file should be located
*/
function __construct($location='', $display=true) {
$this->fp = fopen($location.LOG_FILE, MODE);
$this->fp = fopen($location.$this->logFile, $this->mode);
$this->display = $display;
}

Expand All @@ -23,13 +33,14 @@ function __construct($location='', $display=true) {
* Log
* Adds a record to the log file
*
* @access public
* @param String $log The log entry
* @return bool true
* @return bool
*/
function log($log) {
public function log($log) {
if($this->display) {

$write = date(DATE).$log."\r\n";
$write = date($this->dateFormat).$this->seperator.$log."\r\n";
fwrite($this->fp, $write);

return true;
Expand All @@ -44,17 +55,17 @@ function log($log) {
* Log Variable
* Takes a variable and does a print_r
*
* @access public
* @param mixed $var The varible that is to be printed
* @param String $log The prefix to the variable print
* @return bool true
* @return bool
*/
function logVar($var, $log=null) {
public function logVar($var, $log=null) {
if($this->display) {

$write = date(DATE);
$write = date($this->dateFormat).$this->seperator;

if ($log)
$write .= $log.' - ';
if ($log) $write .= $log.$this->seperator;

$write .= print_r($var, true)."\r\n";
fwrite($this->fp, $write);
Expand All @@ -70,9 +81,14 @@ function logVar($var, $log=null) {
/**
* Close
* Closes the log file
*
* @access public
* @return bool
*/
function close() {
public function close() {
fclose($this->fp);

return true;
}

}
49 changes: 39 additions & 10 deletions lib/simplypoll.php
Expand Up @@ -3,14 +3,15 @@
class SimplyPoll {

private $pollData;
private $pollDB;
private $pollDB; // Stores the DB class
private $pollStrings; // Store the custom strings


/**
* Simply Poll construct
* Access the Simply Poll's database
*
* @param bool $enque Set enqued files
* @param bool $enque Set enqued files
*/
public function __construct($enque=true) {
// Establish our DB class
Expand All @@ -25,7 +26,7 @@ public function __construct($enque=true) {
* Poll Database
* Access the Simply Poll's database
*
* @return object
* @return object
*/
public function pollDB() {
return $this->pollDB;
Expand All @@ -39,8 +40,8 @@ public function pollDB() {
* Display Poll
* Gives the HTML for the poll to display on the front-end
*
* @param array $args
* @return string
* @param array $args
* @return string
*/
public function displayPoll(array $args) {

Expand All @@ -53,6 +54,7 @@ public function displayPoll(array $args) {
if( isset($poll['question']) ) {
$question = stripcslashes($poll['question']);
$answers = $poll['answers'];
$totalvotes = $poll['totalvotes'];

foreach( $answers as $key => $answer ) {
$answers[$key]['answer'] = stripcslashes($answer['answer']);
Expand All @@ -62,6 +64,18 @@ public function displayPoll(array $args) {
$postFile = plugins_url(SP_SUBMIT, dirname(__FILE__));
$thisPage = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$userCannotTakePoll = false;

if(
(
$limit == 'yes' && isset($_COOKIE['sptaken']) &&
in_array($args['id'], unserialize($_COOKIE['sptaken']))
) ||
isset($_GET['simply-poll-return'])
) {
$userCannotTakePoll = true;
}

include(SP_DIR.SP_DISPLAY);
$content = ob_get_clean();
return $content;
Expand All @@ -80,9 +94,9 @@ public function displayPoll(array $args) {
* Passes back the poll results to return a JSON feed of responses. Can
* also just pass back previous results without passing an answer.
*
* @param int $pollID
* @param int $answer
* @return int
* @param int $pollID
* @param int $answer
* @return int
*/
public function submitPoll($pollID, $answer=null) {

Expand Down Expand Up @@ -128,8 +142,8 @@ public function submitPoll($pollID, $answer=null) {
* Grab Poll
* Gets the current state of the the poll
*
* @param int $id
* @return array
* @param int $id
* @return array
*/
public function grabPoll($id=null) {

Expand All @@ -144,5 +158,20 @@ public function grabPoll($id=null) {
return $poll;
}


/*************************************************************************/


/**
* Grab String
* Pulls the stored string
*
* @param string $name
* @return string
*/
public function grabString($string) {

}


}
12 changes: 0 additions & 12 deletions page/client/results.php

This file was deleted.

0 comments on commit e80955e

Please sign in to comment.