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


PHP JFactory::getLogger方法代码示例

本文整理汇总了PHP中JFactory::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getLogger方法的具体用法?PHP JFactory::getLogger怎么用?PHP JFactory::getLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JFactory的用法示例。


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

示例1: delete

 /**
  * Delete a file or array of files
  *
  * @param   mixed  $file  The file name or an array of file names
  *
  * @return  boolean  True on success
  *
  * @since   11.1
  */
 public static function delete($file)
 {
     // Initialise variables.
     jimport('joomla.client.helper');
     $FTPOptions = JClientHelper::getCredentials('ftp');
     if (is_array($file)) {
         $files = $file;
     } else {
         $files[] = $file;
     }
     // Do NOT use ftp if it is not enabled
     if ($FTPOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
     }
     foreach ($files as $file) {
         $file = JPath::clean($file);
         if (!is_file($file)) {
             continue;
         }
         // Try making the file writable first. If it's read-only, it can't be deleted
         // on Windows, even if the parent folder is writable
         @chmod($file, 0777);
         // In case of restricted permissions we zap it one way or the other
         // as long as the owner is either the webserver or the ftp
         if (@unlink($file)) {
             JFactory::getLogger()->debug('File deleted: ' . $file . '; ' . (!JFactory::getUser()->get('guest') ? ' By: ' . JFactory::getUser()->get('username') . '; ' : '') . 'Request: ' . JRequest::getVar('REQUEST_URI', '', 'server'));
             // Do nothing
         } elseif ($FTPOptions['enabled'] == 1) {
             $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/');
             if (!$ftp->delete($file)) {
                 // FTP connector throws an error
                 return false;
             }
         } else {
             $filename = basename($file);
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('JLIB_FILESYSTEM_DELETE_FAILED', $filename));
             return false;
         }
     }
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:52,代码来源:file.php

示例2: delete

 /**
  * Delete a folder.
  *
  * @param   string  $path  The path to the folder to delete.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  */
 public static function delete($path)
 {
     @set_time_limit(ini_get('max_execution_time'));
     // Sanity check
     if (!$path) {
         // Bad programmer! Bad Bad programmer!
         JError::raiseWarning(500, __METHOD__ . ': ' . JText::_('JLIB_FILESYSTEM_ERROR_DELETE_BASE_DIRECTORY'));
         return false;
     }
     // Initialise variables.
     $FTPOptions = JClientHelper::getCredentials('ftp');
     try {
         // Check to make sure the path valid and clean
         $path = JPath::clean($path);
     } catch (UnexpectedValueException $e) {
         throw new UnexpectedValueException($e);
     }
     // Is this really a folder?
     if (!is_dir($path)) {
         JError::raiseWarning(21, JText::sprintf('JLIB_FILESYSTEM_ERROR_PATH_IS_NOT_A_FOLDER', $path));
         return false;
     }
     // Remove all the files in folder if they exist; disable all filtering
     $files = self::files($path, '.', false, true, array(), array());
     if (!empty($files)) {
         jimport('joomla.filesystem.file');
         if (JFile::delete($files) !== true) {
             // JFile::delete throws an error
             return false;
         }
     }
     // Remove sub-folders of folder; disable all filtering
     $folders = self::folders($path, '.', false, true, array(), array());
     foreach ($folders as $folder) {
         if (is_link($folder)) {
             // Don't descend into linked directories, just delete the link.
             jimport('joomla.filesystem.file');
             if (JFile::delete($folder) !== true) {
                 // JFile::delete throws an error
                 return false;
             }
         } elseif (self::delete($folder) !== true) {
             // JFolder::delete throws an error
             return false;
         }
     }
     if ($FTPOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
     }
     // In case of restricted permissions we zap it one way or the other
     // as long as the owner is either the webserver or the ftp.
     if (@rmdir($path)) {
         JFactory::getLogger()->debug('Path deleted: ' . $path . '; ' . (!JFactory::getUser()->get('guest') ? ' By: ' . JFactory::getUser()->get('username') . '; ' : '') . 'Request: ' . JRequest::getVar('REQUEST_URI', '', 'server'));
         $ret = true;
     } elseif ($FTPOptions['enabled'] == 1) {
         // Translate path and delete
         $path = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $path), '/');
         // FTP connector throws an error
         $ret = $ftp->delete($path);
     } else {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('JLIB_FILESYSTEM_ERROR_FOLDER_DELETE', $path));
         $ret = false;
     }
     return $ret;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:76,代码来源:folder.php


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