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


PHP ElggFile::setFilenameOnFilestore方法代碼示例

本文整理匯總了PHP中ElggFile::setFilenameOnFilestore方法的典型用法代碼示例。如果您正苦於以下問題:PHP ElggFile::setFilenameOnFilestore方法的具體用法?PHP ElggFile::setFilenameOnFilestore怎麽用?PHP ElggFile::setFilenameOnFilestore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ElggFile的用法示例。


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

示例1: ElggBatch

}
/**
 * Convert 'hjfile' to 'file'
 */
$subtypeIdFrom = add_subtype('object', 'hjfile');
$subtypeIdTo = add_subtype('object', 'file');
$dbprefix = elgg_get_config('dbprefix');
$query = "\tUPDATE {$dbprefix}entities e\r\n\t\t\t\tJOIN {$dbprefix}metadata md ON md.entity_guid = e.guid\r\n\t\t\t\tJOIN {$dbprefix}metastrings msn ON msn.id = md.name_id\r\n\t\t\t\tJOIN {$dbprefix}metastrings msv ON msv.id = md.value_id\r\n\t\t\t\tSET e.subtype = {$subtypeIdTo}\r\n\t\t\t\tWHERE e.subtype = {$subtypeIdFrom} AND msn.string = 'handler' AND msv.string = 'hjwall' ";
$wall_files = new ElggBatch('elgg_get_entities_from_metadata', array('types' => 'object', 'subtypes' => 'file', 'metadata_name_value_pairs' => array('name' => 'handler', 'value' => 'hjwall'), 'limit' => false));
foreach ($wall_files as $file) {
    // Regenerate icons
    if ($file->simpletype == 'image') {
        $thumb_sizes = array('tiny' => 16, 'small' => 25, 'medium' => 40, 'large' => 100, 'preview' => 250, 'master' => 500, 'full' => 1024);
        foreach ($thumb_sizes as $ths => $dim) {
            $thumb = new ElggFile();
            $thumb->setFilenameOnFilestore("hjfile/{$file->getGUID()}{$ths}.jpg");
            unlink($thumb->getFilenameOnFilestore());
        }
        $file->icontime = time();
        $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 60, 60, true);
        if ($thumbnail) {
            $thumb = new ElggFile();
            $thumb->setFilename($prefix . "thumb" . $filestorename);
            $thumb->open("write");
            $thumb->write($thumbnail);
            $thumb->close();
            $file->thumbnail = $prefix . "thumb" . $filestorename;
            unset($thumbnail);
        }
        $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 153, 153, true);
        if ($thumbsmall) {
開發者ID:nooshin-mirzadeh,項目名稱:web_2.0_benchmark,代碼行數:31,代碼來源:upgrades.php

示例2: upgrade20140211

 public function upgrade20140211()
 {
     $ia = elgg_set_ignore_access(true);
     /**
      * Wall owner should become the container of the wall post
      * wall_owner relationship should go away
      */
     $wall_posts = new \ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => 'hjwall', 'relationship' => 'wall_owner', 'limit' => false));
     foreach ($wall_posts as $wall_post) {
         $relationships = get_entity_relationships($wall_post->guid, true);
         foreach ($relationships as $relationship) {
             if ($relationship->relationship !== 'wall_owner') {
                 continue;
             }
             if ($relationship->guid_one !== $wall_post->container_guid) {
                 $wall_post->container_guid = $relationship->guid_one;
                 if ($wall_post->save()) {
                     $relationship->delete();
                 }
             }
         }
     }
     /**
      * Convert attachment metadata to 'attached' relationship for entities
      * and 'html' metadata for the rest
      */
     $wall_posts = new \ElggBatch('elgg_get_entities_from_metadata', array('types' => 'object', 'subtypes' => 'hjwall', 'metadata_names' => 'attachment', 'limit' => false));
     foreach ($wall_posts as $wall_post) {
         $attachment = $wall_post->attachment;
         if (is_numeric($attachment) && ($attached_entity = get_entity($attachment))) {
             add_entity_relationship($attached_entity->guid, 'attached', $wall_post->guid);
         } else {
             $wall_post->html = $attachment;
         }
         unset($wall_post->attachment);
     }
     /**
      * Convert 'hjfile' to 'file'
      */
     $subtypeIdFrom = add_subtype('object', 'hjfile');
     $subtypeIdTo = add_subtype('object', 'file');
     $dbprefix = elgg_get_config('dbprefix');
     $query = "\tUPDATE {$dbprefix}entities e\n\t\t\t\tJOIN {$dbprefix}metadata md ON md.entity_guid = e.guid\n\t\t\t\tJOIN {$dbprefix}metastrings msn ON msn.id = md.name_id\n\t\t\t\tJOIN {$dbprefix}metastrings msv ON msv.id = md.value_id\n\t\t\t\tSET e.subtype = {$subtypeIdTo}\n\t\t\t\tWHERE e.subtype = {$subtypeIdFrom} AND msn.string = 'handler' AND msv.string = 'hjwall' ";
     $wall_files = new \ElggBatch('elgg_get_entities_from_metadata', array('types' => 'object', 'subtypes' => 'file', 'metadata_name_value_pairs' => array('name' => 'handler', 'value' => 'hjwall'), 'limit' => false));
     foreach ($wall_files as $file) {
         // Regenerate icons
         if ($file->simpletype == 'image') {
             $thumb_sizes = array('tiny' => 16, 'small' => 25, 'medium' => 40, 'large' => 100, 'preview' => 250, 'master' => 500, 'full' => 1024);
             foreach ($thumb_sizes as $ths => $dim) {
                 $thumb = new ElggFile();
                 $thumb->setFilenameOnFilestore("hjfile/{$file->getGUID()}{$ths}.jpg");
                 unlink($thumb->getFilenameOnFilestore());
             }
             $file->icontime = time();
             $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 60, 60, true);
             if ($thumbnail) {
                 $thumb = new ElggFile();
                 $thumb->setFilename($prefix . "thumb" . $filestorename);
                 $thumb->open("write");
                 $thumb->write($thumbnail);
                 $thumb->close();
                 $file->thumbnail = $prefix . "thumb" . $filestorename;
                 unset($thumbnail);
             }
             $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 153, 153, true);
             if ($thumbsmall) {
                 $thumb->setFilename($prefix . "smallthumb" . $filestorename);
                 $thumb->open("write");
                 $thumb->write($thumbsmall);
                 $thumb->close();
                 $file->smallthumb = $prefix . "smallthumb" . $filestorename;
                 unset($thumbsmall);
             }
             $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false);
             if ($thumblarge) {
                 $thumb->setFilename($prefix . "largethumb" . $filestorename);
                 $thumb->open("write");
                 $thumb->write($thumblarge);
                 $thumb->close();
                 $file->largethumb = $prefix . "largethumb" . $filestorename;
                 unset($thumblarge);
             }
         }
     }
     /**
      * Set file folder guids as plugin setting
      */
     $folders = new \ElggBatch('elgg_get_entities_from_metadata', array('types' => 'object', 'subtypes' => 'hjfilefolder', 'metadata_name_value_pairs' => array('name' => 'handler', 'value' => 'hjwall'), 'limit' => false));
     foreach ($folders as $folder) {
         elgg_set_plugin_user_setting('wall_collection', $folder->guid, $folder->owner_guid, 'hypeWall');
     }
     /**
      * Convert 'hjfilefolder' to 'wall_collection'
      */
     $subtypeIdFrom = add_subtype('object', 'hjfilefolder');
     $subtypeIdTo = add_subtype('object', 'wallcollection');
     $dbprefix = elgg_get_config('dbprefix');
     $query = "\tUPDATE {$dbprefix}entities e\n\t\t\t\tJOIN {$dbprefix}metadata md ON md.entity_guid = e.guid\n\t\t\t\tJOIN {$dbprefix}metastrings msn ON msn.id = md.name_id\n\t\t\t\tJOIN {$dbprefix}metastrings msv ON msv.id = md.value_id\n\t\t\t\tSET e.subtype = {$subtypeIdTo}\n\t\t\t\tWHERE e.subtype = {$subtypeIdFrom} AND msn.string = 'handler' AND msv.string = 'hjwall' ";
     elgg_set_ignore_access($ia);
 }
開發者ID:justangel,項目名稱:hypeWall,代碼行數:100,代碼來源:Upgrades.php


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