diff --git a/hak_tinymce.php b/hak_tinymce.php
index c7621ec..bb4cef6 100644
--- a/hak_tinymce.php
+++ b/hak_tinymce.php
@@ -57,12 +57,13 @@
add_privs('hak_tinymce_compressor_js','1,2,3,4,5,6');
add_privs('hak_txpimage','1,2,3,4,5,6');
add_privs('hak_txpcatselect','1,2,3,4,5,6');
-
+ add_privs('hak_txpcountselect','1,2,3,4,5,6');
register_callback(array("hak_tinymce","js_prep"), "hak_tinymce_js");
register_callback(array("hak_tinymce","compressor_js_prep"), "hak_tinymce_compressor_js");
register_callback("hak_txpimage", "hak_txpimage");
register_callback("hak_txpcatselect", "hak_txpcatselect");
+ register_callback("hak_txpcountselect", "hak_txpcountselect");
register_tab('extensions', 'hak_tinymce_prefs', 'hak_tinymce');
register_callback(array('hak_tinymce','prefs'), 'hak_tinymce_prefs');
@@ -557,7 +558,7 @@ function install() {
$hak_mceSettings_default .= "theme_advanced_buttons3 : \"\",\n";
$hak_mceSettings_default .= "theme_advanced_toolbar_location : \"top\",\n";
$hak_mceSettings_default .= "theme_advanced_toolbar_align : \"left\",";
- $hak_mceSettings_default .= "entity_encoding : \"numeric\",";
+ $hak_mceSettings_default .= "entity_encoding : \"raw\",";
$hak_mceSettings_compressor = "theme : \"advanced\",\n";
$hak_mceSettings_compressor .= "plugins : \"searchreplace,txpimage\",\n";
@@ -638,9 +639,21 @@ function map_attribs($arr) {
$format .= (!empty($arr["height"])) ? ',height:'.$arr["height"] : '';
$format .= (!empty($arr["alt"])) ? ',alt:"'.$arr["alt"].'"' : '';
$format .= (!empty($arr["title"])) ? ',title:"'.$arr["title"].'"' : '';
+ $format .= ',srcf:""';
$format .= '}';
return $format;
}
+
+ function map_attribsf($arr) {
+ $format = '{src:"'.$arr["path"].'"';
+ $format .= (!empty($arr["width"])) ? ',width:'.$arr["width"] : '';
+ $format .= (!empty($arr["height"])) ? ',height:'.$arr["height"] : '';
+ $format .= (!empty($arr["alt"])) ? ',alt:"'.$arr["alt"].'"' : '';
+ $format .= (!empty($arr["title"])) ? ',title:"'.$arr["title"].'"' : '';
+ $format .= (!empty($arr["srcf"])) ? ',srcf:"'.$arr["srcf"].'"' : '';
+ $format .= '}';
+ return $format;
+ }
} //--- End Class
//----------------------------------------
@@ -656,8 +669,27 @@ function hak_compressor_path($file) {
function hak_txpimage() {
global $img_dir,$path_to_site,$txpcfg;
$category = gps("c");
- $category = (!empty($category)) ? "and category='".doSlash($category)."'" : "";
- $rs = safe_rows_start("*", "txp_image","1=1 ".$category." order by category,name");
+ $author = gps("a");
+ $limit_image = gps("limimg");
+ $limit_img_count = gps("limcount");
+
+ if(empty($author)) { $author = ""; }
+ else { $author = " and author='".doSlash($author)."' "; }
+ if(empty($category)) { $category = ""; }
+ else { $category = " and category='".doSlash($category)."' "; }
+
+ if(empty($limit_img_count)) { $limit_img_count = 0; }
+ else { $limit_img_count = intval($limit_img_count); }
+ if($limit_image=='0') { $limit_image = ""; }
+ elseif(empty($limit_image)) { $limit_image = " limit 0,10"; }
+ else {
+ if(intval($limit_image)==0) { $limit_image = " limit 0,10"; }
+ else { $limit_image = " limit ".$limit_img_count*intval($limit_image).",".intval($limit_image); }
+ }
+ $srcf2 = gps("srcf2");
+ $srcf2 = (!empty($srcf2))? true : false;
+
+ $rs = safe_rows_start("*", "txp_image","1=1 ".$category.$author." order by id desc,category,name".$limit_image);
$src = gps("src");
@@ -682,9 +714,19 @@ function hak_txpimage() {
$thumb["height"] = $thumb_h;
$thumb["alt"] = $image["alt"];
$thumb["caption"] = $image["caption"];
+ $thumbf["path"] = hu.$img_dir.'/'.$id.'t'.$ext;
+ $thumbf["width"] = $thumb_w;
+ $thumbf["height"] = $thumb_h;
+ $thumbf["alt"] = $image["alt"];
+ $thumbf["caption"] = $image["caption"];
+ $thumbf["srcf"] = $image["path"];
$preview = $thumb;
$thumbclick = 'onclick=\'TxpImageDialog.insertImage(this,'.hak_tinymce::map_attribs($thumb).');return'.n.'false;\'';
+ $thumbclickf = 'onclick=\'TxpImageDialog.insertImage(this,'.hak_tinymce::map_attribsf($thumbf).');return'.n.'false;\'';
$thumbclick = '
';
+ if($srcf2) {
+ $thumbclick .= '
';
+ }
}
//$desiredheight = $preview["height"];
@@ -719,15 +761,155 @@ function hak_txpimage() {
}
function hak_txpcatselect() {
+ global $img_dir,$path_to_site,$txpcfg;
+ $num = 10;
+ $category = gps("c");
+ $author = gps("a");
+ $limit_image = gps("limimg");
+ $limit_img_count = gps("limcount");
+
+ if(empty($author) || $author=='0') { $author = ""; }
+ else { $author = " and author='".doSlash($author)."' "; }
+ if(empty($category) || $category=='0') { $category = ""; }
+ else { $category = " and category='".doSlash($category)."' "; }
+
$rs = getTree("root",'image');
+
+ $a_out = array();
+ $a_out[] = array('name'=>'0','title'=>'All','level'=>0);
+ $rs_author = safe_rows_start("name, RealName", "txp_users","1=1");
+ if($rs_author) {
+ while ($a = nextRow($rs_author)) {
+ extract($a);
+ $a_out[] = array('name'=>$name,'title'=>$RealName,'level'=>0);
+ }
+ }
+
+ $lim_out = array();
+ $lim_out[] = array('name'=>'0','title'=>'All','level'=>0);
+ $lim_out[] = array('name'=>'10','title'=>'10','level'=>0);
+ $lim_out[] = array('name'=>'20','title'=>'20','level'=>0);
+ $lim_out[] = array('name'=>'30','title'=>'30','level'=>0);
+ $lim_out[] = array('name'=>'50','title'=>'50','level'=>0);
+
+ $t_ar = array("id"=>0,"name"=>'0',"title"=>'All',"level"=>0,"children"=>0,"parent"=>'root');
+ array_unshift($rs, $t_ar);
+
if ($rs) {
- echo tag(gTxt('category'),"legend").
- treeSelectInput("category",$rs,"","txpCategory");
+ echo '
'.
+ treeSelectInput2("category",$rs,"0","txpCategory").
+ '
'.
+ treeSelectInput2("author",$a_out,"0","txpAuthor").'
'.
+ '
'.
+ '
'.
+ treeSelectInput2("LimitImages",$lim_out,"10","txpLimitImages").'
';
+ }
+ exit(0);
+}
+function hak_txpcountselect() {
+ global $img_dir,$path_to_site,$txpcfg;
+ $num = 10;
+ $category = gps("c");
+ $author = gps("a");
+ $limit_image = gps("limimg");
+ $limit_img_count = gps("limcount");
+
+ if(empty($author) || $author=='0') { $author = ""; }
+ else { $author = " and author='".doSlash($author)."' "; }
+ if(empty($category) || $category=='0') { $category = ""; }
+ else { $category = " and category='".doSlash($category)."' "; }
+
+ if(empty($limit_img_count)) { $limit_img_count = 0; }
+ else { $limit_img_count = intval($limit_img_count); }
+
+ if($limit_image=='0') { $limit_image = 1; }
+ elseif(empty($limit_image)) { $limit_image = 10; }
+ else { $limit_image = (intval($limit_image)==0)? 1 : intval($limit_image); }
+
+ $rcount = safe_count("txp_image", "1=1 ".$category.$author);
+ $count = 0; $min_count = 0; $max_count = 0; $lim_count_out = array();
+ $count = ceil($rcount/$limit_image);
+ if($count<=$num) { $min_count = 0; $max_count = $count; }
+ elseif($limit_img_count>$count) { $min_count=($count-$num>0)? $count-$num: 0; $max_count = $count; }
+ elseif($count<$num) { $min_count=0; $max_count=$count; }
+ else{
+ $pol = ceil($num/2);
+ $max_count=($limit_img_count+$pol>=$count)? $count : (($limit_img_count+$pol<=$num)? $num : $limit_img_count+$pol);
+ $min_count=($limit_img_count-$pol<=0)? 0 : (($max_count-$num>0)? $max_count-$num : $limit_img_count-$pol);
}
+ for($i=0; $i<$count; $i++) {
+ $lim_count_out[] = array('count_li'=>$i);
+ }
+ if ($rcount>$limit_image && $limit_image>1) { echo liLinks2($lim_count_out, $limit_img_count, $count, $min_count, $max_count, $num); }
+ else { echo ''; }
exit(0);
}
+function treeSelectInput2($select_name = '', $array = '', $value = '', $select_id = '', $truncate = 0) {
+ $out = array();
+ $selected = false;
+ foreach ($array as $a)
+ {
+ if ($a['name'] == 'root')
+ {
+ continue;
+ }
+ extract($a);
+ if ($name == $value)
+ {
+ $sel = ' selected="selected"';
+ $selected = true;
+ }
+ else
+ {
+ $sel = '';
+ }
+ $sp = str_repeat(sp.sp, $level);
+ if (($truncate > 3) && (strlen(utf8_decode($title)) > $truncate)) {
+ $htmltitle = ' title="'.htmlspecialchars($title).'"';
+ $title = preg_replace('/^(.{0,'.($truncate - 3).'}).*$/su','$1',$title);
+ $hellip = '…';
+ } else {
+ $htmltitle = $hellip = '';
+ }
+ $out[] = n.t.'';
+ }
+
+ return n.'';
+}
+
+function liLinks2($array = '', $value = '', $count = 0, $min_count = 0, $max_count = 0, $num = 10) {
+ $out = array();
+ if($count>0) {
+ foreach ($array as $a) {
+ extract($a);
+ if($count_li == $value) { $class = ' class="li_links active" style="font-weight: bold;color:red;" '; }
+ else { $class = ' class="li_links"'; }
+ if($count_li>=($min_count-1) && $count_li<=$max_count) {
+ $out[] = n.t.''.htmlspecialchars($count_li + 1).'';
+ }
+ if($count_li==$max_count) { break; }
+ }
+ if($count>$num && $out) {
+ $out2x = n.t.'«';
+ $tmin = ($min_count-1<0)? 0 : $min_count-1;
+ $value_min = ($value-1<0)? 0 : $value-1;
+ $out1x = n.t.'<';
+ array_unshift($out, $out2x, $out1x);
+ //$tmax = ($max_count+1>$count)? $count-1 : $max_count+1;
+ $value_max = ($value+1>=$count)? $count-1 : $value+1;
+ $out[$count] = n.t.'>';
+ $count2 = $count-1;
+ $out[$count+1] = n.t.'»';
+ }
+ }
+ return n.'';
+}
# --- END PLUGIN CODE ---
if (0) {
diff --git a/txpimage/css/txpimage.css b/txpimage/css/txpimage.css
index ff7de93..5488a2f 100644
--- a/txpimage/css/txpimage.css
+++ b/txpimage/css/txpimage.css
@@ -72,4 +72,7 @@ input {width: 280px;}
border:1px solid silver;
background:white;
}
-
+#left_panel{float:left;width:140px;}
+#labelCategory, #labelAuthor, #labelLimit {font-size: 8px;}
+ul.pagination {margin: 1em 0; padding: 0.5em; text-align: left;}
+ul.pagination li {display: inline; padding: 0.1em; border:none;}
diff --git a/txpimage/editor_plugin.js b/txpimage/editor_plugin.js
index cb3fa49..92e513e 100644
--- a/txpimage/editor_plugin.js
+++ b/txpimage/editor_plugin.js
@@ -19,8 +19,8 @@
ed.windowManager.open({
file : url + '/image.htm',
- width : 480 + parseInt(ed.getLang('advimage.delta_width', 0), 10),
- height : 480 + parseInt(ed.getLang('advimage.delta_height', 0), 10),
+ width : 530 + parseInt(ed.getLang('advimage.delta_width', 0), 10),
+ height : 510 + parseInt(ed.getLang('advimage.delta_height', 0), 10),
inline : 1
}, {
plugin_url : url
diff --git a/txpimage/image.htm b/txpimage/image.htm
index f89fb69..f0dacfc 100644
--- a/txpimage/image.htm
+++ b/txpimage/image.htm
@@ -33,7 +33,9 @@
|
-
+
+
+
|
|
diff --git a/txpimage/img/picturef.png b/txpimage/img/picturef.png
new file mode 100644
index 0000000..791212f
Binary files /dev/null and b/txpimage/img/picturef.png differ
diff --git a/txpimage/js/txpimage.js b/txpimage/js/txpimage.js
index 3d148b6..40605e9 100644
--- a/txpimage/js/txpimage.js
+++ b/txpimage/js/txpimage.js
@@ -38,6 +38,7 @@ var TxpImageDialog = {
nl.usemap.value = dom.getAttrib(n, 'usemap');
nl.longdesc.value = dom.getAttrib(n, 'longdesc');
nl.insert.value = ed.getLang('update');
+ nl.srcf2.value = '0';
if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover'))) {
nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
@@ -126,7 +127,7 @@ var TxpImageDialog = {
},
insertAndClose : function() {
- var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
+ var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, argsf = {}, el;
tinyMCEPopup.restoreSelection();
@@ -166,6 +167,11 @@ var TxpImageDialog = {
longdesc : nl.longdesc.value
});
+ tinymce.extend(argsf, {
+ href : nl.srcf.value,
+ 'class' : 'fancybox'
+ });
+
args.onmouseover = args.onmouseout = '';
if (f.onmousemovecheck.checked) {
@@ -182,11 +188,20 @@ var TxpImageDialog = {
if (el && el.nodeName == 'IMG') {
ed.dom.setAttribs(el, args);
} else {
- ed.execCommand('mceInsertContent', false, ' ', {skip_undo : 1});
- ed.dom.setAttribs('__mce_tmp', args);
- ed.dom.setAttrib('__mce_tmp', 'id', '');
- ed.undoManager.add();
- }
+ if(argsf.href != "") {
+ ed.execCommand('mceInsertContent', false, ' ', {skip_undo : 1});
+ ed.dom.setAttribs('__mce_tmp', args);
+ ed.dom.setAttrib('__mce_tmp', 'id', '');
+ ed.dom.setAttribs('__mce_tmp_a', argsf);
+ ed.dom.setAttrib('__mce_tmp_a', 'id', '');
+ ed.undoManager.add();
+ } else {
+ ed.execCommand('mceInsertContent', false, ' ', {skip_undo : 1});
+ ed.dom.setAttribs('__mce_tmp', args);
+ ed.dom.setAttrib('__mce_tmp', 'id', '');
+ ed.undoManager.add();
+ }
+ }
tinyMCEPopup.close();
},
@@ -464,18 +479,47 @@ var TxpImageDialog = {
success: function (response) {
tinyMCEPopup.dom.setHTML('catselect', response);
tinymce.dom.Event.add(tinyMCEPopup.dom.get('txpCategory'), 'change', function (e) {
- this.loadImageBrowser(e.target.value);
+ tinyMCEPopup.dom.setHTML('image_browse', ' ');
+ this.loadCountBrowser(e.target.value, tinyMCEPopup.dom.get('txpAuthor').value || '0', tinyMCEPopup.dom.get('txpLimitImages').value || '0', '0');
+ }, this);
+ tinymce.dom.Event.add(tinyMCEPopup.dom.get('txpAuthor'), 'change', function (e) {
+ tinyMCEPopup.dom.setHTML('image_browse', ' ');
+ this.loadCountBrowser(tinyMCEPopup.dom.get('txpCategory').value || '0', e.target.value, tinyMCEPopup.dom.get('txpLimitImages').value || '0', '0');
}, this);
- this.loadImageBrowser();
+ tinymce.dom.Event.add(tinyMCEPopup.dom.get('txpLimitImages'), 'change', function (e) {
+ tinyMCEPopup.dom.setHTML('image_browse', ' ');
+ this.loadCountBrowser(tinyMCEPopup.dom.get('txpCategory').value || '0', tinyMCEPopup.dom.get('txpAuthor').value || '0', e.target.value, '0');
+ }, this);
+ this.loadCountBrowser();
}
});
},
- loadImageBrowser: function (category) {
+ loadCountBrowser: function (category, author, limit, limcount) {
+ var selCat = category || "";
+ var selAuthor = author || "";
+ var selLimit = limit || 10;
+ var selLimCount = limcount || 0;
+ var src = tinyMCEPopup.dom.get('src').value || '';
+ tinymce.util.XHR.send({
+ url:this.txpEndPoint + '?event=hak_txpcountselect&src='+ src + '&c='+ selCat + '&a=' + selAuthor + '&limimg=' + selLimit + '&limcount=' + selLimCount + '&_rnd=' + new Date().getTime(),
+ type: 'GET',
+ scope: this,
+ success: function (response) {
+ tinyMCEPopup.dom.setHTML("imagesmax", response);
+ this.loadImageBrowser(selCat,selAuthor,selLimit,selLimCount);
+ }
+ });
+ },
+ loadImageBrowser: function (category, author, limit, limcount) {
var selCat = category || "";
+ var selAuthor = author || "";
+ var selLimit = limit || 10;
+ var selLimCount = limcount || 0;
var src = tinyMCEPopup.dom.get('src').value || '';
+ var srcf2 = tinyMCEPopup.dom.get('srcf2').value || 1;
tinymce.util.XHR.send({
- url:this.txpEndPoint + '?event=hak_txpimage&src='+ src + '&c='+ selCat + '&_rnd=' + new Date().getTime(),
+ url:this.txpEndPoint + '?event=hak_txpimage&src='+ src + '&c='+ selCat + '&a=' + selAuthor + '&limimg=' + selLimit + '&limcount=' + selLimCount + '&srcf2=' + srcf2 + '&_rnd=' + new Date().getTime(),
type: 'GET',
success: function (response) {
tinyMCEPopup.dom.setHTML("image_browse", response);
|