The properties below (except componentName, bareComponentName and the ones marked with property-read) can be configured in the fof.xml component configuration file. Sample fof.xml: The paths can use the variables %ROOT%, %PUBLIC%, %ADMIN%, %TMP%, %LOG% i.e. all the path keys returned by Platform's getPlatformBaseDirs() method in uppercase and surrounded by percent signs.
Inheritance: extends ContainerBase
Example #1
0
 /**
  * Public constructor. Initialises the protected members as well.
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     $container = Container::getInstance('com_akeeba');
     $config['update_component'] = 'pkg_akeeba';
     $config['update_sitename'] = 'Akeeba Backup Core';
     $config['update_site'] = 'http://cdn.akeebabackup.com/updates/pkgakeebacore.xml';
     $config['update_extraquery'] = '';
     $isPro = defined('AKEEBA_PRO') ? AKEEBA_PRO : 0;
     $dlid = $container->params->get('update_dlid', '');
     // If I have a valid Download ID I will need to use a non-blank extra_query in Joomla! 3.2+
     if (preg_match('/^([0-9]{1,}:)?[0-9a-f]{32}$/i', $dlid)) {
         // Even if the user entered a Download ID in the Core version. Let's switch his update channel to Professional
         $isPro = true;
     }
     if ($isPro) {
         $config['update_sitename'] = 'Akeeba Backup Professional';
         $config['update_site'] = 'http://cdn.akeebabackup.com/updates/pkgakeebapro.xml';
         $config['update_extraquery'] = 'dlid=' . $dlid;
     }
     parent::__construct($config);
     $this->container = $container;
     $this->extension_id = $this->findExtensionId('pkg_akeeba', 'package');
     if (empty($this->extension_id)) {
         $this->createFakePackageExtension();
         $this->extension_id = $this->findExtensionId('pkg_akeeba', 'package');
     }
 }
Example #2
0
 public function getItems($streams)
 {
     $arsContainer = \FOF30\Container\Container::getInstance('com_ars');
     $items = array();
     /** @var \Akeeba\ReleaseSystem\Site\Model\Update $model */
     $model = $arsContainer->factory->model('Update');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Items $dlModel */
     $dlModel = $arsContainer->factory->model('Items');
     foreach ($streams as $stream_id) {
         $items = $model->getItems($stream_id);
         if (empty($items)) {
             continue;
         }
         $i = array_shift($items);
         // Is the user authorized to download this item?
         $iFull = $dlModel->find($i->item_id);
         if (!\Akeeba\ReleaseSystem\Site\Helper\Filter::filterItem($iFull)) {
             continue;
         }
         // Add this item
         $newItem = array('id' => $i->item_id, 'release_id' => $i->release_id, 'name' => $i->name, 'version' => $i->version, 'maturity' => $i->maturity);
         $items[] = (object) $newItem;
     }
     return $items;
 }
Example #3
0
 /**
  * Create the view
  *
  * @param   string $viewType The type of the view (item, default, form)
  */
 protected function createView($viewType)
 {
     $this->setDevServer();
     $view = $this->getViewName($this->input);
     if (!$this->component) {
         $this->out("Can't find component details in composer.json file. Run 'fof init'");
         exit;
     }
     if (!$view) {
         $this->out("Syntax: fof generate " . $viewType . "view <name>");
         exit;
     }
     // Backend or frontend?
     $backend = !$this->input->get('frontend', false);
     try {
         // Create the view
         $this->createViewFile($view, $viewType, $backend);
         $message = $backend ? "Backend" : "Frontend";
         $message .= " " . $viewType . " view for " . $view . ' created!';
         // All ok!
         $this->out($message);
     } catch (\Exception $e) {
         if ($e instanceof NoTableColumns) {
             $container = Container::getInstance($this->component);
             $this->out("FOF cannot find a database table for " . $view . '. It should be named #__' . $this->component . '_' . strtolower($container->inflector->pluralize($view)));
             exit;
         }
         $this->out($e);
         exit;
     }
 }
Example #4
0
File: Model.php Project: Joal01/fof
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $applyAccess = $this->element['apply_access'] ? (string) $this->element['apply_access'] : 'false';
     $modelName = (string) $this->element['model'];
     $nonePlaceholder = (string) $this->element['none'];
     $translate = empty($this->element['translate']) ? 'true' : (string) $this->element['translate'];
     $translate = in_array(strtolower($translate), array('true', 'yes', '1', 'on')) ? true : false;
     if (!empty($nonePlaceholder)) {
         $options[] = JHtml::_('select.option', null, JText::_($nonePlaceholder));
     }
     // Process field atrtibutes
     $applyAccess = strtolower($applyAccess);
     $applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1'));
     // Explode model name into component name and prefix
     $componentName = $this->form->getContainer()->componentName;
     $mName = $modelName;
     if (strpos($modelName, '.') !== false) {
         list($componentName, $mName) = explode('.', $mName, 2);
     }
     // Get the applicable container
     $container = $this->form->getContainer();
     if ($componentName != $container->componentName) {
         $container = Container::getInstance($componentName);
     }
     /** @var DataModel $model */
     $model = $container->factory->model($mName)->setIgnoreRequest(true)->savestate(false);
     if ($applyAccess) {
         $model->applyAccessFiltering();
     }
     // Process state variables
     /** @var \SimpleXMLElement $stateoption */
     foreach ($this->element->children() as $stateoption) {
         // Only add <option /> elements.
         if ($stateoption->getName() != 'state') {
             continue;
         }
         $stateKey = (string) $stateoption['key'];
         $stateValue = (string) $stateoption;
         $model->setState($stateKey, $stateValue);
     }
     // Set the query and get the result list.
     $items = $model->get(true);
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #5
0
 /**
  * Public constructor
  */
 function __construct()
 {
     $configOverrides = array();
     $configOverrides['volatile.core.finalization.action_handlers'] = array(new TestExtract());
     $configOverrides['volatile.core.finalization.action_queue_before'] = array('test_extract');
     // Apply the configuration overrides, please
     $this->configOverrides = $configOverrides;
     $this->container = Container::getInstance('com_akeeba');
 }
Example #6
0
 /**
  * Public constructor. Initialises the protected members as well. Useful $config keys:
  * update_component		The component name, e.g. com_foobar
  * update_version		The default version if the manifest cache is unreadable
  * update_site			The URL to the component's update XML stream
  * update_extraquery	The extra query to append to (commercial) components' download URLs
  * update_sitename		The update site's name (description)
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     $container = Container::getInstance('com_FOOBAR');
     parent::__construct($container);
     // Get an instance of the updater class
     $this->updater = JUpdater::getInstance();
     // Get the component name
     if (isset($config['update_component'])) {
         $this->component = $config['update_component'];
     } else {
         $this->component = $this->input->getCmd('option', '');
     }
     // Get the component version
     if (isset($config['update_version'])) {
         $this->version = $config['update_version'];
     }
     // Get the update site
     if (isset($config['update_site'])) {
         $this->updateSite = $config['update_site'];
     }
     // Get the extra query
     if (isset($config['update_extraquery'])) {
         $this->extraQuery = $config['update_extraquery'];
     }
     // Get the extra query
     if (isset($config['update_sitename'])) {
         $this->updateSiteName = $config['update_sitename'];
     }
     // Get the extension type
     list($extensionPrefix, $extensionName) = explode('_', $this->component);
     switch ($extensionPrefix) {
         default:
         case 'com':
             $type = 'component';
             $name = $this->component;
             break;
         case 'pkg':
             $type = 'package';
             $name = $this->component;
             break;
     }
     // Find the extension ID
     $db = $this->container->db;
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q($type))->where($db->qn('element') . ' = ' . $db->q($name));
     $db->setQuery($query);
     $extension = $db->loadObject();
     if (is_object($extension)) {
         $this->extension_id = $extension->extension_id;
         $data = json_decode($extension->manifest_cache, true);
         if (isset($data['version'])) {
             $this->version = $data['version'];
         }
     }
 }
Example #7
0
 public function __construct(array $values = array())
 {
     if (!isset($values['componentName'])) {
         $values['componentName'] = 'com_fakeapp';
     }
     if (!isset($values['platform'])) {
         $values['platform'] = function (Container $c) {
             return new TestJoomlaPlatform($c);
         };
     }
     return parent::__construct($values);
 }
Example #8
0
 /**
  * Returns a list of subscription groups / levels in a format suitable for selection lists
  *
  * @return  array
  */
 static function getGroupsForSelect()
 {
     /** @var self $instance */
     $instance = Container::getInstance('com_ars')->factory->model('SubscriptionIntegration');
     $ret = [];
     $temp = $instance->getGroups();
     if (!empty($temp)) {
         foreach ($temp as $k => $v) {
             $ret[] = ['key' => $k, 'value' => $v];
         }
     }
     return $ret;
 }
Example #9
0
 public function onContentPrepare($context, &$article, &$params, $limitstart = 0)
 {
     if (!$this->enabled) {
         return true;
     }
     // Check whether the plugin should process or not
     if (\JString::strpos($article->text, 'downloadid') === false) {
         return true;
     }
     // Make sure our auto-loader is set up and ready
     \FOF30\Container\Container::getInstance('com_ars');
     // Search for this tag in the content
     $regex = "#{[\\s]*downloadid[\\s]*}#s";
     $article->text = preg_replace_callback($regex, array('self', 'process'), $article->text);
 }
Example #10
0
File: Model.php Project: akeeba/fof
 public function execute()
 {
     // Backend or frontend?
     $section = $this->input->get('frontend', false) ? 'site' : 'admin';
     $view = $this->getViewName($this->input);
     // Let's force the use of the Magic Factory
     $container = Container::getInstance($this->component, array('factoryClass' => 'FOF30\\Factory\\MagicFactory'));
     $container->factory->setSaveScaffolding(true);
     $view = $container->inflector->pluralize($view);
     $classname = $container->getNamespacePrefix($section) . 'Model\\' . ucfirst($view);
     $scaffolding = new ModelBuilder($container);
     $scaffolding->setSection($section);
     if (!$scaffolding->make($classname, $view)) {
         throw new \RuntimeException("An error occurred while creating the Model class");
     }
 }
Example #11
0
 /**
  * Sets the category we are operating on
  *
  * @param Categories|integer $cat A category table or a numeric category ID
  *
  * @return void
  */
 protected function setCategory($cat)
 {
     // Initialise
     $this->category = null;
     $this->category_id = null;
     $this->folder = null;
     if ($cat instanceof Categories) {
         $this->category = $cat;
         $this->category_id = $cat->id;
     } elseif (is_numeric($cat)) {
         $this->category_id = (int) $cat;
         $container = Container::getInstance('com_ars');
         $this->category = $container->factory->model('Categories')->tmpInstance();
         $this->category->find($this->category_id);
     }
     // Store folder
     $folder = $this->category->directory;
     // Check for categories stored in Amazon S3
     $potentialPrefix = substr($folder, 0, 5);
     $potentialPrefix = strtolower($potentialPrefix);
     if ($potentialPrefix == 's3://') {
         // If it is stored on S3 make sure there are files stored with the given directory prefix
         $check = substr($folder, 5);
         $s3 = AmazonS3::getInstance();
         $items = $s3->getBucket('', $check . '/');
         if (empty($items)) {
             return;
         }
     } else {
         // If it is stored locally, make sure the folder exists
         \JLoader::import('joomla.filesystem.folder');
         if (!\JFolder::exists($folder)) {
             $folder = JPATH_ROOT . '/' . $folder;
             if (!\JFolder::exists($folder)) {
                 return;
             }
         }
     }
     $this->folder = $folder;
 }
Example #12
0
	/**
	 * This method is called when the Quick Icons module is constructing its set
	 * of icons. You can return an array which defines a single icon and it will
	 * be rendered right after the stock Quick Icons.
	 *
	 * @param  $context  The calling context
	 *
	 * @return array A list of icon definition associative arrays, consisting of the
	 *                 keys link, image, text and access.
	 *
	 * @since       2.5
	 */
	public function onGetIcons($context)
	{
		$user                = JFactory::getUser();
		if ( !$user->authorise('akeeba.backup', 'com_akeeba'))
		{
			return;
		}


		if (
				$context != $this->params->get('context', 'mod_quickicon')
				|| !JFactory::getUser()->authorise('core.manage', 'com_installer')
		)
		{
			return;
		}

		$container = \FOF30\Container\Container::getInstance('com_akeeba');

		// Necessary defines for Akeeba Engine
		if ( !defined('AKEEBAENGINE'))
		{
			define('AKEEBAENGINE', 1);
			define('AKEEBAROOT',  $container->backEndPath . '/BackupEngine');
			define('ALICEROOT', $container->backEndPath . '/AliceEngine');

			// Make sure we have a profile set throughout the component's lifetime
			$session    = $container->session;
			$profile_id = $session->get('profile', null, 'akeeba');

			if (is_null($profile_id))
			{
				$session->set('profile', 1, 'akeeba');
			}

			// Load Akeeba Engine
			require_once $container->backEndPath . '/BackupEngine/Factory.php';
		}

		Platform::addPlatform('joomla3x', JPATH_ADMINISTRATOR . '/components/com_akeeba/BackupPlatform/Joomla3x');

		$url = JUri::base();
		$url = rtrim($url, '/');

		$profileId = (int)$this->params->get('profileid', 1);
		$token     = JFactory::getSession()->getToken();

		if ($profileId <= 0)
		{
			$profileId = 1;
		}

		$ret = array(
			'link'  => 'index.php?option=com_akeeba&view=Backup&autostart=1&returnurl=' . urlencode($url) . '&profileid=' . $profileId . "&$token=1",
			'image' => 'akeeba-black',
			'text'  => JText::_('PLG_QUICKICON_AKEEBABACKUP_OK'),
			'id'    => 'plg_quickicon_akeebabackup',
			'group' => 'MOD_QUICKICON_MAINTENANCE',
		);

		if (version_compare(JVERSION, '3.0', 'lt'))
		{
			$ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-48.png';
		}

		if ($this->params->get('enablewarning', 0) == 0)
		{
			// Process warnings
			$warning = false;

			$aeconfig = Factory::getConfiguration();
			Platform::getInstance()->load_configuration();

			// Get latest non-SRP backup ID
			$filters  = array(
				array(
					'field'   => 'tag',
					'operand' => '<>',
					'value'   => 'restorepoint'
				)
			);
			$ordering = array(
				'by'    => 'backupstart',
				'order' => 'DESC'
			);

			/** @var \Akeeba\Backup\Admin\Model\Statistics $model */
			$model = $container->factory->model('Statistics')->tmpInstance();
			$list  = $model->getStatisticsListWithMeta(false, $filters, $ordering);

			if ( !empty($list))
			{
				$record = (object)array_shift($list);
			}
			else
			{
				$record = null;
			}

			// Process "failed backup" warnings, if specified
			if ($this->params->get('warnfailed', 0) == 0)
			{
				if ( !is_null($record))
				{
					$warning = (($record->status == 'fail') || ($record->status == 'run'));
				}
			}

			// Process "stale backup" warnings, if specified
			if (is_null($record))
			{
				$warning = true;
			}
			else
			{
				$maxperiod = $this->params->get('maxbackupperiod', 24);
				JLoader::import('joomla.utilities.date');
				$lastBackupRaw    = $record->backupstart;
				$lastBackupObject = new JDate($lastBackupRaw);
				$lastBackup       = $lastBackupObject->toUnix(false);
				$maxBackup        = time() - $maxperiod * 3600;
				if ( !$warning)
				{
					$warning = ($lastBackup < $maxBackup);
				}
			}

			if ($warning)
			{
				$ret['image'] = 'akeeba-red';
				$ret['text']  = JText::_('PLG_QUICKICON_AKEEBABACKUP_BACKUPREQUIRED');

				if (version_compare(JVERSION, '3.0', 'lt'))
				{
					$ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-warning-48.png';
				}
				else
				{
					$ret['text'] = '<span class="badge badge-important">' . $ret['text'] . '</span>';
				}
			}
		}

		if (version_compare(JVERSION, '3.0', 'gt'))
		{
			$inlineCSS = <<< CSS
.icon-akeeba-black {
	background-image: url("../media/com_akeeba/icons/akeebabackup-16-black.png");
	width: 16px;
	height: 16px;
}

.icon-akeeba-red {
	background-image: url("../media/com_akeeba/icons/akeebabackup-16-red.png");
	width: 16px;
	height: 16px;
}

.quick-icons .nav-list [class^="icon-akeeba-"], .quick-icons .nav-list [class*=" icon-akeeba-"] {
	margin-right: 7px;
}

.quick-icons .nav-list [class^="icon-akeeba-red"], .quick-icons .nav-list [class*=" icon-akeeba-red"] {
	margin-bottom: -4px;
}
CSS;

			JFactory::getApplication()->getDocument()->addStyleDeclaration($inlineCSS);
		}

		// Re-enable self
		$db    = JFactory::getDbo();
		$query = $db->getQuery(true)
					->update($db->qn('#__extensions'))
					->set($db->qn('enabled') . ' = ' . $db->q('1'))
					->where($db->qn('element') . ' = ' . $db->q('akeebabackup'))
					->where($db->qn('folder') . ' = ' . $db->q('quickicon'));
		$db->setQuery($query);
		$db->execute();

		\FOF30\Utils\CacheCleaner::clearPluginsCache();

		return array($ret);
	}
Example #13
0
 public function execute()
 {
     define('AKEEBADEBUG', 1);
     // Set all errors to output the messages to the console, in order to
     // avoid infinite loops in JError ;)
     restore_error_handler();
     JError::setErrorHandling(E_ERROR, 'die');
     JError::setErrorHandling(E_WARNING, 'echo');
     JError::setErrorHandling(E_NOTICE, 'echo');
     // Required by Joomla!
     JLoader::import('joomla.environment.request');
     // Set the root path to Admin Tools Pro
     define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_ars');
     // Load F0F
     JLoader::import('f0f.include');
     // Load the language files
     $jlang = JFactory::getLanguage();
     $jlang->load('com_ars', JPATH_ADMINISTRATOR);
     $jlang->load('com_ars.override', JPATH_ADMINISTRATOR);
     // Load the version.php file
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/version.php';
     // Display banner
     $year = gmdate('Y');
     $phpversion = PHP_VERSION;
     $phpenvironment = PHP_SAPI;
     $this->out("Akeeba Release System Updater CLI");
     $this->out("Copyright (C) 2011-{$year} Nicholas K. Dionysopoulos");
     $this->out(str_repeat('-', 79));
     $this->out("Akeeba Release System is Free Software, distributed under the terms of the GNU General");
     $this->out("Public License version 3 or, at your option, any later version.");
     $this->out("This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the");
     $this->out("license. See http://www.gnu.org/licenses/gpl-3.0.html for details.");
     $this->out(str_repeat('-', 79));
     $this->out("You are using PHP {$phpversion} ({$phpenvironment})");
     $this->out("");
     $safe_mode = true;
     if (function_exists('ini_get')) {
         $safe_mode = ini_get('safe_mode');
     }
     if (!$safe_mode && function_exists('set_time_limit')) {
         $this->out("Unsetting time limit restrictions");
         @set_time_limit(0);
     }
     $this->out("Checking for new versions");
     $container = \FOF30\Container\Container::getInstance('com_akeebasubs');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Updates $updateModel */
     $updateModel = $container->factory->model('Updates')->tmpInstance();
     $result = $updateModel->autoupdate();
     echo implode("\n", $result['message']);
     $this->close(0);
 }
Example #14
0
File: View.php Project: akeeba/fof
 /**
  * Load a helper file
  *
  * @param   string $helperClass    The last part of the name of the helper
  *                                 class.
  *
  * @return  void
  *
  * @deprecated  3.0  Just use the class in your code. That's what the autoloader is for.
  */
 public function loadHelper($helperClass = null)
 {
     // Get the helper class name
     $className = '\\' . $this->container->getNamespacePrefix() . 'Helper\\' . ucfirst($helperClass);
     // This trick autoloads the helper class. We can't instantiate it as
     // helpers are (supposed to be) abstract classes with static method
     // interfaces.
     class_exists($className);
 }
Example #15
0
 /**
  * Returns the details of the latest backup as HTML
  *
  * @return  string  HTML
  */
 public function getLatestBackupDetails()
 {
     $db = Container::getInstance('com_akeeba')->db;
     $query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'))->where($db->qn('origin') . ' != ' . $db->q('restorepoint'));
     $db->setQuery($query);
     $id = $db->loadResult();
     $backup_types = Factory::getEngineParamsProvider()->loadScripting();
     if (empty($id)) {
         return '<p class="label">' . JText::_('COM_AKEEBA_BACKUP_STATUS_NONE') . '</p>';
     }
     $record = Platform::getInstance()->get_statistics($id);
     \JLoader::import('joomla.utilities.date');
     switch ($record['status']) {
         case 'run':
             $status = JText::_('COM_AKEEBA_BUADMIN_LABEL_STATUS_PENDING');
             $statusClass = "label-warning";
             break;
         case 'fail':
             $status = JText::_('COM_AKEEBA_BUADMIN_LABEL_STATUS_FAIL');
             $statusClass = "label-important";
             break;
         case 'complete':
             $status = JText::_('COM_AKEEBA_BUADMIN_LABEL_STATUS_OK');
             $statusClass = "label-success";
             break;
         default:
             $status = '';
             $statusClass = '';
     }
     switch ($record['origin']) {
         case 'frontend':
             $origin = JText::_('COM_AKEEBA_BUADMIN_LABEL_ORIGIN_FRONTEND');
             break;
         case 'backend':
             $origin = JText::_('COM_AKEEBA_BUADMIN_LABEL_ORIGIN_BACKEND');
             break;
         case 'cli':
             $origin = JText::_('COM_AKEEBA_BUADMIN_LABEL_ORIGIN_CLI');
             break;
         default:
             $origin = '&ndash;';
             break;
     }
     $type = '';
     if (array_key_exists($record['type'], $backup_types['scripts'])) {
         $type = Platform::getInstance()->translate($backup_types['scripts'][$record['type']]['text']);
     }
     $startTime = new \JDate($record['backupstart']);
     $html = '<table class="table table-striped">';
     $html .= '<tr><td>' . JText::_('COM_AKEEBA_BUADMIN_LABEL_START') . '</td><td>' . $startTime->format(JText::_('DATE_FORMAT_LC4'), true) . '</td></tr>';
     $html .= '<tr><td>' . JText::_('COM_AKEEBA_BUADMIN_LABEL_DESCRIPTION') . '</td><td>' . $record['description'] . '</td></tr>';
     $html .= '<tr><td>' . JText::_('COM_AKEEBA_BUADMIN_LABEL_STATUS') . '</td><td><span class="label ' . $statusClass . '">' . $status . '</span></td></tr>';
     $html .= '<tr><td>' . JText::_('COM_AKEEBA_BUADMIN_LABEL_ORIGIN') . '</td><td>' . $origin . '</td></tr>';
     $html .= '<tr><td>' . JText::_('COM_AKEEBA_BUADMIN_LABEL_TYPE') . '</td><td>' . $type . '</td></tr>';
     $html .= '</table>';
     return $html;
 }
Example #16
0
 public static function getFiles($selected = null, $release_id = 0, $item_id = 0, $id = 'type', $attribs = array())
 {
     $container = Container::getInstance('com_ars');
     /** @var Items $model */
     $model = $container->factory->model('Items')->tmpInstance();
     $options = $model->getFilesOptions($release_id, $item_id);
     return self::genericlist($options, $id, $attribs, $selected, $id);
 }
Example #17
0
 /**
  * Reads a "collection" XML update source and returns the complete tree of categories
  * and extensions applicable for platform version $jVersion
  *
  * @param   string  $url       The collection XML update source URL to read from
  * @param   string  $jVersion  Joomla! version to fetch updates for, or null to use JVERSION
  *
  * @return  array  A list of update sources applicable to $jVersion
  */
 public function getAllUpdates($url, $jVersion = null)
 {
     // Get the target platform
     if (is_null($jVersion)) {
         $jVersion = JVERSION;
     }
     // Initialise return value
     $updates = array('metadata' => array('name' => '', 'description' => ''), 'categories' => array(), 'extensions' => array());
     // Download and parse the XML file
     $container = Container::getInstance('com_foobar');
     $downloader = new Download($container);
     $xmlSource = $downloader->getFromURL($url);
     try {
         $xml = new SimpleXMLElement($xmlSource, LIBXML_NONET);
     } catch (Exception $e) {
         return $updates;
     }
     // Sanity check
     if ($xml->getName() != 'extensionset') {
         unset($xml);
         return $updates;
     }
     // Initialise return value with the stream metadata (name, description)
     $rootAttributes = $xml->attributes();
     foreach ($rootAttributes as $k => $v) {
         $updates['metadata'][$k] = (string) $v;
     }
     // Initialise the raw list of updates
     $rawUpdates = array('categories' => array(), 'extensions' => array());
     // Segregate the raw list to a hierarchy of extension and category entries
     /** @var SimpleXMLElement $extension */
     foreach ($xml->children() as $extension) {
         switch ($extension->getName()) {
             case 'category':
                 // These are the parameters we expect in a category
                 $params = array('name' => '', 'description' => '', 'category' => '', 'ref' => '', 'targetplatformversion' => $jVersion);
                 // These are the attributes of the element
                 $attributes = $extension->attributes();
                 // Merge them all
                 foreach ($attributes as $k => $v) {
                     $params[$k] = (string) $v;
                 }
                 // We can't have a category with an empty category name
                 if (empty($params['category'])) {
                     continue;
                 }
                 // We can't have a category with an empty ref
                 if (empty($params['ref'])) {
                     continue;
                 }
                 if (empty($params['description'])) {
                     $params['description'] = $params['category'];
                 }
                 if (!array_key_exists($params['category'], $rawUpdates['categories'])) {
                     $rawUpdates['categories'][$params['category']] = array();
                 }
                 $rawUpdates['categories'][$params['category']][] = $params;
                 break;
             case 'extension':
                 // These are the parameters we expect in a category
                 $params = array('element' => '', 'type' => '', 'version' => '', 'name' => '', 'detailsurl' => '', 'targetplatformversion' => $jVersion);
                 // These are the attributes of the element
                 $attributes = $extension->attributes();
                 // Merge them all
                 foreach ($attributes as $k => $v) {
                     $params[$k] = (string) $v;
                 }
                 // We can't have an extension with an empty element
                 if (empty($params['element'])) {
                     continue;
                 }
                 // We can't have an extension with an empty type
                 if (empty($params['type'])) {
                     continue;
                 }
                 // We can't have an extension with an empty version
                 if (empty($params['version'])) {
                     continue;
                 }
                 if (empty($params['name'])) {
                     $params['name'] = $params['element'] . ' ' . $params['version'];
                 }
                 if (!array_key_exists($params['type'], $rawUpdates['extensions'])) {
                     $rawUpdates['extensions'][$params['type']] = array();
                 }
                 if (!array_key_exists($params['element'], $rawUpdates['extensions'][$params['type']])) {
                     $rawUpdates['extensions'][$params['type']][$params['element']] = array();
                 }
                 $rawUpdates['extensions'][$params['type']][$params['element']][] = $params;
                 break;
             default:
                 break;
         }
     }
     unset($xml);
     if (!empty($rawUpdates['categories'])) {
         foreach ($rawUpdates['categories'] as $category => $entries) {
             $update = $this->filterListByPlatform($entries, $jVersion);
             $updates['categories'][$category] = $update;
         }
     }
     if (!empty($rawUpdates['extensions'])) {
         foreach ($rawUpdates['extensions'] as $type => $extensions) {
             $updates['extensions'][$type] = array();
             if (!empty($extensions)) {
                 foreach ($extensions as $element => $entries) {
                     $update = $this->filterListByPlatform($entries, $jVersion);
                     $updates['extensions'][$type][$element] = $update;
                 }
             }
         }
     }
     return $updates;
 }
Example #18
0
 /**
  * Returns a temporary container instance for a specific component.
  *
  * @param   string  $component  The component you want to get a container for, e.g. com_foobar.
  * @param   array   $values     Container configuration overrides you want to apply. Optional.
  * @param   string  $section    The application section (site, admin) you want to fetch. Any other value results in auto-detection.
  *
  * @return \FOF30\Container\Container
  */
 protected static function &makeInstance($component, array $values = array(), $section = 'auto')
 {
     // Try to auto-detect some defaults
     $tmpConfig = array_merge($values, array('componentName' => $component));
     $tmpContainer = new Container($tmpConfig);
     if (!in_array($section, array('site', 'admin'))) {
         $section = $tmpContainer->platform->isBackend() ? 'admin' : 'site';
     }
     $appConfig = $tmpContainer->appConfig;
     // Get the namespace from fof.xml
     $namespace = $appConfig->get('container.componentNamespace', null);
     // $values always overrides $namespace and fof.xml
     if (isset($values['componentNamespace'])) {
         $namespace = $values['componentNamespace'];
     }
     // If there is no namespace set, try to guess it.
     if (empty($namespace)) {
         $bareComponent = $component;
         if (substr($component, 0, 4) == 'com_') {
             $bareComponent = substr($component, 4);
         }
         $namespace = ucfirst($bareComponent);
     }
     // Get the default front-end/back-end paths
     $frontEndPath = $appConfig->get('container.frontEndPath', JPATH_SITE . '/components/' . $component);
     $backEndPath = $appConfig->get('container.backEndPath', JPATH_ADMINISTRATOR . '/components/' . $component);
     // Parse path variables if necessary
     $frontEndPath = $tmpContainer->parsePathVariables($frontEndPath);
     $backEndPath = $tmpContainer->parsePathVariables($backEndPath);
     // Apply path overrides
     if (isset($values['frontEndPath'])) {
         $frontEndPath = $values['frontEndPath'];
     }
     if (isset($values['backEndPath'])) {
         $backEndPath = $values['backEndPath'];
     }
     $thisPath = $section == 'admin' ? $backEndPath : $frontEndPath;
     // Get the namespaces for the front-end and back-end parts of the component
     $frontEndNamespace = '\\' . $namespace . '\\Site\\';
     $backEndNamespace = '\\' . $namespace . '\\Admin\\';
     // Special case: if the frontend and backend paths are identical, we don't use the Site and Admin namespace
     // suffixes after $this->componentNamespace (so you may use FOF with JApplicationWeb apps)
     if ($frontEndPath == $backEndPath) {
         $frontEndNamespace = '\\' . $namespace . '\\';
         $backEndNamespace = '\\' . $namespace . '\\';
     }
     // Do we have to register the component's namespaces with the autoloader?
     $autoloader = Autoloader::getInstance();
     if (!$autoloader->hasMap($frontEndNamespace)) {
         $autoloader->addMap($frontEndNamespace, $frontEndPath);
     }
     if (!$autoloader->hasMap($backEndNamespace)) {
         $autoloader->addMap($backEndNamespace, $backEndPath);
     }
     // Get the Container class name
     $classNamespace = $section == 'admin' ? $backEndNamespace : $frontEndNamespace;
     $class = $classNamespace . 'Container';
     // Get the values overrides from fof.xml
     $values = array_merge(array('factoryClass' => '\\FOF30\\Factory\\BasicFactory', 'platformClass' => '\\FOF30\\Platform\\Joomla\\Platform', 'scaffolding' => false, 'saveScaffolding' => false, 'saveControllerScaffolding' => false, 'saveModelScaffolding' => false, 'saveViewScaffolding' => false, 'section' => $section), $values);
     $values = array_merge($values, array('componentName' => $component, 'componentNamespace' => $namespace, 'frontEndPath' => $frontEndPath, 'backEndPath' => $backEndPath, 'thisPath' => $thisPath, 'rendererClass' => $appConfig->get('container.rendererClass', null), 'factoryClass' => $appConfig->get('container.factoryClass', $values['factoryClass']), 'platformClass' => $appConfig->get('container.platformClass', $values['platformClass']), 'scaffolding' => $appConfig->get('container.scaffolding', $values['scaffolding']), 'saveScaffolding' => $appConfig->get('container.saveScaffolding', $values['saveScaffolding']), 'saveControllerScaffolding' => $appConfig->get('container.saveControllerScaffolding', $values['saveControllerScaffolding']), 'saveModelScaffolding' => $appConfig->get('container.saveModelScaffolding', $values['saveModelScaffolding']), 'saveViewScaffolding' => $appConfig->get('container.saveViewScaffolding', $values['saveViewScaffolding'])));
     if (empty($values['rendererClass'])) {
         unset($values['rendererClass']);
     }
     $mediaVersion = $appConfig->get('container.mediaVersion', null);
     if (!empty($mediaVersion)) {
         $values['mediaVersion'] = $mediaVersion;
     }
     unset($appConfig);
     unset($tmpConfig);
     unset($tmpContainer);
     if (class_exists($class, true)) {
         $container = new $class($values);
     } else {
         $container = new Container($values);
     }
     return $container;
 }
    /**
     * Override this method to display a custom component installation message if you so wish
     *
     * @param  \JInstallerAdapterComponent  $parent  Parent class calling us
     */
    protected function renderPostInstallation($parent)
    {
        try {
            $this->warnAboutJSNPowerAdmin();
        } catch (Exception $e) {
            // Don't sweat if the site's db croaks while I'm checking for 3PD software that causes trouble
        }
        // Load the version file
        if (!defined('AKEEBA_PRO')) {
            @(include_once JPATH_ADMINISTRATOR . '/components/com_akeeba/version.php');
        }
        if (!defined('AKEEBA_PRO')) {
            define('AKEEBA_PRO', '0');
        }
        $videoTutorialURL = 'https://www.akeebabackup.com/videos/1212-akeeba-backup-core.html';
        if (AKEEBA_PRO) {
            $videoTutorialURL = 'https://www.akeebabackup.com/videos/1213-akeeba-backup-for-joomla-pro.html';
        }
        ?>
		<img src="../media/com_akeeba/icons/logo-48.png" width="48" height="48" alt="Akeeba Backup" align="right"/>

		<h2>Welcome to Akeeba Backup!</h2>

		<div style="margin: 1em; font-size: 14pt; background-color: #fffff9; color: black">
			You can download translation files <a href="http://cdn.akeebabackup.com/language/akeebabackup/index.html">directly
				from our CDN page</a>.
		</div>

		<fieldset>
			<p>
				We strongly recommend watching our
				<a href="<?php 
        echo $videoTutorialURL;
        ?>
">video
				tutorials</a> before using this component.
			</p>

			<p>
				If this is the first time you install Akeeba Backup on your site please run the
				<a href="index.php?option=com_akeeba&view=ConfigurationWizard">Configuration Wizard</a>. Akeeba Backup will
				configure itself optimally for your site.
			</p>

			<p>
				By installing this component you are implicitly accepting
				<a href="https://www.akeebabackup.com/license.html">its license (GNU GPLv3)</a> and our
				<a href="https://www.akeebabackup.com/privacy-policy.html">Terms of Service</a>,
				including our Support Policy.
			</p>
		</fieldset>
	<?php 
        // Let's install common tables
        $container = null;
        $model = null;
        if (class_exists('FOF30\\Container\\Container')) {
            try {
                $container = \FOF30\Container\Container::getInstance('com_akeeba');
            } catch (\Exception $e) {
                $container = null;
            }
        }
        if (is_object($container) && class_exists('FOF30\\Container\\Container') && $container instanceof \FOF30\Container\Container) {
            /** @var \Akeeba\Backup\Admin\Model\UsageStatistics $model */
            try {
                $model = $container->factory->model('UsageStatistics')->tmpInstance();
            } catch (\Exception $e) {
                $model = null;
            }
        }
        /** @var \Akeeba\Backup\Admin\Model\UsageStatistics $model */
        try {
            if (is_object($model) && class_exists('Akeeba\\Backup\\Admin\\Model\\UsageStatistics') && $model instanceof Akeeba\Backup\Admin\Model\UsageStatistics && method_exists($model, 'collectStatistics')) {
                $iframe = $model->collectStatistics(true);
                if ($iframe) {
                    echo $iframe;
                }
            }
        } catch (\Exception $e) {
        }
    }
Example #20
0
 /**
  * Renders a raw fieldset of a F0FForm and returns the corresponding HTML
  *
  * @param   \stdClass  &$fieldset   The fieldset to render
  * @param   Form       &$form       The form to render
  * @param   DataModel  $model       The model providing our data
  * @param   string     $formType    The form type e.g. 'edit' or 'read'
  * @param   boolean    $showHeader  Should I render the fieldset's header?
  * @param   string     $innerHtml   Render inner tab if set
  *
  * @return  string    The HTML rendering of the fieldset
  */
 public function renderFieldset(\stdClass &$fieldset, Form &$form, DataModel $model, $formType, $showHeader = true, &$innerHtml = null)
 {
     $html = '';
     $fields = $form->getFieldset($fieldset->name);
     if (isset($fieldset->class)) {
         $class = 'class="' . $fieldset->class . '"';
     } else {
         $class = '';
     }
     if (isset($innerHtml[$fieldset->name])) {
         $innerclass = isset($fieldset->innerclass) ? ' class="' . $fieldset->innerclass . '"' : '';
         $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . "\n";
         $html .= "\t\t" . '<div' . $innerclass . '>' . "\n";
     } else {
         $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . "\n";
     }
     $isTabbedFieldset = $this->isTabFieldset($fieldset);
     if (isset($fieldset->label) && !empty($fieldset->label) && !$isTabbedFieldset) {
         $html .= "\t\t" . '<h3>' . \JText::_($fieldset->label) . '</h3>' . "\n";
     }
     // Add an external view template, if specified
     $sourceTemplate = isset($fieldset->source) ? $fieldset->source : null;
     $sourceView = isset($fieldset->source_view) ? $fieldset->source_view : null;
     $sourceViewType = isset($fieldset->source_view_type) ? $fieldset->source_view_type : 'html';
     $sourceComponent = isset($fieldset->source_component) ? $fieldset->source_component : null;
     if (!empty($sourceTemplate)) {
         $sourceContainer = empty($sourceComponent) ? $this->container : Container::getInstance($sourceComponent);
         if (empty($sourceView)) {
             $viewObject = new View($sourceContainer, array('name' => 'FAKE_FORM_VIEW'));
         } else {
             $viewObject = $sourceContainer->factory->view($sourceView, $sourceViewType);
         }
         $viewObject->populateFromModel($model);
         $html .= $viewObject->loadAnyTemplate($sourceTemplate, array('model' => $model, 'form' => $form, 'fieldset' => $fieldset, 'formType' => $formType, 'innerHtml' => $innerHtml));
     }
     // Add the fieldset fields
     if (!empty($fields)) {
         foreach ($fields as $field) {
             $groupClass = $form->getFieldAttribute($field->fieldname, 'groupclass', '', $field->group);
             // Auto-generate label and description if needed
             // Field label
             $title = $form->getFieldAttribute($field->fieldname, 'label', '', $field->group);
             $emptylabel = $form->getFieldAttribute($field->fieldname, 'emptylabel', false, $field->group);
             $label_placement = $form->getFieldAttribute($field->fieldname, 'label_placement', null, $field->group);
             if (empty($title) && !$emptylabel) {
                 $model->getName();
                 $title = strtoupper($this->container->componentName . '_' . $model->getName() . '_' . $field->id . '_LABEL');
             }
             if (empty($label_placement)) {
                 $label_placement = !empty($title) ? 'left' : 'none';
             }
             // Field description
             $description = $form->getFieldAttribute($field->fieldname, 'description', '', $field->group);
             /**
              * The following code is backwards incompatible. Most forms don't require a description in their form
              * fields. Having to use emptydescription="1" on each one of them is an overkill. Removed.
              */
             /*
             $emptydescription   = $form->getFieldAttribute($field->fieldname, 'emptydescription', false, $field->group);
             if (empty($description) && !$emptydescription)
             {
             	$description = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_DESC');
             }
             */
             // Do we have field "prepend" and "append" text?
             $prependText = $form->getFieldAttribute($field->fieldname, 'prepend_text', '', $field->group);
             $appendText = $form->getFieldAttribute($field->fieldname, 'append_text', '', $field->group);
             if (!empty($prependText)) {
                 $prependText = \JText::_($prependText);
             }
             if (!empty($appendText)) {
                 $appendText = \JText::_($appendText);
             }
             $inputField = '';
             if ($formType == 'read') {
                 $inputField = $field->static;
             }
             if ($formType == 'edit') {
                 $inputField = $field->input;
             }
             if ($prependText || $appendText) {
                 $wrapperClass = $prependText ? 'input-prepend' : '';
                 $wrapperClass .= $appendText ? 'input-append' : '';
             }
             $renderedLabel = !empty($title) ? $this->renderFieldsetLabel($field, $form, $title) : '';
             $renderedLabel = $label_placement == 'empty' ? '' : $renderedLabel;
             switch ($label_placement) {
                 case 'left':
                 case 'empty':
                     $html .= "\t\t\t" . '<div class="control-group ' . $groupClass . '">' . "\n";
                     $html .= "\t\t\t" . $renderedLabel;
                     $html .= "\t\t\t\t" . '<div class="controls">' . "\n";
                     break;
                 case 'top':
                     $html .= "\t\t\t" . '<div class="' . $groupClass . '">' . "\n";
                     $html .= "\t\t\t" . $renderedLabel . "<br/>\n";
                     break;
             }
             if ($prependText || $appendText) {
                 $html .= "\t\t\t\t<div class=\"{$wrapperClass}\">\n";
             }
             if ($prependText) {
                 $html .= "\t\t\t\t\t<span class=\"add-on\">{$prependText}</span>\n";
             }
             $html .= "\t\t\t\t\t" . $inputField . "\n";
             if ($appendText) {
                 $html .= "\t\t\t\t\t<span class=\"add-on\">{$appendText}</span>\n";
             }
             if ($prependText || $appendText) {
                 $html .= "\t\t\t\t</div>\n";
             }
             if (!empty($description)) {
                 $html .= "\t\t\t\t" . '<span class="help-block">';
                 $html .= \JText::_($description) . '</span>' . "\n";
             }
             switch ($label_placement) {
                 case 'left':
                 case 'empty':
                     $html .= "\t\t\t\t" . '</div>' . "\n";
                     $html .= "\t\t\t" . '</div>' . "\n";
                     break;
                 case 'top':
                     $html .= "\t\t\t" . '</div>' . "\n";
                     break;
                 case 'bottom':
                     $html .= "\t\t\t" . '<br/>' . "\n";
                     $html .= "\t\t\t" . $renderedLabel . "\n";
                     $html .= "\t\t\t" . '</div>' . "\n";
             }
         }
     }
     if (isset($innerHtml[$fieldset->name])) {
         $html .= "\t\t" . '</div>' . "\n";
         $html .= implode('', $innerHtml[$fieldset->name]) . "\n";
         $html .= "\t" . '</div>' . "\n";
     } else {
         $html .= "\t" . '</div>' . "\n";
     }
     return $html;
 }
Example #21
0
 /**
  * Inisialises the arrays.
  */
 private function initialise()
 {
     // Make sure our auto-loader is set up and ready
     $container = \FOF30\Container\Container::getInstance('com_ars');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Releases $model */
     $model = $container->factory->model('Releases');
     $model->reset(true)->published(1)->latest(true)->access_user($container->platform->getUser()->id)->with(['items', 'category']);
     /** @var \FOF30\Model\DataModel\Collection $releases */
     $releases = $model->get(true)->filter(function ($item) {
         return \Akeeba\ReleaseSystem\Site\Helper\Filter::filterItem($item, true);
     });
     $cats = [];
     if ($releases->count()) {
         /** @var \Akeeba\ReleaseSystem\Admin\Model\Releases $release */
         foreach ($releases as $release) {
             $cat = $release->category;
             $cat->title = trim(strtoupper($cat->title));
             $cats[] = $cat;
             $this->categoryTitles[$cat->title] = $cat->id;
             $this->categoryLatest[$cat->id] = $release;
         }
     }
     $this->prepared = true;
 }
Example #22
0
function arsBuildRouteRaw(&$query)
{
    $segments = array();
    $view = ArsRouterHelper::getAndPop($query, 'view', 'invalid');
    $task = ArsRouterHelper::getAndPop($query, 'task', 'download');
    // Map all possible views
    if (in_array($view, ['download', 'Download', 'downloads', 'Downloads', 'Items', 'Item'])) {
        $view = 'Item';
        $task = 'download';
    }
    if ($view != 'Item' || $task != 'download') {
        return $segments;
    }
    $container = \FOF30\Container\Container::getInstance('com_ars');
    $id = ArsRouterHelper::getAndPop($query, 'id');
    $Itemid = ArsRouterHelper::getAndPop($query, 'Itemid');
    $menus = JMenu::getInstance('site');
    // Get download item info
    /** @var \Akeeba\ReleaseSystem\Site\Model\Items $download */
    $download = $container->factory->model('Items')->tmpInstance();
    $download->find($id);
    // If we have an extension other than html, raw, ini, xml, php try to set the format to manipulate the extension (if
    // Joomla! is configured to use extensions in URLs)
    $fileTarget = $download->type == 'link' ? $download->url : $download->filename;
    $extension = pathinfo($fileTarget, PATHINFO_EXTENSION);
    if (!in_array($extension, ['html', 'raw', 'ini', 'xml', 'php'])) {
        $query['format'] = $extension;
    }
    // Get release info
    $release = $download->release;
    // Get category alias
    $catAlias = $release->category->alias;
    $catVgroupId = $release->category->vgroup_id;
    if ($Itemid) {
        $menu = $menus->getItem($Itemid);
        $mview = '';
        if (!empty($menu)) {
            if (isset($menu->query['view'])) {
                $mview = $menu->query['view'];
            }
        }
        switch ($mview) {
            case 'browses':
            case 'browse':
            case 'Categories':
                $segments[] = $catAlias;
                $segments[] = $release->alias;
                $segments[] = $download->alias;
                $query['Itemid'] = $Itemid;
                break;
            case 'category':
            case 'Releases':
                $params = $menu->params instanceof JRegistry ? $menu->params : $menus->getParams($Itemid);
                if ($params->get('catid', 0) == $release->category_id) {
                    $segments[] = $release->alias;
                    $segments[] = $download->alias;
                    $query['Itemid'] = $Itemid;
                } else {
                    $Itemid = null;
                }
                break;
            case 'release':
            case 'Items':
                $params = $menu->params instanceof JRegistry ? $menu->params : $menus->getParams($Itemid);
                if ($params->get('relid', 0) == $release->id) {
                    $segments[] = $download->alias;
                    $query['Itemid'] = $Itemid;
                } else {
                    $Itemid = null;
                }
                break;
            default:
                $Itemid = null;
        }
    }
    if (empty($Itemid)) {
        $options = array('option' => 'com_ars', 'view' => 'Items');
        $params = array('relid' => $release->id);
        if ($catVgroupId) {
            $options['vgroupid'] = $catVgroupId;
        }
        $possibleViews = ['Items', 'release'];
        $menu = null;
        foreach ($possibleViews as $possibleView) {
            $altQueryOptions = array_merge($options, ['view' => $possibleView]);
            $menu = ArsRouterHelper::findMenu($altQueryOptions, $params);
            if (is_object($menu)) {
                break;
            }
        }
        if (is_object($menu)) {
            $segments[] = $download->alias;
            $query['Itemid'] = $menu->id;
        } else {
            $options = array('option' => 'com_ars', 'view' => 'category');
            $params = array('catid' => $release->category_id);
            if ($catVgroupId) {
                $options['vgroupid'] = $catVgroupId;
            }
            $possibleViews = ['Releases', 'category'];
            foreach ($possibleViews as $possibleView) {
                $altQueryOptions = array_merge($options, ['view' => $possibleView]);
                $menu = ArsRouterHelper::findMenu($altQueryOptions, $params);
                if (is_object($menu)) {
                    break;
                }
            }
        }
        if (is_object($menu)) {
            $segments[] = $release->alias;
            $segments[] = $download->alias;
            $query['Itemid'] = $menu->id;
        }
        if (!is_object($menu)) {
            $options = array('view' => 'browses', 'option' => 'com_ars');
            if ($catVgroupId) {
                $options['vgroupid'] = $catVgroupId;
            }
            $possibleViews = ['Categories', 'browse', 'browses'];
            $menu = null;
            foreach ($possibleViews as $possibleView) {
                $altQueryOptions = array_merge($options, ['view' => $possibleView]);
                $menu = ArsRouterHelper::findMenu($altQueryOptions);
                if (is_object($menu)) {
                    break;
                }
            }
            if (!is_object($menu)) {
                $segments[] = 'repository';
                $segments[] = $catAlias;
                $segments[] = $release->alias;
                $segments[] = $download->alias;
            } else {
                $segments[] = $catAlias;
                $segments[] = $release->alias;
                $segments[] = $download->alias;
                $query['Itemid'] = $menu->id;
            }
        }
    }
    return $segments;
}
Example #23
0
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getRenderedTemplate($isRepeatable = false)
 {
     $sourceTemplate = isset($this->element['source']) ? (string) $this->element['source'] : null;
     $sourceView = isset($this->element['source_view']) ? (string) $this->element['source_view'] : null;
     $sourceViewType = isset($this->element['source_view_type']) ? (string) $this->element['source_view_type'] : 'html';
     $sourceComponent = isset($this->element['source_component']) ? (string) $this->element['source_component'] : null;
     if (empty($sourceTemplate)) {
         return '';
     }
     $sourceContainer = empty($sourceComponent) ? $this->form->getContainer() : Container::getInstance($sourceComponent);
     if (empty($sourceView)) {
         $viewObject = new View($sourceContainer, array('name' => 'FAKE_FORM_VIEW'));
     } else {
         $viewObject = $sourceContainer->factory->view($sourceView, $sourceViewType);
     }
     $viewObject->populateFromModel($this->form->getModel());
     return $viewObject->loadAnyTemplate($sourceTemplate, array('model' => $isRepeatable ? $this->item : $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
 }
Example #24
0
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string                $type   install, update or discover_update
  * @param   JInstallerAdapterLibrary $parent Parent object
  */
 public function postflight($type, JInstallerAdapterLibrary $parent)
 {
     $this->loadFOF30();
     if (!defined('FOF30_INCLUDED')) {
         return;
     }
     // Install or update database
     $db = JFactory::getDbo();
     /** @var JInstaller $grandpa */
     $grandpa = $parent->getParent();
     $src = $grandpa->getPath('source');
     $sqlSource = $src . '/fof/sql';
     // If we have an uppercase db prefix we can expect the database update to fail because we cannot detect reliably
     // the existence of database tables. See https://github.com/joomla/joomla-cms/issues/10928#issuecomment-228549658
     $prefix = $db->getPrefix();
     $canFail = preg_match('/[A-Z]/', $prefix);
     try {
         $dbInstaller = new FOF30\Database\Installer($db, $sqlSource);
         $dbInstaller->updateSchema();
     } catch (\Exception $e) {
         if (!$canFail) {
             throw $e;
         }
     }
     // Since we're adding common table, I have to nuke the installer cache, otherwise checks on their existence would fail
     $dbInstaller->nukeCache();
     // Clear the FOF cache
     $fakeController = \FOF30\Container\Container::getInstance('com_FOOBAR');
     $fakeController->platform->clearCache();
 }
Example #25
0
 /**
  * Gets an object instance of the foreign model
  *
  * @param  array  $config  Optional configuration information for the Model
  *
  * @return DataModel
  */
 public function &getForeignModel(array $config = array())
 {
     // If the model comes from this component go through our Factory
     if (is_null($this->foreignModelComponent)) {
         $model = $this->container->factory->model($this->foreignModelName, $config)->tmpInstance();
         return $model;
     }
     // The model comes from another component. Create a container and go through its factory.
     $foreignContainer = Container::getInstance($this->foreignModelComponent, array('tempInstance' => true));
     $model = $foreignContainer->factory->model($this->foreignModelName, $config)->tmpInstance();
     return $model;
 }
Example #26
0
 /**
  * Returns the main download ID for a user. If it doesn't exist it creates a new one.
  *
  * @return mixed
  */
 public static function myDownloadID($user_id = null)
 {
     $container = Container::getInstance('com_ars');
     $user = $container->platform->getUser($user_id);
     if ($user->guest) {
         return '';
     }
     /** @var DownloadIDLabels $model */
     $model = $container->factory->model('DownloadIDLabels')->tmpInstance();
     $dlidRecord = $model->user_id($user->id)->primary(1)->firstOrCreate(['user_id' => $user->id, 'primary' => 1, 'enabled' => 1]);
     return $dlidRecord->dlid;
 }
Example #27
0
 /**
  * Returns a list of all currently active subscription levels for a specific Joomla! user ID. The return is an array
  * of integers, e.g. [1, 2, 5, 8]
  *
  * @return  array
  */
 public function getGroupsForUser($user_id)
 {
     // If we are not logged in we don't have any active subscriptions.
     if (empty($user_id)) {
         return [];
     }
     $container = Container::getInstance('com_akeebasubs');
     $subscriptionsModel = $container->factory->model('Subscriptions')->tmpInstance();
     $rawList = $subscriptionsModel->enabled(1)->user_id($user_id)->get(true);
     $theList = array();
     if ($rawList->count()) {
         foreach ($rawList as $item) {
             $theList[] = $item->akeebasubs_level_id;
         }
     }
     return array_unique($theList);
 }
Example #28
0
File: Form.php Project: Joal01/fof
 /**
  * Load a class for one of the form's entities of a particular type.
  * Currently, it makes sense to use this method for the "field" and "rule" entities
  * (but you can support more entities in your subclass).
  *
  * @param   string $entity One of the form entities (field, header or rule).
  * @param   string $type   Type of an entity.
  *
  * @return  mixed  Class name on success or false otherwise.
  *
  * @since   2.0
  */
 public function loadClass($entity, $type)
 {
     // Get the prefixes for namespaced classes (FOF3 way)
     $namespacedPrefixes = array($this->container->getNamespacePrefix(), 'FOF30\\');
     // Get the prefixes for non-namespaced classes (FOF2 and Joomla! way)
     $plainPrefixes = array('J');
     // If the type is given as prefix.type add the custom type into the two prefix arrays
     if (strpos($type, '.')) {
         list($prefix, $type) = explode('.', $type);
         array_unshift($plainPrefixes, $prefix);
         array_unshift($namespacedPrefixes, $prefix);
     }
     // First try to find the namespaced class
     foreach ($namespacedPrefixes as $prefix) {
         $class = rtrim($prefix, '\\') . '\\Form\\' . ucfirst($entity) . '\\' . ucfirst($type);
         if (class_exists($class, true)) {
             return $class;
         }
     }
     // TODO The rest of the code is legacy and will be removed in a future version
     // Then try to find the non-namespaced class
     $classes = array();
     foreach ($plainPrefixes as $prefix) {
         $class = \JString::ucfirst($prefix, '_') . 'Form' . \JString::ucfirst($entity, '_') . \JString::ucfirst($type, '_');
         if (class_exists($class, true)) {
             return $class;
         }
         $classes[] = $class;
     }
     // Get the field search path array.
     $reflector = new \ReflectionClass('\\JFormHelper');
     $addPathMethod = $reflector->getMethod('addPath');
     $addPathMethod->setAccessible(true);
     $paths = $addPathMethod->invoke(null, $entity);
     // If the type is complex, add the base type to the paths.
     if ($pos = strpos($type, '_')) {
         // Add the complex type prefix to the paths.
         for ($i = 0, $n = count($paths); $i < $n; $i++) {
             // Derive the new path.
             $path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
             // If the path does not exist, add it.
             if (!in_array($path, $paths)) {
                 $paths[] = $path;
             }
         }
         // Break off the end of the complex type.
         $type = substr($type, $pos + 1);
     }
     // Try to find the class file.
     $type = strtolower($type) . '.php';
     foreach ($paths as $path) {
         if ($file = \JPath::find($path, $type)) {
             require_once $file;
             foreach ($classes as $class) {
                 if (class_exists($class, false)) {
                     return $class;
                 }
             }
         }
     }
     return false;
 }
Example #29
0
<?php

/**
 * @package   AkeebaReleaseSystem
 * @copyright Copyright (c)2010-2014 Nicholas K. Dionysopoulos
 * @license   GNU General Public License version 3, or later
 * @version   $Id$
 */
defined('_JEXEC') or die;
if (!defined('FOF30_INCLUDED') && !@(include_once JPATH_LIBRARIES . '/fof30/include.php')) {
    return;
}
// Do not run if Akeeba Subscriptions is not enabled
JLoader::import('joomla.application.component.helper');
if (!JComponentHelper::isEnabled('com_ars')) {
    return;
}
if (!class_exists('Akeeba\\ReleaseSystem\\Site\\Helper\\Filter')) {
    // This has the side-effect of initialising our auto-loader
    \FOF30\Container\Container::getInstance('com_ars');
}
$dlid = \Akeeba\ReleaseSystem\Site\Helper\Filter::myDownloadID();
if (!is_null($dlid)) {
    require JModuleHelper::getLayoutPath('mod_arsdlid', $params->get('layout', 'default'));
}
Example #30
0
 /**
  * Reads an "extension" XML update source and returns all listed update entries.
  *
  * If you have a "collection" XML update source you should do something like this:
  * $collection = new F0FUtilsUpdateCollection();
  * $extensionUpdateURL = $collection->getExtensionUpdateSource($url, 'component', 'com_foobar', JVERSION);
  * $extension = new F0FUtilsUpdateExtension();
  * $updates = $extension->getUpdatesFromExtension($extensionUpdateURL);
  *
  * @param   string  $url  The extension XML update source URL to read from
  *
  * @return  array  An array of update entries
  */
 public function getUpdatesFromExtension($url)
 {
     // Initialise
     $ret = array();
     // Get and parse the XML source
     $container = Container::getInstance('com_FOOBAR');
     $downloader = new Download($container);
     $xmlSource = $downloader->getFromURL($url);
     try {
         $xml = new SimpleXMLElement($xmlSource, LIBXML_NONET);
     } catch (Exception $e) {
         return $ret;
     }
     // Sanity check
     if ($xml->getName() != 'updates') {
         unset($xml);
         return $ret;
     }
     // Let's populate the list of updates
     /** @var SimpleXMLElement $update */
     foreach ($xml->children() as $update) {
         // Sanity check
         if ($update->getName() != 'update') {
             continue;
         }
         $entry = array('infourl' => array('title' => '', 'url' => ''), 'downloads' => array(), 'tags' => array(), 'targetplatform' => array());
         $properties = get_object_vars($update);
         foreach ($properties as $nodeName => $nodeContent) {
             switch ($nodeName) {
                 default:
                     $entry[$nodeName] = $nodeContent;
                     break;
                 case 'infourl':
                 case 'downloads':
                 case 'tags':
                 case 'targetplatform':
                     break;
             }
         }
         $infourlNode = $update->xpath('infourl');
         $entry['infourl']['title'] = (string) $infourlNode[0]['title'];
         $entry['infourl']['url'] = (string) $infourlNode[0];
         $downloadNodes = $update->xpath('downloads/downloadurl');
         foreach ($downloadNodes as $downloadNode) {
             $entry['downloads'][] = array('type' => (string) $downloadNode['type'], 'format' => (string) $downloadNode['format'], 'url' => (string) $downloadNode);
         }
         $tagNodes = $update->xpath('tags/tag');
         foreach ($tagNodes as $tagNode) {
             $entry['tags'][] = (string) $tagNode;
         }
         /** @var SimpleXMLElement[] $targetPlatformNode */
         $targetPlatformNode = $update->xpath('targetplatform');
         $entry['targetplatform']['name'] = (string) $targetPlatformNode[0]['name'];
         $entry['targetplatform']['version'] = (string) $targetPlatformNode[0]['version'];
         $client = $targetPlatformNode[0]->xpath('client');
         $entry['targetplatform']['client'] = is_array($client) && count($client) ? (string) $client[0] : '';
         $folder = $targetPlatformNode[0]->xpath('folder');
         $entry['targetplatform']['folder'] = is_array($folder) && count($folder) ? (string) $folder[0] : '';
         $ret[] = $entry;
     }
     unset($xml);
     return $ret;
 }