Skip to content

Commit

Permalink
further java like formatting for php, a work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
pellcorp committed Aug 18, 2013
1 parent df67a5a commit 1d52af5
Show file tree
Hide file tree
Showing 74 changed files with 13,872 additions and 17,888 deletions.
8 changes: 6 additions & 2 deletions admin/logfile/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ function _build_tooltip($prompt, $value) {
header("Content-type: application/octetstream");
header("Content-Length: " . filesize($logging_config_r['file']));

fpassthru2($logging_config_r['file']);

$fp = fopen ($logging_config_r['file'], 'rb' );
if ($fp) {
fpassthru($fp);
}
fclose($fp);

//no theme here!
return;
} else if ($HTTP_VARS['op'] == 'clear') { // confirm with user to delete log
Expand Down
88 changes: 43 additions & 45 deletions lib/AdminAjaxJobs.class.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?php
require_once("./lib/xajax/xajax_core/xajax.inc.php");
require_once ("./lib/xajax/xajax_core/xajax.inc.php");

class AdminAjaxJobs
{
class AdminAjaxJobs {
var $_processed;
var $_failures;
var $_remaining;
var $_batchlimit;
var $_completed;
var $_totalItems;

var $_job;
var $_args;
var $_id;

var $_debug;

function AdminAjaxJobs($id, $job, $batchlimit) {
$this->_id = $id;
$this->_job = $job;
Expand All @@ -28,84 +25,85 @@ function calculateProgress() {
// total items to be processed.
$this->_totalItems = $this->_completed + $this->_remaining;
}

function dojob($job, $arg1, $continue, $completedCount, $failureCount) {
$this->_job = $job;
$this->_args = array($arg1);
$this->_args = array (
$arg1 );

$objResponse = new xajaxResponse();

if(!is_numeric($completedCount)) {
$objResponse = new xajaxResponse ();
if (! is_numeric ( $completedCount )) {
$completedCount = 0;
}

$this->_completed = $completedCount;
$this->_failures = $failureCount;

if($continue !== 'false') {
if ($continue !== 'false') {
/**
* This method will set processed, remaining, failures, but subclass
* can also override calculateProgress
*/
$this->__executeJob();
$this->__executeJob ();

$this->calculateProgress();
$this->calculateProgress ();

if($this->_processed == 0 && $this->_failures > 0) {
$objResponse->assign("messageText", "className", "error");
$objResponse->assign("progressSpinner", "className", "hidden");
$objResponse->assign("messageText", "innerHTML", "Job Failure (Completed: ".$this->_completed.", Failures: ".$this->_failures.")");
if ($this->_processed == 0 && $this->_failures > 0) {
$objResponse->assign ( "messageText", "className", "error" );
$objResponse->assign ( "progressSpinner", "className", "hidden" );
$objResponse->assign ( "messageText", "innerHTML", "Job Failure (Completed: " . $this->_completed . ", Failures: " . $this->_failures . ")" );
} else {
$percentage = 0;
if($this->_remaining > 0) {
if($this->_completed > 0) {
$percentage = floor($this->_completed / ($this->_totalItems / 100));
if ($this->_remaining > 0) {
if ($this->_completed > 0) {
$percentage = floor ( $this->_completed / ($this->_totalItems / 100) );
}
} else {
$percentage = 100;
}

$level = 0;
if($percentage > 0) {
$level = floor($percentage / 10);
if ($percentage > 0) {
$level = floor ( $percentage / 10 );
}

if( $level > 0 ) {
$rsimage = theme_image_src('rs.gif');
if ($level > 0) {
$rsimage = theme_image_src ( 'rs.gif' );

for($i=0; $i<=$level; $i++) {
$objResponse->assign("status$i", "src", $rsimage);
for($i = 0; $i <= $level; $i ++) {
$objResponse->assign ( "status$i", "src", $rsimage );
}
}

$objResponse->assign("percentage", "innerHTML", "$percentage%");
$objResponse->assign ( "percentage", "innerHTML", "$percentage%" );

if($this->_remaining > 0) {
$objResponse->assign("messageText", "innerHTML", "Completed ".$this->_completed." of ".$this->_totalItems." (Failures: ".$this->_failures.")");
$objResponse->assign("progressSpinner", "className", "");
if ($this->_remaining > 0) {
$objResponse->assign ( "messageText", "innerHTML", "Completed " . $this->_completed . " of " . $this->_totalItems . " (Failures: " . $this->_failures . ")" );
$objResponse->assign ( "progressSpinner", "className", "" );

// todo - how to get waitCursor to start again.
$objResponse->script("xajax_".$this->_id.".dojob('$job', '$arg1', document.forms['progressForm']['continue'].value, '$this->_completed', '".$this->_failures."');");
$objResponse->script ( "xajax_" . $this->_id . ".dojob('$job', '$arg1', document.forms['progressForm']['continue'].value, '$this->_completed', '" . $this->_failures . "');" );
} else {
$objResponse->assign("messageText", "innerHTML", "Job Complete (Completed: ".$this->_completed.", Failures: ".$this->_failures.")");
$objResponse->assign("progressSpinner", "className", "hidden");
$objResponse->assign ( "messageText", "innerHTML", "Job Complete (Completed: " . $this->_completed . ", Failures: " . $this->_failures . ")" );
$objResponse->assign ( "progressSpinner", "className", "hidden" );
}
}
} else {
$objResponse->assign("messageText", "innerHTML", "Job Aborted (Completed: ".$this->_completed.", Failures: ".$this->_failures.")");
$objResponse->assign("progressSpinner", "className", "hidden");
$objResponse->assign ( "messageText", "innerHTML", "Job Aborted (Completed: " . $this->_completed . ", Failures: " . $this->_failures . ")" );
$objResponse->assign ( "progressSpinner", "className", "hidden" );
}

if(strlen($this->_debug)>0) {
$objResponse->assign("debug", "innerHTML", $this->_debug);
if (strlen ( $this->_debug ) > 0) {
$objResponse->assign ( "debug", "innerHTML", $this->_debug );
}

return $objResponse;
}

function printJobProgressBar($arg1 = NULL) {
$gsimage = theme_image_src('gs.gif');

$gsimage = theme_image_src ( 'gs.gif' );
$divContents = '
<div id="status" style="{width:300; margin: 4px}">
Expand All @@ -117,7 +115,7 @@ function printJobProgressBar($arg1 = NULL) {
<ul id="progressBar">';

for($i=1; $i<=10; $i++) {
for($i = 1; $i <= 10; $i ++) {
$divContents .= "\n<li><img id=\"status$i\" src=\"$gsimage\"></li>";
}

Expand All @@ -129,15 +127,15 @@ function printJobProgressBar($arg1 = NULL) {
<form id="progressForm">
<input type="hidden" name="continue" value="true" />
<input type="button" class="button" id="startButton" value="Start"
onclick="document.getElementById(\'progressSpinner\').className=\'\'; this.form[\'continue\'].value=\'true\'; xajax_'.$this->_id.'.dojob(\''.$this->_job.'\', \''.$arg1.'\', \'true\', \'0\', \'0\'); this.disabled=true; return false;" />
onclick="document.getElementById(\'progressSpinner\').className=\'\'; this.form[\'continue\'].value=\'true\'; xajax_' . $this->_id . '.dojob(\'' . $this->_job . '\', \'' . $arg1 . '\', \'true\', \'0\', \'0\'); this.disabled=true; return false;" />
<input type="button" class="button" id="cancelButton" value="Cancel"
onclick="this.form[\'continue\'].value=\'false\'; this.disabled=true; " />
</form>
</div>';

echo $divContents;
}

function __executeJob() {
}
}
Expand Down
Loading

0 comments on commit 1d52af5

Please sign in to comment.