本文整理汇总了PHP中FD::makeFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::makeFolder方法的具体用法?PHP FD::makeFolder怎么用?PHP FD::makeFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::makeFolder方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* Uploads the given file to a temporary location on the site.
*
* @since 1.0
* @access public
* @param string
* @return string The path to the uploaded item.
*/
public function upload($file, $hash, $userId)
{
// Check if file exists on the server
if (!isset($file['tmp_name']) || empty($file)) {
$this->setError(JText::_('COM_EASYSOCIAL_UPLOADER_FILE_NOT_FOUND'));
return false;
}
// Lets figure out the storage path.
$config = FD::config();
// Test if the folder exists for this upload type.
$path = JPATH_ROOT . '/' . FD::cleanPath($config->get('uploader.storage.container'));
if (!FD::makeFolder($path)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_CREATE_DESTINATION_FOLDER', $path));
return false;
}
// Let's finalize the storage path.
$storage = $path . '/' . $userId;
if (!FD::makeFolder($storage)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_CREATE_DESTINATION_FOLDER', $storage));
return false;
}
// Once the script reaches here, we assume everything is good now.
// Copy the files over.
jimport('joomla.filesystem.file');
$absolutePath = $storage . '/' . $hash;
if (!JFile::copy($file['tmp_name'], $absolutePath)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_COPY_TO_DESTINATION_FOLDER', $absolutePath));
return false;
}
return $absolutePath;
}
示例2: getStoragePath
public static function getStoragePath($inputName, $overwrite = true)
{
// Create a temporary folder for this session.
$session = JFactory::getSession();
$uid = md5($session->getId() . $inputName);
$path = SOCIAL_MEDIA . '/tmp/' . $uid . '_avatar';
if ($overwrite) {
// If the folder exists, delete them first.
if (JFolder::exists($path)) {
JFolder::delete($path);
}
// Create folder if necessary.
FD::makeFolder($path);
}
return $path;
}
示例3: upload
/**
* Responsible to store the uploaded images.
*
* @since 1.0
* @access public
* @param null
*
* @author Mark Lee <mark@stackideas.com>
*/
public function upload($file)
{
// Get config object.
$config = FD::config();
// Do not proceed if image doesn't exist.
if (empty($file) || !isset($file['tmp_name'])) {
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_AVATARS_FILE_UNAVAILABLE'));
return false;
}
// Get the default avatars storage location.
$avatarsPath = JPATH_ROOT . '/' . FD::cleanPath($config->get('avatars.storage.container'));
// Test if the avatars path folder exists. If it doesn't we need to create it.
if (!FD::makeFolder($avatarsPath)) {
$this->setError(JText::_('Errors when creating default container for avatar'));
return false;
}
// Get the default avatars storage location for this type.
$typePath = $config->get('avatars.storage.' . $this->type);
$storagePath = $avatarsPath . '/' . FD::cleanPath($typePath);
// Ensure storage path exists.
if (!FD::makeFolder($storagePath)) {
$this->setError(JText::_('Errors when creating path for avatar'));
return false;
}
// Get the profile id and construct the final path.
$idPath = FD::cleanPath($this->uid);
$storagePath = $storagePath . '/' . $idPath;
// Ensure storage path exists.
if (!FD::makeFolder($storagePath)) {
$this->setError(JText::_('Errors when creating default path for avatar'));
return false;
}
// Get the image library to perform some checks.
$image = FD::get('Image');
$image->load($file['tmp_name']);
// Test if the image is really a valid image.
if (!$image->isValid()) {
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_AVATARS_FILE_NOT_IMAGE'));
return false;
}
// Process avatar storage.
$avatar = FD::get('Avatar', $image);
// Let's create the avatar.
$sizes = $avatar->create($storagePath);
if ($sizes === false) {
$this->setError(JText::_('Sorry, there was some errors when creating the avatars.'));
return false;
}
// Delete previous files.
$this->deleteFile($storagePath);
// Assign the values back.
foreach ($sizes as $size => $url) {
$this->{$size} = $url;
}
return true;
}
示例4: processDiscussionFiles
private function processDiscussionFiles()
{
$db = FD::db();
$sql = $db->sql();
$query = 'select a.*, d.`uid` as `esdiscussid`, c.`uid` as `esgroupid`, e.`uid` as `escollectid`';
$query .= ' from `#__community_files` as a';
$query .= ' inner join `#__social_migrators` as c on a.`groupid` = c.`oid` and c.`element` = ' . $db->Quote('groups') . ' and c.`component` = ' . $db->Quote($this->name);
$query .= ' inner join `#__social_migrators` as d on a.discussionid = d.oid and d.`element` = ' . $db->Quote('groupdiscussionsparent') . ' and d.`component` = ' . $db->Quote($this->name);
$query .= ' left join `#__social_migrators` as e on a.groupid = e.oid and e.`element` = ' . $db->Quote('groupcollection') . ' and e.`component` = ' . $db->Quote($this->name);
$query .= ' where not exists ( ';
$query .= ' select b.`id` from `#__social_migrators` as b';
$query .= ' where a.`id` = b.`oid` and b.`element` = ' . $db->Quote('groupdiscussionsfile') . ' and b.`component` = ' . $db->Quote($this->name);
$query .= ' )';
$query .= ' ORDER BY a.`id` ASC';
$sql->raw($query);
$db->setQuery($sql);
$jsFiles = $db->loadObjectList();
if (count($jsFiles) <= 0) {
return null;
}
foreach ($jsFiles as $jsFile) {
$esCollectionId = $this->getGroupCollectionId($jsFile);
$filePath = JPATH_ROOT . '/' . $jsFile->filepath;
if (JFile::exists($filePath)) {
// add the file extension into the filename.
$filePathArr = explode('.', $filePath);
$fileExt = $filePathArr[count($filePathArr) - 1];
// append file ext into filename.
$jsFile->name = $jsFile->name . '.' . $fileExt;
$fileMime = $this->getFileMimeType($filePath);
$fileHash = md5($jsFile->name . $jsFile->filepath);
$esFile = FD::table('File');
$esFile->name = $jsFile->name;
$esFile->collection_id = $esCollectionId;
$esFile->hits = $jsFile->hits;
$esFile->hash = $fileHash;
$esFile->uid = $jsFile->esgroupid;
$esFile->type = SOCIAL_TYPE_GROUP;
$esFile->created = $jsFile->created;
$esFile->user_id = $jsFile->creator;
$esFile->size = $jsFile->filesize;
$esFile->mime = $fileMime;
$esFile->state = SOCIAL_STATE_PUBLISHED;
$esFile->storage = SOCIAL_STORAGE_JOOMLA;
$esFile->store();
// attach this file into discussion.
$esDiscussFile = FD::table('DiscussionFile');
$esDiscussFile->file_id = $esFile->id;
$esDiscussFile->discussion_id = $jsFile->esdiscussid;
$esDiscussFile->store();
// now we need to append the file tag into discussion content.
$fileTag = "\r\n";
$fileTag .= '[file id="' . $esFile->id . '"]' . $jsFile->name . '[/file]';
$esDiscuss = FD::table('Discussion');
$esDiscuss->load($jsFile->esdiscussid);
$esDiscuss->content = $esDiscuss->content . $fileTag;
$esDiscuss->store();
// now we copy the file into es.
$storage = $esFile->getStoragePath();
// Ensure that the storage path exists.
FD::makeFolder($storage);
$state = JFile::copy($filePath, $storage . '/' . $esFile->hash);
// now we add stream
$stream = FD::stream();
$tpl = $stream->getTemplate();
$group = FD::group($jsFile->esgroupid);
// this is a cluster stream and it should be viewable in both cluster and user page.
$tpl->setCluster($jsFile->esgroupid, SOCIAL_TYPE_GROUP, $group->type);
// Set the actor
$tpl->setActor($jsFile->creator, SOCIAL_TYPE_USER);
// Set the context
$tpl->setContext($esFile->id, SOCIAL_TYPE_FILES);
// Set the verb
$tpl->setVerb('uploaded');
// set date
$tpl->setDate($jsFile->created);
// Set the params to cache the group data
$registry = FD::registry();
$registry->set('group', $group);
$registry->set('file', $esFile);
// Set the params to cache the group data
$tpl->setParams($registry);
// since this is a cluster and user stream, we need to call setPublicStream
// so that this stream will display in unity page as well
// This stream should be visible to the public
$tpl->setAccess('core.view');
$stream->add($tpl);
$this->log('groupdiscussionsfile', $jsFile->id, $esFile->id);
$this->info->setInfo('File with id ' . $jsFile->id . ' for group discussion ' . $jsFile->discussionid . ' successfully migrated into EasySocial.');
} else {
$this->log('groupdiscussionsfile', $jsFile->id, 0);
$this->info->setInfo('File with id ' . $jsFile->id . ' for group discussion ' . $jsFile->discussionid . ' not found. Migration of this file aborted.');
}
}
return $this->info;
}
示例5: delete
/**
* Override parent's behavior of deleting as we also need to delete physical files.
*
* @since 1.0
* @access public
* @param string
* @return bool
*/
public function delete($pk = null)
{
$state = parent::delete();
if (!$state) {
return false;
}
// Get config
$config = FD::config();
// Get the default avatars storage location.
$avatarsPath = JPATH_ROOT . '/' . FD::cleanPath($config->get('avatars.storage.container'));
// Test if the avatars path folder exists. If it doesn't we need to create it.
if (!FD::makeFolder($avatarsPath)) {
FD::logError(__FILE__, __LINE__, 'AVATARS: Unable to create the path ' . $avatarsPath);
$this->setError(JText::_('Errors when creating default container for avatar'));
return false;
}
// Get the default avatars storage location for this type.
$typePath = $config->get('avatars.storage.' . $this->type);
$storagePath = $avatarsPath . '/' . FD::cleanPath($typePath);
// Set the absolute path based on the uid.
$storagePath = $storagePath . '/' . $this->uid;
$this->deleteFolder($storagePath);
return $state;
}
示例6: getStoragePath
/**
* Gets the storage path for photos folder
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getStoragePath($uid, $type, $createFolders = true)
{
// Construct destination path
$config = FD::config();
// Get initial storage path
$storage = JPATH_ROOT;
// Append it with the container path
$storage = $storage . '/' . FD::cleanPath($config->get('avatars.storage.container'));
// Ensure that the folder exists
if ($createFolders) {
FD::makeFolder($storage);
}
// Append it with the type
$storage = $storage . '/' . FD::cleanPath($config->get('avatars.storage.' . $type));
// Ensure that the folder exists
if ($createFolders) {
FD::makeFolder($storage);
}
// Construct the last segment which contains the uid.
$storage = $storage . '/' . $uid;
// Ensure that the path exists.
if ($createFolders) {
FD::makeFolder($storage);
}
return $storage;
}
示例7: addFile
/**
* Allows caller to upload files
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function addFile($title = null)
{
if (!$this->hasWriteAccess()) {
return FD::exception(JText::_('COM_EASYSOCIAL_EXPLORER_NO_ACCESS_TO_UPLOAD'));
}
// Ensure that the storage path really exists on the site
FD::makeFolder($this->storagePath);
// Get the maximum size allowed from the child
$max = $this->getMaxSize();
// Define uploader options
$options = array('name' => 'file', 'maxsize' => $max);
// Get uploaded file from $_FILE
$file = FD::uploader($options)->getFile();
// If there was an error getting uploaded file, stop.
if ($file instanceof SocialException) {
return $file;
}
// Get filename
$name = $file['name'];
// Get the folder to store this item to.
$collectionId = JRequest::getInt('id', 0);
$table = FD::table('File');
$table->name = $name;
$table->collection_id = $collectionId;
$table->hits = 0;
$table->hash = md5('tmp');
$table->uid = $this->uid;
$table->type = $this->type;
$table->created = JFactory::getDate()->toSql();
$table->user_id = FD::user()->id;
$table->size = filesize($file['tmp_name']);
$table->mime = $file['type'];
$table->state = SOCIAL_STATE_PUBLISHED;
$table->storage = SOCIAL_STORAGE_JOOMLA;
// Try to store the data on the database.
$table->store();
// Now we need to really upload the file.
$state = $table->storeWithFile($file);
// Format the data now
$result = $this->format(array($table));
return $result[0];
}
示例8: storeWithFile
/**
* Identical to the store method but it also stores the file properties.
* Maps a file object into the correct properties.
*
* @since 1.0
* @access public
* @param $_FILES $file File data
*
* @return boolean True if success, false otherwise.
*/
public function storeWithFile($file)
{
// Check if file exists on the server
if (!isset($file['tmp_name']) || empty($file)) {
$this->setError(JText::_('COM_EASYSOCIAL_UPLOADER_FILE_NOT_FOUND'));
return false;
}
// Get the name of the uploaded file.
if (isset($file['name']) && !empty($file['name'])) {
$this->name = $file['name'];
}
// Get the mime type of the file.
if (isset($file['type']) && !empty($file['type'])) {
$this->mime = $file['type'];
}
// Get the file size.
if (isset($file['size']) && !empty($file['size'])) {
$this->size = $file['size'];
}
// If there's no type or the unique id is invalid we should break here.
if (!$this->type || !$this->uid) {
$this->setError(JText::_('COM_EASYSOCIAL_UPLOADER_COMPOSITE_ITEMS_NOT_DEFINED'));
return false;
}
// Generate a random hash for the file.
$this->hash = md5($this->name . $file['tmp_name']);
// Try to store the item first.
$state = $this->store();
// Once the script reaches here, we assume everything is good now.
// Copy the files over.
jimport('joomla.filesystem.file');
$storage = $this->getStoragePath();
// Ensure that the storage path exists.
FD::makeFolder($storage);
$state = JFile::copy($file['tmp_name'], $storage . '/' . $this->hash);
if (!$state) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_COPY_TO_DESTINATION_FOLDER', $typePath . '/' . $this->uid . '/' . $this->hash));
return false;
}
return $state;
}
示例9: saveCover
public function saveCover(&$post, $uid, $type)
{
$coverData = !empty($post[$this->inputName]) ? $post[$this->inputName] : '';
unset($post[$this->inputName]);
if (empty($coverData)) {
return true;
}
$coverData = FD::makeObject($coverData);
// Get the cover table.
$cover = FD::table('Cover');
// Try to load existing cover
$state = $cover->load(array('uid' => $uid, 'type' => $type));
// If no existing cover, then we set the uid and type.
if (!$state) {
$cover->uid = $uid;
$cover->type = $type;
}
// If both data does not exist, then we don't proceed to store the data.
if (empty($coverData->data) && empty($coverData->position)) {
return true;
}
if (!empty($coverData->data)) {
if ($coverData->data === 'delete') {
$cover->delete();
return true;
}
$coverObj = FD::makeObject($coverData->data);
// Get the cover album.
$album = SocialFieldsUserCoverHelper::getDefaultAlbum($uid, $type);
// Create the photo object.
$photo = SocialFieldsUserCoverHelper::createPhotoObject($uid, $type, $album->id, $coverObj->stock->title, false);
// If there are no cover set for this album, set it as cover.
if (empty($album->cover_id)) {
$album->cover_id = $photo->id;
$album->store();
}
// Construct the path to where the photo is temporarily uploaded.
// $tmpPath = SocialFieldsUserCoverHelper::getPath($this->inputName);
$tmpPath = dirname($coverObj->stock->path);
// Get the supposed path of where the cover should be
// Instead of doing SocialPhotos::getStoragePath, I copied the logic from there but only to create the folders up until albumId section.
// We do not want JPATH_ROOT to be included in the $storage variable
$storage = '/' . FD::cleanPath(FD::config()->get('photos.storage.container'));
FD::makeFolder(JPATH_ROOT . $storage);
$storage .= '/' . $album->id;
FD::makeFolder(JPATH_ROOT . $storage);
$storage .= '/' . $photo->id;
FD::makeFolder(JPATH_ROOT . $storage);
// Copy the photo from the temporary path to the storage folder.
$state = JFolder::copy($tmpPath, JPATH_ROOT . $storage, '', true);
// If cannot copy out the photo, then don't proceed
if ($state !== true) {
$this->setError(JText::_('PLG_FIELDS_COVER_ERROR_UNABLE_TO_MOVE_FILE'));
return false;
}
// Create the photo meta for each available sizes.
foreach ($coverObj as $key => $value) {
SocialFieldsUserCoverHelper::createPhotoMeta($photo, $key, $storage . '/' . $value->file);
}
// Set the uploaded photo as cover for this user.
$cover->setPhotoAsCover($photo->id);
}
// Set the position of the cover if available.
if (!empty($coverData->position)) {
$position = FD::makeObject($coverData->position);
if (isset($position->x)) {
$cover->x = $position->x;
}
if (isset($position->y)) {
$cover->y = $position->y;
}
}
// Store the cover object
$cover->store();
// And we're done.
return true;
}
示例10: getStoragePath
/**
* Retrieves the storage path for this album
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getStoragePath(SocialTableAlbum $album, $relative = false)
{
// Rename temporary folder to the destination.
jimport('joomla.filesystem.folder');
// Get destination folder path.
$storage = $album->getStoragePath($relative);
// Build the storage path now with the album id
$storage = $storage . '/' . $this->id;
// Ensure that the final storage path exists.
if (!$relative) {
FD::makeFolder($storage);
}
return $storage;
}
示例11: installPackage
public function installPackage($file, $type, $allowedExtension = array(), $extract = true)
{
FD::checkToken();
$view = $this->getCurrentView();
if (empty($file['tmp_name'])) {
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_ERROR_INVALID_TYPE'), SOCIAL_MSG_ERROR);
return false;
}
if ($file['type'] !== 'application/octet-stream') {
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_ERROR_INVALID_TYPE'), SOCIAL_MSG_ERROR);
return false;
}
$fileext = pathinfo($file['name'], PATHINFO_EXTENSION);
if (empty($allowedExtension)) {
$allowedExtension = array($type);
}
if (!in_array($fileext, $allowedExtension)) {
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_ERROR_INVALID_TYPE'), SOCIAL_MSG_ERROR);
return false;
}
$files = array();
if (in_array($fileext, $allowedExtension) && ($fileext !== 'zip' || !$extract)) {
$files[] = $file['tmp_name'];
}
$tmpPath = null;
if ($fileext === 'zip' && $extract) {
jimport('joomla.filesystem.archive');
$key = md5(uniqid() . $file['tmp_name']);
$tmpPath = SOCIAL_TMP . '/' . $key;
$state = FD::makeFolder($tmpPath);
if (!$state) {
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_ERROR_UNABLE_TO_CREATE_TMP_FOLDER') . ': ' . $tmpPath, SOCIAL_MSG_ERROR);
return false;
}
$state = JArchive::extract($file['tmp_name'], $tmpPath);
if (!$state) {
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_ERROR_UNABLE_TO_EXTRACT_PACKAGE'), SOCIAL_MSG_ERROR);
return false;
}
$scanExtension = array_diff($allowedExtension, array('zip'));
foreach ($scanExtension as $e) {
$files = array_merge($files, JFolder::files($tmpPath, '.' . $e . '$', true, true));
}
}
$model = FD::model($type);
foreach ($files as $file) {
if (!$model->install($file)) {
$view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
return false;
}
}
if (!empty($tmpPath)) {
JFolder::delete($tmpPath);
}
$view->setMessage(JText::_('COM_EASYSOCIAL_INSTALL_UPLOAD_SUCCESSFULLY', SOCIAL_MSG_SUCCESS));
return true;
}
示例12: getStoragePath
/**
* Gets the storage path for photos folder
*
* @since 1.0
* @access public
* @param string
* @return
*/
public static function getStoragePath($albumId, $photoId, $createFolders = true)
{
// Get destination folder path.
$config = FD::config();
$container = FD::cleanPath($config->get('photos.storage.container'));
$storage = JPATH_ROOT . '/' . $container;
// Test if the storage folder exists
if ($createFolders) {
FD::makeFolder($storage);
}
// Set the storage path to the album
$storage = $storage . '/' . $albumId;
// If it doesn't exist, create it.
if ($createFolders) {
FD::makeFolder($storage);
}
// Create a new folder for the photo
$storage = $storage . '/' . $photoId;
if ($createFolders) {
FD::makeFolder($storage);
}
// Re-generate the storage path since we do not want to store the JPATH_ROOT
$storage = '/' . $container . '/' . $albumId . '/' . $photoId;
return $storage;
}
示例13: upload
/**
* Responsible to store the uploaded images.
*
* @since 1.0
* @access public
* @param null
*
* @author Mark Lee <mark@stackideas.com>
*/
public function upload($files)
{
// Get config object.
$config = FD::config();
// Do not proceed if image doesn't exist.
if (empty($files) || !isset($files['file'])) {
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_COVERS_FILE_UNAVAILABLE'));
return false;
}
// Get the single file input since the $files is an array.
$file = $files['file'];
// Get the default avatars storage location.
$coversPath = JPATH_ROOT . '/' . FD::cleanPath($config->get('covers.storage.container'));
// Test if the avatars path folder exists. If it doesn't we need to create it.
if (!FD::makeFolder($coversPath)) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Unable to create the path ' . $coversPath);
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_COVERS_UNABLE_TO_CREATE_CONTAINER_FOLDER'));
return false;
}
// Get the defaults avatar path.
$defaultsPath = $coversPath . '/' . FD::cleanPath($config->get('covers.storage.default'));
// Ensure that the defaults path exist
if (!FD::makeFolder($defaultsPath)) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Unable to create the path ' . $defaultsPath);
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_COVERS_UNABLE_TO_CREATE_DEFAULT_FOLDER'));
return false;
}
// Get the default avatars storage location for this type.
$typePath = $config->get('covers.storage.defaults.' . $this->type);
$storagePath = $defaultsPath . '/' . FD::cleanPath($typePath);
// Ensure storage path exists.
if (!FD::makeFolder($storagePath)) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Unable to create the path ' . $storagePath);
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_COVERS_UNABLE_TO_CREATE_DEFAULT_FOLDER'));
return false;
}
// Get the profile id and construct the final path.
$idPath = FD::cleanPath($this->uid);
$storagePath = $storagePath . '/' . $idPath;
// Ensure storage path exists.
if (!FD::makeFolder($storagePath)) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Unable to create the path ' . $storagePath);
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_COVERS_UNABLE_TO_CREATE_DEFAULT_FOLDER'));
return false;
}
// Get the image library to perform some checks.
$image = FD::get('Image');
$image->load($file['tmp_name']);
// Test if the image is really a valid image.
if (!$image->isValid()) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Image uploaded ' . $file['name'] . ' is invalid');
$this->setError(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_AVATARS_FILE_NOT_IMAGE'));
return false;
}
// Process covers storage.
$cover = FD::get('Cover', $image);
// Try to create the covers.
$sizes = $cover->create($storagePath);
// Test if the server returned an error.
if ($sizes === false) {
FD::logError(__FILE__, __LINE__, 'DEFAULT_COVERS: Error creating covers at ' . $storagePath);
$this->setError(JText::_('Sorry, there was some errors when creating the covers.'));
return false;
}
// Assign the values back.
foreach ($sizes as $size => $url) {
$this->{$size} = $url;
}
return true;
}