function footer($javascript = '')
    {
        echo '<div id="content"></div>';
        echo '<script language="javascript" type="text/javascript">';
        ?>

	function contains(arr, key) {
		for (i=0; i<arr.length; i++) {
			if (arr[i].toLowerCase() == key.toLowerCase()) {
				return true;
			}
		}
		return false;
	}

	function albumSwitch(sel) {
		var selected = sel.options[sel.selectedIndex];
		var albumtext = document.getElementById("albumtext");
		var albumbox = document.getElementById("folderdisplay");
		var titlebox = document.getElementById("albumtitle");
		var checkbox = document.getElementById("autogen");
		
		if (selected.value == "") {
			albumtext.style.display = "block";
			albumbox.value = "";
			titlebox.value = "";
			document.getElementById("foldererror").style.display = "none";
			checkbox.checked = true;
			toggleAutogen("folderdisplay", "albumtitle", checkbox);
		} else {
			albumtext.style.display = "none";
			albumbox.value = selected.value;
			titlebox.value = selected.text;
		}
	}

	function updateFolder(nameObj, folderID, checkboxID) {
		var autogen = document.getElementById(checkboxID).checked;
		var folder = document.getElementById(folderID);
		var name = nameObj.value;
		var fname = "";
		var fnamesuffix = "";
		var count = 1;
		if (autogen && name != "") {
			fname = name;
			fname = fname.toLowerCase();
			fname = fname.replace(/[\!@#$\%\^&*()\~`\'\"]/gi, "");
			fname = fname.replace(/[^a-zA-Z0-9]/gi, "-");
			fname = fname.replace(/--*/gi, "-");
			while (contains(albumArray, fname+fnamesuffix)) {
				fnamesuffix = "-"+count;
				count++;
			}
		}
		folder.value = fname+fnamesuffix;
	}

	function validateFolder(folderObj) {
		var errorDiv = document.getElementById("foldererror");
		if (albumArray && contains(albumArray, folderObj.value)) {
			errorDiv.style.display = "block";
		} else {
			errorDiv.style.display = "none";
		}
	}

	function toggleAutogen(fieldID, nameID, checkbox) {
		var field = document.getElementById(fieldID);
		var name = document.getElementById(nameID);
		if (checkbox.checked) {
			window.folderbackup = field.value;
			field.disabled = true;
			updateFolder(name, fieldID, checkbox.id);
		} else {
			if (window.folderbackup && window.folderbackup != "")
				field.value = window.folderbackup;
			field.disabled = false;
		}
	}


		
	function startUpload(folder) {
		var xml = window.external.Property('TransferManifest');
		var files = xml.selectNodes('transfermanifest/filelist/file');

		for (i = 0; i < files.length; i++) {
			var postTag = xml.createNode(1, 'post', '');
			postTag.setAttribute('href', '<?php 
        echo FULLWEBPATH . '/' . basename(__FILE__) . '?cmd=upload';
        ?>
&folder=' + folder);
			postTag.setAttribute('name', 'userpicture');

			var dataTag = xml.createNode(1, 'formdata', '');
			dataTag.setAttribute('name', 'MAX_FILE_SIZE');
			dataTag.text = '10000000';
			postTag.appendChild(dataTag);

			files.item(i).appendChild(postTag);
        }

        var uploadTag = xml.createNode(1, 'uploadinfo', '');
        uploadTag.setAttribute('friendlyname', '<?php 
        echo utf8::encode_javascript(getOption('gallery_title'));
        ?>
');
        var htmluiTag = xml.createNode(1, 'htmlui', '');
        htmluiTag.text = '<?php 
        echo utf8::encode_javascript(FULLWEBPATH);
        ?>
';
        uploadTag.appendChild(htmluiTag);

        xml.documentElement.appendChild(uploadTag);

        window.external.Property('TransferManifest')=xml;
        window.external.SetWizardButtons(true,true,true);
        content.innerHtml=xml;
        window.external.FinalNext();
	}

	function OnBack() {
		<?php 
        echo $this->onBack;
        ?>
	}

	function OnNext() {
		<?php 
        echo $this->onNext;
        ?>
	}

	function OnCancel() {
		<?php 
        echo $this->onCancel;
        ?>
	}

	function window.onload() {
		window.external.SetWizardButtons(1,1,0);
		window.external.SetHeaderText('<?php 
        echo utf8::encode_javascript(getOption('gallery_title'));
        ?>
','<?php 
        echo utf8::encode_javascript(FULLWEBPATH);
        ?>
');
	}
	
	<?php 
        echo $javascript;
        ?>
	
		<?php 
        echo '</script></body></html>';
    }
Exemple #2
0
/**
 * encodes a pre-sanitized string to be used as a Javascript parameter
 *
 * @param string $this_string
 * @return string
 */
function js_encode($this_string)
{
    global $_zp_UTF8;
    $this_string = preg_replace("/\r?\n/", "\\n", $this_string);
    $this_string = utf8::encode_javascript($this_string);
    return $this_string;
}