本文整理汇总了PHP中JFile::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::getName方法的具体用法?PHP JFile::getName怎么用?PHP JFile::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readFileList
private function readFileList($path)
{
$filter = '^[wW][^\\.].*\\.([Pp][Nn][Gg]|[Jj][Pp][Ee]?[Gg])';
$recurse = true;
$excludefiles = array();
$excludeexts = array();
jimport('joomla.filesystem.folder');
$filelist = JFolder::files($path, $filter, $recurse, true, $excludefiles);
$files = array();
$files[] =& $this->getFile(null);
$count = 0;
while (list($i, $file) = each($filelist)) {
$count++;
if ($count > 500) {
break;
}
if (in_array(JFile::getName($file), $excludefiles)) {
continue;
}
if (in_array(JFile::getExt($file), $excludeexts)) {
continue;
}
$file =& $this->getFile($file);
$files[] = $file;
}
$this->fileSort($files);
return $files;
}
示例2: onPromoteList
function onPromoteList($uid)
{
if ($uid) {
$user = JFactory::getUser($uid);
} else {
$user = JFactory::getUser();
}
jimport('joomla.filesystem.file');
$db = JFactory::getDBO();
$name = JFile::getName(__FILE__);
$name = JFile::stripExt($name);
//$name = $this->params->get('plugin_name');
$sobichk = $this->_sobichk();
if (!empty($sobichk)) {
$query = "SELECT CONCAT_WS('|', '" . $name . "', s.itemid) as value, s.title as text FROM #__sobi2_item AS s\n\t\t\t\t\t\t\t\t LEFT JOIN #__users AS u ON s.updating_user = u.id\n\t\t\t\t\t\t\t\t WHERE u.id=" . $user->id . "\n\t\t\t\t\t\t\t\t ORDER BY itemid";
$db->setQuery($query);
$itemlist = $db->loadObjectlist();
if (empty($itemlist)) {
$list[0]->value = $name . '|' . '0';
$list[0]->text = JText::_("NO_SOBILIST");
return $list;
} else {
return $itemlist;
}
}
}
示例3: onPromoteList
function onPromoteList($uid)
{
jimport('joomla.filesystem.file');
$db = JFactory::getDBO();
if ($uid) {
$user = JFactory::getUser($uid);
} else {
$user = JFactory::getUser();
}
$name = JFile::getName(__FILE__);
$name = JFile::stripExt($name);
$jschk = $this->_chkextension();
if (!empty($jschk)) {
$query = "SELECT CONCAT_WS('|', '" . $name . "', e.id) as value, e.title AS text FROM #__community_events AS e\n\t\t\t\t\t\t\t\tLEFT JOIN #__users AS u ON e.creator = u.id\n\t\t\t\t\t\t\t\tWHERE u.id =" . $user->id;
$db->setQuery($query);
$itemlist = $db->loadObjectlist();
if (empty($itemlist)) {
$list = array();
//$list[0]->value=$name.'|'.'0';
// $list[0]->text=JText::_("NO_EVENTS");
return $list;
} else {
return $itemlist;
}
}
}
示例4: createThumb
public static function createThumb($path, $width = 100, $height = 100, $crop = 2)
{
$myImage = new JImage();
$myImage->loadFile(JPATH_SITE . DS . $path);
if ($myImage->isLoaded()) {
// $filename = end(explode('/', $path));
$filename = JFile::getName($path);
$filefolder = substr(md5(self::getFolderPath($path)), 1, 10);
$newfilename = $width . 'x' . $height . '_' . $filefolder . '_' . JFile::makeSafe($filename);
$fileExists = JFile::exists(JPATH_CACHE . '/' . $newfilename);
if (!$fileExists) {
$resizedImage = $myImage->resize($width, $height, true, $crop);
$properties = $myImage->getImageFileProperties($path);
$mime = $properties->mime;
if ($mime == 'image/jpeg') {
$type = IMAGETYPE_JPEG;
} elseif ($mime = 'image/png') {
$type = IMAGETYPE_PNG;
} elseif ($mime = 'image/gif') {
$type = IMAGETYPE_GIF;
}
$resizedImage->toFile(JPATH_CACHE . '/' . $newfilename, $type);
}
return $newfilename;
} else {
return "My file is not loaded";
}
}
示例5: uploadFile
/**
* Upload Simple File Manager files in the right folder.
*
* @param string $tmp_name
* Temporary path of the uploaded file on the server
* @param string $file_name
* Name of the uploaded file
* @return uploaded file path (in case of success) or false (in case of error)
*/
public static function uploadFile($tmp_name, $file_name)
{
jimport('joomla.filesystem.file');
$src = $tmp_name;
$dest = JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . uniqid("", true) . DIRECTORY_SEPARATOR . JFile::makeSafe(JFile::getName($file_name));
return JFile::upload($src, $dest) ? $dest : false;
}
示例6: add
/**
* Add a download.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $path
* @param string $description
*
* @throws Exception
* @throws DomainException
* @return mixed
*
*/
public function add($user, $repo, $path, $description = '')
{
/*
* First part: Create the download resource
*/
// Build the request data.
$fileName = JFile::getName($path);
$data = json_encode(array('name' => $fileName, 'size' => filesize($path), 'description' => $description));
// Build the request path.
$repoPath = '/repos/' . $user . '/' . $repo . '/downloads';
// Send the request.
$response = $this->client->post($this->fetchUrl($repoPath), $data);
// Validate the response code.
if (201 != $response->code) {
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
/*
* Second part: Upload the file
*
* For the second part we use plain curl - JHttp seems to add some unnecessary stuff...
*/
$respData = json_decode($response->body);
if (!$respData) {
throw new Exception('Invalid response');
}
$data = array('key' => $respData->path, 'acl' => $respData->acl, 'success_action_status' => 201, 'Filename' => $respData->name, 'AWSAccessKeyId' => $respData->accesskeyid, 'Policy' => $respData->policy, 'Signature' => $respData->signature, 'Content-Type' => $respData->mime_type, 'file' => '@' . $path);
$ch = curl_init();
$curlOptions = array(CURLOPT_URL => $respData->s3_url, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER, true);
curl_setopt_array($ch, $curlOptions);
$result = curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (201 != $responseCode) {
throw new DomainException($result, $responseCode);
}
/*
$this->options->set('api.url', $respData->s3_url);
// Unset credentials
$this->options->set('api.username', '');
$this->options->set('api.password', '');
$headers = array(
// 'Expires' => time() + 300,
);
$response = $this->client->post($this->fetchUrl(''), $data, $headers);
// Validate the response code.
if(201 != $response->code)
{
// Decode the error response and throw an exception.
throw new DomainException($response->body, $response->code);
}
return json_decode($response->body);
*/
return $this;
}
示例7: getCleanArray
/**
* @param $array
* @return array
*/
function getCleanArray($array)
{
$newArray = array();
foreach ($array as $value) {
array_push($newArray, JFile::stripExt(JFile::getName($value)));
}
return $newArray;
}
示例8: getCleanArray
function getCleanArray($array) {
jimport('joomla.filesystem.file');
$newArray = array();
foreach($array as $value) array_push($newArray, JFile::stripExt(JFile::getName($value)));
return $newArray;
}
示例9: postflight
function postflight($type, $parent)
{
if (version_compare(JVERSION, '3.0.0', '>')) {
$messages = array();
// Import required modules
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
jimport('joomla.filesystem.file');
//$db = JFactory::getDBO();
//$query = "ALTER TABLE #__k2_items ADD FULLTEXT(extra_fields)";
//$db->setQuery($query);
//$db->query();
// Get packages
$p_dir = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_jak2filter' . DS . 'packages');
// Did you give us a valid directory?
if (!is_dir($p_dir)) {
$messages[] = JText::_('Package directory(Related modules, plugins) is missing');
} else {
$subpackages = JFolder::files($p_dir);
$result = true;
$installer = new JInstaller();
if ($subpackages) {
$app = JFactory::getApplication();
$templateDir = 'templates/' . $app->getTemplate();
foreach ($subpackages as $zpackage) {
if (JFile::getExt($p_dir . DS . $zpackage) != "zip") {
continue;
}
$subpackage = JInstallerHelper::unpack($p_dir . DS . $zpackage);
if ($subpackage) {
$type = JInstallerHelper::detectType($subpackage['dir']);
if (!$type) {
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::_($zpackage . " Not valid package") . '</span>';
$result = false;
}
if (!$installer->install($subpackage['dir'])) {
// There was an error installing the package
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Error')) . '</span>';
} else {
$messages[] = '<img src="' . $templateDir . '/images/admin/tick.png" alt="" width="16" height="16" /> <span style="color:#00FF00;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Success')) . '</span>';
}
if (!is_file($subpackage['packagefile'])) {
$subpackage['packagefile'] = $p_dir . DS . $subpackage['packagefile'];
}
if (is_dir($subpackage['extractdir'])) {
JFolder::delete($subpackage['extractdir']);
}
if (is_file($subpackage['packagefile'])) {
JFile::delete($subpackage['packagefile']);
}
}
}
}
JFolder::delete($p_dir);
}
}
}
示例10: zipLiveTemplate
public function zipLiveTemplate(&$model)
{
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$item =& $model->getItem();
$item->name = strtolower($item->name);
//Create TempFolders
if (JFolder::exists($model->getTempPath(true))) {
JFolder::delete($model->getTempPath(true));
}
JFolder::create($model->getTempPath());
//Copy the template
if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $item->name)) {
JFolder::copy(JPATH_SITE . DS . 'templates' . DS . $item->name, $model->getTempPath(), '', true);
} elseif (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $item->name)) {
JFolder::copy(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $item->name, $model->getTempPath(), '', true);
} else {
JFolder::delete($model->getTempPath());
return -2;
}
//Create Language Folders
if (!JFolder::exists($model->getTempPath() . DS . 'language')) {
JFolder::create($model->getTempPath() . DS . 'language');
}
//Find Language Files
$langs_site = JLanguage::getKnownLanguages(JPATH_SITE);
$langs_admin = JLanguage::getKnownLanguages(JPATH_ADMINISTRATOR);
$langfiles_site = array();
$langfiles_admin = array();
foreach ($langs_site as $lang) {
$langfiles_site = array_merge(JFolder::files(JPATH_SITE . DS . 'language' . DS . $lang['tag'], $item->name, true, true), $langfiles_site);
}
foreach ($langs_admin as $lang) {
$langfiles_admin = array_merge(JFolder::files(JPATH_ADMINISTRATOR . DS . 'language' . DS . $lang['tag'], $item->name, true, true), $langfiles_admin);
}
//Copy Language Files
if (count($langfiles_site)) {
foreach ($langfiles_site as $file) {
JFile::copy($file, $model->getTempPath() . DS . 'language' . DS . JFile::getName($file));
}
}
if (count($langfiles_admin)) {
foreach ($langfiles_admin as $file) {
JFile::copy($file, $model->getTempPath() . DS . 'language' . DS . JFile::getName($file));
}
}
$model->readinFiles();
$model->buildArchiveContent();
//create archive
$model->createArchive();
//delete tmp folder
if (JFolder::exists(JPATH_SITE . DS . 'tmp' . DS . 'jctmp')) {
JFolder::delete(JPATH_SITE . DS . 'tmp' . DS . 'jctmp');
}
}
示例11: download
/**
* Downloads the backup file of a specific backup attempt,
* if it's available
*
*/
function download()
{
$cid = JRequest::getVar('cid', array(), 'default', 'array');
$id = JRequest::getInt('id');
$part = JRequest::getInt('part', 999);
if (empty($id)) {
if (is_array($cid) && !empty($cid)) {
$id = $cid[0];
} else {
$id = -1;
}
}
if ($id <= 0) {
$this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=buadmin', JText::_('STATS_ERROR_INVALIDID'), 'error');
parent::display();
return;
}
$model =& $this->getModel('statistics');
$model->setId($id);
$statentry =& $model->getStatistic();
if ($statentry->multipart == 0) {
// Single part backup
$filename = $model->getFilename($id);
} else {
// Multi-part backup
$allFilenames = $model->getAllFilenames($id);
if (!(@count($allFilenames) > 0)) {
$filename = null;
} else {
if ($part <= count($allFilenames)) {
$filename = $allFilenames[$part];
} else {
$filename = null;
}
}
}
jimport('joomla.filesystem.file');
if (is_null($filename) || empty($filename) || !JFile::exists($filename)) {
$this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=buadmin', JText::_('STATS_ERROR_INVALIDDOWNLOAD'), 'error');
parent::display();
return;
} else {
$basename = @JFile::getName($filename);
JRequest::setVar('format', 'raw');
@ob_end_clean();
@clearstatcache();
header('Content-Disposition: attachment; filename=' . $basename);
header('MIME-Version: 1.0');
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($filename));
header('Cache-Control: no-cache');
@readfile($filename);
die;
}
}
示例12: deployPackage
/**
* @static
* @return int|mixed
*/
public function deployPackage()
{
$input = JFactory::getApplication()->input;
$files = $input->get('file', array(), 'array');
foreach ($files as $file) {
JLog::add('| >> ' . sprintf(jgettext('Uploading %s ...'), JFile::getName($file)));
$this->github->downloads->add($input->get('owner'), $input->get('repo'), $file);
}
return count($files);
}
示例13: listFiles
function listFiles($path, $regex = '.')
{
$files = array();
// Make sure path is valid
$path = JPath::clean($path);
if (empty($path) || JString::strpos($path, JPATH_ROOT) === false) {
return $files;
}
$list = JFolder::files($path, $regex, false, true);
if (empty($list)) {
return $files;
}
foreach ($list as $filename) {
$f = new JObject();
$f->name = JFile::getName($filename);
$f->path = $filename;
$f->src = JString::str_ireplace(JPATH_ROOT . DS, JURI::root(), $f->path);
$f->src = str_replace(DS, '/', $f->src);
$f->size = LinkrHelper::parseSize($f->path);
$f->ext = strtolower(JFile::getExt($f->name));
switch ($f->ext) {
// Image
case 'bmp':
case 'gif':
case 'jpg':
case 'jpeg':
case 'odg':
case 'png':
case 'xcf':
list($w, $h) = @getimagesize($f->path);
$size = LinkrHelper::imageResize($w, $h, 32);
$f->width = $size['width'];
$f->height = $size['height'];
$f->icon = JString::str_ireplace(JPATH_ROOT . DS, JURI::root(), $f->path);
$f->icon = str_replace(DS, '/', $f->icon);
$f->type = JText::_('Image');
break;
// Other files
// Other files
default:
$f->type = strtoupper($f->ext);
$f->width = 32;
$f->height = 32;
$icon = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_media' . DS . 'images' . DS . 'mime-icon-32' . DS . $f->ext . '.png';
if (file_exists($icon)) {
$f->icon = JURI::root() . 'administrator/components/com_media/images/mime-icon-32/' . $f->ext . '.png';
} else {
$f->icon = JURI::root() . 'administrator/components/com_media/images/con_info.png';
}
break;
}
$files[] = $f;
}
return $files;
}
示例14: getLargeAvatar
/**
* Get large avatar use for cropping
* @return string
*/
public function getLargeAvatar()
{
$config = CFactory::getConfig();
$largeAvatar = $config->getString('imagefolder') . '/avatar/profile-' . JFile::getName($this->avatar);
if (JFile::exists(JPATH_ROOT . '/' . $largeAvatar)) {
return CUrlHelper::avatarURI($largeAvatar) . '?' . md5(time());
/* adding random param to prevent browser caching */
} else {
return $this->getAvatar();
}
}
示例15: getLargeAvatar
/**
* Get large avatar use for cropping
* @return string
*/
public function getLargeAvatar()
{
$config = CFactory::getConfig();
$largeAvatar = $config->getString('imagefolder') . '/avatar/profile-' . JFile::getName($this->avatar);
$current = CStorage::getStorage($this->storage);
if ($current->exists($largeAvatar)) {
return $current->getURI($largeAvatar);
} else {
return $this->getAvatar();
}
}