I m running a custom snippet that pull s data over queries.
This is the snippet
<?php
// Created by C H 22/1/13
// version: 0.15
// updated: 22/1/18
// Updated: Changed mysql calls to $modx calls to make sure future updates to Evolution don't harm the program
Class Music {
var $template = array();
var $db;
var $fl;
var $orderstr = "created DESC"; // Default value. Change this to change the initial order.
var $username;
var $message = array();
var $config = array();
function Music($config="") {
global $modx;
//mysql_set_charset('utf8');
require_once "data.class.inc.php";
require_once "file.class.inc.php";
//include_once "messages.inc.php";
// Load Templates
$this->loadTemplates();
// Set class config dont do anything if there is nothing in the config
if ( $config ) {
foreach ($config as $key => $value) {
$this->config[$key] = $value;
$modx->setPlaceholder($key, $value);
}
}
// Set the default category to prevent
if ($this->config['defaultCategory']) {
$this->config['composerCategories'] = $this->config['defaultCategory'];
}
// Set config for the class
$this->config['edit'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canEdit']));
$this->config['add'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canAdd']));
$this->config['delete'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canDelete']));
$this->config['table'] = $GLOBALS['table_prefix'] . $this->config['dataset'];
// Added for ajax Support
if ($this->db->config['ajax'] == 1 ) {
$modx->regClientStartupScript('assets/snippets/ncr/jqcmd.js');
}
// load jQuery Library if specified
if ( $this->config['jQuery'] ) {
$modx->regClientStartupScript($this->config['jQuery']);
}
// Load custom CSS and JS
$modx->regClientCSS('assets/snippets/music/css/music.css');
$modx->regClientStartupScript('assets/snippets/music/js/music.js');
$modx->regClientStartupScript('assets/snippets/music/js/jquery.cookie.js');
// override action parameter if incoming URL has parameter action
if ( $_REQUEST['action'] ) {
$this->config['action'] = $_REQUEST['action'];
}
$this->db = new dataDBMusic($this->config);
$this->fl = new MusicFiles($this->config);
//print_r($this->config);
} // End of class constructor
function loadTemplates() {
// Load Default Templates.
$this->config['listTpl'] = file_get_contents('assets/snippets/music/templates/list.template.html','r');
$this->config['listPublisherTpl'] = file_get_contents('assets/snippets/music/templates/listpublisher.template.html','r');
$this->config['viewTpl'] = file_get_contents('assets/snippets/music/templates/view.template.html','r');
$this->config['viewPublisherTpl'] = file_get_contents('assets/snippets/music/templates/viewpublisher.template.html','r');
$this->config['addComposerTpl'] = file_get_contents('assets/snippets/music/templates/addcomposer.template.html','r');
$this->config['addPublisherTpl'] = file_get_contents('assets/snippets/music/templates/addpublisher.template.html','r');
$this->config['editTpl'] = file_get_contents('assets/snippets/music/templates/edit.template.html','r');
$this->config['editPublisherTpl'] = file_get_contents('assets/snippets/music/templates/editpublisher.template.html','r');
$this->config['fileimageTpl'] = file_get_contents('assets/snippets/music/templates/fileimage.template.html','r');
$this->config['deleteimageTpl'] = file_get_contents('assets/snippets/music/templates/deleteimage.template.html','r');
}
function Run() {
global $modx;
// Write a cookie about the listpage for the composer database
//setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
setcookie("composerListPage", $this->config['listPage'], time()+ (3600*60), "/", $_SERVER['SERVER_NAME'], 0) ;
// $output = print_r($this->config) . print_r($this->config);
// Put a div in for a message!
$output = "<div id='message' style='display:none;'></div>";
// create the header - Only show if we are not doing any editing or adding
if ( $this->config['action'] == "add" || $this->config['action'] == "edit" || $this->config['action'] == "view" ) {
} else {
$letterlinks = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if ($this->config['dataset'] != "publisher") {
// Add Category selection box
$output .= "<table>";
$output .= "<tr>";
$output .= "<td>";
$output .= "<div style='display:none;'>Category: </div>";
$output .= "</td>";
$output .= "<td>";
$output .= "<div id='categoryheader' style='display:none;' >";
$output .= $this->db->buildCategory($_REQUEST['category']);
$output .= "</div>";
$output .= "</td>";
$output .= "</tr>";
$output .= "<tr>";
$output .= "<td>";
$output .= "<div id='nationalityheader'>Nationality: </div>";
$output .= "</td>";
$output .= "<td>";
$output .= "<div id='nationality'>";
$output .= $this->db->buildNationality( $_REQUEST['nationality'], "GetRecords");
$output .= "</div>";
$output .= "</td>";
$output .= "</tr>";
$output .= "<tr>";
$output .= "<td>";
$output .= "<div id='settings'>";
$output .= "<input id='configsettings' name='settings' type='hidden' value='[+settings+]' />";
$output .= "</div>";
$output .= "<div id='searchdata'>Search: ";
$output .= "</td>";
$output .= "<td>";
$output .= "<input id='searchfield' name='searchfield' type='text' value='Search data' onfocus=\"this.value=(this.value=='Search data...')? '' : this.value ;\" />";
$output .= "</div>";
$output .= "</td>";
$output .= "</tr>";
$output .= "</table>";
}
$output .= "<div id='filter'>";
// Create alphabet list to break the list down
$output .= $this->db->displayBreakdown();
$output .= "</div>";
$output .= "<div id='results'></div>";
}
// Display the list of quintets and quartets
if ( $this->config['action'] == "list" && $_REQUEST['filter'] && $this->config['dataset'] != "publisher" ) {
// List the quartets, quintets
$modx->setPlaceholder( 'data', $this->db->listRecords() );
$output .= $this->config['listTpl'];
} else if ( $this->config['action'] == "list" && $_REQUEST['filter'] && $this->config['dataset'] == "publisher") {
// List the publishers
$modx->setPlaceholder( 'data', $this->db->listPublishers() );
$output .= $this->config['listPublisherTpl'];
} else if ( $this->config['action'] == "view" && $_REQUEST['idcomp'] ) {
// View the quartets
$this->db->getRecord();
$output .= $this->config['viewTpl'];
} else if ( $this->config['action'] == "view" && $_REQUEST['idpub'] ) {
// View the Publishers
$this->db->getPublisherRecord();
$output .= $this->config['viewPublisherTpl'];
} else if ( $this->config['action'] == "edit" && $this->config['edit'] && $_REQUEST['idcomp'] ) {
// Get the record to edit for quartets and quintets
$this->db->getRecord();
// Get the details so we can add a new publisher via the edit screen
$modx->setPlaceholder('addPublisher', $this->config['addPublisherTpl']);
// Make sure we build the drop down box for the publishers so a user can change to an existing record
// Set Button Placeholder to Update
$modx->setPlaceholder('updateAction', "Update");
$output .= $this->config['editTpl'];
} else if ( $this->config['action'] == "edit" && $this->config['edit'] && $_REQUEST['idpub'] ) {
// Get the Publisher record
$this->db->getPublisherRecord();
// Set Button Placeholder to Update
$output .= $this->config['editPublisherTpl'];
} else if ( $this->config['action'] == "deletefile" && $this->config['edit'] ) {
// Delete the image file in quartets, quintets
if ( $this->fl->deleteFile() ) {
// remove the entry in the database
$this->db->deleteImage();
}
} else if ( $this->config['action'] == "Update" && $this->config['edit'] && $this->config['dataset'] != "publisher") {
// Update the quintets, quartets record
// remove the file first due to class restrictions
if ( $_POST['deletefile'] ) {
$this->fl->deleteFile() ;
$this->db->deleteImage();
}
if ($_FILES['file']['name']) {
// upload file
// This should upload the file and update the database with the appropriate folder information.
$this->db->updateImage($this->fl->uploadFile());
}
// Update record back to database
$this->db->updateRecord();
// Take me to view the page to see the changes
$parameters = "&idcomp=".$_POST['idcomp'];
$url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full');
$modx->sendRedirect($url);
} else if ( $this->config['action'] == "Update" && $this->config['edit'] && $this->config['dataset'] == "publisher" ) {
// Update Publisher record back to database
$this->db->updatePublisherRecord();
// Take me to view the page to see the changes
$parameters = "&idpub=".$_POST['idpub'];
$url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full');
$modx->sendRedirect($url);
} else if ( $_REQUEST['action'] == "deletecomposer" && $this->config['delete'] ) {
// Delete Composer
// check the image of the record to ensure there is a file to remove too
$this->db->getRecord();
if ( $modx->getPlaceholder('composerimage') ) {
$this->fl->deleteFile();
}
$this->db->deleteComposer();
// If we sent a filter parameter then we should return to the same screen
if ( $_REQUEST['filter'] ) {
$parameters = "filter=".$_REQUEST['filter'];
$url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full');
$modx->sendRedirect($url);
}
} else if ( $_REQUEST['action'] == 'deletepublisher' && $this->config['delete'] ) {
// Delete Publisher Record
$this->db->deletePublisher();
// If we sent a filter parameter then we should return to the same screen
if ( $_REQUEST['filter'] ) {
$parameters = "filter=".$_REQUEST['filter'];
$url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full');
$modx->sendRedirect($url);
}
} else if ( $this->config['action'] == "add" && $this->config['dataset'] != "publisher" && $this->config['add'] ) {
// Add a new quartet, quintet
$modx->setPlaceholder('Nationality', $this->db->buildNationality());
$modx->setPlaceholder('Country', $this->db->buildNationality());
$modx->setPlaceholder('Publisher', $this->db->buildPublisher());
$modx->setPlaceholder('Category', $this->db->buildCategory());
$modx->setPlaceholder('updateAction', "Save");
$modx->setPlaceholder('addPublisher', $this->config['addPublisherTpl']);
$output .= $this->config['addComposerTpl'];
} else if ( $this->config['action'] == "add" && $this->config['dataset'] == "publisher" && $this->config['add'] ) {
// Add a New Publisher
$modx->setPlaceholder('Country', $this->db->buildNationality());
$output .= $this->config['addPublisherTpl'];
} else if ( $this->config['action'] == "Save" && $this->config['add'] ) {
// Save Composer Record
if ( $_POST ) {
$_REQUEST['idcomp'] = $this->db->saveComposer();
if ($_FILES['file']['name']) {
// upload file
// This should upload the file and update the database with the appropriate folder information.
$this->db->updateImage($this->fl->uploadFile());
}
$output .= "Record Saved!<br />";
}
}
return $output;
}
} // end
?>
**
Observed behavior
It should, as on the EVO page, spit out addresses or names of composeres and publishers. Instead I get a blanc page and in Revo i get this in the error log:
PHP warning: Undefined array key “listPage”
PHP warning: Undefined array key “action”
PHP warning: Undefined array key “action”
PHP warning: Undefined array key “action”
PHP warning: Undefined array key “dataset”
Respectively on line 92, 99,99,99 and 104 of above script.
I have no clue where to begin, anyone?
MODX 3.0.4 PL, running on a transip VPS with Plesk CP. Cant find apache version or NGIX version nor MySQL version, all not shown in info.php.