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


PHP elgg_strtolower函数代码示例

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


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

示例1: tp_get_watermark_filename

/**
 * Create the watermark image filename
 *
 * @param string $text
 * @param ElggUser $owner
 * @return string
 */
function tp_get_watermark_filename($text, $owner)
{
    $base = elgg_strtolower($text);
    $base = preg_replace("/[^\\w-]+/", "-", $base);
    $base = trim($base, '-');
    $filename = tp_get_img_dir();
    $filename .= elgg_strtolower($owner->username . "_" . $base . "_stamp");
    return $filename;
}
开发者ID:pleio,项目名称:tidypics,代码行数:16,代码来源:watermark.php

示例2: save

 /**
  * Saves uploaded file to ElggFile with given attributes
  *
  * @param array  $attributes New file attributes and metadata
  * @apara string $prefix     Filestore prefix
  * @return \Upload
  */
 public function save(array $attributes = array(), $prefix = self::DEFAULT_FILESTORE_PREFIX)
 {
     $this->error_code = $this->error;
     $this->error = $this->getError();
     $this->filesize = $this->size;
     $this->path = $this->tmp_name;
     $this->mimetype = $this->detectMimeType();
     $this->simpletype = $this->parseSimpleType();
     if (!$this->isSuccessful()) {
         return $this;
     }
     $prefix = trim($prefix, '/');
     if (!$prefix) {
         $prefix = self::DEFAULT_FILESTORE_PREFIX;
     }
     $id = elgg_strtolower(time() . $this->name);
     $filename = implode('/', array($prefix, $id));
     $type = elgg_extract('type', $attributes, 'object');
     $subtype = elgg_extract('subtype', $attributes, 'file');
     $class = get_subtype_class($type, $subtype);
     if (!$class) {
         $class = '\\ElggFile';
     }
     try {
         $filehandler = new $class();
         foreach ($attributes as $key => $value) {
             $filehandler->{$key} = $value;
         }
         $filehandler->setFilename($filename);
         $filehandler->title = $this->name;
         $filehandler->originalfilename = $this->name;
         $filehandler->filesize = $this->size;
         $filehandler->mimetype = $this->mimetype;
         $filehandler->simpletype = $this->simpletype;
         $filehandler->open("write");
         $filehandler->close();
         if ($this->simpletype == 'image') {
             $img = new \hypeJunction\Files\Image($this->tmp_name);
             $img->save($filehandler->getFilenameOnFilestore(), hypeApps()->config->getSrcCompressionOpts());
         } else {
             move_uploaded_file($this->tmp_name, $filehandler->getFilenameOnFilestore());
         }
         if ($filehandler->save()) {
             $this->guid = $filehandler->getGUID();
             $this->file = $filehandler;
         }
     } catch (\Exception $ex) {
         elgg_log($ex->getMessage(), 'ERROR');
         $this->error = elgg_echo('upload:error:unknown');
     }
     return $this;
 }
开发者ID:n8b,项目名称:VMN,代码行数:59,代码来源:Upload.php

示例3: copyGroup

function copyGroup($guid, $name, $parentGroupGuid = null, array $options = null)
{
    $inheritMembers = $_POST['inheritMembers'];
    $inheritFiles = $_POST['inheritFiles'];
    $inheritForums = $_POST['inheritForums'];
    $inheritSubGroups = $_POST['subGroups'];
    if ($options) {
        $inheritMembers = $options['inheritMembers'];
        $inheritFiles = $options['inheritFiles'];
        $inheritForums = $options['inheritForums'];
        $inheritSubGroups = $options['inheritSubGroups'];
    }
    $groupOptions = array('inheritMembers' => $inheritMembers, 'inheritFiles' => $inheritFiles, 'inheritForums' => $inheritForums, 'inheritSubGroups' => $inheritSubGroups);
    //check if a sub-group when parentGroupGuid is null
    if (!isset($parentGroupGuid)) {
        $parentGroup = elgg_get_entities_from_relationship(array("relationship" => "au_subgroup_of", "relationship_guid" => $guid));
        $parentGroupGuid = $parentGroup[0]->guid;
    }
    //get group
    $oldGroup = get_entity($guid);
    //get user
    $user = get_user($oldGroup->owner_guid);
    //create new group
    $newGroup = clone $oldGroup;
    $newGroup->name = $name;
    $newGroup->save();
    //get all categories associated with the group and associate them with the copied group
    $groupCats = elgg_get_entities(array('type' => 'object', 'subtype' => 'hjcategory', 'order_by' => 'e.last_action desc', 'limit' => 40, 'full_view' => false, 'container_guid' => $guid));
    foreach ($groupCats as $groupCat) {
        $newGroupCat = clone $groupCat;
        $newGroupCat->container_guid = $newGroup->guid;
        $newGroupCat->save();
    }
    if ($inheritFiles) {
        //clone files belonging to the old group add add them to their new categories
        $groupFiles = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'order_by' => 'e.last_action desc', 'limit' => 500, 'full_view' => false, 'container_guid' => $guid));
        foreach ($groupFiles as $groupFile) {
            $newGroupFile = clone $groupFile;
            $newGroupFile->container_guid = $newGroup->guid;
            $newGroupFile->access_id = $newGroup->group_acl;
            $date = new DateTime();
            $newTimeStamp = $date->getTimestamp();
            $newGroupFile->time_created = $newTimeStamp;
            $newGroupFile->time_updated = $newTimeStamp;
            $newGroupFile->last_action = $newTimeStamp;
            $newGroupFile->save();
            //copy file over on disk
            $prefix = "file/";
            $filestorename = elgg_strtolower(time() . $newGroupFile->originalfilename);
            $sourceDest = $newGroupFile->getFilenameOnFilestore();
            $newGroupFile->setFilename($prefix . $filestorename);
            $newGroupFile->open("write");
            $newGroupFile->close();
            if (!copy($sourceDest, $newGroupFile->getFilenameOnFilestore())) {
                error_log("couldn't copy");
            }
            //if file is tagged in a category, need to update to reflect copied groups category
            if ($newGroupFile->universal_categories) {
                $categories = elgg_get_entities(array('type' => 'object', 'subtype' => 'hjcategory', 'order_by' => 'e.last_action desc', 'limit' => 40, 'full_view' => false, 'container_guid' => $newGroup->guid));
                $copyCategories = elgg_get_entities_from_relationship(array('relationship' => HYPECATEGORIES_RELATIONSHIP, 'relationship_guid' => $groupFile->guid, 'inverse_relationship' => false, 'limit' => 150));
                foreach ($categories as $category) {
                    foreach ($copyCategories as $c) {
                        if ($category->title == $c->title) {
                            add_entity_relationship($newGroupFile->guid, HYPECATEGORIES_RELATIONSHIP, $category->guid);
                        }
                    }
                }
            }
            //$newGroupFile->save();
        }
        //get all folders associated with the group and associate them with the new copied group
        $groupFolders = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'folder', 'order_by' => 'e.last_action desc', 'limit' => 120, 'full_view' => false, 'container_guid' => $guid, 'metadata_name' => 'parent_guid', 'metadata_value' => 0));
        foreach ($groupFolders as $groupFolder) {
            $newGroupFolder = clone $groupFolder;
            $newGroupFolder->container_guid = $newGroup->guid;
            $newGroupFolder->access_id = $newGroup->group_acl;
            $newGroupFolder->save();
            //get files associated with folder
            $files = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'order_by' => 'e.last_action desc', 'limit' => 500, 'full_view' => false, 'container_guid' => $newGroup->guid));
            $oldFolderFiles = elgg_get_entities_from_relationship(array('relationship' => 'folder_of', 'relationship_guid' => $groupFolder->guid, 'inverse_relationship' => false, 'limit' => 100));
            foreach ($oldFolderFiles as $f) {
                foreach ($files as $file) {
                    if ($file->title == $f->title) {
                        add_entity_relationship($newGroupFolder->guid, 'folder_of', $file->guid);
                    }
                }
            }
            //get sub folders
            $subFolders = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'folder', 'order_by' => 'e.last_action desc', 'limit' => 60, 'full_view' => false, 'container_guid' => $guid, 'metadata_name' => 'parent_guid', 'metadata_value' => $groupFolder->guid));
            foreach ($subFolders as $subFolder) {
                $newSubFolder = clone $subFolder;
                $newSubFolder->container_guid = $newGroup->guid;
                $newSubFolder->access_id = $newGroup->group_acl;
                $newSubFolder->parent_guid = $newGroupFolder->guid;
                $newSubFolder->save();
                $oldSubFolderFiles = elgg_get_entities_from_relationship(array('relationship' => 'folder_of', 'relationship_guid' => $subFolder->guid, 'inverse_relationship' => false, 'limit' => 60));
                foreach ($oldSubFolderFiles as $f) {
                    foreach ($files as $file) {
                        if ($file->title == $f->title) {
                            add_entity_relationship($newSubFolder->guid, 'folder_of', $file->guid);
//.........这里部分代码省略.........
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:101,代码来源:copy.php

示例4: add_submenu_item

                }
                global $CONFIG;
                add_submenu_item(elgg_echo($label), $CONFIG->wwwroot . "pg/search/?tag=" . urlencode($tag) . "&subtype=" . $object_subtype . "&object=" . urlencode($object_type) . "&tagtype=" . urlencode($md_type) . "&owner_guid=" . urlencode($owner_guid));
            }
        }
    }
    add_submenu_item(elgg_echo('all'), $CONFIG->wwwroot . "pg/search/?tag=" . urlencode($tag) . "&owner_guid=" . urlencode($owner_guid));
}
if (empty($objecttype) && empty($subtype)) {
    $title = sprintf(elgg_echo('searchtitle'), $tag);
} else {
    if (empty($objecttype)) {
        $objecttype = 'object';
    }
    $itemtitle = 'item:' . $objecttype;
    if (!empty($subtype)) {
        $itemtitle .= ':' . $subtype;
    }
    $itemtitle = elgg_echo($itemtitle);
    $title = sprintf(elgg_echo('advancedsearchtitle'), $itemtitle, $tag);
}
if (!empty($tag)) {
    $body = "";
    $body .= elgg_view_title($title);
    // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));
    $body .= trigger_plugin_hook('search', '', $tag, "");
    $body .= elgg_view('search/startblurb', array('tag' => $tag));
    $body .= list_entities_from_metadata($md_type, elgg_strtolower($tag), $objecttype, $subtype, $owner_guid_array, 10, false, false);
    $body = elgg_view_layout('two_column_left_sidebar', '', $body);
}
page_draw($title, $body);
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:index.php

示例5: elgg_extract

$list_class = (array) elgg_extract('class', $vars, []);
unset($vars['class']);
$list_class[] = 'elgg-input-checkboxes';
$list_class[] = "elgg-{$vars['align']}";
$id = elgg_extract('id', $vars, '');
unset($vars['id']);
if (is_array($vars['value'])) {
    $values = array_map('elgg_strtolower', $vars['value']);
} else {
    $values = array(elgg_strtolower($vars['value']));
}
$input_vars = $vars;
$input_vars['default'] = false;
if ($vars['name']) {
    $input_vars['name'] = "{$vars['name']}[]";
}
unset($input_vars['align']);
unset($input_vars['options']);
// include a default value so if nothing is checked 0 will be passed.
if ($vars['name'] && $vars['default'] !== false) {
    echo elgg_view('input/hidden', ['name' => $vars['name'], 'value' => $default]);
}
$checkboxes = '';
foreach ($vars['options'] as $label => $value) {
    $input_vars['checked'] = in_array(elgg_strtolower($value), $values);
    $input_vars['value'] = $value;
    $input_vars['label'] = $label;
    $input = elgg_view('input/checkbox', $input_vars);
    $checkboxes .= "<li>{$input}</li>";
}
echo elgg_format_element('ul', ['class' => $list_class, 'id' => $id], $checkboxes);
开发者ID:thehereward,项目名称:Elgg,代码行数:31,代码来源:checkboxes.php

示例6: search_get_highlighted_relevant_substrings

/**
 * Return a string with highlighted matched queries and relevant context
 * Determins context based upon occurance and distance of words with each other.
 *
 * @param string $haystack
 * @param string $query
 * @param int $min_match_context = 30
 * @param int $max_length = 300
 * @return string
 */
function search_get_highlighted_relevant_substrings($haystack, $query, $min_match_context = 30, $max_length = 300)
{
    global $CONFIG;
    $haystack = strip_tags($haystack);
    $haystack_length = elgg_strlen($haystack);
    $haystack_lc = elgg_strtolower($haystack);
    $words = search_remove_ignored_words($query, 'array');
    // if haystack < $max_length return the entire haystack w/formatting immediately
    if ($haystack_length <= $max_length) {
        $return = search_highlight_words($words, $haystack);
        return $return;
    }
    // get the starting positions and lengths for all matching words
    $starts = array();
    $lengths = array();
    foreach ($words as $word) {
        $word = elgg_strtolower($word);
        $count = elgg_substr_count($haystack_lc, $word);
        $word_len = elgg_strlen($word);
        // find the start positions for the words
        if ($count > 1) {
            $offset = 0;
            while (FALSE !== ($pos = elgg_strpos($haystack_lc, $word, $offset))) {
                $start = $pos - $min_match_context > 0 ? $pos - $min_match_context : 0;
                $starts[] = $start;
                $stop = $pos + $word_len + $min_match_context;
                $lengths[] = $stop - $start;
                $offset += $pos + $word_len;
            }
        } else {
            $pos = elgg_strpos($haystack_lc, $word);
            $start = $pos - $min_match_context > 0 ? $pos - $min_match_context : 0;
            $starts[] = $start;
            $stop = $pos + $word_len + $min_match_context;
            $lengths[] = $stop - $start;
        }
    }
    $offsets = search_consolidate_substrings($starts, $lengths);
    // figure out if we can adjust the offsets and lengths
    // in order to return more context
    $total_length = array_sum($offsets);
    $add_length = 0;
    if ($total_length < $max_length) {
        $add_length = floor(($max_length - $total_length) / count($offsets) / 2);
        $starts = array();
        $lengths = array();
        foreach ($offsets as $offset => $length) {
            $start = $offset - $add_length > 0 ? $offset - $add_length : 0;
            $length = $length + $add_length;
            $starts[] = $start;
            $lengths[] = $length;
        }
        $offsets = search_consolidate_substrings($starts, $lengths);
    }
    // sort by order of string size descending (which is roughly
    // the proximity of matched terms) so we can keep the
    // substrings with terms closest together and discard
    // the others as needed to fit within $max_length.
    arsort($offsets);
    $return_strs = array();
    $total_length = 0;
    foreach ($offsets as $start => $length) {
        $string = trim(elgg_substr($haystack, $start, $length));
        // continue past if adding this substring exceeds max length
        if ($total_length + $length > $max_length) {
            continue;
        }
        $total_length += $length;
        $return_strs[$start] = $string;
    }
    // put the strings in order of occurence
    ksort($return_strs);
    // add ...s where needed
    $return = implode('...', $return_strs);
    if (!array_key_exists(0, $return_strs)) {
        $return = "...{$return}";
    }
    // add to end of string if last substring doesn't hit the end.
    $starts = array_keys($return_strs);
    $last_pos = $starts[count($starts) - 1];
    if ($last_pos + elgg_strlen($return_strs[$last_pos]) < $haystack_length) {
        $return .= '...';
    }
    $return = search_highlight_words($words, $return);
    return $return;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:96,代码来源:start.php

示例7: get_entity

// TODO: ask the user for another group container instead
$container = get_entity($container_guid);
if (!$container) {
    $container_guid = elgg_get_logged_in_user_guid();
}
// create new file object
$file = new ElggFile();
$file->title = $title;
$file->access_id = $access_id;
$file->description = $description;
$file->container_guid = $container_guid;
$file->tags = $tags;
$file->setMimeType("application/vnd.oasis.opendocument.text");
$file->simpletype = "document";
// same naming pattern as in file/actions/file/upload.php
$filestorename = "file/" . elgg_strtolower(time() . $_FILES['upload']['name']);
$file->setFilename($filestorename);
// Open the file to guarantee the directory exists
$file->open("write");
$file->close();
// now put file into destination
move_uploaded_file($_FILES['upload']['tmp_name'], $file->getFilenameOnFilestore());
// create lock
$lock_guid = odt_editor_locking_create_lock($file, $user_guid);
$file->save();
// log success
system_message(elgg_echo("file:saved"));
add_to_river('river/object/file/create', 'create', $user_guid, $file->guid);
// reply to client
$reply = array("file_guid" => $file->guid, "document_url" => elgg_get_site_url() . "file/download/{$file->uid}", "file_name" => $file->getFilename(), "lock_guid" => $lock_guid);
print json_encode($reply);
开发者ID:smellems,项目名称:odt_editor,代码行数:31,代码来源:upload_asnew.php

示例8: file_tools_unzip

/**
 * Unzip an uploaded zip file
 *
 * @param array $file           the $_FILES information
 * @param int   $container_guid the container to put the files/folders under
 * @param int   $parent_guid    the parrent folder
 *
 * @return bool
 */
function file_tools_unzip($file, $container_guid, $parent_guid = 0)
{
    $extracted = false;
    if (!empty($file) && !empty($container_guid)) {
        $allowed_extensions = file_tools_allowed_extensions();
        $zipfile = elgg_extract("tmp_name", $file);
        $container_entity = get_entity($container_guid);
        $access_id = get_input("access_id", false);
        if ($access_id === false) {
            if (!empty($parent_guid) && ($parent_folder = get_entity($parent_guid)) && elgg_instanceof($parent_folder, "object", FILE_TOOLS_SUBTYPE)) {
                $access_id = $parent_folder->access_id;
            } else {
                if (elgg_instanceof($container_entity, "group")) {
                    $access_id = $container_entity->group_acl;
                } else {
                    $access_id = get_default_access($container_entity);
                }
            }
        }
        // open the zip file
        $zip = zip_open($zipfile);
        while ($zip_entry = zip_read($zip)) {
            // open the zip entry
            zip_entry_open($zip, $zip_entry);
            // set some variables
            $zip_entry_name = zip_entry_name($zip_entry);
            $filename = basename($zip_entry_name);
            // check for folder structure
            if (strlen($zip_entry_name) != strlen($filename)) {
                // there is a folder structure, check it and create missing items
                file_tools_create_folders($zip_entry, $container_guid, $parent_guid);
            }
            // extract the folder structure from the zip entry
            $folder_array = explode("/", $zip_entry_name);
            $parent = $parent_guid;
            foreach ($folder_array as $folder) {
                $folder = utf8_encode($folder);
                if ($entity = file_tools_check_foldertitle_exists($folder, $container_guid, $parent)) {
                    $parent = $entity->getGUID();
                } else {
                    if ($folder == end($folder_array)) {
                        $prefix = "file/";
                        $extension_array = explode('.', $folder);
                        $file_extension = end($extension_array);
                        if (in_array(strtolower($file_extension), $allowed_extensions)) {
                            $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                            // create the file
                            $filehandler = new ElggFile();
                            $filehandler->setFilename($prefix . $folder);
                            $filehandler->title = $folder;
                            $filehandler->originalfilename = $folder;
                            $filehandler->owner_guid = elgg_get_logged_in_user_guid();
                            $filehandler->container_guid = $container_guid;
                            $filehandler->access_id = $access_id;
                            $filehandler->open("write");
                            $filehandler->write($buf);
                            $filehandler->close();
                            $mime_type = $filehandler->detectMimeType($filehandler->getFilenameOnFilestore());
                            // hack for Microsoft zipped formats
                            $info = pathinfo($folder);
                            $office_formats = array("docx", "xlsx", "pptx");
                            if ($mime_type == "application/zip" && in_array($info["extension"], $office_formats)) {
                                switch ($info["extension"]) {
                                    case "docx":
                                        $mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                                        break;
                                    case "xlsx":
                                        $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                                        break;
                                    case "pptx":
                                        $mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
                                        break;
                                }
                            }
                            // check for bad ppt detection
                            if ($mime_type == "application/vnd.ms-office" && $info["extension"] == "ppt") {
                                $mime_type = "application/vnd.ms-powerpoint";
                            }
                            $simple_type = file_get_simple_type($mime_type);
                            $filehandler->setMimeType($mime_type);
                            $filehandler->simpletype = $simple_type;
                            if ($simple_type == "image") {
                                $filestorename = elgg_strtolower(time() . $folder);
                                $thumb = new ElggFile();
                                $thumb->owner_guid = elgg_get_logged_in_user_guid();
                                $thumbnail = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 60, 60, true);
                                if ($thumbnail) {
                                    $thumb->setFilename($prefix . "thumb" . $filestorename);
                                    $thumb->open("write");
                                    $thumb->write($thumbnail);
                                    $thumb->close();
//.........这里部分代码省略.........
开发者ID:lorea,项目名称:Hydra-dev,代码行数:101,代码来源:functions.php

示例9: acceptUploadedFile

 /**
  * Writes contents of the uploaded file to an instance of ElggFile
  *
  * @note Note that this function moves the file and populates properties,
  * but does not call ElggFile::save().
  *
  * @note This method will automatically assign a filename on filestore based
  * on the upload time and filename. By default, the file will be written
  * to /file directory on owner's filestore. You can change this directory,
  * by setting 'filestore_prefix' property of the ElggFile instance before
  * calling this method.
  *
  * @param UploadedFile $upload Uploaded file object
  * @return bool 
  */
 public function acceptUploadedFile(UploadedFile $upload)
 {
     if (!$upload->isValid()) {
         return false;
     }
     $old_filestorename = '';
     if ($this->exists()) {
         $old_filestorename = $this->getFilenameOnFilestore();
     }
     $originalfilename = $upload->getClientOriginalName();
     $this->originalfilename = $originalfilename;
     if (empty($this->title)) {
         $this->title = htmlspecialchars($this->originalfilename, ENT_QUOTES, 'UTF-8');
     }
     $this->upload_time = time();
     $prefix = $this->filestore_prefix ?: 'file';
     $prefix = trim($prefix, '/');
     $filename = elgg_strtolower("{$prefix}/{$this->upload_time}{$this->originalfilename}");
     $this->setFilename($filename);
     $this->filestore_prefix = $prefix;
     $hook_params = ['file' => $this, 'upload' => $upload];
     $uploaded = _elgg_services()->hooks->trigger('upload', 'file', $hook_params);
     if ($uploaded !== true && $uploaded !== false) {
         $filestorename = $this->getFilenameOnFilestore();
         try {
             $uploaded = $upload->move(pathinfo($filestorename, PATHINFO_DIRNAME), pathinfo($filestorename, PATHINFO_BASENAME));
         } catch (FileException $ex) {
             _elgg_services()->logger->error($ex->getMessage());
             $uploaded = false;
         }
     }
     if ($uploaded) {
         if ($old_filestorename && $old_filestorename != $this->getFilenameOnFilestore()) {
             // remove old file
             unlink($old_filestorename);
         }
         $mime_type = $this->detectMimeType(null, $upload->getClientMimeType());
         $this->setMimeType($mime_type);
         $this->simpletype = elgg_get_file_simple_type($mime_type);
         _elgg_services()->events->triggerAfter('upload', 'file', $this);
         return true;
     }
     return false;
 }
开发者ID:elgg,项目名称:elgg,代码行数:59,代码来源:ElggFile.php

示例10: hj_inbox_send_message

/**
 * Send a message to specified recipients
 *
 * @param int $sender_guid GUID of the sender entity
 * @param array $recipient_guids An array of recipient GUIDs
 * @param str $subject Subject of the message
 * @param str $message Body of the message
 * @param str $message_type Type of the message
 * @param array $params Additional parameters, e.g. 'message_hash', 'attachments'
 * @return boolean
 */
function hj_inbox_send_message($sender_guid, $recipient_guids, $subject = '', $message = '', $message_type = '', array $params = array())
{
    $ia = elgg_set_ignore_access();
    if (!is_array($recipient_guids)) {
        $recipient_guids = array($recipient_guids);
    }
    if (isset($params['message_hash'])) {
        $message_hash = elgg_extract('message_hash', $params);
    }
    if (isset($params['attachments'])) {
        $attachments = elgg_extract('attachments', $params);
    }
    $user_guids = $recipient_guids;
    $user_guids[] = $sender_guid;
    sort($user_guids);
    if (!$message_hash) {
        $title = strtolower($subject);
        $title = trim(str_replace('re:', '', $title));
        $message_hash = sha1(implode(':', $user_guids) . $title);
    }
    $acl_hash = sha1(implode(':', $user_guids));
    $dbprefix = elgg_get_config('dbprefix');
    $query = "SELECT * FROM {$dbprefix}access_collections WHERE name = '{$acl_hash}'";
    $collection = get_data_row($query);
    //error_log(print_r($collection, true));
    $acl_id = $collection->id;
    if (!$acl_id) {
        $site = elgg_get_site_entity();
        $acl_id = create_access_collection($acl_hash, $site->guid);
        update_access_collection($acl_id, $user_guids);
    }
    //error_log($acl_id);
    $message_sent = new ElggObject();
    $message_sent->subtype = "messages";
    $message_sent->owner_guid = $sender_guid;
    $message_sent->container_guid = $sender_guid;
    $message_sent->access_id = ACCESS_PRIVATE;
    $message_sent->title = $subject;
    $message_sent->description = $message;
    $message_sent->toId = $recipient_guids;
    // the users receiving the message
    $message_sent->fromId = $sender_guid;
    // the user sending the message
    $message_sent->readYet = 1;
    // this is a toggle between 0 / 1 (1 = read)
    $message_sent->hiddenFrom = 0;
    // this is used when a user deletes a message in their sentbox, it is a flag
    $message_sent->hiddenTo = 0;
    // this is used when a user deletes a message in their inbox
    $message_sent->msg = 1;
    $message_sent->msgType = $message_type;
    $message_sent->msgHash = $message_hash;
    $message_sent->save();
    if ($attachments) {
        $count = count($attachments['name']);
        for ($i = 0; $i < $count; $i++) {
            if ($attachments['error'][$i] || !$attachments['name'][$i]) {
                continue;
            }
            $name = $attachments['name'][$i];
            $file = new ElggFile();
            $file->container_guid = $message_sent->guid;
            $file->title = $name;
            $file->access_id = (int) $acl_id;
            $prefix = "file/";
            $filestorename = elgg_strtolower(time() . $name);
            $file->setFilename($prefix . $filestorename);
            $file->open("write");
            $file->close();
            move_uploaded_file($attachments['tmp_name'][$i], $file->getFilenameOnFilestore());
            $saved = $file->save();
            if ($saved) {
                $mime_type = ElggFile::detectMimeType($attachments['tmp_name'][$i], $attachments['type'][$i]);
                $info = pathinfo($name);
                $office_formats = array('docx', 'xlsx', 'pptx');
                if ($mime_type == "application/zip" && in_array($info['extension'], $office_formats)) {
                    switch ($info['extension']) {
                        case 'docx':
                            $mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                            break;
                        case 'xlsx':
                            $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                            break;
                        case 'pptx':
                            $mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
                            break;
                    }
                }
                // check for bad ppt detection
//.........这里部分代码省略.........
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:101,代码来源:base.php

示例11: elgg_extract

 */
$additional_class = elgg_extract('class', $vars);
$align = elgg_extract('align', $vars, 'vertical');
$class = "elgg-input-radio elgg-{$align}";
if ($additional_class) {
    $class = " {$additional_class}";
    unset($vars['class']);
}
if (isset($vars['align'])) {
    unset($vars['align']);
}
$options = $vars['options'];
unset($vars['options']);
$value = $vars['value'];
unset($vars['value']);
if ($options && count($options) > 0) {
    echo "<ul class=\"{$class}\">";
    foreach ($options as $label => $option) {
        $vars['checked'] = elgg_strtolower($option) == elgg_strtolower($value);
        $vars['value'] = $option;
        $attributes = elgg_format_attributes($vars);
        // handle indexed array where label is not specified
        // @deprecated 1.8 Remove in 1.9
        if (is_integer($label)) {
            elgg_deprecated_notice('$vars[\'options\'] must be an associative array in input/radio', 1.8);
            $label = $option;
        }
        echo "<li><label><input type=\"radio\" {$attributes} />{$label}</label></li>";
    }
    echo '</ul>';
}
开发者ID:rasul,项目名称:Elgg,代码行数:31,代码来源:radio.php

示例12: saveUploadedFiles

 /**
  * Save uploaded files
  *
  * @param string $input_name Form input name
  * @param array  $attributes File attributes
  * @return ElggFile[]
  */
 protected function saveUploadedFiles($input_name, array $attributes = [])
 {
     $files = [];
     $uploaded_files = $this->getUploadedFiles($input_name);
     $subtype = elgg_extract('subtype', $attributes, 'file', false);
     unset($attributes['subtype']);
     $class = get_subtype_class('object', $subtype);
     if (!$class || !class_exists($class) || !is_subclass_of($class, ElggFile::class)) {
         $class = ElggFile::class;
     }
     foreach ($uploaded_files as $upload) {
         if (!$upload->isValid()) {
             $error = new \stdClass();
             $error->error = elgg_get_friendly_upload_error($upload->getError());
             $files[] = $error;
             continue;
         }
         $file = new $class();
         $file->subtype = $subtype;
         foreach ($attributes as $key => $value) {
             $file->{$key} = $value;
         }
         $old_filestorename = '';
         if ($file->exists()) {
             $old_filestorename = $file->getFilenameOnFilestore();
         }
         $originalfilename = $upload->getClientOriginalName();
         $file->originalfilename = $originalfilename;
         if (empty($file->title)) {
             $file->title = htmlspecialchars($file->originalfilename, ENT_QUOTES, 'UTF-8');
         }
         $file->upload_time = time();
         $prefix = $file->filestore_prefix ?: 'file';
         $prefix = trim($prefix, '/');
         $filename = elgg_strtolower("{$prefix}/{$file->upload_time}{$file->originalfilename}");
         $file->setFilename($filename);
         $file->filestore_prefix = $prefix;
         $hook_params = ['file' => $file, 'upload' => $upload];
         $uploaded = _elgg_services()->hooks->trigger('upload', 'file', $hook_params);
         if ($uploaded !== true && $uploaded !== false) {
             $filestorename = $file->getFilenameOnFilestore();
             try {
                 $uploaded = $upload->move(pathinfo($filestorename, PATHINFO_DIRNAME), pathinfo($filestorename, PATHINFO_BASENAME));
             } catch (FileException $ex) {
                 elgg_log($ex->getMessage(), 'ERROR');
                 $uploaded = false;
             }
         }
         if (!$uploaded) {
             $error = new \stdClass();
             $error->error = elgg_echo('dropzone:file_not_entity');
             $files[] = $error;
             continue;
         }
         if ($old_filestorename && $old_filestorename != $file->getFilenameOnFilestore()) {
             // remove old file
             unlink($old_filestorename);
         }
         $mime_type = $file->detectMimeType(null, $upload->getClientMimeType());
         $file->setMimeType($mime_type);
         $file->simpletype = elgg_get_file_simple_type($mime_type);
         _elgg_services()->events->triggerAfter('upload', 'file', $file);
         if (!$file->save() || !$file->exists()) {
             $file->delete();
             $error = new \stdClass();
             $error->error = elgg_echo('dropzone:file_not_entity');
             $files[] = $error;
             continue;
         }
         if ($file->saveIconFromElggFile($file)) {
             $file->thumbnail = $file->getIcon('small')->getFilename();
             $file->smallthumb = $file->getIcon('medium')->getFilename();
             $file->largethumb = $file->getIcon('large')->getFilename();
         }
         $success = new \stdClass();
         $success->file = $file;
         $files[] = $success;
     }
     return $files;
 }
开发者ID:hypejunction,项目名称:hypedropzone,代码行数:87,代码来源:DropzoneService.php

示例13: hj_framework_handle_multifile_upload

function hj_framework_handle_multifile_upload($user_guid)
{
    if (!empty($_FILES)) {
        $access = elgg_get_ignore_access();
        elgg_set_ignore_access(true);
        $file = $_FILES['Filedata'];
        $filehandler = new hjFile();
        $filehandler->owner_guid = (int) $user_guid;
        $filehandler->container_guid = (int) $user_guid;
        $filehandler->access_id = ACCESS_DEFAULT;
        $filehandler->data_pattern = hj_framework_get_data_pattern('object', 'hjfile');
        $filehandler->title = $file['name'];
        $filehandler->description = '';
        $prefix = "hjfile/";
        $filestorename = elgg_strtolower($file['name']);
        $mime = hj_framework_get_mime_type($file['name']);
        $filehandler->setFilename($prefix . $filestorename);
        $filehandler->setMimeType($mime);
        $filehandler->originalfilename = $file['name'];
        $filehandler->simpletype = hj_framework_get_simple_type($mime);
        $filehandler->filesize = round($file['size'] / (1024 * 1024), 2) . "Mb";
        $filehandler->open("write");
        $filehandler->close();
        move_uploaded_file($file['tmp_name'], $filehandler->getFilenameOnFilestore());
        $file_guid = $filehandler->save();
        hj_framework_set_entity_priority($filehandler);
        elgg_trigger_plugin_hook('hj:framework:file:process', 'object', array('entity' => $filehandler));
        if ($file_guid) {
            $meta_value = $filehandler->getGUID();
        } else {
            $meta_value = $filehandler->getFilenameOnFilestore();
        }
        if ($file_guid && $filehandler->simpletype == "image") {
            $thumb_sizes = hj_framework_get_thumb_sizes();
            foreach ($thumb_sizes as $thumb_type => $thumb_size) {
                $thumbnail = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $thumb_size['w'], $thumb_size['h'], $thumb_size['square'], 0, 0, 0, 0, true);
                if ($thumbnail) {
                    $thumb = new ElggFile();
                    $thumb->setMimeType($file['type']);
                    $thumb->owner_guid = $user_guid;
                    $thumb->setFilename("{$prefix}{$filehandler->getGUID()}{$thumb_type}.jpg");
                    $thumb->open("write");
                    $thumb->write($thumbnail);
                    $thumb->close();
                    $thumb_meta = "{$thumb_type}thumb";
                    $filehandler->{$thumb_meta} = $thumb->getFilename();
                    unset($thumbnail);
                }
            }
        }
        $response = array('status' => 'OK', 'value' => $meta_value);
    } else {
        $response = array('status' => 'FAIL');
    }
    echo json_encode($response);
    elgg_set_ignore_access($access);
    return;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:58,代码来源:deprecated.php

示例14: elgg_echo

 		if ($mem_required > $mem_avail) {
 			array_push($not_uploaded, $sent_file['name']);
 			array_push($error_msgs, elgg_echo('tidypics:image_pixels'));
 			trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING);
 			continue;
 		}
 	} else if ($image_lib == 'ImageMagickPHP') {
 		// haven't been able to determine a limit like there is for GD
 	}
 */
 $mime = "image/jpeg";
 //not sure how to get this from the file if we aren't posting it
 //this will save to users folder in /image/ and organize by photo album
 $prefix = "image/" . $container_guid . "/";
 $file = new ElggFile();
 $filestorename = elgg_strtolower(time() . $name);
 $file->setFilename($prefix . $filestorename . ".jpg");
 //that's all flickr stores so I think this is safe
 $file->setMimeType($mime);
 $file->originalfilename = $name;
 $file->subtype = "image";
 $file->simpletype = "image";
 $file->access_id = $access_id;
 if ($container_guid) {
     $file->container_guid = $container_guid;
 }
 // get the file from flickr and save it locally
 $filename = $file->getFilenameOnFilestore();
 $destination = fopen($filename, "w");
 $source = fopen($photo["url"], "r");
 while ($a = fread($source, 1024)) {
开发者ID:rijojoy,项目名称:MyIceBerg,代码行数:31,代码来源:flickrImportPhotoset1.php

示例15: entityFactory

 /**
  * Create new entities from file uploads
  *
  * @param string $input Name of the file input
  * @return void
  */
 protected static function entityFactory($input)
 {
     if (!isset(self::$config['filestore_prefix'])) {
         $prefix = "file/";
     }
     $uploads = self::$uploads[$input];
     $handled_uploads = array();
     $entities = array();
     foreach ($uploads as $key => $upload) {
         if ($upload->error) {
             $handled_uploads[] = $upload;
             continue;
         }
         $filehandler = new ElggFile();
         if (is_array(self::$attributes)) {
             foreach (self::$attributes as $key => $value) {
                 $filehandler->{$key} = $value;
             }
         }
         $filestorename = elgg_strtolower(time() . $upload->name);
         $filehandler->setFilename($prefix . $filestorename);
         $filehandler->title = $upload->name;
         $filehandler->originalfilename = $upload->name;
         $filehandler->filesize = $upload->size;
         $filehandler->mimetype = $upload->mimetype;
         $filehandler->simpletype = $upload->simpletype;
         $filehandler->open("write");
         $filehandler->close();
         move_uploaded_file($upload->path, $filehandler->getFilenameOnFilestore());
         if ($filehandler->save()) {
             $upload->guid = $filehandler->getGUID();
             $upload->file = $filehandler;
             if ($filehandler->simpletype == "image") {
                 IconHandler::makeIcons($filehandler);
             }
             $entities[] = $filehandler;
         } else {
             $upload->error = elgg_echo('upload:error:unknown');
         }
         $handled_uploads[] = $upload;
     }
     self::$uploads[$input] = $handled_uploads;
     self::$files[$input] = $entities;
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:50,代码来源:UploadHandler.php


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