• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_FileCache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: dbm_delete_orphan_files

/**
 * Find and delete orphan File objects with no matching file on disk
 */
function dbm_delete_orphan_files()
{
    global $DB;
    $FileCache =& get_FileCache();
    echo T_('Deleting of the orphan File objects from the database...');
    evo_flush();
    $files_SQL = new SQL();
    $files_SQL->SELECT('file_ID');
    $files_SQL->FROM('T_files');
    $files_SQL->ORDER_BY('file_ID');
    $count_files_valid = 0;
    $count_files_deleted = 0;
    $page_size = 100;
    $current_page = 0;
    while (1) {
        // Search the files by page to save memory
        $files_SQL->LIMIT($current_page * $page_size . ', ' . $page_size);
        $files = $DB->get_col($files_SQL->get());
        if (empty($files)) {
            // All files were verified, Stop here
            break;
        }
        foreach ($files as $file_ID) {
            $File = $FileCache->get_by_ID($file_ID, false, false);
            if ($File->exists()) {
                // File exists on the disk
                $count_files_valid++;
            } else {
                // File doesn't exist on the disk, Remove it from DB
                $File->dbdelete();
                $count_files_deleted++;
            }
        }
        echo ' .';
        evo_flush();
        // Clear cache after each page to save memory
        $FileCache->clear();
        $current_page++;
    }
    echo 'OK<br /><br />';
    echo sprintf(T_('%d File objects have been deleted.'), $count_files_deleted) . '<br />';
    echo sprintf(T_('%d File objects are valid entries.'), $count_files_valid);
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:46,代码来源:_dbmaintenance.funcs.php


示例2: display

    /**
     * Display the widget!
     *
     * @param array MUST contain at least the basic display params
     */
    function display($params)
    {
        global $localtimenow;
        $this->init_display($params);
        if ($this->disp_params['order_by'] == 'RAND' && isset($this->BlockCache)) {
            // Do NOT cache if display order is random
            $this->BlockCache->abort_collect();
        }
        global $Blog;
        $list_blogs = $this->disp_params['blog_ID'] ? $this->disp_params['blog_ID'] : $Blog->ID;
        //pre_dump( $list_blogs );
        // Display photos:
        // TODO: permissions, complete statuses...
        // TODO: A FileList object based on ItemListLight but adding File data into the query?
        //          overriding ItemListLigth::query() for starters ;)
        $FileCache =& get_FileCache();
        $FileList = new DataObjectList2($FileCache);
        // Query list of files:
        $SQL = new SQL();
        $SQL->SELECT('post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_canonical_slug_ID,
									post_tiny_slug_ID, post_ptyp_ID, post_title, post_excerpt, post_url, file_ID,
									file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc');
        $SQL->FROM('T_categories INNER JOIN T_postcats ON cat_ID = postcat_cat_ID
									INNER JOIN T_items__item ON postcat_post_ID = post_ID
									INNER JOIN T_links ON post_ID = link_itm_ID
									INNER JOIN T_files ON link_file_ID = file_ID');
        $SQL->WHERE('cat_blog_ID IN (' . $list_blogs . ')');
        // fp> TODO: want to restrict on images :]
        $SQL->WHERE_and('post_status = "published"');
        // TODO: this is a dirty hack. More should be shown.
        $SQL->WHERE_and('post_datestart <= \'' . remove_seconds($localtimenow) . '\'');
        if (!empty($this->disp_params['item_type'])) {
            // Get items only with specified type
            $SQL->WHERE_and('post_ptyp_ID = ' . intval($this->disp_params['item_type']));
        }
        $SQL->GROUP_BY('link_ID');
        $SQL->LIMIT($this->disp_params['limit'] * 4);
        // fp> TODO: because we have no way of getting images only, we get 4 times more data than requested and hope that 25% at least will be images :/
        $SQL->ORDER_BY(gen_order_clause($this->disp_params['order_by'], $this->disp_params['order_dir'], 'post_', 'post_ID ' . $this->disp_params['order_dir'] . ', link_ID'));
        $FileList->sql = $SQL->get();
        $FileList->query(false, false, false, 'Media index widget');
        $layout = $this->disp_params['thumb_layout'];
        $nb_cols = $this->disp_params['grid_nb_cols'];
        $count = 0;
        $r = '';
        /**
         * @var File
         */
        while ($File =& $FileList->get_next()) {
            if ($count >= $this->disp_params['limit']) {
                // We have enough images already!
                break;
            }
            if (!$File->is_image()) {
                // Skip anything that is not an image
                // fp> TODO: maybe this property should be stored in link_ltype_ID or in the files table
                continue;
            }
            if ($layout == 'grid') {
                if ($count % $nb_cols == 0) {
                    $r .= $this->disp_params['grid_colstart'];
                }
                $r .= $this->disp_params['grid_cellstart'];
            } else {
                $r .= $this->disp_params['item_start'];
            }
            // 1/ Hack a dirty permalink( will redirect to canonical):
            // $link = url_add_param( $Blog->get('url'), 'p='.$post_ID );
            // 2/ Hack a link to the right "page". Very daring!!
            // $link = url_add_param( $Blog->get('url'), 'paged='.$count );
            // 3/ Instantiate a light object in order to get permamnent url:
            $ItemLight = new ItemLight($FileList->get_row_by_idx($FileList->current_idx - 1));
            // index had already been incremented
            $r .= '<a href="' . $ItemLight->get_permanent_url() . '">';
            // Generate the IMG THUMBNAIL tag with all the alt, title and desc if available
            $r .= $File->get_thumb_imgtag($this->disp_params['thumb_size'], '', '', $ItemLight->title);
            $r .= '</a>';
            if ($this->disp_params['disp_image_title']) {
                $title = $File->get('title') ? $this->get('title') : $ItemLight->title;
                $r .= '<span class="note">' . $title . '</span>';
            }
            ++$count;
            if ($layout == 'grid') {
                $r .= $this->disp_params['grid_cellend'];
                if ($count % $nb_cols == 0) {
                    $r .= $this->disp_params['grid_colend'];
                }
            } else {
                $r .= $this->disp_params['item_end'];
            }
        }
        // Exit if no files found
        if (empty($r)) {
            return;
        }
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_coll_media_index.widget.php


示例3: foreach

foreach ($params['fields'] as $field_key => $field_data) {
    $highlighted = '';
    if ($field_data['old'] != $field_data['new']) {
        $td_class = emailskin_style('table.email_table.bordered tr.row_red td');
    } else {
        $td_class = emailskin_style('table.email_table.bordered td');
    }
    echo '<tr><th' . emailskin_style('table.email_table.bordered th') . '>' . T_($field_data['title']) . '</th>' . '<td' . $td_class . '>' . ($field_data['old'] == '' ? '&nbsp;' : $field_data['old']) . '</td>' . '<td' . $td_class . '>' . ($field_data['new'] == '' ? '&nbsp;' : $field_data['new']) . '</td></tr>' . "\n";
}
echo '</table>' . "\n";
$UserCache =& get_UserCache();
if ($User =& $UserCache->get_by_ID($params['user_ID'], false, false)) {
    $duplicated_files_message = '';
    if ($params['new_avatar_upload']) {
        // Get warning message about duplicated files when any new profile picture has been uploaded
        $FileCache =& get_FileCache();
        $new_File =& $FileCache->get_by_ID($params['new_avatar_upload']);
        $duplicated_files_message = $new_File->get_duplicated_files_message(array('message' => '<p' . emailskin_style('.p') . '><b' . emailskin_style('.important') . '>' . T_('WARNING: the same profile picture is used by these other users: %s.') . '</b></p>' . "\n", 'use_style' => true));
    }
    if ($params['avatar_changed']) {
        // If profile pictre has been changed
        echo '<p' . emailskin_style('.p') . '>' . T_('The main profile picture was changed to:') . '</p>' . "\n";
        echo '<p' . emailskin_style('.p') . '>' . $User->get_avatar_File()->get_tag('', '', '', '', 'fit-320x320', 'original', '', '', '', '', '', '#', '', 1, 'none') . '</p>' . "\n";
    } elseif ($params['new_avatar_upload']) {
        // Display the newly uploaded file only if it was not set as main profile picture
        echo '<p' . emailskin_style('.p') . '>' . T_('A new profile picture file was uploaded:') . '</p>' . "\n";
        echo '<p' . emailskin_style('.p') . '>' . $new_File->get_tag('', '', '', '', 'fit-320x320', 'original', '', '', '', '', '', '#', '', 1, 'none') . '</p>' . "\n";
    }
    // Display warning message about duplicated files
    echo $duplicated_files_message;
    // User's pictures:
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:account_changed.html.php


示例4: add_link

 /**
  * Add new link to owner Item
  *
  * @param integer file ID
  * @param integer link position ( 'teaser', 'teaserperm', 'teaserlink', 'aftermore', 'inline', 'fallback' )
  * @param int order of the link
  * @param boolean true to update owner last touched timestamp after link was created, false otherwise
  * @return integer|boolean Link ID on success, false otherwise
  */
 function add_link($file_ID, $position = NULL, $order = 1, $update_owner = true)
 {
     if (is_null($position)) {
         // Use default link position
         $position = $this->get_default_position($file_ID);
     }
     $edited_Link = new Link();
     $edited_Link->set('itm_ID', $this->Item->ID);
     $edited_Link->set('file_ID', $file_ID);
     $edited_Link->set('position', $position);
     $edited_Link->set('order', $order);
     if ($edited_Link->dbinsert()) {
         // New link was added to the item, invalidate blog's media BlockCache
         BlockCache::invalidate_key('media_coll_ID', $this->Item->get_blog_ID());
         $FileCache =& get_FileCache();
         $File = $FileCache->get_by_ID($file_ID, false, false);
         $file_name = empty($File) ? '' : $File->get_name();
         syslog_insert(sprintf('File %s was linked to %s with ID=%s', '<b>' . $file_name . '</b>', $this->type, $this->link_Object->ID), 'info', 'file', $file_ID);
         if ($update_owner) {
             // Update last touched date of the Item
             $this->update_last_touched_date();
         }
         // Reset the Links
         $this->Links = NULL;
         $this->load_Links();
         return $edited_Link->ID;
     }
     return false;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:38,代码来源:_linkitem.class.php


示例5: get_attachment_FileList

 /**
  * Get list of attached files
  * 
  * INNER JOIN on files ensures we only get back file links
  * 
  * @param integer Limit max result
  * @param string Restrict to files/images linked to a specific position.
  *               Position can be 'teaser'|'aftermore'|'inline'
  *               Use comma as separator
  * @param string order by
  * @return DataObjectList2 on success or NULL if no linked files found
  */
 function get_attachment_FileList($limit = 1000, $position = NULL, $order = 'link_ID')
 {
     if (!isset($GLOBALS['files_Module'])) {
         return NULL;
     }
     load_class('_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2');
     $FileCache =& get_FileCache();
     $FileList = new DataObjectList2($FileCache);
     // IN FUNC
     $SQL = new SQL();
     $SQL->SELECT('file_ID, file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc, link_ID');
     $SQL->FROM('T_links INNER JOIN T_files ON link_file_ID = file_ID');
     $SQL->WHERE($this->get_where_condition());
     if (!empty($position)) {
         global $DB;
         $position = explode(',', $position);
         $SQL->WHERE_and('link_position IN ( ' . $DB->quote($position) . ' )');
     }
     //$SQL->ORDER_BY( $order );
     $SQL->ORDER_BY('link_order');
     $SQL->LIMIT($limit);
     $FileList->sql = $SQL->get();
     $FileList->query(false, false, false, 'get_attachment_FileList');
     if ($FileList->result_num_rows == 0) {
         // Nothing found
         $FileList = NULL;
     }
     return $FileList;
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:41,代码来源:_linkowner.class.php


示例6: _wp_mw_newmediaobject


//.........这里部分代码省略.........
    $filename = array_pop($filepath_parts);
    logIO('Original file name: ' . $filename);
    // Validate and sanitize filename
    if ($error_filename = process_filename($filename, true)) {
        return xmlrpcs_resperror(5, $error_filename);
    }
    logIO('Sanitized file name: ' . $filename);
    // Check valid path parts:
    $rds_subpath = '';
    foreach ($filepath_parts as $filepath_part) {
        if (empty($filepath_part) || $filepath_part == '.') {
            // self ref not useful
            continue;
        }
        if ($error = validate_dirname($filepath_part)) {
            // invalid relative path:
            logIO($error);
            return xmlrpcs_resperror(6, $error);
        }
        $rds_subpath .= $filepath_part . '/';
    }
    logIO('Subpath: ' . $rds_subpath);
    // Create temporary file and insert contents into it.
    $tmpfile_name = tempnam(sys_get_temp_dir(), 'fmupload');
    if ($tmpfile_name) {
        if (save_to_file($data, $tmpfile_name, 'wb')) {
            $image_info = @getimagesize($tmpfile_name);
        } else {
            return xmlrpcs_resperror(13, 'Error while writing to temp file.');
        }
    }
    if (!empty($image_info)) {
        // This is an image file, let's check mimetype and correct extension
        if ($image_info['mime'] != $file_mimetype) {
            // Invalid file type
            $FiletypeCache =& get_FiletypeCache();
            // Get correct file type based on mime type
            $correct_Filetype = $FiletypeCache->get_by_mimetype($image_info['mime'], false, false);
            $file_mimetype = $image_info['mime'];
            // Check if file type is known by us, and if it is allowed for upload.
            // If we don't know this file type or if it isn't allowed we don't change the extension! The current extension is allowed for sure.
            if ($correct_Filetype && $correct_Filetype->is_allowed()) {
                // A FileType with the given mime type exists in database and it is an allowed file type for current User
                // The "correct" extension is a plausible one, proceed...
                $correct_extension = array_shift($correct_Filetype->get_extensions());
                $path_info = pathinfo($filename);
                $current_extension = $path_info['extension'];
                // change file extension to the correct extension, but only if the correct extension is not restricted, this is an extra security check!
                if (strtolower($current_extension) != strtolower($correct_extension) && !in_array($correct_extension, $force_upload_forbiddenext)) {
                    // change the file extension to the correct extension
                    $old_filename = $filename;
                    $filename = $path_info['filename'] . '.' . $correct_extension;
                }
            }
        }
    }
    // Get File object for requested target location:
    $FileCache =& get_FileCache();
    $newFile =& $FileCache->get_by_root_and_path($fm_FileRoot->type, $fm_FileRoot->in_type_ID, trailing_slash($rds_subpath) . $filename, true);
    if ($newFile->exists()) {
        if ($overwrite && $newFile->unlink()) {
            // OK, file deleted
            // Delete thumb caches from old location:
            logIO('Old file deleted');
            $newFile->rm_cache();
        } else {
            return xmlrpcs_resperror(8, sprintf(T_('The file &laquo;%s&raquo; already exists.'), $filename));
        }
    }
    // Trigger plugin event
    if ($Plugins->trigger_event_first_false('AfterFileUpload', array('File' => &$newFile, 'name' => &$filename, 'type' => &$file_mimetype, 'tmp_name' => &$tmpfile_name, 'size' => &$filesize))) {
        // Plugin returned 'false'.
        // Abort upload for this file:
        @unlink($tmpfile_name);
        return xmlrpcs_resperror(16, 'File upload aborted by a plugin.');
    }
    if (!mkdir_r($newFile->get_dir())) {
        // Dir didn't already exist and could not be created
        return xmlrpcs_resperror(9, 'Error creating sub directories: ' . $newFile->get_rdfs_rel_path());
    }
    if (!@rename($tmpfile_name, $newFile->get_full_path())) {
        return xmlrpcs_resperror(13, 'Error while writing to file.');
    }
    // chmod the file
    $newFile->chmod();
    // Initializes file properties (type, size, perms...)
    $newFile->load_properties();
    // Load meta data AND MAKE SURE IT IS CREATED IN DB:
    $newFile->meta == 'unknown';
    $newFile->load_meta(true);
    // Resize and rotate
    logIO('Running file post-processing (resize and rotate)...');
    prepare_uploaded_files(array($newFile));
    logIO('Done');
    $url = $newFile->get_url();
    logIO('URL of new file: ' . $url);
    $struct = new xmlrpcval(array('file' => new xmlrpcval($filename, 'string'), 'url' => new xmlrpcval($url, 'string'), 'type' => new xmlrpcval($file_mimetype, 'string')), 'struct');
    logIO('OK.');
    return new xmlrpcresp($struct);
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_xmlrpcs.funcs.php


示例7: display

    /**
     * Display the widget!
     *
     * @param array MUST contain at least the basic display params
     */
    function display($params)
    {
        global $localtimenow, $DB, $Blog;
        $this->init_display($params);
        $blog_ID = intval($this->disp_params['blog_ID']);
        if (empty($blog_ID)) {
            // Use current blog by default
            $blog_ID = $Blog->ID;
        }
        $BlogCache =& get_BlogCache();
        if (!$BlogCache->get_by_ID($blog_ID, false, false)) {
            // No blog exists
            return;
        }
        // Display photos:
        // TODO: permissions, complete statuses...
        // TODO: A FileList object based on ItemListLight but adding File data into the query?
        //          overriding ItemListLigth::query() for starters ;)
        // Init caches
        $FileCache =& get_FileCache();
        $ItemCache =& get_ItemCache();
        // Query list of files and posts fields:
        // Note: We use ItemQuery to get attachments from all posts which should be visible ( even in case of aggregate blogs )
        $ItemQuery = new ItemQuery($ItemCache->dbtablename, $ItemCache->dbprefix, $ItemCache->dbIDname);
        $ItemQuery->SELECT('post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_canonical_slug_ID,
									post_tiny_slug_ID, post_ityp_ID, post_title, post_excerpt, post_url, file_ID, file_type,
									file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc, file_path_hash');
        $ItemQuery->FROM_add('INNER JOIN T_links ON post_ID = link_itm_ID');
        $ItemQuery->FROM_add('INNER JOIN T_files ON link_file_ID = file_ID');
        $ItemQuery->where_chapter($blog_ID);
        if ($this->disp_params['item_visibility'] == 'public') {
            // Get images only of the public items
            $ItemQuery->where_visibility(array('published'));
        } else {
            // Get image of all available posts for current user
            $ItemQuery->where_visibility(NULL);
        }
        $ItemQuery->WHERE_and('( file_type = "image" ) OR ( file_type IS NULL )');
        $ItemQuery->WHERE_and('post_datestart <= \'' . remove_seconds($localtimenow) . '\'');
        $ItemQuery->WHERE_and('link_position != "cover"');
        if (!empty($this->disp_params['item_type'])) {
            // Get items only with specified type
            $ItemQuery->WHERE_and('post_ityp_ID = ' . intval($this->disp_params['item_type']));
        }
        $ItemQuery->GROUP_BY('link_ID');
        // fp> TODO: because no way of getting images only, we get 4 times more data than requested and hope that 25% at least will be images :/
        // asimo> This was updated and we get images and those files where we don't know the file type yet. Now we get 2 times more data than requested.
        // Maybe it would be good to get only the requested amount of files, because after a very short period the file types will be set for all images.
        $ItemQuery->LIMIT(intval($this->disp_params['limit']) * 2);
        $ItemQuery->ORDER_BY(gen_order_clause($this->disp_params['order_by'], $this->disp_params['order_dir'], 'post_', 'post_ID ' . $this->disp_params['order_dir'] . ', link_ID'));
        // Init FileList with the above defined query
        $FileList = new DataObjectList2($FileCache);
        $FileList->sql = $ItemQuery->get();
        $FileList->query(false, false, false, 'Media index widget');
        $layout = $this->disp_params['thumb_layout'];
        $nb_cols = $this->disp_params['grid_nb_cols'];
        $count = 0;
        $r = '';
        /**
         * @var File
         */
        while ($File =& $FileList->get_next()) {
            if ($count >= $this->disp_params['limit']) {
                // We have enough images already!
                break;
            }
            if (!$File->is_image()) {
                // Skip anything that is not an image
                // Only images are selected or those files where we don't know the file type yet.
                // This check is only for those files where we don't know the filte type. The file type will be set during the check.
                continue;
            }
            if ($layout == 'grid') {
                // Grid layout
                if ($count % $nb_cols == 0) {
                    $r .= $this->disp_params['grid_colstart'];
                }
                $r .= $this->disp_params['grid_cellstart'];
            } elseif ($layout == 'flow') {
                // Flow block layout
                $r .= $this->disp_params['flow_block_start'];
            } else {
                // List layout
                $r .= $this->disp_params['item_start'];
            }
            // 1/ Hack a dirty permalink( will redirect to canonical):
            // $link = url_add_param( $Blog->get('url'), 'p='.$post_ID );
            // 2/ Hack a link to the right "page". Very daring!!
            // $link = url_add_param( $Blog->get('url'), 'paged='.$count );
            // 3/ Instantiate a light object in order to get permamnent url:
            $ItemLight = new ItemLight($FileList->get_row_by_idx($FileList->current_idx - 1));
            // index had already been incremented
            $r .= '<a href="' . $ItemLight->get_permanent_url() . '">';
            // Generate the IMG THUMBNAIL tag with all the alt, title and desc if available
            $r .= $File->get_thumb_imgtag($this->disp_params['thumb_size'], '', '', $ItemLight->title);
//.........这里部分代码省略.........
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_coll_media_index.widget.php


示例8: content

 /**
  * Template function: display content of comment
  *
  * @param string Output format, see {@link format_to_output()}
  * @param boolean Add ban url action icon after each url or not
  * @param boolean show comment attachments
  * @param array attachment display params
  */
 function content($format = 'htmlbody', $ban_urls = false, $show_attachments = true, $params = array())
 {
     global $current_User;
     global $Plugins;
     // Make sure we are not missing any param:
     $params = array_merge(array('before_image' => '<figure class="evo_image_block">', 'before_image_legend' => '<figcaption class="evo_image_legend">', 'after_image_legend' => '</figcaption>', 'after_image' => '</figure>', 'image_size' => 'fit-400x320', 'image_class' => '', 'image_text' => '', 'attachments_mode' => 'read', 'attachments_view_text' => ''), $params);
     $attachments = array();
     if ($show_attachments) {
         if (empty($this->ID) && isset($this->checked_attachments)) {
             // PREVIEW
             $attachment_ids = explode(',', $this->checked_attachments);
             $FileCache =& get_FileCache();
             foreach ($attachment_ids as $ID) {
                 $File = $FileCache->get_by_ID($ID, false, false);
                 if ($File != NULL) {
                     $attachments[] = $File;
                 }
             }
         } else {
             // Get all Links
             $LinkOwner = new LinkComment($this);
             $attachments =& $LinkOwner->get_Links();
         }
     }
     $images_above_content = '';
     $images_below_content = '';
     foreach ($attachments as $index => $attachment) {
         if (!empty($this->ID)) {
             // Normal mode when comment exists in DB (NOT PREVIEW mode)
             $Link = $attachment;
             $link_position = $Link->get('position');
             $params['Link'] = $Link;
             $attachment = $attachment->get_File();
         } else {
             // Set default position for preview files
             $link_position = 'aftermore';
         }
         $File = $attachment;
         if (empty($File)) {
             // File object doesn't exist in DB
             global $Debuglog;
             $Debuglog->add(sprintf('File object linked to comment #%d does not exist in DB!', $this->ID), array('error', 'files'));
             continue;
         }
         if (!$File->exists()) {
             // File doesn't exist on the disk
             global $Debuglog;
             $Debuglog->add(sprintf('File linked to comment #%d does not exist (%s)!', $this->ID, $File->get_full_path()), array('error', 'files'));
             continue;
         }
         $r = '';
         $params['File'] = $File;
         $params['Comment'] = $this;
         $params['data'] =& $r;
         $temp_params = $params;
         foreach ($params as $param_key => $param_value) {
             // Pass all params by reference, in order to give possibility to modify them by plugin
             // So plugins can add some data before/after image tag (E.g. used by infodots plugin)
             $params[$param_key] =& $params[$param_key];
         }
         if (count($Plugins->trigger_event_first_true('RenderCommentAttachment', $params)) != 0) {
             // File was processed by plugin
             if ($link_position == 'teaser') {
                 // Image should be displayed above content
                 $images_above_content .= $r;
             } else {
                 // Image should be displayed below content
                 $images_below_content .= $r;
             }
             unset($attachments[$index]);
             continue;
         }
         if ($File->is_image()) {
             // File is image
             if ($params['attachments_mode'] == 'view') {
                 // Only preview attachments
                 $image_link_rel = '';
                 $image_link_to = '';
             } else {
                 // Read attachments
                 $image_link_rel = 'lightbox[c' . $this->ID . ']';
                 $image_link_to = 'original';
             }
             if (empty($this->ID)) {
                 // PREVIEW mode
                 $r = $File->get_tag($params['before_image'], $params['before_image_legend'], $params['after_image_legend'], $params['after_image'], $params['image_size'], $image_link_to, T_('Posted by ') . $this->get_author_name(), $image_link_rel, $params['image_class'], '', '', '#');
             } else {
                 $r = $Link->get_tag(array_merge(array('image_link_to' => $image_link_to, 'image_link_title' => T_('Posted by ') . $this->get_author_name(), 'image_link_rel' => $image_link_rel), $params));
             }
             if ($link_position == 'teaser') {
                 // Image should be displayed above content
                 $images_above_content .= $r;
//.........这里部分代码省略.........
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_comment.class.php


示例9: wpxml_import


//.........这里部分代码省略.........
            $SQL->FROM('T_items__itemtag');
            $SQL->WHERE('itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
            $old_tags_this_blog = array_unique($DB->get_col($SQL->get()));
            if (!empty($old_tags_this_blog)) {
                // Get tags from other blogs
                $SQL = new SQL();
                $SQL->SELECT('itag_tag_ID');
                $SQL->FROM('T_items__itemtag');
                $SQL->WHERE('itag_itm_ID NOT IN ( ' . implode(', ', $old_posts) . ' )');
                $old_tags_other_blogs = array_unique($DB->get_col($SQL->get()));
                $old_tags_other_blogs_sql = !empty($old_tags_other_blogs) ? ' AND tag_ID NOT IN ( ' . implode(', ', $old_tags_other_blogs) . ' )' : '';
                // Remove the tags that are no longer used
                $DB->query('DELETE FROM T_items__tag
					WHERE tag_ID IN ( ' . implode(', ', $old_tags_this_blog) . ' )' . $old_tags_other_blogs_sql);
            }
            // Remove the links of tags with posts
            $DB->query('DELETE FROM T_items__itemtag WHERE itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
        }
        echo T_('OK') . '<br />';
        if ($delete_files) {
            // Delete the files
            echo T_('Removing the files... ');
            if (!empty($deleted_file_IDs)) {
                // Commit the DB changes before files deleting
                $DB->commit();
                // Get the deleted file IDs that are linked to other objects
                $SQL = new SQL();
                $SQL->SELECT('DISTINCT link_file_ID');
                $SQL->FROM('T_links');
                $SQL->WHERE('link_file_ID IN ( ' . implode(', ', $deleted_file_IDs) . ' )');
                $linked_file_IDs = $DB->get_col($SQL->get());
                // We can delete only the files that are NOT linked to other objects
                $deleted_file_IDs = array_diff($deleted_file_IDs, $linked_file_IDs);
                $FileCache =& get_FileCache();
                foreach ($deleted_file_IDs as $deleted_file_ID) {
                    if (!($deleted_File =& $FileCache->get_by_ID($deleted_file_ID, false, false))) {
                        // Incorrect file ID
                        echo '<p class="red">' . sprintf(T_('No file #%s found in DB. It cannot be deleted.'), $deleted_file_ID) . '</p>';
                    }
                    if (!$deleted_File->unlink()) {
                        // No permission to delete file
                        echo '<p class="red">' . sprintf(T_('Could not delete the file &laquo;%s&raquo;.'), $deleted_File->get_full_path()) . '</p>';
                    }
                    // Clear cache to save memory
                    $FileCache->clear();
                }
                // Start new transaction for the data inserting
                $DB->begin();
            }
            echo T_('OK') . '<br />';
        }
        echo '<br />';
    }
    /* Import authors */
    $authors = array();
    $authors_IDs = array();
    if (isset($xml_data['authors']) && count($xml_data['authors']) > 0) {
        global $Settings, $UserSettings;
        echo T_('Importing the users... ');
        evo_flush();
        // Get existing users
        $SQL = new SQL();
        $SQL->SELECT('user_login, user_ID');
        $SQL->FROM('T_users');
        $existing_users = $DB->get_assoc($SQL->get());
        $authors_count = 0;
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:67,代码来源:_wp.funcs.php


示例10: load_meta

 /**
  * Attempt to load meta data for all files in the list.
  *
  * Will attempt only once per file and cache the result.
  */
 function load_meta()
 {
     global $DB, $Debuglog;
     $to_load = array();
     for ($i = 0; $i < count($this->_entries); $i++) {
         // For each file:
         $loop_File =& $this->_entries[$i];
         // echo '<br>'.$loop_File->get_full_path();
         if ($loop_File->meta != 'unknown') {
             // We have already loaded meta data:
             continue;
         }
         $to_load[] = $DB->quote(md5($this->_FileRoot->type . $this->_FileRoot->in_type_ID . $loop_File->get_rdfp_rel_path(), true));
     }
     if (count($to_load)) {
         // We have something to load...
         /**
          * @var FileCache
          */
         $FileCache =& get_FileCache();
         $rows = $DB->get_results("\n\t\t\t\tSELECT *\n\t\t\t\t  FROM T_files\n\t\t\t\t WHERE file_path_hash IN (" . implode(',', $to_load) . ")", OBJECT, 'Load FileList meta data');
         if (count($rows)) {
             // Go through rows of loaded meta data...
             foreach ($rows as $row) {
                 // Retrieve matching File object:
                 /**
                  * @var File
                  */
                 $loop_File =& $FileCache->get_by_root_and_path($row->file_root_type, $row->file_root_ID, $row->file_path);
                 // Associate meta data to File object:
                 $loop_File->load_meta(false, $row);
             }
         }
     }
     // For all Files that still have no meta data, memorize that we could not find any meta data
     for ($i = 0; $i < count($this->_entries); $i++) {
         // For each file:
         $loop_File =& $this->_entries[$i];
         if ($loop_File->meta == 'unknown') {
             $loop_File->meta = 'notfound';
         }
     }
     // Has sth been loaded?
     return count($to_load) && count($rows);
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:50,代码来源:_filelist.class.php


示例11: get_duplicated_files_message

 /**
  * Get message if the duplicates exist for this file
  *
  * @param array Params
  * @return string Message text
  */
 function get_duplicated_files_message($params = array())
 {
     $params = array_merge(array('message' => '%s', 'file_type' => 'image', 'root_type' => 'user', 'root_ID' => NULL, 'link_to' => 'user', 'use_style' => false), $params);
     // Find the duplicated files
     $duplicated_file_IDs = $this->get_duplicated_files($params);
     if (empty($duplicated_file_IDs)) {
         // No duplicates
         return false;
     }
     $FileCache =& get_FileCache();
     $duplicated_files = array();
     foreach ($duplicated_file_IDs as $file_ID => $file_root_ID) {
         if (!($duplicated_File =& $FileCache->get_by_ID($file_ID, false, false))) {
             // Broken file object
             continue;
         }
         if ($params['link_to'] == 'user') {
             // Link to profile picture edit form
             global $admin_url;
             $UserCache =& get_UserCache();
             $User =& $UserCache->get_by_ID($file_root_ID, false, false);
             $link_text = $User ? $User->get_colored_login(array('use_style' => $params['use_style'])) : T_('Deleted user');
             $link_class = $User ? $User->get_gender_class() : 'user';
             $link_url = $admin_url . '?ctrl=user&amp;user_tab=avatar&amp;user_ID=' . $file_root_ID;
             $duplicated_files[] = '<a href="' . $link_url . '" class="nowrap ' . $link_class . '">' . $duplicated_File->get_tag('', '', '', '', 'crop-top-15x15', '', '', 'lightbox[d' . $this->ID . ']', 'avatar_before_login') . ' ' . $link_text . '</a>';
         } else {
             // Default link
             $duplicated_files[] = $duplicated_File->get_tag('', '', '', '', 'crop-top-15x15', 'original', '', 'lightbox[d' . $this->ID . ']');
         }
     }
     return sprintf($params['message'], implode(', ', $duplicated_files));
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:38,代码来源:_file.class.php


示例12: get_gallery_images

 function get_gallery_images($limit = 1000, $order = '')
 {
     if ($filenames = $this->get_directory_files('relative')) {
         $FileCache =& get_FileCache();
         switch (strtoupper($order)) {
             case 'ASC':
                 sort($filenames);
                 break;
             case 'DESC':
                 rsort($filenames);
                 break;
             case 'RAND':
                 shuffle($filenames);
                 break;
         }
         $i = 1;
         foreach ($filenames as $filename) {
             if ($i > $limit) {
                 // We've got enough images
                 break;
             }
             /*
             sam2kb> TODO: we may need to filter files by extension first, it doesn't make sence
             		to query the database for every single .txt or .zip file.
             		The best solution would be to have file MIME type field in DB
             */
             $l_File =& $FileCache->get_by_root_and_path($this->_FileRoot->type, $this->_FileRoot->in_type_ID, $filename);
             $l_File->load_meta();
             if (!$l_File->is_image()) {
                 // Not an image
                 continue;
             }
             $Files[] = $l_File;
             $i++;
         }
         if (!empty($Files)) {
             return $Files;
         }
     }
     return false;
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:41,代码来源:_file.class.php


示例13: syslog_object_link

/**
 * Get a link to object of system log
 *
 * @param string Object type
 * @param integer Object ID
 * @return string
 */
function syslog_object_link($object_type, $object_ID)
{
    global $current_User, $admin_url;
    $link = '';
    if (empty($object_ID)) {
        // Invalid object ID
        return 'Empty object ID';
    }
    switch ($object_type) {
        case 'comment':
            // Link to comment
            $CommentCache =& get_CommentCache();
            if (($Comment =& $CommentCache->get_by_ID($object_ID, false, false)) !== false) {
                if ($current_User->check_perm('comment!CURSTATUS', 'edit', false, $Comment)) {
                    // Current user has permission to edit this comment
                    $Item =& $Comment->get_Item();
                    $link = '<a href="' . $admin_url . '?ctrl=comments&action=edit&comment_ID=' . $Comment->ID . '">' . $Item->title . ' #' . $Comment->ID . '</a>';
                }
            } else {
                // Comment was deleted or ID is incorrect
                $link = 'No comment';
            }
            break;
        case 'item':
            // Link to item
            $ItemCache =& get_ItemCache();
            if (($Item =& $ItemCache->get_by_ID($object_ID, false, false)) !== false) {
                if ($current_User->check_perm('item_post!CURSTATUS', 'edit', false, $Item)) {
                    // Current user has permission to edit this item
                    $link = '<a href="' . $Item->get_edit_url() . '">' . $Item->title . '</a>';
                }
            } else {
                // Item was deleted or ID is incorrect
                $link = 'No item';
            }
            break;
        case 'user':
            // Link to user
            if ($current_User->check_perm('users', 'view')) {
                // Current user has permission to view users
                $UserCache = get_UserCache();
                if (($User =& $UserCache->get_by_ID($object_ID, false, false)) !== false) {
                    // User exists
                    $link = $User->get_identity_link();
                } else {
                    // User was deleted or ID is incorrect
                    $link = 'No user';
                }
            }
            break;
        case 'file':
            // Link to file
            $FileCache =& get_FileCache();
            if (($File =& $FileCache->get_by_ID($object_ID, false, false)) !== false) {
                // File exists
                $link = $File->is_dir() ? '' : $File->get_view_link();
                $link .= ' ' . $File->get_target_icon();
            } else {
                // User was deleted or ID is incorrect
                $link = 'No file';
            }
            break;
    }
    return $link;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:72,代码来源:_syslog_list.view.php


示例14: pbm_process_messages


//.........这里部分代码省略.........
                    if ($hasRelated) {
                        pbm_process_attachments($content, $parsedMIME['Related'], $mediadir, $pbmBlog->get_media_url(), true, 'related');
                    }
                } else {
                    pbm_msg(T_('Unable to access media directory. No attachments processed.'), true);
                }
            } else {
                pbm_msg(T_('Files module is disabled or missing!'), true);
            }
        }
        // CHECK and FORMAT content
        global $Plugins;
        $renderer_params = array('Blog' => &$pbmBlog, 'setting_name' => 'coll_apply_rendering');
        $renderers = $Plugins->validate_renderer_list($Settings->get('eblog_renderers'), $renderer_params);
        pbm_msg('Applying the following text renderers: ' . implode(', ', $renderers));
        // Do some optional filtering on the content
        // Typically stuff that will help the content to validate
        // Useful for code display
        // Will probably be used for validation also
        $Plugins_admin =& get_Plugins_admin();
        $params = array('object_type' => 'Item', 'object_Blog' => &$pbmBlog);
        $Plugins_admin->filter_contents($post_title, $content, $renderers, $params);
        pbm_msg('Filtered post content: <pre style="font-size:10px">' . htmlspecialchars($content) . '</pre>');
        $context = $Settings->get('eblog_html_tag_limit') ? 'commenting' : 'posting';
        $post_title = check_html_sanity($post_title, $context, $pbmUser);
        $content = check_html_sanity($content, $context, $pbmUser);
        global $Messages;
        if ($Messages->has_errors()) {
            // Make it easier for user to find and correct the errors
            pbm_msg("\n" . sprintf(T_('Processing message: %s'), $post_title), true);
            pbm_msg($Messages->get_string(T_('Cannot post, please correct these errors:'), 'error'), true);
            $Messages->clear();
            rmdir_r($tmpDirMIME);
            continue;
        }
        if ($test_mode_on) {
            // Test mode
            pbm_msg('<b class="green">It looks like the post can be successfully saved in the database. However we will not do it in test mode.</b>');
        } else {
            load_class('items/model/_item.class.php', 'Item');
            global $pbm_items, $DB, $localtimenow;
            $post_status = 'published';
            pbm_msg(sprintf('<h4>Saving item "%s" in the database</h4>', $post_title));
            // INSERT NEW POST INTO DB:
            $edited_Item = new Item();
            $edited_Item->set_creator_User($pbmUser);
            $edited_Item->set($edited_Item->lasteditor_field, $pbmUser->ID);
            $edited_Item->set('title', $post_title);
            $edited_Item->set('content', $content);
            $edited_Item->set('datestart', $post_date);
            $edited_Item->set('datemodified', date('Y-m-d H:i:s', $localtimenow));
            $edited_Item->set('main_cat_ID', $main_cat_ID);
            $edited_Item->set('extra_cat_IDs', $extra_cat_IDs);
            $edited_Item->set('status', $post_status);
            $edited_Item->set('locale', $pbmUser->locale);
            $edited_Item->set('renderers', $renderers);
            // INSERT INTO DB:
            $edited_Item->dbinsert('through_email');
            pbm_msg(sprintf('Item created?: ' . (isset($edited_Item->ID) ? 'yes' : 'no')));
            // Execute or schedule notifications & pings:
            $edited_Item->handle_post_processing(true);
            if (!empty($pbm_item_files)) {
                // Attach files
                $FileCache =& get_FileCache();
                $order = 1;
                foreach ($pbm_item_files as $filename) {
                    pbm_msg(sprintf('Saving file "%s" in the database', $fil 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_ItemCache函数代码示例发布时间:2022-05-15
下一篇:
PHP get_CountryCache函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap