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


PHP osc_thumbnail_dimensions函数代码示例

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


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

示例1: 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

示例2: 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

示例3: doModel

 function doModel()
 {
     parent::doModel();
     switch ($this->action) {
         case 'import':
             // calling import view
             $this->doView('tools/import.php');
             break;
         case 'import_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action cannot be done because it is a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=import');
             }
             // calling
             $sql = Params::getFiles('sql');
             if (isset($sql['size']) && $sql['size'] != 0) {
                 $content_file = file_get_contents($sql['tmp_name']);
                 $conn = DBConnectionClass::newInstance();
                 $c_db = $conn->getOsclassDb();
                 $comm = new DBCommandClass($c_db);
                 if ($comm->importSQL($content_file)) {
                     osc_add_flash_ok_message(_m('Import complete'), 'admin');
                 } else {
                     osc_add_flash_error_message(_m('There was a problem importing data to the database'), 'admin');
                 }
             } else {
                 osc_add_flash_warning_message(_m('No file was uploaded'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=import');
             break;
         case 'images':
             // calling images view
             $this->doView('tools/images.php');
             break;
         case 'images_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action cannot be done because it is a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=images');
             }
             $preferences = Preference::newInstance()->toArray();
             $wat = new Watermark();
             $aResources = ItemResource::newInstance()->getAllResources();
             foreach ($aResources as $resource) {
                 osc_run_hook('regenerate_image', $resource);
                 $path = osc_content_path() . 'uploads/';
                 // comprobar que no haya original
                 $img_original = $path . $resource['pk_i_id'] . "_original*";
                 $aImages = glob($img_original);
                 // there is original image
                 if (count($aImages) == 1) {
                     $image_tmp = $aImages[0];
                 } else {
                     $img_normal = $path . $resource['pk_i_id'] . ".*";
                     $aImages = glob($img_normal);
                     if (count($aImages) == 1) {
                         $image_tmp = $aImages[0];
                     } else {
                         $img_thumbnail = $path . $resource['pk_i_id'] . "_thumbnail*";
                         $aImages = glob($img_thumbnail);
                         $image_tmp = $aImages[0];
                     }
                 }
                 // extension
                 preg_match('/\\.(.*)$/', $image_tmp, $matches);
                 if (isset($matches[1])) {
                     $extension = $matches[1];
                     // Create normal size
                     $path_normal = $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '.jpg';
                     $size = explode('x', osc_normal_dimensions());
                     ImageResizer::fromFile($image_tmp)->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/' . $resource['pk_i_id'] . '_preview.jpg';
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // Create thumbnail
                     $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '_thumbnail.jpg';
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // update resource info
                     ItemResource::newInstance()->update(array('s_path' => 'oc-content/uploads/', 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => 'image/jpeg'), array('pk_i_id' => $resource['pk_i_id']));
                     osc_run_hook('regenerated_image', ItemResource::newInstance()->findByPrimaryKey($resource['pk_i_id']));
                     // si extension es direfente a jpg, eliminar las imagenes con $extension si hay
                     if ($extension != 'jpg') {
                         $files_to_remove = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "*" . $extension;
                         $fs = glob($files_to_remove);
                         if (is_array($fs)) {
                             array_map("unlink", $fs);
                         }
                     }
                     // ....
                 } else {
                     // no es imagen o imagen sin extesión
                 }
             }
             osc_add_flash_ok_message(_m('Re-generation complete'), 'admin');
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:tools.php

示例4: while

    <?php 
$i = 0;
$listcount = 0;
while (osc_has_items()) {
    if ($listcount % 3 == 0) {
        echo '</ul><ul class="row">';
    }
    $listcount++;
    $admin = false;
    if (View::newInstance()->_exists("listAdmin")) {
        $admin = true;
    }
    ?>
    <?php 
    $size = explode('x', osc_thumbnail_dimensions());
    ?>
    <li class="col-sm-6 col-md-4 <?php 
    if (osc_item_is_premium()) {
        echo ' premium';
    }
    ?>
">
        <div class="listing-card">
            <?php 
    if (osc_images_enabled_at_items()) {
        ?>
            <?php 
        if (osc_count_item_resources()) {
            ?>
            <a class="listing-thumb" href="<?php 
开发者ID:oanav,项目名称:closetshare,代码行数:30,代码来源:loop-user-grid.php

示例5: _e

            <div class="form-horizontal">
                <h2 class="render-title"><?php 
_e('Image sizes');
?>
</h2>
                <div class="form-row">
                    <p><?php 
_e('The sizes listed below determine the maximum dimensions in pixels to use when uploading a image. Format: <b>Width</b> x <b>Height</b>.');
?>
</p>
                    <div class="form-label"><?php 
_e('Thumbnail size');
?>
</div>
                    <div class="form-controls"><input type="text" class="input-medium" name="dimThumbnail" value="<?php 
echo osc_esc_html(osc_thumbnail_dimensions());
?>
" /></div>
                </div>
                <div class="form-row">
                    <div class="form-label"><?php 
_e('Preview size');
?>
</div>
                    <div class="form-controls"><input type="text" class="input-medium" name="dimPreview" value="<?php 
echo osc_esc_html(osc_preview_dimensions());
?>
" /></div>
                </div>
                <div class="form-row">
                    <div class="form-label"><?php 
开发者ID:oanav,项目名称:closetshare,代码行数:31,代码来源:media.php

示例6: _e

}
?>
                            </fieldset>

                            <fieldset>
                                <legend><?php 
_e('Dimensions');
?>
</legend>
                                <p>
                                    <label for="thumbnail"><?php 
_e('Thumbnail dimensions');
?>
</label><br />
                                    <input type="text" name="dimThumbnail" id="thumbnail" value="<?php 
echo osc_thumbnail_dimensions();
?>
" />
                                </p>

                                <p>
                                    <label for="preview"><?php 
_e('Preview dimensions');
?>
</label><br />
                                    <input type="text" name="dimPreview" id="preview" value="<?php 
echo osc_preview_dimensions();
?>
" />
                                </p>
开发者ID:acharei,项目名称:OSClass,代码行数:30,代码来源:media.php

示例7: doModel


//.........这里部分代码省略.........
                 $dimNormal = is_numeric($dimNormal) ? $dimNormal . "x" . $dimNormal : "100x100";
             }
             // is imagick extension loaded?
             if (!@extension_loaded('imagick')) {
                 $use_imagick = false;
             }
             // max size allowed by PHP configuration?
             $max_upload = (int) ini_get('upload_max_filesize');
             $max_post = (int) ini_get('post_max_size');
             $memory_limit = (int) ini_get('memory_limit');
             $upload_mb = min($max_upload, $max_post, $memory_limit) * 1024;
             // set maxSizeKB equals to PHP configuration if it's bigger
             if ($maxSizeKb > $upload_mb) {
                 $status = 'warning';
                 $maxSizeKb = $upload_mb;
                 // flash message text warning
                 $error .= sprintf(_m("You cannot set a maximum file size higher than the one allowed in the PHP configuration: <b>%d KB</b>"), $upload_mb);
             }
             $iUpdated += osc_set_preference('maxSizeKb', $maxSizeKb);
             $iUpdated += osc_set_preference('dimThumbnail', $dimThumbnail);
             $iUpdated += osc_set_preference('dimPreview', $dimPreview);
             $iUpdated += osc_set_preference('dimNormal', $dimNormal);
             $iUpdated += osc_set_preference('keep_original_image', $keepOriginalImage);
             $iUpdated += osc_set_preference('force_aspect_image', $forceAspectImage);
             $iUpdated += osc_set_preference('force_jpeg', $forceJPEG);
             $iUpdated += osc_set_preference('use_imagick', $use_imagick);
             if ($error != '') {
                 switch ($status) {
                     case 'error':
                         osc_add_flash_error_message($error, 'admin');
                         break;
                     case 'warning':
                         osc_add_flash_warning_message($error, 'admin');
                         break;
                     default:
                         osc_add_flash_ok_message($error, 'admin');
                         break;
                 }
             } else {
                 osc_add_flash_ok_message(_m('Media config has been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=media');
             break;
         case 'images_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=media');
             }
             osc_csrf_check();
             $aResources = ItemResource::newInstance()->getAllResources();
             foreach ($aResources as $resource) {
                 osc_run_hook('regenerate_image', $resource);
                 if (strpos($resource['s_content_type'], 'image') !== false) {
                     if (file_exists(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_original." . $resource['s_extension'])) {
                         $image_tmp = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_original." . $resource['s_extension'];
                         $use_original = true;
                     } else {
                         if (file_exists(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "." . $resource['s_extension'])) {
                             $image_tmp = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "." . $resource['s_extension'];
                             $use_original = false;
                         } else {
                             if (file_exists(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_preview." . $resource['s_extension'])) {
                                 $image_tmp = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_preview." . $resource['s_extension'];
                                 $use_original = false;
                             } else {
                                 $use_original = false;
                                 continue;
                             }
                         }
                     }
                     // Create normal size
                     $path_normal = $path = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . '.' . $resource['s_extension'];
                     $size = explode('x', osc_normal_dimensions());
                     $img = ImageResizer::fromFile($image_tmp)->resizeTo($size[0], $size[1]);
                     if ($use_original) {
                         if (osc_is_watermark_text()) {
                             $img->doWatermarkText(osc_watermark_text(), osc_watermark_text_color());
                         } elseif (osc_is_watermark_image()) {
                             $img->doWatermarkImage();
                         }
                     }
                     $img->saveToFile($path);
                     // Create preview
                     $path = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . '_preview.' . $resource['s_extension'];
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // Create thumbnail
                     $path = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . '_thumbnail.' . $resource['s_extension'];
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     osc_run_hook('regenerated_image', ItemResource::newInstance()->findByPrimaryKey($resource['pk_i_id']));
                 } else {
                     // no es imagen o imagen sin extesión
                 }
             }
             osc_add_flash_ok_message(_m('Re-generation complete'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=media');
             break;
     }
 }
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:media.php

示例8: doModel


//.........这里部分代码省略.........
                    // there is original image
                    if (count($aImages) == 1) {
                        $image_tmp = $aImages[0];
                    } else {
                        $img_normal = $path . $resource['pk_i_id'] . ".*";
                        $aImages = glob($img_normal);
                        if (count($aImages) == 1) {
                            $image_tmp = $aImages[0];
                        } else {
                            $img_thumbnail = $path . $resource['pk_i_id'] . "_thumbnail*";
                            $aImages = glob($img_thumbnail);
                            $image_tmp = $aImages[0];
                        }
                    }
                    // extension
                    preg_match('/\\.(.*)$/', $image_tmp, $matches);
                    if (isset($matches[1])) {
                        $extension = $matches[1];
                        // Create normal size
                        $path_normal = $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '.jpg';
                        $size = explode('x', osc_normal_dimensions());
                        ImageResizer::fromFile($image_tmp)->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/' . $resource['pk_i_id'] . '_preview.jpg';
                        $size = explode('x', osc_preview_dimensions());
                        ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                        // Create thumbnail
                        $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '_thumbnail.jpg';
                        $size = explode('x', osc_thumbnail_dimensions());
                        ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                        // update resource info
                        ItemResource::newInstance()->update(array('s_path' => 'oc-content/uploads/', 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => 'image/jpeg'), array('pk_i_id' => $resource['pk_i_id']));
                        osc_run_hook('regenerated_image', ItemResource::newInstance()->findByPrimaryKey($resource['pk_i_id']));
                        // si extension es direfente a jpg, eliminar las imagenes con $extension si hay
                        if ($extension != 'jpg') {
                            @unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "." . $extension);
                            @unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_original." . $extension);
                            @unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_preview." . $extension);
                            @unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_thumbnail." . $extension);
                        }
                        // ....
                    } else {
                        // no es imagen o imagen sin extesión
                    }
                }
                osc_add_flash_ok_message(_m('Re-generation complete'), 'admin');
                $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=media');
                break;
            case 'update':
                // update index view
                $iUpdated = 0;
                $sPageTitle = Params::getParam('pageTitle');
                $sPageDesc = Params::getParam('pageDesc');
                $sContactEmail = Params::getParam('contactEmail');
                $sLanguage = Params::getParam('language');
                $sDateFormat = Params::getParam('dateFormat');
                $sCurrency = Params::getParam('currency');
                $sWeekStart = Params::getParam('weekStart');
                $sTimeFormat = Params::getParam('timeFormat');
                $sTimezone = Params::getParam('timezone');
                $sNumRssItems = Params::getParam('num_rss_items');
开发者ID:semul,项目名称:Osclass,代码行数:67,代码来源:settings.php

示例9: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'import':
             // calling import view
             $this->doView('tools/import.php');
             break;
         case 'import_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=import');
             }
             // calling
             $sql = Params::getFiles('sql');
             if (isset($sql['size']) && $sql['size'] != 0) {
                 $content_file = file_get_contents($sql['tmp_name']);
                 $conn = DBConnectionClass::newInstance();
                 $c_db = $conn->getOsclassDb();
                 $comm = new DBCommandClass($c_db);
                 if ($comm->importSQL($content_file)) {
                     osc_add_flash_ok_message(_m('Import complete'), 'admin');
                 } else {
                     osc_add_flash_error_message(_m('There was a problem importing data to the database'), 'admin');
                 }
             } else {
                 osc_add_flash_error_message(_m('No file was uploaded'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=import');
             break;
         case 'images':
             // calling images view
             $this->doView('tools/images.php');
             break;
         case 'images_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=images');
             }
             $preferences = Preference::newInstance()->toArray();
             $wat = new Watermark();
             $aResources = ItemResource::newInstance()->getAllResources();
             foreach ($aResources as $resource) {
                 osc_run_hook('regenerate_image', $resource);
                 $path = osc_content_path() . 'uploads/';
                 // comprobar que no haya original
                 $img_original = $path . $resource['pk_i_id'] . "_original*";
                 $aImages = glob($img_original);
                 // there is original image
                 if (count($aImages) == 1) {
                     $image_tmp = $aImages[0];
                 } else {
                     $img_normal = $path . $resource['pk_i_id'] . ".*";
                     $aImages = glob($img_normal);
                     if (count($aImages) == 1) {
                         $image_tmp = $aImages[0];
                     } else {
                         $img_thumbnail = $path . $resource['pk_i_id'] . "_thumbnail*";
                         $aImages = glob($img_thumbnail);
                         $image_tmp = $aImages[0];
                     }
                 }
                 // extension
                 preg_match('/\\.(.*)$/', $image_tmp, $matches);
                 if (isset($matches[1])) {
                     $extension = $matches[1];
                     // Create normal size
                     $path_normal = $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '.jpg';
                     $size = explode('x', osc_normal_dimensions());
                     ImageResizer::fromFile($image_tmp)->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/' . $resource['pk_i_id'] . '_preview.jpg';
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // Create thumbnail
                     $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '_thumbnail.jpg';
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // update resource info
                     ItemResource::newInstance()->update(array('s_path' => 'oc-content/uploads/', 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => 'image/jpeg'), array('pk_i_id' => $resource['pk_i_id']));
                     osc_run_hook('regenerated_image', ItemResource::newInstance()->findByPrimaryKey($resource['pk_i_id']));
                     // si extension es direfente a jpg, eliminar las imagenes con $extension si hay
                     if ($extension != 'jpg') {
                         $files_to_remove = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "*" . $extension;
                         $fs = glob($files_to_remove);
                         if (is_array($fs)) {
                             array_map("unlink", $fs);
                         }
                     }
                     // ....
                 } else {
                     // no es imagen o imagen sin extesión
                 }
             }
             osc_add_flash_ok_message(_m('Re-generation complete'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=images');
//.........这里部分代码省略.........
开发者ID:acharei,项目名称:OSClass,代码行数:101,代码来源:tools.php

示例10: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'import':
             // calling import view
             $this->doView('tools/import.php');
             break;
         case 'import_post':
             // calling
             $sql = Params::getFiles('sql');
             //dev.conquer: if the file es too big, we can have problems with the upload or with memory
             $content_file = file_get_contents($sql['tmp_name']);
             $conn = getConnection();
             if ($conn->osc_dbImportSQL($content_file)) {
                 osc_add_flash_message(_m('Import complete'), 'admin');
             } else {
                 osc_add_flash_message(_m('There was a problem importing data to the database'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=import');
             break;
         case 'images':
             // calling images view
             $this->doView('tools/images.php');
             break;
         case 'images_post':
             $preferences = Preference::newInstance()->toArray();
             $path = osc_content_path() . 'uploads/';
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (preg_match('|([0-9]+)_thumbnail\\.png|i', $file, $matches)) {
                     $orig_file = str_replace('_thumbnail.', '_original.', $file);
                     $tmpName = osc_content_path() . 'uploads/' . $orig_file;
                     if (!file_exists($orig_file)) {
                         copy(str_replace('_original.', '.', $tmpName), $tmpName);
                     }
                     // Create thumbnail
                     $thumbnailPath = osc_content_path() . 'uploads/' . $file;
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($thumbnailPath);
                     // Create preview
                     $thumbnailPath = osc_content_path() . 'uploads/' . str_replace('_thumbnail.', '_preview.', $file);
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($thumbnailPath);
                     // Create normal size
                     $thumbnailPath = osc_content_path() . 'uploads/' . str_replace('_thumbnail.', '.', $file);
                     $size = explode('x', osc_normal_dimensions());
                     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($thumbnailPath);
                     if (!osc_keep_original_image()) {
                         @unlink($tmpName);
                     }
                 }
             }
             closedir($dir);
             osc_add_flash_message(_m('Re-generation complete'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=images');
             break;
         case 'upgrade':
             $this->doView('tools/upgrade.php');
             break;
         case 'backup':
             $this->doView('tools/backup.php');
             break;
         case 'backup-sql':
             //databasse dump...
             if (Params::getParam('bck_dir') != '') {
                 $path = trim(Params::getParam('bck_dir'));
                 if (substr($path, -1, 1) != "/") {
                     $path .= '/';
                 }
             } else {
                 $path = osc_base_path();
             }
             $filename = 'OSClass_mysqlbackup.' . date('YmdHis') . '.sql';
             switch (osc_dbdump($path, $filename)) {
                 case -1:
                     $msg = _m('Path is empty');
                     break;
                 case -2:
                     $msg = _m('Could not connect with the database') . '. Error: ' . mysql_error();
                     break;
                 case -3:
                     $msg = _m('Could not select the database') . '. Error: ' . mysql_error();
                     break;
                 case -4:
                     $msg = _m('There are no tables to back up');
                     break;
                 case -5:
                     $msg = _m('The folder is not writable');
                     break;
                 default:
                     $msg = _m('Backup has been done properly');
                     break;
             }
             osc_add_flash_message($msg, 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=tools&action=backup');
             break;
         case 'backup-zip':
             //zip of the code just to back it up
             if (Params::getParam('bck_dir') != '') {
                 $archive_name = trim(Params::getParam('bck_dir'));
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:tools.php

示例11: uploadItemResources

 public function uploadItemResources($aResources, $itemId)
 {
     if ($aResources != '') {
         $itemResourceManager = ItemResource::newInstance();
         foreach ($aResources['error'] as $key => $error) {
             if ($error == UPLOAD_ERR_OK) {
                 $tmpName = $aResources['tmp_name'][$key];
                 $itemResourceManager->insert(array('fk_i_item_id' => $itemId));
                 $resourceId = $itemResourceManager->getConnection()->get_last_id();
                 // Create thumbnail
                 $path = osc_content_path() . 'uploads/' . $resourceId . '_thumbnail.png';
                 $size = explode('x', osc_thumbnail_dimensions());
                 ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
                 // Create normal size
                 $path = osc_content_path() . 'uploads/' . $resourceId . '.png';
                 $size = explode('x', osc_normal_dimensions());
                 ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
                 if (osc_keep_original_image()) {
                     $path = osc_content_path() . 'uploads/' . $resourceId . '_original.png';
                     move_uploaded_file($tmpName, $path);
                 }
                 $s_path = 'oc-content/uploads/';
                 $resourceType = 'image/png';
                 $itemResourceManager->update(array('s_path' => $s_path, 's_name' => osc_genRandomPassword(), 's_extension' => 'png', 's_content_type' => $resourceType), array('pk_i_id' => $resourceId, 'fk_i_item_id' => $itemId));
             }
         }
         unset($itemResourceManager);
     }
 }
开发者ID:hashemgamal,项目名称:OSClass,代码行数:29,代码来源:ItemActions.php

示例12: 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

示例13: uploadFiles

 public function uploadFiles($gn_id, $files = array())
 {
     if (empty($files)) {
         return TRUE;
     }
     $gn_id = (int) $gn_id;
     if (empty($gn_id)) {
         return FALSE;
     }
     $news_folder = osc_content_path() . 'uploads/news/';
     if (file_exists($news_folder) == FALSE) {
         mkdir($news_folder, 0777, TRUE);
     }
     $item_folder = "{$news_folder}{$gn_id}/";
     if (file_exists($item_folder) == FALSE) {
         mkdir($item_folder, 0777, TRUE);
     }
     $valid_images = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif');
     if ($files['error'] != 0) {
         return FALSE;
     }
     if (!in_array($files['type'], $valid_images)) {
         return FALSE;
     }
     if (empty($files['tmp_name'])) {
         return FALSE;
     }
     ImageResizer::fromFile($files['tmp_name'])->saveToFile($item_folder . 'original.jpg');
     $size = explode('x', osc_normal_dimensions());
     ImageResizer::fromFile($files['tmp_name'])->resizeTo($size[0], $size[1])->saveToFile($item_folder . 'normal.jpg');
     $size = explode('x', osc_preview_dimensions());
     ImageResizer::fromFile($files['tmp_name'])->resizeTo($size[0], $size[1])->saveToFile($item_folder . 'preview.jpg');
     $size = explode('x', osc_thumbnail_dimensions());
     ImageResizer::fromFile($files['tmp_name'])->resizeTo($size[0], $size[1])->saveToFile($item_folder . 'thumb.jpg');
 }
开发者ID:faosclass,项目名称:gz_news,代码行数:35,代码来源:GzNewsModel.php


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