code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Edit Tag By Peg</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script language="javascript">
window.resizeTo(600, 450);
function Init() {
__dlg_translate("EditTag");
__dlg_init();
var param = window.dialogArguments;
document.getElementById("TAG").value = param["content"];
document.getElementById("TAG").focus();
}
function onCancel() {
__dlg_close( null );
return false;
}
function onOK() {
var ret = document.getElementById("TAG").value;
__dlg_close( ret );
}
</script>
</head>
<body class="dialog" onLoad="Init();">
<div class="title">Tag Editor</div>
<textarea name="TAG" id="TAG" cols=22 rows=5 style="width: 100%; height: 315px; margin-top: 8px; margin-bottom: 4px; font-family: monospace; font-size: 11px;"></textarea>
<div id="buttons">
<button type="submit" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/EditTag/popups/edit_tag.html | HTML | art | 1,188 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// Author: Maarten Molenschot, maarten@nrgmm.nl
{
"Insert/edit horizontal rule": "Horizontale lijn invoegen/bewerken",
"Horizontal Rule": "Horizontale lijn",
"Layout": "Weergave",
"Width:": "Breedte:",
"percent": "procent",
"pixels": "pixels",
"Height:": "Hoogte:",
"Alignment:": "Uitvulling:",
"Left": "Links",
"Center": "Midden",
"Right": "Rechts",
"Style": "Style",
"Color:": "kleur",
"No shading": "Geen schaduw",
"Note:": "Notitie",
"To select an existing horizontal rule, a double-click may be needed.": "Om een bestaande horizontale lijn te selecteren moet je mogelijk dubbel klikken."
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/nl.js | JavaScript | art | 698 |
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: Udo Schmal (gocher), http://www.schaffrath-neuemedien.de/, udo.schmal@t-online.de
{
"Insert/edit horizontal rule": "horizontale Linie einfügen/bearbeiten",
"Horizontal Rule": "Horizontale Linie",
"Layout": "Gestaltung",
"Width:": "Breite:",
"percent": "Prozent",
"pixels": "Pixel",
"Height:": "Höhe:",
"Alignment:": "Ausrichtung:",
"Left": "links",
"Center": "zentriert",
"Right": "rechts",
"Style": "Stil",
"Color:": "Farbe",
"No shading": "keine Schattierung",
"Note:": "Anmerkung",
"To select an existing horizontal rule, a double-click may be needed.": "Um eine horizontale Linie auszuwählen kann ein Doppelklick erforderlich sein."
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/de.js | JavaScript | art | 739 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"Insert/edit horizontal rule": "Insérer une règle horizontale",
"Horizontal Rule": "Règle horizontale",
"Layout": "Layout",
"Width:": "Largeur",
"percent": "pourcent",
"pixels": "pixels",
"Height:": "Hauteur",
"Alignment:": "Alignement",
"Left": "Gauche",
"Center": "Centre",
"Right": "Droite",
"Style": "Style",
"Color:": "Couleur",
"No shading": "Pas d'ombre",
"Note:": "Note",
"To select an existing horizontal rule, a double-click may be needed.": "Pour sélectionner une règle horizontale, un double-clic peut être nécessaire."
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/fr.js | JavaScript | art | 624 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
// This string is for auto detection of multi-encoding editor : 国際化文字検出用文字列
{
"Insert/edit horizontal rule": "水平線の挿入/修正",
"Horizontal Rule": "水平線",
"Layout": "レイアウト",
"Width:": "幅:",
"percent": "パーセント",
"pixels": "ピクセル",
"Height:": "高さ:",
"Alignment:": "行揃え:",
"Left": "左",
"Center": "中央",
"Right": "右",
"Style": "スタイル",
"Color:": "色:",
"No shading": "影付けなし",
"Note:": "備考",
"To select an existing horizontal rule, a double-click may be needed.":"既存の水平線を選択するにはDoubleClickが必要。"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/ja.js | JavaScript | art | 710 |
// I18N constants
// LANG: "nb", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"Insert/edit horizontal rule": "Sett inn/ rediger horisontal linje",
"Horizontal Rule": "Horisontal linje",
"Layout": "Oppsett",
"Width:": "Bredde:",
"percent": "prosent",
"pixels": "Piksel",
"Height:": "Høyde:",
"Alignment:": "Justering:",
"Left": "Venstre",
"Center": "Sentrert",
"Right": "Høyre",
"Style": "Stil",
"Color:": "Farge",
"No shading": "Ingen skygge",
"Note:": "Notat",
"To select an existing horizontal rule, a double-click may be needed.": "For å velge en horisontal linje kan det hende du må dobbeltklikke."
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/nb.js | JavaScript | art | 690 |
// I18N constants
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
// Last revision: 05 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"Alignment:": "Alinhamento:",
"Cancel": "Cancelar",
"Center": "Centralizar",
"Color:": "Côr:",
"Height:": "Alturar:",
"Horizontal Rule": "Linha Horizontal",
"Insert/Edit Horizontal Rule": "Inserir/Editar Linha Horizontal",
"Insert/edit horizontal rule": "Inserir/editar linha horizontal",
"Layout": "Esquema",
"Left": "Esquerda",
"No shading": "Sem sombra",
"OK": "OK",
"Right": "Direita",
"Style": "Estilo",
"Width:": "Largura:",
"percent": "porcentagem",
"pixels": "pixels"
}
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/lang/pt_br.js | JavaScript | art | 1,002 |
HorizontalRule._pluginInfo = {
name : "HorizontalRule",
version : "1.0",
developer : "Nelson Bright",
developer_url : "http://www.brightworkweb.com/",
c_owner : "Nelson Bright",
sponsor : "BrightWork, Inc.",
sponsor_url : "http://www.brightworkweb.com/",
license : "htmlArea"
};
function HorizontalRule(editor) {
this.editor = editor;
var cfg = editor.config;
var toolbar = cfg.toolbar;
var self = this;
cfg.registerButton({
id : "edithorizontalrule",
tooltip : this._lc("Insert/edit horizontal rule"),
// image : editor.imgURL("ed_hr.gif", "HorizontalRule"),
image : [_editor_url + "images/ed_buttons_main.gif",6,0],
textMode : false,
action : function(editor) {
self.buttonPress(editor);
}
});
cfg.addToolbarElement("edithorizontalrule","inserthorizontalrule",0);
}
HorizontalRule.prototype._lc = function(string) {
return Xinha._lc(string, 'HorizontalRule');
};
HorizontalRule.prototype.buttonPress = function(editor) {
this.editor = editor;
this._editHorizontalRule();
};
HorizontalRule.prototype._editHorizontalRule = function(rule) {
editor = this.editor;
var sel = editor._getSelection();
var range = editor._createRange(sel);
var outparam = null;
if (typeof rule == "undefined") {
rule = editor.getParentElement();
if (rule && !/^hr$/i.test(rule.tagName))
rule = null;
}
if (rule) {
var f_widthValue = rule.style.width || rule.width;
outparam = {
f_size : parseInt(rule.style.height,10) || rule.size,
f_widthUnit : (/(%|px)$/.test(f_widthValue)) ? RegExp.$1 : 'px',
f_width : parseInt (f_widthValue,10),
f_color : Xinha._colorToRgb(rule.style.backgroundColor) || rule.color,
f_align : rule.style.textAlign || rule.align,
f_noshade : (parseInt(rule.style.borderWidth,10) == 0) || rule.noShade
};
}
editor._popupDialog("plugin://HorizontalRule/edit_horizontal_rule.html", function(param) {
if (!param) { // user pressed Cancel
return false;
}
var hr = rule;
if (!hr) {
var hrule = editor._doc.createElement("hr");
for (var field in param) {
var value = param[field];
if(value == "") continue;
switch (field) {
case "f_width" :
if(param["f_widthUnit"]=="%")
{
hrule.style.width = value + "%";
}
else
{
hrule.style.width = value + "px";
}
break;
case "f_size" :
hrule.style.height = value + "px";
break;
case "f_align" : // Gecko needs the margins for alignment
hrule.style.textAlign = value;
switch (value) {
case 'left':
hrule.style.marginLeft = "0";
break;
case 'right':
hrule.style.marginRight = "0";
break;
case 'center':
hrule.style.marginLeft = "auto";
hrule.style.marginRight = "auto";
break;
}
break;
case "f_color" :
hrule.style.backgroundColor = value;
break;
case "f_noshade" :
hrule.style.border = "0";
break;
}
}
if ( Xinha.is_gecko )
{ // If I use editor.insertNodeAtSelection(hrule) here I get get a </hr> closing tag
editor.execCommand("inserthtml",false,Xinha.getOuterHTML(hrule));
}
else editor.insertNodeAtSelection(hrule);
} else {
for (var field in param) {
var value = param[field];
switch (field) {
case "f_width" :
if(param["f_widthUnit"]=="%")
{
hr.style.width = value + "%";
}
else
{
hr.style.width = value + "px";
}
break;
case "f_size" :
hr.style.height = value + "px";
break;
case "f_align" :
hr.style.textAlign = value;
switch (value) {
case 'left':
hr.style.marginLeft = "0";
hr.style.marginRight = null;
break;
case 'right':
hr.style.marginRight = "0";
hr.style.marginLeft = null;
break;
case 'center':
hr.style.marginLeft = "auto";
hr.style.marginRight = "auto";
break;
}
break;
case "f_color" :
hr.style.backgroundColor = value;
break;
case "f_noshade" :
break;
}
hr.style.border = (param["f_noshade"]) ? "0" : null;
}
}
}, outparam);
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/HorizontalRule.js | JavaScript | art | 4,225 |
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Insert/Edit Horizontal Rule</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript" src="../../../modules/ColorPicker/ColorPicker.js"></script>
<script type="text/javascript">
editor = window.opener.editor;
function Init() {
__dlg_translate("HorizontalRule");
__dlg_init(null,{width:320,height:290});
var params = window.dialogArguments;
if(params) {
document.getElementById("f_size").value = params.f_size;
document.getElementById("f_width").value = params.f_width;
document.getElementById("f_widthUnit").value = params.f_widthUnit;
document.getElementById("f_align").value = params.f_align;
document.getElementById("f_color").value = params.f_color;
document.getElementById("hrpv").style.backgroundColor = params.f_color;
document.getElementById("f_noshade").checked = params.f_noshade;
}
var colpick = document.getElementById('hrpv');
var f_color = document.getElementById('f_color');
var colPicker = new Xinha.colorPicker({cellsize:'5px',callback:selectColor});
colpick.onclick = function() { colPicker.open('top,left',colpick, f_color.value ); }
document.getElementById("f_width").focus();
}
function onOK() {
var fields = ["f_size", "f_width", "f_widthUnit", "f_align", "f_color", "f_noshade"];
var param = {};
for (var i in fields) {
var id = fields[i];
var el = document.getElementById(id);
param[id] = (el.type == "checkbox") ? el.checked : el.value;
}
__dlg_close(param);
return false;
}
function onCancel() {
__dlg_close(null);
return false;
}
function selectColor(color) {
document.getElementById('hrpv').style.backgroundColor = color;
document.getElementById('f_color').value = color;
}
window.onload = Init;
</script>
<style type="text/css">
.buttonColor {
padding: 1px;
cursor: default;
border: 1px solid;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.buttonColor-hilite {
border-color: #000;
}
.buttonColor .chooser {
height: 0.6em;
border: 1px solid;
padding: 0px 1em;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.buttonColor .nocolor {
padding: 0px;
height: 0.6em;
border: 1px solid;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.buttonColor .nocolor-hilite { background-color: #fff; color: #f00; }
</style>
</head>
<body class="dialog">
<div class="title">Horizontal Rule</div>
<form action="" method="get">
<fieldset>
<legend>Layout</legend>
<div class="fr">Width:</div>
<input style="margin-right: 0.5em;" name="f_width" id="f_width" size="5" type="text" />
<select style="margin-right: 0.5em;" name="f_widthUnit" id="f_widthUnit">
<option value="%">percent</option>
<option value="px">pixels</option>
</select>
<br />
<div class="fr">Height:</div>
<input style="margin-right: 0.5em;" name="f_size" id="f_size" size="5" type="text" /> <span>pixels</span>
<br />
<div class="fr">Alignment:</div>
<select name="f_align" id="f_align">
<option value="left">Left</option>
<option value="center">Center</option>
<option value="right">Right</option>
</select>
</fieldset>
<fieldset>
<legend>Style</legend>
<div class="fr">Color:</div>
<table cellpadding="2" cellspacing="0" id="hrbtn" class="buttonColor">
<tr>
<td class="chooser" id="hrpv"
onmouseover="document.getElementById('hrbtn').style.borderColor='black'"
onmouseout="document.getElementById('hrbtn').style.borderColor='ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight'"
> </td>
<td class="nocolor" id="hrclr"
onmouseover="document.getElementById('hrclr').style.color='#f00'"
onmouseout="document.getElementById('hrclr').style.color='#000'"
onclick="document.getElementById('f_color').value=''; document.getElementById('hrpv').style.backgroundColor=''">×</td>
</tr>
</table>
<br />
<div class="fr"> </div>
<input type="hidden" name="f_color" id="f_color" />
<input type="checkbox" name="f_noshade" id="f_noshade" value="noshade" />
<span>No shading</span>
<br />
</fieldset>
<div id="buttons">
<button type="submit" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/HorizontalRule/popups/edit_horizontal_rule.html | HTML | art | 4,690 |
.insert-smiley a {
display:block; float:left; margin:2px; border:none !important; text-decoration:none !important;
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/dialog.css | CSS | art | 118 |
[
{ title: 'Grin', src: 'Grin.gif' },
{ title: 'Angry', src: 'Angry.gif' },
{ title: 'Excited', src: 'Excited.gif' },
{ title: 'Cool', src: 'Cool.gif' },
{ title: 'Wink', src: 'Wink.gif' },
{ title: 'Surprised', src: 'Surprised.gif' },
{ title: 'Sad', src: 'Sad.gif' },
{ title: 'Pleased', src: 'Pleased.gif' }
] | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/smileys/smileys.js | JavaScript | art | 386 |
<?php
/** This script can be used to automatically output all smiley images you
* dump into this folder, as long as they are gif, jpg or png.
*
* Simply set your
*
* xinha_config.InsertSmiley.smileys =
* _editor_url+'/plugins/InsertSmiley/smilies.php';
*
* (or better, make a new smileys folder outside of Xinha
* and copy this file to it and change the line above
* appropriately).
*
*/
// You will probably need to change this if you copy this file elsewhere!
require_once(realpath(dirname(__FILE__) . '/../../../contrib/php-xinha.php'));
$dh = opendir(dirname(__FILE__));
$smileys = array();
while($f = readdir($dh))
{
$M = array();
if(preg_match('/^(.*)\.(gif|jpg|png)$/i', $f, $M))
{
$smileys[] = array('title' => $M[1], 'src'=> $f);
}
}
closedir($dh);
echo xinha_to_js($smileys);
?> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/smileys/smileys.php | PHP | art | 899 |
/*---------------------------------------*\
Insert Smiley Plugin for Xinha
-----------------------------------------
original author: Ki Master George (kimastergeorge@gmail.com)
rewritten: James Sleeman (james@gogo.co.nz)
\*---------------------------------------*/
InsertSmiley._pluginInfo = {
name : "InsertSmiley",
version : "2.0",
developer : "V 1.0 Ki Master George, V2.0 James Sleeman",
developer_url : "http://www.gogo.co.nz/",
c_owner : "Ki Master George, James Sleeman",
sponsor : "Gogo Internet Services",
sponsor_url : "http://www.gogo.co.nz/",
license : "htmlArea"
};
/** To configure the InsertSmiley plugin.
*
* Set xinha_config.InsertSmiley.smileys to EITHER
*
* * A URL to a file called smileys.js, which follows the format
* you can view in smileys/smileys.js
*
* * A URL to a file called smileys.php (or whatever other language)
* which outputs a file in the same way as smileys/smileys.php
*
* * A javascript the same as you will find in smileys/smileys.js
*
* By defaut the static smileys/smileys.js file is used, you may
* wish to set this like so
*
* xinha_config.InsertSmiley.smileys = _editor_url+'/plugins/InsertSmiley/smileys/smileys.php';
*
* And then you can add new smileys just by dumping all the images into the
* /xinha/plugins/InsertSmiley/smileys/
* folder and they will automatically be made available.
*
*/
Xinha.Config.prototype.InsertSmiley= {
smileys : ''
};
Xinha.loadStyle('dialog.css', 'InsertSmiley');
function InsertSmiley(editor) {
this.editor = editor;
this.smileys = false;
this.dialog = false;
var cfg = editor.config;
var self = this;
// register the toolbar buttons provided by this plugin
cfg.registerButton({
id : "insertsmiley",
tooltip : this._lc("Insert Smiley"),
image : editor.imgURL("ed_smiley.gif", "InsertSmiley"),
textMode : false,
action : function(editor) {
self.buttonPress(editor);
}
});
cfg.addToolbarElement("insertsmiley", "inserthorizontalrule", 1);
}
InsertSmiley.prototype.onGenerateOnce = function()
{
// Back compat for ray's smiley config in changeset:904 ( ticket:1093 )
if(this.editor.config.InsertSmiley.smileyURL)
{
var smileys = [ ];
var smileylist = Xinha._geturlcontent(Xinha.getPluginDir("InsertSmiley") + '/smileys.txt');
var smileyURL = this.editor.config.InsertSmiley.smileyURL;
smileylist = smileylist.match(/^.+$/mg);
for(var i = 0; i < smileylist.length; i++)
{
smileys[smileys.length] = { title: smileylist[i], src: smileyURL + encodeURIComponent(smileylist[i]) };
}
this.editor.config.InsertSmiley.smileys = smileys;
}
this.loadAssets();
};
InsertSmiley.prototype._lc = function(string) {
return Xinha._lc(string, 'InsertSmiley');
};
/** Load the dialog and js files.
*
*/
InsertSmiley.prototype.loadAssets = function()
{
var self = this;
if (self.loading) return;
if(typeof this.editor.config.InsertSmiley.smileys != 'string')
{
// Must be a smiley definition itself
this.smileys = this.editor.config.InsertSmiley.smileys;
this.smiley_base = _editor_url; // Doesn't make a lot of sense, we assume the smileys will have absolute paths anyway
}
else
{
var smileys_def =
this.editor.config.InsertSmiley.smileys
? this.editor.config.InsertSmiley.smileys // URL to the smileys.js file, or somethign that creates it
: (Xinha.getPluginDir("InsertSmiley") + '/smileys/smileys.js'); // our own default one
Xinha._getback(
smileys_def,
function(sm) { self.smileys = eval(sm); self.smileys_base = smileys_def.replace(/\/[^\/]+(\?.*)?$/, '/'); }
);
}
Xinha._getback( Xinha.getPluginDir("InsertSmiley") + '/dialog.html', function(html) { self.makeDialog(html); } );
}
/** Make the dialog
*
* @note It is really important that this happens throuh the onGenerateOnce event
* (in this case it goes onGenerateOnce -> loadAssets -> makeDialog)
* because otherwise creating the dialog can fail in mysterious ways (silent
* javascript exceptions in Gecko etc).
*/
InsertSmiley.prototype.makeDialog = function(html)
{
var self = this;
// We can not make the dialog until the smileys are loaded, so wait a bit.
if(!this.smileys)
{
window.setTimeout(function() { self.makeDialog(html); }, 1000);
return;
}
var dialog = new Xinha.Dialog(this.editor, html, 'InsertSmiley', {width:155, height:100}, {modal:false});
var src;
var s;
var a;
for(var i = 0; i < this.smileys.length; i++)
{
src = this.smileys[i].src.match(/^(([a-zA-Z]+:\/\/)|\/)/) ?
this.smileys[i].src : this.smileys_base + this.smileys[i].src;
s = document.createElement('img');
s.src = src;
s.alt = dialog._lc(this.smileys[i].title);
s.style.border = 'none';
a = document.createElement('a');
a.href= 'javascript:void(0);';
a.smiley_src = src;
a.title = dialog._lc(this.smileys[i].title);
// This is where we insert the smiley into the HTML
Xinha.addDom0Event(a, 'click', function(ev) { self.editor.insertHTML('<img src="'+this.smiley_src+'" alt="'+this.title+'" />'); Xinha._stopEvent(window.event ? event : ev); return false; });
a.appendChild(s);
dialog.getElementById('smileys').appendChild(a);
a = null; s = null; src = null;
}
this.dialog = dialog;
return true;
}
/** Show the dialog.
*/
InsertSmiley.prototype.buttonPress = function(editor) {
if(this.dialog)
{
this.dialog.show();
}
else
{
// Should put something here!
}
return;
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/InsertSmiley.js | JavaScript | art | 5,956 |
<h1 id="[h1]"><l10n>Insert Smiley</l10n></h1>
<div style="position:relative;" id="[smileys]" class="insert-smiley">
</div> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/dialog.html | HTML | art | 125 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// Author: Maarten Molenschot, maarten@nrgmm.nl
{
"Insert Smiley": "Smiley invoegen",
"Smiley": "Smiley",
"Cancel": "Annuleren"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/nl.js | JavaScript | art | 193 |
// I18N constants
// LANG: "de", ENCODING: UTF-8
{
"Insert Smiley": "Smiley einfügen",
"Smiley": "Smiley",
"Cancel": "Abbrechen"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/de.js | JavaScript | art | 142 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"Insert Smiley": "Insérer un smiley",
"Smiley": "Smiley",
"Cancel": "Annuler"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/fr.js | JavaScript | art | 142 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
{
"Insert Smiley": "スマイリーの挿入",
"Smiley": "スマイリー",
"Cancel": "中止"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/ja.js | JavaScript | art | 149 |
// I18N constants
// LANG: "nb", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"Insert Smiley": "Sett inn smiley",
"Smiley": "Smiley",
"Cancel": "Avbryt"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/nb.js | JavaScript | art | 210 |
// I18N constants
//
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
//
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
//
// Last revision: 06 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"Cancel": "Cancelar",
"Insert Smiley": "Inserir Smiley"
}
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/InsertSmiley/lang/pt_br.js | JavaScript | art | 559 |
// Unormat plugin for Xinha
UnFormat._pluginInfo = {
name : "UnFormat",
version : "1.0",
license : "htmlArea"
};
function UnFormat(editor) {
this.editor = editor;
var cfg = editor.config;
var self = this;
cfg.registerButton({
id : "unformat",
tooltip : Xinha._lc("Page Cleaner",'UnFormat'),
image : editor.imgURL("unformat.gif", "UnFormat"),
textMode : false,
action : function(editor) {
self.show();
}
});
cfg.addToolbarElement("unformat", "killword", 1);
}
UnFormat.prototype.onGenerateOnce = function(editor){
// Load assets
var self = UnFormat;
if (self.loading) return;
self.loading = true;
self.methodsReady = true;
Xinha._getback(Xinha.getPluginDir('UnFormat') + '/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; });
}
UnFormat.prototype.onUpdateToolbar = function(editor){
if (!(UnFormat.dialogReady && UnFormat.methodsReady))
{
this.editor._toolbarObjects.UnFormat.state("enabled", false);
}
else this.onUpdateToolbar = null;
}
UnFormat.prototype.prepareDialog = function(editor){
var self = this;
var editor = this.editor;
var dialog = this.dialog = new Xinha.Dialog(editor, UnFormat.html, 'Xinha',{width:400})
// Connect the OK and Cancel buttons
dialog.getElementById('ok').onclick = function() {self.apply();}
dialog.getElementById('cancel').onclick = function() { self.dialog.hide()};
this.dialogReady = true;
}
UnFormat.prototype.show = function(editor){
if (!this.dialog) this.prepareDialog();
var editor = this.editor;
var values =
{
"cleaning_area" : 'selection',
"formatting" : '',
"html_all" : ''
}
// now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog
this.dialog.show(values);
this.dialog.onresize();
}
UnFormat.prototype.apply = function(editor){
var editor = this.editor;
var doc = editor._doc;
var param = this.dialog.getValues();
// selection is only restored on dialog.hide()
this.dialog.hide();
// assign the given arguments
if (param["cleaning_area"] == "all") {
var html = editor._doc.body.innerHTML;
} else {
var html = editor.getSelectedHTML();
}
if (param.html_all) {
html = html.replace(/<[\!]*?[^<>]*?>/g, "");
}
if (param.formatting) {
html = html.replace(/style="[^"]*"/gi, "");
html = html.replace(/<\/?font[^>]*>/gi,"");
html = html.replace(/<\/?b>/gi,"");
html = html.replace(/<\/?strong[^>]*>/gi,"");
html = html.replace(/<\/?i>/gi,"");
html = html.replace(/<\/?em[^>]*>/gi,"");
html = html.replace(/<\/?u[^>]*>/gi,"");
html = html.replace(/<\/?strike[^>]*>/gi,"");
html = html.replace(/ align=[^\s|>]*/gi,"");
html = html.replace(/ class=[^\s|>]*/gi,"");
}
if (param["cleaning_area"] == "all") {
editor._doc.body.innerHTML = html;
} else {
editor.insertHTML(html);
}
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/UnFormat.js | JavaScript | art | 2,993 |
<h1 id="[h1]"><l10n>Page Cleaner</l10n></h1>
<form action="" method="get" style="padding-top:10px" id="[inputs]">
<fieldset>
<legend><l10n>Cleaning Area</l10n></legend>
<span><l10n>Selection</l10n></span><input type="radio" name="[cleaning_area]" id="[clean_selection]" value="selection" checked="checked" />
<span><l10n>All</l10n></span><input type="radio" name="[cleaning_area]" id="[clean_page]" value="all" />
</fieldset>
<br />
<fieldset>
<legend><l10n>Cleaning options</l10n></legend>
<div class="space"></div>
<div class="fr"><l10n>Formatting:</l10n></div>
<input type="checkbox" name="[formatting]" id="[formatting]" checked value="on" />
<p />
<div class="fr"><l10n>All HTML:</l10n></div>
<input type="checkbox" name="[html_all]" id="[html_all]" value="on" />
<p />
</fieldset>
<br /><br />
<p style="text-align:center"><l10n>Select which types of formatting you would like to remove.</l10n></p>
<div class="buttons" id="[buttons]">
<input type="button" id="[ok]" value="_(OK)" />
<input type="button" id="[cancel]" value="_(Cancel)" />
</div>
</form>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/dialog.html | HTML | art | 1,133 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
{
"Page Cleaner": "Pagina Schoonmaker",
"Cleaning Area": "Schoonmaak gebied",
"Selection": "Geselecteerde tekst",
"All": "Alles",
"Cleaning options": "Schoonmaak opties",
"Formatting:": "Format",
"All HTML:": "Alle html",
"Select which types of formatting you would like to remove." : "Selecteer welke types van Formatteren je wilt verwijderen"
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/nl.js | JavaScript | art | 413 |
// I18N constants
// LANG: "de", ENCODING: UTF-8 | ISO-8859-1
{
"Page Cleaner": "Seite bereinigen",
"Cleaning Area": "Reinigungsbereich",
"Selection": "Ausgewählter Bereich",
"All": "Alles",
"Cleaning options": "Reinigungsoptionen",
"Formatting:": "Formatierung:",
"All HTML:": "Ganzes HTML:",
"Select which types of formatting you would like to remove." : "Wählen Sie aus welche Formatierungen Sie entfernen wollen."
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/de.js | JavaScript | art | 439 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"Page Cleaner": "Nettoyeur de page",
"Cleaning Area": "Zone de nettoyage",
"Selection": "Sélection",
"All": "Tout",
"Cleaning options": "Options de nettoyage",
"Formatting:": "Format",
"All HTML:": "Tout le HTML",
"Select which types of formatting you would like to remove.": "Sélectionnez quel type de formatage vous voulez supprimer."
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/fr.js | JavaScript | art | 408 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
{
"Page Cleaner": "ページクリーナー",
"Cleaning Area": "クリーニング領域",
"Selection": "選択部分",
"All": "すべて",
"Cleaning options": "クリーニングオプション",
"Formatting:": "書式指定タグ:",
"All HTML:": "全HTMLタグ:",
"Select which types of formatting you would like to remove.": "削除する書式を選択してください。"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/ja.js | JavaScript | art | 446 |
// I18N constants
// LANG: "nb", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"Page Cleaner": "Dokumentvasker",
"Cleaning Area": "Vaskeområde",
"Selection": "Markert område",
"All": "Hele dokumentet",
"Cleaning options": "Vaskemetoder",
"Formatting:": "Formattering:",
"All HTML:": "All HTML-kode:",
"Select which types of formatting you would like to remove.": "Velg hva slags formattering du ønsker å fjerne."
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/nb.js | JavaScript | art | 482 |
// I18N constants
//
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
//
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
//
// Last revision: 06 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"All": "Tudo",
"All HTML:": "Todo HTML:",
"Cancel": "Cancelar",
"Cleaning Area": "Limpando Área",
"Cleaning options": "Opções de limpesa",
"Formatting:": "Formatação:",
"OK": "OK",
"Page Cleaner": "Limpesa de página",
"Select which types of formatting you would like to remove.": "Selecione o tipo de formatação que deseja remover.",
"Selection": "Seleção"
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/UnFormat/lang/pt_br.js | JavaScript | art | 885 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// Author: Maarten Molenschot, maarten@nrgmm.nl
{
"Save": "Opslaan",
"Saving...": "Bezig met opslaan...",
"in progress": "bezig met opslaan...",
"Ready": "Klaar"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/nl.js | JavaScript | art | 226 |
// I18N constants
// LANG: "de", ENCODING: UTF-8
{
"Save": "Speichern",
"Saving...": "Speichern...",
"in progress": "in Arbeit",
"Ready": "Fertig"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/de.js | JavaScript | art | 161 |
// I18N constants
// LANG: "ru", ENCODING: UTF-8
// Simple job done by Alexey Kirpichnikov <alexkir at kiwistudio dot ru>
{
"Save": "Сохранить",
"Saving...": "Сохранение...",
"in progress": "пожалуйста, ждите",
"Ready": "Готово"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/ru.js | JavaScript | art | 276 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"Save": "Enregistrer",
"Saving...": "Enregistrement...",
"in progress": "en cours",
"Ready": "Prêt"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/fr.js | JavaScript | art | 166 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
{
"Save": "保存",
"Saving...": "保存中...",
"in progress": "処理中",
"Ready": "レディ"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/ja.js | JavaScript | art | 153 |
// I18N constants
//
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
//
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
//
// Last revision: 06 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt)
{
"Save": "Salvar",
"Saving...": "Gravando...",
"in progress": "em processo",
"Ready": "Pronto"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/lang/pt_br.js | JavaScript | art | 597 |
/*------------------------------------------*\
SaveSubmit for Xinha
____________________
See README.txt for information
\*------------------------------------------*/
function SaveSubmit(editor) {
this.editor = editor;
this.changed = false;
var self = this;
var cfg = editor.config;
this.textarea = this.editor._textArea;
cfg.registerIcon('savesubmitchanged', Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_red.gif");
cfg.registerIcon('savesubmitunchanged', Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_green.gif");
cfg.registerButton({
id : "savesubmit",
tooltip : self._lc("Save"),
image : cfg.iconList.savesubmitunchanged,
textMode : false,
action : function() {
self.save();
}
});
cfg.addToolbarElement("savesubmit", "popupeditor", -1);
}
SaveSubmit.prototype._lc = function(string) {
return Xinha._lc(string, 'SaveSubmit');
}
SaveSubmit._pluginInfo = {
name : "SaveSubmit",
version : "1.0",
developer : "Raimund Meyer",
developer_url : "http://x-webservice.net",
c_owner : "Raimund Meyer",
sponsor : "",
sponsor_url : "",
license : "htmlArea"
}
SaveSubmit.prototype.onKeyPress = function(ev) {
if ( ev.ctrlKey && this.editor.getKey(ev) == 's') {
this.save(this.editor);
Xinha._stopEvent(ev);
return true;
}
else {
if (!this.changed) {
if (this.getChanged()) this.setChanged();
return false;
}
}
}
SaveSubmit.prototype.onExecCommand = function (cmd) {
if (this.changed && cmd == 'undo') {
if (this.initial_html == this.editor.getInnerHTML()) this.setUnChanged();
return false;
}
}
SaveSubmit.prototype.onUpdateToolbar = function () {
if (!this.initial_html) this.initial_html = this.editor.getInnerHTML();
if (!this.changed) {
if (this.getChanged()) this.setChanged();
return false;
}
}
SaveSubmit.prototype.getChanged = function() {
if (this.initial_html === null) this.initial_html = this.editor.getInnerHTML();
if (this.initial_html != this.editor.getInnerHTML() && this.changed == false) {
this.changed = true;
return true;
}
else return false;
}
SaveSubmit.prototype.setChanged = function() {
this.editor._toolbarObjects.savesubmit.swapImage(this.editor.config.iconList.savesubmitchanged);
this.editor.updateToolbar();
}
SaveSubmit.prototype.setUnChanged = function() {
this.changed = false;
this.editor._toolbarObjects.savesubmit.swapImage(this.editor.config.iconList.savesubmitunchanged);
}
SaveSubmit.prototype.changedReset = function() {
this.initial_html = null;
this.setUnChanged();
}
SaveSubmit.prototype.save = function() {
this.buildMessage();
var editor = this.editor;
var self =this;
var form = editor._textArea.form;
form.onsubmit();
var name, value, content ='';
for (var i=0;i<form.elements.length;i++)
{
if (( form.elements[i].type == 'checkbox' || form.elements[i].type == 'radio' ) && !form.elements[i].checked ) continue;
content += ((i>0) ? '&' : '') + form.elements[i].name + '=' + encodeURIComponent(form.elements[i].value);
}
var url = editor._textArea.form.action || window.location.href;
Xinha._postback(url, content, function(getback) {
if (getback) {
self.setMessage(getback);
//self.setMessage(self._lc("Ready"));
self.changedReset();
}
removeMessage = function() { self.removeMessage()} ;
window.setTimeout("removeMessage()",1000);
});
}
SaveSubmit.prototype.setMessage = function(string) {
var textarea = this.textarea;
if ( !document.getElementById("message_sub_" + textarea.id)) { return ; }
var elt = document.getElementById("message_sub_" + textarea.id);
elt.innerHTML = Xinha._lc(string, 'SaveSubmit');
}
SaveSubmit.prototype.removeMessage = function() {
var textarea = this.textarea;
if (!document.getElementById("message_" + textarea.id)) { return ; }
document.body.removeChild(document.getElementById("message_" + textarea.id));
}
//ripped mokhet's loading message function
SaveSubmit.prototype.buildMessage = function() {
var textarea = this.textarea;
var htmlarea = this.editor._htmlArea;
var loading_message = document.createElement("div");
loading_message.id = "message_" + textarea.id;
loading_message.className = "loading";
loading_message.style.width = htmlarea.offsetWidth +'px' ;//(this.editor._iframe.offsetWidth != 0) ? this.editor._iframe.offsetWidth +'px' : this.editor._initial_ta_size.w;
loading_message.style.left = Xinha.findPosX(htmlarea) + 'px';
loading_message.style.top = (Xinha.findPosY(htmlarea) + parseInt(htmlarea.offsetHeight) / 2) - 50 + 'px';
var loading_main = document.createElement("div");
loading_main.className = "loading_main";
loading_main.id = "loading_main_" + textarea.id;
loading_main.appendChild(document.createTextNode(this._lc("Saving...")));
var loading_sub = document.createElement("div");
loading_sub.className = "loading_sub";
loading_sub.id = "message_sub_" + textarea.id;
loading_sub.appendChild(document.createTextNode(this._lc("in progress")));
loading_message.appendChild(loading_main);
loading_message.appendChild(loading_sub);
document.body.appendChild(loading_message);
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SaveSubmit/SaveSubmit.js | JavaScript | art | 5,122 |
/**
* An input field Image Picker utilising the Xinha ImageManager.
*
* Hijack the Xinha ImageManager plugin to provide an image URL picker
* for any form input field in the form of a "Browse" button to the
* right of the field, in the same manner as a file type input field
* except it opens the familiar ImageManager dialog to upload/select/edit
* an image and returns the URL of the image to the field's value.
*
* Example Usage:
*
* <script type="text/javascript">_editor_url = '/url/to/xinha';</script>
* <script type="text/javascript" src="image-picker.js" />
* <script type="text/javascript">
* <?php require_once('/path/to/xinha/contrib/php-xinha.php'); ?>
* with(ImagePicker.prototype)
* {
* <?php
* $Conf = array
* (
* 'images_dir' => '/path/to/images',
* 'images_url' => '/url/to/images',
* 'show_full_options' => false, // Full options are not useful as a URL picker
* // See ImageManager for more configuration options !
* );
* xinha_pass_to_php_backend($Conf);
* ?>
* }
*
* window.onload = function() { new ImagePicker(document.getElementById('idOfTheInputField')); }
* </script>
*
*
* @author $Author$
* @version $Id$
* @package ImageManager
*/
function ImagePicker(field)
{
this.field = field;
var picker = this;
var but = document.createElement('input');
but.type = 'button';
but.value = 'Browse';
but.onclick = function() { picker.popup_picker(); }
field.parentNode.insertBefore(but,field.nextSibling);
field.size = '20';
field.style.textAlign = 'right';
};
ImagePicker.prototype.backend = Xinha.getPluginDir('ImageManager') + '/backend.php?__plugin=ImageManager&';
ImagePicker.prototype.backend_data = null;
ImagePicker.prototype.append_query_string = true;
ImagePicker.prototype.popup_picker = function()
{
var picker = this; // closure for later
var outparam = null;
if(picker.field.value)
{
outparam =
{
f_url : picker.field.value,
f_width : null,
f_height : null,
// None of this stuff is useful to us, we return only a URL.
f_alt : picker.field.value,
f_border : null,
f_align : null,
f_padding: null,
f_margin : null,
f_backgroundColor: null,
f_borderColor: null,
f_border : null,
f_padding: null,
f_margin: null
};
while(outparam.f_url.match(/[?&]((f_[a-z0-9]+)=([^&#]+))/i))
{
outparam[RegExp.$2] = decodeURIComponent(RegExp.$3);
outparam.f_url = outparam.f_url.replace(RegExp.$1, '');
}
outparam.f_url = outparam.f_url.replace(/&{2,}/g, '&');
outparam.f_url = outparam.f_url.replace(/\?&*(#.*)?$/, '');
}
var manager = this.backend + '__function=manager';
if(this.backend_config != null)
{
manager += '&backend_config='
+ encodeURIComponent(this.backend_config);
manager += '&backend_config_hash='
+ encodeURIComponent(this.backend_config_hash);
manager += '&backend_config_secret_key_location='
+ encodeURIComponent(this.backend_config_secret_key_location);
}
if(this.backend_data != null)
{
for ( var i in this.backend_data )
{
manager += '&' + i + '=' + encodeURIComponent(this.backend_data[i]);
}
}
Dialog(manager, function(param) {
if (!param) { // user must have pressed Cancel
return false;
}
picker.field.value = param.f_url;
if(picker.append_query_string)
{
if(picker.field.value.match(/[?&](.*)$/))
{
if(RegExp.$1.length)
{
picker.field.value += '&';
}
}
else
{
picker.field.value += '?';
}
for(var i in param)
{
if(i == 'f_url' || param[i] == null || param[i] == 'null' || param[i] == '') continue;
if(typeof param[i] == 'function') continue;
if(param[i].length = 0) continue;
picker.field.value += i + '=' + encodeURIComponent(param[i]) + '&';
}
}
}, outparam);
}
// Dialog is part of Xinha, but we'll provide it here incase Xinha's not being
// loaded.
if(typeof Dialog == 'undefined')
{
// htmlArea v3.0 - Copyright (c) 2003-2004 interactivetools.com, inc.
// This copyright notice MUST stay intact for use (see license.txt).
//
// Portions (c) dynarch.com, 2003-2004
//
// A free WYSIWYG editor replacement for <textarea> fields.
// For full source code and docs, visit http://www.interactivetools.com/
//
// Version 3.0 developed by Mihai Bazon.
// http://dynarch.com/mishoo
//
// $Id: dialog.js 183 2005-05-20 06:11:44Z gogo $
// Though "Dialog" looks like an object, it isn't really an object. Instead
// it's just namespace for protecting global symbols.
function Dialog(url, action, init) {
if (typeof init == "undefined") {
init = window; // pass this window object by default
}
var dlg = window.open(url, "hadialog",
"toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
"scrollbars=yes,resizable=yes,modal=yes,dependable=yes");
Dialog._modal = dlg;
Dialog._arguments = init;
// make up a function to be called when the Dialog ends.
Dialog._return = function (val)
{
if (val && action) {
action(val);
}
Dialog._modal = null;
};
Dialog._modal.focus();
};
// should be a function, the return handler of the currently opened dialog.
Dialog._return = null;
// constant, the currently opened dialog
Dialog._modal = null;
// the dialog will read it's args from this variable
Dialog._arguments = null;
}
// Deprecated method for passing config, use above instead!
//---------------------------------------------------------
ImagePicker.prototype.backend_config = null;
ImagePicker.prototype.backend_config_hash = null;
ImagePicker.prototype.backend_config_secret_key_location = 'Xinha:ImageManager';
//---------------------------------------------------------
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/image-picker.js | JavaScript | art | 6,092 |
<?php
/**
* Show a list of images in a long horizontal table.
* @author $Author: gogo $
* @version $Id: images.php 877 2007-08-12 15:50:03Z gogo $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('ddt.php');
require_once('Classes/ImageManager.php');
// Compatability for PHP lt 5.2
require_once('Classes/JSON_Compat.php');
// Search for youtube videos
// ?vq=funny+dogs&start-index=20&max-results=15
$youtube = "http://gdata.youtube.com/feeds/api/videos?max-results=50&format=5&alt=json&";
if(@$_REQUEST['ytSearch'])
{
$youtube .= 'vq='.rawurlencode($_REQUEST['ytSearch']) .'&';
}
if(@$_REQUEST['ytUsername'])
{
$youtube .= 'author='.rawurlencode($_REQUEST['ytUsername']);
}
$feed = file_get_contents($youtube);
$data = json_decode($feed, true);
$numRows = $data['feed']['openSearch$totalResults']['$t'];
$firstRow = $data['feed']['openSearch$startIndex']['$t'];
$perPage = $data['feed']['openSearch$itemsPerPage']['$t'];
$lastRow = $startRow-1+$perPage;
$records = $data['feed']['entry'];
//default path is /
$relative = '/';
$manager = new ImageManager($IMConfig);
/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
function format_duration($duration)
{
$hours = floor($duration / (60 * 60));
$duration = $duration - ($hours * 60 * 60);
$minutes = floor($duration / 60);
$duration = $duration - ($minutes * 60);
$seconds = $duration;
if($hours)
{
return $hours . '.' . floor(($minutes/60) * 100) . " hr" . ($minutes ? "s" : '');
}
if($minutes)
{
return $minutes . ' min' . ($minutes > 1 ? 's' : '');
}
return $seconds . ' sec' . ($seconds > 1 ? 's' : '');
}
function rip_youtube_data($record)
{
$media = $record['media$group'];
$title = $media['media$title']['$t'];
$description = substr($media['media$description']['$t'],0,100);
$duration = $media['yt$duration']['seconds'];
$thumbs = array(); // w:h => array( file, file, file)
$largest = array(0,'', 0, 0);
$smallest = array(3000*3000,'', 3000, 3000); // Ok, hacky, sosumi
foreach($media['media$thumbnail'] as $thumb)
{
if(!isset($thumbs["{$thumb['width']}x{$thumb['height']}"]))
{
$thumbs["{$thumb['width']}x{$thumb['height']}"] = array();
if(($thumb['width'] * $thumb['height']) > $largest[0])
$largest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'] , $thumb['height']);
if(($thumb['width'] * $thumb['height']) < $smallest[0])
$smallest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'] , $thumb['height']);
}
$thumbs["{$thumb['width']}x{$thumb['height']}"][$thumb['time']] = $thumb['url'];
}
// Find the main image link
$mainImage = $thumbs[$largest[1]];
$mainImage = array_pop($mainImage);
// Find the thumb image link
$thumbImage = $thumbs[$smallest[1]];
$thumbImage = array_pop($thumbImage);
$embed = NULL;
foreach($media['media$content'] as $vid)
{
if($vid['type'] == 'application/x-shockwave-flash')
{
$embed = $vid['url'];
break;
}
}
// Final image to pass to manager (use query param to record the embed url)
$combinedImage = $mainImage .
'?x-shockwave-flash='.rawurlencode($embed).
'&x-tn='.rawurlencode($thumbImage);
return array
(
'title' => $title,
'description' => $description,
'duration' => format_duration($duration),
'mainImage' => $mainImage,
'thumbImage' => $thumbImage,
'combinedImage' => $combinedImage,
'smallest' => $smallest,
'largest' => $largest,
'thumbs' => $thumbs,
'embed' => $embed,
);
}
function drawFiles($list, &$manager)
{
global $relative;
global $IMConfig;
//$IMConfig['ViewMode'] = 'thumbs';
switch($IMConfig['ViewMode'])
{
case 'details':
{
?>
<script language="Javascript">
<!--
function showPreview(f_url)
{
window.parent.document.getElementById('f_preview').src = window.parent._backend_url + '__function=thumbs&img=' + encodeURIComponent(f_url);
}
//-->
</script>
<table class="listview">
<thead>
<tr><th>Title</th><th>Description</th><th>Duration</th></tr></thead>
<tbody>
<?php
foreach($list as $record)
{
extract(rip_youtube_data($record));
?>
<tr>
<th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo xinha_js_encode($combinedImage)?>', '<?php echo xinha_js_encode($title); ?>', <?php echo $largest[2];?>, <?php echo $largest[3]; ?>);return false;" title="<?php echo htmlspecialchars($title); ?> - <?php echo htmlspecialchars($duration); ?>" onmouseover="showPreview('<?php echo xinha_js_encode($combinedImage);?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" ><?php echo htmlspecialchars($title) ?></a></th>
<td><?php echo htmlspecialchars($description); ?></td>
<td><?php echo htmlspecialchars($duration); ?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
break;
case 'thumbs':
default :
{
foreach($list as $record)
{
extract(rip_youtube_data($record));
?>
<div class="thumb_holder" id="holder_<?php echo asc2hex($combinedImage) ?>">
<a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo xinha_js_encode($combinedImage)?>', '<?php echo xinha_js_encode($title); ?>', <?php echo $largest[2];?>, <?php echo $largest[3]; ?>);return false;" title="<?php echo htmlspecialchars($title); ?> - <?php echo htmlspecialchars($duration); ?>">
<img src="<?php print $thumbImage ?>" alt="<?php echo $title; ?> - <?php echo htmlspecialchars($duration); ?>"/>
</a>
</div>
<?php
}
}
}
}//function drawFiles
/**
* No directories and no files.
*/
function drawNoResults()
{
?>
<div class="noResult">No Videos Found</div>
<?php
}
/**
* No directories and no files.
*/
function drawErrorBase(&$manager)
{
?>
<div class="error"><span>Invalid base directory:</span> <?php echo $manager->config['images_dir']; ?></div>
<?php
}
/**
* Utility to convert ascii string to hex
*/
function asc2hex ($temp)
{
$len = strlen($temp);
$data = "";
for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1)));
return $data;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>YouTube Video List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
if(window.top)
HTMLArea = Xinha = window.top.Xinha;
function hideMessage()
{
var topDoc = window.top.document;
var messages = topDoc.getElementById('messages');
if(messages)
messages.style.display = "none";
}
init = function()
{
__dlg_translate('ImageManager');
hideMessage();
var topDoc = window.top.document;
// update_selected();
}
/*]]>*/
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
<script type="text/javascript" src="../../popups/popup.js"></script>
<script type="text/javascript" src="assets/popup.js"></script>
<style type="text/css">
.dir_holder, .thumb_holder
{
width:140px; height:110px;
float:left;
margin:6px;
background-color:ButtonFace;
border: 1px outset;
}
</style>
</head>
<body>
<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
elseif(count($records)) { ?>
<?php drawFiles($records, $manager); ?>
<?php } else { drawNoResults(); } ?>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/youtube.php | PHP | art | 8,419 |
<?php
/**
* The frame that contains the image to be edited.
* @author $Author:ray $
* @version $Id:editorFrame.php 677 2007-01-19 22:24:36Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/ImageEditor.php');
$manager = new ImageManager($IMConfig);
$editor = new ImageEditor($manager);
$imageInfo = $editor->processImage();
?>
<html>
<head>
<title></title>
<script type="text/javascript">
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
</script>
<link href="<?php print $IMConfig['base_url'];?>assets/editorFrame.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/wz_jsgraphics.js"></script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/EditorContent.js"></script>
<script type="text/javascript">
if(window.top)
HTMLArea = window.top.HTMLArea;
function i18n(str) {
return HTMLArea._lc(str, 'ImageManager');
}
var mode = "<?php echo $editor->getAction(); ?>" //crop, scale, measure
var currentImageFile = "<?php if(count($imageInfo)>0) echo rawurlencode($imageInfo['file']); ?>";
<?php if ($editor->isFileSaved() == 1) { ?>
alert(i18n('File saved.'));
window.parent.opener.selectImage
(
'<?php echo $imageInfo['savedFile'] ?>',
'<?php echo $imageInfo['savedFile'] ?>'.replace(/^.*\/?([^\/]*)$/, '$1'),
<?php echo $imageInfo['width'] ?>,
<?php echo $imageInfo['height'] ?>
);
window.parent.opener.parent.refresh();
window.parent.close();
<?php } else if ($editor->isFileSaved() == -1) { ?>
alert(i18n('File was not saved.'));
<?php } ?>
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/editorFrame.js"></script>
</head>
<body>
<div id="status"></div>
<div id="ant" class="selection" style="visibility:hidden"><img src="<?php print $IMConfig['base_url'];?>img/spacer.gif" width="0" height="0" border="0" alt="" id="cropContent"></div>
<?php if ($editor->isGDEditable() == -1) { ?>
<div style="text-align:center; padding:10px;"><span class="error">GIF format is not supported, image editing not supported.</span></div>
<?php } ?>
<table height="100%" width="100%">
<tr>
<td>
<?php if(count($imageInfo) > 0 && is_file($imageInfo['fullpath'])) { ?>
<span id="imgCanvas" class="crop"><img src="<?php echo $imageInfo['src']; ?>" <?php echo $imageInfo['dimensions']; ?> alt="" id="theImage" name="theImage"></span>
<?php } else { ?>
<span class="error">No Image Available</span>
<?php } ?>
</td>
</tr>
</table>
</body>
</html> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/editorFrame.php | PHP | art | 2,627 |
<?php
/**
* On the fly Thumbnail generation.
* Creates thumbnails given by thumbs.php?img=/relative/path/to/image.jpg
* relative to the base_dir given in config.inc.php
* @author $Author:ray $
* @version $Id:thumbs.php 677 2007-01-19 22:24:36Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/Thumbnail.php');
//check for img parameter in the url
if(!isset($_GET['img']))
{
exit();
}
$manager = new ImageManager($IMConfig);
//get the image and the full path to the image
$image = rawurldecode($_GET['img']);
// If the image is a URL, see if there is an x-thumbnail x-thumb or x-tn param on it
// probably best to use x-tn to save space on the URL
if(preg_match('/^[a-z]+:\/\/.*[?&]x-(thumbnail|thumb|tn)=([^&]+)/i', $image, $Matches))
{
// In which case, we will use the thumbnail
header('location: ' . rawurldecode($Matches[2]));
exit;
}
$fullpath = Files::makeFile($manager->getImagesDir(),$image);
//not a file, so exit
if(!is_file($fullpath))
{
exit();
}
$imgInfo = @getImageSize($fullpath);
//Not an image, send default thumbnail
if(!is_array($imgInfo))
{
//show the default image, otherwise we quit!
$default = $manager->getDefaultThumb();
if($default)
{
header('Location: '.$default);
exit();
}
}
//if the image is less than the thumbnail dimensions
//send the original image as thumbnail
if ($imgInfo[0] <= $IMConfig['thumbnail_width']
&& $imgInfo[1] <= $IMConfig['thumbnail_height'])
{
header('Location: '. $manager->getFileURL($image));
exit();
}
//Check for thumbnails
$thumbnail = $manager->getThumbName($fullpath);
if(is_file($thumbnail))
{
//if the thumbnail is newer, send it
if(filemtime($thumbnail) >= filemtime($fullpath))
{
header('Location: '.$manager->getThumbURL($image));
exit();
}
}
//creating thumbnails
$thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
$thumbnailer->createThumbnail($fullpath, $thumbnail);
//Check for NEW thumbnails
if(is_file($thumbnail))
{
//send the new thumbnail
header('Location: '.$manager->getThumbURL($image));
exit();
}
else
{
//show the default image, otherwise we quit!
$default = $manager->getDefaultThumb();
if($default)
header('Location: '.$default);
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/thumbs.php | PHP | art | 2,303 |
<?php
/**
* Show a list of images in a long horizontal table.
* @author $Author: gogo $
* @version $Id: images.php 877 2007-08-12 15:50:03Z gogo $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/Flickr.php');
// Search for youtube videos
$opts = array(
'per_page'=> 20,
'sort' => 'relevance',
'extras' => 'license,owner_name,tags',
'license' => @$_REQUEST['flkLicense'] ? $_REQUEST['flkLicense'] : flickr_get_default_usage_id(),
);
if(@$_REQUEST['flkSearch'])
{
$opts['text'] = $_REQUEST['flkSearch'];
}
if(@$_REQUEST['flkUsername'])
{
$user_id = flickr_get_user_id($_REQUEST['flkUsername']);
if($user_id)
{
$opts['user_id'] = $user_id;
}
}
$data = flickr_request('flickr.photos.search', $opts);
$records = $data['photos']['photo'];
// For future purposes, we may want an image manager
$relative = '/';
$manager = new ImageManager($IMConfig);
/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
function rip_flickr_data($record)
{
$lics = flickr_get_licenses();
// echo '<pre>'; print_r($lics); die();
$title = $record['title'];
$license = $lics[$record['license']];
// echo '<pre>';print_r($license); die();
$description = '';
$sizes = flickr_request('flickr.photos.getSizes', array('photo_id' => $record['id']));
$sizes = $sizes['sizes'];
$thumbs = array(); // w:h => array( file, file, file)
$largest = array(0,'', 0, 0);
$smallest = array(3000*3000,'', 3000, 3000); // Ok, hacky, sosumi
foreach($sizes['size'] as $thumb)
{
if($thumb['label'] == 'Square') continue; // These are a little smaller than default
if(!isset($thumbs["{$thumb['width']}x{$thumb['height']}"]))
{
$thumbs["{$thumb['width']}x{$thumb['height']}"] = array();
if(($thumb['width'] * $thumb['height']) > $largest[0])
$largest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'] , $thumb['height']);
if(($thumb['width'] * $thumb['height']) < $smallest[0])
$smallest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'] , $thumb['height']);
}
$thumbs["{$thumb['width']}x{$thumb['height']}"][] = $thumb;
}
// Find the main image link
$mainImage = $thumbs[$largest[1]];
$mainImage = array_pop($mainImage);
// Find the thumb image link
$thumbImage = $thumbs[$smallest[1]];
$thumbImage = array_pop($thumbImage);
// Final image to pass to manager (use query param to record the embed url)
$combinedImage = $mainImage['source'] .
'?x-flickr-photo='.rawurlencode($record['id']) .
'&x-lic='.rawurlencode($license['x-id']) .
'&x-uid='.rawurlencode($record['owner']) .
'&x-by='.rawurlencode($record['ownername']) .
'&x-tn='.rawurlencode($thumbImage['source']);
return array
(
'title' => $title,
'description' => $description,
'dimensions' => "{$mainImage['width']}x{$mainImage['height']}",
'license' => $license,
'mainImage' => $mainImage['source'],
'thumbImage' => $thumbImage['source'],
'combinedImage' => $combinedImage,
'smallest' => $smallest,
'largest' => $largest,
'thumbs' => $thumbs,
);
}
function drawFiles($list, &$manager)
{
global $relative;
global $IMConfig;
$IMConfig['ViewMode'] = 'thumbs';
switch($IMConfig['ViewMode'])
{
case 'details':
{
?>
<script language="Javascript">
<!--
function showPreview(f_url)
{
window.parent.document.getElementById('f_preview').src = window.parent._backend_url + '__function=thumbs&img=' + encodeURIComponent(f_url);
}
//-->
</script>
<table class="listview">
<thead>
<tr><th>Title</th><th>Description</th><th>Dimensions</th></tr></thead>
<tbody>
<?php
foreach($list as $record)
{
extract(rip_flickr_data($record));
?>
<tr>
<th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo xinha_js_encode($combinedImage)?>', '<?php echo xinha_js_encode($title); ?>', <?php echo $largest[2];?>, <?php echo $largest[3]; ?>);return false;" title="<?php echo htmlspecialchars($title); ?> - <?php echo htmlspecialchars($dimensions); ?>" onmouseover="showPreview('<?php echo xinha_js_encode($combinedImage);?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" ><?php echo htmlspecialchars($title) ?></a></th>
<td><?php echo htmlspecialchars($description); ?></td>
<td><?php echo htmlspecialchars($dimensions); ?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
break;
case 'thumbs':
default :
{
foreach($list as $record)
{
extract(rip_flickr_data($record));
?>
<div class="thumb_holder" id="holder_<?php echo asc2hex($combinedImage) ?>">
<a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo xinha_js_encode($combinedImage)?>', '<?php echo xinha_js_encode($title); ?>', <?php echo $largest[2];?>, <?php echo $largest[3]; ?>);return false;" title="<?php echo htmlspecialchars($title); ?> - <?php echo htmlspecialchars($dimensions); ?>">
<img src="<?php print $thumbImage ?>" alt="<?php echo $title; ?> - <?php echo htmlspecialchars($dimensions); ?>"/>
</a>
<div class="flk-license"><a href="<?php echo $license['url'] ?>" target="_blank"><?php echo htmlspecialchars($license['name']) ?></a></div>
</div>
<?php
}
}
}
}//function drawFiles
/**
* No directories and no files.
*/
function drawNoResults()
{
?>
<div class="noResult">No Photos Found</div>
<?php
}
/**
* No directories and no files.
*/
function drawErrorBase(&$manager)
{
?>
<div class="error"><span>Invalid base directory:</span> <?php echo $manager->config['images_dir']; ?></div>
<?php
}
/**
* Utility to convert ascii string to hex
*/
function asc2hex ($temp)
{
$len = strlen($temp);
$data = "";
for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1)));
return $data;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Flickr Picture List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
if(window.top)
HTMLArea = Xinha = window.top.Xinha;
function hideMessage()
{
var topDoc = window.top.document;
var messages = topDoc.getElementById('messages');
if(messages)
messages.style.display = "none";
}
init = function()
{
__dlg_translate('ImageManager');
hideMessage();
var topDoc = window.top.document;
// update_selected();
}
/*]]>*/
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
<script type="text/javascript" src="../../popups/popup.js"></script>
<script type="text/javascript" src="assets/popup.js"></script>
</head>
<body class="flickr">
<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
elseif(count($records)) { ?>
<?php drawFiles($records, $manager); ?>
<?php } else { drawNoResults(); } ?>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/flickr.php | PHP | art | 8,126 |
<?php
/**
* Unified backend for ImageManager
*
* Image Manager was originally developed by:
* Xiang Wei Zhuo, email: xiangweizhuo(at)hotmail.com Wei Shou.
*
* Unified backend sponsored by DTLink Software, http://www.dtlink.com
* Implementation by Yermo Lamers, http://www.formvista.com
*
* (c) DTLink, LLC 2005.
* Distributed under the same terms as HTMLArea itself.
* This notice MUST stay intact for use (see license.txt).
*
* DESCRIPTION:
*
* Instead of using separate URL's for each function, ImageManager now
* routes all requests to the server through this single, replaceable,
* entry point. backend.php expects at least two URL variable parameters:
*
* __plugin=ImageManager for future expansion; identify the plugin being requested.
* __function=thumbs|images|editorFrame|editor|manager function being called.
*
* Having a single entry point that strictly adheres to a defined interface will
* make the backend code much easier to maintain and expand. It will make it easier
* on integrators, not to mention it'll make it easier to have separate
* implementations of the backend in different languages (Perl, Python, ASP, etc.)
*
* @see config.inc.php
*/
// Strip slashes if MQGPC is on
set_magic_quotes_runtime(0);
if(get_magic_quotes_gpc())
{
$to_clean = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
while(count($to_clean))
{
$cleaning =& $to_clean[array_pop($junk = array_keys($to_clean))];
unset($to_clean[array_pop($junk = array_keys($to_clean))]);
foreach(array_keys($cleaning) as $k)
{
if(is_array($cleaning[$k]))
{
$to_clean[] =& $cleaning[$k];
}
else
{
$cleaning[$k] = stripslashes($cleaning[$k]);
}
}
}
}
/**
* ImageManager configuration
*/
require_once('config.inc.php');
/**
* debug message library
*/
include_once( "ddt.php" );
// uncomment to turn on debugging
// _ddtOn();
_ddt( __FILE__, __LINE__, "backend.php: top with query '" . $_SERVER["PHP_SELF"] . "' string '" . $_SERVER["QUERY_STRING"] . "'" );
$formVars = empty($_POST) ? $_GET : $_POST;
// make sure the request is for us (this gives us the ability to eventually organize
// a backend event handler system) For an include file the return doesn't make alot of
// sense but eventually we'll want to turn all of this into at least functions
// separating out all the presentation HTML from the logic. (Right now all the HTML
// used by ImageManager is in the same files as the PHP code ...)
if ( @$formVars[ "__plugin" ] != "ImageManager" )
{
// not for us.
_ddt( __FILE__, __LINE__, "request was not for us" );
return true;
}
// so we don't have to re-engineer the entire thing right now, since it's probably
// going to get rewritten anyway, we just include the correct file based on the
// function request.
_ddt( __FILE__, __LINE__, "backend.php(): handling function '" . $formVars[ "__function" ] . "' base_dir is '" . $IMConfig["base_dir"] . "'" );
switch ( @$formVars[ "__function" ] )
{
case "editor":
include_once( $IMConfig['base_dir'] . "/editor.php" );
exit();
break;
case "editorFrame":
include_once( $IMConfig['base_dir'] . "/editorFrame.php" );
exit();
break;
case "manager":
_ddt( __FILE__, __LINE__, "including '" . $IMConfig['base_dir'] . "/manager.php" );
include_once( $IMConfig['base_dir'] . "/manager.php" );
exit();
break;
case "images":
include_once( $IMConfig['base_dir'] . "/images.php" );
exit();
break;
case "thumbs":
include_once( $IMConfig['base_dir'] . "/thumbs.php" );
exit();
break;
case "resizer":
include_once( $IMConfig['base_dir'] . "/resizer.php" );
exit();
break;
case "youtube":
include_once( $IMConfig['base_dir'] . "/youtube.php" );
exit();
break;
case "flickr":
include_once( $IMConfig['base_dir'] . "/flickr.php" );
exit();
break;
default:
_ddt( __FILE__, __LINE__, "function request not supported" );
_error( __FILE__, __LINE__, "function request not supported" );
break;
} // end of switch.
return false ;
// END
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/backend.php | PHP | art | 4,080 |
<?php
/**
* Image Manager configuration file.
* @author $Author:gogo $
* @version $Id:config.inc.php 830 2007-05-09 13:27:34Z gogo $
* @package ImageManager
*
* @todo change all these config values to defines()
*/
// REVISION HISTORY:
//
// 2005-03-20 Yermo Lamers (www.formvista.com):
// . unified backend.
// . created a set of defaults that make sense for bundling with Xinha.
// -------------------------------------------------------------------------
/**
* Default backend URL
*
* URL to use for unified backend.
*
* The ?__plugin=ImageManager& is required.
*/
$IMConfig['backend_url'] = "backend.php?__plugin=ImageManager&";
/**
* Backend Installation Directory
*
* location of backend install; these are used to link to css and js
* assets because we may have the front end installed in a different
* directory than the backend. (i.e. nothing assumes that the frontend
* and the backend are in the same directory)
*/
$IMConfig['base_dir'] = getcwd();
$IMConfig['base_url'] = '';
// ------------------------------------------------------------
/**
* Path to directory containing images.
*
* File system path to the directory you want to manage the images
* for multiple user systems, set it dynamically.
*
* NOTE: This directory requires write access by PHP. That is,
* PHP must be able to create files in this directory.
* Able to create directories is nice, but not necessary.
*
* CHANGE THIS: for out-of-the-box demo purposes we're setting this to ./demo_images
* which has some graphics in it.
*/
// $IMConfig['images_dir'] = "/some/path/to/images/directory;
$IMConfig['images_dir'] = "demo_images";
// -------------------------------------------------------------------------
/**
* URL of directory containing images.
*
* The URL to the above path, the web browser needs to be able to see it.
* It can be protected via .htaccess on apache or directory permissions on IIS,
* check you web server documentation for futher information on directory protection
* If this directory needs to be publicly accessiable, remove scripting capabilities
* for this directory (i.e. disable PHP, Perl, CGI). We only want to store assets
* in this directory and its subdirectories.
*
* CHANGE THIS: You need to change this to match the url where you have Xinha
* installed. If the images show up blank chances are this is not set correctly.
*/
// $IMConfig['images_url'] = "/url/to/above";
// try to figure out the URL of the sample images directory. For your installation
// you will probably want to keep images in another directory.
$IMConfig['images_url'] = str_replace( "backend.php", "", $_SERVER["PHP_SELF"] ) . "demo_images";
// -------------------------------------------------------------------------
/**
* PHP Safe Mode?
*
* Possible values: true, false
*
* TRUE - If PHP on the web server is in safe mode, set this to true.
* SAFE MODE restrictions: directory creation will not be possible,
* only the GD library can be used, other libraries require
* Safe Mode to be off.
*
* FALSE - Set to false if PHP on the web server is not in safe mode.
*/
$IMConfig['safe_mode'] = false;
// -------------------------------------------------------------------------
/**
* Image Library to use.
*
* Possible values: 'GD', 'IM', or 'NetPBM'
*
* The image manipulation library to use, either GD or ImageMagick or NetPBM.
* If you have safe mode ON, or don't have the binaries to other packages,
* your choice is 'GD' only. Other packages require Safe Mode to be off.
*
* DEFAULT: GD is probably the most likely to be available.
*/
$IMConfig['IMAGE_CLASS'] = 'GD';
// -------------------------------------------------------------------------
/**
* NetPBM or IM binary path.
*
* After defining which library to use, if it is NetPBM or IM, you need to
* specify where the binary for the selected library are. And of course
* your server and PHP must be able to execute them (i.e. safe mode is OFF).
* GD does not require the following definition.
*/
$IMConfig['IMAGE_TRANSFORM_LIB_PATH'] ='/usr/bin/';
// For windows, something like
// C:/"Program Files"/ImageMagick-5.5.7-Q16/
// -------------------------------------------------------------------------
// OPTIONAL SETTINGS
// -------------------------------------------------------------------------
/**
* Thumbnail prefix
*
* The prefix for thumbnail files, something like .thumb will do. The
* thumbnails files will be named as "prefix_imagefile.ext", that is,
* prefix + orginal filename.
*/
$IMConfig['thumbnail_prefix'] = '.';
// -------------------------------------------------------------------------
/**
* Thumbnail Directory
*
* Thumbnail can also be stored in a directory, this directory
* will be created by PHP. If PHP is in safe mode, this parameter
* is ignored, you can not create directories.
*
* If you do not want to store thumbnails in a directory, set this
* to false or empty string '';
*/
$IMConfig['thumbnail_dir'] = '.thumbs';
// -------------------------------------------------------------------------
/**
* Resize files, or not. If the dimensions for an image are changed
* this will control if the image is actually resized.
*
* Usually you want this true, unless you are very disk space concious.
*/
$IMConfig['resize_files'] = true;
// -------------------------------------------------------------------------
/**
* Resized prefix
*
* The prefix for resized files, something like .resized will do. The
* resized files will be named <prefix>_<width>x<height>_<original>
* resized files are created when one changes the dimensions of an image
* in the image manager selection dialog - the image is scaled when the
* user clicks the ok button.
*/
$IMConfig['resized_prefix'] = '.resized';
// -------------------------------------------------------------------------
/**
* Resized Directory
*
* Resized images may also be stored in a directory, except in safe mode.
*/
$IMConfig['resized_dir'] = '.resized';
/**
* Full options
*
* Determines whether the user is given options for padding,
* background/padding colour, margin, border and border colour.
*/
$IMConfig['show_full_options'] = true;
// -------------------------------------------------------------------------
/**
* Allow New Directories
*
*
* Possible values: true, false
*
* TRUE - Allow the user to create new sub-directories in the
* $IMConfig['base_dir'].
*
* FALSE - No directory creation.
*
* NOTE: If $IMConfig['safe_mode'] = true, this parameter
* is ignored, you can not create directories
*
* DEFAULT: for demo purposes we turn this off.
*/
$IMConfig['allow_new_dir'] = true;
// -------------------------------------------------------------------------
/**
* Allow Uploads
*
* Possible values: true, false
*
* TRUE - Allow the user to upload files.
*
* FALSE - No uploading allowed.
*
* DEFAULT: for demo purposes we turn this off.
*/
$IMConfig['allow_upload'] = false;
// -------------------------------------------------------------------------
/**
* Allow Delete
*
* Possible values: true, false
*
* TRUE - Allow the user to delete files/dirs
*
* FALSE - No deleting allowed.
*
*/
$IMConfig['allow_delete'] = true;
// -------------------------------------------------------------------------
/**
* Allow Edit
*
* Possible values: true, false
*
* TRUE - Allow the user to edit files
*
* FALSE - No editing allowed.
*
*/
$IMConfig['allow_edit'] = true;
// -------------------------------------------------------------------------
/**
* Validate Images
*
* Possible values: true, false
*
* TRUE - If set to true, uploaded files will be validated based on the
* function getImageSize, if we can get the image dimensions then
* I guess this should be a valid image. Otherwise the file will be rejected.
*
* FALSE - All uploaded files will be processed.
*
* NOTE: If uploading is not allowed, this parameter is ignored.
*/
$IMConfig['validate_images'] = true;
$IMConfig['allowed_image_extensions'] = array("jpg","gif","png","jpeg");
// -------------------------------------------------------------------------
/**
* Default Thumnail.
*
* The default thumbnail if the thumbnails can not be created, either
* due to error or bad image file.
*/
$IMConfig['default_thumbnail'] = 'img/default.gif';
// -------------------------------------------------------------------------
/**
* Thumbnail dimensions.
*/
$IMConfig['thumbnail_width'] = 96;
$IMConfig['thumbnail_height'] = 96;
// -------------------------------------------------------------------------
/**
* Editor Temporary File Prefix.
*
* Image Editor temporary filename prefix.
*/
$IMConfig['tmp_prefix'] = '.editor_';
$IMConfig['ViewMode'] = 'thumbs';
// -------------------------------------------------------------------------
/** Margin Types
* If your HTML will be used in an email, then using CSS type "margin"
* is not so reliable and you should set UseHSpaceVSpace to be true
* to go back to the old fashioned hspace="" and vspace="" attributes on
* images.
*/
$IMConfig['UseHSpaceVSpace'] = false;
// -------------------------------------------------------------------------
/**
* ImageManager/Picker can provide selection interfaces for more than just
* images on the server ("Pictures").
*
* Local - the classical ImageManager for images stored on this server.
*
* YouTube - provides selection (but not upload etc) of videos on YouTube
* see smart-image.js for how to make the videos work as videos instead of
* static images.
*
* Flickr - provides selection (but not upload etc) of public images on Flickr
* Set
* $IMConfig['Flickr'] = array('Key' => 'yourkeyhere');
* to turn on Flickr support.
*
* To get a key: http://www.flickr.com/services/api/keys/
*
* WARNING: Flickr restricts commercial use of the API. If your site is in any way even
* remotely commercial you need to ask for a commercial key from flickr.
*
* ADDITIONAL WARNING: Flickr requires that you provide a link back to them, preferably
* on the image itself (linking to the image) - you can use smart-image.js to do
* something like this.
*
* ADDITIONAL ADDITIONAL WARNING: It's up to you to comply with the image's license!!
*/
$IMConfig['Local'] = TRUE;
$IMConfig['YouTube'] = FALSE;
$IMConfig['Flickr'] = FALSE;
// These are some configurable defaults for Flickr, to override
// $IMConfig['Flickr'] = array('Whatever' => 'You Want');
$FlickrDefaults = array
(
// This is the URL as flickr provides it for the licence which you wish
// to search on by default. The default here is the least restrictive one.
'Default License' => 'http://creativecommons.org/licenses/by/2.0/',
);
////////////////////////////////////////////////////////////////////////////////
// ================== END OF CONFIGURATION ======================= //
////////////////////////////////////////////////////////////////////////////////
// Standard PHP Backend Data Passing
// if data was passed using xinha_pass_to_php_backend() we merge the items
// provided into the Config
require_once(realpath(dirname(__FILE__) . '/../../contrib/php-xinha.php'));
if($passed_data = xinha_read_passed_data())
{
$IMConfig = array_merge($IMConfig, $passed_data);
$IMConfig['backend_url'] .= xinha_passed_data_querystring() . '&';
if($IMConfig['Flickr'])
{
foreach($FlickrDefaults as $k => $v)
{
if(!isset($IMConfig['Flickr'][$k]))
{
$IMConfig['Flickr'][$k] = $v;
}
}
}
}
// Deprecated config passing, don't use this way any more!
elseif(isset($_REQUEST['backend_config']))
{
if(get_magic_quotes_gpc()) {
$_REQUEST['backend_config'] = stripslashes($_REQUEST['backend_config']);
}
if($_REQUEST['backend_config_secret_key_location'] !== 'Xinha:ImageManager')
{
trigger_error('Programming Error - please contact the website administrator/programmer to alert them to this problem. A non-default backend key location is being used to pass backend data to Xinha, but the same key location is not being used to receive data. The special backend configuration has been ignored. To resolve this, you should edit plugins/ImageManager/config.php and change the default key location from "Xinha:ImageManager" to your desired non default. See: http://trac.xinha.org/ticket/1518', E_USER_ERROR);
}
else
{
// Config specified from front end, check that it's valid
session_start();
$secret = $_SESSION[$_REQUEST['backend_config_secret_key_location']];
if($_REQUEST['backend_config_hash'] !== sha1($_REQUEST['backend_config'] . $secret))
{
die("Backend security error.");
}
$to_merge = unserialize($_REQUEST['backend_config']);
if(!is_array($to_merge))
{
die("Backend config syntax error.");
}
$IMConfig = array_merge($IMConfig, $to_merge);
$IMConfig['backend_url'] .= "backend_config=" . rawurlencode($_REQUEST['backend_config']) . '&';
$IMConfig['backend_url'] .= "backend_config_hash=" . rawurlencode($_REQUEST['backend_config_hash']) . '&';
$IMConfig['backend_url'] .= "backend_config_secret_key_location=" . rawurlencode($_REQUEST['backend_config_secret_key_location']) . '&';
}
}
define('IMAGE_CLASS', $IMConfig['IMAGE_CLASS']);
define('IMAGE_TRANSFORM_LIB_PATH', $IMConfig['IMAGE_TRANSFORM_LIB_PATH']);
define( "IM_CONFIG_LOADED", "yes" );
// bring in the debugging library
include_once( "ddt.php" );
// uncomment to send debug messages to a local file
// _setDebugLog( "/tmp/debug_log.txt" );
// turn debugging on everywhere.
// _ddtOn();
// END
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/config.inc.php | PHP | art | 13,602 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// Author: Maarten Molenschot, maarten@nrgmm.nl
{
"Image Manager": "Afbeeldingen Beheer",
"Crop": "Passend maken"
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/nl.js | JavaScript | art | 177 |
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: Udo Schmal (gocher), http://www.schaffrath-neuemedien.de/, udo.schmal@t-online.de
{
"Image Manager": "Bildmanager",
"Insert Image": "Bild einfügen",
"Directory": "Ordner",
"Directory Up": "übergeordneter Ordner",
"New Folder": "Neuer Ordner",
"Trash": "Müll",
"Edit": "bearbeiten",
"Image File": "Bilddatei",
"Upload": "Hochladen",
"Width": "Breite",
"Height": "Höhe",
"Constrain Proportions": "Proportional",
"Border": "Rand",
"V Space": "vertikaler Freiraum",
"H Space": "horizontaler Freiraum",
"Refresh": "Aktualisieren",
"Uploading...": "Hochladen...",
"Crop": "Beschneiden",
"Resize": "Größe ändern",
"Rotate": "Drehen",
"Measure": "Abmessungen",
"Marker": "Marker",
"Save": "Speichern",
"Filename:": "Dateiname:",
"Image Format": "Bildformat:",
"Quality:": "Qualität",
"JPEG High": "JPEG hoch",
"JPEG Medium": "JPEG mittel",
"JPEG Low": "JPEG niedrig",
"File saved.": "Datei gespeichert.",
"File was not saved.": "Datei wurde nicht gespeichert.",
"Start X:": "Start X",
"Start Y:": "Start Y",
"Lock": "Sperren",
"Flip Image": "Bild spiegeln",
"Flip Horizontal": "horizontal spiegeln",
"Flip Vertical": "vertikal spiegeln",
"Rotate Image": "Bild drehen",
"Rotate 180 °": "180° drehen",
"Rotate 90 ° CW": "90° drehen im UZS",
"Rotate 90 ° CCW": "90° drehen gegen UZS",
"Angle:": "Winkel:",
"W:": "B:",
"Clear": "Entfernen",
"Loading": "Laden",
"Invalid base directory:": "Ungültiges Startverzeichnis:",
"Delete file?": "Datei löschen?",
"Please delete all files/folders inside the folder you wish to delete first.": "Bitte löschen Sie zuerst alle Dateien im Ordner den Sie löschen möchten.",
"Delete folder?": "Ordner löschen?",
"Folder Name:": "Ordnername:",
"No Images Found": "Kein Bild gefunden",
"Invalid folder name, please choose another folder name.": "Ungültiger Ordnername, bitte wählen sie einen anderen Namen.",
"GIF format is not supported, image editing not supported.": "GIF Format wird nicht unterstützt, Bildbearbeitung wird nicht unterstützt.",
"No Image Available": "Kein Bild verfügbar",
"No Image selected.": "Kein Bild ausgewählt.",
"Description:": "Beschreibung:",
"Align:": "Ausrichtung:",
"Margin:": "Außenabstand:",
"Padding:": "Innenabstand:",
"Color:": "Farbe:"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/de.js | JavaScript | art | 2,408 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
// translated: Krzysztof Kotowicz, http://www.eskot.krakow.pl/portfolio/, koto@webworkers.pl
{
"Image Manager": "Menedżer obrazków",
"Insert Image": "Wstaw obrazek",
"Directory": "Katalog",
"Directory Up": "Katalog wyżej",
"New Folder": "Nowy katalog",
"Trash": "Usuń",
"Edit": "Edytuj",
"Image File": "Plik obrazka",
"Upload": "Wgraj",
"Width": "Szerokość",
"Height": "Wysokość",
"Width:": "Szerokość:",
"Height:": "Wysokość:",
"Constrain Proportions": "Zachowaj proporcje",
"Border": "Ramka",
"V Space": "Odległość V",
"H Space": "Odległość H",
"Refresh": "Odśwież",
"Uploading...": "Wgrywanie...",
"Crop": "Przytnij",
"Resize": "Przeskaluj",
"Rotate": "Obróć",
"Measure": "Zmierz",
"Marker": "Zaznacz",
"Save": "Zapisz",
"Filename:": "Nazwa pliku:",
"Image Format": "Format pliku:",
"Quality:": "Jakość",
"JPEG High": "JPEG wysoka",
"JPEG Medium": "JPEG średnia",
"JPEG Low": "JPEG niska",
"File saved.": "Zapisano plik.",
"File was not saved.": "Nie zapisano pliku.",
"Start X:": "Początek X",
"Start Y:": "Początek Y",
"Lock": "Zablokuj",
"Flip Image": "Odwróć",
"Flip Horizontal": "Odwróć poziomo",
"Flip Vertical": "Odwróć pionowo",
"Rotate Image": "Obróć",
"Rotate 180 °": "Obróć 180°",
"Rotate 90 ° CW": "Obróć 90° w prawo",
"Rotate 90 ° CCW": "Obróć 90° w lewo",
"Angle:": "Kąt:",
"W:": "L:",
"Clear": "Wyczyść",
"Loading": "Ładowanie",
"Invalid base directory:": "Nieprawidłowy katalog bazowy:",
"Delete file?": "Usunąć plik?",
"Please delete all files/folders inside the folder you wish to delete first.": "Najpierw usuń wszystkie pliki i podkatalogi katalogu.",
"Delete folder?": "Usunąć katalog ?",
"Folder Name:": "Nazwa katalogu",
"No Images Found": "Nie znaleziono obrazków",
"Invalid folder name, please choose another folder name.": "Nieprawidłowa nazwa katalogu, wybierz inną.",
"GIF format is not supported, image editing not supported.": "Brak obsługi plików GIF, edycja jest niemożliwa.",
"No Image Available": "Obrazek niedostępny",
"No Image selected.": "Nie zaznaczono obrazka.",
"Description:": "Opis:",
"Align:": "Wyrównanie:",
"Description:": "Opis:",
"Margin:": "Margines:",
"Padding:": "Wcięcie:",
"Border:": "Ramka:",
"Color:": "Kolor:",
"Upload:": "Wgraj:"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/pl.js | JavaScript | art | 2,437 |
// I18N constants
// LANG: "ru", ENCODING: UTF-8
// Author: Andrei Blagorazumov, a@fnr.ru
{
"Image Manager": "Менеджер картинок",
"Insert Image": "Вставка картинки",
"Directory": "Папка",
"Directory Up": "Папка наверх",
"New Folder": "Новая папка",
"Trash": "Корзина",
"Edit": "Правка",
"Image File": "Файл картинки",
"Upload": "Загрузить",
"Width": "Ширина",
"Height": "Высота",
"Width:": "Ширина",
"Height:": "Высота",
"Constrain Proportions": "Сохранить пропорции",
"Border": "Рамка",
"V Space": "Поле V",
"H Space": "Поле H",
"Refresh": "Обновить",
"Uploading...": "Загрузка...",
"Crop": "Обрезать",
"Resize": "Масшабировать",
"Rotate": "Повернуть",
"Measure": "Измерение",
"Marker": "Маркер",
"Save": "Сохранить",
"Filename:": "Имя файла",
"Image Format": "Формат картинки",
"Quality:": "Качество",
"JPEG High": "JPEG высок.",
"JPEG Medium": "JPEG средн.",
"JPEG Low": "JPEG низк.",
"File saved.": "Файл сохранен.",
"File was not saved.": "Файл не сохранен.",
"Start X:": "Начало X",
"Start Y:": "Начало Y",
"Lock": "Блокировка",
"Flip Image": "Развернуть картинку",
"Flip Horizontal": "Развернуть по горизонтали",
"Flip Vertical": "Развернуть по вертикали",
"Rotate Image": "Повернуть картинку",
"Rotate 180 В°": "Повернуть на 180°",
"Rotate 90 В° CW": "Повернуть на 90° по часовой",
"Rotate 90 В° CCW": "Повернуть на 90° против часовой",
"Angle:": "Угол",
"W:": "Ш:",
"Clear": "Очистить",
"Loading": "Загрузка",
"Invalid base directory:": "Неверная базовая папка:",
"Delete file?": "Удалить файл?",
"Please delete all files/folders inside the folder you wish to delete first.": "Пожалуйста удалите все файлы/папки в папке, которую вы хотите удалить.",
"Delete folder?": "Удалить папку?",
"Folder Name:": "Название папки:",
"No Images Found": "Картинок не найдено",
"Invalid folder name, please choose another folder name.": "Неправильное имя папки, пожалуйста выберите другое.",
"GIF format is not supported, image editing not supported.": "Формат GIF не поддерживается, редактирование картинки не поддерживается.",
"No Image Available": "Нет доступных картинок",
"No Image selected.": "Картинки не выбраны.",
"Color:": "Цвет",
"Align:": "Выравнивание",
"Margin:": "Отступ",
"Padding:": "Поля",
"Border:": "Рамка"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/ru.js | JavaScript | art | 3,191 |
// I18N constants
// LANG: "sv" (Swedish), ENCODING: UTF-8
// translated: Erik Dalén, <dalen@jpl.se>
{
"Image Manager": "Bildbehandlare",
"Crop": "Beskjär"
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/sv.js | JavaScript | art | 165 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"Image Manager": "Bibliothèque d'images",
"Insert Image": "Insérer une image",
"Directory": "Répertoire",
"Directory Up": "Remonter",
"New Folder": "Nouveau répertoire",
"Trash": "Détruire",
"Edit": "Editer",
"Image File": "Fichier",
"Upload": "Télécharger",
"Width": "Largeur",
"Height": "Hauteur",
"Width:": "Largeur",
"Height:": "Hauteur",
"Constrain Proportions": "Conserver les proportions",
"Border": "Bordure",
"V Space": "Espace V",
"H Space": "Espace H",
"Refresh": "Rafraîchir",
"Uploading...": "Chargement...",
"Crop": "Recadrer",
"Resize": "Retailler",
"Rotate": "Pivoter",
"Measure": "Mesure",
"Marker": "Marqueur",
"Save": "Sauver",
"Filename:": "Nom",
"Image Format": "Format d'image",
"Quality:": "Qualité",
"JPEG High": "JPEG haut",
"JPEG Medium": "JPEG moyen",
"JPEG Low": "JPEG bas",
"File saved.": "Fichier sauvegardé.",
"File was not saved.": "Fichier non sauvegardé.",
"Start X:": "Début X",
"Start Y:": "Début Y",
"Lock": "Cadenas",
"Flip Image": "Symétrie",
"Flip Horizontal": "Symétrie horizontale",
"Flip Vertical": "Symétrie verticale",
"Rotate Image": "Rotation",
"Rotate 180 °": "Rotation 180°",
"Rotate 90 ° CW": "Rotation 90° horaire",
"Rotate 90 ° CCW": "Rotation 90° antihoraire",
"Angle:": "Angle",
"W:": "L:",
"Clear": "Effacer",
"Loading": "Chargement en cours",
"Invalid base directory:": "Répertoire de base invalide:",
"Delete file?": "Suppression du fichier ?",
"Please delete all files/folders inside the folder you wish to delete first.": "Veuillez tout d'abord supprimer tous les fichiers et répertoires contenus",
"Delete folder?": "Suppression du répertoire ?",
"Folder Name:": "Nom du répertoire",
"No Images Found": "Aucune image trouvée",
"Invalid folder name, please choose another folder name.": "Nom de répertoire invalide, veuillez choisir un autre nom",
"GIF format is not supported, image editing not supported.": "Format GIF non supporté, édition d'image non supportée",
"No Image Available": "Aucune image disponible",
"No Image selected.": "Aucune image sélectionnée.",
"Color:": "Couleur",
"Align:": "Alignement",
"Margin:": "Marge",
"Padding:": "Espacement",
"Border:": "Bordure"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/fr.js | JavaScript | art | 2,349 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
{
"Image Manager": "画像マネージャ",
"Insert Image": "画像の挿入",
"Directory": "ディレクトリ",
"Directory Up": "親ディレクトリへ",
"New Folder": "新規フォルダ",
"Trash": "削除",
"Edit": "編集",
"Image File": "画像ファイル",
"Upload": "アップロード",
"Width": "幅",
"Height": "高さ",
"Width:": "幅:",
"Height:": "高さ:",
"Constrain Proportions": "縦横比を固定",
"Border": "ボーダー",
"V Space": "垂直余白",
"H Space": "水平余白",
"Refresh": "更新",
"Uploading...": "アップロード中...",
"Crop": "切り抜き",
"Resize": "サイズ変更",
"Rotate": "回転",
"Measure": "計測",
"Marker": "マーカー",
"Save": "保存",
"Filename:": "ファイル名:",
"Image Format": "画像形式",
"Quality:": "画質:",
"JPEG High": "JPEG 高画質",
"JPEG Medium": "JPEG 標準",
"JPEG Low": "JPEG 低画質",
"File saved.": "ファイルを保存しました。",
"File was not saved.": "ファイルを保存できませんでした。",
"Start X:": "開始 X",
"Start Y:": "開始 Y",
"Lock": "ロック",
"Flip Image": "画像を反転",
"Flip Horizontal": "左右反転",
"Flip Vertical": "上下反転",
"Rotate Image": "画像を回転",
"Rotate 180 °": "180°",
"Rotate 90 ° CW": "90° 時計回り",
"Rotate 90 ° CCW": "90° 反時計回り",
"Angle:": "角度:",
"W:": "W:",
"Clear": "クリア",
"Loading": "ロード中",
"Invalid base directory:": "無効なディレクトリ:",
'Delete file "$file"?': 'ファイル "$file" を削除しますか?',
"Please delete all files/folders inside the folder you wish to delete first.": "削除したいフォルダ内のファイルとフォルダを全て削除しておいてください。",
'Delete folder "$dir"?': 'フォルダ "$dir" を削除しますか?',
"Folder Name:": "フォルダ名:",
"No Files Found": "ファイルがありません",
"Invalid folder name, please choose another folder name.": "無効なフォルダ名です。別のフォルダ名を選んでください。",
"GIF format is not supported, image editing not supported.": "GIF形式はサポートされていないため、画像編集できません。",
"No Image Available": "画像がありません",
"No Image selected.": "画像が選択されていません。",
"Color:": "色:",
"Align:": "行揃え",
"Margin:": "間隔:",
"Padding:": "余白:",
"Border:": "境界線:",
"Upload": "アップロード",
"Upload:": "アップロード:",
"Description:": "説明:"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/ja.js | JavaScript | art | 2,680 |
// I18N constants
// LANG: "nb", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"Image Manager": "Bildebehandler",
"Insert Image": "Sett inn bilde",
"Directory": "Mappe",
"Directory Up": "Opp en mappe",
"New Folder": "Ny mappe",
"Trash": "Søppelkurv",
"Edit": "Rediger",
"Image File": "Bildefil",
"Upload": "Last opp",
"Width": "Bredde",
"Height": "Høyde",
"Constrain Proportions": "Behold proposjoner",
"Border": "Ramme",
"V Space": "vertikal marg",
"H Space": "horisontal marg",
"Refresh": "Oppfrisk",
"Uploading...": "Laster opp...",
"Crop": "Beskjær",
"Resize": "Endre størrelse",
"Rotate": "Roter",
"Measure": "Mål",
"Marker": "Marker",
"Save": "Lagre",
"Filename:": "Filnavn:",
"Image Format": "Bildeformat:",
"Quality:": "Kvalitet",
"JPEG High": "JPEG høy",
"JPEG Medium": "JPEG middelse",
"JPEG Low": "JPEG lav",
"File saved.": "Fil lagret.",
"File was not saved.": "Fil ble ikke lagret.",
"Start X:": "Start X",
"Start Y:": "Start Y",
"Lock": "Sperre",
"Flip Image": "Vend bilde",
"Flip Horizontal": "Vend horisontal",
"Flip Vertical": "Vend vertikal",
"Rotate Image": "Roter bilde",
"Rotate 180 °": "Roter 180°",
"Rotate 90 ° CW": "Roter 90° med klokka",
"Rotate 90 ° CCW": "Roter 90° mot klokka",
"Angle:": "Vinkel:",
"W:": "B:",
"Clear": "Fjern",
"Loading": "Laster",
"Invalid base directory:": "Feil rot-mappe:",
"Delete file?": "Slette fil?",
"Please delete all files/folders inside the folder you wish to delete first.": "Vennligst slett alle filer og mapper i mappen du ønsker å slette og prøv igjen.",
"Delete folder?": "Slett mappe?",
"Folder Name:": "Mappenavn:",
"No Images Found": "Ingen bilder funnet",
"Invalid folder name, please choose another folder name.": "Ugyldig mappenavn, vennligst velg et annet navn på mappen.",
"GIF format is not supported, image editing not supported.": "Bildeformatet GIF er ikke støttet.",
"No Image Available": "Inget bilde er tilgjengelig",
"No Image selected.": "Inget bilde er valgt.",
"Description:": "Beskrivelse:",
"Align:": "Justering:",
"Margin:": "Marg:",
"Padding:": "Innsidemarg:",
"Color:": "Farge:"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/nb.js | JavaScript | art | 2,253 |
// I18N constants
// LANG: "es", ENCODING: UTF-8
// translated: michael Hauptmnn (mhauptma73) , http://www.azahost.com/, miguel@azalorea.com
{
"Image Manager": "Editor de imágenes",
"Insert Image": "insertar imagen",
"Directory": "Directorio",
"Directory Up": "Directorio superior",
"New Folder": "Crear directorio",
"Trash": "Basura",
"Edit": "editar",
"Image File": "Fichero",
"Upload": "Subir",
"Width": "Ancho",
"Height": "Alto",
"Width:": "Ancho:",
"Height:": "Alto:",
"Constrain Proportions": "Proporcional",
"Border": "Borde",
"V Space": "espacio vertical",
"H Space": "espacio horizontal",
"Refresh": "Actualizar",
"Uploading...": "Subir...",
"Crop": "Recortar",
"Resize": "Cambiar tamaño",
"Rotate": "Girar",
"Measure": "Dimensiones",
"Marker": "Marcador",
"Save": "Guardar",
"Filename:": "Nombre del fichero:",
"Image Format": "Formato:",
"Quality:": "Calidad",
"JPEG High": "JPEG alto",
"JPEG Medium": "JPEG medio",
"JPEG Low": "JPEG bajo",
"File saved.": "Fichero guardado.",
"File was not saved.": "el fichero no ha sido guardado.",
"Start X:": "Inicio X",
"Start Y:": "Inicio Y",
"Lock": "Bloquear",
"Flip Image": "invertir imagen",
"Flip Horizontal": "invertir horizontalmente",
"Flip Vertical": "invertir verticalmente",
"Rotate Image": "Girar imagen",
"Rotate 180 °": "Girar 180º",
"Rotate 90 ° CW": "Girar 90º sentido reloj",
"Rotate 90 ° CCW": "Girar 90º sentido contrareloj",
"Angle:": "Ángulo:",
"W:": "B:",
"Clear": "Eliminar",
"Loading": "Cargar",
"Invalid base directory:": "Directorio de inicio inválido:",
"Delete file?": "¿Borrar fichero?",
"Please delete all files/folders inside the folder you wish to delete first.": "Primero tiene que borrar todoas los ficheros de este directorio.",
"Delete folder?": "¿Borrar directorio?",
"Folder Name:": "Nombre del directorio:",
"No Images Found": "No se ha encontrado imagen",
"Invalid folder name, please choose another folder name.": "Nombre de directorio inválido... por favor elija otro nombre.",
"GIF format is not supported, image editing not supported.": "No hay soporte para imágenes en formato GIF.",
"No Image Available": "No hay imagen",
"No Image selected.": "No ha seleccionado imagen.",
"Description:": "Descripción:",
"Align:": "Alineado:",
"Description:": "Descripción:",
"Margin:": "Margen exterior:",
"Padding:": "Margen interior:",
"Border:": "Borde:",
"Color:": "Color:",
"Upload:": "Subir:"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/es.js | JavaScript | art | 2,530 |
// I18N constants
//
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
//
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
//
// Last revision: 06 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"A:": "A:",
"Absbottom": "Inferior absoluto",
"Absmiddle": "Meio absoluto",
"Angle:": "Ângulo:",
"Baseline": "Linha de base",
"Bottom": "Base",
"Cancel": "Cancelar",
"Clear": "Limpar",
"Constrain Proportions": "Manter proporções",
"Crop": "Recortar",
"D:": "G:",
"Directory": "Diretório",
"Directory Up": "Diretório Acima",
"Edit": "Editar",
"Filename:": "Nome do arquivo:",
"Flip Horizontal": "Espelhar Horizontalmente",
"Flip Image": "Espelhar Imagem",
"Flip Vertical": "Espelhar Verticalmente",
"Folder Name:": "Nome da Pasta:",
"GIF": "GIF",
"GIF format is not supported, image editing not supported.": "Formato GIF não é suportado, edição de imagem não é suportada.",
"H:": "A:",
"Height:": "Altura:",
"Image Editor": "Editor de Imagem",
"Image Format": "Formato da Imagem",
"Image List": "Lista de Imagens",
"Image Manager": "Gerenciador de Imagens",
"Image Selection": "Seleção de Imagem",
"Insert Image": "Inserir Imagem",
"Invalid base directory:": "Diretório base inválido:",
"JPEG High": "JPEG Alto",
"JPEG Low": "JPEG Baixo",
"JPEG Medium": "JPEG Médio",
"Left": "Esquerda",
"Lock": "Travar",
"Marker": "Marcar",
"Measure": "Medida",
"Middle": "Meio",
"New Folder": "Nova Pasta",
"No Image Available": "Sem Imagem Disponível",
"No Images Found": "Nenhuma Imagem Encontrada",
"Not set": "Não definido",
"OK": "OK",
"PNG": "PNG",
"Positioning of this image": "Posicionamento desta imagem",
"Quality:": "Qualidade:",
"Refresh": "Atualização",
"Resize": "Redimencionar",
"Right": "Direita",
"Rotate": "Rotacionar",
"Rotate 180 °": "Rotacionar 180 °",
"Rotate 90 ° CCW": "Rotacionar 90 ° anti-horário",
"Rotate 90 ° CW": "Rotacionar 90 ° horário",
"Rotate Image": "Rotacionar Imagem",
"Save": "Gravar",
"Start X:": "Início X:",
"Start Y:": "Início Y:",
"Texttop": "Texto no topo",
"Top": "Topo",
"Trash": "Lixo",
"W:": "C:",
"Width:": "Largura:",
"X:": "X:",
"Y:": "Y:",
// not find with lc_parse_strings.php
"Image File": "Arquivo Imagem",
"Upload": "Enviar",
"Upload:": "Enviar imagem:",
"Width": "Largura",
"Height": "Altura",
"Border": "Borda",
"V Space": "Espaço vert.",
"H Space": "Espaço horiz.",
"Uploading...": "Enviando...",
"File saved.": "Arquivo gravado.",
"File was not saved.": "Arquivo não foi salvo.",
"Loading": "Lendo",
"Delete file?": "Apagar arquivo?",
"Please delete all files/folders inside the folder you wish to delete first.": "Por favor, primeiro apague todos os arquivos/pastas dentro da pasta que deseja apagar.",
"Delete folder?": "Apagar pasta?",
"Folder Name:": "Nome da Pasta:",
"No Files Found": "Nenhum arquivo encontrado",
"Invalid folder name, please choose another folder name.": "Nome inválido para pasta, escolha outro nome.",
"No Image selected.": "Nenhuma imagem selecionada.",
"Description:": "Descrição:",
"Align:": "Alinhamento:",
"Margin:": "Margem:",
"Padding:": "Espaçamento:",
"Border:": "Borda:",
"Color:": "Côr:"
}
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/lang/pt_br.js | JavaScript | art | 3,613 |
/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
if (!document.getElementById) { return; }
this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params = new Object();
this.variables = new Object();
this.attributes = new Array();
if(swf) { this.setAttribute('swf', swf); }
if(id) { this.setAttribute('id', id); }
if(w) { this.setAttribute('width', w); }
if(h) { this.setAttribute('height', h); }
if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
if (!window.opera && document.all && this.installedVer.major > 7) {
// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
deconcept.SWFObject.doPrepUnload = true;
}
if(c) { this.addParam('bgcolor', c); }
var q = quality ? quality : 'high';
this.addParam('quality', q);
this.setAttribute('useExpressInstall', false);
this.setAttribute('doExpressInstall', false);
var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
this.setAttribute('xiRedirectUrl', xir);
this.setAttribute('redirectUrl', '');
if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
useExpressInstall: function(path) {
this.xiSWFPath = !path ? "expressinstall.swf" : path;
this.setAttribute('useExpressInstall', true);
},
setAttribute: function(name, value){
this.attributes[name] = value;
},
getAttribute: function(name){
return this.attributes[name];
},
addParam: function(name, value){
this.params[name] = value;
},
getParams: function(){
return this.params;
},
addVariable: function(name, value){
this.variables[name] = value;
},
getVariable: function(name){
return this.variables[name];
},
getVariables: function(){
return this.variables;
},
getVariablePairs: function(){
var variablePairs = new Array();
var key;
var variables = this.getVariables();
for(key in variables){
variablePairs[variablePairs.length] = key +"="+ variables[key];
}
return variablePairs;
},
getSWFHTML: function() {
var swfNode = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
if (this.getAttribute("doExpressInstall")) {
this.addVariable("MMplayerType", "PlugIn");
this.setAttribute('swf', this.xiSWFPath);
}
swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
var params = this.getParams();
for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
var pairs = this.getVariablePairs().join("&");
if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
swfNode += '/>';
} else { // PC IE
if (this.getAttribute("doExpressInstall")) {
this.addVariable("MMplayerType", "ActiveX");
this.setAttribute('swf', this.xiSWFPath);
}
swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
var params = this.getParams();
for(var key in params) {
swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
}
var pairs = this.getVariablePairs().join("&");
if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
swfNode += "</object>";
}
return swfNode;
},
write: function(elementId){
if(this.getAttribute('useExpressInstall')) {
// check to see if we need to do an express install
var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
this.setAttribute('doExpressInstall', true);
this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
this.addVariable("MMdoctitle", document.title);
}
}
if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
n.innerHTML = this.getSWFHTML();
return true;
}else{
if(this.getAttribute('redirectUrl') != "") {
document.location.replace(this.getAttribute('redirectUrl'));
}
}
return false;
}
}
/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins && navigator.mimeTypes.length){
var x = navigator.plugins["Shockwave Flash"];
if(x && x.description) {
PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
}
}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
var axo = 1;
var counter = 3;
while(axo) {
try {
counter++;
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
// document.write("player v: "+ counter);
PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
} catch (e) {
axo = null;
}
}
} else { // Win IE (non mobile)
// do minor version lookup in IE, but avoid fp6 crashing issues
// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
try{
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
}catch(e){
try {
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
} catch(e) {
if (PlayerVersion.major == 6) {
return PlayerVersion;
}
}
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
} catch(e) {}
}
if (axo != null) {
PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}
}
return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
if(this.major < fv.major) return false;
if(this.major > fv.major) return true;
if(this.minor < fv.minor) return false;
if(this.minor > fv.minor) return true;
if(this.rev < fv.rev) return false;
return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
getRequestParameter: function(param) {
var q = document.location.search || document.location.hash;
if (param == null) { return q; }
if(q) {
var pairs = q.substring(1).split("&");
for (var i=0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return pairs[i].substring((pairs[i].indexOf("=")+1));
}
}
}
return "";
}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
var objects = document.getElementsByTagName("OBJECT");
for (var i = objects.length - 1; i >= 0; i--) {
objects[i].style.display = 'none';
for (var x in objects[i]) {
if (typeof objects[i][x] == 'function') {
objects[i][x] = function(){};
}
}
}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
if (!deconcept.unloadSet) {
deconcept.SWFObjectUtil.prepUnload = function() {
__flash_unloadHandler = function(){};
__flash_savedUnloadHandler = function(){};
window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
}
window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
deconcept.unloadSet = true;
}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/swfobject/swfobject_source.js | JavaScript | art | 9,321 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SWFObject embed by Geoff Stearns (express install) @ deconcept</title>
<!-- SWFObject embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/swfobject/ -->
<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">
body {
background-color: #eeeeee;
font: .8em/1.3em verdana,arial,helvetica,sans-serif;
}
#info {
width: 300px;
overflow: auto;
}
#flashcontent {
border: solid 1px #000;
width: 300px;
height: 300px;
float: left;
margin: 15px 20px;
}
</style>
</head>
<body>
<div id="flashcontent">
<strong>You need to upgrade your Flash Player</strong>
This is replaced by the Flash content.
Place your alternate content here and users without the Flash plugin or with
Javascript turned off will see this. Content here allows you to leave out <code>noscript</code>
tags. Include a link to <a href="expressinstall.html?detectflash=false">bypass the detection</a> if you wish.
</div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("so_tester.swf", "sotester", "300", "300", "9", "#FF6600");
so.addVariable("flashVarText", "this is passed in via FlashVars"); // this line is optional, but this example uses the variable and displays this text inside the flash movie
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
// ]]>
</script>
<div id="info">
<p>
This Flash movie was embedded using the <a href="http://blog.deconcept.com/swfobject/">SWFObject</a> embed method by <a href="http://blog.deconcept.com/">Geoff Stearns</a>.
</p>
<p>Other sample embeds:</p>
<ul>
<li><a href="swfobject.html">Basic Flash Embed with alternate content</a></li>
<li><a href="fullpage.html">Full page Flash embed</a></li>
<li>Basic Flash Embed with Express Install allowed</li>
</ul>
<p>You can also <a href="flashversion.html">view your installed Flash version</a>.</p>
<p>
<a href="view-source:http://blog.deconcept.com/swfobject/expressinstall.html">View source</a> (in mozilla, firefox) | <a href="swfobject_source.js">View Javascript</a>.
</p>
<p>
<a href="http://blog.deconcept.com/swfobject/swfobject1-4.zip">Download Source</a>.
</p>
</div>
<p style="clear: both;margin-left: 20px"><a href="http://validator.w3.org/check?uri=referer">Validate XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></p>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/swfobject/expressinstall.html | HTML | art | 2,723 |
/** The ImageManager plugin has the capability to also select other things and represent them as images.
* For example, it can select YouTube videos, and the image it returns will be the "large size thumbnail"
* of the video which YouTube provides, along with some "meta information" which is stored as a query string
* on the end of the image URL.
*
* For example, a YouTube video url returned by ImageManager may look like this (I've inserted newlines here):
* http://img.youtube.com/vi/_ctBsZJmPv8/0.jpg
* ?x-shockwave-flash=http%3A%2F%2Fwww.youtube.com%2Fv%2F_ctBsZJmPv8
* &x-thumbnail=http%3A%2F%2Fimg.youtube.com%2Fvi%2F_ctBsZJmPv8%2F3.jpg
* &f_alt=CAW%20Sportcruiser%20ZK-JBZ%20does%20a%20touch%20and%20go%20at%20Tirohia
* &f_width=320
* &f_height=240
*
* It should be clear what the meta information all means.
*
* The job of SmartImages is to look through the page where you OUTPUT (use) the stuff you edited with
* Xinha/ImageManager/ImagePicker find images with the appropriate meta information, and replace them
* with something other than an image (in this case, it would replace it with the YouTube video of course).
*
* REPEAT: You need to use SmartImages (or make your own alternative) on the page(s) where you OUTPUT (use)
* the content you edited with Xinha/ImageManager/ImagePicker. If you don't, well, you just get to see a
* static image, instead of the video (as will anybody with JS turned off etc, which is quite the bonus really!)
*
* Example Usage:
* <head>
* <script type="text/javascript" src="/xinha/plugins/ImageManager/smart-image.js"></script>
* </head>
* <body onload="SmartImages.replace_all();">
*
* If you want to do something fancy with youtube/flash smart images, check out the SmartImages.replace_flash
* method below where you can specify dimensions, background colour, pass data to the flash, and set attributes
* on the resulting object/embed.
*
* @author $Author: gogo $
* @version $Id: image-manager.js 856 2007-06-13 18:34:34Z wymsy $
* @package ImageManager
*/
var SmartImages =
{
_flash_meta_re: new RegExp(/\?.*(x-shockwave-flash)=([^&]+)/),
_flickr_meta_re: new RegExp(/\?.*(x-flickr-photo)=([^&]+)/),
/** Replace an image which has exta meta information on the query string
* (from selecting a video from youtube with the image manager/picker)
* with the flash video referenced in that data.
*
* @param Element|null Image element, or null to replace all images
* which have the meta data.
* @param Object|null An object of parameters, or null for the default
{
width: '100%', // null for "same as image"
height: '100%', // null for "same as image"
bgcolor: '#000000', // null for transparent?
embed_params: {
wmode: 'transparent'
},
embed_attributes: {
}
flash_params: {
my_variable: 'something'
}
}
*
*/
replace_flash:
function (img, params)
{
if(!img)
{
var images = document.getElementsByTagName('img');
for(var x = 0; x < images.length; x++)
{
if(images[x].src.match(SmartImages._flash_meta_re))
{
SmartImages.replace_flash(images[x], params);
}
}
}
else
{
var i = img;
if(!i.src.match(SmartImages._flash_meta_re))
return;
var swf = decodeURIComponent(RegExp.$2);
if(!i.id)
{
i.id = 'ximg'+Math.floor(Math.random() * 100000);
}
if(!params) params = { };
if(!params.embed_params)
params.embed_params = { 'wmode':'transparent' };
if(!params.flash_params)
params.flash_params = { }
if(!params.embed_attributes)
params.embed_attributes = { }
if(!params.width) params.width = i.offsetWidth;
if(!params.height) params.height = i.offsetHeight;
if(params.bgcolor) params.embed_params.bgcolor = params.bgcolor;
swfobject.embedSWF(swf, i.id, params.width, params.height, '7.0.0', null, params.flash_params, params.embed_params, params.embed_attributes);
}
},
/** Add an overlay over flickr images which shows the copyright owner, and a link to the
* photo at flickr. Flickr requires attribution of all images, this should I believe satisfy
* that requirement.
*
* Note However that flickr expressly forbids any commercial use of thier API without
* a commercial API key, which they need you to apply for.
*
*/
attribute_flickr:
function(img, params)
{
if(!img)
{
var images = document.getElementsByTagName('img');
for(var x = 0; x < images.length; x++)
{
if(images[x].src.match(SmartImages._flickr_meta_re))
{
SmartImages.attribute_flickr(images[x], params);
}
}
}
else
{
var i = img;
if(!i.src.match(SmartImages._flickr_meta_re))
return;
var meta = SmartImages.get_meta(i.src);
var inf = document.createElement('a');
inf.appendChild(document.createTextNode('© ' + meta['x-by']));
inf.appendChild(document.createTextNode(' - flickr.com '));
inf.href = 'http://www.flickr.com/photos/'+meta['x-uid']+'/'+meta['x-flickr-photo']+'/';
inf.target = '_blank';
inf.style.position = 'absolute';
inf.style.display = 'block';
inf.style.visibility = 'hidden';
inf.className = 'xinha-flickr-info';
inf.style.backgroundColor = '#CCC';
inf.style.opacity = '0.6';
inf.style.padding = '2px';
inf.style.color = 'black';
i.xFlickrInfo = inf;
// Need to append it before we position it
document.body.appendChild(i.xFlickrInfo);
i.xFlickrShow = function()
{
var p = SmartImages.get_position(this);
this.xFlickrInfo.style.top = p.y + (this.offsetHeight - this.xFlickrInfo.offsetHeight) + 'px';
this.xFlickrInfo.style.left = p.x + ((this.offsetWidth / 2) - (this.xFlickrInfo.offsetWidth / 2)) + 'px';
this.xFlickrInfo.style.visibility = 'visible';
var im = this;
window.setTimeout(function() { im.xFlickrInfo.style.visibility = 'hidden'; }, 4000);
}
SmartImages.add_event(i, 'mouseover', function() { i.xFlickrShow(); });
SmartImages.add_event(window,'resize',function() { if(i.xFlickrInfo.style.visibility == 'visible') i.xFlickrShow(); });
}
},
get_meta:
function(url)
{
var outparam = { };
while(url.match(/[?&](([fx][_-][a-z0-9_-]+)=([^&#]+))/i))
{
try
{
outparam[RegExp.$2] = decodeURIComponent(RegExp.$3);
}
catch(e)
{
// Truncated component probably
}
url = url.replace(RegExp.$1, '');
}
return outparam;
},
/** Get the X/Y position of an element */
get_position: function(obj) {
var x = 0;
var y = 0;
if (obj.offsetParent) {
x = obj.offsetLeft
y = obj.offsetTop
while (obj = obj.offsetParent) {
x += obj.offsetLeft
y += obj.offsetTop
}
}
return { 'x': x, 'y': y };
},
/** Add event */
add_event: function(el, evname, func)
{
if(document.addEventListener)
{
el.addEventListener(evname, func, true);
}
else
{
el.attachEvent("on" + evname, func);
}
},
/** Replace all the images that have appropriate meta information with
* something more interesting.
*/
replace_all:
function()
{
SmartImages.replace_flash();
SmartImages.attribute_flickr();
}
}
// Below is the source for SWFObject, including it here rather than trying to do an include just to make it easier.
if(typeof swfobject == 'undefined')
{
/* SWFObject v2.0 rc2 <http://code.google.com/p/swfobject/>
Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject = function() {
var domLoadFnArr = [];
var regObjArr = [];
var timer = null;
var storedAltContent = null;
var isDomLoaded = false;
var isExpressInstallActive = false;
/* Centralized function for browser feature detection
- Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
- User agent string detection is only used when no alternative is possible
- Is executed directly for optimal performance
*/
var ua = function() {
var w3cdom = typeof document.getElementById != "undefined" && typeof document.getElementsByTagName != "undefined" && typeof document.createElement != "undefined" && typeof document.appendChild != "undefined" && typeof document.replaceChild != "undefined" && typeof document.removeChild != "undefined" && typeof document.cloneNode != "undefined";
var playerVersion = [0,0,0];
var d = null;
if (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") {
d = navigator.plugins["Shockwave Flash"].description;
if (d) {
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
}
}
else if (typeof window.ActiveXObject != "undefined") {
var a = null;
var fp6Crash = false;
try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
}
catch(e) {
try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
playerVersion = [6,0,21];
a.AllowScriptAccess = "always"; // Introduced in fp6.0.47
}
catch(e) {
if (playerVersion[0] == 6) {
fp6Crash = true;
}
}
if (!fp6Crash) {
try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
}
catch(e) {}
}
}
if (!fp6Crash && a) { // a will return null when ActiveX is disabled
try {
d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29
if (d) {
d = d.split(" ")[1].split(",");
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
catch(e) {}
}
}
var u = navigator.userAgent.toLowerCase();
var p = navigator.platform.toLowerCase();
var webkit = /webkit/.test(u);
var webkitVersion = webkit ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : 0;
var ie = false;
var win = p ? /win/.test(p) : /win/.test(u);
var mac = p ? /mac/.test(p) : /mac/.test(u);
/*@cc_on
ie = true;
@if (@_win32)
win = true;
@elif (@_mac)
mac = true;
@end
@*/
return { w3cdom:w3cdom, playerVersion:playerVersion, webkit:webkit, webkitVersion:webkitVersion, ie:ie, win:win, mac:mac };
}();
/* Cross-browser onDomLoad
- Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
- Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
*/
var onDomLoad = function() {
if (!ua.w3cdom) {
return;
}
addDomLoadEvent(main);
if (ua.ie && ua.win) {
try { // Avoid a possible Operation Aborted error
document.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
var s = document.getElementById("__ie_ondomload");
if (s) {
s.onreadystatechange = function() {
if (this.readyState == "complete") {
this.parentNode.removeChild(this);
callDomLoadFunctions();
}
};
}
}
catch(e) {}
}
if (ua.webkit && typeof document.readyState != "undefined") {
timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { callDomLoadFunctions(); }}, 10);
}
if (typeof document.addEventListener != "undefined") {
document.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
}
addLoadEvent(callDomLoadFunctions);
}();
function callDomLoadFunctions() {
if (isDomLoaded) {
return;
}
if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
var s = document.createElement("span");
try { // Avoid a possible Operation Aborted error
var t = document.getElementsByTagName("body")[0].appendChild(s);
t.parentNode.removeChild(t);
}
catch (e) {
return;
}
}
isDomLoaded = true;
if (timer) {
clearInterval(timer);
timer = null;
}
var dl = domLoadFnArr.length;
for (var i = 0; i < dl; i++) {
domLoadFnArr[i]();
}
}
function addDomLoadEvent(fn) {
if (isDomLoaded) {
fn();
}
else {
domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
}
}
/* Cross-browser onload
- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
- Will fire an event as soon as a web page including all of its assets are loaded
*/
function addLoadEvent(fn) {
if (typeof window.addEventListener != "undefined") {
window.addEventListener("load", fn, false);
}
else if (typeof document.addEventListener != "undefined") {
document.addEventListener("load", fn, false);
}
else if (typeof window.attachEvent != "undefined") {
window.attachEvent("onload", fn);
}
else if (typeof window.onload == "function") {
var fnOld = window.onload;
window.onload = function() {
fnOld();
fn();
};
}
else {
window.onload = fn;
}
}
/* Main function
- Will preferably execute onDomLoad, otherwise onload (as a fallback)
*/
function main() { // Static publishing only
var rl = regObjArr.length;
for (var i = 0; i < rl; i++) { // For each registered object element
var id = regObjArr[i].id;
if (ua.playerVersion[0] > 0) { // If no fp is installed, we let the object element do its job (show alternative content)
var obj = document.getElementById(id);
if (obj) {
regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
if (ua.webkit && ua.webkitVersion < 312) { // Older webkit engines ignore the object element's nested param elements
fixParams(obj);
}
}
else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion([6,0,65]) && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
showExpressInstall(regObjArr[i]);
}
else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
displayAltContent(obj);
}
}
}
createCSS("#" + id, "visibility:visible");
}
}
/* Fix nested param elements, which are ignored by older webkit engines
- This includes Safari up to and including version 1.2.2 on Mac OS 10.3
- Fall back to the proprietary embed element
*/
function fixParams(obj) {
var nestedObj = obj.getElementsByTagName("object")[0];
if (nestedObj) {
var e = document.createElement("embed");
var a = nestedObj.attributes;
if (a) {
var al = a.length;
for (var i = 0; i < al; i++) {
if (a[i].nodeName.toLowerCase() == "data") {
e.setAttribute("src", a[i].nodeValue);
}
else {
e.setAttribute(a[i].nodeName, a[i].nodeValue);
}
}
}
var c = nestedObj.childNodes;
if (c) {
var cl = c.length;
for (var j = 0; j < cl; j++) {
if (c[j].nodeType == 1 && c[j].nodeName.toLowerCase() == "param") {
e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
}
}
}
obj.parentNode.replaceChild(e, obj);
}
}
/* Fix hanging audio/video threads and force open sockets and NetConnections to disconnect
- Occurs when unloading a web page in IE using fp8+ and innerHTML/outerHTML
- Dynamic publishing only
*/
function fixObjectLeaks(id) {
if (ua.ie && ua.win && hasPlayerVersion([8,0,0])) {
window.attachEvent("onunload", function () {
var obj = document.getElementById(id);
for (var i in obj) {
if (typeof obj[i] == "function") {
obj[i] = function() {};
}
}
obj.parentNode.removeChild(obj);
});
}
}
/* Show the Adobe Express Install dialog
- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
*/
function showExpressInstall(regObj) {
isExpressInstallActive = true;
var obj = document.getElementById(regObj.id);
if (obj) {
if (regObj.altContentId) {
var ac = document.getElementById(regObj.altContentId);
if (ac) {
storedAltContent = ac;
}
}
else {
storedAltContent = abstractAltContent(obj);
}
if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
regObj.width = "310";
}
if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
regObj.height = "137";
}
var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn";
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var dt = document.title;
var fv = "MMredirectURL=" + window.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt;
var replaceId = regObj.id;
// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
if (ua.ie && ua.win && obj.readyState != 4) {
var newObj = document.createElement("div");
replaceId += "SWFObjectNew";
newObj.setAttribute("id", replaceId);
obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
obj.style.display = "none";
window.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
}
createSWF({ data:regObj.expressInstall, id:"SWFObjectExprInst", width:regObj.width, height:regObj.height }, { flashvars:fv }, replaceId);
}
}
/* Functions to abstract and display alternative content
*/
function displayAltContent(obj) {
if (ua.ie && ua.win && obj.readyState != 4) {
// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
var el = document.createElement("div");
obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
el.parentNode.replaceChild(abstractAltContent(obj), el);
obj.style.display = "none";
window.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
}
else {
obj.parentNode.replaceChild(abstractAltContent(obj), obj);
}
}
function abstractAltContent(obj) {
var ac = document.createElement("div");
if (ua.win && ua.ie) {
ac.innerHTML = obj.innerHTML;
}
else {
var nestedObj = obj.getElementsByTagName("object")[0];
if (nestedObj) {
var c = nestedObj.childNodes;
if (c) {
var cl = c.length;
for (var i = 0; i < cl; i++) {
if (!(c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param") && !(c[i].nodeType == 8)) {
ac.appendChild(c[i].cloneNode(true));
}
}
}
}
}
return ac;
}
/* Cross-browser dynamic SWF creation
*/
function createSWF(attObj, parObj, id) {
var r;
var el = document.getElementById(id);
if (typeof attObj.id == "undefined") { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
attObj.id = id;
}
if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
var att = "";
for (var i in attObj) {
if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
if (i == "data") {
parObj.movie = attObj[i];
}
else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
att += ' class="' + attObj[i] + '"';
}
else if (i != "classid") {
att += ' ' + i + '="' + attObj[i] + '"';
}
}
}
var par = "";
for (var j in parObj) {
if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
par += '<param name="' + j + '" value="' + parObj[j] + '" />';
}
}
el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
fixObjectLeaks(attObj.id); // This bug affects dynamic publishing only
r = document.getElementById(attObj.id);
}
else if (ua.webkit && ua.webkitVersion < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
var e = document.createElement("embed");
e.setAttribute("type", "application/x-shockwave-flash");
for (var k in attObj) {
if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
if (k == "data") {
e.setAttribute("src", attObj[k]);
}
else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
e.setAttribute("class", attObj[k]);
}
else if (k != "classid") { // Filter out IE specific attribute
e.setAttribute(k, attObj[k]);
}
}
}
for (var l in parObj) {
if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
if (l != "movie") { // Filter out IE specific param element
e.setAttribute(l, parObj[l]);
}
}
}
el.parentNode.replaceChild(e, el);
r = e;
}
else { // Well-behaving browsers
var o = document.createElement("object");
o.setAttribute("type", "application/x-shockwave-flash");
for (var m in attObj) {
if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
o.setAttribute("class", attObj[m]);
}
else if (m != "classid") { // Filter out IE specific attribute
o.setAttribute(m, attObj[m]);
}
}
}
for (var n in parObj) {
if (parObj[n] != Object.prototype[n] && n != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
createObjParam(o, n, parObj[n]);
}
}
el.parentNode.replaceChild(o, el);
r = o;
}
return r;
}
function createObjParam(el, pName, pValue) {
var p = document.createElement("param");
p.setAttribute("name", pName);
p.setAttribute("value", pValue);
el.appendChild(p);
}
function hasPlayerVersion(rv) {
return (ua.playerVersion[0] > rv[0] || (ua.playerVersion[0] == rv[0] && ua.playerVersion[1] > rv[1]) || (ua.playerVersion[0] == rv[0] && ua.playerVersion[1] == rv[1] && ua.playerVersion[2] >= rv[2])) ? true : false;
}
/* Cross-browser dynamic CSS creation
- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
*/
function createCSS(sel, decl) {
if (ua.ie && ua.mac) {
return;
}
var h = document.getElementsByTagName("head")[0];
var s = document.createElement("style");
s.setAttribute("type", "text/css");
s.setAttribute("media", "screen");
if (!(ua.ie && ua.win) && typeof document.createTextNode != "undefined") {
s.appendChild(document.createTextNode(sel + " {" + decl + "}"));
}
h.appendChild(s);
if (ua.ie && ua.win && typeof document.styleSheets != "undefined" && document.styleSheets.length > 0) {
var ls = document.styleSheets[document.styleSheets.length - 1];
if (typeof ls.addRule == "object") {
ls.addRule(sel, decl);
}
}
}
return {
/* Public API
- Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
*/
registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
if (!ua.w3cdom || !objectIdStr || !swfVersionStr) {
return;
}
var regObj = {};
regObj.id = objectIdStr;
var v = swfVersionStr.split(".");
regObj.swfVersion = [parseInt(v[0], 10), parseInt(v[1], 10), parseInt(v[2], 10)];
regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : false;
regObjArr[regObjArr.length] = regObj;
createCSS("#" + objectIdStr, "visibility:hidden");
},
getObjectById: function(objectIdStr) {
var r = null;
if (ua.w3cdom && isDomLoaded) {
var o = document.getElementById(objectIdStr);
if (o) {
var n = o.getElementsByTagName("object")[0];
if (!n || (n && typeof o.SetVariable != "undefined")) {
r = o;
}
else if (typeof n.SetVariable != "undefined") {
r = n;
}
}
}
return r;
},
embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
return;
}
widthStr += ""; // Auto-convert to string to make it idiot proof
heightStr += "";
if (hasPlayerVersion(swfVersionStr.split("."))) {
createCSS("#" + replaceElemIdStr, "visibility:hidden");
var att = (typeof attObj == "object") ? attObj : {};
att.data = swfUrlStr;
att.width = widthStr;
att.height = heightStr;
var par = (typeof parObj == "object") ? parObj : {};
if (typeof flashvarsObj == "object") {
for (var i in flashvarsObj) {
if (flashvarsObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
if (typeof par.flashvars != "undefined") {
par.flashvars += "&" + i + "=" + flashvarsObj[i];
}
else {
par.flashvars = i + "=" + flashvarsObj[i];
}
}
}
}
addDomLoadEvent(function() {
createSWF(att, par, replaceElemIdStr);
createCSS("#" + replaceElemIdStr, "visibility:visible");
});
}
else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion([6,0,65]) && (ua.win || ua.mac)) {
createCSS("#" + replaceElemIdStr, "visibility:hidden");
addDomLoadEvent(function() {
var regObj = {};
regObj.id = regObj.altContentId = replaceElemIdStr;
regObj.width = widthStr;
regObj.height = heightStr;
regObj.expressInstall = xiSwfUrlStr;
showExpressInstall(regObj);
createCSS("#" + replaceElemIdStr, "visibility:visible");
});
}
},
getFlashPlayerVersion: function() {
return { major:ua.playerVersion[0], minor:ua.playerVersion[1], release:ua.playerVersion[2] };
},
hasFlashPlayerVersion: function(versionStr) {
return hasPlayerVersion(versionStr.split("."));
},
createSWF: function(attObj, parObj, replaceElemIdStr) {
if (ua.w3cdom && isDomLoaded) {
return createSWF(attObj, parObj, replaceElemIdStr);
}
else {
return undefined;
}
},
createCSS: function(sel, decl) {
if (ua.w3cdom) {
createCSS(sel, decl);
}
},
addDomLoadEvent:addDomLoadEvent,
addLoadEvent:addLoadEvent,
getQueryParamValue: function(param) {
var q = document.location.search || document.location.hash;
if (param == null) {
return q;
}
if(q) {
var pairs = q.substring(1).split("&");
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return pairs[i].substring((pairs[i].indexOf("=") + 1));
}
}
}
return "";
},
// For internal usage only
expressInstallCallback: function() {
if (isExpressInstallActive && storedAltContent) {
var obj = document.getElementById("SWFObjectExprInst");
if (obj) {
obj.parentNode.replaceChild(storedAltContent, obj);
storedAltContent = null;
isExpressInstallActive = false;
}
}
}
};
}();
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/smart-image.js | JavaScript | art | 28,915 |
<?php
header('Content-Type: text/javascript; charset=UTF-8');
/**
* Resize images to a given size, and saving in a new file.
* resize.php?img=/relative/path/to/image.jpg&width=<pixels>&height=<pixels>[&to=/relative/path/to/newimage.jpg]
* relative to the base_dir given in config.inc.php
* This is pretty much just thumbs.php with some mods, I'm too lazy to do it properly
* @author $Author:ray $
* @version $Id:resizer.php 922 2007-12-30 14:35:46Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/Thumbnail.php');
function js_fail($message) { echo 'alert(\'' . $message . '\'); false'; exit; }
function js_success($resultFile) { echo '\'' . $resultFile . '\''; exit; }
//check for img parameter in the url
if(!isset($_GET['img']) || !isset($_GET['width']) || !isset($_GET['height']))
{
js_fail('Missing parameter.');
}
if($IMConfig['resize_files'] == FALSE)
{
js_success($_GET['img']);
}
$manager = new ImageManager($IMConfig);
//get the image and the full path to the image
$image = $_GET['img'];
$fullpath = Files::makeFile($manager->getImagesDir(),$image);
//not a file, so exit
if(!is_file($fullpath))
{
js_fail("File {$fullpath} does not exist.");
}
$imgInfo = @getImageSize($fullpath);
//Not an image, bail out.
if(!is_array($imgInfo))
{
js_fail("File {$fullpath} is not an image.");
}
if(!isset($_GET['to']))
{
$resized = $manager->getResizedName($fullpath,$_GET['width'],$_GET['height']);
$_GET['to'] = $manager->getResizedName($image,$_GET['width'],$_GET['height'], FALSE);
}
else
{
$resized = Files::makeFile($manager->getImagesDir(),$_GET['to']);
}
// Check to see if it already exists
if(is_file($resized))
{
// And is newer
if(filemtime($resized) >= filemtime($fullpath))
{
js_success($_GET['to']);
}
}
// resize (thumbnailer will do this for us just fine)
$thumbnailer = new Thumbnail($_GET['width'],$_GET['height']);
$thumbnailer->proportional = FALSE;
$thumbnailer->createThumbnail($fullpath, $resized);
// did it work?
if(is_file($resized))
{
js_success($_GET['to']);
}
else
{
js_fail("Resize Failed.");
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/resizer.php | PHP | art | 2,165 |
<?php
/**
* The main GUI for the ImageManager.
* @author $Author:ray $
* @version $Id:manager.php 987 2008-04-12 12:39:04Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('ddt.php');
require_once('Classes/ImageManager.php');
$manager = new ImageManager($IMConfig);
$dirs = $manager->getDirs();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Insert Image</title>
<script type="text/javascript">
// temporary. An ImageManager rewrite will take care of this kludge.
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
_resized_prefix = "<?php echo $IMConfig['resized_prefix']; ?>";
_resized_dir = "<?php echo $IMConfig['resized_dir']; ?>";
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php print $IMConfig['base_url'];?>assets/manager.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../popups/popup.js"></script>
<script type="text/javascript" src="assets/popup.js"></script>
<script type="text/javascript" src="../../modules/ColorPicker/ColorPicker.js"></script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
if(window.opener)
Xinha = HTMLArea = window.opener.Xinha;
var thumbdir = "<?php echo $IMConfig['thumbnail_dir']; ?>";
var base_url = "<?php echo $manager->getImagesURL(); ?>";
/*]]>*/
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/manager.js"></script>
<?php
if(!$IMConfig['show_full_options'])
{
?>
<style type="text/css">
.fullOptions { visibility:hidden; }
</style>
<?php
}
?>
<script type="text/javascript">
function switchChooser(toChooserPanel)
{
var ourPanel = document.getElementById(toChooserPanel);
if(!ourPanel) return false; // Can't change, doesn't exist.
// hide all panels
var d = document.getElementById('chooserFieldset').getElementsByTagName('div');
for(i = 0; i < d.length; i++)
{
if(d[i].className.match(/chooserPanel/))
d[i].style.display = 'none';
}
// show ours
ourPanel.style.display = 'block';
}
</script>
</head>
<body>
<form action="<?php print $IMConfig['backend_url'] ?>" id="uploadForm" method="post" enctype="multipart/form-data">
<input type="hidden" name="__plugin" value="ImageManager" />
<input type="hidden" name="__function" value="images" />
<fieldset id="chooserFieldset">
<legend>
Choose From:
<select onchange="switchChooser(this.options[this.selectedIndex].value)">
<?php
if($IMConfig['Local'])
{
?>
<option value="picturesChooser">This Server</option>
<?php
}
?>
<?php
if($IMConfig['YouTube'])
{
?>
<option value="youtubeChooser">YouTube Videos</option>
<?php
}
?>
<?php
if($IMConfig['Flickr'])
{
?>
<option value="flickrChooser">Flickr Pictures</option>
<?php
}
?>
</select>
</legend>
<?php
if($IMConfig['Local'])
{
?>
<div id="picturesChooser" class="chooserPanel">
<table width="100%">
<tr>
<th><label for="dirPath">Directory</label></th>
<td>
<select name="dir" class="dirWidth" id="dirPath" onchange="updateDir(this)">
<option value="/">/</option>
<?php
foreach($dirs as $relative=>$fullpath)
{
?>
<option value="<?php echo rawurlencode($relative); ?>"><?php echo $relative; ?></option>
<?php
}
?>
</select>
</td>
<td>
<a href="#" onclick="javascript: goUpDir();" title="Directory Up"><img src="<?php print $IMConfig['base_url']; ?>img/btnFolderUp.gif" height="15" width="15" alt="Directory Up" /></a>
<?php
if($IMConfig['safe_mode'] == false && $IMConfig['allow_new_dir'])
{
?>
<a href="#" onclick="newFolder();" title="New Folder"><img src="<?php print $IMConfig['base_url']; ?>img/btnFolderNew.gif" height="15" width="15" alt="New Folder" /></a>
<?php
}
?>
</td>
</tr>
<?php
if($IMConfig['allow_upload'] == TRUE)
{
?>
<tr>
<th style="text-align: left;">Upload:</th>
<td colspan="2">
<input type="file" name="upload" id="upload" />
<input name="Upload" type="submit" id="Upload" value="Upload" onclick="doUpload();" />
</td>
</tr>
<?php
}
?>
</table>
<div id="messages" style="display: none;"><span id="message"></span><img src="<?php print $IMConfig['base_url']; ?>img/dots.gif" width="22" height="12" alt="..." /></div>
<iframe src="<?php print $IMConfig['backend_url']; ?>__function=images" name="imgManager" id="imgManager" class="imageFrame" scrolling="auto" title="Image Selection" frameborder="0"></iframe>
</div>
<?php
}
?>
<?php
if($IMConfig['YouTube'])
{
?>
<div id="youtubeChooser" style="display:none" class="chooserPanel">
<table width="100%">
<tr>
<th><labelfor="ytUsername">YouTube Username</label></th>
<td>
<input type="text" name="ytUsername" id="ytUsername" />
</td>
<th><labelfor="ytSearch">Keyword</label></th>
<td>
<input type="text" name="ytSearch" id="ytSearch" />
</td>
<td>
<input type="button" value="Search" onclick="document.getElementById('ytManager').src='<?php print $IMConfig['backend_url']; ?>__function=youtube&ytSearch='+document.getElementById('ytSearch').value+'&ytUsername='+document.getElementById('ytUsername').value;" />
</td>
</tr>
</table>
<div id="messages" style="display: none;"><span id="message"></span><img SRC="<?php print $IMConfig['base_url']; ?>img/dots.gif" width="22" height="12" alt="..." /></div>
<iframe src="<?php print $IMConfig['backend_url']; ?>__function=youtube" name="ytManager" id="ytManager" class="imageFrame" scrolling="auto" title="YouTube Selection" frameborder="0"></iframe>
</div>
<?php
}
?>
<?php
if($IMConfig['Flickr'])
{
require_once('Classes/Flickr.php');
$lics = flickr_get_license_id_by_usage();
?>
<div id="flickrChooser" style="display:none" class="chooserPanel">
<script type="text/javascript">
function flickr_go()
{
var u = '<?php print $IMConfig['backend_url']; ?>__function=flickr';
u += '&flkSearch=' + encodeURIComponent(document.getElementById('flkSearch').value);
u += '&flkUsername='+ encodeURIComponent(document.getElementById('flkUsername').value);
u += '&flkLicense=' + encodeURIComponent( document.getElementById('flkLicense').options[document.getElementById('flkLicense').selectedIndex].value );
document.getElementById('flkManager').src= u;
}
</script>
<table width="100%">
<tr>
<th><labelfor="ytUsername">Flickr Username/Email</label></th>
<td>
<input type="text" name="flkUsername" id="flkUsername" />
</td>
<th><labelfor="ytSearch">Keyword</label></th>
<td>
<input type="text" name="flkSearch" id="flkSearch" />
</td>
<td>
<input type="button" value="Search" onclick="flickr_go();" />
</td>
</tr>
<tr>
<th>Usage Restriction:</th>
<td colspan="3">
<select name="flkLicense" id="flkLicense" onchange="flickr_go();">
<?php
foreach($lics as $usage => $licid)
{
?>
<option value="<?php echo $licid ?>" <?php if(flickr_is_default_license($licid)) echo 'selected="selected"' ?>> <?php echo $licid ?> <?php echo htmlspecialchars($usage) ?></li>
<?php
}
?>
</select>
</td>
<td><a href="http://flickr.com/" target="_blank">flickr.com</a></td>
</tr>
</table>
<div id="messages" style="display: none;"><span id="message"></span><img SRC="<?php print $IMConfig['base_url']; ?>img/dots.gif" width="22" height="12" alt="..." /></div>
<iframe src="<?php print $IMConfig['backend_url']; ?>__function=flickr" name="flkManager" id="flkManager" class="imageFrame" scrolling="auto" title="Flickr Selection" frameborder="0"></iframe>
</div>
<?php
}
?>
</fieldset>
<!-- image properties -->
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<th style="text-align: left;">Description:</th>
<td colspan="6">
<input type="text" id="f_alt" style="width:95%"/>
</td>
<td rowspan="4" width="100" height="100" style="vertical-align: middle;" style="padding:4px;background-color:#CCC;border:1px inset;">
<img src="" id="f_preview" />
</td>
</tr>
<tr>
<th style="text-align: left;">Width:</th>
<td >
<input id="f_width" type="text" name="f_width" size="4" onchange="javascript:checkConstrains('width');" />
</td>
<td rowspan="2">
<div style="position:relative">
<img src="<?php print $IMConfig['base_url']; ?>img/locked.gif" id="imgLock" width="25" height="32" alt="Constrained Proportions" style="vertical-align: middle;" /><input type="checkbox" id="constrain_prop" checked="checked" onclick="javascript:toggleConstrains(this);" style="position:absolute;top:8px;left:0px;" value="on" />
</div>
</td>
<th style="text-align: left;" class="fullOptions">Margin:</th>
<td colspan="3" class="fullOptions">
<?php
if(@$IMConfig['UseHSpaceVSpace'])
{
?>
<input name="f_hspace" type="text" id="f_hspace" size="3" />
x <input name="f_vspace" type="text" id="f_vspace" size="3" />
<?php
}
else
{
?>
<input name="f_margin" type="text" id="f_margin" size="3" />
<?php
}
?>
px </td>
</tr>
<tr>
<th style="text-align: left;">Height:</th>
<td>
<input name="f_height" type="text" id="f_height" size="4" />
</td>
<th style="text-align: left;" class="fullOptions">Padding:</th>
<td class="fullOptions">
<input name="f_padding" type="text" id="f_padding" size="3" />
px </td>
<th style="text-align: left;" class="fullOptions">Color:</th>
<td class="fullOptions">
<input name="f_backgroundColor" type="text" id="f_backgroundColor" size="7" />
</td>
</tr>
<tr class="fullOptions">
<th style="text-align: left;">Alignment:</th>
<td colspan="2">
<select size="1" id="f_align" title="Positioning of this image">
<option value="" >Not set</option>
<option value="left" >Left</option>
<option value="right" >Right</option>
<option value="texttop" >Texttop</option>
<option value="absmiddle" >Absmiddle</option>
<option value="baseline" selected="selected" >Baseline</option>
<option value="absbottom" >Absbottom</option>
<option value="bottom" >Bottom</option>
<option value="middle" >Middle</option>
<option value="top" >Top</option>
</select>
</td>
<th style="text-align: left;">Border:</th>
<td>
<input name="f_border" type="text" id="f_border" size="3" />
px </td>
<th style="text-align: left;">Color:</th>
<td>
<input name="f_borderColor" type="text" id="f_borderColor" size="7" />
</td>
</tr>
</table>
<div style="text-align: right;">
<hr />
<button type="button" class="buttons" onclick="return refresh();">Refresh</button>
<button type="button" class="buttons" onclick="return onOK();">OK</button>
<button type="button" class="buttons" onclick="return onCancel();">Cancel</button>
</div>
<!--// image properties -->
<input type="hidden" id="orginal_width" />
<input type="hidden" id="orginal_height" />
<input type="hidden" id="f_url" class="largelWidth" value="" />
</form>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/manager.php | PHP | art | 12,826 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>New Folder</title>
<script type="text/javascript" src="../../popups/popup.js"></script>
<style type="text/css">
/*<![CDATA[*/
html, body { background-color: ButtonFace; color: ButtonText; font: 11px Tahoma,Verdana,sans-serif; margin: 0; padding: 0;}
body { padding: 5px; }
.title { background-color: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; border-bottom: 1px solid black; letter-spacing: 2px;}
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
.buttons { width: 70px; text-align: center; }
form { padding: 0px; margin: 0;}
form .elements{
padding: 10px; text-align: center;
}
/*]]>*/
</style>
<script type="text/javascript" src="assets/popup.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
window.resizeTo(300, 160);
if(window.opener)
HTMLArea = window.opener.HTMLArea;
init = function ()
{
__dlg_init();
__dlg_translate('ImageManager');
document.getElementById("f_foldername").focus();
};
function onCancel()
{
__dlg_close(null);
return false;
}
function onOK()
{
// pass data back to the calling window
var fields = ["f_foldername"];
var param = new Object();
for (var i in fields) {
var id = fields[i];
var el = document.getElementById(id);
param[id] = el.value;
}
__dlg_close(param);
return false;
}
function addEvent(obj, evType, fn)
{
if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; }
else { return false; }
}
addEvent(window, 'load', init);
//-->
</script>
</head>
<body >
<div class="title">New Folder</div>
<form action="">
<div class="elements">
<label for="f_foldername">Folder Name:</label>
<input type="text" id="f_foldername" />
</div>
<div style="text-align: right;">
<hr />
<button type="button" class="buttons" onclick="return onOK();">OK</button>
<button type="button" class="buttons" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/newFolder.html | HTML | art | 2,297 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/JSON.php | PHP | art | 34,013 |
<?php
/** If there is no json_encode() or json_decode() function already in existance (recent PHP will provide native)
* use the PEAR::JSON class to do the job.
*
*/
if(!function_exists('json_decode'))
{
function &get_json()
{
global $JSON_Singleton;
if(!isset($JSON_Singleton))
{
require_once(dirname(__FILE__) . '/JSON.php');
$JSON_Singleton = new Services_JSON();
}
return $JSON_Singleton;
}
function json_decode($str, $loose = FALSE)
{
$json =& get_json();
if($loose)
{
$json->use = SERVICES_JSON_LOOSE_TYPE;
}
else
{
$json->use = 0;
}
return $json->decode($str);
}
function json_encode($var, $loose = FALSE)
{
$json =& get_json();
if($loose)
{
$json->use = SERVICES_JSON_LOOSE_TYPE;
}
else
{
$json->use = 0;
}
return $json->encode($var);
}
}
?> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/JSON_Compat.php | PHP | art | 1,027 |
<?php
/***********************************************************************
** Title.........: ImageMagick Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: IM.php
** Last changed..: 30 Aug 2003
** Notes.........: Orginal is from PEAR
**/
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
// $Id:IM.php 937 2008-01-20 23:13:25Z ray $
//
// Image Transformation interface using command line ImageMagick
//
require_once "../ImageManager/Classes/Transform.php";
Class Image_Transform_Driver_IM extends Image_Transform
{
/**
* associative array commands to be executed
* @var array
*/
var $command = array();
/**
*
*
*/
function Image_Transform_Driver_IM()
{
return true;
} // End Image_IM
/**
* Load image
*
* @param string filename
*
* @return mixed none or a PEAR error object on error
* @see PEAR::isError()
*/
function load($image)
{
$this->uid = md5($_SERVER['REMOTE_ADDR']);
/*if (!file_exists($image)) {
return PEAR::raiseError('The image file ' . $image . ' does\'t exist', true);
}*/
$this->image = $image;
$this->_get_image_details($image);
} // End load
/**
* Resize Action
*
* @param int new_x new width
* @param int new_y new height
*
* @return none
* @see PEAR::isError()
*/
function _resize($new_x, $new_y)
{
/*if (isset($this->command['resize'])) {
return PEAR::raiseError("You cannot scale or resize an image more than once without calling save or display", true);
}*/
$this->command['resize'] = "-geometry ${new_x}x${new_y}!";
$this->new_x = $new_x;
$this->new_y = $new_y;
} // End resize
/**
* Crop the image
*
* @param int $crop_x left column of the image
* @param int $crop_y top row of the image
* @param int $crop_width new cropped image width
* @param int $crop_height new cropped image height
*/
function crop($crop_x, $crop_y, $crop_width, $crop_height)
{
$this->command['crop'] = "-crop {$crop_width}x{$crop_height}+{$crop_x}+{$crop_y}";
}
/**
* Flip the image horizontally or vertically
*
* @param boolean $horizontal true if horizontal flip, vertical otherwise
*/
function flip($horizontal)
{
if($horizontal)
$this->command['flop'] = "-flop";
else
$this->command['flip'] = "-flip";
}
/**
* rotate
*
* @param int angle rotation angle
* @param array options no option allowed
*
*/
function rotate($angle, $options=null)
{
if ('-' == $angle{0}) {
$angle = 360 - substr($angle, 1);
}
$this->command['rotate'] = "-rotate $angle";
} // End rotate
/**
* addText
*
* @param array options Array contains options
* array(
* 'text' The string to draw
* 'x' Horizontal position
* 'y' Vertical Position
* 'Color' Font color
* 'font' Font to be used
* 'size' Size of the fonts in pixel
* 'resize_first' Tell if the image has to be resized
* before drawing the text
* )
*
* @return none
* @see PEAR::isError()
*/
function addText($params)
{
$default_params = array(
'text' => 'This is Text',
'x' => 10,
'y' => 20,
'color' => 'red',
'font' => 'Arial.ttf',
'resize_first' => false // Carry out the scaling of the image before annotation?
);
$params = array_merge($default_params, $params);
extract($params);
if (true === $resize_first) {
// Set the key so that this will be the last item in the array
$key = 'ztext';
} else {
$key = 'text';
}
$this->command[$key] = "-font $font -fill $color -draw 'text $x,$y \"$text\"'";
// Producing error: gs: not found gs: not found convert: Postscript delegate failed [No such file or directory].
} // End addText
/**
* Adjust the image gamma
*
* @param float $outputgamma
*
* @return none
*/
function gamma($outputgamma=1.0) {
$this->command['gamma'] = "-gamma $outputgamma";
}
function reduce_colors($number = 256)
{
$this->command['colors'] = "-colors $number";
}
/**
* Save the image file
*
* @param string $filename the name of the file to write to
* @param quality $quality image dpi, default=75
* @param string $type (JPG,PNG...)
*
* @return none
*/
function save($filename, $type='', $quality = 85)
{
$type == '' ? $this->type : $type;
$cmd = '' . IMAGE_TRANSFORM_LIB_PATH . 'convert ';
$cmd .= implode(' ', $this->command) . " -quality $quality ";
$cmd .= '"'.($this->image) . '" "' . ($filename) . '"';
//$cmd = str_replace('/', '\\', $cmd);
//echo($cmd.'<br>');
exec($cmd,$retval);
//error_log('IM '.print_r($retval,true));
} // End save
/**
* Display image without saving and lose changes
*
* @param string type (JPG,PNG...);
* @param int quality 75
*
* @return none
*/
function display($type = '', $quality = 75)
{
if ($type == '') {
header('Content-type: image/' . $this->type);
passthru(IMAGE_TRANSFORM_LIB_PATH . ' ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($this->type) . ":-");
} else {
header('Content-type: image/' . $type);
passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($type) . ":-");
}
}
/**
* Destroy image handle
*
* @return none
*/
function free()
{
return true;
}
} // End class ImageIM
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/IM.php | PHP | art | 7,986 |
<?php
/***********************************************************************
** Title.........: NetPBM Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: NetPBM.php
** Last changed..: 30 Aug 2003
** Notes.........: Orginal is from PEAR
**/
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
// $Id:NetPBM.php 709 2007-01-30 23:22:04Z ray $
//
// Image Transformation interface using command line NetPBM
require_once "../ImageManager/Classes/Transform.php";
Class Image_Transform_Driver_NetPBM extends Image_Transform
{
/**
* associative array commands to be executed
* @var array
*/
var $command = array();
/**
* Class Constructor
*/
function Image_Transform_Driver_NetPBM()
{
$this->uid = md5($_SERVER['REMOTE_ADDR']);
return true;
} // End function Image_NetPBM
/**
* Load image
*
* @param string filename
*
* @return mixed none or a PEAR error object on error
* @see PEAR::isError()
*/
function load($image)
{
//echo $image;
$this->image = $image;
$this->_get_image_details($image);
} // End load
/**
* Resizes the image
*
* @return none
* @see PEAR::isError()
*/
function _resize($new_x, $new_y)
{
// there's no technical reason why resize can't be called multiple
// times...it's just silly to do so
$this->command[] = IMAGE_TRANSFORM_LIB_PATH .
"pnmscale -width $new_x -height $new_y";
$this->_set_new_x($new_x);
$this->_set_new_y($new_y);
} // End resize
/**
* Crop the image
*
* @param int $crop_x left column of the image
* @param int $crop_y top row of the image
* @param int $crop_width new cropped image width
* @param int $crop_height new cropped image height
*/
function crop($crop_x, $crop_y, $crop_width, $crop_height)
{
$this->command[] = IMAGE_TRANSFORM_LIB_PATH .
"pnmcut -left $crop_x -top $crop_y -width $crop_width -height $crop_height";
}
/**
* Rotates the image
*
* @param int $angle The angle to rotate the image through
*/
function rotate($angle)
{
$angle = -1*floatval($angle);
if($angle > 90)
{
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias 90";
$this->rotate(-1*($angle-90));
}
else if ($angle < -90)
{
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias -90";
$this->rotate(-1*($angle+90));
}
else
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias $angle";
} // End rotate
/**
* Flip the image horizontally or vertically
*
* @param boolean $horizontal true if horizontal flip, vertical otherwise
*/
function flip($horizontal)
{
if($horizontal)
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -lr";
else
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -tb";
}
/**
* Adjust the image gamma
*
* @param float $outputgamma
*
* @return none
*/
function gamma($outputgamma = 1.0) {
$this->command[13] = IMAGE_TRANSFORM_LIB_PATH . "pnmgamma $outputgamma";
}
/**
* adds text to an image
*
* @param array options Array contains options
* array(
* 'text' // The string to draw
* 'x' // Horizontal position
* 'y' // Vertical Position
* 'Color' // Font color
* 'font' // Font to be used
* 'size' // Size of the fonts in pixel
* 'resize_first' // Tell if the image has to be resized
* // before drawing the text
* )
*
* @return none
*/
function addText($params)
{
$default_params = array('text' => 'This is Text',
'x' => 10,
'y' => 20,
'color' => 'red',
'font' => 'Arial.ttf',
'size' => '12',
'angle' => 0,
'resize_first' => false);
// we ignore 'resize_first' since the more logical approach would be
// for the user to just call $this->_resize() _first_ ;)
extract(array_merge($default_params, $params));
$this->command[] = "ppmlabel -angle $angle -colour $color -size "
."$size -x $x -y ".$y+$size." -text \"$text\"";
} // End addText
function _postProcess($type, $quality, $save_type)
{
$type = is_null($type) || $type==''? $this->type : $type;
$save_type = is_null($save_type) || $save_type==''? $this->type : $save_type;
//echo "TYPE:". $this->type;
array_unshift($this->command, IMAGE_TRANSFORM_LIB_PATH
. $type.'topnm '. $this->image);
$arg = '';
switch(strtolower($save_type)){
case 'gif':
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmquant 256";
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type";
break;
case 'jpg':
case 'jpeg':
$arg = "--quality=$quality";
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type $arg";
break;
default:
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmto$save_type $arg";
break;
} // switch
return implode('|', $this->command);
}
/**
* Save the image file
*
* @param string $filename the name of the file to write to
* @param string $type (jpeg,png...);
* @param int $quality 75
* @return none
*/
function save($filename, $type=null, $quality = 85)
{
$cmd = $this->_postProcess('', $quality, $type) . ">$filename";
//if we have windows server
if(isset($_ENV['OS']) && eregi('window',$_ENV['OS']))
$cmd = ereg_replace('/','\\',$cmd);
//echo $cmd."##";
$output = system($cmd);
error_log('NETPBM: '.$cmd);
//error_log($output);
$this->command = array();
} // End save
/**
* Display image without saving and lose changes
*
* @param string $type (jpeg,png...);
* @param int $quality 75
* @return none
*/
function display($type = null, $quality = 75)
{
header('Content-type: image/' . $type);
$cmd = $this->_postProcess($type, $quality);
passthru($cmd);
$this->command = array();
}
/**
* Destroy image handle
*
* @return none
*/
function free()
{
// there is no image handle here
return true;
}
} // End class NetPBM
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/NetPBM.php | PHP | art | 8,608 |
<?php
/**
* File Utilities.
* @author $Author:koto $
* @version $Id:Files.php 841 2007-05-27 13:31:51Z koto $
* @package ImageManager
*/
define('FILE_ERROR_NO_SOURCE', 100);
define('FILE_ERROR_COPY_FAILED', 101);
define('FILE_ERROR_DST_DIR_FAILED', 102);
define('FILE_COPY_OK', 103);
define('FILE_ERROR_DST_DIR_EXIST', 104);
/**
* File Utilities
* @author $Author:koto $
* @version $Id:Files.php 841 2007-05-27 13:31:51Z koto $
* @package ImageManager
* @subpackage files
*/
class Files
{
/**
* Copy a file from source to destination. If unique == true, then if
* the destination exists, it will be renamed by appending an increamenting
* counting number.
* @param string $source where the file is from, full path to the files required
* @param string $destination_file name of the new file, just the filename
* @param string $destination_dir where the files, just the destination dir,
* e.g., /www/html/gallery/
* @param boolean $unique create unique destination file if true.
* @return string the new copied filename, else error if anything goes bad.
*/
function copyFile($source, $destination_dir, $destination_file, $unique=true)
{
if(!is_uploaded_file($source) && !(file_exists($source) && is_file($source)))
return FILE_ERROR_NO_SOURCE;
$destination_dir = Files::fixPath($destination_dir);
if(!is_dir($destination_dir))
Return FILE_ERROR_DST_DIR_FAILED;
$filename = Files::escape($destination_file);
if($unique)
{
$dotIndex = strrpos($destination_file, '.');
$ext = '';
if(is_int($dotIndex))
{
$ext = substr($destination_file, $dotIndex);
$base = substr($destination_file, 0, $dotIndex);
}
$counter = 0;
while(is_file($destination_dir.$filename))
{
$counter++;
$filename = $base.'_'.$counter.$ext;
}
}
if (!copy($source, $destination_dir.$filename))
return FILE_ERROR_COPY_FAILED;
//verify that it copied, new file must exists
if (is_file($destination_dir.$filename))
Return $filename;
else
return FILE_ERROR_COPY_FAILED;
}
/**
* Create a new folder.
* @param string $newFolder specifiy the full path of the new folder.
* @return boolean true if the new folder is created, false otherwise.
*/
function createFolder($newFolder)
{
mkdir ($newFolder, 0777);
return chmod($newFolder, 0777);
}
/**
* Escape the filenames, any non-word characters will be
* replaced by an underscore.
* @param string $filename the orginal filename
* @return string the escaped safe filename
*/
function escape($filename)
{
Return preg_replace('/[^\w\._]/', '_', $filename);
}
/**
* Delete a file.
* @param string $file file to be deleted
* @return boolean true if deleted, false otherwise.
*/
function delFile($file)
{
if(is_file($file))
Return unlink($file);
else
Return false;
}
/**
* Delete folder(s), can delete recursively.
* @param string $folder the folder to be deleted.
* @param boolean $recursive if true, all files and sub-directories
* are delete. If false, tries to delete the folder, can throw
* error if the directory is not empty.
* @return boolean true if deleted.
*/
function delFolder($folder, $recursive=false)
{
$deleted = true;
if($recursive)
{
$d = dir($folder);
while (false !== ($entry = $d->read()))
{
if ($entry != '.' && $entry != '..')
{
$obj = Files::fixPath($folder).$entry;
//var_dump($obj);
if (is_file($obj))
{
$deleted &= Files::delFile($obj);
}
else if(is_dir($obj))
{
$deleted &= Files::delFolder($obj, $recursive);
}
}
}
$d->close();
}
//$folder= $folder.'/thumbs';
//var_dump($folder);
if(is_dir($folder))
$deleted &= rmdir($folder);
else
$deleted &= false;
Return $deleted;
}
/**
* Append a / to the path if required.
* @param string $path the path
* @return string path with trailing /
*/
function fixPath($path)
{
//append a slash to the path if it doesn't exists.
if(!(substr($path,-1) == '/'))
$path .= '/';
Return $path;
}
/**
* Concat two paths together. Basically $pathA+$pathB
* @param string $pathA path one
* @param string $pathB path two
* @return string a trailing slash combinded path.
*/
function makePath($pathA, $pathB)
{
$pathA = Files::fixPath($pathA);
if(substr($pathB,0,1)=='/')
$pathB = substr($pathB,1);
Return Files::fixPath($pathA.$pathB);
}
/**
* Similar to makePath, but the second parameter
* is not only a path, it may contain say a file ending.
* @param string $pathA the leading path
* @param string $pathB the ending path with file
* @return string combined file path.
*/
function makeFile($pathA, $pathB)
{
$pathA = Files::fixPath($pathA);
if(substr($pathB,0,1)=='/')
$pathB = substr($pathB,1);
Return $pathA.$pathB;
}
/**
* Format the file size, limits to Mb.
* @param int $size the raw filesize
* @return string formated file size.
*/
function formatSize($size)
{
if($size < 1024)
return $size.' bytes';
else if($size >= 1024 && $size < 1024*1024)
return sprintf('%01.2f',$size/1024.0).' KB';
else
return sprintf('%01.2f',$size/(1024.0*1024)).' MB';
}
/**
* Returns size of a directory, with all file & subdirectory
* sizes added up
* @param string dir path
* @return int
*/
function dirSize($dirName = '.')
{
$dir = dir($dirName);
$size = 0;
while ($file = $dir->read()) {
if ($file != '.' && $file != '..')
{
if (is_dir("$dirName$file"))
{
$size += Files::dirSize($dirName . '/' . $file);
}
else
{
$size += filesize($dirName . '/' . $file);
}
}
}
$dir->close();
return $size;
}
/**
* Renames file, preserving its directory and extension
* @param string $oldPath path to the old existing file
* @param string new filename (just the name, without path or extension)
* @author Krzysztof Kotowicz <koto@webworkers.pl>
*/
function renameFile($oldPath, $newName) {
if(!(file_exists($oldPath) && is_file($oldPath)))
return FILE_ERROR_NO_SOURCE;
$oldFileParts = pathinfo($oldPath);
$newPath = $oldFileParts['dirname'] . '/'
. $newName
. (!empty($oldFileParts['extension']) ? '.' . $oldFileParts['extension'] : '');
if (file_exists($newPath))
return false;
if (!rename($oldPath, $newPath))
return FILE_ERROR_COPY_FAILED;
}
function rename ($oldPath,$newPath)
{
if(!(is_dir($oldPath) || is_file($oldPath)))
return FILE_ERROR_NO_SOURCE;
if (file_exists($newPath))
return FILE_ERROR_DST_DIR_EXIST;
$ret = rename($oldPath, $newPath);
if (!$ret)
return FILE_ERROR_COPY_FAILED;
else return FILE_COPY_OK;
}
/**
* copy a directory and all subdirectories and files (recursive)
* @author SBoisvert at Don'tSpamMe dot Bryxal dot ca (adapted from php.net)
* @author Raimund Meyer
* @param string base path
* @param string source directory
* @param string destination directory
* @param bool overwrite existing files
*
* @return mixed bool true on pass, number on fail
*/
function copyDir($basePath, $source, $dest, $overwrite = false)
{
if(!is_dir($basePath . $dest))
{
if (!@mkdir($basePath . $dest)) return FILE_ERROR_DST_DIR_FAILED;
}
if($handle = opendir($basePath . $source))
{ // if the folder exploration is sucsessful, continue
while( ($file = readdir($handle)) !== false)
{ // as long as storing the next file to $file is successful, continue
if($file != '.' && $file != '..')
{
$path = $source . '/' . $file;
if(is_file($basePath . $path))
{
/*if(!is_file($basePath . $dest . '/' . $file) || $overwrite)
{
if(!@copy($basePath . $path, $basePath . $dest . '/' . $file))
{
return FILE_ERROR_COPY_FAILED;
}
}*/
Files::copyFile($basePath . $path, $basePath . $dest . '/', $file, true);
}
elseif(is_dir($basePath . $path))
{
if(!is_dir($basePath . $dest . '/' . $file))
{
mkdir($basePath . $dest . '/' . $file); // make subdirectory before subdirectory is copied
Files::copyDir($basePath, $path, $dest . '/' . $file, $overwrite); //recurse!
}
}
}
}
closedir($handle);
}
return true;
}
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/Files.php | PHP | art | 8,341 |
<?php
/**
* Create thumbnails.
* @author $Author:ray $
* @version $Id:Thumbnail.php 709 2007-01-30 23:22:04Z ray $
* @package ImageManager
*/
require_once('../ImageManager/Classes/Transform.php');
/**
* Thumbnail creation
* @author $Author:ray $
* @version $Id:Thumbnail.php 709 2007-01-30 23:22:04Z ray $
* @package ImageManager
* @subpackage Images
*/
class Thumbnail
{
/**
* Graphics driver, GD, NetPBM or ImageMagick.
*/
var $driver;
/**
* Thumbnail default width.
*/
var $width = 96;
/**
* Thumbnail default height.
*/
var $height = 96;
/**
* Thumbnail default JPEG quality.
*/
var $quality = 85;
/**
* Thumbnail is proportional
*/
var $proportional = true;
/**
* Default image type is JPEG.
*/
var $type = 'jpeg';
/**
* Create a new Thumbnail instance.
* @param int $width thumbnail width
* @param int $height thumbnail height
*/
function Thumbnail($width=96, $height=96)
{
$this->driver = Image_Transform::factory(IMAGE_CLASS);
$this->width = $width;
$this->height = $height;
}
/**
* Create a thumbnail.
* @param string $file the image for the thumbnail
* @param string $thumbnail if not null, the thumbnail will be saved
* as this parameter value.
* @return boolean true if thumbnail is created, false otherwise
*/
function createThumbnail($file, $thumbnail=null)
{
if(!is_file($file))
Return false;
//error_log('Creating Thumbs: '.$file);
$this->driver->load($file);
if($this->proportional)
{
$width = $this->driver->img_x;
$height = $this->driver->img_y;
if ($width > $height)
$this->height = intval($this->width/$width*$height);
else if ($height > $width)
$this->width = intval($this->height/$height*$width);
}
$this->driver->resize($this->width, $this->height);
if(is_null($thumbnail))
$this->save($file);
else
$this->save($thumbnail);
$this->free();
if(is_file($thumbnail))
Return true;
else
Return false;
}
/**
* Save the thumbnail file.
* @param string $file file name to be saved as.
*/
function save($file)
{
$this->driver->save($file);
}
/**
* Free up the graphic driver resources.
*/
function free()
{
$this->driver->free();
}
}
?> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/Thumbnail.php | PHP | art | 2,368 |
<?php
/**
* Simple functions to access the flickr API (yes I know this is the "Classes" directory and this isn't a class).
* @author $Author: gogo $
* @version $Id: images.php 877 2007-08-12 15:50:03Z gogo $
* @package ImageManager
*/
require_once(dirname(__FILE__) . '/JSON_Compat.php');
function flickr_request($method, $params = array())
{
global $IMConfig;
$flickr = "http://api.flickr.com/services/rest/?method={$method}&format=json&nojsoncallback=1&api_key=" . $IMConfig['Flickr']['Key'];
foreach($params as $k => $v)
{
$flickr .= "&{$k}=".rawurlencode($v);
}
$feed = file_get_contents($flickr);
if($feed)
{
$feed = json_decode($feed, true);
if(!$feed || !isset($feed['stat']) || ($feed['stat'] != 'ok'))
{
print_r($params);
trigger_error($feed['message'], E_USER_ERROR);
return FALSE;
}
}
else
{
trigger_error('Null response from Flickr', E_USER_ERROR);
}
return $feed;
}
function flickr_get_licenses()
{
static $lics;
if(!$lics)
{
if(0 && isset($_SESSION['flickr_licenses']))
{
$lics = $_SESSION['flickr_licenses'];
return $lics;
}
$lics = array();
$x = flickr_request('flickr.photos.licenses.getInfo');
$x = $x['licenses']['license'];
foreach($x as $l)
{
// Add out own descriptive "usage" text
switch($l['url'])
{
case 'http://creativecommons.org/licenses/by/2.0/':
case 'http://creativecommons.org/licenses/by-sa/2.0/':
$l['usage'] = 'Attribution Required';
break;
case 'http://creativecommons.org/licenses/by-nd/2.0/':
$l['usage'] = 'Attribution Required, No Modifications';
break;
case 'http://creativecommons.org/licenses/by-nc-nd/2.0/':
$l['usage'] = 'Non Commercial ONLY, Attribution Required, No Modifications';
break;
case 'http://creativecommons.org/licenses/by-nc/2.0/':
case 'http://creativecommons.org/licenses/by-nc-sa/2.0/':
$l['usage'] = 'Non Commercial ONLY, Attribution Required';
break;
default:
$l['usage'] = 'Use ONLY Permitted With Written Permission';
break;
}
// And our own identifier
switch($l['url'])
{
case 'http://creativecommons.org/licenses/by/2.0/':
$l['x-id'] = 'cc2';
break;
case 'http://creativecommons.org/licenses/by-sa/2.0/':
$l['x-id'] = 'ccsa2';
break;
case 'http://creativecommons.org/licenses/by-nd/2.0/':
$l['x-id'] = 'ccnd2';
break;
case 'http://creativecommons.org/licenses/by-nc-nd/2.0/':
$l['x-id'] = 'ccncnd2';
break;
case 'http://creativecommons.org/licenses/by-nc/2.0/':
$l['x-id'] = 'ccnc2';
break;
case 'http://creativecommons.org/licenses/by-nc-sa/2.0/':
$l['x-id'] = 'ccncsa2';
break;
default:
$l['x-id'] = '';
break;
}
$lics[$l['id']] = $l;
}
$_SESSION['flickr_licenses'] = $lics;
}
return $lics;
}
function flickr_get_license_id_by_usage()
{
$lics = flickr_get_licenses();
$use = array();
foreach($lics as $lic)
{
if(!isset($use[$lic['usage']]))
{
$use[$lic['usage']] = $lic['id'];
}
else
{
$use[$lic['usage']] .= "," . $lic['id'];
}
}
return $use;
}
function flickr_is_default_license($licIDs)
{
global $IMConfig;
$lics = flickr_get_licenses();
foreach($lics as $lic)
{
if($lic['url'] == $IMConfig['Flickr']['Default License'])
{
if(in_array($lic['id'], explode(',', $licIDs))) return TRUE;
}
}
return FALSE;
}
function flickr_get_default_usage_id()
{
$usages = flickr_get_license_id_by_usage();
foreach($usages as $usage => $id)
{
if(flickr_is_default_license($id)) return $id;
}
return 0;
}
function flickr_get_user_id($NameOrEmail)
{
if(preg_match('/@/', $NameOrEmail))
{
$d = flickr_request('flickr.people.findByEmail', array('find_email' => $NameOrEmail));
if($d)
{
return $d['user']['id'];
}
}
else
{
$d = flickr_request('flickr.people.findByUsername', array('username' => $NameOrEmail));
if($d)
{
return $d['user']['id'];
}
}
}
?> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/Flickr.php | PHP | art | 4,509 |
<?php
/**
* Image Editor. Editing tools, crop, rotate, scale and save.
* @author $Author:ray $
* @version $Id:ImageEditor.php 938 2008-01-22 20:13:47Z ray $
* @package ImageManager
*/
require_once('../ImageManager/Classes/Transform.php');
/**
* Handles the basic image editing capbabilities.
* @author $Author:ray $
* @version $Id:ImageEditor.php 938 2008-01-22 20:13:47Z ray $
* @package ImageManager
* @subpackage Editor
*/
class ImageEditor
{
/**
* ImageManager instance.
*/
var $manager;
/**
* user based on IP address
*/
var $_uid;
/**
* tmp file storage time.
*/
var $lapse_time =900; //15 mins
var $filesaved = 0;
/**
* Create a new ImageEditor instance. Editing requires a
* tmp file, which is saved in the current directory where the
* image is edited. The tmp file is assigned by md5 hash of the
* user IP address. This hashed is used as an ID for cleaning up
* the tmp files. In addition, any tmp files older than the
* the specified period will be deleted.
* @param ImageManager $manager the image manager, we need this
* for some file and path handling functions.
*/
function ImageEditor($manager)
{
$this->manager = $manager;
$this->_uid = md5($_SERVER['REMOTE_ADDR']);
}
/**
* Did we save a file?
* @return int 1 if the file was saved sucessfully,
* 0 no save operation, -1 file save error.
*/
function isFileSaved()
{
Return $this->filesaved;
}
/**
* Process the image, if not action, just display the image.
* @return array with image information, empty array if not an image.
* <code>array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"',
* 'file'=>'image file, relative', 'fullpath'=>'full path to the image');</code>
*/
function processImage()
{
if(isset($_GET['img']))
$relative = rawurldecode($_GET['img']);
else
Return array();
//$relative = '/Series2004NoteFront.jpg';
$imgURL = $this->manager->getFileURL($relative);
$fullpath = $this->manager->getFullPath($relative);
$imgInfo = @getImageSize($fullpath);
if(!is_array($imgInfo))
Return array();
$action = $this->getAction();
if(!is_null($action))
{
$image = $this->processAction($action, $relative, $fullpath);
}
else
{
$image['src'] = $imgURL;
$image['dimensions'] = $imgInfo[3];
$image['file'] = $relative;
$image['fullpath'] = $fullpath;
$image['filesize'] = @filesize($fullpath);
}
Return $image;
}
/**
* Process the actions, crop, scale(resize), rotate, flip, and save.
* When ever an action is performed, the result is save into a
* temporary image file, see createUnique on the filename specs.
* It does not return the saved file, alway returning the tmp file.
* @param string $action, should be 'crop', 'scale', 'rotate','flip', or 'save'
* @param string $relative the relative image filename
* @param string $fullpath the fullpath to the image file
* @return array with image information
* <code>array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"',
* 'file'=>'image file, relative', 'fullpath'=>'full path to the image');</code>
*/
function processAction($action, $relative, $fullpath)
{
$params = '';
if(isset($_GET['params']))
$params = $_GET['params'];
$values = explode(',',$params);
$saveFile = $this->getSaveFileName($values[0]);
$img = Image_Transform::factory(IMAGE_CLASS);
$img->load($fullpath);
if ( is_callable( array($img,'paletteToTrueColorWithTransparency')) && !imageistruecolor($img->imageHandle))
{
$img->paletteToTrueColorWithTransparency();
}
switch ($action)
{
case 'crop':
$img->crop(intval($values[0]),intval($values[1]),
intval($values[2]),intval($values[3]));
break;
case 'scale':
$img->resize(intval($values[0]),intval($values[1]));
break;
case 'rotate':
$img->rotate(floatval($values[0]));
break;
case 'flip':
if ($values[0] == 'hoz')
$img->flip(true);
else if($values[0] == 'ver')
$img->flip(false);
break;
case 'save':
if(!is_null($saveFile))
{
$quality = intval($values[1]);
if($quality <0) $quality = 85;
$newSaveFile = $this->makeRelative($relative, $saveFile);
$newSaveFile = $this->getUniqueFilename($newSaveFile);
//get unique filename just returns the filename, so
//we need to make the relative path once more.
$newSaveFile = $this->makeRelative($relative, $newSaveFile);
$image['saveFile'] = $newSaveFile;
$newSaveFullpath = $this->manager->getFullPath($newSaveFile);
if ( $values[0] == 'gif' && is_callable(array($img, 'preserveTransparencyForPalette')))
{
$img->preserveTransparencyForPalette();
}
$img->save($newSaveFullpath, $values[0], $quality);
if(is_file($newSaveFullpath))
$this->filesaved = 1;
else
$this->filesaved = -1;
}
break;
case 'preview':
$quality = intval($values[1]);
$image['file'] = $relative;
$image['fullpath'] = $fullpath;
//create the tmp image file
$filename = $this->createUnique($fullpath);
$newRelative = $this->makeRelative($relative, $filename);
$newFullpath = $this->manager->getFullPath($newRelative);
$newURL = $this->manager->getFileURL($newRelative);
if ( $values[0] == 'gif' && is_callable(array($img, 'preserveTransparencyForPalette')))
{
$img->preserveTransparencyForPalette();
}
$img->save($newFullpath, $values[0] );
$img->free();
//get the image information
$imgInfo = @getimagesize($newFullpath);
$image['src'] = $newURL;
$image['width'] = $imgInfo[0];
$image['height'] = $imgInfo[1];
$image['dimensions'] = $imgInfo[3];
$image['file'] = $relative;
$image['fullpath'] = $fullpath;
$image['filesize'] = @filesize($newFullpath);
Return $image;
break;
}
//create the tmp image file
$filename = $this->createUnique($fullpath);
$newRelative = $this->makeRelative($relative, $filename);
$newFullpath = $this->manager->getFullPath($newRelative);
$newURL = $this->manager->getFileURL($newRelative);
//save the file.
$img->save($newFullpath, 'png' );
$img->free();
//get the image information
$imgInfo = @getimagesize($newFullpath);
$image['src'] = $newURL;
$image['width'] = $imgInfo[0];
$image['height'] = $imgInfo[1];
$image['dimensions'] = $imgInfo[3];
$image['file'] = $newRelative;
$image['fullpath'] = $newFullpath;
$image['filesize'] = @filesize($newFullpath);
$image['type'] = image_type_to_mime_type($imgInfo[2]);
Return $image;
}
/**
* Get the file name base on the save name
* and the save type.
* @param string $type image type, 'jpeg', 'png', or 'gif'
* @return string the filename according to save type
*/
function getSaveFileName($type)
{
if(!isset($_GET['file']))
Return null;
$filename = Files::escape(rawurldecode($_GET['file']));
$index = strrpos($filename,'.');
$base = substr($filename,0,$index);
$ext = strtolower(substr($filename,$index+1,strlen($filename)));
if($type == 'jpeg' && !($ext=='jpeg' || $ext=='jpg'))
{
Return $base.'.jpeg';
}
if($type=='png' && $ext != 'png')
Return $base.'.png';
if($type=='gif' && $ext != 'gif')
Return $base.'.gif';
// Ensure type is in acceptable image types
$valid_extensions = $this->manager->config['allowed_image_extensions'];
if(!in_array($ext, $valid_extensions))
{
return $base . ".".strtolower($type ? $type : 'jpg');
}
Return $filename;
}
/**
* Get the default save file name, used by editor.php.
* @return string a suggestive filename, this should be unique
*/
function getDefaultSaveFile()
{
if(isset($_GET['img']))
$relative = rawurldecode($_GET['img']);
else
Return null;
Return $this->getUniqueFilename($relative);
}
/**
* Get a unique filename. If the file exists, the filename
* base is appended with an increasing integer.
* @param string $relative the relative filename to the base_dir
* @return string a unique filename in the current path
*/
function getUniqueFilename($relative)
{
$fullpath = $this->manager->getFullPath($relative);
$pathinfo = pathinfo($fullpath);
$path = Files::fixPath($pathinfo['dirname']);
$file = Files::escape($pathinfo['basename']);
$filename = $file;
$dotIndex = strrpos($file, '.');
$ext = '';
if(is_int($dotIndex))
{
$ext = substr($file, $dotIndex);
$base = substr($file, 0, $dotIndex);
}
$counter = 0;
while(is_file($path.$filename))
{
$counter++;
$filename = $base.'_'.$counter.$ext;
}
Return $filename;
}
/**
* Specifiy the original relative path, a new filename
* and return the new filename with relative path.
* i.e. $pathA (-filename) + $file
* @param string $pathA the relative file
* @param string $file the new filename
* @return string relative path with the new filename
*/
function makeRelative($pathA, $file)
{
$index = strrpos($pathA,'/');
if(!is_int($index))
Return $file;
$path = substr($pathA, 0, $index);
Return Files::fixPath($path).$file;
}
/**
* Get the action GET parameter
* @return string action parameter
*/
function getAction()
{
$action = null;
if(isset($_GET['action']))
$action = $_GET['action'];
Return $action;
}
/**
* Generate a unique string based on md5(microtime()).
* Well not so uniqe, as it is limited to 6 characters
* @return string unique string.
*/
function uniqueStr()
{
return substr(md5(microtime()),0,6);
}
/**
* Create unique tmp image file name.
* The filename is based on the tmp file prefix
* specified in config.inc.php plus
* the UID (basically a md5 of the remote IP)
* and some random 6 character string.
* This function also calls to clean up the tmp files.
* @param string $file the fullpath to a file
* @return string a unique filename for that path
* NOTE: it only returns the filename, path no included.
*/
function createUnique($file)
{
$pathinfo = pathinfo($file);
$path = Files::fixPath($pathinfo['dirname']);
$imgType = $this->getImageType($file);
$unique_str = $this->manager->getTmpPrefix().$this->_uid.'_'.$this->uniqueStr().".".$imgType;
//make sure the the unique temp file does not exists
while (file_exists($path.$unique_str))
{
$unique_str = $this->manager->getTmpPrefix().$this->_uid.'_'.$this->uniqueStr().".".$imgType;
}
$this->cleanUp($path,$pathinfo['basename']);
Return $unique_str;
}
/**
* Delete any tmp image files.
* @param string $path the full path
* where the clean should take place.
*/
function cleanUp($path,$file)
{
$path = Files::fixPath($path);
if(!is_dir($path))
Return false;
$d = @dir($path);
$tmp = $this->manager->getTmpPrefix();
$tmpLen = strlen($tmp);
$prefix = $tmp.$this->_uid;
$len = strlen($prefix);
while (false !== ($entry = $d->read()))
{
//echo $entry."<br>";
if(is_file($path.$entry) && $this->manager->isTmpFile($entry))
{
if(substr($entry,0,$len)==$prefix && $entry != $file)
Files::delFile($path.$entry);
else if(substr($entry,0,$tmpLen)==$tmp && $entry != $file)
{
if(filemtime($path.$entry)+$this->lapse_time < time())
Files::delFile($path.$entry);
}
}
}
$d->close();
}
/**
* Get the image type base on an image file.
* @param string $file the full path to the image file.
* @return string of either 'gif', 'jpeg', 'png' or 'bmp'
* otherwise it will return null.
*/
function getImageType($file)
{
$imageInfo = @getImageSize($file);
if(!is_array($imageInfo))
Return null;
switch($imageInfo[2])
{
case 1:
Return 'gif';
case 2:
Return 'jpeg';
case 3:
Return 'png';
case 6:
Return 'bmp';
}
Return null;
}
/**
* Check if the specified image can be edit by GD
* mainly to check that GD can read and save GIFs
* @return int 0 if it is not a GIF file, 1 is GIF is editable, -1 if not editable.
*/
function isGDEditable()
{
if(isset($_GET['img']))
$relative = rawurldecode($_GET['img']);
else
Return 0;
if(IMAGE_CLASS != 'GD')
Return 0;
$fullpath = $this->manager->getFullPath($relative);
$type = $this->getImageType($fullpath);
if($type != 'gif')
Return 0;
if(function_exists('ImageCreateFrom'.$type)
&& function_exists('image'.$type))
Return 1;
else
Return -1;
}
/**
* Check if GIF can be edit by GD.
* @return int 0 if it is not using the GD library, 1 is GIF is editable, -1 if not editable.
*/
function isGDGIFAble()
{
if(IMAGE_CLASS != 'GD')
Return 0;
if(function_exists('ImageCreateFromGif')
&& function_exists('imagegif'))
Return 1;
else
Return -1;
}
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/ImageEditor.php | PHP | art | 13,430 |
<?php
/***********************************************************************
** Title.........: Image Transformation Interface
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: Transform.php
** Last changed..: 30 Aug 2003
** Notes.........: Orginal is from PEAR
Added a few extra,
- create unique filename in a particular directory,
used for temp image files.
- added cropping to GD, NetPBM, ImageMagick
**/
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// | Alan Knowles <alan@akbkhome.com> |
// | Vincent Oostindie <vincent@sunlight.tmfweb.nl> |
// +----------------------------------------------------------------------+
//
// $Id:Transform.php 709 2007-01-30 23:22:04Z ray $
//
// Image Transformation interface
//
/**
* The main "Image_Resize" class is a container and base class which
* provides the static methods for creating Image objects as well as
* some utility functions (maths) common to all parts of Image Resize.
*
* The object model of DB is as follows (indentation means inheritance):
*
* Image_Resize The base for each Image implementation. Provides default
* | implementations (in OO lingo virtual methods) for
* | the actual Image implementations as well as a bunch of
* | maths methods.
* |
* +-Image_GD The Image implementation for the PHP GD extension . Inherits
* Image_Resize
* When calling DB::setup for GD images the object returned is an
* instance of this class.
*
* @package Image Resize
* @version 1.00
* @author Peter Bowyer <peter@mapledesign.co.uk>
* @since PHP 4.0
*/
Class Image_Transform
{
/**
* Name of the image file
* @var string
*/
var $image = '';
/**
* Type of the image file (eg. jpg, gif png ...)
* @var string
*/
var $type = '';
/**
* Original image width in x direction
* @var int
*/
var $img_x = '';
/**
* Original image width in y direction
* @var int
*/
var $img_y = '';
/**
* New image width in x direction
* @var int
*/
var $new_x = '';
/**
* New image width in y direction
* @var int
*/
var $new_y = '';
/**
* Path the the library used
* e.g. /usr/local/ImageMagick/bin/ or
* /usr/local/netpbm/
*/
var $lib_path = '';
/**
* Flag to warn if image has been resized more than once before displaying
* or saving.
*/
var $resized = false;
var $uid = '';
var $lapse_time =900; //15 mins
/**
* Create a new Image_resize object
*
* @param string $driver name of driver class to initialize
*
* @return mixed a newly created Image_Transform object, or a PEAR
* error object on error
*
* @see PEAR::isError()
* @see Image_Transform::setOption()
*/
function &factory($driver)
{
if ('' == $driver) {
die("No image library specified... aborting. You must call ::factory() with one parameter, the library to load.");
}
$this->uid = md5($_SERVER['REMOTE_ADDR']);
include_once "../ImageManager/Classes/$driver.php";
$classname = "Image_Transform_Driver_{$driver}";
$obj =& new $classname;
return $obj;
}
/**
* Resize the Image in the X and/or Y direction
* If either is 0 it will be scaled proportionally
*
* @access public
*
* @param mixed $new_x (0, number, percentage 10% or 0.1)
* @param mixed $new_y (0, number, percentage 10% or 0.1)
*
* @return mixed none or PEAR_error
*/
function resize($new_x = 0, $new_y = 0)
{
// 0 means keep original size
$new_x = (0 == $new_x) ? $this->img_x : $this->_parse_size($new_x, $this->img_x);
$new_y = (0 == $new_y) ? $this->img_y : $this->_parse_size($new_y, $this->img_y);
// Now do the library specific resizing.
return $this->_resize($new_x, $new_y);
} // End resize
/**
* Scale the image to have the max x dimension specified.
*
* @param int $new_x Size to scale X-dimension to
* @return none
*/
function scaleMaxX($new_x)
{
$new_y = round(($new_x / $this->img_x) * $this->img_y, 0);
return $this->_resize($new_x, $new_y);
} // End resizeX
/**
* Scale the image to have the max y dimension specified.
*
* @access public
* @param int $new_y Size to scale Y-dimension to
* @return none
*/
function scaleMaxY($new_y)
{
$new_x = round(($new_y / $this->img_y) * $this->img_x, 0);
return $this->_resize($new_x, $new_y);
} // End resizeY
/**
* Scale Image to a maximum or percentage
*
* @access public
* @param mixed (number, percentage 10% or 0.1)
* @return mixed none or PEAR_error
*/
function scale($size)
{
if ((strlen($size) > 1) && (substr($size,-1) == '%')) {
return $this->scaleByPercentage(substr($size, 0, -1));
} elseif ($size < 1) {
return $this->scaleByFactor($size);
} else {
return $this->scaleByLength($size);
}
} // End scale
/**
* Scales an image to a percentage of its original size. For example, if
* my image was 640x480 and I called scaleByPercentage(10) then the image
* would be resized to 64x48
*
* @access public
* @param int $size Percentage of original size to scale to
* @return none
*/
function scaleByPercentage($size)
{
return $this->scaleByFactor($size / 100);
} // End scaleByPercentage
/**
* Scales an image to a factor of its original size. For example, if
* my image was 640x480 and I called scaleByFactor(0.5) then the image
* would be resized to 320x240.
*
* @access public
* @param float $size Factor of original size to scale to
* @return none
*/
function scaleByFactor($size)
{
$new_x = round($size * $this->img_x, 0);
$new_y = round($size * $this->img_y, 0);
return $this->_resize($new_x, $new_y);
} // End scaleByFactor
/**
* Scales an image so that the longest side has this dimension.
*
* @access public
* @param int $size Max dimension in pixels
* @return none
*/
function scaleByLength($size)
{
if ($this->img_x >= $this->img_y) {
$new_x = $size;
$new_y = round(($new_x / $this->img_x) * $this->img_y, 0);
} else {
$new_y = $size;
$new_x = round(($new_y / $this->img_y) * $this->img_x, 0);
}
return $this->_resize($new_x, $new_y);
} // End scaleByLength
/**
*
* @access public
* @return void
*/
function _get_image_details($image)
{
//echo $image;
$data = @GetImageSize($image);
#1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order,
# 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC
if (is_array($data)){
switch($data[2]){
case 1:
$type = 'gif';
break;
case 2:
$type = 'jpeg';
break;
case 3:
$type = 'png';
break;
case 4:
$type = 'swf';
break;
case 5:
$type = 'psd';
case 6:
$type = 'bmp';
case 7:
case 8:
$type = 'tiff';
default:
echo("We do not recognize this image format");
}
$this->img_x = $data[0];
$this->img_y = $data[1];
$this->type = $type;
return true;
} else {
echo("Cannot fetch image or images details.");
return null;
}
/*
$output = array(
'width' => $data[0],
'height' => $data[1],
'type' => $type
);
return $output;
*/
}
/**
* Parse input and convert
* If either is 0 it will be scaled proportionally
*
* @access private
*
* @param mixed $new_size (0, number, percentage 10% or 0.1)
* @param int $old_size
*
* @return mixed none or PEAR_error
*/
function _parse_size($new_size, $old_size)
{
if ('%' == $new_size) {
$new_size = str_replace('%','',$new_size);
$new_size = $new_size / 100;
}
if ($new_size > 1) {
return (int) $new_size;
} elseif ($new_size == 0) {
return (int) $old_size;
} else {
return (int) round($new_size * $old_size, 0);
}
}
function uniqueStr()
{
return substr(md5(microtime()),0,6);
}
//delete old tmp files, and allow only 1 file per remote host.
function cleanUp($id, $dir)
{
$d = dir($dir);
$id_length = strlen($id);
while (false !== ($entry = $d->read())) {
if (is_file($dir.'/'.$entry) && substr($entry,0,1) == '.' && !ereg($entry, $this->image))
{
//echo filemtime($this->directory.'/'.$entry)."<br>";
//echo time();
if (filemtime($dir.'/'.$entry) + $this->lapse_time < time())
unlink($dir.'/'.$entry);
if (substr($entry, 1, $id_length) == $id)
{
if (is_file($dir.'/'.$entry))
unlink($dir.'/'.$entry);
}
}
}
$d->close();
}
function createUnique($dir)
{
$unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type;
//make sure the the unique temp file does not exists
while (file_exists($dir.$unique_str))
{
$unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type;
}
$this->cleanUp($this->uid, $dir);
return $unique_str;
}
/**
* Set the image width
* @param int $size dimension to set
* @since 29/05/02 13:36:31
* @return
*/
function _set_img_x($size)
{
$this->img_x = $size;
}
/**
* Set the image height
* @param int $size dimension to set
* @since 29/05/02 13:36:31
* @return
*/
function _set_img_y($size)
{
$this->img_y = $size;
}
/**
* Set the image width
* @param int $size dimension to set
* @since 29/05/02 13:36:31
* @return
*/
function _set_new_x($size)
{
$this->new_x = $size;
}
/**
* Set the image height
* @param int $size dimension to set
* @since 29/05/02 13:36:31
* @return
*/
function _set_new_y($size)
{
$this->new_y = $size;
}
/**
* Get the type of the image being manipulated
*
* @return string $this->type the image type
*/
function getImageType()
{
return $this->type;
}
/**
*
* @access public
* @return string web-safe image type
*/
function getWebSafeFormat()
{
switch($this->type){
case 'gif':
case 'png':
return 'png';
break;
default:
return 'jpeg';
} // switch
}
/**
* Place holder for the real resize method
* used by extended methods to do the resizing
*
* @access private
* @return PEAR_error
*/
function _resize() {
return null; //PEAR::raiseError("No Resize method exists", true);
}
/**
* Place holder for the real load method
* used by extended methods to do the resizing
*
* @access public
* @return PEAR_error
*/
function load($filename) {
return null; //PEAR::raiseError("No Load method exists", true);
}
/**
* Place holder for the real display method
* used by extended methods to do the resizing
*
* @access public
* @param string filename
* @return PEAR_error
*/
function display($type, $quality) {
return null; //PEAR::raiseError("No Display method exists", true);
}
/**
* Place holder for the real save method
* used by extended methods to do the resizing
*
* @access public
* @param string filename
* @return PEAR_error
*/
function save($filename, $type, $quality) {
return null; //PEAR::raiseError("No Save method exists", true);
}
/**
* Place holder for the real free method
* used by extended methods to do the resizing
*
* @access public
* @return PEAR_error
*/
function free() {
return null; //PEAR::raiseError("No Free method exists", true);
}
/**
* Reverse of rgb2colorname.
*
* @access public
* @return PEAR_error
*
* @see rgb2colorname
*/
function colorhex2colorarray($colorhex) {
$r = hexdec(substr($colorhex, 1, 2));
$g = hexdec(substr($colorhex, 3, 2));
$b = hexdec(substr($colorhex, 4, 2));
return array($r,$g,$b);
}
/**
* Reverse of rgb2colorname.
*
* @access public
* @return PEAR_error
*
* @see rgb2colorname
*/
function colorarray2colorhex($color) {
$color = '#'.dechex($color[0]).dechex($color[1]).dechex($color[2]);
return strlen($color)>6?false:$color;
}
/* Methods to add to the driver classes in the future */
function addText()
{
return null; //PEAR::raiseError("No addText method exists", true);
}
function addDropShadow()
{
return null; //PEAR::raiseError("No AddDropShadow method exists", true);
}
function addBorder()
{
return null; //PEAR::raiseError("No addBorder method exists", true);
}
function crop()
{
return null; //PEAR::raiseError("No crop method exists", true);
}
function flip()
{
return null;
}
function gamma()
{
return null; //PEAR::raiseError("No gamma method exists", true);
}
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/Transform.php | PHP | art | 16,270 |
<?php
/**
* ImageManager, list images, directories, and thumbnails.
* @author $Author:ray $
* @version $Id:ImageManager.php 709 2007-01-30 23:22:04Z ray $
* @package ImageManager
*/
require_once('../ImageManager/Classes/Files.php');
// uncomment to turn on debugging
// _ddtOn();
/**
* ImageManager Class.
* @author $Author:ray $
* @version $Id:ImageManager.php 709 2007-01-30 23:22:04Z ray $
*/
class ImageManager
{
/**
* Configuration array.
*/
var $config;
/**
* Array of directory information.
*/
var $dirs;
/**
* Constructor. Create a new Image Manager instance.
* @param array $config configuration array, see config.inc.php
*/
function ImageManager($config)
{
$this->config = $config;
}
/**
* Get the images base directory.
* @return string base dir, see config.inc.php
*/
function getImagesDir()
{
Return $this->config['images_dir'];
}
/**
* Get the images base URL.
* @return string base url, see config.inc.php
*/
function getImagesURL()
{
Return $this->config['images_url'];
}
function isValidBase()
{
return is_dir($this->getImagesDir());
}
/**
* Get the tmp file prefix.
* @return string tmp file prefix.
*/
function getTmpPrefix()
{
Return $this->config['tmp_prefix'];
}
/**
* Get the sub directories in the base dir.
* Each array element contain
* the relative path (relative to the base dir) as key and the
* full path as value.
* @return array of sub directries
* <code>array('path name' => 'full directory path', ...)</code>
*/
function getDirs()
{
if(is_null($this->dirs))
{
$dirs = $this->_dirs($this->getImagesDir(),'/');
ksort($dirs);
$this->dirs = $dirs;
}
return $this->dirs;
}
/**
* Recursively travese the directories to get a list
* of accessable directories.
* @param string $base the full path to the current directory
* @param string $path the relative path name
* @return array of accessiable sub-directories
* <code>array('path name' => 'full directory path', ...)</code>
*/
function _dirs($base, $path)
{
$base = Files::fixPath($base);
$dirs = array();
if($this->isValidBase() == false)
return $dirs;
$d = @dir($base);
while (false !== ($entry = $d->read()))
{
//If it is a directory, and it doesn't start with
// a dot, and if is it not the thumbnail directory
if(is_dir($base.$entry)
&& substr($entry,0,1) != '.'
&& $this->isThumbDir($entry) == false)
{
$relative = Files::fixPath($path.$entry);
$fullpath = Files::fixPath($base.$entry);
$dirs[$relative] = $fullpath;
$dirs = array_merge($dirs, $this->_dirs($fullpath, $relative));
}
}
$d->close();
Return $dirs;
}
/**
* Get all the files and directories of a relative path.
* @param string $path relative path to be base path.
* @return array of file and path information.
* <code>array(0=>array('relative'=>'fullpath',...), 1=>array('filename'=>fileinfo array(),...)</code>
* fileinfo array: <code>array('url'=>'full url',
* 'relative'=>'relative to base',
* 'fullpath'=>'full file path',
* 'image'=>imageInfo array() false if not image,
* 'stat' => filestat)</code>
*/
function getFiles($path)
{
$files = array();
$dirs = array();
if($this->isValidBase() == false)
return array($files,$dirs);
$path = Files::fixPath($path);
$base = Files::fixPath($this->getImagesDir());
$fullpath = Files::makePath($base,$path);
$d = @dir($fullpath);
while (false !== ($entry = $d->read()))
{
//not a dot file or directory
if(substr($entry,0,1) != '.')
{
if(is_dir($fullpath.$entry)
&& $this->isThumbDir($entry) == false)
{
$relative = Files::fixPath($path.$entry);
$full = Files::fixPath($fullpath.$entry);
$count = $this->countFiles($full);
$dirs[$relative] = array('fullpath'=>$full,'entry'=>$entry,'count'=>$count);
}
else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false)
{
$img = $this->getImageInfo($fullpath.$entry);
if(!(!is_array($img)&&$this->config['validate_images']))
{
$file['url'] = Files::makePath($this->config['base_url'],$path).$entry;
$file['relative'] = $path.$entry;
$file['fullpath'] = $fullpath.$entry;
$file['image'] = $img;
$file['stat'] = stat($fullpath.$entry);
$files[$entry] = $file;
}
}
}
}
$d->close();
ksort($dirs);
ksort($files);
Return array($dirs, $files);
}
/**
* Count the number of files and directories in a given folder
* minus the thumbnail folders and thumbnails.
*/
function countFiles($path)
{
$total = 0;
if(is_dir($path))
{
$d = @dir($path);
while (false !== ($entry = $d->read()))
{
//echo $entry."<br>";
if(substr($entry,0,1) != '.'
&& $this->isThumbDir($entry) == false
&& $this->isTmpFile($entry) == false
&& $this->isThumb($entry) == false)
{
$total++;
}
}
$d->close();
}
return $total;
}
/**
* Get image size information.
* @param string $file the image file
* @return array of getImageSize information,
* false if the file is not an image.
*/
function getImageInfo($file)
{
Return @getImageSize($file);
}
/**
* Check if the file contains the thumbnail prefix.
* @param string $file filename to be checked
* @return true if the file contains the thumbnail prefix, false otherwise.
*/
function isThumb($file)
{
$len = strlen($this->config['thumbnail_prefix']);
if(substr($file,0,$len)==$this->config['thumbnail_prefix'])
Return true;
else
Return false;
}
/**
* Check if the given directory is a thumbnail directory.
* @param string $entry directory name
* @return true if it is a thumbnail directory, false otherwise
*/
function isThumbDir($entry)
{
if($this->config['thumbnail_dir'] == false
|| strlen(trim($this->config['thumbnail_dir'])) == 0)
Return false;
else
Return ($entry == $this->config['thumbnail_dir']);
}
/**
* Check if the given file is a tmp file.
* @param string $file file name
* @return boolean true if it is a tmp file, false otherwise
*/
function isTmpFile($file)
{
$len = strlen($this->config['tmp_prefix']);
if(substr($file,0,$len)==$this->config['tmp_prefix'])
Return true;
else
Return false;
}
/**
* For a given image file, get the respective thumbnail filename
* no file existence check is done.
* @param string $fullpathfile the full path to the image file
* @return string of the thumbnail file
*/
function getThumbName($fullpathfile)
{
$path_parts = pathinfo($fullpathfile);
$thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename'];
if( strlen(trim($this->config['thumbnail_dir'])) == 0 || $this->config['safe_mode'] == true)
{
Return Files::makeFile($path_parts['dirname'],$thumbnail);
}
else
{
$path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']);
if(!is_dir($path))
Files::createFolder($path);
Return Files::makeFile($path,$thumbnail);
}
}
/**
* Similar to getThumbName, but returns the URL, base on the
* given base_url in config.inc.php
* @param string $relative the relative image file name,
* relative to the base_dir path
* @return string the url of the thumbnail
*/
function getThumbURL($relative)
{
_ddt( __FILE__, __LINE__, "getThumbURL(): relative is '$relative'" );
$path_parts = pathinfo($relative);
$thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename'];
if($path_parts['dirname']=='\\') $path_parts['dirname']='/';
if($this->config['safe_mode'] == true
|| strlen(trim($this->config['thumbnail_dir'])) == 0)
{
Return Files::makeFile($this->getImagesURL(),rawurlencode($thumbnail));
}
else
{
if(strlen(trim($this->config['thumbnail_dir'])) > 0)
{
$path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']);
$url_path = Files::makePath($this->getImagesURL(), $path);
_ddt( __FILE__, __LINE__, "getThumbURL(): url_path is '$url_path'" );
Return Files::makeFile($url_path,rawurlencode($thumbnail));
}
else //should this ever happen?
{
//error_log('ImageManager: Error in creating thumbnail url');
}
}
}
/**
* For a given image file, get the respective resized filename
* no file existence check is done.
* @param string $fullpathfile the full path to the image file
* @param integer $width the intended width
* @param integer $height the intended height
* @param boolean $mkDir whether to attempt to make the resized_dir if it doesn't exist
* @return string of the resized filename
*/
function getResizedName($fullpathfile, $width, $height, $mkDir = TRUE)
{
$path_parts = pathinfo($fullpathfile);
$thumbnail = $this->config['resized_prefix']."_{$width}x{$height}_{$path_parts['basename']}";
if( strlen(trim($this->config['resized_dir'])) == 0 || $this->config['safe_mode'] == true )
{
Return Files::makeFile($path_parts['dirname'],$thumbnail);
}
else
{
$path = Files::makePath($path_parts['dirname'],$this->config['resized_dir']);
if($mkDir && !is_dir($path))
Files::createFolder($path);
Return Files::makeFile($path,$thumbnail);
}
}
/**
* Check if the given path is part of the subdirectories
* under the base_dir.
* @param string $path the relative path to be checked
* @return boolean true if the path exists, false otherwise
*/
function validRelativePath($path)
{
$dirs = $this->getDirs();
if($path == '/')
Return true;
//check the path given in the url against the
//list of paths in the system.
for($i = 0; $i < count($dirs); $i++)
{
$key = key($dirs);
//we found the path
if($key == $path)
Return true;
next($dirs);
}
Return false;
}
/**
* Process uploaded files, assumes the file is in
* $_FILES['upload'] and $_POST['dir'] is set.
* The dir must be relative to the base_dir and exists.
* If 'validate_images' is set to true, only file with
* image dimensions will be accepted.
* @return null
*/
function processUploads()
{
if($this->isValidBase() == false)
return;
$relative = null;
if(isset($_POST['dir']))
$relative = rawurldecode($_POST['dir']);
else
return;
//check for the file, and must have valid relative path
if(isset($_FILES['upload']) && $this->validRelativePath($relative))
{
$this->_processFiles($relative, $_FILES['upload']);
}
}
/**
* Process upload files. The file must be an
* uploaded file. If 'validate_images' is set to
* true, only images will be processed. Any duplicate
* file will be renamed. See Files::copyFile for details
* on renaming.
* @param string $relative the relative path where the file
* should be copied to.
* @param array $file the uploaded file from $_FILES
* @return boolean true if the file was processed successfully,
* false otherwise
*/
function _processFiles($relative, $file)
{
if($file['error']!=0)
{
Return false;
}
if(!is_file($file['tmp_name']))
{
Return false;
}
if(!is_uploaded_file($file['tmp_name']))
{
Files::delFile($file['tmp_name']);
Return false;
}
if($this->config['validate_images'] == true)
{
$imgInfo = @getImageSize($file['tmp_name']);
if(!is_array($imgInfo))
{
Files::delFile($file['tmp_name']);
Return false;
}
}
$valid_extensions = $this->config['allowed_image_extensions'];
$afruext = strtolower(substr(strrchr($file['name'], "."), 1));
if(!in_array($afruext, $valid_extensions))
{
Files::delFile($file['tmp_name']);
Return 'Cannot upload $extension='.$afruext.'$ Files. Permission denied.';
}
//now copy the file
$path = Files::makePath($this->getImagesDir(),$relative);
$result = Files::copyFile($file['tmp_name'], $path, $file['name']);
//no copy error
if(!is_int($result))
{
Files::delFile($file['tmp_name']);
Return true;
}
//delete tmp files.
Files::delFile($file['tmp_name']);
Return false;
}
/**
* Get the URL of the relative file.
* basically appends the relative file to the
* base_url given in config.inc.php
* @param string $relative a file the relative to the base_dir
* @return string the URL of the relative file.
*/
function getFileURL($relative)
{
Return Files::makeFile($this->getImagesURL(),$relative);
}
/**
* Get the fullpath to a relative file.
* @param string $relative the relative file.
* @return string the full path, .ie. the base_dir + relative.
*/
function getFullPath($relative)
{
Return Files::makeFile($this->getImagesDir(),$relative);;
}
/**
* Get the default thumbnail.
* @return string default thumbnail, empty string if
* the thumbnail doesn't exist.
*/
function getDefaultThumb()
{
// FIXME: hack
Return $this->config['default_thumbnail'];
if(is_file($this->config['default_thumbnail']))
{
Return $this->config['default_thumbnail'];
}
else
Return '';
}
/**
* Get the thumbnail url to be displayed.
* If the thumbnail exists, and it is up-to-date
* the thumbnail url will be returns. If the
* file is not an image, a default image will be returned.
* If it is an image file, and no thumbnail exists or
* the thumbnail is out-of-date (i.e. the thumbnail
* modified time is less than the original file)
* then a thumbs.php?img=filename.jpg is returned.
* The thumbs.php url will generate a new thumbnail
* on the fly. If the image is less than the dimensions
* of the thumbnails, the image will be display instead.
* @param string $relative the relative image file.
* @return string the url of the thumbnail, be it
* actually thumbnail or a script to generate the
* thumbnail on the fly.
*/
function getThumbnail($relative)
{
global $IMConfig;
_ddt( __FILE__, __LINE__, "getThumbnail(): top with '$relative'" );
$fullpath = Files::makeFile($this->getImagesDir(),$relative);
//not a file???
if(!is_file($fullpath))
Return $this->getDefaultThumb();
$imgInfo = @getImageSize($fullpath);
//not an image
if(!is_array($imgInfo))
Return $this->getDefaultThumb();
//the original image is smaller than thumbnails,
//so just return the url to the original image.
if ($imgInfo[0] <= $this->config['thumbnail_width']
&& $imgInfo[1] <= $this->config['thumbnail_height'])
Return $this->getFileURL($relative);
$thumbnail = $this->getThumbName($fullpath);
//check for thumbnails, if exists and
// it is up-to-date, return the thumbnail url
if(is_file($thumbnail))
{
if(filemtime($thumbnail) >= filemtime($fullpath))
{
_ddt( __FILE__, __LINE__, "getThumbnail(): returning url '" . $this->getThumbURL($relative) . "'" );
Return $this->getThumbURL($relative);
}
}
//well, no thumbnail was found, so ask the thumbs.php
//to generate the thumbnail on the fly.
Return $IMConfig['backend_url'] . '__function=thumbs&img='.rawurlencode($relative);
}
/**
* Delete and specified files.
* @return boolean true if delete, false otherwise
*/
function deleteFiles()
{
if(isset($_GET['delf']))
$this->_delFile(rawurldecode($_GET['delf']));
}
/**
* Delete and specified directories.
* @return boolean true if delete, false otherwise
*/
function deleteDirs()
{
if(isset($_GET['deld']))
return $this->_delDir(rawurldecode($_GET['deld']));
else
Return false;
}
/**
* Delete the relative file, and any thumbnails.
* @param string $relative the relative file.
* @return boolean true if deleted, false otherwise.
*/
function _delFile($relative)
{
$fullpath = Files::makeFile($this->getImagesDir(),$relative);
//check that the file is an image
if($this->config['validate_images'] == true)
{
if(!is_array($this->getImageInfo($fullpath)))
return false; //hmmm not an Image!!???
}
$thumbnail = $this->getThumbName($fullpath);
if(Files::delFile($fullpath))
Return Files::delFile($thumbnail);
else
Return false;
}
/**
* Delete directories recursively.
* @param string $relative the relative path to be deleted.
* @return boolean true if deleted, false otherwise.
*/
function _delDir($relative)
{
$fullpath = Files::makePath($this->getImagesDir(),$relative);
if($this->countFiles($fullpath) <= 0)
return Files::delFolder($fullpath,true); //delete recursively.
else
Return false;
}
/**
* Create new directories.
* If in safe_mode, nothing happens.
* @return boolean true if created, false otherwise.
*/
function processNewDir()
{
if($this->config['safe_mode'] == true)
Return false;
if(isset($_GET['newDir']) && isset($_GET['dir']))
{
$newDir = rawurldecode($_GET['newDir']);
$dir = rawurldecode($_GET['dir']);
$path = Files::makePath($this->getImagesDir(),$dir);
$fullpath = Files::makePath($path, Files::escape($newDir));
if(is_dir($fullpath))
Return false;
Return Files::createFolder($fullpath);
}
}
}
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/ImageManager.php | PHP | art | 17,851 |
<?php
/***********************************************************************
** Title.........: GD Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: GD.php
** Last changed..: 30 Aug 2003
** Notes.........: Orginal is from PEAR
**/
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// | Alan Knowles <alan@akbkhome.com> |
// +----------------------------------------------------------------------+
//
// Usage :
// $img = new Image_Transform_GD();
// $angle = -78;
// $img->load('magick.png');
//
// if($img->rotate($angle,array('autoresize'=>true,'color_mask'=>array(255,0,0)))){
// $img->addText(array('text'=>"Rotation $angle",'x'=>0,'y'=>100,'font'=>'/usr/share/fonts/default/TrueType/cogb____.ttf'));
// $img->display();
// } else {
// echo "Error";
// }
//
//
// $Id:GD.php 938 2008-01-22 20:13:47Z ray $
//
// Image Transformation interface using the GD library
//
require_once "../ImageManager/Classes/Transform.php";
Class Image_Transform_Driver_GD extends Image_Transform
{
/**
* Holds the image file for manipulation
*/
var $imageHandle = '';
/**
* Holds the original image file
*/
var $old_image = '';
/**
* Check settings
*
* @return mixed true or or a PEAR error object on error
*
* @see PEAR::isError()
*/
function Image_Transform_GD()
{
return;
} // End function Image
/**
* Load image
*
* @param string filename
*
* @return mixed none or a PEAR error object on error
* @see PEAR::isError()
*/
function load($image)
{
$this->uid = md5($_SERVER['REMOTE_ADDR']);
$this->image = $image;
$this->_get_image_details($image);
$functionName = 'ImageCreateFrom' . $this->type;
if(function_exists($functionName))
{
$this->imageHandle = $functionName($this->image);
if ( $this->type == 'png')
{
imageAlphaBlending($this->imageHandle, false);
imageSaveAlpha($this->imageHandle, true);
}
}
} // End load
/**
* addText
*
* @param array options Array contains options
* array(
* 'text' The string to draw
* 'x' Horizontal position
* 'y' Vertical Position
* 'Color' Font color
* 'font' Font to be used
* 'size' Size of the fonts in pixel
* 'resize_first' Tell if the image has to be resized
* before drawing the text
* )
*
* @return none
* @see PEAR::isError()
*/
function addText($params)
{
$default_params = array(
'text' => 'This is Text',
'x' => 10,
'y' => 20,
'color' => array(255,0,0),
'font' => 'Arial.ttf',
'size' => '12',
'angle' => 0,
'resize_first' => false // Carry out the scaling of the image before annotation? Not used for GD
);
$params = array_merge($default_params, $params);
extract($params);
if( !is_array($color) ){
if ($color[0]=='#'){
$this->colorhex2colorarray( $color );
} else {
include_once('Image/Transform/Driver/ColorsDefs.php');
$color = isset($colornames[$color])?$colornames[$color]:false;
}
}
$c = imagecolorresolve ($this->imageHandle, $color[0], $color[1], $color[2]);
if ('ttf' == substr($font, -3)) {
ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
} else {
ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
}
return true;
} // End addText
/**
* Rotate image by the given angle
* Uses a fast rotation algorythm for custom angles
* or lines copy for multiple of 90 degrees
*
* @param int $angle Rotation angle
* @param array $options array( 'autoresize'=>true|false,
* 'color_mask'=>array(r,g,b), named color or #rrggbb
* )
* @author Pierre-Alain Joye
* @return mixed none or a PEAR error object on error
* @see PEAR::isError()
*/
function rotate($angle, $options=null)
{
if(function_exists('imagerotate')) {
$white = imagecolorallocatealpha ($this->imageHandle, 255, 255, 255, 127);
$this->imageHandle = imagerotate($this->imageHandle, $angle, $white);
return true;
}
if ( $options==null ){
$autoresize = true;
$color_mask = array(105,255,255);
} else {
extract( $options );
}
while ($angle <= -45) {
$angle += 360;
}
while ($angle > 270) {
$angle -= 360;
}
$t = deg2rad($angle);
if( !is_array($color_mask) ){
if ($color[0]=='#'){
$this->colorhex2colorarray( $color_mask );
} else {
include_once('Image/Transform/Driver/ColorDefs.php');
$color = isset($colornames[$color_mask])?$colornames[$color_mask]:false;
}
}
// Do not round it, too much lost of quality
$cosT = cos($t);
$sinT = sin($t);
$img =& $this->imageHandle;
$width = $max_x = $this->img_x;
$height = $max_y = $this->img_y;
$min_y = 0;
$min_x = 0;
$x1 = round($max_x/2,0);
$y1 = round($max_y/2,0);
if ( $autoresize ){
$t = abs($t);
$a = round($angle,0);
switch((int)($angle)){
case 0:
$width2 = $width;
$height2 = $height;
break;
case 90:
$width2 = $height;
$height2 = $width;
break;
case 180:
$width2 = $width;
$height2 = $height;
break;
case 270:
$width2 = $height;
$height2 = $width;
break;
default:
$width2 = (int)(abs(sin($t) * $height + cos($t) * $width));
$height2 = (int)(abs(cos($t) * $height+sin($t) * $width));
}
$width2 -= $width2%2;
$height2 -= $height2%2;
$d_width = abs($width - $width2);
$d_height = abs($height - $height2);
$x_offset = $d_width/2;
$y_offset = $d_height/2;
$min_x2 = -abs($x_offset);
$min_y2 = -abs($y_offset);
$max_x2 = $width2;
$max_y2 = $height2;
}
$img2 = @$this->newImgPreserveAlpha( imagecreateTrueColor($width2,$height2) );
if ( !is_resource($img2) ){
return false;/*PEAR::raiseError('Cannot create buffer for the rotataion.',
null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/
}
$this->img_x = $width2;
$this->img_y = $height2;
imagepalettecopy($img2,$img);
$mask = imagecolorallocatealpha ($img2,$color_mask[0],$color_mask[1],$color_mask[2],127);
// use simple lines copy for axes angles
switch((int)($angle)){
case 0:
imagefill ($img2, 0, 0,$mask);
for ($y=0; $y < $max_y; $y++) {
for ($x = $min_x; $x < $max_x; $x++){
$c = @imagecolorat ( $img, $x, $y);
imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c);
}
}
break;
case 90:
imagefill ($img2, 0, 0,$mask);
for ($x = $min_x; $x < $max_x; $x++){
for ($y=$min_y; $y < $max_y; $y++) {
$c = imagecolorat ( $img, $x, $y);
imagesetpixel($img2,$max_y-$y-1,$x,$c);
}
}
break;
case 180:
imagefill ($img2, 0, 0,$mask);
for ($y=0; $y < $max_y; $y++) {
for ($x = $min_x; $x < $max_x; $x++){
$c = @imagecolorat ( $img, $x, $y);
imagesetpixel($img2, $max_x2-$x-1, $max_y2-$y-1, $c);
}
}
break;
case 270:
imagefill ($img2, 0, 0,$mask);
for ($y=0; $y < $max_y; $y++) {
for ($x = $max_x; $x >= $min_x; $x--){
$c = @imagecolorat ( $img, $x, $y);
imagesetpixel($img2,$y,$max_x-$x-1,$c);
}
}
break;
// simple reverse rotation algo
default:
$i=0;
for ($y = $min_y2; $y < $max_y2; $y++){
// Algebra :)
$x2 = round((($min_x2-$x1) * $cosT) + (($y-$y1) * $sinT + $x1),0);
$y2 = round((($y-$y1) * $cosT - ($min_x2-$x1) * $sinT + $y1),0);
for ($x = $min_x2; $x < $max_x2; $x++){
// Check if we are out of original bounces, if we are
// use the default color mask
if ( $x2>=0 && $x2<$max_x && $y2>=0 && $y2<$max_y ){
$c = imagecolorat ( $img, $x2, $y2);
} else {
$c = $mask;
}
imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c);
// round verboten!
$x2 += $cosT;
$y2 -= $sinT;
}
}
break;
}
$this->old_image = $this->imageHandle;
$this->imageHandle = $img2;
return true;
}
/**
* Resize Action
*
* For GD 2.01+ the new copyresampled function is used
* It uses a bicubic interpolation algorithm to get far
* better result.
*
* @param int $new_x new width
* @param int $new_y new height
*
* @return true on success or pear error
* @see PEAR::isError()
*/
function _resize($new_x, $new_y) {
if ($this->resized === true) {
return false; /*PEAR::raiseError('You have already resized the image without saving it. Your previous resizing will be overwritten', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/
}
if(function_exists('ImageCreateTrueColor')){
$new_img = $this->newImgPreserveAlpha( ImageCreateTrueColor($new_x,$new_y) );
} else {
$new_img =ImageCreate($new_x,$new_y);
}
if(function_exists('ImageCopyResampled')){
ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
} else {
ImageCopyResized($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
}
$this->old_image = $this->imageHandle;
$this->imageHandle = $new_img;
$this->resized = true;
$this->new_x = $new_x;
$this->new_y = $new_y;
return true;
}
/**
* Crop the image
*
* @param int $crop_x left column of the image
* @param int $crop_y top row of the image
* @param int $crop_width new cropped image width
* @param int $crop_height new cropped image height
*/
function crop($new_x, $new_y, $new_width, $new_height)
{
if(function_exists('ImageCreateTrueColor')){
$new_img = $this->newImgPreserveAlpha(ImageCreateTrueColor($new_width,$new_height));
} else {
$new_img =ImageCreate($new_width,$new_height);
}
if(function_exists('ImageCopyResampled')){
ImageCopyResampled($new_img, $this->imageHandle, 0, 0, $new_x, $new_y,$new_width,$new_height,$new_width,$new_height);
} else {
ImageCopyResized($new_img, $this->imageHandle, 0, 0, $new_x, $new_y, $new_width,$new_height,$new_width,$new_height);
}
$this->old_image = $this->imageHandle;
$this->imageHandle = $new_img;
$this->resized = true;
$this->new_x = $new_x;
$this->new_y = $new_y;
return true;
}
/**
* Flip the image horizontally or vertically
*
* @param boolean $horizontal true if horizontal flip, vertical otherwise
*/
function flip($horizontal)
{
if(!$horizontal) {
$this->rotate(180);
}
$width = imagesx($this->imageHandle);
$height = imagesy($this->imageHandle);
for ($j = 0; $j < $height; $j++) {
$left = 0;
$right = $width-1;
while ($left < $right) {
//echo " j:".$j." l:".$left." r:".$right."\n<br>";
$t = imagecolorat($this->imageHandle, $left, $j);
imagesetpixel($this->imageHandle, $left, $j, imagecolorat($this->imageHandle, $right, $j));
imagesetpixel($this->imageHandle, $right, $j, $t);
$left++; $right--;
}
}
return true;
}
/**
* Adjust the image gamma
*
* @param float $outputgamma
*
* @return none
*/
function gamma($outputgamma=1.0) {
ImageGammaCorrect($this->imageHandle, 1.0, $outputgamma);
}
function paletteToTrueColorWithTransparency()
{
$oldImg = $this->imageHandle;
$newImg = $this->newImgPreserveAlpha( imagecreatetruecolor($this->img_x,$this->img_y) );
imagecopy($newImg,$oldImg,0,0,0,0,$this->img_x,$this->img_y);
$this->imageHandle = $newImg;
}
function newImgPreserveAlpha($newImg)
{
if ( $this->type == 'jpeg') return $newImg;
// Turn off transparency blending (temporarily)
imagealphablending($newImg, false);
// Create a new transparent color for image
if ( $transparent = imagecolortransparent($this->imageHandle) >= 0 )
{
if (imageistruecolor($this->imageHandle))
{
$red = ($transparent & 0xFF0000) >> 16;
$green = ($transparent & 0x00FF00) >> 8;
$blue = ($transparent & 0x0000FF);
$color_values = array('red' => $red, 'green' => $green, 'blue' => $blue);
}
else
{
$color_values = imagecolorsforindex($this->imageHandle,$transparent);
}
$color_values = imagecolorsforindex($this->imageHandle,$transparent);
$color = imagecolorallocatealpha($newImg, $color_values['red'],$color_values['green'],$color_values['blue'], 127);
$colort = imagecolorallocate($newImg, $color_values['red'],$color_values['green'],$color_values['blue']);
}
else
{
$color = imagecolorallocatealpha($newImg, 252, 2, 252, 127);
$colort = imagecolorallocate($newImg, 252, 2, 252);
}
imagecolortransparent($newImg,$colort);
// Completely fill the background of the new image with allocated color.
imagefill($newImg, 0, 0, $color);
// Restore transparency blending
imagesavealpha($newImg, true);
return $newImg;
}
function preserveTransparencyForPalette()
{
$new_img = imagecreatetruecolor($this->img_x,$this->img_y);
$truecolor = imageistruecolor($this->imageHandle);
$transparent = imagecolorallocate($new_img, 252,2,252); // nasty pinkish purple that hopefully doesn't exist in the image
imagecolortransparent($new_img, $transparent);
for ($i=0;$i<$this->img_y;$i++)
{
for ($j=0;$j<$this->img_x;$j++)
{
$c = imagecolorat($this->imageHandle,$j, $i);
if ($truecolor)
{
$a = ($c >> 24) & 0xFF;
$r = ($c >> 16) & 0xFF;
$g = ($c >> 8) & 0xFF;
$b = $c & 0xFF;
$color_values = array('red' => $r, 'green' => $g, 'blue' => $b, 'alpha' => $a);
}
else
{
$color_values = imagecolorsforindex($this->imageHandle,$c);
}
if ($color_values['alpha'] >= 126)
{
imagesetpixel($new_img, $j, $i, $transparent);
}
else
{
imagesetpixel($new_img, $j, $i, $c);
}
}
}
$this->imageHandle = $new_img;
}
/**
* Save the image file
*
* @param string $filename the name of the file to write to
* @param int $quality output DPI, default is 85
* @param string $types define the output format, default
* is the current used format
*
* @return none
*/
function save($filename, $type = '', $quality = 85)
{
$type = $type==''? $this->type : $type;
$functionName = 'image' . $type;
if(function_exists($functionName))
{
$this->old_image = $this->imageHandle;
if($type=='jpeg')
$functionName($this->imageHandle, $filename, $quality);
else
$functionName($this->imageHandle, $filename);
$this->imageHandle = $this->old_image;
$this->resized = false;
}
} // End save
/**
* Display image without saving and lose changes
*
* @param string type (JPG,PNG...);
* @param int quality 75
*
* @return none
*/
function display($type = '', $quality = 75)
{
if ($type != '') {
$this->type = $type;
}
$functionName = 'Image' . $this->type;
if(function_exists($functionName))
{
header('Content-type: image/' . strtolower($this->type));
$functionName($this->imageHandle, '', $quality);
$this->imageHandle = $this->old_image;
$this->resized = false;
ImageDestroy($this->old_image);
$this->free();
}
}
/**
* Destroy image handle
*
* @return none
*/
function free()
{
if ($this->imageHandle){
ImageDestroy($this->imageHandle);
}
}
} // End class ImageGD
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/Classes/GD.php | PHP | art | 20,244 |
<?php
/**
* The PHP Image Editor user interface.
* @author $Author:ray $
* @version $Id:editor.php 987 2008-04-12 12:39:04Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('Classes/ImageManager.php');
require_once('Classes/ImageEditor.php');
$manager = new ImageManager($IMConfig);
$editor = new ImageEditor($manager);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
</script>
<link href="<?php print $IMConfig['base_url'];?>assets/editor.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/slider.js"></script>
<script type="text/javascript" src="../../popups/popup.js"></script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/popup.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
window.resizeTo(673, 531);
if(window.opener)
HTMLArea = window.opener.HTMLArea;
/*]]>*/
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/editor.js"></script>
</head>
<body>
<div id="indicator">
<img src="<?php print $IMConfig['base_url'];?>img/spacer.gif" id="indicator_image" height="20" width="20" alt="" />
</div>
<div id="tools">
<div id="tools_crop" style="display:none;">
<div id="tool_inputs">
<label for="cx">Start X:</label><input type="text" id="cx" class="textInput" onchange="updateMarker('crop')"/>
<label for="cy">Start Y:</label><input type="text" id="cy" class="textInput" onchange="updateMarker('crop')"/>
<label for="cw">Width:</label><input type="text" id="cw" class="textInput" onchange="updateMarker('crop')"/>
<label for="ch">Height:</label><input type="text" id="ch" class="textInput" onchange="updateMarker('crop')"/>
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
</div>
<a href="javascript: editor.doSubmit('crop');" class="buttons" title="OK"><img src="<?php print $IMConfig['base_url'];?>img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
<a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="<?php print $IMConfig['base_url'];?>img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>
</div>
<div id="tools_scale" style="display:none;">
<div id="tool_inputs">
<label for="sw">Width:</label><input type="text" id="sw" class="textInput" onchange="checkConstrains('width')"/>
<a href="javascript:toggleConstraints();" title="Lock"><img src="<?php print $IMConfig['base_url'];?>img/islocked2.gif" id="scaleConstImg" height="14" width="8" alt="Lock" class="div" /></a><label for="sh">Height:</label>
<input type="text" id="sh" class="textInput" onchange="checkConstrains('height')"/>
<input type="checkbox" id="constProp" value="1" checked="checked" onclick="toggleConstraints()"/>
<label for="constProp">Constrain Proportions</label>
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
</div>
<a href="javascript: editor.doSubmit('scale');" class="buttons" title="OK"><img src="<?php print $IMConfig['base_url'];?>img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
<a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="<?php print $IMConfig['base_url'];?>img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>
</div>
<div id="tools_rotate" style="display:none;">
<div id="tool_inputs">
<select id="flip" name="flip" style="margin-left: 10px; vertical-align: middle;">
<option selected="selected">Flip Image</option>
<option>-----------------</option>
<option value="hoz">Flip Horizontal</option>
<option value="ver">Flip Vertical</option>
</select>
<select name="rotate" onchange="rotatePreset(this)" style="margin-left: 20px; vertical-align: middle;">
<option selected="selected">Rotate Image</option>
<option>-----------------</option>
<option value="180">Rotate 180 °</option>
<option value="90">Rotate 90 ° CW</option>
<option value="-90">Rotate 90 ° CCW</option>
</select>
<label for="ra">Angle:</label><input type="text" id="ra" class="textInput" />
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
</div>
<a href="javascript: editor.doSubmit('rotate');" class="buttons" title="OK"><img src="<?php print $IMConfig['base_url'];?>img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
<a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="<?php print $IMConfig['base_url'];?>img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>
</div>
<div id="tools_measure" style="display:none;">
<div id="tool_inputs">
<label>X:</label><input type="text" class="measureStats" id="sx" />
<label>Y:</label><input type="text" class="measureStats" id="sy" />
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
<label>W:</label><input type="text" class="measureStats" id="mw" />
<label>H:</label><input type="text" class="measureStats" id="mh" />
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
<label>A:</label><input type="text" class="measureStats" id="ma" />
<label>D:</label><input type="text" class="measureStats" id="md" />
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
<button type="button" onclick="editor.reset();" >Clear</button>
</div>
</div>
<div id="tools_save" style="display:none;">
<div id="tool_inputs">
<label for="save_filename">Filename:</label><input type="text" id="save_filename" value="<?php echo $editor->getDefaultSaveFile();?>"/>
<select name="format" id="save_format" style="margin-left: 10px; vertical-align: middle;" onchange="updateFormat(this)">
<option value="" selected="selected">Image Format</option>
<option value="">---------------------</option>
<option value="jpeg,85">JPEG High</option>
<option value="jpeg,60">JPEG Medium</option>
<option value="jpeg,35">JPEG Low</option>
<option value="png">PNG</option>
<?php if($editor->isGDGIFAble() != -1) { ?>
<option value="gif">GIF</option>
<?php } ?>
</select>
<label>Quality:</label>
<table style="display: inline; vertical-align: middle;" cellpadding="0" cellspacing="0">
<tr>
<td>
<div id="slidercasing">
<div id="slidertrack" style="width:100px"><img src="<?php print $IMConfig['base_url'];?>img/spacer.gif" width="1" height="1" border="0" alt="track" /></div>
<div id="sliderbar" style="left:85px" onmousedown="captureStart();"><img src="<?php print $IMConfig['base_url'];?>img/spacer.gif" width="1" height="1" border="0" alt="track" /></div>
</div>
</td>
</tr>
</table>
<input type="text" id="quality" onchange="updateSlider(this.value)" style="width: 2em;" value="85"/>
<img src="<?php print $IMConfig['base_url'];?>img/div.gif" height="30" width="2" class="div" alt="|" />
</div>
<a href="javascript: editor.doSubmit('save');" class="buttons" title="OK"><img src="<?php print $IMConfig['base_url'];?>img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
<a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="<?php print $IMConfig['base_url'];?>img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>
</div>
</div>
<div id="toolbar">
<a href="javascript:toggle('crop')" id="icon_crop" title="Crop"><img src="<?php print $IMConfig['base_url'];?>img/crop.gif" height="20" width="20" alt="Crop" /><span>Crop</span></a>
<a href="javascript:toggle('scale')" id="icon_scale" title="Resize"><img src="<?php print $IMConfig['base_url'];?>img/scale.gif" height="20" width="20" alt="Resize" /><span>Resize</span></a>
<a href="javascript:toggle('rotate')" id="icon_rotate" title="Rotate"><img src="<?php print $IMConfig['base_url'];?>img/rotate.gif" height="20" width="20" alt="Rotate" /><span>Rotate</span></a>
<a href="javascript:toggle('measure')" id="icon_measure" title="Measure"><img src="<?php print $IMConfig['base_url'];?>img/measure.gif" height="20" width="20" alt="Measure" /><span>Measure</span></a>
<a href="javascript: toggleMarker();" title="Marker"><img id="markerImg" src="<?php print $IMConfig['base_url'];?>img/t_black.gif" height="20" width="20" alt="Marker" /><span>Marker</span></a>
<a href="javascript:toggle('save')" id="icon_save" title="Save"><img src="<?php print $IMConfig['base_url'];?>img/save.gif" height="20" width="20" alt="Save" /><span>Save</span></a>
</div>
<div id="contents">
<iframe src="<?php print $IMConfig['backend_url']; ?>__function=editorFrame&img=<?php if(isset($_GET['img'])) echo rawurlencode($_GET['img']); ?>" name="editor" id="editor" scrolling="auto" title="Image Editor" frameborder="0"></iframe>
</div>
<div id="bottom"></div>
</body>
</html> | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/editor.php | PHP | art | 9,309 |
<?php
/*
This ddt library is released under the terms of the HTMLArea license.
See license.txt that is shipped with Xinha.
*/
// must be included after the configuration has been loaded.
if ( ! defined( "IM_CONFIG_LOADED" ) )
die( "sorry" );
/**
* Debug and Error Message functions.
*
* These functions implement a procedural version of the formVista DDT debug
* message system.
*
* @package formVista
* @subpackage lib
* @copyright DTLink, LLC 2005
* @author Yermo Lamers
* @see http://www.formvista.com/contact.html
*/
// REVISION HISTORY:
//
// 26 Jan 2001 YmL:
// . initial revision
//
// 2002-06-19 YmL:
// . added logging debug and error messages to a file.
//
// 2004-02-06 YmL:
// . added a newline to generated messages.
//
// 2005-01-09 YmL:
// . now checks global $fvDEBUG[ "logfile" ] setting for
// logfile to output to.
// . dumping to file has not been combined into a dumpmsg
// method.
//
// 2005-02-25 YmL:
// . added _error() support for cmdLine programs.
//
// 2005-03-20 YmL:
// . changed license for this file to HTMLArea from RPL.
// . quick hack to repurpose for Xinha.
//
// -------------------------------------------------------
/**
* dumps message to stdout or log file depending upon global.
*
* checks $fvDEBUG["logfile"] global for name of file to dump
* messages to. Opens the file once.
*/
function dumpmsg( $msgline )
{
global $fvDEBUG;
if ( @$fvDEBUG[ "logfile" ] != NULL )
{
// only open the file once and store the handle in the global
// fvDEBUG array .. for now.
if ( @$fvDEBUG[ "logfile_fp" ] == NULL )
{
// we clear out the debug file on each run.
if (( $fvDEBUG[ "logfile_fp" ] = fopen( $fvDEBUG[ "logfile" ], "a" )) == NULL )
{
die( "ddt(): unable to open debug log" );
return false ;
}
}
fputs( $fvDEBUG[ "logfile_fp" ], "$msgline" );
fflush( $fvDEBUG[ "logfile_fp" ] );
}
else
{
echo $msgline;
}
} // end of dumpmsg.
/**
* displays a formatted debugging message.
*
* If ddtOn() was called, outputs a formatted debugging message.
*
* @param string $file filename, usually __FILE__
* @param string $line line number in file, usually __LINE__
* @param string $msg debugging message to display
*/
function _ddt( $file, $line, $msg )
{
global $_DDT;
global $_DDT_DEBUG_LOG;
global $_DDT_CMDLINE;
$basename = basename( $file );
if ( @$_DDT == "yes" )
{
if ( @$_DDT_CMDLINE == "yes" )
{
dumpmsg( basename( $file ) . ":$line: $msg \n" );
flush();
}
else
{
dumpmsg( "<p>$basename:$line: $msg</p>\n" );
}
}
} // end of _ddt
/**
* displays a formatted dump of an associative array.
*
* If ddtOn() was called, outputs a formatted debugging message showing
* contents of array.
*
* @param string $file filename, usually __FILE__
* @param string $line line number in file, usually __LINE__
* @param string $msg debugging message to display
* @param array $array_var array to dump.
*/
function _ddtArray( $file, $line, $msg, $array_var )
{
global $_DDT;
if ( $_DDT == "yes" )
{
dumpmsg( "<h2>$file:$line: $msg</h2>" );
foreach ( $array_var as $name => $value )
{
dumpmsg( "<p><b>$name</b> => <b>$value</b>\n" );
}
}
} // end of _ddtArray
// -----------------------------------------------------------------
/**
* Central Error Function.
*
* Displays a formatted error message to the user.
* If the global _DDT_ERROR_LOG is set the error message is dumped
* to that file instead of being displayed to the user.
*/
function _error( $file, $line, $msg )
{
global $_DDT_ERROR_LOG;
global $_DDT_CMDLINE;
if ( @$_DDT_ERROR_LOG == NULL )
{
if ( @$_DDT_CMDLINE == "yes" )
{
echo basename($file) . ":$line: $msg\n";
}
else
{
echo "<h2>$file:$line: $msg</h2>";
}
}
else
{
if (( $fp = fopen( $_DDT_ERROR_LOG, "a" )) != NULL )
{
fputs( $fp, date("D M j G:i:s T Y") . " - $file:$line: $msg\n" );
fclose( $fp );
}
}
} // end of _error
// ----------------------------------------------------------------------
function errorEcho( $title, $field )
{
global $error_msg;
if ( $error_msg[ $field ] != "" )
{
echo "<FONT SIZE=\"+2\" COLOR=\"RED\">$title</FONT>";
}
else
{
echo $title;
}
} // end of errorEcho
/**
* turns on procedural debugging.
*
* Causes _ddt() calls to display debugging messages.
*/
function _ddtOn()
{
global $_DDT;
$_DDT = "yes";
}
/**
* set error message destination.
*
* sets the destination for error messages.
*
* @param string $file full path to errorlog.
*/
function _setErrorLog( $errorLog )
{
global $_DDT_ERROR_LOG;
$_DDT_ERROR_LOG = $errorLog;
}
/**
* set output file for debugging messages.
*
* sets the destination file for debugging messages.
*
* @param string $file full path to debuglog.
*/
function _setDebugLog( $debugLog )
{
global $fvDEBUG;
$fvDEBUG[ "logfile" ] = $debugLog;
}
/**
* set debugging output style to command line.
*
* tells ddt to format debugging messages for a
* command line program.
*/
function _ddtSetCmdLine()
{
global $_DDT_CMDLINE;
$_DDT_CMDLINE = "yes";
}
// END
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/ddt.php | PHP | art | 5,027 |
<?php
/**
* Show a list of images in a long horizontal table.
* @author $Author:ray $
* @version $Id:images.php 987 2008-04-12 12:39:04Z ray $
* @package ImageManager
*/
require_once('config.inc.php');
require_once('ddt.php');
require_once('Classes/ImageManager.php');
// uncomment for debugging
// _ddtOn();
//default path is /
$relative = '/';
$manager = new ImageManager($IMConfig);
//process any file uploads
$manager->processUploads();
if($IMConfig['allow_delete'])
{
$manager->deleteFiles();
}
$refreshDir = false;
//process any directory functions
if(($IMConfig['allow_delete'] && $manager->deleteDirs()) || $manager->processNewDir())
$refreshDir = true;
//check for any sub-directory request
//check that the requested sub-directory exists
//and valid
if(isset($_REQUEST['dir']))
{
$path = rawurldecode($_REQUEST['dir']);
if($manager->validRelativePath($path))
$relative = $path;
}
$manager = new ImageManager($IMConfig);
//get the list of files and directories
$list = $manager->getFiles($relative);
/* ================= OUTPUT/DRAW FUNCTIONS ======================= */
/**
* Draw the files in an table.
*/
function drawFiles($list, &$manager)
{
global $relative;
global $IMConfig;
switch($IMConfig['ViewMode'])
{
case 'details':
{
?>
<script language="Javascript">
<!--
function showPreview(f_url)
{
window.parent.document.getElementById('f_preview').src =
window.parent._backend_url + '__function=thumbs&img=' + f_url;
}
//-->
</script>
<table class="listview">
<thead>
<tr><th>Name</th><th>Filesize</th><th>Dimensions</th></tr></thead>
<tbody>
<?php
foreach($list as $entry => $file)
{
?>
<tr>
<th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" onmouseover="showPreview('<?php echo $file['relative'];?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" ><?php echo $entry ?></a></th>
<td><?php echo Files::formatSize($file['stat']['size']); ?></td>
<td><?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } ?></td>
<td class="actions">
<?php
if($IMConfig['allow_delete'])
{
?>
<a href="<?php print $IMConfig['backend_url']; ?>__function=images&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0" /></a>
<?php
}
?>
<?php
if($IMConfig['allow_edit'])
{
?>
<a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" border="0" /></a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
break;
case 'thumbs':
default :
{
foreach($list as $entry => $file)
{
?>
<div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>">
<a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>">
<img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"/>
</a>
<div class="edit">
<?php
if($IMConfig['allow_delete'])
{
?>
<a href="<?php print $IMConfig['backend_url']; ?>__function=images&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a>
<?php
}
?>
<?php
if($IMConfig['allow_edit'])
{
?>
<a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" /></a>
<?php
}
?>
<?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?>
</div>
</div>
<?php
}
}
}
}//function drawFiles
/**
* Draw the directory.
*/
function drawDirs($list, &$manager)
{
global $relative;
global $IMConfig;
switch($IMConfig['ViewMode'])
{
case 'details':
{
}
break;
case 'thumbs':
default :
{
foreach($list as $path => $dir)
{ ?>
<div class="dir_holder">
<a class="dir" href="<?php print $IMConfig['backend_url'];?>__function=images&dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="<?php print $IMConfig['base_url'];?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>
<div class="edit">
<?php
if($IMConfig['allow_delete'])
{
?>
<a href="<?php print $IMConfig['backend_url'];?>__function=images&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>
<?php
}
?>
<?php echo $dir['entry']; ?>
</div>
</div>
<?php
} //foreach
}
}
}//function drawDirs
/**
* No directories and no files.
*/
function drawNoResults()
{
?>
<div class="noResult">No Images Found</div>
<?php
}
/**
* No directories and no files.
*/
function drawErrorBase(&$manager)
{
?>
<div class="error"><span>Invalid base directory:</span> <?php echo $manager->config['images_dir']; ?></div>
<?php
}
/**
* Utility to convert ascii string to hex
*/
function asc2hex ($temp)
{
$len = strlen($temp);
$data = "";
for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1)));
return $data;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Image List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
_backend_url = "<?php print $IMConfig['backend_url']; ?>";
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
if(window.top)
HTMLArea = Xinha = window.top.Xinha;
function hideMessage()
{
var topDoc = window.top.document;
var messages = topDoc.getElementById('messages');
if(messages)
messages.style.display = "none";
}
init = function()
{
__dlg_translate('ImageManager');
hideMessage();
var topDoc = window.top.document;
<?php
//we need to refesh the drop directory list
//save the current dir, delete all select options
//add the new list, re-select the saved dir.
if($refreshDir)
{
$dirs = $manager->getDirs();
?>
var selection = topDoc.getElementById('dirPath');
var currentDir = selection.options[selection.selectedIndex].text;
while(selection.length > 0)
{ selection.remove(0); }
selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");
<?php foreach($dirs as $relative=>$fullpath) { ?>
selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");
<?php } ?>
for(var i = 0; i < selection.length; i++)
{
var thisDir = selection.options[i].text;
if(thisDir == currentDir)
{
selection.selectedIndex = i;
break;
}
}
<?php } ?>
update_selected();
}
function editImage(image)
{
var url = "<?php print $IMConfig['backend_url']; ?>__function=editor&img="+image;
Dialog(url, function(param)
{
if (!param) // user must have pressed Cancel
return false;
else
{
return true;
}
}, null);
}
/*]]>*/
</script>
<script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
<script type="text/javascript" src="../../popups/popup.js"></script>
<script type="text/javascript" src="assets/popup.js"></script>
</head>
<body>
<?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>
<?php drawDirs($list[0], $manager); ?>
<?php drawFiles($list[1], $manager); ?>
<?php } else { drawNoResults(); } ?>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/images.php | PHP | art | 9,824 |
body
{
margin: 0; padding: 0;
font: 11px Tahoma,Verdana,sans-serif;
}
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
#indicator
{
width: 25px;
height: 20px;
background-color: #eef;
padding: 15px 20px;
position: absolute;
left: 0; top: 0;
}
* html #indicator
{
padding: 14px 22px;
}
#tools
{
width: 600px;
height: 50px;
background-color: #eef;
padding: 0;
position: absolute;
left: 63px;
border-left: 1px solid white;
border-bottom: 1px solid white;
}
#toolbar
{
width: 53px;
height: 435px;
background-color: #eef;
float: left;
text-align: center;
padding: 5px;
position: absolute;
top: 50px;
border-top: 1px solid white;
border-right: 1px solid white;
}
#contents
{
width: 600px;
height: 445px;
position: absolute;
left: 64px; top: 51px;
}
#editor
{
width: 600px;
height: 445px;
}
#toolbar a
{
padding: 5px;
width: 40px;
display: block;
border: 1px solid #eef;
text-align: center;
text-decoration: none;
color: #669;
margin: 5px 0;
}
#toolbar a:hover
{
background-color: #F9F9FF;
border-color: #669;
}
#toolbar a.iconActive
{
border-color: #669;
}
#toolbar a span
{
display: block;
text-decoration: none;
}
#toolbar a img
{
border: 0 none;
}
#tools .textInput
{
width: 3em;
vertical-align: 0px;
}
* html #tools .textInput
{
vertical-align: middle;
}
#tools .measureStats
{
width: 4.5em;
border: 0 none;
background-color: #eef;
vertical-align: 0px;
}
* html #tools .measureStats
{
vertical-align: middle;
}
#tools label
{
margin: 0 2px 0 5px;
}
#tools input
{
vertical-align: middle;
}
#tools #tool_inputs
{
padding-top: 10px;
float: left;
}
#tools .div
{
vertical-align: middle;
margin: 0 5px;
}
#tools img
{
border: 0 none;
}
#tools a.buttons
{
margin-top: 10px;
border: 1px solid #eef;
display: block;
float: left;
}
#tools a.buttons:hover
{
background-color: #F9F9FF;
border-color: #669;
}
#slidercasing {
/*border:1px solid #CCCCCC;
background-color:#FFFFFF;*/
width:100px;
height:5px;
position:relative;
z-index:4;
padding:10px;
top: 6px;
margin: 0 -5px 0 -10px;
}
#slidertrack {
position:relative;
border:1px solid #CCCCCC;
background-color:#FFFFCC;
z-index:5;
height:5px;
}
#sliderbar {
position:absolute;
z-index:6;
border:1px solid #CCCCCC;
background-color:#DDDDDD;
width:15px;
padding:0px;
height:20px;
cursor: pointer;
top:2px;
}
* html #slidercasing
{
top:0;
}
#bottom
{
position: relative;
top: 490px;
}
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/editor.css | CSS | art | 3,009 |
body { margin: 0; padding: 0; }
.edit { font-size: small; font-family: small-caption, sans-serif; padding-top: 3px;}
.edit a { border: none; padding: 3px; text-decoration:none; }
.edit a:hover { background-color: ButtonHighlight; }
.edit a img { border: none; vertical-align: bottom; }
.noResult { font-size:large; font-weight:bold; color:#ccc; font-family: Helvetica, sans-serif; text-align: center; padding-top: 60px; }
.error { color:#c00; font-weight:bold; font-size: medium; font-family: Helvetica, sans-serif; text-align: center; padding-top: 65px;}
.dir_holder, .thumb_holder
{
width:110px; height:132px;
float:left;
margin:6px;
background-color:ButtonFace;
border: 1px outset;
}
.thumb_holder.active
{
background:Highlight;
color:HighlightText;
border:1px dashed Highlight;
}
.dir_holder a.dir, .thumb_holder a.thumb
{
height:100px;
display:block;
text-align:center;
padding:5px;
text-decoration:none;
}
.thumb_holder a.thumb img
{
border:1px solid black;
}
.dir_holder a.dir img
{
border:none;
}
.listview { width:100% }
.listview td, .listview th { text-align:left; font-size:small; }
.listview td.actions { text-align:right; }
.listview td.actions img { border:0px; }
.flk-license { font-size: xx-small; text-align:center; }
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/imagelist.css | CSS | art | 1,327 |
/***********************************************************************
** Title.........: Simple Lite Slider for Image Editor
** Version.......: 1.1
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: slider.js
** Last changed..: 31 Mar 2004
** Notes.........: Works in IE and Mozilla
**/
var ie=document.all
var ns6=document.getElementById&&!document.all
document.onmouseup = captureStop;
var currentSlider = null,sliderField = null;
var rangeMin = null, rangeMax= null, sx = -1, sy = -1, initX=0;
function getMouseXY(e) {
//alert('hello');
x = ns6? e.clientX: event.clientX
y = ns6? e.clientY: event.clientY
if (sx < 0) sx = x; if (sy < 0) sy = y;
var dx = initX +(x-sx);
if (dx <= rangeMin)
dx = rangeMin;
else if (dx >= rangeMax)
dx = rangeMax;
var range = (dx-rangeMin)/(rangeMax - rangeMin)*100;
if (currentSlider != null)
currentSlider.style.left = dx+"px";
if (sliderField != null)
{
sliderField.value = parseInt(range);
}
return false;
}
function initSlider()
{
if (currentSlider == null)
currentSlider = document.getElementById('sliderbar');
if (sliderField == null)
sliderField = document.getElementById('quality');
if (rangeMin == null)
rangeMin = 3
if (rangeMax == null)
{
var track = document.getElementById('slidertrack');
rangeMax = parseInt(track.style.width);
}
}
function updateSlider(value)
{
initSlider();
var newValue = parseInt(value)/100*(rangeMax-rangeMin);
if (newValue <= rangeMin)
newValue = rangeMin;
else if (newValue >= rangeMax)
newValue = rangeMax;
if (currentSlider != null)
currentSlider.style.left = newValue+"px";
var range = newValue/(rangeMax - rangeMin)*100;
if (sliderField != null)
sliderField.value = parseInt(range);
}
function captureStart()
{
initSlider();
initX = parseInt(currentSlider.style.left);
if (initX > rangeMax)
initX = rangeMax;
else if (initX < rangeMin)
initX = rangeMin;
document.onmousemove = getMouseXY;
return false;
}
function captureStop()
{
sx = -1; sy = -1;
document.onmousemove = null;
return false;
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/slider.js | JavaScript | art | 2,313 |
/***********************************************************************
** Title.........: Javascript Graphics
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: wz_jsgraphics.js
** Last changed..: 31 Aug 2003
** Notes.........: Modified for Image Editor, added extra commands
**/
/* This notice must be untouched at all times.
wz_jsgraphics.js v. 2.03
The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de
Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
Created 3. 11. 2002 by Walter Zorn <walter@kreuzotter.de>
Last modified: 11. 6. 2003
High Performance JavaScript Graphics Library.
Provides methods
- to draw lines, rectangles, ellipses, polygons
with specifiable line thickness,
- to fill rectangles and ellipses
- to draw text.
NOTE: Operations, functions and branching have rather been optimized
to efficiency and speed than to shortness of source code.
This program is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License
at http://www.gnu.org/copyleft/gpl.html for more details.
*/
var jg_ihtm, jg_ie, jg_dom,
jg_n4 = (document.layers && typeof document.classes != "undefined");
function chkDHTM(x, i)
{
x = document.body || null;
jg_ie = (x && typeof x.insertAdjacentHTML != "undefined");
jg_dom = (x && !jg_ie &&
typeof x.appendChild != "undefined" &&
typeof document.createRange != "undefined" &&
typeof (i = document.createRange()).setStartBefore != "undefined" &&
typeof i.createContextualFragment != "undefined");
jg_ihtm = (!jg_ie && !jg_dom && x && typeof x.innerHTML != "undefined");
}
function pntDoc()
{
this.wnd.document.write(this.htm);
this.htm = '';
}
function pntCnvDom()
{
var x = document.createRange();
x.setStartBefore(this.cnv);
x = x.createContextualFragment(this.htm);
this.cnv.appendChild(x);
this.htm = '';
}
function pntCnvIe()
{
this.cnv.insertAdjacentHTML("BeforeEnd", this.htm);
this.htm = '';
}
function pntCnvIhtm()
{
this.cnv.innerHTML += this.htm;
this.htm = '';
}
function pntCnv()
{
this.htm = '';
}
function mkDiv(x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;background-color:' + this.color + ';'+
'"><\/div>';
//alert(this.htm);
}
function mkDivPrint(x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'border-left:' + w + 'px solid ' + this.color + ';'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;background-color:' + this.color + ';'+
'"><\/div>';
}
function mkLyr(x, y, w, h)
{
this.htm += '<layer '+
'left="' + x + '" '+
'top="' + y + '" '+
'width="' + w + '" '+
'height="' + h + '" '+
'bgcolor="' + this.color + '"><\/layer>\n';
}
function mkLbl(txt, x, y)
{
this.htm += '<div style="position:absolute;white-space:nowrap;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'font-family:' + this.ftFam + ';'+
'font-size:' + this.ftSz + ';'+
'color:' + this.color + ';' + this.ftSty + '">'+
txt +
'<\/div>';
}
function mkLin(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1;
if (dx >= dy)
{
var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx,
ox = x;
while ((dx--) > 0)
{
++x;
if (p > 0)
{
this.mkDiv(ox, y, x-ox, 1);
y += yIncr;
p += pru;
ox = x;
}
else p += pr;
}
this.mkDiv(ox, y, x2-ox+1, 1);
}
else
{
var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy,
oy = y;
if (y2 <= y1)
{
while ((dy--) > 0)
{
if (p > 0)
{
this.mkDiv(x++, y, 1, oy-y+1);
y += yIncr;
p += pru;
oy = y;
}
else
{
y += yIncr;
p += pr;
}
}
this.mkDiv(x2, y2, 1, oy-y2+1);
}
else
{
while ((dy--) > 0)
{
y += yIncr;
if (p > 0)
{
this.mkDiv(x++, oy, 1, y-oy);
p += pru;
oy = y;
}
else p += pr;
}
this.mkDiv(x2, oy, 1, y2-oy+1);
}
}
}
function mkLin2D(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1;
var s = this.stroke;
if (dx >= dy)
{
if (s-0x3 > 0)
{
var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
_s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1;
}
else var _s = s;
var ad = Math.ceil(s/2);
var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx,
ox = x;
while ((dx--) > 0)
{
++x;
if (p > 0)
{
this.mkDiv(ox, y, x-ox+ad, _s);
y += yIncr;
p += pru;
ox = x;
}
else p += pr;
}
this.mkDiv(ox, y, x2-ox+ad+1, _s);
}
else
{
if (s-0x3 > 0)
{
var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
_s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1;
}
else var _s = s;
var ad = Math.round(s/2);
var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy,
oy = y;
if (y2 <= y1)
{
++ad;
while ((dy--) > 0)
{
if (p > 0)
{
this.mkDiv(x++, y, _s, oy-y+ad);
y += yIncr;
p += pru;
oy = y;
}
else
{
y += yIncr;
p += pr;
}
}
this.mkDiv(x2, y2, _s, oy-y2+ad);
}
else
{
while ((dy--) > 0)
{
y += yIncr;
if (p > 0)
{
this.mkDiv(x++, oy, _s, y-oy+ad);
p += pru;
oy = y;
}
else p += pr;
}
this.mkDiv(x2, oy, _s, y2-oy+ad+1);
}
}
}
function mkLinDott(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1,
drw = true;
if (dx >= dy)
{
var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx;
while ((dx--) > 0)
{
if (drw) this.mkDiv(x, y, 1, 1);
drw = !drw;
if (p > 0)
{
y += yIncr;
p += pru;
}
else p += pr;
++x;
}
if (drw) this.mkDiv(x, y, 1, 1);
}
else
{
var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy;
while ((dy--) > 0)
{
if (drw) this.mkDiv(x, y, 1, 1);
drw = !drw;
y += yIncr;
if (p > 0)
{
++x;
p += pru;
}
else p += pr;
}
if (drw) this.mkDiv(x, y, 1, 1);
}
}
function mkOv(left, top, width, height)
{
var a = width>>1, b = height>>1,
wod = width&1, hod = (height&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
ox = 0, oy = b,
aa = (a*a)<<1, bb = (b*b)<<1,
st = (aa>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa*((b<<1)-1),
w, h;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+0x3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
w = x-ox;
h = oy-y;
if (w&0x2 && h&0x2)
{
this.mkOvQds(cx, cy, -x+0x2, ox+wod, -oy, oy-1+hod, 1, 1);
this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1);
}
else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h);
ox = x;
oy = y;
}
else
{
tt -= aa*((y<<1)-0x3);
st -= (aa<<1)*(--y);
}
}
this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod);
}
function mkOv2D(left, top, width, height)
{
var s = this.stroke;
width += s-1;
height += s-1;
var a = width>>1, b = height>>1,
wod = width&1, hod = (height&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
aa = (a*a)<<1, bb = (b*b)<<1,
st = (aa>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa*((b<<1)-1);
if (s-0x4 < 0 && (!(s-0x2) || width-0x33 > 0 && height-0x33 > 0))
{
var ox = 0, oy = b,
w, h,
pxl, pxr, pxt, pxb, pxw;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+0x3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
w = x-ox;
h = oy-y;
if (w-1)
{
pxw = w+1+(s&1);
h = s;
}
else if (h-1)
{
pxw = s;
h += 1+(s&1);
}
else pxw = h = s;
this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h);
ox = x;
oy = y;
}
else
{
tt -= aa*((y<<1)-0x3);
st -= (aa<<1)*(--y);
}
}
this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod);
}
else
{
var _a = (width-((s-1)<<1))>>1,
_b = (height-((s-1)<<1))>>1,
_x = 0, _y = _b,
_aa = (_a*_a)<<1, _bb = (_b*_b)<<1,
_st = (_aa>>1)*(1-(_b<<1)) + _bb,
_tt = (_bb>>1) - _aa*((_b<<1)-1),
pxl = new Array(),
pxt = new Array(),
_pxb = new Array();
pxl[0] = 0;
pxt[0] = b;
_pxb[0] = _b-1;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+0x3);
tt += (bb<<1)*(++x);
pxl[pxl.length] = x;
pxt[pxt.length] = y;
}
else if (tt < 0)
{
st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
pxl[pxl.length] = x;
pxt[pxt.length] = y;
}
else
{
tt -= aa*((y<<1)-0x3);
st -= (aa<<1)*(--y);
}
if (_y > 0)
{
if (_st < 0)
{
_st += _bb*((_x<<1)+0x3);
_tt += (_bb<<1)*(++_x);
_pxb[_pxb.length] = _y-1;
}
else if (_tt < 0)
{
_st += _bb*((_x<<1)+0x3) - (_aa<<1)*(_y-1);
_tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-0x3);
_pxb[_pxb.length] = _y-1;
}
else
{
_tt -= _aa*((_y<<1)-0x3);
_st -= (_aa<<1)*(--_y);
_pxb[_pxb.length-1]--;
}
}
}
var ox = 0, oy = b,
_oy = _pxb[0],
l = pxl.length,
w, h;
for (var i = 0; i < l; i++)
{
if (typeof _pxb[i] != "undefined")
{
if (_pxb[i] < _oy || pxt[i] < oy)
{
x = pxl[i];
this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy);
ox = x;
oy = pxt[i];
_oy = _pxb[i];
}
}
else
{
x = pxl[i];
this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
ox = x;
oy = pxt[i];
}
}
this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
}
}
function mkOvDott(left, top, width, height)
{
var a = width>>1, b = height>>1,
wod = width&1, hod = height&1,
cx = left+a, cy = top+b,
x = 0, y = b,
aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
st = (aa2>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa2*((b<<1)-1),
drw = true;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+0x3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+0x3) - aa4*(y-1);
tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3);
}
else
{
tt -= aa2*((y<<1)-0x3);
st -= aa4*(--y);
}
if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1);
drw = !drw;
}
}
function mkRect(x, y, w, h)
{
var s = this.stroke;
this.mkDiv(x, y, w, s);
this.mkDiv(x+w, y, s, h);
this.mkDiv(x, y+h, w+s, s);
this.mkDiv(x, y+s, s, h-s);
}
function mkRectDott(x, y, w, h)
{
this.drawLine(x, y, x+w, y);
this.drawLine(x+w, y, x+w, y+h);
this.drawLine(x, y+h, x+w, y+h);
this.drawLine(x, y, x, y+h);
}
function jsgFont()
{
this.PLAIN = 'font-weight:normal;';
this.BOLD = 'font-weight:bold;';
this.ITALIC = 'font-style:italic;';
this.ITALIC_BOLD = this.ITALIC + this.BOLD;
this.BOLD_ITALIC = this.ITALIC_BOLD;
}
var Font = new jsgFont();
function jsgStroke()
{
this.DOTTED = -1;
}
var Stroke = new jsgStroke();
function jsGraphics(id, wnd)
{
this.setColor = new Function('arg', 'this.color = arg;');
this.getColor = new Function('return this.color');
this.setStroke = function(x)
{
this.stroke = x;
if (!(x+1))
{
this.drawLine = mkLinDott;
this.mkOv = mkOvDott;
this.drawRect = mkRectDott;
}
else if (x-1 > 0)
{
this.drawLine = mkLin2D;
this.mkOv = mkOv2D;
this.drawRect = mkRect;
}
else
{
this.drawLine = mkLin;
this.mkOv = mkOv;
this.drawRect = mkRect;
}
};
this.setPrintable = function(arg)
{
this.printable = arg;
this.mkDiv = jg_n4? mkLyr : arg? mkDivPrint : mkDiv;
};
this.setFont = function(fam, sz, sty)
{
this.ftFam = fam;
this.ftSz = sz;
this.ftSty = sty || Font.PLAIN;
};
this.drawPolyline = this.drawPolyLine = function(x, y, s)
{
var i = x.length-1; while (i >= 0)
this.drawLine(x[i], y[i], x[--i], y[i]);
};
this.fillRect = function(x, y, w, h)
{
this.mkDiv(x, y, w, h);
};
this.fillRectPattern = function(x, y, w, h, url)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;'+
//'background-color:' + this.color + ';'+
"background-image: url('" + url + "');"+
"layer-background-image: url('" + url + "');"+
'z-index:100;"><\/div>';
//alert(this.htm);
}
this.drawHandle = function(x, y, w, h, cursor)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'padding: 2px;overflow:hidden;'+
"cursor: '" + cursor + "';"+
'" class="handleBox" id="' + cursor + '" ><\/div>';
}
this.drawHandleBox = function(x, y, w, h, cursor)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+(w+2)+'px,'+(h+2)+'px,0);'+
'overflow:hidden; border: solid 1px '+ this.color+';'+
"cursor: '" + cursor + "';"+
'" class="handleBox" id="' + cursor + '" ><\/div>';
}
this.drawPolygon = function(x, y)
{
this.drawPolyline(x, y);
this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
};
this.drawEllipse = this.drawOval = function(x, y, w, h)
{
this.mkOv(x, y, w, h);
};
this.fillEllipse = this.fillOval = function(left, top, w, h)
{
var a = (w -= 1)>>1, b = (h -= 1)>>1,
wod = (w&1)+1, hod = (h&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
ox = 0, oy = b,
aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
st = (aa2>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa2*((b<<1)-1),
pxl, dw, dh;
if (w+1) while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+0x3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+0x3) - aa4*(y-1);
pxl = cx-x;
dw = (x<<1)+wod;
tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3);
dh = oy-y;
this.mkDiv(pxl, cy-oy, dw, dh);
this.mkDiv(pxl, cy+oy-dh+hod, dw, dh);
ox = x;
oy = y;
}
else
{
tt -= aa2*((y<<1)-0x3);
st -= aa4*(--y);
}
}
this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod);
};
this.drawString = mkLbl;
this.clear = function()
{
this.htm = "";
if (this.cnv) this.cnv.innerHTML = this.defhtm;
};
this.mkOvQds = function(cx, cy, xl, xr, yt, yb, w, h)
{
this.mkDiv(xr+cx, yt+cy, w, h);
this.mkDiv(xr+cx, yb+cy, w, h);
this.mkDiv(xl+cx, yb+cy, w, h);
this.mkDiv(xl+cx, yt+cy, w, h);
};
this.setStroke(1);
this.setPrintable(false);
this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN);
this.color = '#000000';
this.htm = '';
this.wnd = wnd || window;
if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM();
if (typeof id != 'string' || !id) this.paint = pntDoc;
else
{
this.cnv = document.all? (this.wnd.document.all[id] || null)
: document.getElementById? (this.wnd.document.getElementById(id) || null)
: null;
this.defhtm = (this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : '';
this.paint = jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv;
}
}
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/wz_jsgraphics.js | JavaScript | art | 20,802 |
/**
* Functions for the image listing, used by images.php only
* @author $Author:gogo $
* @version $Id:images.js 927 2008-01-08 03:40:02Z gogo $
* @package ImageManager
*/
function i18n(str) {
return Xinha._lc(str, 'ImageManager');
}
function changeDir(newDir)
{
showMessage('Loading');
// backend_url is defined in the calling page. For now we
// assume it has a trailing &
location.href = _backend_url + "__function=images&dir="+encodeURIComponent(newDir);
}
function newFolder(dir, newDir)
{
location.href = _backend_url + "__function=images&dir="+encodeURIComponent(dir)+"&newDir="+encodeURIComponent(newDir);
}
//update the dir list in the parent window.
function updateDir(newDir)
{
var selection = window.top.document.getElementById('dirPath');
if(selection)
{
for(var i = 0; i < selection.length; i++)
{
var thisDir = selection.options[i].text;
if(thisDir == newDir)
{
selection.selectedIndex = i;
showMessage('Loading');
break;
}
}
}
}
function selectImage(filename, alt, width, height)
{
var topDoc = window.top.document;
var obj = topDoc.getElementById('f_url'); obj.value = filename;
var obj = topDoc.getElementById('f_width'); obj.value = width;
var obj = topDoc.getElementById('f_width'); obj.value = width;
var obj = topDoc.getElementById('f_height'); obj.value = height;
var obj = topDoc.getElementById('f_alt'); obj.value = alt;
var obj = topDoc.getElementById('orginal_width'); obj.value = width;
var obj = topDoc.getElementById('orginal_height'); obj.value = height;
// Set preview for the selected
topDoc.getElementById('f_preview').src = window.parent._backend_url + '__function=thumbs&img=' + encodeURIComponent(filename);
update_selected();
}
var _current_selected = null;
function update_selected()
{
var topDoc = window.top.document;
if(_current_selected)
{
_current_selected.className = _current_selected.className.replace(/(^| )active( |$)/, '$1$2');
_current_selected = null;
}
// Grab the current file, and highlight it if we have it
var c_file = topDoc.getElementById('f_url').value;
var selection = topDoc.getElementById('dirPath');
var currentDir = selection.options[selection.selectedIndex].text;
var dRe = new RegExp('^(' + currentDir.replace(/([\/\^$*+?.()|{}[\]])/g, '\\$1') + ')([^/]*)$');
if(dRe.test(c_file))
{
var holder = document.getElementById('holder_' + asc2hex(RegExp.$2));
if(holder)
{
_current_selected = holder;
holder.className += ' active';
}
}
}
function asc2hex(str)
{
var hexstr = '';
for(var i = 0; i < str.length; i++)
{
var hex = (str.charCodeAt(i)).toString(16);
if(hex.length == 1) hex = '0' + hex;
hexstr += hex;
}
return hexstr;
}
function showMessage(newMessage)
{
var topDoc = window.top.document;
var message = topDoc.getElementById('message');
var messages = topDoc.getElementById('messages');
if(message && messages)
{
if(message.firstChild)
message.removeChild(message.firstChild);
message.appendChild(topDoc.createTextNode(i18n(newMessage)));
messages.style.display = "block";
}
}
function addEvent(obj, evType, fn)
{
if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; }
else { return false; }
}
function confirmDeleteFile(file)
{
if(confirm(i18n("Delete file?")))
return true;
return false;
}
function confirmDeleteDir(dir, count)
{
if(count > 0)
{
alert(i18n("Please delete all files/folders inside the folder you wish to delete first."));
return;
}
if(confirm(i18n("Delete folder?")))
return true;
return false;
}
addEvent(window, 'load', init);
Xinha = window.parent.Xinha;
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/images.js | JavaScript | art | 3,953 |
// htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc.
// This copyright notice MUST stay intact for use (see license.txt).
//
// Portions (c) dynarch.com, 2003
//
// A free WYSIWYG editor replacement for <textarea> fields.
// For full source code and docs, visit http://www.interactivetools.com/
//
// Version 3.0 developed by Mihai Bazon.
// http://dynarch.com/mishoo
//
// $Id:popup.js 856 2007-06-13 18:34:34Z wymsy $
// Override the ordinary popup.js translation to add translation for a few other HTML elements.
function __dlg_translate(context) {
var types = ["span", "option", "td", "th", "button", "div", "label", "a","img", "legend"];
for (var type = 0; type < types.length; ++type) {
var spans = document.getElementsByTagName(types[type]);
for (var i = spans.length; --i >= 0;) {
var span = spans[i];
if (span.firstChild && span.firstChild.data) {
var txt = Xinha._lc(span.firstChild.data, context);
if (txt)
span.firstChild.data = txt;
}
if (span.title) {
var txt = Xinha._lc(span.title, context);
if (txt)
span.title = txt;
}
if (span.alt) {
var txt = Xinha._lc(span.alt, context);
if (txt)
span.alt = txt;
}
}
}
document.title = Xinha._lc(document.title, context);
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/popup.js | JavaScript | art | 1,519 |
html, body, .dialog { background-color: ButtonFace; color: ButtonText; font: 11px Tahoma,Verdana,sans-serif; margin: 0; padding: 0;}
body { padding: 5px; }
fieldset { padding: 0;}
.title { background-color: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; border-bottom: 1px solid black; letter-spacing: 2px;}
form { padding: 0px; margin: 0 auto; width: 550px;}
a { padding: 5px; border: 1px solid ButtonFace; }
a img { border: 0; }
a:hover { border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; }
.dirs { padding: 1em; }
.imageFrame { width: 100%; height: 145px; margin: 0 auto; margin-top: 1em; background-color: White;}
#youtubeChooser .imageFrame { height: 155px; }
.smallWidth{ width: 4em; }
.largelWidth{ width: 22em; }
.inputTable { margin: 1em auto; }
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
.buttons { width: 70px; text-align: center; }
.clearboth{ clear: both; }
#messages { position: relative; left: 175px; top: 115px; background-color: white; width:200px; float: left; margin-top: -52px; border: 1px solid #ccc; text-align: center; padding: 15px; }
#message { font-size: 15px; font-weight: bold; color: #69c; }
iframe { border:1px inset; border-right:none; border-left:none; border-bottom:none; }
table { margin-top:10px; }
th, td { padding-right:3px; text-align:left; font-family:small-caption,helvetica,sans-serif; }
.buttonColor {
width :1em;
margin-left: 2px;
cursor: default;
}
.buttonColor .chooser, .buttonColor .nocolor {
height: 0.6em;
border: 1px solid;
padding: 0px 1em;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.buttonColor .buttonClick {
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.buttonColor .buttonColor-hilite {
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.buttonColor .nocolor { padding: 0px; }
.buttonColor .nocolor-hilite { background-color: #fff; color: #f00; }
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/manager.css | CSS | art | 2,015 |
body { margin: 0; padding: 0; background-color: #eee; }
table { width: 100%; }
table td { text-align: center; }
.crop{cursor:crosshair;}
.selection { border: dotted 1px #000000; position:absolute; width: 0px; height: 1px; z-index:5; }
.selectionWhite{ border: dotted 1px #FFFFFF; position:absolute; width: 0px; height: 1px; z-index:5; }
.handleBox{ z-index:105; }
.error { font-size:large; font-weight:bold; color:#c00; font-family: Helvetica, sans-serif; } | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/editorFrame.css | CSS | art | 466 |
// Dialog v3.0 - Copyright (c) 2003-2004 interactivetools.com, inc.
// This copyright notice MUST stay intact for use (see license.txt).
//
// Portions (c) dynarch.com, 2003-2004
//
// A free WYSIWYG editor replacement for <textarea> fields.
// For full source code and docs, visit http://www.interactivetools.com/
//
// Version 3.0 developed by Mihai Bazon.
// http://dynarch.com/mishoo
//
// $Id:dialog.js 929 2008-01-09 21:10:59Z ray $
// Though "Dialog" looks like an object, it isn't really an object. Instead
// it's just namespace for protecting global symbols.
function Dialog(url, action, init) {
if (typeof init == "undefined") {
init = window; // pass this window object by default
}
if (typeof window.showModalDialog == 'function')
{
Dialog._return = action;
var r = window.showModalDialog(url, init, "dialogheight=10;dialogwidth=10;resizable=yes");
}
else
{
Dialog._geckoOpenModal(url, action, init);
}
}
Dialog._parentEvent = function(ev) {
setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
if (Dialog._modal && !Dialog._modal.closed) {
Dialog._stopEvent(ev);
}
};
// should be a function, the return handler of the currently opened dialog.
Dialog._return = null;
// constant, the currently opened dialog
Dialog._modal = null;
// the dialog will read it's args from this variable
Dialog._arguments = null;
Dialog._geckoOpenModal = function(url, action, init) {
//var urlLink = "hadialog"+url.toString();
var myURL = "hadialog"+url;
var regObj = /\W/g;
myURL = myURL.replace(regObj,'_');
var dlg = window.open(url, myURL,
"toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
"scrollbars=no,resizable=yes,modal=yes,dependable=yes");
Dialog._modal = dlg;
Dialog._arguments = init;
// capture some window's events
function capwin(w) {
Dialog._addEvent(w, "click", Dialog._parentEvent);
Dialog._addEvent(w, "mousedown", Dialog._parentEvent);
Dialog._addEvent(w, "focus", Dialog._parentEvent);
}
// release the captured events
function relwin(w) {
Dialog._removeEvent(w, "click", Dialog._parentEvent);
Dialog._removeEvent(w, "mousedown", Dialog._parentEvent);
Dialog._removeEvent(w, "focus", Dialog._parentEvent);
}
capwin(window);
// capture other frames
for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
// make up a function to be called when the Dialog ends.
Dialog._return = function (val) {
if (val && action) {
action(val);
}
relwin(window);
// capture other frames
for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
Dialog._modal = null;
};
};
// event handling
Dialog._addEvent = function(el, evname, func) {
if (Dialog.is_ie) {
el.attachEvent("on" + evname, func);
} else {
el.addEventListener(evname, func, true);
}
};
Dialog._removeEvent = function(el, evname, func) {
if (Dialog.is_ie) {
el.detachEvent("on" + evname, func);
} else {
el.removeEventListener(evname, func, true);
}
};
Dialog._stopEvent = function(ev) {
if (Dialog.is_ie) {
ev.cancelBubble = true;
ev.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
};
Dialog.agt = navigator.userAgent.toLowerCase();
Dialog.is_ie = ((Dialog.agt.indexOf("msie") != -1) && (Dialog.agt.indexOf("opera") == -1)); | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/dialog.js | JavaScript | art | 3,338 |
.icons {
font: 11px Tahoma,Verdana,sans-serif;
color: #666699;
text-align: center;
text-decoration: none;
border: 1px solid #EEEEFF;
-Moz-Border-Radius: 6px 6px 6px 6px;
}
body, td, p {
font: 11px Tahoma,Verdana,sans-serif;
}
.iconsOver {
font: 11px Tahoma,Verdana,sans-serif;
color: #666699;
text-align: center;
text-decoration: none;
background-color: #F9F9FF;
border: 1px solid #666699;
-Moz-Border-Radius: 6px 6px 6px 6px;
}
.topBar {
font: 11px Tahoma,Verdana,sans-serif;
color: #666699;
}
.iconsSel {
font: 11px Tahoma,Verdana,sans-serif;
color: #666699;
text-align: center;
text-decoration: none;
border: 1px solid #666699;
-Moz-Border-Radius: 6px 6px 6px 6px;
}
.iconText {
font: 11px Tahoma,Verdana,sans-serif;
color: #666699;
text-decoration: none;
text-align: center;
}
.measureStats{
width: 50px;
}
#slidercasing {
/*border:1px solid #CCCCCC;
background-color:#FFFFFF;*/
width:100px;
height:5px;
position:relative;
z-index:4;
padding:10px;
}
#slidertrack {
position:relative;
border:1px solid #CCCCCC;
background-color:#FFFFCC;
z-index:5;
height:5px;
}
#sliderbar {
position:absolute;
z-index:6;
border:1px solid #CCCCCC;
background-color:#DDDDDD;
width:15px;
padding:0px;
height:20px;
cursor: pointer;
top:2px;
}
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/ImageEditor.css | CSS | art | 1,495 |
/**
* Functions for the ImageManager, used by manager.php only
* @author $Author:gogo $
* @version $Id:manager.js 877 2007-08-12 15:50:03Z gogo $
* @package ImageManager
*/
//Translation
function i18n(str) {
return Xinha._lc(str, 'ImageManager');
}
//set the alignment options
function setAlign(align)
{
var selection = document.getElementById('f_align');
for(var i = 0; i < selection.length; i++)
{
if(selection.options[i].value == align)
{
selection.selectedIndex = i;
break;
}
}
}
//initialise the form
doneinit = 0; // Seems that in Opera the load event of the iframe re-fires this one also.
init = function ()
{
if(doneinit++) return;
__dlg_init(null, {width:600,height:460});
__dlg_translate('ImageManager');
// This is so the translated string shows up in the drop down.
document.getElementById("f_align").selectedIndex = 1;
document.getElementById("f_align").selectedIndex = 0;
var uploadForm = document.getElementById('uploadForm');
if(uploadForm) uploadForm.target = 'imgManager';
var param = window.dialogArguments;
if (param)
{
var image_regex = new RegExp( '(https?://[^/]*)?' + base_url.replace(/\/$/, '') );
param.f_url = param.f_url.replace( image_regex, "" );
// The image URL may reference one of the automatically resized images
// (when the user alters the dimensions in the picker), clean that up
// so it looks right and we get back to a normal f_url
var rd = (_resized_dir) ? _resized_dir.replace(Xinha.RE_Specials, '\\$1') + '/' : '';
var rp = _resized_prefix.replace(Xinha.RE_Specials, '\\$1');
var dreg = new RegExp('^(.*/)' + rd + rp + '_([0-9]+)x([0-9]+)_([^/]+)$');
if(dreg.test(param.f_url))
{
param.f_url = RegExp.$1 + RegExp.$4;
param.f_width = RegExp.$2;
param.f_height = RegExp.$3;
}
for (var id in param)
{
if(id == 'f_align') continue;
if(document.getElementById(id))
{
document.getElementById(id).value = param[id];
}
}
document.getElementById("orginal_width").value = param["f_width"];
document.getElementById("orginal_height").value = param["f_height"];
setAlign(param["f_align"]);
// Locate to the correct directory
var dreg = new RegExp('^(.*/)([^/]+)$');
if(dreg.test(param['f_url']) && !(new RegExp('^https?://','i')).test(param['f_url']))
{
changeDir(RegExp.$1);
var dirPath = document.getElementById('dirPath');
for(var i = 0; i < dirPath.options.length; i++)
{
if(dirPath.options[i].value == encodeURIComponent(RegExp.$1))
{
dirPath.options[i].selected = true;
break;
}
}
}
document.getElementById('f_preview').src = _backend_url + '__function=thumbs&img=' + encodeURIComponent(param.f_url);
}
// Hookup color pickers
new Xinha.colorPicker.InputBinding(document.getElementById('f_backgroundColor'));
new Xinha.colorPicker.InputBinding(document.getElementById('f_borderColor'));
document.getElementById("f_alt").focus();
};
function onCancel()
{
__dlg_close(null);
return false;
}
function onOK()
{
// pass data back to the calling window
var fields = ["f_url", "f_alt", "f_align", "f_width", "f_height", "f_padding", "f_margin", "f_border", "f_borderColor", "f_backgroundColor", 'f_hspace', 'f_vspace'];
var param = new Object();
for (var i in fields)
{
var id = fields[i];
var el = document.getElementById(id);
if(id == "f_url" && el.value.indexOf('://') < 0 )
{
if ( el.value == "" )
{
alert( i18n("No Image selected.") );
return( false );
}
param[id] = makeURL(base_url,el.value);
}
else if (el)
param[id] = el.value;
// else alert("Missing " + fields[i]); <-- Not useful to tell people this, maybe for debugging.
}
// See if we need to resize the image
var origsize =
{
w:document.getElementById('orginal_width').value,
h:document.getElementById('orginal_height').value
}
if( (origsize.w != param.f_width)
|| (origsize.h != param.f_height) )
{
// Yup, need to resize
var resized = Xinha._geturlcontent(_backend_url + '&__function=resizer&img=' + encodeURIComponent(document.getElementById('f_url').value) + '&width=' + param.f_width + '&height=' + param.f_height);
// alert(resized);
resized = eval(resized);
if(resized)
{
param.f_url = makeURL(base_url, resized);
}
}
__dlg_close(param);
return false;
}
//similar to the Files::makeFile() in Files.php
function makeURL(pathA, pathB)
{
if(pathA.substring(pathA.length-1) != '/')
pathA += '/';
if(pathB.charAt(0) == '/');
pathB = pathB.substring(1);
return pathA+pathB;
}
function updateDir(selection)
{
var newDir = selection.options[selection.selectedIndex].value;
changeDir(newDir);
}
function goUpDir()
{
var selection = document.getElementById('dirPath');
var currentDir = selection.options[selection.selectedIndex].text;
if(currentDir.length < 2)
return false;
var dirs = currentDir.split('/');
var search = '';
for(var i = 0; i < dirs.length - 2; i++)
{
search += dirs[i]+'/';
}
for(var i = 0; i < selection.length; i++)
{
var thisDir = selection.options[i].text;
if(thisDir == search)
{
selection.selectedIndex = i;
var newDir = selection.options[i].value;
changeDir(newDir);
break;
}
}
}
function changeDir(newDir)
{
if(typeof imgManager != 'undefined')
{
imgManager.changeDir(newDir);
}
}
function toggleConstrains(constrains)
{
var lockImage = document.getElementById('imgLock');
var constrains = document.getElementById('constrain_prop');
if(constrains.checked)
{
lockImage.src = "img/locked.gif";
checkConstrains('width')
}
else
{
lockImage.src = "img/unlocked.gif";
}
}
function checkConstrains(changed)
{
//alert(document.form1.constrain_prop);
var constrains = document.getElementById('constrain_prop');
if(constrains.checked)
{
var obj = document.getElementById('orginal_width');
var orginal_width = parseInt(obj.value);
var obj = document.getElementById('orginal_height');
var orginal_height = parseInt(obj.value);
var widthObj = document.getElementById('f_width');
var heightObj = document.getElementById('f_height');
var width = parseInt(widthObj.value);
var height = parseInt(heightObj.value);
if(orginal_width > 0 && orginal_height > 0)
{
if(changed == 'width' && width > 0) {
heightObj.value = parseInt((width/orginal_width)*orginal_height);
}
if(changed == 'height' && height > 0) {
widthObj.value = parseInt((height/orginal_height)*orginal_width);
}
}
}
}
function showMessage(newMessage)
{
var message = document.getElementById('message');
var messages = document.getElementById('messages');
if(message.firstChild)
message.removeChild(message.firstChild);
message.appendChild(document.createTextNode(i18n(newMessage)));
messages.style.display = '';
}
function addEvent(obj, evType, fn)
{
if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; }
else { return false; }
}
function doUpload()
{
var uploadForm = document.getElementById('uploadForm');
if(uploadForm)
showMessage('Uploading');
}
function refresh()
{
var selection = document.getElementById('dirPath');
updateDir(selection);
}
function newFolder()
{
function createFolder(folder)
{
var selection = document.getElementById('dirPath');
var dir = selection.options[selection.selectedIndex].value;
if(folder == thumbdir)
{
alert(i18n('Invalid folder name, please choose another folder name.'));
return false;
}
if (folder && folder != '' && typeof imgManager != 'undefined')
{
imgManager.newFolder(dir, encodeURI(folder));
}
}
// IE7 has crippled the prompt()
if (Xinha.ie_version > 6)
{
Dialog("newFolder.html", function(param)
{
if (!param) // user must have pressed Cancel
{
return false;
}
else
{
var folder = param['f_foldername'];
createFolder(folder);
}
}, null);
}
else
{
var folder = prompt(i18n('Please enter name for new folder...'), i18n('Untitled'));
createFolder(folder);
}
}
addEvent(window, 'load', init);
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/manager.js | JavaScript | art | 8,703 |
/**
* Javascript used by the editorFrame.php, it basically initializes the frame.
* @author $Author:ray $
* @version $Id:editorFrame.js 677 2007-01-19 22:24:36Z ray $
* @package ImageManager
*/
var topDoc = window.top.document;
var t_cx = topDoc.getElementById('cx');
var t_cy = topDoc.getElementById('cy');
var t_cw = topDoc.getElementById('cw');
var t_ch = topDoc.getElementById('ch');
var m_sx = topDoc.getElementById('sx');
var m_sy = topDoc.getElementById('sy');
var m_w = topDoc.getElementById('mw');
var m_h = topDoc.getElementById('mh');
var m_a = topDoc.getElementById('ma');
var m_d = topDoc.getElementById('md');
var s_sw = topDoc.getElementById('sw');
var s_sh = topDoc.getElementById('sh');
var r_ra = topDoc.getElementById('ra');
var pattern = "img/2x2.gif";
function doSubmit(action)
{
if (action == 'crop')
{
// backend_url is set by the calling page. For now we assume it contains
// a trailing &
var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=crop¶ms="+parseInt(t_cx.value)+','+parseInt(t_cy.value)+','+ parseInt(t_cw.value)+','+parseInt(t_ch.value);
//alert(url);
location.href = url;
//location.reload();
}
else if (action == 'scale')
{
var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=scale¶ms="+parseInt(s_sw.value)+','+parseInt(s_sh.value);
//alert(url);
location.href = url;
}
else if (action == 'rotate')
{
var flip = topDoc.getElementById('flip');
if(flip.value == 'hoz' || flip.value == 'ver')
location.href = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=flip¶ms="+flip.value;
else if (isNaN(parseFloat(r_ra.value))==false)
location.href = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=rotate¶ms="+parseFloat(r_ra.value);
}
else if(action == 'save') {
var s_file = topDoc.getElementById('save_filename');
var s_format = topDoc.getElementById('save_format');
var s_quality = topDoc.getElementById('quality');
var format = s_format.value.split(",");
if(s_file.value.length <= 0)
{
alert(i18n('Please enter a filename to save.'));
}
else
{
var filename = encodeURI(s_file.value);
var quality = parseInt(s_quality.value);
var url = _backend_url + "__function=editorFrame&img="+currentImageFile+"&action=save¶ms="+format[0]+","+quality+"&file="+filename;
//alert(url);
location.href = url;
}
}
}
function addEvent(obj, evType, fn)
{
if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; }
else { return false; }
}
var jg_doc
init = function()
{
jg_doc = new jsGraphics("imgCanvas"); // draw directly into document
jg_doc.setColor("#000000"); // black
initEditor();
};
addEvent(window, 'load', init);
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/assets/editorFrame.js | JavaScript | art | 3,126 |
/**
* The ImageManager plugin javascript.
* @author $Author:(local) $
* @version $Id:image-manager.js 856M 2007-06-13 18:34:34Z (local) $
* @package ImageManager
*/
/**
* To Enable the plug-in add the following line before Xinha is initialised.
*
* Xinha.loadPlugin("ImageManager");
*
* Then configure the config.inc.php file, that is all.
* For up-to-date documentation, please visit http://www.zhuo.org/htmlarea/
*/
/**
* It is pretty simple, this file over rides the Xinha.prototype._insertImage
* function with our own, only difference is the popupDialog url
* point that to the php script.
*/
function ImageManager(editor)
{
}
ImageManager._pluginInfo = {
name : "ImageManager",
version : "1.0",
developer : "Xiang Wei Zhuo",
developer_url : "http://www.zhuo.org/htmlarea/",
license : "htmlArea"
};
// CONFIGURATION README:
//
// It's useful to pass the configuration to the backend through javascript
// (this saves editing the backend config itself), this needs to be done
// in a trusted/secure manner... here is how to do it..
//
// 1. You need to be able to put PHP in your xinha_config setup
// 2. In step 3 write something like
// --------------------------------------------------------------
// with (xinha_config.ImageManager)
// {
// <?php
// require_once('/path/to/xinha/contrib/php-xinha.php');
// xinha_pass_to_php_backend
// (
// array
// (
// 'images_dir' => '/home/your/directory',
// 'images_url' => '/directory'
// )
// )
// ?>
// }
// --------------------------------------------------------------
//
// this will work provided you are using normal file-based PHP sessions
// (most likely), if not, you may need to modify the php-xinha.php
// file to suit your setup.
Xinha.Config.prototype.ImageManager =
{
'backend' : Xinha.getPluginDir("ImageManager") + '/backend.php?__plugin=ImageManager&',
'backend_data' : null,
// Deprecated method for passing config, use above instead!
//---------------------------------------------------------
'backend_config' : null,
'backend_config_hash': null,
'backend_config_secret_key_location': 'Xinha:ImageManager'
//---------------------------------------------------------
};
// Over ride the _insertImage function in htmlarea.js.
// Open up the ImageManger script instead.
Xinha.prototype._insertImage = function(image) {
var editor = this; // for nested functions
var outparam = null;
if (typeof image == "undefined") {
image = this.getParentElement();
if (image && !/^img$/i.test(image.tagName))
image = null;
}
// the selection will have the absolute url to the image.
// coerce it to be relative to the images directory.
//
// FIXME: we have the correct URL, but how to get it to select?
// FIXME: need to do the same for MSIE.
if ( image )
{
outparam =
{
f_url : Xinha.is_ie ? image.src : image.src,
f_alt : image.alt,
f_border : image.style.borderWidth ? image.style.borderWidth : image.border,
f_align : image.align,
f_padding: image.style.padding,
f_margin : image.style.margin,
f_width : image.width,
f_height : image.height,
f_backgroundColor: image.style.backgroundColor,
f_borderColor: image.style.borderColor,
f_hspace: image.hspace && image.hspace != '-1' ? parseInt(image.hspace) : '',
f_vspace: image.vspace && image.vspace != '-1' ? parseInt(image.vspace) : ''
};
function shortSize(cssSize)
{
if(/ /.test(cssSize))
{
var sizes = cssSize.split(' ');
var useFirstSize = true;
for(var i = 1; i < sizes.length; i++)
{
if(sizes[0] != sizes[i])
{
useFirstSize = false;
break;
}
}
if(useFirstSize) cssSize = sizes[0];
}
return cssSize;
}
outparam.f_border = shortSize(outparam.f_border);
outparam.f_padding = shortSize(outparam.f_padding);
outparam.f_margin = shortSize(outparam.f_margin);
function convertToHex(color) {
if (typeof color == "string" && /, /.test.color)
color = color.replace(/, /, ','); // rgb(a, b) => rgb(a,b)
if (typeof color == "string" && / /.test.color) { // multiple values
var colors = color.split(' ');
var colorstring = '';
for (var i = 0; i < colors.length; i++) {
colorstring += Xinha._colorToRgb(colors[i]);
if (i + 1 < colors.length)
colorstring += " ";
}
return colorstring;
}
return Xinha._colorToRgb(color);
}
outparam.f_backgroundColor = convertToHex(outparam.f_backgroundColor);
outparam.f_borderColor = convertToHex(outparam.f_borderColor);
} // end of if we selected an image before raising the dialog.
// the "manager" var is legacy code. Should probably reference the
// actual config variable in each place .. for now this is good enough.
// alert( "backend is '" + editor.config.ImageManager.backend + "'" );
var manager = editor.config.ImageManager.backend + '__function=manager';
if(editor.config.ImageManager.backend_config != null)
{
manager += '&backend_config='
+ encodeURIComponent(editor.config.ImageManager.backend_config);
manager += '&backend_config_hash='
+ encodeURIComponent(editor.config.ImageManager.backend_config_hash);
manager += '&backend_config_secret_key_location='
+ encodeURIComponent(editor.config.ImageManager.backend_config_secret_key_location);
}
if(editor.config.ImageManager.backend_data != null)
{
for ( var i in editor.config.ImageManager.backend_data )
{
manager += '&' + i + '=' + encodeURIComponent(editor.config.ImageManager.backend_data[i]);
}
}
Dialog(manager, function(param) {
if (!param) { // user must have pressed Cancel
return false;
}
var img = image;
if (!img) {
if (Xinha.is_ie) {
var sel = editor._getSelection();
var range = editor._createRange(sel);
editor._doc.execCommand("insertimage", false, param.f_url);
img = range.parentElement();
// wonder if this works...
if (img.tagName.toLowerCase() != "img") {
img = img.previousSibling;
}
} else {
img = document.createElement('img');
img.src = param.f_url;
editor.insertNodeAtSelection(img);
}
} else {
img.src = param.f_url;
}
for (field in param) {
var value = param[field];
switch (field) {
case "f_alt" : img.alt = value; break;
case "f_border" :
if(value.length)
{
img.style.borderWidth = /[^0-9]/.test(value) ? value : (parseInt(value) + 'px');
if(img.style.borderWidth && !img.style.borderStyle)
{
img.style.borderStyle = 'solid';
}
}
else
{
img.style.borderWidth = '';
img.style.borderStyle = '';
}
break;
case "f_borderColor": img.style.borderColor = value; break;
case "f_backgroundColor": img.style.backgroundColor = value; break;
case "f_padding":
{
if(value.length)
{
img.style.padding = /[^0-9]/.test(value) ? value : (parseInt(value) + 'px');
}
else
{
img.style.padding = '';
}
}
break;
case "f_margin":
{
if(value.length)
{
img.style.margin = /[^0-9]/.test(value) ? value : (parseInt(value) + 'px');
}
else
{
img.style.margin = '';
}
}
break;
case "f_align" : img.align = value; break;
case "f_width" :
{
if(!isNaN(parseInt(value))) { img.width = parseInt(value); } else { img.width = ''; }
}
break;
case "f_height":
{
if(!isNaN(parseInt(value))) { img.height = parseInt(value); } else { img.height = ''; }
}
break;
case "f_hspace" :
{
if(!isNaN(parseInt(value))) { img.hspace = parseInt(value); } else { img.hspace = ''; }
}
break;
case "f_vspace" :
{
if(!isNaN(parseInt(value))) { img.vspace = parseInt(value); } else { img.vspace = ''; }
}
break;
}
}
}, outparam);
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/ImageManager/ImageManager.js | JavaScript | art | 8,640 |
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
function FindReplace(editor) {
this.editor = editor;
var cfg = editor.config;
var self = this;
cfg.registerButton("FR-findreplace", this._lc("Find and Replace"),
editor.imgURL("ed_find.gif", "FindReplace"), false,
function(editor) { self.buttonPress(editor); });
cfg.addToolbarElement(["FR-findreplace","separator"], ["formatblock","fontsize","fontname"], -1);
}
FindReplace.prototype.buttonPress = function(editor) {
FindReplace.editor = editor;
var sel = editor.getSelectedHTML();
if(/\w/.test(sel)) {
sel = sel.replace(/<[^>]*>/g,"");
sel = sel.replace(/ /g,"");
}
var param = /\w/.test(sel) ? {fr_pattern: sel} : null;
editor._popupDialog("plugin://FindReplace/find_replace", null, param);
};
FindReplace._pluginInfo = {
name : "FindReplace",
version : "1.0 - beta",
developer : "Cau Guanabara",
developer_url : "mailto:caugb@ibest.com.br",
c_owner : "Cau Guanabara",
sponsor : "Independent production",
sponsor_url : "http://www.netflash.com.br/gb/HA3-rc1/examples/find-replace.html",
license : "htmlArea"
};
FindReplace.prototype._lc = function(string) {
return Xinha._lc(string, 'FindReplace');
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/FindReplace.js | JavaScript | art | 1,485 |
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// Author: Maarten Molenschot, maarten@nrgmm.nl
{
// messages
"Substitute this occurrence?": "Deze overeenkomst vervangen?",
"Enter the text you want to find": "Voer tekst in waar je op wilt zoeken",
"Inform a replacement word": "Voer een vervang woord of zin in",
"found items": "gevonden overeenkomsten",
"replaced items": "vervangen items",
"found item": "gevonden overeenkomst",
"replaced item": "vervangen item",
"not found": "niet gevonden",
// window
"Find and Replace": "Zoek en vervang",
"Search for:": "Zoek naar:",
"Replace with:": "Vervang met:",
"Options": "Opties",
"Whole words only": "Alleen hele woorden",
"Case sensitive search": "Exact zoeken",
"Substitute all occurrences": "Vervang alle overeenkomsten",
"Clear": "Leeg",
"Highlight": "Markeren",
"Undo": "Ongedaan maken",
"Next": "Volgende",
"Done": "Voltooien"
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/nl.js | JavaScript | art | 957 |
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: Udo Schmal (gocher), http://www.schaffrath-neuemedien.de/, udo.schmal@t-online.de
{
// messages
"Substitute this occurrence?": "Treffer ersetzen?",
"Enter the text you want to find": "Geben Sie einen Text ein den Sie finden möchten",
"Inform a replacement word": "Geben sie einen Text zum ersetzen ein",
"found items": "alle Treffer",
"replaced items": "ersetzte Treffer",
"found item": "Treffer",
"replaced item": "ersetzter Treffer",
"not found": "kein Teffer",
// window
"Find and Replace": "Suchen und ersetzen",
"Search for:": "Suchen nach:",
"Replace with:": "Ersetzen durch:",
"Options": "Optionen",
"Whole words only": "Ganze Wörter",
"Case sensitive search": "Groß-/Kleinschreibung",
"Substitute all occurrences": "alle Treffer ersetzen",
"Clear": "Nächstes ersetzen",
"Highlight": "Hervorheben",
"Undo": "Rückgängig",
"Next": "Nächster",
"Done": "Fertig"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/de.js | JavaScript | art | 982 |
// I18N constants
// LANG: "pl", ENCODING: UTF-8
// translated: Krzysztof Kotowicz, koto1sa@o2.pl, http://www.eskot.krakow.pl/portfolio
{
// messages
"Substitute this occurrence?": "Zamienić to wystąpienie?",
"Enter the text you want to find": "Podaj tekst, jaki chcesz wyszukać",
"Inform a replacement word": "Podaj tekst do zamiany",
"found items": "znalezionych",
"replaced items": "zamienionych",
"found item": "znaleziony",
"replaced item": "zamieniony",
"not found": "nie znaleziony",
// window
"Find and Replace": "Znajdź i zamień",
"Search for:": "Szukaj:",
"Replace with:": "Zamień na:",
"Options": "Opcje",
"Whole words only": "Całe słowa",
"Case sensitive search": "Wg wielkości liter",
"Substitute all occurrences": "Zamień wszystkie wystąpienia",
"Clear": "Wyczyść",
"Highlight": "Podświetl",
"Undo": "Cofnij",
"Next": "Następny",
"Done": "Gotowe"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/pl.js | JavaScript | art | 922 |
// I18N constants
// LANG: "ru", ENCODING: UTF-8
// Author: Andrei Blagorazumov, a@fnr.ru
{
// messages
"Substitute this occurrence?": "Заменить это вхождение?",
"Enter the text you want to find": "Введите текст, который вы хотите найти",
"Inform a replacement word": "Показать замещающее слово",
"found items": "найти",
"replaced items": "замененные",
"found item": "найти",
"replaced item": "замененная",
"not found": "не найдено",
// window
"Find and Replace": "Найти и заменить",
"Search for:": "Найти",
"Replace with:": "Заменить с",
"Options": "Опции",
"Whole words only": "Только слова целиком",
"Case sensitive search": "Поиск с учетом регистра",
"Substitute all occurrences": "Заменить все вхождения",
"Clear": "Очистить",
"Highlight": "Выделить",
"Undo": "Отменить",
"Next": "След.",
"Done": "OK"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/ru.js | JavaScript | art | 1,117 |
// I18N constants
// LANG: "sv" (Swedish), ENCODING: UTF-8
// translated: Erik Dalén, <dalen@jpl.se>
{
// messages
"Substitute this occurrence?": "Ersätt denna?",
"Enter the text you want to find": "Skriv in text du vill söka",
"Inform a replacement word": "Skriv in ett ersättningsord",
"found items": "förekomster funna i sökningen",
"replaced items": "förekomster erstatta",
"found item": "Träff",
"replaced item": "erstatt träff",
"not found": "inte funnet",
// window
"Find and Replace": "Sök och ersätt",
"Search for:": "Sök efter:",
"Replace with:": "Ersätt med:",
"Options": "Välj",
"Whole words only": "Bara hela ord",
"Case sensitive search": "Skilj mellan stora och små bokstäver",
"Substitute all occurrences": "Erstatt alla träffar",
"Clear": "Töm",
"Highlight": "Markera",
"Undo": "Tillbaka",
"Next": "Nästa",
"Done": "Färdig"
};
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/sv.js | JavaScript | art | 909 |
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
// messages
"Substitute this occurrence?": "Remplacer cette occurrence ?",
"Enter the text you want to find": "Texte à trouver",
"Inform a replacement word": "Indiquez un mot de remplacement",
"found items": "éléments trouvés",
"replaced items": "éléments remplacés",
"found item": "élément trouvé",
"replaced item": "élément remplacé",
"not found": "non trouvé",
// window
"Find and Replace": "Chercher et Remplacer",
"Search for:": "Chercher",
"Replace with:": "Remplacer par",
"Options": "Options",
"Whole words only": "Mots entiers seulement",
"Case sensitive search": "Recherche sensible à la casse",
"Substitute all occurrences": "Remplacer toutes les occurences",
"Clear": "Effacer",
"Highlight": "Surligner",
"Undo": "Annuler",
"Next": "Suivant",
"Done": "Fin"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/fr.js | JavaScript | art | 881 |
// I18N constants
// LANG: "ja", ENCODING: UTF-8
{
// messages
"Substitute this occurrence?": "置換しますか?",
"Enter the text you want to find": "検索したいテキストを入力します",
"Inform a replacement word": "単語の置換を知らせる",
"found items": "件が検索されました",
"replaced items": "件が置換されました",
"found item": "件が検索されました",
"replaced item": "件が置換されました",
"not found": "はありません",
// window
"Find and Replace": "検索/置換",
"Search for:": "検索:",
"Replace with:": "置換:",
"Options": "設定",
"Whole words only": "完全一致のみ",
"Case sensitive search": "大文字/小文字区別",
"Substitute all occurrences": "すべて置換",
"Clear": "通常表示",
"Highlight": "強調表示",
"Undo": "元に戻す",
"Next": "次を検索",
"Done": "終了"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/ja.js | JavaScript | art | 919 |
// I18N constants
// LANG: "nb", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
// messages
"Substitute this occurrence?": "Vennligst bekreft at du vil erstatte?",
"Enter the text you want to find": "Skriv inn teksten du ønsker å finne",
"Inform a replacement word": "Vennligst skriv inn et erstatningsord / setning",
"found items": "forekomster funnet i søket",
"replaced items": "forekomster erstattet",
"found item": "Treff",
"replaced item": "erstattet treff",
"not found": "ikke funnet",
// window
"Find and Replace": "Søk og erstatt",
"Search for:": "Søk etter:",
"Replace with:": "Erstatt med:",
"Options": "Valg",
"Whole words only": "Bare hele ord",
"Case sensitive search": "Skille mellom store og små bokstaver",
"Substitute all occurrences": "Erstatt alle treff",
"Clear": "Tøm",
"Highlight": "Uthev",
"Undo": "Tilbake",
"Next": "Neste",
"Done": "Ferdig"
}; | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/nb.js | JavaScript | art | 967 |
// I18N constants
//
// LANG: "pt_br", ENCODING: UTF-8
// Portuguese Brazilian Translation
//
// Initial basic translation
// Author: Cau guanabara (independent developer), caugb@ibest.com.br
//
// Final translation
// Author: Marcio Barbosa, <marcio@mpg.com.br>
// MSN: tomarshall@msn.com - ICQ: 69419933
// Site: http://www.mpg.com.br
//
// Last revision: 06 september 2007
// Please don´t remove this information
// If you modify any source, please insert a comment with your name and e-mail
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"Case sensitive search": "Procura diferenciada Maiúsculas/Minúsculas",
"Clear": "Limpar",
"Done": "Executado",
"Enter the text you want to find": "Forneça o texto que deseja procurar",
"Find and Replace": "Procurar e Substituir",
"Highlight": "Marcar",
"Inform a replacement word": "Informe uma palavra para substituir",
"Next": "Próxima",
"Options": "Opções",
"Replace with:": "Substituir por:",
"Search for:": "Procurar por:",
"Substitute all occurrences": "Substituir todas as ocorrências",
"Substitute this occurrence?": "Substituir todas as ocorrências?",
"Undo": "Desfazer",
"Whole words only": "Apenas palavras inteiras",
"found item": "Item encontrado",
"found items": "Itens encontrados",
"not found": "nada encontrado",
"replaced item": "substituir item",
"replaced items": "substituir itens"
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/lang/pt_br.js | JavaScript | art | 1,471 |
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
var FindReplace = window.opener.FindReplace;
var editor = FindReplace.editor;
var is_mo = window.opener.Xinha.is_gecko;
var tosearch = '';
var pater = null;
var buffer = null;
var matches = 0;
var replaces = 0;
var fr_spans = new Array();
function _lc(string) {
return(window.opener.Xinha._lc(string, 'FindReplace'));
}
function execSearch(params) {
var ihtml = editor._doc.body.innerHTML;
if(buffer == null)
buffer = ihtml;
if(params['fr_pattern'] != tosearch) {
if(tosearch != '')
clearDoc();
tosearch = params['fr_pattern'];
}
if(matches == 0) {
er = params['fr_words'] ? "/(?!<[^>]*)(\\b"+params['fr_pattern']+"\\b)(?![^<]*>)/g" :
"/(?!<[^>]*)("+params['fr_pattern']+")(?![^<]*>)/g";
if(!params['fr_matchcase'])
er += "i";
pater = eval(er);
var tago = '<span id=frmark>';
var tagc = '</span>';
var newHtml = ihtml.replace(pater,tago+"$1"+tagc);
editor.setHTML(newHtml);
var getallspans = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getallspans.length; i++)
if(/^frmark/.test(getallspans[i].id))
fr_spans.push(getallspans[i]);
}
spanWalker(params['fr_pattern'],params['fr_replacement'],params['fr_replaceall']);
}
function spanWalker(pattern,replacement,replaceall) {
var foundtrue = false;
clearMarks();
for (var i = matches; i < fr_spans.length; i++) {
var elm = fr_spans[i];
foundtrue = true;
if(!(/[0-9]$/.test(elm.id))) {
matches++;
disab('fr_clear',false);
elm.id = 'frmark_'+matches;
elm.style.color = 'white';
elm.style.backgroundColor = 'highlight';
elm.style.fontWeight = 'bold';
elm.scrollIntoView(false);
if(/\w/.test(replacement)) {
if(replaceall || confirm(_lc("Substitute this occurrence?"))) {
elm.firstChild.replaceData(0,elm.firstChild.data.length,replacement);
replaces++;
disab('fr_undo',false);
}
if(replaceall) {
clearMarks();
continue;
}
}
break;
}
}
var last = (i >= fr_spans.length - 1);
if(last || !foundtrue) { // EOF
var message = _lc("Done")+':\n\n';
if(matches > 0) {
if(matches == 1) message += matches+' '+_lc("found item");
else message += matches+' '+_lc("found items");
if(replaces > 0) {
if(replaces == 1) message += ',\n'+replaces+' '+_lc("replaced item");
else message += ',\n'+replaces+' '+_lc("replaced items");
}
hiliteAll();
disab('fr_hiliteall',false);
} else { message += '"'+pattern+'" '+_lc("not found"); }
alert(message+'.');
}
}
function clearDoc() {
var doc = editor._doc.body.innerHTML;
var er = /(<span\s+[^>]*id=.?frmark[^>]*>)([^<>]*)(<\/span>)/gi;
editor._doc.body.innerHTML = doc.replace(er,"$2");
pater = null;
tosearch = '';
fr_spans = new Array();
matches = 0;
replaces = 0;
disab("fr_hiliteall,fr_clear",true);
}
function clearMarks() {
var getall = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getall.length; i++) {
var elm = getall[i];
if(/^frmark/.test(elm.id)) {
var objStyle = editor._doc.getElementById(elm.id).style;
objStyle.backgroundColor = "";
objStyle.color = "";
objStyle.fontWeight = "";
}
}
}
function hiliteAll() {
var getall = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getall.length; i++) {
var elm = getall[i];
if(/^frmark/.test(elm.id)) {
var objStyle = editor._doc.getElementById(elm.id).style;
objStyle.backgroundColor = "highlight";
objStyle.color = "white";
objStyle.fontWeight = "bold";
}
}
}
function resetContents() {
if(buffer == null) return;
var transp = editor._doc.body.innerHTML;
editor._doc.body.innerHTML = buffer;
buffer = transp;
}
function disab(elms,toset) {
var names = elms.split(/[,; ]+/);
for(var i = 0; i < names.length; i++)
document.getElementById(names[i]).disabled = toset;
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/fr_engine.js | JavaScript | art | 4,358 |
<html>
<head>
<title>Find and Replace</title>
<!--
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
-->
<script type="text/javascript" src="../fr_engine.js"></script>
<script type="text/javascript" src="../../../popups/popup.js"></script>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript">
window.resizeTo(335, 250);
var accepted = {
'fr_pattern' : true,
'fr_replacement' : true,
'fr_words' : true,
'fr_matchcase' : true,
'fr_replaceall' : true
};
function Init() {
__dlg_translate('FindReplace');
__dlg_init();
disab("fr_undo,fr_clear,fr_hiliteall",true);
var params = window.dialogArguments;
if(params) {
document.getElementById('fr_pattern').value = params["fr_pattern"];
document.getElementById('fr_replacement').focus();
} else {
document.getElementById('fr_pattern').focus();
}
document.body.onkeypress = __dlg_key_press;
}
function onCancel() {
clearDoc();
__dlg_close(null);
return false;
}
function onOK() {
var required = {'fr_pattern' : _lc("Enter the text you want to find")};
for (var i in required) {
var el = document.getElementById(i);
if (!el.value) {
alert(required[i]);
el.focus();
return false;
}
}
var param = {};
for (var i in accepted) {
var el = document.getElementById(i);
param[i] = el.type == 'checkbox' ? el.checked : el.value;
}
execSearch(param);
return false;
}
function __dlg_key_press(ev) {
ev || (ev = window.event);
switch(ev.keyCode) {
case 13:
document.getElementById('fr_go').click();
document.getElementById('fr_pattern').focus();
break;
case 27:
clearDoc();
window.close();
return false;
}
return true;
}
</script>
<style type="text/css">
table .label { text-align: right; width: 12em; }
.title {
background: #ddf;
color: #000;
font-weight: bold;
font-size: 120%;
padding: 3px 10px;
margin-bottom: 10px;
border-bottom: 1px solid black;
letter-spacing: 2px;
}
.buttons { border-top: 1px solid #999; padding: 2px; text-align: right; }
.hrstyle { border-width: 1px; border-color: #666; width: 95%; padding: 2px; }
</style>
</head>
<body class="dialog" onload="Init()">
<div class="title">Find and Replace</div>
<form action="" method="get">
<table border="0" style="width: 100%; padding: 2px;"><!---->
<tbody>
<tr>
<td width="29%" style="text-align: right; vertical-align: bottom;">Search for:</td>
<td width="71%" colspan="2" style="vertical-align: bottom;">
<input id="fr_pattern" type="text" style="width: 200px" onFocus="this.select();">
</td>
</tr>
<tr>
<td style="text-align: right;">Replace with:</td>
<td colspan="2">
<input id="fr_replacement" type="text" style="width: 200px" onFocus="this.select();">
</td>
</tr>
<tr>
<td colspan="3"><table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="78%" style="padding: 2px">
<FIELDSET style="width:90%; padding: 5px">
<LEGEND><span>Options</span></LEGEND>
<input id="fr_words" type="checkbox" checked onClick="clearDoc();" value="on">
<span onClick="e = document.getElementById('fr_words');
e.click(); e.focus();" style="cursor:default">
<span>Whole words only</span></span><br />
<input id="fr_matchcase" type="checkbox" onClick="clearDoc();" value="on">
<span onClick="e = document.getElementById('fr_matchcase');
e.click(); e.focus();" style="cursor:default">
<span>Case sensitive search</span></span><br />
<input id="fr_replaceall" type="checkbox" onClick="
if(document.getElementById('fr_replacement').value == '') {
alert(_lc('Inform a replacement word'));
return false;
}
clearDoc();" value="on">
<span onClick="e = document.getElementById('fr_replaceall');
e.click(); e.focus();" style="cursor:default">
<span>Substitute all occurrences</span></span>
</FIELDSET></td>
<td width="22%" style="vertical-align: bottom; text-align: right; padding: 4px">
<button type="button" id="fr_clear" onClick="clearMarks()">Clear</button>
<div class="space"></div>
<button type="button" id="fr_hiliteall" onClick="hiliteAll()">Highlight</button>
<div class="space"></div>
<button type="button" id="fr_undo" onClick="resetContents();">Undo</button>
</td>
</tr>
</table></td>
</tr>
</tbody>
</table>
<div style="border-top: 1px solid #999; padding: 2px; padding: 5px; text-align: right; height: 20px"><button type="button" id="fr_go" onclick="return onOK();">Next</button>
<button type="button" name="cancel" onclick="return onCancel();">Done</button>
</div>
</form>
</body>
</html>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/FindReplace/popups/find_replace.html | HTML | art | 5,302 |
// Spell Checker Plugin for HTMLArea-3.0
// Sponsored by www.americanbible.org
// Implementation by Mihai Bazon, http://dynarch.com/mishoo/
//
// (c) dynarch.com 2003.
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
//
// $Id:spell-check-ui.js 987M 2008-04-12 12:39:04Z (local) $
// internationalization file was already loaded in parent ;-)
var SpellChecker = window.opener.SpellChecker;
var Xinha = window.opener.Xinha;
var _editor_url = window.opener._editor_url;
var is_ie = Xinha.is_ie;
var editor = SpellChecker.editor;
var frame = null;
var currentElement = null;
var wrongWords = null;
var modified = false;
var allWords = {};
var fixedWords = [];
var suggested_words = {};
var to_p_dict = []; // List of words to add to personal dictionary.
var to_r_list = []; // List of words to add to replacement list.
function _lc(string) {
return Xinha._lc(string, 'SpellChecker');
}
function makeCleanDoc(leaveFixed) {
// document.getElementById("status").innerHTML = 'Please wait: rendering valid HTML';
var words = wrongWords.concat(fixedWords);
for (var i = words.length; --i >= 0;) {
var el = words[i];
if (!(leaveFixed && /HA-spellcheck-fixed/.test(el.className))) {
if(el.firstChild)
el.parentNode.insertBefore(el.firstChild, el);
el.parentNode.removeChild(el);
} else
el.className = "HA-spellcheck-fixed";
}
// we should use innerHTML here, but IE6's implementation fucks up the
// HTML to such extent that our poor Perl parser doesn't understand it
// anymore.
return Xinha.getHTML(frame.contentWindow.document.body, true, editor);
}
function recheckClicked() {
document.getElementById("status").innerHTML = _lc("Please wait: changing dictionary to") + ': "' + document.getElementById("f_dictionary").value + '".';
var field = document.getElementById("f_content");
field.value = makeCleanDoc(true);
field.form.submit();
}
function saveClicked() {
if (modified) {
editor.setHTML(makeCleanDoc(false));
}
if(to_p_dict.length || to_r_list.length && editor.config.SpellChecker.backend == 'php')
{
var data = {};
for(var i = 0;i < to_p_dict.length;i++)
{
data['to_p_dict[' + i + ']'] = to_p_dict[i];
}
for(var i = 0;i < to_r_list.length;i++)
{
data['to_r_list[' + i + '][0]'] = to_r_list[i][0];
data['to_r_list[' + i + '][1]'] = to_r_list[i][1];
}
// var win = window;
window.opener.Xinha._postback(Xinha.getPluginDir("SpellChecker") + '/spell-check-savedicts.php', data);
window.close();
}
else
{
window.close();
}
return false;
}
function cancelClicked() {
var ok = true;
if (modified) {
ok = confirm(_lc("This will drop changes and quit spell checker. Please confirm."));
}
if (ok) {
window.close();
}
return false;
}
function replaceWord(el) {
var replacement = document.getElementById("v_replacement").value;
var this_word_modified = (el.innerHTML != replacement);
if (this_word_modified)
modified = true;
if (el) {
el.className = el.className.replace(/\s*HA-spellcheck-(hover|fixed)\s*/g, " ");
}
el.className += " HA-spellcheck-fixed";
el.__msh_fixed = true;
if (!this_word_modified) {
return false;
}
to_r_list.push([el.innerHTML, replacement]);
el.innerHTML = replacement;
}
function replaceClicked() {
replaceWord(currentElement);
var start = currentElement.__msh_id;
var index = start;
do {
++index;
if (index == wrongWords.length) {
index = 0;
}
} while ((index != start) && wrongWords[index].__msh_fixed);
if (index == start) {
index = 0;
alert(_lc("Finished list of mispelled words"));
}
wrongWords[index].__msh_wordClicked(true);
return false;
}
function revertClicked() {
document.getElementById("v_replacement").value = currentElement.__msh_origWord;
replaceWord(currentElement);
currentElement.className = "HA-spellcheck-error HA-spellcheck-current";
return false;
}
function replaceAllClicked() {
var replacement = document.getElementById("v_replacement").value;
var ok = true;
var spans = allWords[currentElement.__msh_origWord];
if (spans.length == 0) {
alert("An impossible condition just happened. Call FBI. ;-)");
} else if (spans.length == 1) {
replaceClicked();
return false;
}
/*
var message = "The word \"" + currentElement.__msh_origWord + "\" occurs " + spans.length + " times.\n";
if (replacement == currentElement.__msh_origWord) {
ok = confirm(message + "Ignore all occurrences?");
} else {
ok = confirm(message + "Replace all occurrences with \"" + replacement + "\"?");
}
*/
if (ok) {
for (var i = 0; i < spans.length; ++i) {
if (spans[i] != currentElement) {
replaceWord(spans[i]);
}
}
// replace current element the last, so that we jump to the next word ;-)
replaceClicked();
}
return false;
}
function ignoreClicked() {
document.getElementById("v_replacement").value = currentElement.__msh_origWord;
replaceClicked();
return false;
}
function ignoreAllClicked() {
document.getElementById("v_replacement").value = currentElement.__msh_origWord;
replaceAllClicked();
return false;
}
function learnClicked() {
to_p_dict.push(currentElement.__msh_origWord);
return ignoreAllClicked();
}
function internationalizeWindow() {
var types = ["div", "span", "button"];
for (var i = 0; i < types.length; ++i) {
var tag = types[i];
var els = document.getElementsByTagName(tag);
for (var j = els.length; --j >= 0;) {
var el = els[j];
if (el.childNodes.length == 1 && /\S/.test(el.innerHTML)) {
var txt = el.innerHTML;
el.innerHTML = _lc(txt);
}
}
}
}
function initDocument() {
internationalizeWindow();
modified = false;
frame = document.getElementById("i_framecontent");
var field = document.getElementById("f_content");
field.value = Xinha.getHTML(editor._doc.body, false, editor);
var dict = document.getElementById("f_dictionary");
if(typeof editor.config.SpellChecker.defaultDictionary != "undefined"
&& editor.config.SpellChecker.defaultDictionary != "") {
dict.value = editor.config.SpellChecker.defaultDictionary;
} else {
dict.value = "en_GB";
}
if(editor.config.SpellChecker.backend == 'php')
{
field.form.action = Xinha.getPluginDir("SpellChecker") + '/spell-check-logic.php';
}
if(editor.config.SpellChecker.utf8_to_entities)
{
document.getElementById('utf8_to_entities').value = 1;
}
else
{
document.getElementById('utf8_to_entities').value = 0;
}
field.form.submit();
document.getElementById("f_init").value = "0";
// assign some global event handlers
var select = document.getElementById("v_suggestions");
select.onchange = function() {
document.getElementById("v_replacement").value = this.value;
};
if (is_ie) {
select.attachEvent("ondblclick", replaceClicked);
} else {
select.addEventListener("dblclick", replaceClicked, true);
}
document.getElementById("b_replace").onclick = replaceClicked;
if(editor.config.SpellChecker.backend == 'php')
{
document.getElementById("b_learn").onclick = learnClicked;
}
else
{
document.getElementById("b_learn").parentNode.removeChild(document.getElementById("b_learn"));
}
document.getElementById("b_replall").onclick = replaceAllClicked;
document.getElementById("b_ignore").onclick = ignoreClicked;
document.getElementById("b_ignall").onclick = ignoreAllClicked;
document.getElementById("b_recheck").onclick = recheckClicked;
document.getElementById("b_revert").onclick = revertClicked;
document.getElementById("b_info").onclick = displayInfo;
document.getElementById("b_ok").onclick = saveClicked;
document.getElementById("b_cancel").onclick = cancelClicked;
select = document.getElementById("v_dictionaries");
select.onchange = function() {
document.getElementById("f_dictionary").value = this.value;
};
}
function getAbsolutePos(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}
function wordClicked(scroll) {
var self = this;
if (scroll) (function() {
var pos = getAbsolutePos(self);
var ws = { x: frame.offsetWidth - 4,
y: frame.offsetHeight - 4 };
var wp = { x: frame.contentWindow.document.body.scrollLeft,
y: frame.contentWindow.document.body.scrollTop };
pos.x -= Math.round(ws.x/2);
if (pos.x < 0) pos.x = 0;
pos.y -= Math.round(ws.y/2);
if (pos.y < 0) pos.y = 0;
frame.contentWindow.scrollTo(pos.x, pos.y);
})();
if (currentElement) {
var a = allWords[currentElement.__msh_origWord];
currentElement.className = currentElement.className.replace(/\s*HA-spellcheck-current\s*/g, " ");
for (var i = 0; i < a.length; ++i) {
var el = a[i];
if (el != currentElement) {
el.className = el.className.replace(/\s*HA-spellcheck-same\s*/g, " ");
}
}
}
currentElement = this;
this.className += " HA-spellcheck-current";
var a = allWords[currentElement.__msh_origWord];
for (var i = 0; i < a.length; ++i) {
var el = a[i];
if (el != currentElement) {
el.className += " HA-spellcheck-same";
}
}
// document.getElementById("b_replall").disabled = (a.length <= 1);
// document.getElementById("b_ignall").disabled = (a.length <= 1);
var txt;
if (a.length == 1) {
txt = "one occurrence";
} else if (a.length == 2) {
txt = "two occurrences";
} else {
txt = a.length + " occurrences";
}
var suggestions = suggested_words[this.__msh_origWord];
if (suggestions)
suggestions = suggestions.split(/,/);
else
suggestions = [];
var select = document.getElementById("v_suggestions");
document.getElementById("statusbar").innerHTML = "Found " + txt +
' for word "<b>' + currentElement.__msh_origWord + '</b>"';
for (var i = select.length; --i >= 0;) {
select.remove(i);
}
for (var i = 0; i < suggestions.length; ++i) {
var txt = suggestions[i];
var option = document.createElement("option");
option.value = txt;
option.appendChild(document.createTextNode(txt));
select.appendChild(option);
}
document.getElementById("v_currentWord").innerHTML = this.__msh_origWord;
if (suggestions.length > 0) {
select.selectedIndex = 0;
select.onchange();
} else {
document.getElementById("v_replacement").value = this.innerHTML;
}
select.style.display = "none";
select.style.display = "block";
return false;
}
function wordMouseOver() {
this.className += " HA-spellcheck-hover";
}
function wordMouseOut() {
this.className = this.className.replace(/\s*HA-spellcheck-hover\s*/g, " ");
}
function displayInfo() {
var info = frame.contentWindow.spellcheck_info;
if (!info)
alert("No information available");
else {
var txt = "** Document information **";
for (var i in info) {
txt += "\n" + i + " : " + info[i];
}
alert(txt);
}
return false;
}
function finishedSpellChecking() {
// initialization of global variables
currentElement = null;
wrongWords = null;
allWords = {};
fixedWords = [];
suggested_words = frame.contentWindow.suggested_words;
document.getElementById("status").innerHTML = "Xinha Spell Checker (<a href=\"readme-tech.html\" onclick=\"window.open(this.href,'_blank');return false;\" title=\"Technical information\">info</a>)";
var doc = frame.contentWindow.document;
var spans = doc.getElementsByTagName("span");
var sps = [];
var id = 0;
for (var i = 0; i < spans.length; ++i) {
var el = spans[i];
if (/HA-spellcheck-error/.test(el.className)) {
sps.push(el);
el.__msh_wordClicked = wordClicked;
el.onclick = function(ev) {
ev || (ev = window.event);
ev && Xinha._stopEvent(ev);
return this.__msh_wordClicked(false);
};
el.onmouseover = wordMouseOver;
el.onmouseout = wordMouseOut;
el.__msh_id = id++;
var txt = (el.__msh_origWord = el.firstChild.data);
el.__msh_fixed = false;
if (typeof allWords[txt] == "undefined") {
allWords[txt] = [el];
} else {
allWords[txt].push(el);
}
} else if (/HA-spellcheck-fixed/.test(el.className)) {
fixedWords.push(el);
}
}
var dicts = doc.getElementById("HA-spellcheck-dictionaries");
if (dicts) {
dicts.parentNode.removeChild(dicts);
dicts = dicts.innerHTML.split(/,/);
var select = document.getElementById("v_dictionaries");
for (var i = select.length; --i >= 0;) {
select.remove(i);
}
var activeDictionary = document.getElementById("f_dictionary").value;
for (var i = 0; i < dicts.length; ++i) {
var txt = dicts[i];
var option = document.createElement("option");
if(txt == activeDictionary) {
option.selected = true;
}
option.value = txt;
option.appendChild(document.createTextNode(txt));
select.appendChild(option);
}
}
wrongWords = sps;
if (sps.length == 0) {
if (!modified) {
alert(_lc("No mispelled words found with the selected dictionary."));
// window.close();
} else {
alert(_lc("No mispelled words found with the selected dictionary."));
}
return false;
}
(currentElement = sps[0]).__msh_wordClicked(true);
var as = doc.getElementsByTagName("a");
for (var i = as.length; --i >= 0;) {
var a = as[i];
a.onclick = function() {
if (confirm(_lc("Please confirm that you want to open this link") + ":\n" +
this.href + "\n" + _lc("I will open it in a new page."))) {
window.open(this.href);
}
return false;
};
}
} | zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SpellChecker/spell-check-ui.js | JavaScript | art | 13,927 |
<?php
// REVISION HISTORY:
//
// 2005-08-17 YmL:
// . security fix on unchecked variables. Original author missed quite a few
// holes.
umask(000);
$temptext = tempnam('/tmp', 'spell_');
if ((!isset($_POST['dictionary'])) || (strlen(trim($_POST['dictionary'])) < 1))
{
$lang = 'en_GB';
}
else
{
$lang = $_POST['dictionary'];
}
$lang = preg_replace('/[^a-z0-9_]/i', '', $lang);
$aspell = 'aspell';
$aspell_args = '-a --lang=' . $lang;
if(DIRECTORY_SEPARATOR == '\\') //windows
{
$aspell = 'C:\Progra~1\Aspell\bin\aspell.exe';
}
else //linux
{
// See if there is a local install of aspell here
if(file_exists(dirname(__FILE__) . '/aspell/bin/aspell'))
{
putenv('PATH=' . dirname(__FILE__) . '/aspell/bin:' . getenv('PATH'));
putenv('LD_LIBRARY_PATH=' . dirname(__FILE__) . '/aspell/lib:' . getenv('LD_LIBRARY_PATH'));
$dicfil = dirname(__FILE__) .'/aspell/lib/' . preg_replace('/^.*\/lib\/(aspell\S*)\n.*/s', '$1', `aspell config dict-dir`);
$aspell_args .= ' --dict-dir=' . $dicfil . ' --add-filter-path=' . $dicfil ;
}
}
// Old aspell doesn't know about encoding, which means that unicode will be broke, but
// we should at least let it try.
preg_match('/really aspell ([0-9]+)\.([0-9]+)(?:\.([0-9]+))?/i', `$aspell version`, $aVer);
$aVer = array('major' => (int)$aVer[1], 'minor' => (int)$aVer[2], 'release' => (int)@$aVer[3]);
if($aVer['major'] >= 0 && $aVer['minor'] >= 60)
{
$aspell_args .= ' -H --encoding=utf-8';
}
elseif(preg_match('/--encoding/', shell_exec('aspell 2>&1')))
{
$aspell_args .= ' --mode=none --add-filter=sgml --encoding=utf-8';
}
else
{
$aspell_args .= ' --mode=none --add-filter=sgml';
}
// Personal dictionaries
$p_dicts_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'personal_dicts';
if(isset($_REQUEST['p_dicts_path']) && file_exists($_REQUEST['p_dicts_path']) && is_writable($_REQUEST['p_dicts_path']))
{
if(!isset($_REQUEST['p_dicts_name']))
{
if(isset($_COOKIE['SpellChecker_p_dicts_name']))
{
$_REQUEST['p_dicts_name'] = $_COOKIE['SpellChecker_p_dicts_name'];
}
else
{
$_REQUEST['p_dicts_name'] = uniqid('dict');
setcookie('SpellChecker_p_dicts_name', $_REQUEST['p_dicts_name'], time() + 60*60*24*365*10);
}
}
$p_dict_path = $_REQUEST['p_dicts_path'] . DIRECTORY_SEPARATOR . preg_replace('/[^a-z0-9_]/i', '', $_REQUEST['p_dicts_name']);
if(!file_exists($p_dict_path))
{
// since there is a single directory for all users this could end up containing
// quite a few subdirectories. To prevent a DOS situation we'll limit the
// total directories created to 2000 (arbitrary). Adjust to suit your installation.
$count = 0;
if( $dir = @opendir( $p_dicts_path ) )
{
while( FALSE !== ($file = readdir($dir)) )
{
$count++;
}
}
// TODO: make this a config value.
if ( $count > 2000 )
{
// either very heavy use or a DOS attempt
die();
}
mkdir($p_dict_path);
chmod($p_dict_path, 02770);
}
if(file_exists($p_dict_path) && is_writable($p_dict_path))
{
// Good To Go!
$aspell_args .= ' --home-dir=' . $p_dict_path ;
}
}
// as an additional precaution check the aspell_args for illegal
// characters
$aspell_args = preg_replace( "/[|><;\$]+/", '', $aspell_args );
$aspelldictionaries = "$aspell dump dicts";
$aspellcommand = "$aspell $aspell_args < $temptext";
?>
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SpellChecker/aspell_setup.php | PHP | art | 3,560 |
.HA-spellcheck-error { border-bottom: 1px dashed #f00; cursor: default; }
.HA-spellcheck-same { background-color: #cef; color: #000; }
.HA-spellcheck-hover { background-color: #433; color: white; }
.HA-spellcheck-fixed { border-bottom: 1px dashed #0b8; }
.HA-spellcheck-current { background-color: #9be; color: #000; }
.HA-spellcheck-suggestions { display: none; }
#HA-spellcheck-dictionaries { display: none; }
a:link, a:visited { color: #55e; }
| zzh-simple-hr | ZJs/webapp/html-editor/XinHa/plugins/SpellChecker/spell-check-style.css | CSS | art | 449 |