protected static function getXmlPath($type, $name, $group = '', $client = '', $reference = true)
 {
     switch ($type) {
         case 'component':
             $path = JPATH_ADMINISTRATOR . '/components/' . $name . '/' . preg_replace('/^com_/', '', $name);
             break;
         case 'module':
             $path = JApplicationHelper::getClientInfo($client, true)->path . '/modules/' . $name . '/' . $name;
             break;
         case 'plugin':
             $path = JPATH_PLUGINS . '/' . $group . '/' . $name . '/' . $name;
             break;
         case 'library':
             $path = JPATH_MANIFESTS . '/libraries/' . $name;
             break;
         default:
             throw new InvalidArgumentException(sprintf('Extension type "%s" does not support.', $type));
     }
     return Jpath::clean($reference ? str_replace(JPATH_ROOT, '', $path) : $path);
 }
Ejemplo n.º 2
0
 private function deleteOldFiles($filesToDelete = array())
 {
     jimport('joomla.filesystem.file');
     foreach ($filesToDelete as $fileToDelete) {
         $oldfile = Jpath::clean(JPATH_ROOT . $fileToDelete);
         if (JFile::exists($oldfile)) {
             try {
                 JFile::delete($oldfile);
                 JLog::add($oldfile . "deleted", JLog::INFO, 'com_visforms');
             } catch (RuntimeException $e) {
                 JLog::add('Unable to delete ' . $oldfile . ': ' . $e->getMessage(), JLog::INFO, 'com_visforms');
                 throw $e;
             }
         } else {
             JLog::add($oldfile . " does not exist.", JLog::INFO, 'com_visforms');
         }
     }
 }