當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ItemResource類代碼示例

本文整理匯總了PHP中ItemResource的典型用法代碼示例。如果您正苦於以下問題:PHP ItemResource類的具體用法?PHP ItemResource怎麽用?PHP ItemResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ItemResource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: osc_deleteResource

/**
 * Remove resources from disk
 * @param <type> $id
 * @param boolean $admin
 * @return boolean
 */
function osc_deleteResource($id, $admin)
{
    if (defined('DEMO')) {
        return false;
    }
    if (is_array($id)) {
        $id = $id[0];
    }
    $resource = ItemResource::newInstance()->findByPrimaryKey($id);
    if (!is_null($resource)) {
        Log::newInstance()->insertLog('item', 'delete resource', $resource['pk_i_id'], $id, $admin ? 'admin' : 'user', $admin ? osc_logged_admin_id() : osc_logged_user_id());
        $backtracel = '';
        foreach (debug_backtrace() as $k => $v) {
            if ($v['function'] == "include" || $v['function'] == "include_once" || $v['function'] == "require_once" || $v['function'] == "require") {
                $backtracel .= "#" . $k . " " . $v['function'] . "(" . $v['args'][0] . ") called@ [" . $v['file'] . ":" . $v['line'] . "] / ";
            } else {
                $backtracel .= "#" . $k . " " . $v['function'] . " called@ [" . $v['file'] . ":" . $v['line'] . "] / ";
            }
        }
        Log::newInstance()->insertLog('item', 'delete resource backtrace', $resource['pk_i_id'], $backtracel, $admin ? 'admin' : 'user', $admin ? osc_logged_admin_id() : osc_logged_user_id());
        @unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "." . $resource['s_extension']);
        @unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_original." . $resource['s_extension']);
        @unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_thumbnail." . $resource['s_extension']);
        @unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_preview." . $resource['s_extension']);
        osc_run_hook('delete_resource', $resource);
    }
}
開發者ID:naneri,項目名稱:Osclass,代碼行數:33,代碼來源:utils.php

示例2: newInstance

 /**
  * It creates a new ItemResource object class ir if it has been created
  * before, it return the previous object
  *
  * @access public
  * @since unknown
  * @return ItemResource
  */
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
開發者ID:mylastof,項目名稱:os-class,代碼行數:15,代碼來源:ItemResource.php

示例3: __construct

 function __construct($params)
 {
     $this->_get = $params;
     $this->getDBParams();
     $this->result = ItemResource::newInstance()->getResources(Params::getParam('resourceId'), $this->_get['iDisplayStart'], $this->_get['iDisplayLength'], isset($this->order_by['column_name']) ? $this->order_by['column_name'] : 'pk_i_id', isset($this->order_by['type']) ? $this->order_by['type'] : 'desc');
     $this->filtered_total = ItemResource::newInstance()->countResources(Params::getParam('resourceId'));
     $this->total = ItemResource::newInstance()->countResources('');
     $this->toDatatablesFormat();
     $this->dumpToDatatables();
 }
開發者ID:acharei,項目名稱:OSClass,代碼行數:10,代碼來源:media_processing.php

示例4: osc_deleteResource

/**
 * Remove resources from disk
 * @param <type> $id
 * @return boolean
 */
function osc_deleteResource($id)
{
    if (is_array($id)) {
        $id = $id[0];
    }
    $resource = ItemResource::newInstance()->findByPrimaryKey($id);
    if (!is_null($resource)) {
        $resource_original = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "." . $resource['s_extension'];
        $resource_thum = osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_*" . "." . $resource['s_extension'];
        array_map("unlink", glob($resource_thum));
        array_map("unlink", glob($resource_original));
    }
}
開發者ID:hashemgamal,項目名稱:OSClass,代碼行數:18,代碼來源:utils.php

示例5: __construct

 function __construct($params)
 {
     $this->_get = $params;
     $this->getDBParams();
     $this->media = ItemResource::newInstance()->getResources($this->resourceID, $this->start, $this->limit, $this->order_by['column_name'] ? $this->order_by['column_name'] : 'pk_i_id', $this->order_by['type'] ? $this->order_by['type'] : 'desc');
     $this->total = ItemResource::newInstance()->countResources();
     if ($this->resourceID == null) {
         $this->total_filtered = $this->total;
     } else {
         $this->total_filtered = ItemResource::newInstance()->countResources($this->resourceID);
     }
     $this->toDatatablesFormat();
     $this->dumpToDatatables();
 }
開發者ID:randomecho,項目名稱:OSClass,代碼行數:14,代碼來源:media_processing.php

示例6: table

 public function table($params)
 {
     $this->addTableHeader();
     $this->getDBParams($params);
     $media = ItemResource::newInstance()->getResources($this->resourceID, $this->start, $this->limit, $this->order_by['column_name'], $this->order_by['type']);
     $this->processData($media);
     $this->total = ItemResource::newInstance()->countResources();
     if ($this->resourceID == null) {
         $this->total_filtered = $this->total;
     } else {
         $this->total_filtered = ItemResource::newInstance()->countResources($this->resourceID);
     }
     return $this->getData();
 }
開發者ID:mylastof,項目名稱:os-class,代碼行數:14,代碼來源:MediaDataTable.php

示例7: __construct

 function __construct($params)
 {
     $this->_get = $params;
     $p_iPage = 1;
     if (!is_numeric(Params::getParam('iPage')) || Params::getParam('iPage') < 1) {
         Params::setParam('iPage', $p_iPage);
     }
     // force ORDER BY
     $this->order_by['column_name'] = $this->column_names[4];
     $this->order_by['type'] = 'desc';
     $this->getDBParams();
     $this->media = ItemResource::newInstance()->getResources($this->resourceID, $this->start, $this->limit, $this->order_by['column_name'] ? $this->order_by['column_name'] : 'pk_i_id', $this->order_by['type'] ? $this->order_by['type'] : 'desc');
     $this->total = ItemResource::newInstance()->countResources();
     if ($this->resourceID == null) {
         $this->total_filtered = $this->total;
     } else {
         $this->total_filtered = ItemResource::newInstance()->countResources($this->resourceID);
     }
 }
開發者ID:semul,項目名稱:Osclass,代碼行數:19,代碼來源:media_processing.php

示例8: findResourcesByID

 /**
  * Find item resources belong to an item given its id
  *
  * @access public
  * @since unknown
  * @param int $id Item id
  * @return array of resources
  */
 public function findResourcesByID($id)
 {
     return ItemResource::newInstance()->getResources($id);
 }
開發者ID:semul,項目名稱:Osclass,代碼行數:12,代碼來源:Item.php

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

示例10: doModel


//.........這裏部分代碼省略.........
                    // 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 += Preference::newInstance()->update(array('s_value' => $maxSizeKb), array('s_name' => 'maxSizeKb'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $allowedExt), array('s_name' => 'allowedExt'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $dimThumbnail), array('s_name' => 'dimThumbnail'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $dimPreview), array('s_name' => 'dimPreview'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $dimNormal), array('s_name' => 'dimNormal'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $keepOriginalImage), array('s_name' => 'keep_original_image'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $use_imagick), array('s_name' => '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');
                }
                $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');
開發者ID:semul,項目名稱:Osclass,代碼行數:67,代碼來源:settings.php

示例11: doModel

 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'location_countries':
             // This is the autocomplete AJAX
             $countries = Country::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($countries);
             break;
         case 'location_regions':
             // This is the autocomplete AJAX
             $regions = Region::newInstance()->ajax(Params::getParam("term"), Params::getParam("country"));
             echo json_encode($regions);
             break;
         case 'location_cities':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"), Params::getParam("region"));
             echo json_encode($cities);
             break;
         case 'delete_image':
             // Delete images via AJAX
             $id = Params::getParam('id');
             $item = Params::getParam('item');
             $code = Params::getParam('code');
             $secret = Params::getParam('secret');
             $json = array();
             if (Session::newInstance()->_get('userId') != '') {
                 $userId = Session::newInstance()->_get('userId');
                 $user = User::newInstance()->findByPrimaryKey($userId);
             } else {
                 $userId = null;
                 $user = null;
             }
             // Check for required fields
             if (!(is_numeric($id) && is_numeric($item) && preg_match('/^([a-z0-9]+)$/i', $code))) {
                 $json['success'] = false;
                 $json['msg'] = _m("The selected photo couldn't be deleted, the url doesn't exist");
                 echo json_encode($json);
                 return false;
             }
             $aItem = Item::newInstance()->findByPrimaryKey($item);
             // Check if the item exists
             if (count($aItem) == 0) {
                 $json['success'] = false;
                 $json['msg'] = _m('The item doesn\'t exist');
                 echo json_encode($json);
                 return false;
             }
             // Check if the item belong to the user
             if ($userId != null && $userId != $aItem['fk_i_user_id']) {
                 $json['success'] = false;
                 $json['msg'] = _m('The item doesn\'t belong to you');
                 echo json_encode($json);
                 return false;
             }
             // Check if the secret passphrase match with the item
             if ($userId == null && $aItem['fk_i_user_id'] == null && $secret != $aItem['s_secret']) {
                 $json['success'] = false;
                 $json['msg'] = _m('The item doesn\'t belong to you');
                 echo json_encode($json);
                 return false;
             }
             // Does id & code combination exist?
             $result = ItemResource::newInstance()->existResource($id, $code);
             if ($result > 0) {
                 // Delete: file, db table entry
                 osc_deleteResource($id);
                 ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $item, 's_name' => $code));
                 $json['msg'] = _m('The selected photo has been successfully deleted');
                 $json['success'] = 'true';
             } else {
                 $json['msg'] = _m("The selected photo couldn't be deleted");
                 $json['success'] = 'false';
             }
             echo json_encode($json);
             return true;
             break;
         case 'alerts':
             // Allow to register to an alert given (not sure it's used on admin)
             $alert = Params::getParam("alert");
             $email = Params::getParam("email");
             $userid = Params::getParam("userid");
             if ($alert != '' && $email != '') {
//.........這裏部分代碼省略.........
開發者ID:acharei,項目名稱:OSClass,代碼行數:101,代碼來源:ajax.php

示例12: processData

        private function processData($items)
        {
            if(!empty($items)) {

                $csrf_token_url = osc_csrf_token_url();
                foreach($items as $aRow) {
                    View::newInstance()->_exportVariableToView('item', $aRow);
                    $row     = array();
                    $options = array();
                    // -- prepare data --
                    // prepare item title
                    $title = mb_substr($aRow['s_title'], 0, 30, 'UTF-8');
                    if($title != $aRow['s_title']) {
                        $title .= '...';
                    }

                    //icon open add new window
                    $title .= '<span class="icon-new-window"></span>';

                    // Options of each row
                    $options_more = array();
                    if($aRow['b_active']) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=INACTIVE">' . __('Deactivate') .'</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ACTIVE">' . __('Activate') .'</a>';
                    }
                    if($aRow['b_enabled']) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=DISABLE">' . __('Block') .'</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ENABLE">' . __('Unblock') .'</a>';
                    }
                    if($aRow['b_premium']) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status_premium&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=0">' . __('Unmark as premium') .'</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status_premium&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=1">' . __('Mark as premium') .'</a>';
                    }
                    if($aRow['b_spam']) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status_spam&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=0">' . __('Unmark as spam') .'</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=status_spam&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=1">' . __('Mark as spam') .'</a>';
                    }

                    // general options
                    $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=item_edit&amp;id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>';
                    $options[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=items&amp;action=delete&amp;id[]=' . $aRow['pk_i_id'] . '">' . __('Delete') . '</a>';

                    // only show if there are data
                    if(ItemComment::newInstance()->totalComments( $aRow['pk_i_id'] ) > 0) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=list&amp;id=' . $aRow['pk_i_id'] . '">' . __('View comments') . '</a>';
                    }
                    if(ItemResource::newInstance()->countResources( $aRow['pk_i_id'] ) > 0) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=media&amp;action=list&amp;resourceId=' . $aRow['pk_i_id'] . '">' . __('View media') . '</a>';
                    }

                    $options_more = osc_apply_filter('more_actions_manage_items', $options_more, $aRow);
                    // more actions
                    $moreOptions = '<li class="show-more">'.PHP_EOL.'<a href="#" class="show-more-trigger">'. __('Show more') .'...</a>'. PHP_EOL .'<ul>'. PHP_EOL;
                    foreach( $options_more as $actual) {
                        $moreOptions .= '<li>'.$actual."</li>".PHP_EOL;
                    }
                    $moreOptions .= '</ul>'. PHP_EOL .'</li>'.PHP_EOL;

                    $options = osc_apply_filter('actions_manage_items', $options, $aRow);
                    // create list of actions
                    $auxOptions = '<ul>'.PHP_EOL;
                    foreach( $options as $actual) {
                        $auxOptions .= '<li>'.$actual.'</li>'.PHP_EOL;
                    }
                    if(!empty($options_more)) {
                        $auxOptions  .= $moreOptions;
                    }
                    $auxOptions  .= '</ul>'.PHP_EOL;

                    $actions = '<div class="actions">'.$auxOptions.'</div>'.PHP_EOL;

                    // fill a row
                    $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" active="' . $aRow['b_active'] . '" blocked="' . $aRow['b_enabled'] . '"/>';
                    $status = $this->get_row_status();
                    $row['status-border'] = '';
                    $row['status'] = $status['text'];
                    $row['title'] = '<a href="' . osc_item_url() . '" target="_blank">' . $title. '</a>'. $actions;
                    if($aRow['fk_i_user_id']!=null) {
                        $row['user'] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=edit&id=' . $aRow['fk_i_user_id'] . '" target="_blank">' . $aRow['s_user_name'] . '</a>';
                    } else {
                        $row['user'] = $aRow['s_user_name'];
                    }
                    $row['category'] = $aRow['s_category_name'];
                    $row['location'] = $this->get_row_location();
                    $row['date'] = osc_format_date($aRow['dt_pub_date']);
                    $row['expiration'] = osc_format_date($aRow['dt_expiration']);

                    $row = osc_apply_filter('items_processing_row', $row, $aRow);

                    $this->addRow($row);
                    $this->rawRows[] = $aRow;
                }

            }
        }
開發者ID:pombredanne,項目名稱:ArcherSys,代碼行數:99,代碼來源:ItemsDataTable.php

示例13: doModel


//.........這裏部分代碼省略.........
                 Session::newInstance()->_setForm($key, $value);
             }
             $meta = Params::getParam('meta');
             if (is_array($meta)) {
                 foreach ($meta as $key => $value) {
                     Session::newInstance()->_setForm('meta_' . $key, $value);
                     Session::newInstance()->_keepForm('meta_' . $key);
                 }
             }
             $success = $mItems->edit();
             if ($success == 1) {
                 osc_add_flash_ok_message(_m('Changes saved correctly'), 'admin');
                 $url = osc_admin_base_url(true) . "?page=items";
                 // if Referer is saved that means referer is ManageListings or ReportListings
                 if (Session::newInstance()->_get('osc_admin_referer') != '') {
                     $url = Session::newInstance()->_get('osc_admin_referer');
                 }
                 Session::newInstance()->_clearVariables();
                 $this->redirectTo($url);
             } else {
                 osc_add_flash_error_message($success, 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . "?page=items&action=item_edit&id=" . Params::getParam('id'));
             }
             break;
         case 'deleteResource':
             //delete resource
             osc_csrf_check();
             $id = Params::getParam('id');
             $name = Params::getParam('name');
             $fkid = Params::getParam('fkid');
             // delete files
             osc_deleteResource($id, true);
             Log::newInstance()->insertLog('items', 'deleteResource', $id, $id, 'admin', osc_logged_admin_id());
             $result = ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $fkid, 's_name' => $name));
             if ($result === false) {
                 osc_add_flash_error_message(_m('An error has occurred'), 'admin');
             } else {
                 osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=items");
             break;
         case 'post':
             // add item
             $form = count(Session::newInstance()->_getForm());
             $keepForm = count(Session::newInstance()->_getKeepForm());
             if ($form == 0 || $form == $keepForm) {
                 Session::newInstance()->_dropKeepForm();
             }
             $this->_exportVariableToView("new_item", TRUE);
             osc_run_hook('post_item');
             $this->doView('items/frm.php');
             break;
         case 'post_item':
             //post item
             osc_csrf_check();
             $mItem = new ItemActions(true);
             $mItem->prepareData(true);
             // set all parameters into session
             foreach ($mItem->data as $key => $value) {
                 Session::newInstance()->_setForm($key, $value);
             }
             $meta = Params::getParam('meta');
             if (is_array($meta)) {
                 foreach ($meta as $key => $value) {
                     Session::newInstance()->_setForm('meta_' . $key, $value);
                     Session::newInstance()->_keepForm('meta_' . $key);
開發者ID:jmcclenon,項目名稱:Osclass,代碼行數:67,代碼來源:items.php

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

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


注:本文中的ItemResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。