39 foreach (
$_POST as $k => $v ) {
46 if (isset(
$_GET[
'op'])) {
49 if (isset(
$_GET[
'image_id'])) {
52 if (isset(
$_GET[
'imgcat_id'])) {
53 $imgcat_id = intval(
$_GET[
'imgcat_id']);
60 if ( isset($imgcat_id) &&
$op ==
'listimg' ) {
63 if (!$imgcat_read && !$imgcat_write) {
69 if ( isset($imgcat_id) && (
$op ==
'addfile' ||
$op ==
'editcat' ||
$op ==
'updatecat' ||
$op ==
'delcatok' ||
$op ==
'delcat') ) {
91 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
93 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
94 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.lightbox.js');
95 $xoTheme->addScript(
'modules/system/js/admin.js');
105 $catcount = count($imagecategorys);
108 foreach (array_keys($imagecategorys) as
$i) {
111 if ( $imgcat_read || $imgcat_write ) {
114 $cat_images[
'id'] = $imagecategorys[
$i]->getVar(
'imgcat_id');
115 $cat_images[
'name'] = $imagecategorys[
$i]->getVar(
'imgcat_name');
116 $cat_images[
'count'] = $count;
117 $cat_images[
'size'] = $count;
118 $cat_images[
'maxsize'] = $imagecategorys[
$i]->getVar(
'imgcat_maxsize');
119 $cat_images[
'maxwidth'] = $imagecategorys[
$i]->getVar(
'imgcat_maxwidth');
120 $cat_images[
'maxheight'] = $imagecategorys[
$i]->getVar(
'imgcat_maxheight');
121 $cat_images[
'display'] = $imagecategorys[
$i]->getVar(
'imgcat_display');
122 $cat_images[
'weight'] = $imagecategorys[
$i]->getVar(
'imgcat_weight');
123 $cat_images[
'type'] = $imagecategorys[
$i]->getVar(
'imgcat_type');
124 $cat_images[
'store'] = $imagecategorys[
$i]->getVar(
'imgcat_storetype');
126 $xoopsTpl->append_by_ref(
'cat_img', $cat_images);
131 if (!empty($catcount)) {
133 $form->setExtra(
'enctype="multipart/form-data"');
137 $form->addElement($select,
true);
160 $form->addElement($storetype);
177 if ( $imgcat_id > 0 ) {
179 $old = $imgcat->getVar(
'imgcat_display');
180 $imgcat->setVar(
'imgcat_display', !$old );
190 if ($imgcat_id <= 0) {
199 if (!is_object($imagecategory)) {
209 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
211 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/lightbox.css' );
213 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
214 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
215 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.lightbox.js');
216 $xoTheme->addScript(
'modules/system/js/admin.js');
220 $xoBreadCrumb->addLink( $imagecategory->getVar(
'imgcat_name') );
226 $criteria->setSort(
'image_weight ASC, image_id');
234 if ($imagecategory->getVar(
'imgcat_storetype') ==
'db') {
238 foreach (array_keys($images) as $i) {
239 $xoopsTpl->append_by_ref(
'images', $images[$i]->toArray() );
249 if ( file_exists( XOOPS_ROOT_PATH .
'/modules/system/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'/images/lightbox-btn-close.gif' ) ) {
250 $xoopsTpl->assign(
'xoops_language', $GLOBALS[
'xoopsConfig'][
'language'] );
252 $xoopsTpl->assign(
'xoops_language',
'english' );
258 $form->setExtra(
'enctype="multipart/form-data"');
262 $form->addElement($select,
true);
282 $old = $img->getVar(
'image_display');
283 $img->setVar(
'image_display', !$old );
296 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
298 $xoTheme->addScript(
'modules/system/js/admin.js');
309 $xoBreadCrumb->addLink( $image_cat->getVar(
'imgcat_name'),
system_adminVersion(
'images',
'adminpath') .
'&op=listimg&imgcat_id=' .$image->getVar(
'imgcat_id') );
312 if ($image_cat->getVar(
'imgcat_storetype') ==
'db') {
313 $msg =
'<div class="txtcenter"><img class="tooltip" src="' . XOOPS_URL .
'/image.php?id=' .
$image->getVar(
'image_id') .
'" alt="' .
$image->getVar(
'image_nicename') .
'" title="' .
$image->getVar(
'image_nicename') .
'" style="max-width:120px; max-height:120px;"/></div>';
315 $msg =
'<div class="txtcenter"><img src="./class/thumbs/phpThumb.php?src=' .
XOOPS_UPLOAD_PATH .
'/' .
$image->getVar(
'image_name') .
'&h=120" alt="" /></div>';
321 $form->setExtra(
'enctype="multipart/form-data"');
325 $form->addElement($select,
true);
349 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
350 $xoTheme->addStylesheet(
'browse.php?Frameworks/jquery/css/thumbs/thumbs.css' );
352 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
353 $xoTheme->addScript(
'modules/system/js/thumbs.js');
359 if ($image_cat->getVar(
'imgcat_storetype') ==
'db') {
360 $msg =
'<div style="width: 180px;margin:0 auto;"><img class="thumb" src="' . XOOPS_URL .
'/image.php?id=' .
$image->getVar(
'image_id') .
'" alt="" title="" style="max-width:120px; max-height:120px;"/></div>';
362 $msg =
'<div style="width: 180px;margin:0 auto;"><img class="thumb" src="' .
XOOPS_UPLOAD_URL .
'/' .
$image->getVar(
'image_name') .
'" alt="" /></div>';
364 $msg .=
'<div class="spacer">' .
$image->getVar(
'image_nicename') .
'</div>';
376 if (!$GLOBALS[
'xoopsSecurity']->check()) {
377 redirect_header(
'admin.php?fct=images', 3, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
400 if (!$GLOBALS[
'xoopsSecurity']->check()) {
401 redirect_header(
'admin.php?fct=images', 3, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
409 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
428 if (!$GLOBALS[
'xoopsSecurity']->check()) {
429 redirect_header(
'admin.php?fct=images', 3, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
433 if (!is_object($imagecategory)) {
437 $uploader =
new XoopsMediaUploader(
XOOPS_UPLOAD_PATH .
'/images', array(
'image/gif',
'image/jpeg',
'image/pjpeg',
'image/x-png',
'image/png',
'image/bmp'), $imagecategory->getVar(
'imgcat_maxsize'), $imagecategory->getVar(
'imgcat_maxwidth'), $imagecategory->getVar(
'imgcat_maxheight'));
440 $ucount = count(
$_POST[
'xoops_upload_file']);
441 for ($i = 0; $i < $ucount; $i++) {
442 if ($uploader->fetchMedia(
$_POST[
'xoops_upload_file'][$i])) {
443 if (!$uploader->upload()) {
444 $err[] = $uploader->getErrors();
448 $image->setVar(
'image_name',
'images/' . $uploader->getSavedFileName());
449 $image->setVar(
'image_nicename', $image_nicename);
450 $image->setVar(
'image_mimetype', $uploader->getMediaType());
451 $image->setVar(
'image_created', time());
452 $image_display = empty($image_display) ? 0 : 1;
453 $image->setVar(
'image_display', $image_display);
454 $image->setVar(
'image_weight', $image_weight);
455 $image->setVar(
'imgcat_id', $imgcat_id);
456 if ($imagecategory->getVar(
'imgcat_storetype') ==
'db') {
457 $fp = @fopen($uploader->getSavedDestination(),
'rb');
458 $fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
460 $image->setVar(
'image_body', $fbinary,
true);
461 @unlink($uploader->getSavedDestination());
469 $err = array_merge($err, $uploader->getErrors(
false));
472 if (count($err) > 0) {
482 if (!$GLOBALS[
'xoopsSecurity']->check()) {
483 redirect_header(
'admin.php?fct=images', 3, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
487 $imagecategory->setVar(
'imgcat_name', $imgcat_name);
488 $imagecategory->setVar(
'imgcat_maxsize', $imgcat_maxsize);
489 $imagecategory->setVar(
'imgcat_maxwidth', $imgcat_maxwidth);
490 $imagecategory->setVar(
'imgcat_maxheight', $imgcat_maxheight);
491 $imgcat_display = empty($imgcat_display) ? 0 : 1;
492 $imagecategory->setVar(
'imgcat_display', $imgcat_display);
493 $imagecategory->setVar(
'imgcat_weight', $imgcat_weight);
494 $imagecategory->setVar(
'imgcat_storetype', $imgcat_storetype);
495 $imagecategory->setVar(
'imgcat_type',
'C');
499 $newid = $imagecategory->getVar(
'imgcat_id');
501 if (!isset($readgroup)) {
502 $readgroup = array();
504 if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
505 array_push($readgroup, XOOPS_GROUP_ADMIN);
507 foreach ($readgroup as $rgroup) {
508 $imagecategoryperm =& $imagecategoryperm_handler->create();
509 $imagecategoryperm->setVar(
'gperm_groupid', $rgroup);
510 $imagecategoryperm->setVar(
'gperm_itemid', $newid);
511 $imagecategoryperm->setVar(
'gperm_name',
'imgcat_read');
512 $imagecategoryperm->setVar(
'gperm_modid', 1);
513 $imagecategoryperm_handler->insert($imagecategoryperm);
514 unset($imagecategoryperm);
516 if (!isset($writegroup)) {
517 $writegroup = array();
519 if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
520 array_push($writegroup, XOOPS_GROUP_ADMIN);
522 foreach ($writegroup as $wgroup) {
523 $imagecategoryperm =& $imagecategoryperm_handler->create();
524 $imagecategoryperm->setVar(
'gperm_groupid', $wgroup);
525 $imagecategoryperm->setVar(
'gperm_itemid', $newid);
526 $imagecategoryperm->setVar(
'gperm_name',
'imgcat_write');
527 $imagecategoryperm->setVar(
'gperm_modid', 1);
528 $imagecategoryperm_handler->insert($imagecategoryperm);
529 unset($imagecategoryperm);
536 if ($imgcat_id <= 0) {
541 if (!is_object($imagecategory)) {
566 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
567 $xoTheme->addStylesheet(
'browse.php?Frameworks/jquery/css/thumbs/thumbs.css' );
568 $xoTheme->addStylesheet(
'browse.php?Frameworks/jquery/css/lightbox/lightbox.css' );
570 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
571 $xoTheme->addScript(
'modules/system/js/admin.js');
572 $xoTheme->addScript(
'modules/system/js/thumbs.js');
575 $xoBreadCrumb->addLink( $imagecategory->getVar(
'imgcat_name'),
'' );
584 if (!$GLOBALS[
'xoopsSecurity']->check() || $imgcat_id <= 0) {
585 redirect_header(
'admin.php?fct=images',1, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
589 if (!is_object($imagecategory)) {
592 $imagecategory->setVar(
'imgcat_name', $imgcat_name);
593 $imgcat_display = empty($imgcat_display) ? 0 : 1;
594 $imagecategory->setVar(
'imgcat_display', $imgcat_display);
595 $imagecategory->setVar(
'imgcat_maxsize', $imgcat_maxsize);
596 $imagecategory->setVar(
'imgcat_maxwidth', $imgcat_maxwidth);
597 $imagecategory->setVar(
'imgcat_maxheight', $imgcat_maxheight);
598 $imagecategory->setVar(
'imgcat_weight', $imgcat_weight);
608 $imagecategoryperm_handler->deleteAll(
$criteria);
609 if (!isset($readgroup)) {
610 $readgroup = array();
612 if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
613 array_push($readgroup, XOOPS_GROUP_ADMIN);
615 foreach ($readgroup as $rgroup) {
616 $imagecategoryperm =& $imagecategoryperm_handler->create();
617 $imagecategoryperm->setVar(
'gperm_groupid', $rgroup);
618 $imagecategoryperm->setVar(
'gperm_itemid', $imgcat_id);
619 $imagecategoryperm->setVar(
'gperm_name',
'imgcat_read');
620 $imagecategoryperm->setVar(
'gperm_modid', 1);
621 $imagecategoryperm_handler->insert($imagecategoryperm);
622 unset($imagecategoryperm);
624 if (!isset($writegroup)) {
625 $writegroup = array();
627 if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
628 array_push($writegroup, XOOPS_GROUP_ADMIN);
630 foreach ($writegroup as $wgroup) {
631 $imagecategoryperm =& $imagecategoryperm_handler->create();
632 $imagecategoryperm->setVar(
'gperm_groupid', $wgroup);
633 $imagecategoryperm->setVar(
'gperm_itemid', $imgcat_id);
634 $imagecategoryperm->setVar(
'gperm_name',
'imgcat_write');
635 $imagecategoryperm->setVar(
'gperm_modid', 1);
636 $imagecategoryperm_handler->insert($imagecategoryperm);
637 unset($imagecategoryperm);
652 if (!$GLOBALS[
'xoopsSecurity']->check()) {
653 redirect_header(
'admin.php?fct=images', 3, implode(
'<br />', $GLOBALS[
'xoopsSecurity']->getErrors()));
655 $imgcat_id = intval($imgcat_id);
656 if ($imgcat_id <= 0) {
661 if (!is_object($imagecategory)) {
664 if ($imagecategory->getVar(
'imgcat_type') !=
'C') {
673 foreach (array_keys($images) as $i) {