本文整理汇总了PHP中FD::exception方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::exception方法的具体用法?PHP FD::exception怎么用?PHP FD::exception使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::exception方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFile
public function getFile($name = null)
{
// Check if post_max_size is exceeded.
if (empty($_FILES) && empty($_POST)) {
return FD::exception('COM_EASYSOCIAL_EXCEPTION_UPLOAD_POST_SIZE');
}
// Get the file
if (empty($name)) {
$name = $this->name;
}
$file = JRequest::getVar($name, '', 'FILES');
// Check for invalid file object
if (empty($file)) {
return FD::exception('COM_EASYSOCIAL_EXCEPTION_UPLOAD_NO_OBJECT');
}
// If there's an error in this file
if ($file['error']) {
return FD::exception($file, SOCIAL_EXCEPTION_UPLOAD);
}
// Check if file exceeds max upload filesize
$maxsize = FD::math()->convertBytes($this->maxsize);
if ($maxsize > 0 && $file['size'] > $maxsize) {
return FD::exception(JText::sprintf('COM_EASYSOCIAL_EXCEPTION_UPLOAD_MAX_SIZE', FD::math()->convertUnits($maxsize, 'B', 'MB', false, true)));
}
// Return file
return $file;
}
示例2: removeFile
/**
* Removes a file from a group.
*
* @since 1.2
* @access public
* @return mixed True if success, exception if false.
*/
public function removeFile()
{
// Check if the user has access to delete files from this group
if (!$this->group->isMember()) {
return FD::exception(JText::_('COM_EASYSOCIAL_EXPLORER_NO_ACCESS_TO_DELETE'));
}
// Get the file id
$ids = JRequest::getInt('id');
$ids = FD::makeArray($ids);
foreach ($ids as $id) {
$file = FD::table('File');
$file->load($id);
if (!$id || !$file->id) {
return FD::exception(JText::_('COM_EASYSOCIAL_EXPLORER_INVALID_FILE_ID_PROVIDED'));
}
$state = $file->delete();
if (!$state) {
return FD::exception(JText::_($file->getError()));
}
}
return true;
}
示例3: hook
/**
* Service Hook for explorer
*
* @since 1.3
* @access public
* @param string
* @return
*/
public function hook()
{
// Check for request forgeries
FD::checkToken();
// Require the user to be logged in
FD::requireLogin();
// Get the event object
$uid = $this->input->get('uid', 0, 'int');
$type = $this->input->get('type', '', 'cmd');
// Load up the explorer library
$explorer = FD::explorer($uid, $type);
// Determine if the viewer can really view items
if (!$explorer->hook('canViewItem')) {
return $this->view->call(__FUNCTION__);
}
// Get the hook
$hook = $this->input->get('hook', '', 'cmd');
// Get the result
$result = $explorer->hook($hook);
$exception = FD::exception('Folder retrieval successful', SOCIAL_MSG_SUCCESS);
return $this->view->call(__FUNCTION__, $exception, $result);
}
示例4: 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];
}