<?php
defined('_JEXEC') or die();
class HTML_joeWmtPortfolio{
function edit( $option, &$row ) {
HTML_joeWmtPortfolio::setMessageToolbar($row->id);
?>
<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>Image Name: </td>
<td><input type="text" size="50" maxsize="100" name="artLocation" value="<?php echo $row->artLocation; ?>" /></td>
<td rowspan="5" width="20"> </td>
<td rowspan="5"><textarea rows="10" cols="20" readonly="readonly"><?php
$handle=opendir('../components/com_wmtportfolio/artwork/');
while(!false==($file=readdir($handle))){
if ($file != "." && $file != "..") {
echo "$file\n";
}
}
?></textarea></td>
</tr>
<tr>
<td>Description Line 1: </td>
<td><input size="30" name="trackName" value="<?php echo $row->trackName; ?>" /></td>
</tr>
<tr>
<td>Description Line 2: </td>
<td><input size="30" name="artist" value="<?php echo $row->artist; ?>" /></td>
</tr>
<tr>
<td>Description Line 3: </td>
<td><input size="30" name="albumName" value="<?php echo $row->albumName; ?>" /></td>
</tr>
<tr>
<td>Link To: </td>
<td><input size="30" name="linkTo" value="<?php echo $row->linkTo; ?>" /></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
</form>
<?php
}
function listMessages( $option, $rows ) {
HTML_joeWmtPortfolio::setAllMessagesToolbar();
?>
<form action="index2.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<tr>
<th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
<th width="100"></th>
<th class="title" >Image Name</th>
<th>Description Line 1</th>
<th>Description Line 2</th>
<th>Description Line 3</th>
<th>Link To</th>
<th width="10%">Published</th>
</tr>
<?php
$k = 0;
for($i=0; $i < count( $rows ); $i++) {
$row = $rows[$i];
$published = JHTML::_('grid.published', $row, $i );
$checked = JHTML::_('grid.id', $i, $row->id );
$link = 'index.php?option=' . $option . '&task=edit&cid[]='. $row->id;
?>
<tr class="<?php echo "row$k"; ?>">
<td><?php echo $checked; ?></td>
<td><img src="../components/com_wmtportfolio/artwork/<?php echo $row->artLocation; ?>" width="90" height="68" /></td>
<td><a href="<?php echo $link; ?>"><?php echo $row->artLocation; ?></a></td>
<td><?php echo $row->trackName; ?></td>
<td><?php echo $row->artist; ?></td>
<td><?php echo $row->albumName; ?></td>
<td><a href="http://<?php echo $row->linkTo; ?>" target="_blank"><?php echo $row->linkTo; ?></a></td>
<td align="center"><?php echo $published; ?></td>
<?php $k = 1 - $k; ?>
</tr>
<?php }
?>
</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
</form>
<?php
}
function upload($option){
require_once(JPATH_COMPONENT.DS.'controller.php');
HTML_joeWmtPortfolio::setAllMessagesToolbar();
if (isset($_FILES['file'])) {
$userfile = (isset($_FILES['file']['name']) ? $_FILES['file']['name'] : "");
$base_Dir = JPATH_SITE.'/components/com_wmtportfolio/artwork/';
$action="index2.php?option=$option&task=up";
$this->setRedirect($action);
if (!empty($userfile)) {
$filename = split("\.", $userfile);
}
if (empty($userfile)) {
JError::raiseWarning( 500, 'Please select an image to upload');
}
else if (eregi("[^0-9a-zA-Z_]", $filename[0])) {
JError::raiseWarning( 500, 'File must only contain alphanumeric characters and no spaces please.');
}
else if (file_exists($base_Dir.$userfile)) {
JError::raiseWarning( 500, 'Image '.$userfile.' already exists.');
}
else if (strtoupper(substr($userfile,-4))!='.JPG' && strtoupper(substr($userfile,-4))!='.PNG' && strtoupper(substr($userfile,-4))!='.GIF'){
JError::raiseWarning( 500, 'The file must be jpg, png or gif');
}
else if (move_uploaded_file($_FILES['file']['tmp_name'], $base_Dir.$userfile)) {
$action="index2.php?option=$option";
$this->setRedirect($action);
$db =& JFactory::getDBO();
$db->setQuery("INSERT INTO #__wmt_portfolio VALUES (NULL,'".$userfile."','','','','','0')");
$rows = $db->loadObjectList();
WmtPortfolioController::createXml();
WmtPortfolioController::setMessage('Success upload');
} else {
JError::raiseWarning( 500, 'Not success. Try again.');
}
}
else
{
?>
<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm" enctype="multipart/form-data">
<br />
<br />
Choose Image to Upload: <br />
<br />
<input type="file" name="file" />
<br />
<br />
<input type="submit" name="upload" value="Upload Image" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="up" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="act" value="upp" />
</h3>
</form>
<?php
}
}
function setMessageToolbar($id)
{
if ($id) {
$newEdit = 'Edit';
} else {
$newEdit = 'New';
}
JToolBarHelper::title($newEdit . ' WmtPortfolio', 'generic.png');
JToolBarHelper::save();
JToolBarHelper::cancel();
}
function setAllMessagesToolbar()
{
JToolBarHelper::title('WmtPortfolio Manager', 'generic.png');
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::addNew();
JToolBarHelper::editList();
JToolBarHelper::custom('remove','delete.png','delete_f2.png','Remove',false);
JToolBarHelper::custom('up','upload.png','upload_f2.png','Upload',false);
JToolBarHelper::custom('delete','delete.png','delete_f2.png','Deleta',false);
}
}
?>