I tried to find a solution by myself. I was able to create an icon that allows you to upload to photoshare from your pagesetter wyswyg editor (HTMLAREA). But I would like that the HTML code for displaying the uploaded picture is inserted automatically in the text after a sucessful upload.I was not able to do that. I am not very familiar with java script, and hope someone can help me with that.
Here is the code I have written so far:
ENTER this code in pagesetter/guppy/guppy.js right after
config.toolbar[config.toolbar.length-1].push("pagebreak");
near line 440
config.registerButton({
id : "uploadbutton",
tooltip : "upload images",
image : "images/smilies/icon14.gif",
textMode: false,
action:
function(editor, id)
{
if (typeof photoshareFindImage == "undefined")
alert("You have apparently not installed the Photoshare image gallery");
else
{
// Check for base URL which is used to make this run in fullscreen mode
url = (typeof postnukeBaseURL == "undefined" ? "" : postnukeBaseURL+"/" /* defined by html output */);
url += "index.php?module=photoshare&func=uploadimage&url=absolute&html=img&targetID=" + textareaID;
photoshareFindImageHtmlArea30(editor, url, photoshareThumbnailSize /* defined by html output */);
}
}
});
config.toolbar[config.toolbar.length-1].push("uploadbutton");
Then enter the functions photoshare_user_uploadimage() and photoshare_user_uploadimages2() in photoshare/pnuser.php.
The code of these two functions is as follows:
// -----------------------------------------------------------------------
// Upload image and store in opening window's input element
// -----------------------------------------------------------------------
function photoshare_user_uploadimage()
{
// Check access
if (!photoshareAccessFolder(-1, photoshareAccessRequirementView, ''))
return photoshareErrorPage(__FILE__, __LINE__, _PSNOAUTH);
if (!pnModAPILoad('photoshare', 'user'))
return photoshareErrorPage(__FILE__, __LINE__, _PSAPILOADFAILED);
$user = pnUserGetVar('uid');
$targetInputID = pnVarCleanFromInput('targetID');
$resultURLFormat = pnVarCleanFromInput('url');
$resultHTMLFormat = pnVarCleanFromInput('html');
$targetMode = pnVarCleanFromInput('target');
$folders = pnModAPIFunc('photoshare',
'user',
'get_accessible_folders',
array('user' => $user,
'getForList' => false) );
if ($folders === false)
return photoshareErrorAPIGet();
$theme = pnVarPrepForOS(pnUserGetTheme());
$cssURL = "themes/$theme/style/style.css";
echo "\n"
. "\n"
// . "\n\n"
. "\n"
. "\n";
echo "\n";
$initialFolderID = $folders[0]['id'];
// echo "\n";
echo "" . _PSUPLOADIMAGE . "
\n"
. "\n";
// "index.php?module=photoshare&func=uploadimage&url=absolute&html=img&targetID="
echo '<form action="index.php?module=photoshare&func=uploadimages2&" method="post" enctype="multipart/form-data"></form>/ ?enctype=????
echo "| " . _PSFOLDER . ":\n | <select name="\"folderSelect\"" id="\"folderSelect\"">\n";
// Iterate over folders to print options
foreach ($folders as $folder)
{
$folderInfo = pnModAPIFunc('photoshare',
'user',
'get_folder_info',
array('folderID' => $folder['id'],
'countSubFolders' => true) );
if ($folderInfo === false)
return photoshareErrorAPIGet();
else if ($folderInfo === true)
photoshareErrorPage(__FILE__, __LINE__, _PSUNKNOWNFOLDER . " ($folder[id])" );
echo "<option value="\"$folderInfo[id]\"">$folder[title]</option>\n";
}
echo "</select> | \n";
///// enter code start here
// Max. number of images to upload
$imageNum = 1;
$upload_max_filesize = ini_get('upload_max_filesize');
$post_max_size = ini_get('post_max_size');
if ($upload_max_filesize != '')
{
echo ""._PSMAXFILESIZEMSG . ": $upload_max_filesize " . _PSBYTES;
echo " | ";
}
else if ($post_max_size != '')
{
echo ""._PSMAXFILESIZEMSG . ": $post_max_size " . _PSBYTES;
echo " |
| ";
}
// Add upload form for the input
echo '<input type="hidden" name="imagenum" value="'.$imageNum.'" />';
echo '<input type="hidden" name="authid" value="'.pnSecGenAuthKey().'" />';
// $output->FormHidden('fid', $folderID);
for ($i=0 ; $i<$imageNum ; ++$i)
{
// Image file
echo "
"._PSIMAGEFILE;
echo " | <input type="\"file\"" class="\"photoshare-editfile\"" name="\"imagefile$i\"" />";
echo " |
";
// Image title
echo ""._PSIMAGETITLE;
echo " | <input type="\"text\"" class="\"photoshare-edittitle\"" maxlength="\"255\"" name="\"imagetitle$i\"" />";
echo " |
";
// Image description
echo ""._PSIMAGEDESCRIPTION;
echo " | <textarea class="\"photoshare-editdescription\"" name="\"imagedescription$i\"" rows="\"4\""></textarea>";
echo " |
";
// Extra fields
for ($j=1; $j<=photoshareExtraFieldCount; ++$j)
{
$extraTitle = pnModGetVar('photoshare',"extra{$j}Title");
if ($extraTitle != '')
{
echo "".$extraTitle;
echo " | <input type="\"text\"" class="\"photoshare-edittitle\"" maxlength="\"255\"" name="\"extra$i-$j\"" value="\""" />";
echo " |
";
}
}
}
///// end of entered code
if ($resultHTMLFormat == 'img')
{
echo "| "._PSINSERTIMAGE . " | "
. "<select name="\"htmlFormat\"" id="\"htmlFormat\"">"
. "<option value="\"fullImage\"">". _PSINSFULLIMAGE . "</option>\n"
. "<option value="\"thumbnail\"">". _PSINSTHUMBNAIL . "</option>\n"
. "<option value="\"thumbnailPopup\"">". _PSINSTHUMBNAILPOPUP . "</option>\n"
. "<option value="\"fullImageURL\"">". _PSINSFULLIMAGEURL . "</option>\n"
. "<option value="\"fullImageURLPopup\"">". _PSINSFULLIMAGEURLPOPUP . "</option>\n"
. "<option value="\"albumURL\"">". _PSINSALBUMURL . "</option>\n"
. "<option value="\"albumThumbnailURL\"">". _PSINSALBUMURLTHUMBNAIL . "</option>\n"
. "<option value="\"albumURLpopup\"">". _PSINSALBUMURLPOPUP . "</option>\n"
. "<option value="\"albumThumbnailURLpopup\"">". _PSINSALBUMURLTHUMBNAILPOPUP . "</option>\n"
. "</select>\n";
}
// echo "<button>" . _PSFINDSELECT . "</button>"
echo " |
| <input type="\"submit\"" value="\"Add\"" />";
echo "<button>" . _PSCANCEL ."</button>\n";
echo " |
\n";
return true;
}
function photoshare_user_uploadimages2()
{
$output = new pnHTML();
echo "\n"
. "\n"
// . "\n\n"
. "\n"
. "\n";
$folderID = pnVarCleanFromInput("folderSelect");
$imagenum= pnVarCleanFromInput("imagenum");
echo "
FOLDERID".$folderId;
$i="0";
$imageInfo = $_FILES["imagefile$i"];
$title = pnVarCleanFromInput("imagetitle$i");
$description = pnVarCleanFromInput("imagedescription$i");
echo "
Imageinfo:".$imageInfo;
echo "
Title:".$title;
echo "
Description:".$description;
if (!pnSecConfirmAuthKey())
return photoshareErrorPage(__FILE__, __LINE__, _PSBADAUTHKEY);
// Check access
if (!photoshareAccessFolder($folderID, photoshareAccessRequirementEdit, ''))
return photoshareErrorPage(__FILE__, __LINE__, _PSNOAUTH);
if (!pnModAPILoad('photoshare', 'user'))
return photoshareErrorPage(__FILE__, __LINE__, _PSAPILOADFAILED);
// Get parent folder information
$folder = pnModAPIFunc('photoshare',
'user',
'get_folder_info',
array( 'folderID' => $folderID ));
if ($folder === false)
return photoshareErrorAPIGet();
else if ($folder === true)
photoshareErrorPage(__FILE__, __LINE__, _PSCANNOTADDIMAGESWITHOUTFOLDER);
// Get user information
$userInfo = pnModAPIFunc('photoshare',
'user',
'get_user_info');
if ($userInfo === false)
return photoshareErrorAPIGet();
$totalCapacityUsed = $userInfo['totalCapacityUsed'];
$menuHide = array();
$menuSettings = array( 'gotoCurrentFolder' => true );
// photoshareMakeMainMenu($output, $folderID, $menuHide, $menuSettings, _PSTITLEADDINGIMAGES, false, null);
$imageNum = intval( pnVarCleanFromInput('imagenum') );
// $folderId = photoshareGetCurrentFolderID();
$imageDir = 'modules/' . photoshareModGetName() . '/pnimages';
$statusSet = array();
for ($i=0; $i < $imageNum; ++$i)
{
$imageInfo = $_FILES["imagefile$i"];
$title = pnVarCleanFromInput("imagetitle$i");
$description = pnVarCleanFromInput("imagedescription$i");
// Fetch extra fields
$extra = array();
for ($j=1; $j<=photoshareExtraFieldCount; ++$j)
{
$extraTitle = pnModGetVar('photoshare',"extra{$j}Title");
if (!empty($extraTitle))
{
$value = pnVarCleanFromInput("extra$i-$j");
$extra["extra$j"] = $value;
}
}
if (isset($imageInfo['error']) && $imageInfo['error'] != 0 && $imageInfo['name'] != '')
{
$statusSet[] = array('ok' => false,
'message' => $imageInfo['name'] . ': ' . photoshareUploadErrorMsg($imageInfo[error]));
}
else
if ($imageInfo['size'] > 0)
{
$statusSet = array_merge($statusSet,
pnModAPIFunc('photoshare',
'user',
'add_image',
array( 'folderID' => $folderID,
'dataFilename' => $imageInfo['tmp_name'],
'dataFileSize' => $imageInfo['size'],
'imageFilename' => $imageInfo['name'],
'mimeType' => $imageInfo['type'],
'title' => $title,
'description' => $description,
'extra' => $extra,
'isUploaded' => true )) );
}
}
// Quick count of uploaded images
$acceptedImageNum = 0;
foreach ($statusSet as $status)
if ($status['ok'])
++$acceptedImageNum;
$folder['imageCount'] += $acceptedImageNum; // Update for showing only
if ($acceptedImageNum == 0)
$statusSet[] = array('ok' => false,
'message' => _PSNOIMAGES);
echo photoshareGetFolderInfoHTML($folder);
echo "
";
photoshareDisplayStatusSet($output, $imageDir, $statusSet);
$output->SetInputMode(_PNH_PARSEINPUT);
$output->LineBreak();
$viewURL = pnModURL('photoshare', 'user', 'view', array('fid' => $folderID));
$output->LineBreak();
photoshareMakeMainFooter($output);
echo $output-> output;
$resultURLFormat="absolute";
$resultHTMLFormat="img";
$targetMode="htmlArea30";
echo "
<button>" . _PSFINDSELECT . "</button>"
. "<button>" . _PSCANCEL ."</button>\n";
echo "\n";
return true;
}