示例#1
0
 private function image_ids_to_urls($image_ids)
 {
     if ($image_ids == null || count($image_ids) < 1) {
         return $image_ids;
     }
     $obj_image = app::get('image')->model('image');
     $resource_host_url = kernel::get_resource_host_url();
     $image_from_db = $obj_image->getList('image_id,storage,l_url,m_url,s_url', array('image_id|in' => $image_ids));
     foreach ($image_from_db as $imageRow) {
         $image_id = $imageRow['image_id'];
         $fmt_image[$image_id]['s_url'] = $imageRow['s_url'] ? $imageRow['s_url'] : $imageRow['url'];
         if ($fmt_image[$image_id]['s_url'] && !strpos($fmt_image[$image_id]['s_url'], '://')) {
             $fmt_image[$image_id]['s_url'] = $resource_host_url . '/' . $fmt_image[$image_id]['s_url'];
         }
         $fmt_image[$image_id]['m_url'] = $imageRow['m_url'] ? $imageRow['m_url'] : $imageRow['url'];
         if ($fmt_image[$image_id]['m_url'] && !strpos($fmt_image[$image_id]['m_url'], '://')) {
             $fmt_image[$image_id]['m_url'] = $resource_host_url . '/' . $fmt_image[$image_id]['m_url'];
         }
         $fmt_image[$image_id]['l_url'] = $imageRow['l_url'] ? $imageRow['l_url'] : $imageRow['url'];
         if ($fmt_image[$image_id]['l_url'] && !strpos($fmt_image[$image_id]['l_url'], '://')) {
             $fmt_image[$image_id]['l_url'] = $resource_host_url . '/' . $fmt_image[$image_id]['l_url'];
         }
     }
     return $fmt_image;
 }
示例#2
0
文件: editor.php 项目: 453111208/bbc
    function _img_list()
    {
        $img = $this->app->model('image');
        $html = '';
        foreach ($img->getList('url,s_url,l_url,m_url,image_id,width,height,storage', $filter, 0, 20) as $item) {
            $url = '';
            if ($item['storage'] == 'filesystem') {
                $url = kernel::get_resource_host_url();
            }
            $url = $url . ($item['s_url'] ? $item['s_url'] : ($item['m_url'] ? $item['m_url'] : ($item['l_url'] ? $item['l_url'] : $item['url'])));
            if (max($item['width'], $item['height']) > 96) {
                $tag = ($item['width'] > $item['height'] ? 'width=' : 'height=') . '"96"';
            } else {
                $tag = '';
            }
            $html .= <<<EOF
            <div image_id="{$image_id}" style="text-align:center;vertical-align: middle;float:left;width:96px;height:96px;border:3px solid #ddd;margin:3px">
            <img {$tag} src="{$url}" />
            </div>
EOF;
        }
        $pager = view::ui()->pager(array('current' => 2, 'total' => 200, 'link' => 'javascript:' . $this->var_name . '.page(%d)', 'nobutton' => false));
        echo $html . $pager;
    }
示例#3
0
 private function _select_spec($paramsSpec)
 {
     if ($this->pagedata['goods_spec_images']) {
         $specGoodsImagesArr = app::get('image')->model('image')->getList('image_id,s_url,url', array('image_id' => $this->pagedata['goods_spec_images']));
         $resource_host_url = kernel::get_resource_host_url();
         foreach ($specGoodsImagesArr as $row) {
             $row['s_url'] = $row['s_url'] ? $row['s_url'] : $row['url'];
             if ($row['s_url'] && !strpos($row['s_url'], '://')) {
                 $row['s_url'] = $resource_host_url . '/' . $row['s_url'];
             }
             $goodsImages[$row['image_id']] = $row['s_url'];
         }
     }
     foreach ((array) $paramsSpec as $specId => $selectSpecRow) {
         $selectionSpec[$specId] = $selectSpecRow;
         //当前规格选中数量
         $selectCount[$specId] = count($selectSpecRow['option']);
         //选中的规格
         foreach ($selectSpecRow['option'] as $privateSpecValueId => $option) {
             $selectSpecValueId[] = $option['spec_value_id'];
             unset($selectionSpec[$specId]['option'][$privateSpecValueId]);
             if ($selectSpecRow['spec_type'] == 'image') {
                 $option['spec_image_url'] = $option['spec_image'] ? base_storager::image_path($option['spec_image']) : $this->default_spec_image_url;
                 $option['spec_image'] = $option['spec_image'] ? $option['spec_image'] : $this->default_spec_image;
             }
             $selectionSpec[$specId]['option'][$option['spec_value_id']] = $option;
             //规格关联商品图片
             $spec_goods_images = $option['spec_goods_images'] ? explode(',', $option['spec_goods_images']) : array();
             $specGoodsImages = array();
             foreach ((array) $spec_goods_images as $key => $imageId) {
                 if ($goodsImages[$imageId]) {
                     $specGoodsImages[$key]['image_id'] = $imageId;
                     $specGoodsImages[$key]['image_url'] = $goodsImages[$imageId];
                 }
             }
             $selectionSpec[$specId]['option'][$option['spec_value_id']]['spec_goods_images'] = $specGoodsImages;
         }
     }
     return array('selectionSpec' => $selectionSpec, 'selectCount' => $selectCount, 'selectSpecValueId' => $selectSpecValueId);
 }
示例#4
0
文件: kernel.php 项目: 453111208/bbc
 static function get_app_statics_host_url($local_flag = false)
 {
     //return kernel::get_resource_host_url($local_flag).substr(PUBLIC_DIR, strlen(ROOT_DIR)).'/app';
     return kernel::get_resource_host_url($local_flag) . '/app';
 }
示例#5
0
 static function image_storage($content)
 {
     $blocks = preg_split('/%IMG_([0-9a-f]{32})_S_([a-z0-9\\:]*)_IMG%/', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
     $c = count($blocks);
     $imglib = array();
     $img = array();
     for ($i = 0; $i < $c; $i++) {
         switch ($i % 3) {
             case 1:
                 $image_id = $blocks[$i];
                 $img[$image_id][$i] = array($blocks[$i + 1]);
                 $blocks[$i] =& $img[$image_id][$i][0];
                 break;
             case 2:
                 $img[$image_id][$i - 1][1] = $blocks[$i];
                 $blocks[$i] = '';
                 break;
         }
     }
     if ($img) {
         $db = kernel::database();
         foreach ($db->select($s = 'select image_id,url,s_url,m_url,l_url,last_modified,width,height from sdb_image_image where image_id in(\'' . implode("','", array_keys($img)) . '\')') as $r) {
             $imglib[$r['image_id']] = $r;
         }
         foreach ($img as $image_id => $sizes) {
             foreach ($sizes as $i => $item) {
                 switch ($item[0][0]) {
                     case 's':
                         $url = $imglib[$image_id]['s_url'] ? $imglib[$image_id]['s_url'] : $imglib[$image_id]['url'];
                         break;
                     case 'p':
                         $url = $imglib[$image_id]['s_url'] ? $imglib[$image_id]['s_url'] : $imglib[$image_id]['url'];
                         if (defined('ROOT_PZFRESH')) {
                             $url = ROOT_PZFRESH . '/' . $url;
                         }
                         break;
                     case 'm':
                         $url = $imglib[$image_id]['m_url'] ? $imglib[$image_id]['m_url'] : $imglib[$image_id]['url'];
                         break;
                     case 'l':
                         $url = $imglib[$image_id]['l_url'] ? $imglib[$image_id]['l_url'] : $imglib[$image_id]['url'];
                         break;
                     default:
                         $url = $imglib[$image_id]['url'];
                         break;
                 }
                 if ($url && !strpos($url, '://')) {
                     $resource_host_url = kernel::get_resource_host_url();
                     $url = $resource_host_url . '/' . $url;
                 }
                 $code = $r['width'] > $r['height'] ? 'w' : 'h';
                 $img[$image_id][$i][0] = $url ? $url . '?' . $imglib[$image_id]['last_modified'] . '#' . $code : '';
             }
         }
     }
     return implode('', $blocks);
 }
示例#6
0
 /**
  * 根据商品ID,获取到对应的默认图片
  * @params $imageIds array | string 图片ID
  * @params $gids array | string 商品ID
  */
 private function _get_gids_image($imageIds = false, $gids)
 {
     if (!$imageIds) {
         $goodData = app::get('b2c')->model('goods')->getList('goods_id,image_default_id', array('goods_id' => $gids));
         foreach ((array) $goodData as $goodsRow) {
             $gid = $goodsRow['goods_id'];
             $imageIds[$gid] = $goodsRow['image_default_id'];
         }
     }
     $imageData = app::get('image')->model('image')->getList('url,image_id,s_url,m_url,l_url,last_modified', array('image_id' => $imageIds));
     $resource_host_url = kernel::get_resource_host_url();
     foreach ((array) $imageData as $imageRow) {
         $image_id = $imageRow['image_id'];
         $imageUrl[$image_id]['s_url'] = $imageRow['s_url'] ? $imageRow['s_url'] : $imageRow['url'];
         if ($imageUrl[$image_id]['s_url'] && !strpos($imageUrl[$image_id]['s_url'], '://')) {
             $imageUrl[$image_id]['s_url'] = $resource_host_url . '/' . $imageUrl[$image_id]['s_url'];
         }
         $imageUrl[$image_id]['m_url'] = $imageRow['m_url'] ? $imageRow['m_url'] : $imageRow['url'];
         if ($imageUrl[$image_id]['m_url'] && !strpos($imageUrl[$image_id]['m_url'], '://')) {
             $imageUrl[$image_id]['m_url'] = $resource_host_url . '/' . $imageUrl[$image_id]['m_url'];
         }
         $imageUrl[$image_id]['l_url'] = $imageRow['l_url'] ? $imageRow['l_url'] : $imageRow['url'];
         if ($imageUrl[$image_id]['l_url'] && !strpos($imageUrl[$image_id]['l_url'], '://')) {
             $imageUrl[$image_id]['l_url'] = $resource_host_url . '/' . $imageUrl[$image_id]['l_url'];
         }
     }
     foreach ((array) $imageIds as $gid => $image_default_id) {
         $return[$gid] = $imageUrl[$image_default_id];
     }
     return $return;
 }