当前位置: 首页>>代码示例>>PHP>>正文


PHP osc_max_images_per_item函数代码示例

本文整理汇总了PHP中osc_max_images_per_item函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_max_images_per_item函数的具体用法?PHP osc_max_images_per_item怎么用?PHP osc_max_images_per_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了osc_max_images_per_item函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uploadItemResources

        public function uploadItemResources($aResources,$itemId)
        {
            if($aResources != '') {
                $itemResourceManager = ItemResource::newInstance();
                $folder = osc_uploads_path().(floor($itemId/100))."/";

                $numImagesItems = osc_max_images_per_item();
                $numImages = $itemResourceManager->countResources($itemId);
                foreach ($aResources['error'] as $key => $error) {
                    if($numImagesItems==0 || ($numImagesItems>0 && $numImages<$numImagesItems)) {
                        if ($error == UPLOAD_ERR_OK) {
                            $tmpName = $aResources['tmp_name'][$key];
                            $imgres = ImageResizer::fromFile($tmpName);
                            $extension = osc_apply_filter('upload_image_extension', $imgres->getExt());
                            $mime = osc_apply_filter('upload_image_mime', $imgres->getMime());

                            // Create normal size
                            $normal_path = $path = $tmpName."_normal";
                            $size = explode('x', osc_normal_dimensions());
                            $img = ImageResizer::fromFile($tmpName)->autoRotate()->resizeTo($size[0], $size[1]);
                            if( osc_is_watermark_text() ) {
                                $img->doWatermarkText(osc_watermark_text(), osc_watermark_text_color());
                            } else if ( osc_is_watermark_image() ){
                                $img->doWatermarkImage();
                            }
                            $img->saveToFile($path, $extension);

                            // Create preview
                            $path = $tmpName."_preview";
                            $size = explode('x', osc_preview_dimensions());
                            ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);

                            // Create thumbnail
                            $path = $tmpName."_thumbnail";
                            $size = explode('x', osc_thumbnail_dimensions());
                            ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);

                            $numImages++;

                            $itemResourceManager->insert(array(
                                'fk_i_item_id' => $itemId
                            ));
                            $resourceId = $itemResourceManager->dao->insertedId();

                            if(!is_dir($folder)) {
                                if (!@mkdir($folder, 0755, true)) {
                                    return 3; // PATH CAN NOT BE CREATED
                                }
                            }
                            osc_copy($tmpName.'_normal', $folder.$resourceId.'.'.$extension);
                            osc_copy($tmpName.'_preview', $folder.$resourceId.'_preview.'.$extension);
                            osc_copy($tmpName.'_thumbnail', $folder.$resourceId.'_thumbnail.'.$extension);
                            if( osc_keep_original_image() ) {
                                $path = $folder.$resourceId.'_original.'.$extension;
                                osc_copy($tmpName, $path);
                            }
                            @unlink($tmpName."_normal");
                            @unlink($tmpName."_preview");
                            @unlink($tmpName."_thumbnail");
                            @unlink($tmpName);

                            $s_path = str_replace(osc_base_path(), '', $folder);
                            $itemResourceManager->update(
                                array(
                                    's_path'          => $s_path
                                    ,'s_name'         => osc_genRandomPassword()
                                    ,'s_extension'    => $extension
                                    ,'s_content_type' => $mime
                                )
                                ,array(
                                    'pk_i_id'       => $resourceId
                                    ,'fk_i_item_id' => $itemId
                                )
                            );
                            osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
                        }
                    }
                }
                unset($itemResourceManager);
            }
            return 0; // NO PROBLEMS
        }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:82,代码来源:ItemActions.php

示例2: uploadItemResources

 public function uploadItemResources($aResources, $itemId)
 {
     if ($aResources != '') {
         $wat = new Watermark();
         $itemResourceManager = ItemResource::newInstance();
         $numImagesItems = osc_max_images_per_item();
         $numImages = $itemResourceManager->countResources($itemId);
         foreach ($aResources['error'] as $key => $error) {
             if ($numImagesItems == 0 || $numImagesItems > 0 && $numImages < $numImagesItems) {
                 if ($error == UPLOAD_ERR_OK) {
                     $numImages++;
                     $tmpName = $aResources['tmp_name'][$key];
                     $itemResourceManager->insert(array('fk_i_item_id' => $itemId));
                     $resourceId = $itemResourceManager->dao->insertedId();
                     // Create normal size
                     $normal_path = $path = osc_content_path() . 'uploads/' . $resourceId . '.jpg';
                     $size = explode('x', osc_normal_dimensions());
                     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
                     if (osc_is_watermark_text()) {
                         $wat->doWatermarkText($path, osc_watermark_text_color(), osc_watermark_text(), 'image/jpeg');
                     } elseif (osc_is_watermark_image()) {
                         $wat->doWatermarkImage($path, 'image/jpeg');
                     }
                     // Create preview
                     $path = osc_content_path() . 'uploads/' . $resourceId . '_preview.jpg';
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // Create thumbnail
                     $path = osc_content_path() . 'uploads/' . $resourceId . '_thumbnail.jpg';
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                     if (osc_keep_original_image()) {
                         $path = osc_content_path() . 'uploads/' . $resourceId . '_original.jpg';
                         move_uploaded_file($tmpName, $path);
                     }
                     $s_path = 'oc-content/uploads/';
                     $resourceType = 'image/jpeg';
                     $itemResourceManager->update(array('s_path' => $s_path, 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => $resourceType), array('pk_i_id' => $resourceId, 'fk_i_item_id' => $itemId));
                     osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
                 }
             }
         }
         unset($itemResourceManager);
     }
 }
开发者ID:ranjithinnergys,项目名称:OSClass,代码行数:45,代码来源:ItemActions.php

示例3: photos_javascript

    public static function photos_javascript()
    {
        ?>
<script type="text/javascript">
    var photoIndex = 0;
    function gebi(id) { return document.getElementById(id); }
    function ce(name) { return document.createElement(name); }
    function re(id) {
        var e = gebi(id);
        e.parentNode.removeChild(e);
    }
    function addNewPhoto() {
        var max = <?php 
        echo osc_max_images_per_item();
        ?>
;
        var num_img = $('input[name="photos[]"]').size() + $("a.delete").size();
        if((max!=0 && num_img<max) || max==0) {
            var id = 'p-' + photoIndex++;

            var i = ce('input');
            i.setAttribute('type', 'file');
            i.setAttribute('name', 'photos[]');

            var a = ce('a');
            a.style.fontSize = 'x-small';
            a.style.paddingLeft = '10px';
            a.setAttribute('href', '#');
            a.setAttribute('divid', id);
            a.onclick = function() { re(this.getAttribute('divid')); return false; }
            a.appendChild(document.createTextNode('<?php 
        _e('Remove');
        ?>
'));

            var d = ce('div');
            d.setAttribute('id', id);
            d.setAttribute('style','padding: 4px 0;')

            d.appendChild(i);
            d.appendChild(a);

            gebi('photos').appendChild(d);

        } else {
            alert('<?php 
        _e('Sorry, you have reached the maximum number of images per ad');
        ?>
');
        }
    }
    // Listener: automatically add new file field when the visible ones are full.
    setInterval("add_file_field()", 250);
    /**
     * Timed: if there are no empty file fields, add new file field.
     */
    function add_file_field() {
        var count = 0;
        $('input[name="photos[]"]').each(function(index) {
            if ( $(this).val() == '' ) {
                count++;
            }
        });
        var max = <?php 
        echo osc_max_images_per_item();
        ?>
;
        var num_img = $('input[name="photos[]"]').size() + $("a.delete").size();
        if (count == 0 && (max==0 || (max!=0 && num_img<max))) {
            addNewPhoto();
        }
    }
</script>
<?php 
    }
开发者ID:randomecho,项目名称:OSClass,代码行数:75,代码来源:Item.form.class.php

示例4: osc_images_enabled_at_items

?>
                                    </label>
                                    <div class="separate-top-medium">
                                        <label>
                                            <input type="checkbox" <?php 
echo osc_images_enabled_at_items() ? 'checked="checked"' : '';
?>
 name="enableField#images@items" value="1" />
                                            <?php 
_e('Attach images');
?>
                                        </label>
                                    </div>
                                    <div class="separate-top-medium">
                                        <?php 
printf(__('Attach %s images per listing'), '<input type="text" class="input-small" name="numImages@items" value="' . osc_max_images_per_item() . '" />');
?>
                                        <div class="help-box"><?php 
_e('If the value is zero, it means an unlimited number of images is allowed');
?>
</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-actions">
                            <input type="submit" id="save_changes" value="<?php 
echo osc_esc_html(__('Save changes'));
?>
" class="btn btn-submit" />
                        </div>
开发者ID:mylastof,项目名称:os-class,代码行数:31,代码来源:settings.php

示例5: _e

        <meta name="googlebot" content="noindex, nofollow" />
        <script type="text/javascript">
            twitter_theme.text_select_subcategory = "<?php 
_e('Select a subcategory...', 'twitter_bootstrap');
?>
" ;
            twitter_theme.category_selected_id    = "<?php 
echo item_selected_category_id();
?>
" ;
            twitter_theme.subcategory_selected_id = "<?php 
echo item_selected_subcategory_id();
?>
" ;
            twitter_theme.max_number_photos       = <?php 
echo osc_max_images_per_item();
?>
 ;
            twitter_theme.photo_remove_text       = "<?php 
_e('Remove', 'twitter_bootstrap');
?>
" ;
            twitter_theme.max_images_fields_txt   = "<?php 
_e('Sorry, you have reached the maximum number of images per ad', 'twitter_bootstrap');
?>
" ;
            twitter_theme.country_select_id       = "<?php 
echo get_country_id(osc_item() != null ? osc_item() : array());
?>
" ;
            twitter_theme.region_select_id        = "<?php 
开发者ID:nsswaga,项目名称:OSClass,代码行数:31,代码来源:item-post.php

示例6: _e

?>
                            </div>
                            <?php 
if (osc_images_enabled_at_items()) {
    ?>
                            <div class="box photos">
                                <h2><?php 
    _e('Photos', 'modern');
    ?>
</h2>
                                <?php 
    ItemForm::photos();
    ?>
                                <div id="photos">
                                    <?php 
    if (osc_max_images_per_item() == 0 || osc_max_images_per_item() != 0 && osc_count_item_resources() < osc_max_images_per_item()) {
        ?>
                                    <div class="row">
                                        <input type="file" name="photos[]" />
                                    </div>
                                    <?php 
    }
    ?>
                                </div>
                                <a href="#" onclick="addNewPhoto(); return false;"><?php 
    _e('Add new photo', 'modern');
    ?>
</a>
                            </div>
                            <?php 
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:31,代码来源:item-edit.php

示例7: ajax_photos


//.........这里部分代码省略.........
                _e('Delete');
                ?>
</a>
                            <div class="ajax_preview_img"><img src="<?php 
                echo osc_base_url();
                ?>
oc-content/uploads/temp/<?php 
                echo $img;
                ?>
" alt="<?php 
                echo $img;
                ?>
"></div>
                            <input type="hidden" name="ajax_photos[]" value="<?php 
                echo $img;
                ?>
">
                        </li>
                    <?php 
            }
            ?>
                </ul>
            <?php 
        }
        ?>
            <div style="clear:both;"></div>
            <?php 
        $aExt = explode(',', osc_allowed_extension());
        foreach ($aExt as $key => $value) {
            $aExt[$key] = "'" . $value . "'";
        }
        $allowedExtensions = join(',', $aExt);
        $maxSize = (int) osc_max_size_kb() * 1024;
        $maxImages = (int) osc_max_images_per_item();
        ?>

            <script>
                $(document).ready(function() {

                    $('.qq-upload-delete').on('click', function(evt) {
                        evt.preventDefault();
                        var parent = $(this).parent()
                        var result = confirm('<?php 
        echo osc_esc_js(__("This action can't be undone. Are you sure you want to continue?"));
        ?>
');
                        var urlrequest = '';
                        if($(this).attr('ajaxfile')!=undefined) {
                            urlrequest = 'ajax_photo='+$(this).attr('ajaxfile');
                        } else {
                            urlrequest = 'id='+$(this).attr('photoid')+'&item='+$(this).attr('itemid')+'&code='+$(this).attr('photoname')+'&secret='+$(this).attr('photosecret');
                        }
                        if(result) {
                            $.ajax({
                                type: "POST",
                                url: '<?php 
        echo osc_base_url(true);
        ?>
?page=ajax&action=delete_image&'+urlrequest,
                                dataType: 'json',
                                success: function(data){
                                    parent.remove();
                                }
                            });
                        }
                    });
开发者ID:mylastof,项目名称:os-class,代码行数:67,代码来源:Item.form.class.php

示例8: osc_images_enabled_at_items

                                    <td></td>
                                    <td>
                                        <input type="checkbox" <?php 
echo osc_images_enabled_at_items() ? 'checked="true"' : '';
?>
 name="enableField#images@items" value="1" />
                                        <?php 
_e('Attach images');
?>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td class="additional-options">
                                        <?php 
printf(__('Attach %s images per item'), '<input type="text" class="micro" name="numImages@items" value="' . osc_max_images_per_item() . '" />');
?>
                                        <span class="help-box"><?php 
_e('If the value is zero, it means unlimited number of images');
?>
</span>
                                    </td>
                                </tr>
                                <!-- /optional fields -->
                                <tr class="separate">
                                    <td></td>
                                    <td>
                                        <input type="submit" value="<?php 
echo osc_esc_html(__('Save changes'));
?>
" />
开发者ID:randomecho,项目名称:OSClass,代码行数:31,代码来源:settings.php

示例9: doModel


//.........这里部分代码省略.........
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_' . $hook);
                     break;
             }
             break;
         case 'custom':
             // Execute via AJAX custom file
             if (Params::existParam('route')) {
                 $routes = Rewrite::newInstance()->getRoutes();
                 $rid = Params::getParam('route');
                 $file = '../';
                 if (isset($routes[$rid]) && isset($routes[$rid]['file'])) {
                     $file = $routes[$rid]['file'];
                 }
             } else {
                 // DEPRECATED: Disclosed path in URL is deprecated, use routes instead
                 // This will be REMOVED in 3.4
                 $file = Params::getParam('ajaxfile');
             }
             if ($file == '') {
                 echo json_encode(array('error' => 'no action defined'));
                 break;
             }
             // valid file?
             if (strpos($file, '../') !== false || strpos($file, '..\\') !== false || stripos($file, '/admin/') !== false) {
                 //If the file is inside an "admin" folder, it should NOT be opened in frontend
                 echo json_encode(array('error' => 'no valid ajaxFile'));
                 break;
             }
             if (!file_exists(osc_plugins_path() . $file)) {
                 echo json_encode(array('error' => "ajaxFile doesn't exist"));
                 break;
             }
             require_once osc_plugins_path() . $file;
             break;
         case 'check_username_availability':
             $username = osc_sanitize_username(Params::getParam('s_username'));
             if (!osc_is_username_blacklisted($username)) {
                 $user = User::newInstance()->findByUsername($username);
                 if (isset($user['s_username'])) {
                     echo json_encode(array('exists' => 1, 's_username' => $username));
                 } else {
                     echo json_encode(array('exists' => 0, 's_username' => $username));
                 }
             } else {
                 echo json_encode(array('exists' => 1, 's_username' => $username));
             }
             break;
         case 'ajax_upload':
             // Include the uploader class
             require_once LIB_PATH . "AjaxUploader.php";
             $uploader = new AjaxUploader();
             $original = pathinfo($uploader->getOriginalName());
             $filename = uniqid("qqfile_") . "." . $original['extension'];
             $result = $uploader->handleUpload(osc_content_path() . 'uploads/temp/' . $filename);
             $result['uploadName'] = $filename;
             echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
             break;
         case 'ajax_validate':
             $id = Params::getParam('id');
             if (!is_numeric($id)) {
                 echo json_encode(array('success' => false));
                 die;
             }
             $secret = Params::getParam('secret');
             $item = Item::newInstance()->findByPrimaryKey($id);
             if ($item['s_secret'] != $secret) {
                 echo json_encode(array('success' => false));
                 die;
             }
             $nResources = ItemResource::newInstance()->countResources($id);
             $result = array('success' => $nResources < osc_max_images_per_item(), 'count' => $nResources);
             echo json_encode($result);
             break;
         case 'delete_ajax_upload':
             $files = Session::newInstance()->_get('ajax_files');
             $success = false;
             $filename = '';
             if (isset($files[Params::getParam('qquuid')]) && $files[Params::getParam('qquuid')] != '') {
                 $filename = $files[Params::getParam('qquuid')];
                 unset($files[Params::getParam('qquuid')]);
                 Session::newInstance()->_set('ajax_files', $files);
                 $success = @unlink(osc_content_path() . 'uploads/temp/' . $filename);
             }
             echo json_encode(array('success' => $success, 'uploadName' => $filename));
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
     // clear all keep variables into session
     Session::newInstance()->_dropKeepForm();
     Session::newInstance()->_clearVariables();
 }
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:ajax.php

示例10: uploadItemResources

 public function uploadItemResources($aResources, $itemId)
 {
     if ($aResources != '') {
         $wat = new Watermark();
         $itemResourceManager = ItemResource::newInstance();
         $numImagesItems = osc_max_images_per_item();
         $numImages = $itemResourceManager->countResources($itemId);
         foreach ($aResources['error'] as $key => $error) {
             if ($numImagesItems == 0 || $numImagesItems > 0 && $numImages < $numImagesItems) {
                 if ($error == UPLOAD_ERR_OK) {
                     $freedisk = 4 * osc_max_size_kb() * 1024;
                     if (function_exists('disk_free_space')) {
                         $freedisk = @disk_free_space(osc_content_path() . 'uploads/');
                     }
                     if ($freedisk != false) {
                         $tmpName = $aResources['tmp_name'][$key];
                         $total_size = 0;
                         // Create normal size
                         $normal_path = $path = $tmpName . "_normal";
                         $size = explode('x', osc_normal_dimensions());
                         ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
                         if (osc_is_watermark_text()) {
                             $wat->doWatermarkText($path, osc_watermark_text_color(), osc_watermark_text(), 'image/jpeg');
                         } elseif (osc_is_watermark_image()) {
                             $wat->doWatermarkImage($path, 'image/jpeg');
                         }
                         $sizeTmp = filesize($path);
                         $total_size += $sizeTmp !== false ? $sizeTmp : osc_max_size_kb() * 1024;
                         // Create preview
                         $path = $tmpName . "_preview";
                         $size = explode('x', osc_preview_dimensions());
                         ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                         $sizeTmp = filesize($path);
                         $total_size += $sizeTmp !== false ? $sizeTmp : osc_max_size_kb() * 1024;
                         // Create thumbnail
                         $path = $tmpName . "_thumbnail";
                         $size = explode('x', osc_thumbnail_dimensions());
                         ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                         $sizeTmp = filesize($path);
                         $total_size += $sizeTmp !== false ? $sizeTmp : osc_max_size_kb() * 1024;
                         if (osc_keep_original_image()) {
                             $sizeTmp = filesize($tmpName);
                             $total_size += $sizeTmp !== false ? $sizeTmp : osc_max_size_kb() * 1024;
                         }
                         if ($total_size <= $freedisk) {
                             $numImages++;
                             $itemResourceManager->insert(array('fk_i_item_id' => $itemId));
                             $resourceId = $itemResourceManager->dao->insertedId();
                             osc_copy($tmpName . '_normal', osc_content_path() . 'uploads/' . $resourceId . '.jpg');
                             osc_copy($tmpName . '_preview', osc_content_path() . 'uploads/' . $resourceId . '_preview.jpg');
                             osc_copy($tmpName . '_thumbnail', osc_content_path() . 'uploads/' . $resourceId . '_thumbnail.jpg');
                             if (osc_keep_original_image()) {
                                 $path = osc_content_path() . 'uploads/' . $resourceId . '_original.jpg';
                                 move_uploaded_file($tmpName, $path);
                             }
                             $s_path = 'oc-content/uploads/';
                             $resourceType = 'image/jpeg';
                             $itemResourceManager->update(array('s_path' => $s_path, 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => $resourceType), array('pk_i_id' => $resourceId, 'fk_i_item_id' => $itemId));
                             osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
                         } else {
                             return 2;
                             // IMAGES ARE BIGGER THAN SPACE
                         }
                     } else {
                         return 1;
                         // NO SPACE LEFT
                     }
                 }
             }
         }
         unset($itemResourceManager);
     }
     return 0;
     // NO PROBLEMS
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:75,代码来源:ItemActions.php


注:本文中的osc_max_images_per_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。