<?
// Direct access variable
define( "_VALID_DA_", 1 );
define("CONFIGFILE","../../config.inc");
session_start();
//Include Object Includes
if(is_file("../../configuration.php")) require ("../../configuration.php");
if(is_file("../../include.php")) require ("../../include.php");
if(is_file("../../functions.php")) require ("../../functions.php");
Configuration(CONFIGFILE);
global $recursivecount;
//Include Language File
include("../../languages/".strtolower($_SESSION['lang'])."/language.php");
$GLOBALS['pageid'] = $_SESSION['active_page'];
$GLOBALS['imagedirectory']="../../sections/".$GLOBALS['pageid']."/images";
$GLOBALS['filedirectory']="../../sections/".$GLOBALS['pageid']."/files";
$GLOBALS['flashdirectory']="../../sections/".$GLOBALS['pageid']."/flash";
$thisurl = $GLOBALS['thisurl'];
$length = strlen($thisurl);
$lastchr = substr($thisurl, $length-1, $length);
if ($lastchr=="/"){
$thisurl = substr($thisurl, 0, $length-1);
}
//*****************************************************************************
function RecursivePageSelect($pageid, $recursivecount){
$content = null;
$obj_page = new CPage();
$obj_pagearray = new CPageArray();
$obj_pageengine = new CPageEngine();
$obj_content = new CContent();
$obj_contentarray = new CContentArray();
$obj_contentengine = new CContentEngine();
$obj_pagearray = $obj_pageengine->GetChildPages($pageid, -1);
$num_rows = $obj_pagearray->count();
if ($num_rows!=0){
$recursivecount++;
//echo "pageid:$pageid - recursivecount:$recursivecount<br>";
for ( $counter = 1; $counter <= $recursivecount; $counter++)
$braket = $braket."|--";
while( $obj_page = $obj_pagearray->get() ){
$thispageid=$obj_page->page_id;
$thisactive=$obj_page->active;
$obj_content = $obj_contentengine->GetContent(ActiveLanguage(), $thispageid, "name");
$thisname = $obj_content->context;
if ($thisactive==0)
$activepage="style=\"background-color:gray;color:white\"";
else
$activepage="";
$content .= "<option value=\"index.php?pageid=$thispageid\" $activepage $disabled>";
$content .= "$braket";
$content .= "$thisname</option>";;
//echo "thisname(id):$thisname($thispageid)<br>";
$content .= RecursivePageSelect($thispageid, $recursivecount);
}
}
else{
$content = null;
$recursivecount--;
$braket = null;
}
return $content;
}
//*****************************************************************************
function SelectFile($thisurl){
$obj_page = new CPage();
$obj_pagearray = new CPageArray();
$obj_pageengine = new CPageEngine();
$obj_subpage = new CPage();
$obj_subpagearray = new CPageArray();
$obj_subpageengine = new CPageEngine();
$obj_content = new CContent();
$obj_contentarray = new CContentArray();
$obj_contentengine = new CContentEngine();
$content = "
<br>
<center>
<form name=\"SiteForm\" onsubmit=\"javascript:InsertSiteURL();\">
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr>
<td><select name=\"sitesrc\" id=\"sitesrc\">";
$recursivecount = 0;
$obj_pagearray = $obj_pageengine->GetParentPages(-1);
$num_rows = $obj_pagearray->count();
while( $obj_page = $obj_pagearray->get() ){
$thispageid = $obj_page->page_id;
$active=$obj_page->active;
$obj_content = $obj_contentengine->GetContent(ActiveLanguage(), $thispageid, "name");
$thisname = $obj_content->context;
if ($active==0)
$activepage="style=\"background-color:gray;color:white\"";
else
$activepage="";
$content .= "<option value=\"index.php?pageid=$thispageid\" $activepage>$thisname</option>";
$recursivecount = 0;
$content .= RecursivePageSelect($thispageid, $recursivecount);
}
$content .= "
</select>
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CP_CA_IM_INSERT_LINK_."\" />
<input type=\"button\" value=\""._CMN_CANCEL_."\" onClick=\"window.close();\" />
</td>
</tr>
</table>
</form>
<br><br>
<form name=\"FileForm\" onsubmit=\"javascript:InsertFileURL();\">
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr>
<td><select name=\"filesrc\" id=\"filesrc\">
<option value=\"\">"._CP_CA_IM_URL_SELECT_STORED_FILE_."</option>
";
$dh=opendir($GLOBALS['filedirectory']);
while ($file=readdir($dh)){
if ($file!=".." && $file!=".")
$content .= "<option value=\"".$thisurl."/sections/".$GLOBALS['pageid']."/files/$file\">$file</option>";
}
closedir();
$content .= "
</select>
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CP_CA_IM_INSERT_FILE_."\" />
<input type=\"button\" value=\""._CMN_CANCEL_."\" onClick=\"window.close();\" />
</td>
</tr>
</table>
</center>
</form>";
return $content;
}
//*****************************************************************************
function SelectImage($thisurl){
$content = "
<br>
<center>
<form name=\"ImageForm\" onsubmit=\"javascript:InsertImageURL();\">
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr>
<td><select name=\"imagesrc\" id=\"imagesrc\">
<option value=\"\">"._CP_CA_IM_URL_SELECT_STORED_IMAGE_."</option>
";
$dh=opendir($GLOBALS['imagedirectory']);
while ($file=readdir($dh)){
if ($file!=".." && $file!=".")
$content .= "<option value=\"".$thisurl."/sections/".$GLOBALS['pageid']."/images/$file\">$file</option>";
}
closedir();
$content .= "
</select>
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CP_CA_IM_INSERT_IMAGE_."\" />
<input type=\"button\" value=\""._CMN_CANCEL_."\" onClick=\"window.close();\" />
</td>
</tr>
</table>
</center>
</form>";
return $content;
}
//*****************************************************************************
function SelectFlash($thisurl){
$content = "
<br>
<center>
<form name=\"FlashForm\" onsubmit=\"javascript:InsertFlashURL();\">
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr>
<td><select name=\"flashsrc\" id=\"flashsrc\">
<option value=\"\">"._CP_CA_IM_URL_SELECT_STORED_FLASH_."</option>
";
$dh=opendir($GLOBALS['flashdirectory']);
while ($file=readdir($dh)){
if ($file!=".." && $file!=".")
$content .= "<option value=\"".$thisurl."/sections/".$GLOBALS['pageid']."/flash/$file\">$file</option>";
}
closedir();
$content .= "
</select>
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CP_CA_IM_INSERT_FLASH_."\" />
<input type=\"button\" value=\""._CMN_CANCEL_."\" onClick=\"window.close();\" />
</td>
</tr>
</table>
</center>
</form>";
return $content;
}
//*****************************************************************************
function Create_Tab_Menu($fbtype){
$content = "
<div id=\"navcontainer\">
<ul id=\"navlist\">";
$current = "id=\"current\"";
$active = "id=\"active\"";
switch ($fbtype){
default:
case 'file':
$content .= "<li $active><a href=\"#\" $current>"._CP_CA_IM_INSERT_FILE_."</a></li>";
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_IMAGE_."</a></li>";
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_FLASH_."</a></li>";
break;
case 'image':
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_FILE_."</a></li>";
$content .= "<li $active><a href=\"#\" $current>"._CP_CA_IM_INSERT_IMAGE_."</a></li>";
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_FLASH_."</a></li>";
break;
case 'flash':
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_FILE_."</a></li>";
$content .= "<li><a href=\"#\">"._CP_CA_IM_INSERT_IMAGE_."</a></li>";
$content .= "<li $active><a href=\"#\" $current>"._CP_CA_IM_INSERT_FLASH_."</a></li>";
break;
}
$content .= "
</ul>
</div>";
return $content;
};
//------------------------------------------------------------------------------
function Begin_FieldSet(){
$content = null;
$content .= "
<center>
<fieldset>
<img style=\"float:right;\" src=\"../../images/icon48/files.png\" width=\"48\" height=\"48\" border=\"0\"><br>
<legend>"._CP_FILE_ADMINISTRATION_."</legend>
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr><td align=\"center\">
";
return $content;
}
//------------------------------------------------------------------------------
function End_FieldSet(){
$content = null;
$content .= "
</td></tr>
</table>
</fieldset>
</center>
";
return $content;
}
//*****************************************************************************
function HTML_Begin(){
$content .= "
<head>
<title>"._CMN_CILEKCMS_."</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-9\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1254\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<meta name=\"keywords\" content=\"\" />
<meta name=\"description\" content=\"\" />
<meta name=\"robots\" content=\"index,follow\" />
<link href=\"../../style.css\" rel=\"stylesheet\" />
<SCRIPT LANGUAGE=\"JavaScript\">
<!--
// Call this from your popup page it will insert the URL
function InsertImageURL() {
var oForm = document.ImageForm;
var mywin = opener.tinyMCE.getWindowArg(\"window\");
var target_field = mywin.document.getElementById('src');
imgUrl = oForm.imagesrc.value;
target_field.value = imgUrl;
window.close();
}
// Call this from your popup page it will insert the URL
function InsertFileURL() {
var oForm = document.FileForm;
var mywin = opener.tinyMCE.getWindowArg(\"window\");
var target_field = mywin.document.getElementById('href');
fileUrl = oForm.filesrc.value;
target_field.value = fileUrl;
window.close();
}
// Call this from your popup page it will insert the URL
function InsertSiteURL() {
var oForm = document.SiteForm;
var mywin = opener.tinyMCE.getWindowArg(\"window\");
var target_field = mywin.document.getElementById('href');
siteUrl = oForm.sitesrc.value;
target_field.value = siteUrl;
window.close();
}
// Call this from your popup page it will insert the URL
function InsertFlashURL() {
var oForm = document.FlashForm;
var mywin = opener.tinyMCE.getWindowArg(\"window\");
var target_field = mywin.document.getElementById('file');
flashUrl = oForm.flashsrc.value;
target_field.value = flashUrl;
window.close();
}
</SCRIPT>
</head>
<body style=\"background-color:F0F0EE\">";
return $content;
}
//*****************************************************************************
function HTML_End(){
$content .= "
</body>
</html>";
return $content;
}
$content .= Create_Tab_Menu($fbtype);
$content .= HTML_Begin();
$content .= Begin_FieldSet();
switch ($fbtype){
default:
case 'file':
$content .= SelectFile($thisurl);
break;
case 'image':
$content .= SelectImage($thisurl);
break;
case 'flash':
$content .= SelectFlash($thisurl);
break;
}
$content .= End_FieldSet();
$content .= HTML_End();
echo $content;
?>