本文整理汇总了PHP中fn_set_progress函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_set_progress函数的具体用法?PHP fn_set_progress怎么用?PHP fn_set_progress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_set_progress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionNextStep
/**
* Setup next_step action
*
* @param array $cart_settings Cart settings
* @param array $database_settings Database settings
* @param array $server_settings Server settings
* @return bool Always true
*/
public function actionNextStep($cart_settings, $database_settings, $server_settings)
{
$app = App::instance();
$validator = new Validator();
if ($validator->validateAll(array_merge($cart_settings, $server_settings, $database_settings))) {
fn_set_progress('parts', 14);
set_time_limit(0);
if ($app->connectToDB($database_settings['host'], $database_settings['name'], $database_settings['user'], $database_settings['password'], $database_settings['table_prefix'], $database_settings['database_backend'])) {
$app->setToStorage('database_settings', $database_settings);
define('CART_LANGUAGE', $cart_settings['main_language']);
define('DESCR_SL', $cart_settings['main_language']);
define('CART_SECONDARY_CURRENCY', 'NULL');
// Need for cache_level
$sCart = new Setup($cart_settings, $server_settings, $database_settings, $this->isDemoInstall($cart_settings));
$sAddons = new AddonsSetup();
/* Setup Scheme */
fn_set_progress('title', $app->t('setup_scheme'));
fn_set_progress('echo', $app->t('processing'), true);
fn_set_progress('step_scale', 2000);
$sCart->setupScheme();
/* Setup Scheme Data */
fn_set_progress('step_scale', 1);
fn_set_progress('title', $app->t('setup_data'));
fn_set_progress('echo', $app->t('processing'), true);
fn_set_progress('step_scale', 5000);
$sCart->setupData();
$sCart->setSimpleMode();
/* Setup Demo */
if ($this->isDemoInstall($cart_settings)) {
fn_set_progress('step_scale', 1);
fn_set_progress('title', $app->t('setup_demo'));
fn_set_progress('echo', $app->t('installing_demo_catalog'), true);
fn_set_progress('step_scale', 5000);
$sCart->setupDemo();
} else {
fn_set_progress('step_scale', 1);
fn_set_progress('echo', $app->t('cleaning'), true);
$sCart->clean();
}
$sCart->setupUsers();
/* Setup companies */
fn_set_progress('step_scale', 1);
fn_set_progress('title', $app->t('setup_companies'));
fn_set_progress('echo', $app->t('processing'), true);
$sCart->setupCompanies();
/* Setup Languages */
fn_set_progress('step_scale', 1);
fn_set_progress('title', $app->t('setup_languages'));
fn_set_progress('echo', $app->t('processing'), true);
fn_set_progress('step_scale', 1000);
$sCart->setupLanguages($this->isDemoInstall($cart_settings));
$sCart->setupThemes();
/* Setup Add-ons */
fn_set_progress('title', $app->t('setup_addons'));
fn_set_progress('echo', $app->t('processing'), true);
fn_set_progress('step_scale', 100);
$sAddons->setup($this->isDemoInstall($cart_settings), array());
/* Write config */
fn_set_progress('step_scale', 1);
fn_set_progress('echo', $app->t('writing_config'), true);
$sCart->writeConfig();
$this->_prepareHttpData();
$redirect_url = Registry::get('config.http_location') . '/install/index.php?dispatch=setup.complete';
if (Registry::get('runtime.comet')) {
Registry::get('ajax')->assign('force_redirection', $redirect_url);
} else {
fn_redirect($redirect_url);
}
exit;
}
} else {
if (Registry::get('runtime.comet')) {
exit;
} else {
$params['dispatch'] = 'setup.index';
$params['cart_settings'] = $cart_settings;
$params['database_settings'] = $database_settings;
$params['server_settings'] = $server_settings;
$app->run($params);
}
}
return true;
}
示例2: generate
public function generate($force = false)
{
$filename = $this->getFileName();
if (!is_dir(dirname($filename))) {
fn_mkdir(dirname($filename));
}
if ($force) {
fn_rm($filename);
}
if (!file_exists($filename)) {
fn_set_progress('echo', __('generating_xls'), false);
$header = $data = array();
$currencies = Registry::get('currencies');
$currency = $currencies[CART_SECONDARY_CURRENCY];
$currency_format = '#' . $currency['thousands_separator'] . '##0.' . str_repeat('0', $currency['decimals']);
$currency_format = $currency['after'] == 'Y' ? $currency_format . $currency['symbol'] : $currency['symbol'] . $currency_format;
foreach ($this->selected_fields as $field_id => $field_value) {
$header[$this->price_schema['fields'][$field_id]['title']] = $field_id == 'price' ? $currency_format : 'string';
}
$this->writer->writeSheetHeader($this->sheet, $header);
$this->render();
$this->writer->writeToFile($filename);
}
return $filename;
}
示例3: processProducts
/**
* Gets products for printing and print them
* @param array $params product search params
*/
protected function processProducts($params)
{
$total = static::ITEMS_PER_PAGE;
while (static::ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
list($products, $search) = fn_get_products($params, static::ITEMS_PER_PAGE);
$total = $search['total_items'];
if ($params['page'] == 1) {
fn_set_progress('parts', $total);
}
$get_images = !empty($this->selected_fields['image']);
$_params = array('get_icon' => $get_images, 'get_detailed' => $get_images, 'get_options' => Registry::get('addons.price_list.include_options') == 'Y' ? true : false, 'get_discounts' => false);
fn_gather_additional_products_data($products, $_params);
$params['page']++;
$this->printProductsBatch(true);
foreach ($products as $product) {
fn_set_progress('echo');
if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
$product = fn_price_list_get_combination($product);
foreach ($product['combinations'] as $c_id => $c_value) {
$product['price'] = $product['combination_prices'][$c_id];
$product['weight'] = $product['combination_weight'][$c_id];
$product['amount'] = $product['combination_amount'][$c_id];
$product['product_code'] = $product['combination_code'][$c_id];
$this->printProductRow($product, $c_value);
}
} else {
$this->printProductRow($product);
}
}
$this->printProductsBatch();
}
}
示例4: setup
/**
* Installs addons
*
* @param bool $install_demo
* @param array $addons List of addons to be installed, if empty will be installed addons according <auto_install> tag
* @return bool Always true
*/
public function setup($install_demo = true, $addons = array())
{
$app = App::instance();
Registry::set('customer_theme_path', Registry::get('config.dir.install_themes') . '/' . App::THEME_NAME);
$addons = empty($addons) ? $this->_getAddons() : $addons;
foreach ($addons as $addon_name) {
if (fn_install_addon($addon_name, false, $install_demo)) {
fn_set_progress('echo', $app->t('addon_installed', array('addon' => $addon_name)) . '<br/>', true);
}
Registry::set('runtime.database.errors', '');
}
return true;
}
示例5: fn_delete_localization
function fn_delete_localization($localization_ids)
{
$loc_objects = fn_get_localization_objects();
fn_set_progress('parts', sizeof($localization_ids) * sizeof($loc_objects));
foreach ($localization_ids as $loc_id) {
foreach ($loc_objects as $table) {
fn_set_progress('echo', __('converting_data_in_table', array('[table]' => $table)));
db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id));
}
db_query("DELETE FROM ?:localizations WHERE localization_id = ?i", $loc_id);
db_query("DELETE FROM ?:localization_descriptions WHERE localization_id = ?i", $loc_id);
db_query("DELETE FROM ?:localization_elements WHERE localization_id = ?i", $loc_id);
}
fn_set_notification('N', __('notice'), __('done'));
}
示例6: display
/**
* Displays message to appropriate output screen (console/display)
*
* @param string $message Message text
* @param string $title Title text
* @param bool $next_step Move progress to next step
*/
public static function display($message, $title = '', $next_step = true)
{
if (self::isConsole()) {
if (!empty($title)) {
echo $title . PHP_EOL . '================================================' . PHP_EOL;
}
echo $message . PHP_EOL;
if ($next_step) {
echo 'Step ' . self::$current_step . '/' . self::$steps . ' completed' . PHP_EOL;
}
} else {
if (!empty($title)) {
fn_set_progress('title', $title);
}
fn_set_progress('echo', $message, $next_step);
}
if ($next_step) {
self::$current_step++;
}
}
示例7: generate
public function generate($force = false)
{
$filename = $this->getFileName();
if (!is_dir(dirname($filename))) {
fn_mkdir(dirname($filename));
}
if ($force) {
fn_rm($filename);
}
// Min column width in percent
$min_width = array('product' => 50, 'product_code' => 13, 'image' => 10);
if (!file_exists($filename)) {
$max_perc = 100;
$field_count = count($this->selected_fields);
// First step. Check for the min width.
$perc = intval($max_perc / $field_count);
foreach ($this->selected_fields as $field_name => $active) {
if (isset($min_width[$field_name])) {
if ($min_width[$field_name] > $perc) {
$max_perc -= $min_width[$field_name];
$field_count--;
}
}
}
// Second step. Set up the new width values.
$perc = intval($max_perc / $field_count);
foreach ($this->selected_fields as $field_name => $active) {
if (!isset($min_width[$field_name]) || $min_width[$field_name] < $perc) {
$this->price_schema['fields'][$field_name]['min_width'] = $perc;
} else {
$this->price_schema['fields'][$field_name]['min_width'] = $min_width[$field_name];
}
}
fn_set_progress('echo', __('generating_pdf'), false);
$this->render();
}
return $filename;
}
示例8: fn_google_sitemap_check_counter
function fn_google_sitemap_check_counter(&$file, &$link_counter, &$file_counter, $links, $header, $footer, $type)
{
$stat = fstat($file);
if (count($links) + $link_counter > MAX_URLS_IN_MAP || $stat['size'] >= MAX_SIZE_IN_KBYTES * 1024) {
fwrite($file, $footer);
fclose($file);
$file_counter++;
$filename = fn_get_files_dir_path() . 'google_sitemap/sitemap' . $file_counter . '.xml';
$file = fopen($filename, "wb");
$link_counter = count($links);
fwrite($file, $header);
} else {
$link_counter += count($links);
fn_set_progress('echo', __($type));
}
}
示例9: synchronizationObjects
/**
* Sync ebay objects
* @param int $site_id
* @param int $category_id
* @return bool
*/
public static function synchronizationObjects($site_id, $category_id)
{
@set_time_limit(600);
$start_time = fn_get_storage_data('ebay_synchronization_start_time');
if (!empty($start_time) && $start_time > strtotime('-10 minutes')) {
$time = time();
$current_step = fn_get_storage_data('ebay_synchronization_step');
$count_steps = fn_get_storage_data('ebay_synchronization_step_count');
fn_set_progress('title', __('ebay_synchronization_title'));
fn_set_progress('parts', $count_steps);
for ($i = 1; $i < $current_step; $i++) {
fn_set_progress('echo', '.');
}
fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
while (true) {
//TODO move logic to same function fn_get_storage_data
Registry::del('storage_data.ebay_synchronization_step');
Registry::del('storage_data.ebay_synchronization_step_title');
$step = fn_get_storage_data('ebay_synchronization_step');
if (empty($step)) {
return true;
}
if ($step != $current_step) {
fn_set_progress('echo', '.');
fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
$current_step = $step;
}
if ($time < strtotime('-10 minutes')) {
return true;
}
sleep(1);
}
return true;
}
$objects = fn_ebay_get_objects_needed_synchronization($site_id, $category_id);
if (!empty($objects)) {
$current_step = 1;
register_shutdown_function(function () {
fn_set_storage_data('ebay_synchronization_start_time', null);
fn_set_storage_data('ebay_synchronization_step_title', null);
fn_set_storage_data('ebay_synchronization_step', null);
fn_set_storage_data('ebay_synchronization_step_count', null);
});
fn_set_storage_data('ebay_synchronization_start_time', time());
fn_set_storage_data('ebay_synchronization_step_count', count($objects));
fn_set_storage_data('ebay_synchronization_step', $current_step);
fn_set_progress('title', __('ebay_synchronization_title'));
fn_set_progress('parts', count($objects));
if (in_array('Site', $objects)) {
fn_set_progress('echo', __('ebay_synchronization_regions'), false);
fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_regions'));
Site::synchronization();
fn_set_storage_data('ebay_synchronization_step', ++$current_step);
fn_set_progress('echo', '.');
}
if (in_array('Category', $objects)) {
fn_set_progress('echo', __('ebay_synchronization_categories'), false);
fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_categories'));
Category::synchronization($site_id);
fn_set_storage_data('ebay_synchronization_step', ++$current_step);
fn_set_progress('echo', '.');
}
if (in_array('Shipping', $objects)) {
fn_set_progress('echo', __('ebay_synchronization_shipping_services'), false);
fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_shipping_services'));
Shipping::synchronization($site_id);
fn_set_storage_data('ebay_synchronization_step', ++$current_step);
fn_set_progress('echo', '.');
}
if (in_array('CategoryFeature', $objects)) {
fn_set_progress('echo', __('ebay_synchronization_category_features'), false);
fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_category_features'));
CategoryFeature::synchronization($site_id, $category_id);
fn_set_storage_data('ebay_synchronization_step', ++$current_step);
fn_set_progress('echo', '.');
}
}
return true;
}
示例10: fn_set_notification
if (fn_copy($dump['path'], Registry::get('config.dir.backups') . $dump['name'])) {
fn_set_notification('N', __('notice'), __('done'));
} else {
fn_set_notification('E', __('error'), __('cant_create_backup_file'));
}
} else {
fn_set_notification('E', __('error'), __('cant_upload_file'));
}
}
if ($mode == 'optimize') {
// Log database optimization
fn_log_event('database', 'optimize');
$all_tables = db_get_fields("SHOW TABLES");
fn_set_progress('parts', sizeof($all_tables));
foreach ($all_tables as $table) {
fn_set_progress('echo', __('optimizing_table') . " <b>{$table}</b>...<br />");
db_query("OPTIMIZE TABLE {$table}");
db_query("ANALYZE TABLE {$table}");
$fields = db_get_hash_array("SHOW COLUMNS FROM {$table}", 'Field');
if (!empty($fields['is_global'])) {
// Sort table by is_global field
fn_echo('.');
db_query("ALTER TABLE {$table} ORDER BY is_global DESC");
} elseif (!empty($fields['position'])) {
// Sort table by position field
fn_echo('.');
db_query("ALTER TABLE {$table} ORDER BY position");
}
}
fn_set_notification('N', __('notice'), __('done'));
}
示例11: fn_copy
/**
* Recursively copy directory (or just a file)
*
* @param string $source
* @param string $dest
* @param bool $silent
* @param array $exclude_files
* @return bool True on success, false otherwise
*/
function fn_copy($source, $dest, $silent = true, $exclude_files = array())
{
/**
* Ability to forbid file copy or change parameters
*
* @param string $source source file/directory
* @param string $dest destination file/directory
* @param boolean $silent silent flag
* @param array $exclude files to exclude
*/
fn_set_hook('copy_file', $source, $dest, $silent, $exclude_files);
if (empty($source)) {
return false;
}
// Simple copy for a file
if (is_file($source)) {
$source_file_name = fn_basename($source);
if (in_array($source_file_name, $exclude_files)) {
return true;
}
if (@is_dir($dest)) {
$dest .= '/' . $source_file_name;
}
if (filesize($source) == 0) {
$fd = fopen($dest, 'w');
fclose($fd);
$res = true;
} else {
$res = @copy($source, $dest);
}
@chmod($dest, DEFAULT_FILE_PERMISSIONS);
clearstatcache(true, $dest);
return $res;
}
// Make destination directory
if ($silent == false) {
$_dir = strpos($dest, Registry::get('config.dir.root')) === 0 ? str_replace(Registry::get('config.dir.root') . '/', '', $dest) : $dest;
fn_set_progress('echo', $_dir . '<br/>');
}
if (!fn_mkdir($dest)) {
return false;
}
// Loop through the folder
if (@is_dir($source)) {
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== $source . '/' . $entry) {
if (fn_copy($source . '/' . $entry, $dest . '/' . $entry, $silent, $exclude_files) == false) {
return false;
}
}
}
// Clean up
$dir->close();
return true;
} else {
return false;
}
}
示例12: fn_restore_dump
function fn_restore_dump($files)
{
if (empty($files)) {
return false;
}
fn_set_progress('parts', sizeof($files));
foreach ($files as $file) {
$is_archive = false;
$list = array($file);
if (in_array(fn_get_file_ext($file), array('zip', 'tgz'))) {
$is_archive = true;
fn_decompress_files(Registry::get('config.dir.database') . $file, Registry::get('config.dir.database') . '_tmp');
$list = fn_get_dir_contents(Registry::get('config.dir.database') . '_tmp', false, true, 'sql', '_tmp/');
}
foreach ($list as $_file) {
db_import_sql_file(Registry::get('config.dir.database') . $_file);
}
if ($is_archive) {
fn_rm(Registry::get('config.dir.database') . '_tmp');
}
}
// Log database restore
fn_log_event('database', 'restore');
fn_set_hook('database_restore', $files);
fn_clear_cache();
return true;
}
示例13: putList
/**
* Puts list of local files to storage
*
* @param array $list files list (relative path)
* @param string $prefix absolute path prefix
* @param array $params additional parameters list
* @return boolean true on success, false if at least one put was failed
*/
public function putList($list, $prefix, $params = array())
{
if (!empty($list)) {
fn_set_progress('step_scale', sizeof($list));
foreach ($list as $item) {
fn_set_progress('echo', '.');
if (strpos($prefix, '://') !== false) {
$params['contents'] = fn_get_contents($prefix . $item);
} else {
$params['file'] = $prefix . $item;
$params['keep_origins'] = true;
}
if (!$this->put($item, $params)) {
return false;
}
}
}
return true;
}
示例14: fn_install_theme_files
/**
* Installs theme files
*
* @param string $source_theme source theme name
* @param string $dest_theme destination theme name
* @param boolean $from_repo flag, if set to true, theme files are copied from themes_repository
* @return boolean true if theme was installed, false otherwise
*/
function fn_install_theme_files($source_theme, $dest_theme, $from_repo = true)
{
$path_dest = fn_get_theme_path('[themes]/' . $dest_theme, 'C');
if (!fn_is_theme_installed($dest_theme)) {
if (!fn_mkdir($path_dest)) {
fn_set_notification('E', __('error'), __('text_cannot_create_directory', array('[directory]' => fn_get_rel_dir($path_dest))));
return false;
}
$path_repo_base = '';
if ($from_repo) {
$path_repo = fn_get_theme_path('[repo]/' . $source_theme, 'C');
$manifest = Themes::factory($source_theme)->getRepoManifest();
$parent_theme = isset($manifest['parent_theme']) ? $manifest['parent_theme'] : Registry::get('config.base_theme');
if (!empty($parent_theme) && $source_theme != $parent_theme) {
$path_repo_base = fn_get_theme_path('[repo]/' . $parent_theme, 'C');
}
} else {
$path_repo = fn_get_theme_path('[themes]/' . $source_theme, 'C');
}
fn_set_progress('parts', fn_dirs_count($path_repo_base) + fn_dirs_count($path_repo) + 1);
// FIXME: Backward compatibility. Create manifest.json if theme only has manifest.ini
if (file_exists($path_repo . '/' . THEME_MANIFEST_INI) && !file_exists($path_repo . '/' . THEME_MANIFEST)) {
$content = parse_ini_file($path_repo . '/' . THEME_MANIFEST_INI);
fn_put_contents($path_repo . '/' . THEME_MANIFEST, json_encode($content));
}
if (!empty($path_repo_base)) {
fn_copy($path_repo_base, $path_dest, false);
// Clear layouts and styles data
fn_rm($path_dest . '/styles');
fn_rm($path_dest . '/layouts');
// FIXME: Backward compatibility
fn_rm($path_dest . '/presets');
}
fn_copy($path_repo, $path_dest, false);
}
// Re-install add-ons template files
list($installed_addons) = fn_get_addons(array('type' => 'installed'));
foreach ($installed_addons as $addon) {
fn_install_addon_templates($addon['addon']);
}
return true;
}
示例15: putDir
/**
* Put directory to storage
*
* @param string $dir directory to get files from
* @param array $params additional parameters
* @return boolean true of success, false on fail
*/
public function putDir($dir, $params = array())
{
$s3 = $this->s3();
// get object to initialize class and get access to contstants below
$i = 0;
$max_batch = 10;
$files = fn_get_dir_contents($dir, false, true, '', '', true);
fn_set_progress('step_scale', sizeof($files));
foreach ($files as $source_file) {
fn_set_progress('echo', '.');
$i++;
$data = array('acl' => \AmazonS3::ACL_PUBLIC, 'headers' => array());
// File can not be accessible via direct link
if ($this->getOption('secured')) {
$data['headers']['Content-disposition'] = 'attachment; filename="' . fn_basename($source_file) . '"';
$data['acl'] = \AmazonS3::ACL_PRIVATE;
}
$data['contentType'] = fn_get_file_type($source_file);
$data['fileUpload'] = $dir . '/' . $source_file;
$res = $s3->batch()->create_object($this->getOption('bucket'), $this->prefix($source_file), $data);
if ($i == $max_batch) {
$s3->batch()->send();
$i = 0;
}
}
if (!empty($i)) {
$s3->batch()->send();
// send the rest of the batch
}
return true;
}