Пример #1
0
    function view(&$row, &$cat, &$neighbors, &$related, &$params)
    {
        global $option, $mainframe, $wbgItemid, $my;
        global $WBG_CONFIG, $WBG_LANG, $wbGallery_common;
        // mosPathway must be in template
        $wbGallery_common->pathway($row);
        // Stylesheet
        if ($params->get('css')) {
            $mainframe->addCustomHeadTag('<link href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/css/' . $params->get('css') . '" rel="stylesheet" type="text/css" />');
        } else {
            $mainframe->addCustomHeadTag('<link href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/css/default.css" rel="stylesheet" type="text/css" />');
        }
        // Page Title
        if ($params->get('wbg_title_show', 0)) {
            if ($params->get('view_img_name', 0)) {
                $page_title = $row->name;
            } elseif ($params->get('wbg_title_follow', 0)) {
                $page_title = $params->get('wbg_title', $row->name);
            }
            if ($page_title) {
                $title = sprintf($WBG_LANG->_('VIEW_IMAGE'), $page_title);
            } else {
                $title = $WBG_LANG->_('VIEW_IMAGE_GEN');
            }
            $mainframe->setPageTitle($title);
            if (is_object($cat) && strlen($cat->name) && $params->get('view_img_name_cat', 1)) {
                echo '<h1 class="componentheading"><a href="' . sefRelToAbs('index.php?option=' . $option . '&cid=' . $cat->id . '&Itemid=' . $wbgItemid) . '" title="' . $cat->name . '">' . $cat->name . '</a> :: ' . $title . '</h1>';
            } else {
                echo '<h1 class="componentheading">' . $title . '</h1>';
            }
        }
        // Neighbor Links
        if ($params->get('view_neighbors', 1) && ($neighbors->prev_id || $neighbors->next_id)) {
            $link = 'index.php?option=' . $option . '&Itemid=' . $wbgItemid . '&id=';
            echo '<div class="wbgNeighbor">';
            if ($neighbors->prev_id) {
                echo '<a href="' . sefRelToAbs($link . $neighbors->prev_id) . '" alt="' . $neighbors->prev_name . '" class="prev">' . $WBG_LANG->_('VIEW_PREV_IMAGE') . '</a>';
            }
            if ($neighbors->next_id) {
                echo '<a href="' . sefRelToAbs($link . $neighbors->next_id) . '" alt="' . $neighbors->next_name . '" class="next">' . $WBG_LANG->_('VIEW_NEXT_IMAGE') . '</a>';
            }
            echo '</div>';
        }
        // Render Detail Image
        $imgPath = wbGalleryDB_img::getImagePath($params->get('view_img_size', 'large'));
        $imgFile = $imgPath . $row->file;
        ?>

    <div class="wbgImgView">
      <span class="wbgImg">
        <div class="img"><img src="<?php 
        echo $imgFile;
        ?>
" border="0" /></div>
      </span>
    </div>
    <?php 
        // Sku / Price / Photographer
        if ($params->get('view_img_cat', 0)) {
            echo '<div class="category">' . sprintf($WBG_LANG->_('CAT_NAME'), $cat->name) . '</div>';
        }
        if ($params->get('view_img_sku', 0)) {
            echo '<div class="sku"><span>' . $WBG_LANG->_('SKU_TITLE') . '</span> ' . (strlen($row->sku) ? $row->sku : $WBG_LANG->_('SKU_NA')) . '</div>';
        }
        if ($params->get('view_img_price', 0)) {
            echo '<div class="price"><span>' . $WBG_LANG->_('PRICE_TITLE') . '</span> ' . $wbGallery_common->formatPrice($row->price) . '</div>';
        }
        if ($params->get('view_img_photog', 0)) {
            echo '<div class="photog"><span>' . $WBG_LANG->_('PHOTOGRAPHER_TITLE') . '</span> ' . (strlen($row->photographer) ? $row->photographer : $WBG_LANG->_('PHOTOGRAPHER_NA')) . '</div>';
        }
        // Image Description
        if ($params->get('view_img_desc', 1) && strlen(trim(strip_tags($row->description)))) {
            echo '<div class="componentdescription">' . $row->description . '</div>';
            echo '<div class="clr"></div>';
        }
        // Show Related Images
        if ($params->get('view_related', 1) && count($related)) {
            // Image Lightbox
            if ($params->get('img_link', 'lightbox') == 'lightbox' || $params->get('img_name_link', 'lightbox') == 'lightbox') {
                $mainframe->addCustomHeadTag('<script type="text/javascript">var path="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/";</script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/prototype.js"></script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/scriptaculous.js?load=effects"></script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/lightbox.js"></script>');
                $mainframe->addCustomHeadTag('<link rel="stylesheet" href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/css/lightbox.css" type="text/css" media="screen" />');
            }
            // Get Image Size Path
            $imgPath = wbGalleryDB_img::getImagePath($params->get('related_img_size', 'thumb'));
            $lboxImgPath = wbGalleryDB_img::getImagePath($params->get('lightbox_img_size', 'large'));
            // Render Relative Header
            if ($params->get('view_related_title', 1)) {
                if (is_object($cat)) {
                    $relLink = '<a href="' . sefRelToAbs('index.php?option=' . $option . '&cid=' . $cat->id . '&Itemid=' . $wbgItemid) . '" title="' . $cat->name . '">' . $cat->name . '</a>';
                } else {
                    $relLink = '<a href="' . sefRelToAbs('index.php?option=' . $option . '&Itemid=' . $wbgItemid) . '" title="' . $WBG_LANG->_('RELATED_LINK_NOCAT') . '">' . $WBG_LANG->_('RELATED_LINK_NOCAT') . '</a>';
                }
                echo '<h2 class="contentheading">' . sprintf($WBG_LANG->_('RELATED_IMAGES'), $relLink) . '</h2>';
            }
            // Render Images
            echo '<div class="wbgRelatedImages">';
            echo '<div class="wbgImgList">';
            $count = 1;
            $cols = $params->get('related_img_cols', 3);
            echo '<div class="ncpr' . $cols . '">';
            foreach ($related as $img) {
                $link = sefRelToAbs('index.php?option=' . $option . '&id=' . $img->id . '&Itemid=' . $wbgItemid);
                $imgFile = $imgPath . $img->file;
                $lboxFile = $lboxImgPath . $img->file;
                $lboxName = $img->name . ($params->get('img_price', 0) ? ' ' . $wbGallery_common->formatPrice($img->price) : '');
                ?>

            <span class="wbgImg">
              <span class="block">
                <span class="pad">
                  <?php 
                if ($params->get('img_name', 1)) {
                    if ($params->get('img_name_link', 'view') == 'view') {
                        echo '<div class="name"><a href="' . $link . '">' . $img->name . '</a></div>';
                    } elseif ($params->get('img_name_link') == 'lightbox') {
                        echo '<div class="name"><a href="' . $lboxFile . '" rel="lightbox[' . $row->name . ']" title="' . $lboxName . '">' . $img->name . '</a></div>';
                    } else {
                        echo '<div class="name">' . $img->name . '</div>';
                    }
                }
                if ($params->get('img_image', 1)) {
                    if ($params->get('img_link', 'lightbox') != 'lightbox') {
                        $alt_link = null;
                        if ($params->get('lightbox_alternate', 'view') == 'view') {
                            $alt_link = $link;
                        } elseif (in_array($params->get('lightbox_alternate'), array('load', 'load_pop'))) {
                            $alt_link = $lboxFile;
                        }
                        ?>

                      <a href="<?php 
                        echo is_null($alt_link) ? 'javascript:void(0);' : $alt_link;
                        ?>
" title="<?php 
                        echo $lboxName;
                        ?>
" <?php 
                        echo $params->get('lightbox_alternate') == 'load_pop' ? 'target="_blank"' : '';
                        ?>
 class="img"><span style="background-image:url('<?php 
                        echo $imgFile;
                        ?>
');"><img src="<?php 
                        echo $imgFile;
                        ?>
" border="0" /></span></a>
                      <?php 
                    } else {
                        ?>

                      <a href="<?php 
                        echo $lboxFile;
                        ?>
" rel="lightbox[<?php 
                        echo $row->name;
                        ?>
]" title="<?php 
                        echo $lboxName;
                        ?>
" class="img"><span style="background-image:url('<?php 
                        echo $imgFile;
                        ?>
');"><img src="<?php 
                        echo $imgFile;
                        ?>
" border="0" /></span></a>
                      <?php 
                    }
                }
                if ($params->get('img_sku', 0)) {
                    echo '<div class="sku"><span>' . $WBG_LANG->_('SKU_TITLE') . '</span> ' . (strlen($img->sku) ? $img->sku : $WBG_LANG->_('SKU_NA')) . '</div>';
                }
                if ($params->get('img_price', 0)) {
                    echo '<div class="price"><span>' . $WBG_LANG->_('PRICE_TITLE') . '</span> ' . $wbGallery_common->formatPrice($img->price) . '</div>';
                }
                if ($params->get('img_photog', 0)) {
                    echo '<div class="photog"><span>' . $WBG_LANG->_('PHOTOGRAPHER_TITLE') . '</span> ' . (strlen($img->photographer) ? $img->photographer : $WBG_LANG->_('PHOTOGRAPHER_NA')) . '</div>';
                }
                if ($params->get('img_desc', 1)) {
                    echo '<div class="desc">' . $img->description . '</div>';
                }
                ?>

                </span>
              </span>
            </span>
            <?php 
                if (!($count++ % $cols)) {
                    echo '<div class="clr"></div>';
                }
            }
            echo '</div>';
            if (--$count % $cols) {
                echo '<div class="clr"></div>';
            }
            echo '</div>';
            // wbgImgList
            echo '</div>';
            // wbgRelatedImages
        }
        // End Related Images
        if ($params->get('view_goback') || $params->get('view_continue')) {
            echo '<div class="wbgFootnav">';
            if ($params->get('view_goback')) {
                echo '<div class="wbg_goback"><a href="javascript:history.back();" title="' . $WBG_LANG->_('GOBACK') . '">' . $WBG_LANG->_('GOBACK') . '</a></div>';
            }
            if ($params->get('view_continue')) {
                if (is_object($cat)) {
                    $relLink = '<a href="' . sefRelToAbs('index.php?option=' . $option . '&cid=' . $cat->id . '&Itemid=' . $wbgItemid) . '" title="' . $cat->name . '">' . $cat->name . '</a>';
                } else {
                    $relLink = '<a href="' . sefRelToAbs('index.php?option=' . $option . '&Itemid=' . $wbgItemid) . '" title="' . $WBG_LANG->_('RELATED_LINK_NOCAT') . '">' . $WBG_LANG->_('RELATED_LINK_NOCAT') . '</a>';
                }
                echo '<div class="wbg_continue">' . sprintf($WBG_LANG->_('CONTINUE'), $relLink) . '</div>';
            }
            echo '</div>';
        }
    }
 function add($filePath, $fileName, $fileType, &$defRow, $store = true)
 {
     global $my, $mainframe, $database, $option, $priTask, $subTask;
     global $WBG_CONFIG, $wbGalleryDB_cat;
     $time = time() . rand(0, 99999);
     $date = date('Y_m');
     $fileName = preg_replace('/[\\s|\\\\|\\"|\\&|\\?|\']+/', '_', $fileName);
     $fileName = preg_replace('/\\_+/', '_', $fileName);
     $fileExt = preg_replace('/^\\w+\\//', '', $fileType);
     $newFileName = $date . '/' . $time . '.' . $fileExt;
     // Initial File Should be the Largest
     $origInfo = getimagesize($filePath);
     // Debug
     echo "Adding File: " . $fileName . ' -> ' . $newFileName . '<br/>';
     for ($iType = 1; $iType <= 5; $iType++) {
         $active = 0;
         // Process from Largest to Smallest
         switch ($iType) {
             case 1:
                 // ORIGINAL
                 $active = $WBG_CONFIG->save_original;
                 $width = 0;
                 $height = 0;
                 $quality = 0;
                 $path = $mainframe->getCfg('absolute_path') . $WBG_CONFIG->path_original;
                 break;
             case 2:
                 // LARGE
                 $active = $WBG_CONFIG->save_large;
                 $width = $WBG_CONFIG->width_large;
                 $height = $WBG_CONFIG->height_large;
                 $quality = $WBG_CONFIG->quality_large;
                 $path = $mainframe->getCfg('absolute_path') . $WBG_CONFIG->path_large;
                 break;
             case 3:
                 // MEDIUM
                 $active = $WBG_CONFIG->save_medium;
                 $width = $WBG_CONFIG->width_medium;
                 $height = $WBG_CONFIG->height_medium;
                 $quality = $WBG_CONFIG->quality_medium;
                 $path = $mainframe->getCfg('absolute_path') . $WBG_CONFIG->path_medium;
                 break;
             case 4:
                 // THUMB
                 $active = $WBG_CONFIG->save_thumb;
                 $width = $WBG_CONFIG->width_thumb;
                 $height = $WBG_CONFIG->height_thumb;
                 $quality = $WBG_CONFIG->quality_thumb;
                 $path = $mainframe->getCfg('absolute_path') . $WBG_CONFIG->path_thumb;
                 break;
             case 5:
                 // TACK
                 $active = $WBG_CONFIG->save_tack;
                 $width = $WBG_CONFIG->width_tack;
                 $height = $WBG_CONFIG->height_tack;
                 $quality = $WBG_CONFIG->quality_tack;
                 $path = $mainframe->getCfg('absolute_path') . $WBG_CONFIG->path_tack;
                 break;
         }
         // Process the Image for Step
         // Check / Create Destination
         // Copy Image
         // Resize Copied
         if ($active) {
             $fullPath = $path . $newFileName;
             if (!is_writable($path)) {
                 echo "<script> alert('Permission Denied for {$path}'); window.history.go(-1); </script>\n";
                 exit;
             }
             if (!file_exists($path . $date)) {
                 if (!mkdir($path . $date)) {
                     echo "<script> alert('Failed to Create Category Folder'); window.history.go(-1); </script>\n";
                     exit;
                 }
                 mosChmod($path . $date, 0777);
             }
             if (!copy($filePath, $fullPath)) {
                 echo "<script> alert('Failed to Save Image'); window.history.go(-1); </script>\n";
                 exit;
             }
             if ($width && $height) {
                 if (!$this->resize($fullPath, $fileType, $width, $height)) {
                     echo "<script> alert('Error Resizing Image {$fileName}'); window.history.go(-1); </script>\n";
                     exit;
                 } else {
                     $imgInfo = getimagesize($fullPath);
                 }
             }
         }
     }
     // Debug
     echo "Creating Database Record: " . $fileName . '<br/>';
     // Store Record
     $row = new wbGalleryDB_img($database);
     $row->file = $newFileName;
     $row->cat_id = $defRow->cat_id;
     $row->name = strlen($defRow->name) ? $defRow->name : preg_replace('/\\.\\w+$/', '', $fileName);
     $row->description = $defRow->description;
     $row->photographer = $defRow->photographer;
     $row->price = $defRow->price;
     $row->sku = $defRow->sku;
     $row->publised = $defRow->publised;
     $row->created = date('Y-m-d H:i:s');
     $row->modified = $row->created;
     $row->ordering = 0;
     if (is_array($origInfo)) {
         $row->width = $origInfo[0];
         $row->height = $origInfo[1];
         $row->size = $origInfo['bits'];
     } elseif (is_array($imgInfo)) {
         $row->width = $imgInfo[0];
         $row->height = $imgInfo[1];
         $row->size = $imgInfo['bits'];
     }
     if ($store) {
         // Check
         if (!$row->check()) {
             echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
             exit;
         }
         // Store
         if (!$row->store()) {
             echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
             exit;
         }
         // Update Ordering
         $row->updateOrder('cat_id = ' . (int) $row->cat_id);
         echo "Image Stored Successfully <br/><br/>";
         return true;
     } else {
         return $row;
     }
 }
Пример #3
0
    function view(&$row, &$cats, &$imgs, &$pageNav, &$params)
    {
        global $option, $mainframe, $wbgItemid, $my;
        global $WBG_CONFIG, $WBG_LANG, $wbGallery_common;
        // mosPathway must be in template
        $wbGallery_common->pathway($row);
        // Stylesheet
        if ($params->get('css')) {
            $mainframe->addCustomHeadTag('<link href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/css/' . $params->get('css') . '" rel="stylesheet" type="text/css" />');
        } else {
            $mainframe->addCustomHeadTag('<link href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/css/default.css" rel="stylesheet" type="text/css" />');
        }
        // Page Title
        if ($params->get('wbg_title_show', 0)) {
            $custom_title = $params->get('wbg_title_follow', 0) || $row->id == $params->get('cid', 0);
            if ($custom_title && strlen($params->get('wbg_title', null))) {
                $title = $params->get('wbg_title');
            } elseif (strlen($row->name)) {
                $title = sprintf($WBG_LANG->_('VIEW_CATEGORY'), $row->name);
            } else {
                $title = $WBG_LANG->_('VIEW_CATEGORY_GEN');
            }
            $mainframe->setPageTitle($title);
            echo '<h1 class="componentheading">' . $title . '</h1>';
        }
        // Page Description
        if ($params->get('cat_desc', 1) && strlen(trim(strip_tags($row->description)))) {
            echo '<div class="desc">' . $row->description . '</div>';
            echo '<div class="clr"></div>';
        }
        // Show Categories
        $countCat = 0;
        if (count($cats)) {
            // Get Image Size Path
            $imgPath = wbGalleryDB_img::getImagePath($params->get('cat_size', 'thumb'));
            // Render Categories
            echo '<div class="wbgCatList">';
            $count = 1;
            $cols = $params->get('cat_cols', 3);
            echo '<div class="ncpr' . $cols . '">';
            foreach ($cats as $cat) {
                $imgFile = null;
                $link = sefRelToAbs('index.php?option=' . $option . '&cid=' . $cat->id . '&Itemid=' . $wbgItemid);
                if (in_array($params->get('cat_image', 1), array(2, 3)) && $cat->file) {
                    $imgFile = $imgPath . $cat->file;
                } elseif (in_array($params->get('cat_image', 1), array(1, 3)) && $cat->img_file) {
                    $imgFile = $imgPath . $cat->img_file;
                }
                if (!$params->get('cat_image', 1) || $imgFile) {
                    ?>
            <span class="wbgCat">
              <span class="block">
                <span class="pad">
                  <?php 
                    if (!is_null($imgFile)) {
                        if ($params->get('cat_name', 1)) {
                            echo '<div class="name">' . $cat->name . '</div>';
                        }
                        ?>
                      <a href="<?php 
                        echo $link;
                        ?>
" title="'.$cat->name.'" class="img"><span style="background-image:url('<?php 
                        echo $imgFile;
                        ?>
');">
                        <img src="<?php 
                        echo $imgFile;
                        ?>
" alt="'.$cat->name.'" border="0" /></span></a>
                      <?php 
                    } else {
                        echo '<div class="name"><a href="' . $link . '" title="' . $cat->name . '">' . $cat->name . '</a></div>';
                    }
                    if ($params->get('cat_desc', 1)) {
                        echo '<div class="desc">' . $cat->description . '</div>';
                    }
                    ?>
                </span>
              </span>
            </span>
            <?php 
                    if (!($count++ % $cols)) {
                        echo '<div class="clr"></div>';
                    }
                    $countCat++;
                }
            }
            echo '</div>';
            if (--$count % $cols) {
                echo '<div class="clr"></div>';
            }
            echo '</div>';
        }
        // Show Images
        $countImg = 0;
        if (count($imgs)) {
            // Page Navigation
            if (in_array($params->get('show_pagenav', 'both'), array('top', 'both'))) {
                echo '<div class="pagenav_top">' . $pageNav->writePagesLinks('index.php?option=' . $option . '&cid=' . $row->id . '&Itemid=' . $wbgItemid) . '</div>';
            }
            // Image Lightbox
            if ($params->get('img_link', 'lightbox') == 'lightbox' || $params->get('img_name_link', 'lightbox') == 'lightbox') {
                $mainframe->addCustomHeadTag('<script type="text/javascript">var path="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/";</script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/prototype.js"></script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/scriptaculous.js?load=effects"></script>');
                $mainframe->addCustomHeadTag('<script type="text/javascript" src="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/js/lightbox.js"></script>');
                $mainframe->addCustomHeadTag('<link rel="stylesheet" href="' . $mainframe->getCfg('live_site') . '/components/' . $option . '/lightbox/css/lightbox.css" type="text/css" media="screen" />');
            }
            // Get Image Size Path
            $imgPath = wbGalleryDB_img::getImagePath($params->get('img_size', 'thumb'));
            $lboxImgPath = wbGalleryDB_img::getImagePath($params->get('lightbox_img_size', 'large'));
            // Render Images
            echo '<div class="wbgImgList">';
            $count = 1;
            $cols = $params->get('img_cols', 3);
            echo '<div class="ncpr' . $cols . '">';
            foreach ($imgs as $img) {
                $link = sefRelToAbs('index.php?option=' . $option . '&id=' . $img->id . '&Itemid=' . $wbgItemid);
                $imgFile = $imgPath . $img->file;
                $lboxFile = $lboxImgPath . $img->file;
                $lboxName = $img->name . ($params->get('img_price', 0) ? ' ' . $wbGallery_common->formatPrice($img->price) : '');
                ?>
          <span class="wbgImg">
            <span class="block">
              <span class="pad">
                <?php 
                if ($params->get('img_name', 1)) {
                    if ($params->get('img_name_link', 'view') == 'view') {
                        echo '<div class="name"><a href="' . $link . '">' . $img->name . '</a></div>';
                    } elseif ($params->get('img_name_link') == 'lightbox') {
                        echo '<div class="name"><a href="' . $lboxFile . '" rel="lightbox[' . $row->name . ']" title="' . $lboxName . '">' . $img->name . '</a></div>';
                    } elseif ($params->get('img_name_link') == 'load') {
                        echo '<div class="name"><a href="' . $lboxFile . '" title="' . $lboxName . '">' . $img->name . '</a></div>';
                    } elseif ($params->get('img_name_link') == 'load_pop') {
                        echo '<div class="name"><a href="' . $lboxFile . '" title="' . $lboxName . '" target="_blank">' . $img->name . '</a></div>';
                    } else {
                        echo '<div class="name">' . $img->name . '</div>';
                    }
                }
                if ($params->get('img_image', 1)) {
                    if ($params->get('img_link', 'lightbox') != 'lightbox') {
                        $alt_link = null;
                        if ($params->get('lightbox_alternate', 'view') == 'view') {
                            $alt_link = $link;
                        } elseif (in_array($params->get('lightbox_alternate'), array('load', 'load_pop'))) {
                            $alt_link = $lboxFile;
                        }
                        ?>
                    <a href="<?php 
                        echo is_null($alt_link) ? 'javascript:void(0);' : $alt_link;
                        ?>
" title="<?php 
                        echo $lboxName;
                        ?>
" <?php 
                        echo $params->get('lightbox_alternate') == 'load_pop' ? 'target="_blank"' : '';
                        ?>
 class="img"><span style="background-image:url('<?php 
                        echo $imgFile;
                        ?>
');"><img src="<?php 
                        echo $imgFile;
                        ?>
" border="0" /></span></a>
                    <?php 
                    } else {
                        ?>
                    <a href="<?php 
                        echo $lboxFile;
                        ?>
" rel="lightbox[<?php 
                        echo $row->name;
                        ?>
]" title="<?php 
                        echo $lboxName;
                        ?>
" class="img"><span style="background-image:url('<?php 
                        echo $imgFile;
                        ?>
');"><img src="<?php 
                        echo $imgFile;
                        ?>
" border="0" /></span></a>
                    <?php 
                    }
                }
                if ($params->get('img_sku', 0)) {
                    echo '<div class="sku"><span>' . $WBG_LANG->_('SKU_TITLE') . '</span> ' . (strlen($img->sku) ? $img->sku : $WBG_LANG->_('SKU_NA')) . '</div>';
                }
                if ($params->get('img_price', 0)) {
                    echo '<div class="price"><span>' . $WBG_LANG->_('PRICE_TITLE') . '</span> ' . $wbGallery_common->formatPrice($img->price) . '</div>';
                }
                if ($params->get('img_photog', 0)) {
                    echo '<div class="photog"><span>' . $WBG_LANG->_('PHOTOGRAPHER_TITLE') . '</span> ' . (strlen($img->photographer) ? $img->photographer : $WBG_LANG->_('PHOTOGRAPHER_NA')) . '</div>';
                }
                if ($params->get('img_desc', 0)) {
                    echo '<div class="desc">' . $img->description . '</div>';
                }
                ?>
              </span>
            </span>
          </span>
          <?php 
                if (!($count++ % $cols)) {
                    echo '<div class="clr"></div>';
                }
                $countImg++;
            }
            echo '</div>';
            if (--$count % $cols) {
                echo '<div class="clr"></div>';
            }
            echo '</div>';
            // Page Navigation
            if (in_array($params->get('show_pagenav', 'both'), array('bottom', 'both'))) {
                echo '<div class="pagenav_bottom">' . $pageNav->writePagesLinks('index.php?option=' . $option . '&cid=' . $row->id . '&Itemid=' . $wbgItemid) . '</div>';
            }
        }
        // Nothing Displayed? Post Error...
        if (!$countCat && !$countImg) {
            echo '<h2 class="alert_msg">' . $WBG_LANG->_('ALERT_NODISPLAY') . '</h1>';
        }
    }
Пример #4
0
 function upload_save($redirect = true)
 {
     global $my, $mainframe, $database, $option, $priTask, $subTask;
     global $WBG_CONFIG, $wbGalleryDB_cat, $wbGallery_common, $wbGallery_eng;
     // Prepare Runtime
     $tempDir = null;
     $known_images = array('image/pjpeg', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif');
     $time = time();
     // Importing
     $importFolder = mosGetParam($_REQUEST, 'folder', '');
     if ($importFolder && !file_exists($importFolder)) {
         echo "<script> alert('Import Folder Does Not Exist'); document.location.href='index2.php?option=" . $option . "&task=image.upload'; </script>\n";
         exit;
     }
     // Default Values
     $defRow = new wbGalleryDB_img($database);
     $defRow->bind($_POST);
     // Debug
     echo "Image Processing Start: " . $time . '<br/>';
     // ==============================v========================================
     // Single File Upload
     if (!empty($_FILES['img']['tmp_name'])) {
         // Debug
         echo "Single File Detected <br/>";
         if (!in_array($_FILES['img']['type'], $known_images)) {
             echo "<script> alert('Image type: " . $_FILES['img']['type'] . " is an unknown type'); document.location.href='index2.php?option=" . $option . "&task=image.upload'; </script>\n";
             exit;
         }
         $wbGallery_eng->add($_FILES['img']['tmp_name'], $_FILES['img']['name'], $_FILES['img']['type'], $defRow);
         if ($redirect) {
             mosRedirect('index2.php?option=' . $option . '&task=image.upload', 'Image Saved');
         }
     }
     // ==============================v========================================
     // Zip File Upload
     if (!empty($_FILES['zip']['tmp_name'])) {
         //zip file upload
         // Debug
         echo "Compressed File Uploaded <br/>";
         // Create / Define Temporary Folder for Unzipped Files
         if (!mkdir($mainframe->getCfg('absolute_path') . '/media/' . $time)) {
             if (!mkdir('/tmp/' . $time)) {
                 echo "<script> alert('Unable to Create Temp Directory'); history.back(); </script>\n";
                 exit;
             } else {
                 $tempDir = '/tmp/' . $time;
             }
         } else {
             $tempDir = $mainframe->getCfg('absolute_path') . '/media/' . $time;
         }
         // Uncompress ZIP or TAR.GZ
         if (preg_match('/zip$/i', $_FILES['zip']['name'])) {
             // Load ZIP functions
             require_once $mainframe->getCfg('absolute_path') . '/administrator/includes/pcl/pclzip.lib.php';
             require_once $mainframe->getCfg('absolute_path') . '/administrator/includes/pcl/pclerror.lib.php';
             $zipfile = new PclZip($_FILES['zip']['tmp_name']);
             if (substr(PHP_OS, 0, 3) == 'WIN') {
                 define('OS_WINDOWS', 1);
             } else {
                 define('OS_WINDOWS', 0);
             }
             $ret = $zipfile->extract(PCLZIP_OPT_PATH, $tempDir);
             if ($ret == 0) {
                 $wbGallery_common->remove_dir($tempDir);
                 echo "<script> alert('ZIP Extraction Error: " . $zipfile->errorName(true) . "'); history.back(); </script>\n";
                 exit;
             }
         } elseif (preg_match('/tar.gz$/i', $_FILES['zip']['name'])) {
             // Load TAR functions
             require_once $mainframe->getCfg('absolute_path') . '/includes/Archive/Tar.php';
             $archive = new Archive_Tar($_FILES['zip']['tmp_name']);
             $archive->setErrorHandling(PEAR_ERROR_PRINT);
             if (!$archive->extractModify($tempDir, '')) {
                 $wbGallery_common->remove_dir($tempDir);
                 echo "<script> alert('TAR Extraction Error'); history.back(); </script>\n";
                 exit;
             }
         } else {
             // Unknown File...
             $wbGallery_common->remove_dir($tempDir);
             echo "<script> alert('Unknown File Format - Must be .ZIP or .TAR.GZ'); history.back(); </script>\n";
             exit;
         }
     }
     // Zip File Upload
     // ==============================v========================================
     // Process Files from Folder
     if ($tempDir || $importFolder) {
         $processDirs = array();
         $files_added = 0;
         $files_skipped = 0;
         if ($tempDir) {
             $processDirs[] = array('path' => $tempDir, 'remove' => 1);
         }
         if ($importFolder) {
             $processDirs[] = array('path' => $importFolder, 'remove' => 0);
         }
         if (count($processDirs)) {
             foreach ($processDirs as $procDir) {
                 // Read Files from Temp Folder
                 $regImg = array();
                 foreach ($known_images as $k) {
                     $regImg[] = preg_replace('/^.*\\//', '', $k) . '$';
                 }
                 $regStr = '/' . join('|', $regImg) . '/';
                 $files = $wbGallery_common->find_files($procDir['path'], $regStr);
                 unset($regImg);
                 unset($regStr);
                 // Debug
                 echo "Unzipped " . count($files) . " for processing <br/>";
                 if (count($files)) {
                     foreach ($files as $file) {
                         $filePath = $file['path'] . '/' . $file['name'];
                         $res = getimagesize($filePath);
                         $fileType = $res['mime'];
                         if (in_array($fileType, $known_images)) {
                             if ($wbGallery_eng->add($filePath, $file['name'], $fileType, $defRow)) {
                                 $files_added++;
                             } else {
                                 $files_skipped++;
                             }
                         } else {
                             $files_skipped++;
                         }
                     }
                 }
                 if ($procDir['remove']) {
                     $wbGallery_common->remove_dir($procDir['path']);
                 }
             }
             // foreach processDirs
         }
         // if processDirs
         if ($redirect) {
             if (!$files_added && !$files_skipped) {
                 mosRedirect('index2.php?option=' . $option . '&task=image.upload', 'Error: No Files were Processed or Error Finding Files');
             } else {
                 mosRedirect('index2.php?option=' . $option . '&task=image.upload', $files_added . ' images added - ' . $files_skipped . ' files skipped');
             }
         } else {
             if (!$files_added && !$files_skipped) {
                 return false;
             } else {
                 return true;
             }
         }
     }
     mosRedirect('index2.php?option=' . $option . '&task=image.upload', 'Please Specify Images for Processing');
     return false;
 }