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


PHP entity_selector::get_ids方法代码示例

本文整理汇总了PHP中entity_selector::get_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP entity_selector::get_ids方法的具体用法?PHP entity_selector::get_ids怎么用?PHP entity_selector::get_ids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在entity_selector的用法示例。


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

示例1: run

    /**
     * Run the upgrader
     *
     *
     * @return string HTML report
     */
    public function run()
    {
        /* 
        	Check for progress in script -- a starting index of -1 implies that all photos have 
        	already been processed during this session
        */
        if (isset($_SESSION['reason_thumbnail_standardize_script']['last_end_index'])) {
            $start_index = $_SESSION['reason_thumbnail_standardize_script']['last_end_index'];
        } else {
            $start_index = 0;
        }
        if ($start_index == -1) {
            return 'This script has already processed all images during this session!' . '<br />';
        } else {
            $start_time = time();
            $php_max_time = ini_get('max_execution_time');
            if ($php_max_time == 0) {
                $time_limit = 15;
            } else {
                $time_limit = min($php_max_time / 2, 15);
            }
            $es = new entity_selector();
            $es->add_type(id_of('image'));
            $all_image_ids = $es->get_ids();
            $ids_with_only_tb = array();
            $total_num_images = sizeof($all_image_ids);
            /* Start processing images where last time left off, or start at the beginning */
            /* Runs for $time_limit seconds at a time, continues process when script is run again */
            for ($i = $start_index; $i < $total_num_images; $i++) {
                $main_image_path = reason_get_image_path($all_image_ids[$i]);
                /* If no main image exists, copy the thumbnail to be the main image */
                if (!file_exists($main_image_path)) {
                    $thumbnail_path = reason_get_image_path($all_image_ids[$i], 'thumbnail');
                    if (file_exists($thumbnail_path)) {
                        $ids_with_only_tb[] = $all_image_ids[$i];
                        if (!copy($thumbnail_path, $main_image_path)) {
                            echo 'failed to copy image of id ' . $all_image_ids[$i];
                        }
                    }
                }
                if (time() - $start_time > $time_limit) {
                    break;
                }
            }
            /* If all images have been processed, reset the last index*/
            if ($i >= $total_num_images) {
                $_SESSION['reason_thumbnail_standardize_script']['last_end_index'] = -1;
                $_SESSION['reason_thumbnail_standardize_script']['run_again'] = false;
            } else {
                $_SESSION['reason_thumbnail_standardize_script']['last_end_index'] = $i;
                $_SESSION['reason_thumbnail_standardize_script']['run_again'] = true;
            }
            /* Give user some info on how many more times script should be run */
            $percent_remaining = substr(($total_num_images - $i) / $total_num_images * 100, 0, 4);
            echo '<br /> There are ' . $total_num_images . ' total images to process';
            echo '<br /> This execution of the script started at the ' . $start_index . 'th photo';
            echo '<br /> It processed a total of ' . ($i - $start_index) . ' images, and created new main
			images from ' . sizeof($ids_with_only_tb) . ' thumbnails.';
            echo '<br /> A total of ' . ($total_num_images - $i) . ', (' . $percent_remaining . '%)
			images still need to be processed <br />';
        }
    }
开发者ID:hunter2814,项目名称:reason_package,代码行数:68,代码来源:thumbnail_standardize.php

示例2: get_existing_section_ids

 protected function get_existing_section_ids($org_id = null)
 {
     $es = new entity_selector();
     $es->add_type(id_of('course_section_type'));
     if ($org_id) {
         $es->add_relation('org_id = "' . mysql_real_escape_string($org_id) . '"');
     }
     if ($result = $es->get_ids()) {
         return $result;
     } else {
         return array();
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:13,代码来源:course_import.php

示例3: run

 /**
  * Run the upgrader
  *
  * @return string HTML report
  */
 public function run()
 {
     /* 
     	Check for progress in script -- a starting index of -1 implies that all photos have 
     	already been processed during this session
     */
     $current_user = check_authentication();
     if (!reason_user_has_privs(get_user_id($current_user), 'db_maintenance')) {
         die('don\'t have the right permissions?');
     }
     if (isset($_SESSION['reason_image_type_script']['last_end_index'])) {
         $start_index = $_SESSION['reason_image_type_script']['last_end_index'];
     } else {
         $start_index = 0;
     }
     if ($start_index == -1) {
         echo '<p>This script has already processed all images during this session!' . '</p>';
     } else {
         $start_time = time();
         $php_max_time = ini_get('max_execution_time');
         if ($php_max_time == 0) {
             $time_limit = 30;
         } else {
             $time_limit = min($php_max_time / 2, 50);
         }
         $es = new entity_selector();
         $es->add_type(id_of('image'));
         $all_image_ids = $es->get_ids('', 'All', 'get_ids_error');
         /* 
             3 cases for which FILES actually exist
             1. only standard -- no need to update the image Entity table
             2. standard and thumbnail -- give these entities a thumbnail_image_type field
             3. standard, thumbnail, original (full-size) -- give these entites a thumbnail_image_type and
             original_image_type field
         */
         $ids_with_tn = array();
         $ids_with_tn_full = array();
         chdir(PHOTOSTOCK);
         $total_num_image_ids = count($all_image_ids);
         // make sure fields we are going to write to actually exist
         $this->add_unexisting_image_fields();
         for ($index = $start_index; $index < $total_num_image_ids; $index++) {
             $image_id = $all_image_ids[$index];
             if (file_exists(reason_get_image_path($image_id, 'thumbnail'))) {
                 $image = new entity($image_id);
                 // Check if the entity already has a thumbnail_image_type to avoid clobbering an old value
                 // when the UPDATE SQL query is run
                 // Note: at this point, we have determined a thumbnail exists, so 'thumbnail_image_type'
                 // will not be null if the field already exists
                 if (!$image->has_value('thumbnail_image_type')) {
                     if (file_exists(reason_get_image_path($image_id, 'original'))) {
                         $ids_with_tn_full[] = $image_id;
                     } else {
                         $ids_with_tn[] = $image_id;
                     }
                 }
             }
             if (time() - $start_time > $time_limit) {
                 break;
             }
         }
         $this->run_sql_queries($ids_with_tn, $ids_with_tn_full);
         // Session stuff
         if ($index >= $total_num_image_ids) {
             $_SESSION['reason_image_type_script']['last_end_index'] = -1;
             $_SESSION['reason_image_type_script']['run_again'] = false;
         } else {
             $_SESSION['reason_image_type_script']['last_end_index'] = $index;
             $_SESSION['reason_image_type_script']['run_again'] = true;
         }
         echo '<p>Started at index ' . $start_index . ' out of ' . $total_num_image_ids . '<br />';
         echo 'Ended at index ' . $index . ' (' . round($index / $total_num_image_ids * 100, 2) . '%)<br />';
         echo 'Processed ' . ($index - $start_index) . ' total images<br />';
         echo 'There were a total of ' . count($ids_with_tn) . ' ids with a main image and thumbnail <br />';
         echo 'There were a total of ' . count($ids_with_tn_full) . ' ids with a main image, thumbnail, and full</p>';
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:82,代码来源:image_extension_clean_up.php


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