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


PHP Engine\Factory类代码示例

本文整理汇总了PHP中Akeeba\Engine\Factory的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _prepare

 protected function _prepare()
 {
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Processing parameters");
     // Get the DB connection parameters
     if (is_array($this->_parametersArray)) {
         $driver = array_key_exists('driver', $this->_parametersArray) ? $this->_parametersArray['driver'] : 'mysql';
         $host = array_key_exists('host', $this->_parametersArray) ? $this->_parametersArray['host'] : '';
         $port = array_key_exists('port', $this->_parametersArray) ? $this->_parametersArray['port'] : '';
         $username = array_key_exists('username', $this->_parametersArray) ? $this->_parametersArray['username'] : '';
         $username = array_key_exists('user', $this->_parametersArray) ? $this->_parametersArray['user'] : $username;
         $password = array_key_exists('password', $this->_parametersArray) ? $this->_parametersArray['password'] : '';
         $database = array_key_exists('database', $this->_parametersArray) ? $this->_parametersArray['database'] : '';
         $prefix = array_key_exists('prefix', $this->_parametersArray) ? $this->_parametersArray['prefix'] : '';
     }
     if ($driver == 'mysql' && !function_exists('mysql_connect')) {
         $driver = 'mysqli';
     }
     $options = array('driver' => $driver, 'host' => $host . ($port != '' ? ':' . $port : ''), 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => is_null($prefix) ? '' : $prefix);
     $db = Factory::getDatabase($options);
     $driverType = $db->getDriverType();
     if ($driverType == 'mssql') {
         $driverType = 'sqlsrv';
     }
     $className = '\\Akeeba\\Engine\\Dump\\Reverse\\' . ucfirst($driverType);
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Instanciating new reverse engineering database dump engine {$className}");
     if (!class_exists($className, true)) {
         $this->setState('error', 'Akeeba Engine does not have a reverse engineering dump engine for ' . $driverType . ' databases');
     } else {
         $this->_engine = new $className();
         $this->_engine->setup($this->_parametersArray);
         $this->_engine->callStage('_prepare');
         $this->setState($this->_engine->getState(), $this->_engine->getError());
         $this->propagateFromObject($this->_engine);
     }
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:35,代码来源:Reverse.php

示例2: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('profile' => -1, 'engineconfig' => array());
     $defConfig = array_merge($defConfig, $parameters);
     $profile = (int) $defConfig['profile'];
     $data = $defConfig['engineconfig'];
     if (empty($profile)) {
         throw new \RuntimeException('Invalid profile ID', 404);
     }
     // Forbid stupidly selecting the site's root as the output or temporary directory
     if (array_key_exists('akeeba.basic.output_directory', $data)) {
         $folder = $data['akeeba.basic.output_directory'];
         $folder = Factory::getFilesystemTools()->translateStockDirs($folder, true, true);
         $check = Factory::getFilesystemTools()->translateStockDirs('[SITEROOT]', true, true);
         if ($check == $folder) {
             $data['akeeba.basic.output_directory'] = '[DEFAULT_OUTPUT]';
         }
     }
     // Merge it
     $config = Factory::getConfiguration();
     $protectedKeys = $config->getProtectedKeys();
     $config->resetProtectedKeys();
     $config->mergeArray($data, false, false);
     $config->setProtectedKeys($protectedKeys);
     // Save configuration
     return Platform::getInstance()->save_configuration($profile);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:37,代码来源:SaveConfiguration.php

示例3: onBrowse

 public function onBrowse($tpl = null)
 {
     AkeebaStrapper::addJSfile('media://com_akeeba/js/fsfilter.js');
     $model = $this->getModel();
     $task = $model->getState('browse_task', 'normal');
     // Add custom submenus
     $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
     $toolbar->appendLink(JText::_('FILTERS_LABEL_NORMALVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=normal', $task == 'normal');
     $toolbar->appendLink(JText::_('FILTERS_LABEL_TABULARVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=tabular', $task == 'tabular');
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Get a JSON representation of the available roots
     $filters = Factory::getFilters();
     $root_info = $filters->getInclusions('dir');
     $roots = array();
     $options = array();
     if (!empty($root_info)) {
         // Loop all dir definitions
         foreach ($root_info as $dir_definition) {
             if (is_null($dir_definition[1])) {
                 // Site root definition has a null element 1. It is always pushed on top of the stack.
                 array_unshift($roots, $dir_definition[0]);
             } else {
                 $roots[] = $dir_definition[0];
             }
             $options[] = JHTML::_('select.option', $dir_definition[0], $dir_definition[0]);
         }
     }
     $site_root = $roots[0];
     $attribs = 'onchange="akeeba.Fsfilters.activeRootChanged();"';
     $this->root_select = JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root');
     $this->roots = $roots;
     switch ($task) {
         case 'normal':
         default:
             $this->setLayout('default');
             // Get a JSON representation of the directory data
             $model = $this->getModel();
             $json = json_encode($model->make_listing($site_root, array(), ''));
             $this->json = $json;
             break;
         case 'tabular':
             $this->setLayout('tabular');
             // Get a JSON representation of the tabular filter data
             $model = $this->getModel();
             $json = json_encode($model->get_filters($site_root));
             $this->json = $json;
             break;
     }
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $pmodel = F0FModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->profilename = $this->escape($profile_data->description);
     return true;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:60,代码来源:view.html.php

示例4: _prepare

 protected function _prepare()
 {
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Processing parameters");
     $options = null;
     // Get the DB connection parameters
     if (is_array($this->_parametersArray)) {
         $driver = array_key_exists('driver', $this->_parametersArray) ? $this->_parametersArray['driver'] : 'mysql';
         $host = array_key_exists('host', $this->_parametersArray) ? $this->_parametersArray['host'] : '';
         $port = array_key_exists('port', $this->_parametersArray) ? $this->_parametersArray['port'] : '';
         $username = array_key_exists('username', $this->_parametersArray) ? $this->_parametersArray['username'] : '';
         $username = array_key_exists('user', $this->_parametersArray) ? $this->_parametersArray['user'] : $username;
         $password = array_key_exists('password', $this->_parametersArray) ? $this->_parametersArray['password'] : '';
         $database = array_key_exists('database', $this->_parametersArray) ? $this->_parametersArray['database'] : '';
         $prefix = array_key_exists('prefix', $this->_parametersArray) ? $this->_parametersArray['prefix'] : '';
         $options = array('driver' => $driver, 'host' => $host . ($port != '' ? ':' . $port : ''), 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => is_null($prefix) ? '' : $prefix);
     }
     $db = Factory::getDatabase($options);
     $driverType = $db->getDriverType();
     $className = '\\Akeeba\\Engine\\Dump\\Native\\' . ucfirst($driverType);
     // Check if we have a native dump driver
     if (!class_exists($className, true)) {
         Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Native database dump engine {$className} not found; trying Reverse Engineering instead");
         // Native driver nor found, I will try falling back to reverse engineering
         $className = '\\Akeeba\\Engine\\Dump\\Reverse\\' . ucfirst($driverType);
     }
     if (!class_exists($className, true)) {
         $this->setState('error', 'Akeeba Engine does not have a native dump engine for ' . $driverType . ' databases');
     } else {
         Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Instanciating new native database dump engine {$className}");
         $this->_engine = new $className();
         $this->_engine->setup($this->_parametersArray);
         $this->_engine->callStage('_prepare');
         $this->setState($this->_engine->getState(), $this->_engine->getError());
     }
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:35,代码来源:Native.php

示例5: getLatestBackupInformation

 /**
  * Get the information for the latest backup
  *
  * @return   array|null  An array of backup record information or null if there is no usable backup for site transfer
  */
 public function getLatestBackupInformation()
 {
     // Initialise
     $ret = null;
     $db = Factory::getDatabase();
     /** @var AkeebaModelStatistics $model */
     $model = F0FModel::getTmpInstance('Statistics', 'AkeebaModel');
     $model->savestate(0);
     $model->setState('limitstart', 0);
     $model->setState('limit', 1);
     $backups = $model->getStatisticsListWithMeta(false, null, $db->qn('id') . ' DESC');
     // No valid backups? No joy.
     if (empty($backups)) {
         return $ret;
     }
     // Get the latest backup
     $backup = array_shift($backups);
     // If it's not stored on the server (e.g. remote backup), no joy.
     if ($backup['meta'] != 'ok') {
         return $ret;
     }
     // If it's not a full site backup, no joy.
     if ($backup['type'] != 'full') {
         return $ret;
     }
     return $backup;
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:32,代码来源:transfers.php

示例6: onAdd

 public function onAdd($tpl = null)
 {
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get a JSON representation of GUI data
     $json = AkeebaHelperEscape::escapeJS(Factory::getEngineParamsProvider()->getJsonGuiDefinition(), '"\\');
     $this->json = $json;
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $profileName = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->profilename = $profileName;
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Are the settings secured?
     if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
         $this->securesettings = -1;
     } elseif (!Factory::getSecureSettings()->supportsEncryption()) {
         $this->securesettings = 0;
     } else {
         JLoader::import('joomla.filesystem.file');
         $filename = JPATH_COMPONENT_ADMINISTRATOR . '/engine/serverkey.php';
         if (JFile::exists($filename)) {
             $this->securesettings = 1;
         } else {
             $this->securesettings = 0;
         }
     }
     // Add live help
     AkeebaHelperIncludes::addHelp('config');
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:31,代码来源:view.html.php

示例7: __construct

 public function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'inclusion';
     $this->method = 'direct';
     $this->filter_name = 'Libraries';
     // FIXME This filter doesn't work very well on many live hosts. Disabled for now.
     parent::__construct();
     return;
     if (empty($this->filter_name)) {
         $this->filter_name = strtolower(basename(__FILE__, '.php'));
     }
     // Get the saved library path and compare it to the default
     $jlibdir = Platform::getInstance()->get_platform_configuration_option('jlibrariesdir', '');
     if (empty($jlibdir)) {
         if (defined('JPATH_LIBRARIES')) {
             $jlibdir = JPATH_LIBRARIES;
         } elseif (defined('JPATH_PLATFORM')) {
             $jlibdir = JPATH_PLATFORM;
         } else {
             $jlibdir = false;
         }
     }
     if ($jlibdir !== false) {
         $jlibdir = Factory::getFilesystemTools()->TranslateWinPath($jlibdir);
         $defaultLibraries = Factory::getFilesystemTools()->TranslateWinPath(JPATH_SITE . '/libraries');
         if ($defaultLibraries != $jlibdir) {
             // The path differs, add it here
             $this->filter_data['JPATH_LIBRARIES'] = $jlibdir;
         }
     } else {
         $this->filter_data = array();
     }
     parent::__construct();
 }
开发者ID:esorone,项目名称:efcpw,代码行数:35,代码来源:Libraries.php

示例8: onAdd

 protected function onAdd($tpl = null)
 {
     /** @var AkeebaModelCpanels $model */
     $model = $this->getModel();
     $aeconfig = Factory::getConfiguration();
     // Load the helper classes
     $this->loadHelper('utils');
     $this->loadHelper('status');
     $statusHelper = AkeebaHelperStatus::getInstance();
     // Load the model
     if (!class_exists('AkeebaModelStatistics')) {
         JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $statmodel = new AkeebaModelStatistics();
     $this->profileid = $model->getProfileID();
     // Active profile ID
     $this->profilelist = $model->getProfilesList();
     // List of available profiles
     $this->statuscell = $statusHelper->getStatusCell();
     // Backup status
     $this->detailscell = $statusHelper->getQuirksCell();
     // Details (warnings)
     $this->statscell = $statmodel->getLatestBackupDetails();
     $this->fixedpermissions = $model->fixMediaPermissions();
     // Fix media/com_akeeba permissions
     $this->needsdlid = $model->needsDownloadID();
     $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
     $this->extension_id = $model->getState('extension_id', 0, 'int');
     // Should I ask for permission to display desktop notifications?
     JLoader::import('joomla.application.component.helper');
     $this->desktop_notifications = \Akeeba\Engine\Util\Comconfig::getValue('desktop_notifications', '0') ? 1 : 0;
     $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true);
     return $this->onDisplay($tpl);
 }
开发者ID:jvhost,项目名称:A-Website,代码行数:34,代码来源:view.html.php

示例9: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('backup_id' => 0);
     $defConfig = array_merge($defConfig, $parameters);
     $backup_id = (int) $defConfig['backup_id'];
     // Get the basic statistics
     $record = Platform::getInstance()->get_statistics($backup_id);
     // Get a list of filenames
     $backup_stats = Platform::getInstance()->get_statistics($backup_id);
     // Backup record doesn't exist
     if (empty($backup_stats)) {
         throw new \RuntimeException('Invalid backup record identifier', 404);
     }
     $filenames = Factory::getStatistics()->get_all_filenames($record);
     if (empty($filenames)) {
         // Archives are not stored on the server or no files produced
         $record['filenames'] = array();
     } else {
         $filedata = array();
         $i = 0;
         // Get file sizes per part
         foreach ($filenames as $file) {
             $i++;
             $size = @filesize($file);
             $size = is_numeric($size) ? $size : 0;
             $filedata[] = array('part' => $i, 'name' => basename($file), 'size' => $size);
         }
         // Add the file info to $record['filenames']
         $record['filenames'] = $filedata;
     }
     return $record;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:42,代码来源:GetBackupInfo.php

示例10: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN, 'backupid' => null);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $tag = $filter->clean($defConfig['tag'], 'cmd');
     $backupid = $filter->clean($defConfig['backupid'], 'cmd');
     // Set the active profile
     $session = $this->container->session;
     // Try to set the profile from the setup parameters
     if (!empty($profile)) {
         $profile = max(1, $profile);
         // Make sure $profile is a positive integer >= 1
         $session->set('profile', $profile);
         define('AKEEBA_PROFILE', $profile);
     }
     /** @var \Akeeba\Backup\Site\Model\Backup $model */
     $model = $this->container->factory->model('Backup')->tmpInstance();
     $model->setState('tag', $tag);
     $model->setState('backupid', $backupid);
     $array = $model->stepBackup(false);
     if ($array['Error'] != '') {
         throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
     }
     // BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
     $statistics = Factory::getStatistics();
     $array['BackupID'] = $statistics->getId();
     // Remote clients expect a boolean, not an integer.
     $array['HasRun'] = $array['HasRun'] === 0;
     return $array;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:42,代码来源:StepBackup.php

示例11: is_excluded_by_api

 protected function is_excluded_by_api($test, $root)
 {
     static $from_datetime;
     $config = Factory::getConfiguration();
     if (is_null($from_datetime)) {
         $user_setting = $config->get('core.filters.dateconditional.start');
         $from_datetime = strtotime($user_setting);
     }
     // Get the filesystem path for $root
     $fsroot = $config->get('volatile.filesystem.current_root', '');
     $ds = $fsroot == '' || $fsroot == '/' ? '' : DIRECTORY_SEPARATOR;
     $filename = $fsroot . $ds . $test;
     // Get the timestamp of the file
     $timestamp = @filemtime($filename);
     // If we could not get this information, include the file in the archive
     if ($timestamp === false) {
         return false;
     }
     // Compare it with the user-defined minimum timestamp and exclude if it's older than that
     if ($timestamp <= $from_datetime) {
         return true;
     }
     // No match? Just include the file!
     return false;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:25,代码来源:StackDateconditional.php

示例12: onBeforeBrowse

 public function onBeforeBrowse()
 {
     $result = parent::onBeforeBrowse();
     if ($result) {
         $params = JComponentHelper::getParams('com_akeeba');
         $model = $this->getThisModel();
         $view = $this->getThisView();
         /** @var AkeebaModelCpanels $model */
         $view->setModel($model);
         $aeconfig = Factory::getConfiguration();
         // Invalidate stale backups
         Factory::resetState(array('global' => true, 'log' => false, 'maxrun' => $params->get('failure_timeout', 180)));
         // Just in case the reset() loaded a stale configuration...
         Platform::getInstance()->load_configuration();
         // Let's make sure the temporary and output directories are set correctly and writable...
         $wizmodel = F0FModel::getAnInstance('Confwiz', 'AkeebaModel');
         $wizmodel->autofixDirectories();
         // Check if we need to toggle the settings encryption feature
         $model->checkSettingsEncryption();
         // Update the magic component parameters
         $model->updateMagicParameters();
         // Run the automatic database check
         $model->checkAndFixDatabase();
         // Run the automatic update site refresh
         /** @var AkeebaModelUpdates $updateModel */
         $updateModel = F0FModel::getTmpInstance('Updates', 'AkeebaModel');
         $updateModel->refreshUpdateSite();
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:lojinha,代码行数:30,代码来源:cpanel.php

示例13: scanFolder

 protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
 {
     $registry = Factory::getConfiguration();
     // Initialize variables
     $arr = array();
     $false = false;
     if (!is_dir($folder) && !is_dir($folder . '/')) {
         return $false;
     }
     try {
         $di = new \DirectoryIterator($folder);
     } catch (\Exception $e) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!$di->valid()) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!empty($position)) {
         $di->seek($position);
         if ($di->key() != $position) {
             $position = null;
             return $arr;
         }
     }
     $counter = 0;
     $maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
     while ($di->valid()) {
         if ($di->isDot()) {
             $di->next();
             continue;
         }
         if ($di->isDir() != $forFolders) {
             $di->next();
             continue;
         }
         $ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
         $dir = $folder . $ds . $di->getFilename();
         $data = _AKEEBA_IS_WINDOWS ? Factory::getFilesystemTools()->TranslateWinPath($dir) : $dir;
         if ($data) {
             $counter++;
             $arr[] = $data;
         }
         if ($counter == $maxCounter) {
             break;
         } else {
             $di->next();
         }
     }
     // Determine the new value for the position
     $di->next();
     if ($di->valid()) {
         $position = $di->key() - 1;
     } else {
         $position = null;
     }
     return $arr;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:59,代码来源:Large.php

示例14: stepDatabaseDump

 /**
  * Performs one more step of dumping database data
  *
  * @return  void
  */
 protected function stepDatabaseDump()
 {
     // We do not create any dump file, we will simply include the whole database file inside the backup
     Factory::getLog()->log(LogLevel::INFO, "SQLite database detected, no SQL dump files will be created.");
     $this->setState('postrun');
     $this->setStep('');
     $this->setSubstep('');
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:13,代码来源:Sqlite.php

示例15:

 function __construct()
 {
     $this->object = 'dbobject';
     $this->subtype = 'content';
     $this->method = 'api';
     if (Factory::getKettenrad()->getTag() == 'restorepoint') {
         $this->enabled = false;
     }
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:9,代码来源:StackFinder.php


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