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


PHP tpl_fetch函数代码示例

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


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

示例1: execute

 /**
  * Execute the script
  *
  * @param void
  * @return boolean
  */
 function execute()
 {
     // ---------------------------------------------------
     //  Check MySQL version
     // ---------------------------------------------------
     $mysql_version = mysql_get_server_info($this->database_connection);
     if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) {
         $constants['DB_CHARSET'] = 'utf8';
         @mysql_query("SET NAMES 'utf8'", $this->database_connection);
         tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci');
         tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
     } else {
         tpl_assign('default_collation', $default_collation = '');
         tpl_assign('default_charset', $default_charset = '');
     }
     // if
     tpl_assign('table_prefix', TABLE_PREFIX);
     // ---------------------------------------------------
     //  Execute migration
     // ---------------------------------------------------
     $total_queries = 0;
     $executed_queries = 0;
     $upgrade_script = tpl_fetch(get_template_path('db_migration/1_0_milanga'));
     if ($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) {
         $this->printMessage("Database schema transformations executed (total queries: {$total_queries})");
     } else {
         $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true);
         return false;
     }
     // if
     $this->printMessage('Feng Office has been upgraded. You are now running Feng Office ' . $this->getVersionTo() . ' Enjoy!');
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:38,代码来源:MilangaUpgradeScript.class.php

示例2: advanced_pagination

/**
 * Advanced pagination. Differenced between simple and advanced paginations is that 
 * advanced pagination uses template so its output can be changed in a great number of ways.
 * 
 * All variables are just passed to the template, nothing is done inside the function!
 *
 * @access public
 * @param DataPagination $pagination Pagination object
 * @param string $url_base Base URL in witch we will insert current page number
 * @param string $template Template that will be used. It can be absolute path to existing file
 *   or template name that used with get_template_path will return real template path
 * @param string $page_placeholder Short string inside of $url_base that will be replaced with
 *   current page numer
 * @return null
 */
function advanced_pagination(DataPagination $pagination, $url_base, $template = 'advanced_pagination', $page_placeholder = '#PAGE#')
{
    tpl_assign(array('advanced_pagination_object' => $pagination, 'advanced_pagination_url_base' => $url_base, 'advanced_pagination_page_placeholder' => urlencode($page_placeholder)));
    // tpl_assign
    $template_path = is_file($template) ? $template : get_template_path($template);
    return tpl_fetch($template_path);
}
开发者ID:469306621,项目名称:Languages,代码行数:22,代码来源:pagination.php

示例3: smarty_function_include_layout

/**
 * Include layout
 * 
 * Parameters:
 * 
 * - name - layout name
 * - module - module name
 *
 * @param array $params
 * @param Smarty $smarty
 * @return null
 */
function smarty_function_include_layout($params, &$smarty)
{
    $name = array_var($params, 'name');
    if (empty($name)) {
        return new InvalidParamError('name', $name, "'name' property is required for 'include_layout' helper", true);
    }
    // if
    $module = array_var($params, 'module');
    if (empty($module)) {
        return new InvalidParamError('module', $module, "'module' property is required for 'include_layout' helper", true);
    }
    // if
    return tpl_fetch(get_layout_path($name, $module));
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:26,代码来源:function.include_layout.php

示例4: ajx_check_login

/**
 * Checks whether the user is logged in and if not returns an error response.
 *
 */
function ajx_check_login()
{
    if (is_ajax_request() && !logged_user() instanceof Contact && (array_var($_GET, 'c') != 'access' || array_var($_GET, 'a') != 'relogin')) {
        // error, user not logged in => return error message
        $response = AjaxResponse::instance();
        $response->setCurrentContent("empty");
        $response->setError(SESSION_EXPIRED_ERROR_CODE, lang("session expired error"));
        // display the object as json
        tpl_assign("object", $response);
        $content = tpl_fetch(Env::getTemplatePath("json"));
        tpl_assign("content_for_layout", $content);
        tpl_display(Env::getLayoutPath("json"));
        exit;
    }
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:19,代码来源:ajax.php

示例5: execute

 /**
  * Execute the script
  *
  * @param void
  * @return boolean
  */
 function execute()
 {
     // ---------------------------------------------------
     //  Check MySQL version
     // ---------------------------------------------------
     $mysql_version = mysql_get_server_info($this->database_connection);
     if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) {
         $constants['DB_CHARSET'] = 'utf8';
         @mysql_query("SET NAMES 'utf8'", $this->database_connection);
         tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci');
         tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
     } else {
         tpl_assign('default_collation', $default_collation = '');
         tpl_assign('default_charset', $default_charset = '');
     }
     // if
     tpl_assign('table_prefix', TABLE_PREFIX);
     if (defined('DB_ENGINE')) {
         tpl_assign('engine', DB_ENGINE);
     } else {
         tpl_assign('engine', 'InnoDB');
     }
     // ---------------------------------------------------
     //  Execute migration
     // ---------------------------------------------------
     $total_queries = 0;
     $executed_queries = 0;
     $installed_version = installed_version();
     if (version_compare($installed_version, "1.1") <= 0) {
         $upgrade_script = tpl_fetch(get_template_path('db_migration/1_2_chinchulin'));
     } else {
         $upgrade_script = "DELETE FROM `" . TABLE_PREFIX . "config_options` WHERE `name` = 'time_format_use_24';\r\n\t\t\tUPDATE `" . TABLE_PREFIX . "config_options` SET `category_name` = 'modules' WHERE `name` = 'enable_email_module';\r\n\t\t\tALTER TABLE `" . TABLE_PREFIX . "mail_contents` ADD COLUMN `content_file_id` VARCHAR(40) NOT NULL default '';\r\n\t\t\t";
     }
     @unlink("../../language/de_de/._lang.js");
     if ($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) {
         $this->printMessage("Database schema transformations executed (total queries: {$total_queries})");
     } else {
         $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true);
         return false;
     }
     // if
     $this->printMessage('Feng Office has been upgraded. You are now running Feng Office ' . $this->getVersionTo() . ' Enjoy!');
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:49,代码来源:ChinchulinUpgradeScript.class.php

示例6: load_help

function load_help($template){
	$dir = Localization::instance()->getLanguageDirPath().'/'.Localization::instance()->getLocale();
	$help_file = $dir.'/help/'.$template.'.html';
	if(is_file($help_file)){
		return tpl_fetch($help_file);
	}else{
		$default = Localization::instance()->getLanguageDirPath().'/en_us/help/'.$template.'.html';
		if(is_file($default)){
			return tpl_fetch($default);
		}else{
			$noHelp = Localization::instance()->getLanguageDirPath().'/en_us/help/no_help.html';
			if(is_file($noHelp)){
				return tpl_fetch($noHelp);
			}else{
				return '';
			}
		}
	}	
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:19,代码来源:help.php

示例7: setSidebar

 /**
  * Set page sidebar
  *
  * @access public
  * @param string $template Path of sidebar template
  * @return null
  * @throws FileDnxError if $template file does not exists
  */
 protected function setSidebar($template)
 {
     tpl_assign('content_for_sidebar', tpl_fetch($template));
 }
开发者ID:469306621,项目名称:Languages,代码行数:12,代码来源:ApplicationController.class.php

示例8: render_project_application_logs

/**
 * Render one project's application logs
 * 
 * This helper will render array of log entries.
 *
 * @param array $project The project.
 * @param array $log_entries An array of entries for this project.
 * @return null
 */
function render_project_application_logs($project, $log_entries)
{
    tpl_assign('application_logs_project', $project);
    tpl_assign('application_logs_entries', $log_entries);
    return tpl_fetch(get_template_path('render_project_application_logs', 'application'));
}
开发者ID:469306621,项目名称:Languages,代码行数:15,代码来源:application.php

示例9: execute

 /**
  * Execute the script
  *
  * @param void
  * @return boolean
  */
 function execute()
 {
     // ---------------------------------------------------
     //  Check MySQL version
     // ---------------------------------------------------
     $mysql_version = mysql_get_server_info($this->database_connection);
     if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) {
         $constants['DB_CHARSET'] = 'utf8';
         @mysql_query("SET NAMES 'utf8'", $this->database_connection);
         tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci');
         tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
     } else {
         tpl_assign('default_collation', $default_collation = '');
         tpl_assign('default_charset', $default_charset = '');
     }
     // if
     tpl_assign('table_prefix', TABLE_PREFIX);
     if (defined('DB_ENGINE')) {
         tpl_assign('engine', DB_ENGINE);
     } else {
         tpl_assign('engine', 'InnoDB');
     }
     // ---------------------------------------------------
     //  Execute migration
     // ---------------------------------------------------
     // RUN QUERIES
     $total_queries = 0;
     $executed_queries = 0;
     $installed_version = installed_version();
     if (version_compare($installed_version, $this->getVersionFrom()) <= 0) {
         // upgrading from a version lower than this script's 'from' version
         $upgrade_script = tpl_fetch(get_template_path('db_migration/1_7_pastafrola'));
     } else {
         // upgrading from a pre-release of this version (beta, rc, etc)
         $upgrade_script = "";
         if (version_compare($installed_version, '1.7-beta') <= 0) {
             $upgrade_script .= "\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES\r\n\t\t\t\t\t\t('system', 'notification_from_address', '', 'StringConfigHandler', 1, 0, 'Address to use as from field in email notifications. If empty, users address is used');\r\n\t\t\t\t";
         }
         if (version_compare($installed_version, '1.7-rc') <= 0) {
             $upgrade_script .= "\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES\r\n\t\t\t\t\t\t('general', 'use_owner_company_logo_at_header', '0', 'BoolConfigHandler', 0, 0, '')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t\tDELETE FROM `" . TABLE_PREFIX . "config_options` WHERE `category_name`='general' AND `name`='detect_mime_type_from_extension';\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "user_ws_config_options` (`category_name`, `name`, `default_value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES \r\n \t\t\t\t\t\t('general', 'detect_mime_type_from_extension', '0', 'BoolConfigHandler', 0, 800, '')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t";
         }
         if (version_compare($installed_version, '1.7-rc2') <= 0) {
             $upgrade_script .= "\r\n\t\t\t\t\tALTER TABLE `" . TABLE_PREFIX . "administration_tools` ADD COLUMN `visible` BOOLEAN NOT NULL DEFAULT 1;\r\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "administration_tools` SET `visible`=0 WHERE `name`='mass_mailer';\r\n\t\t\t\t";
         }
         if (version_compare($installed_version, '1.7') <= 0) {
             $upgrade_script .= "\r\n\t\t\t\t\tALTER TABLE `" . TABLE_PREFIX . "mail_accounts` \r\n\t\t\t\t\t ADD COLUMN `last_error_date` DATETIME NOT NULL default '0000-00-00 00:00:00',\r\n\t\t\t\t\t ADD COLUMN `last_error_msg` VARCHAR(255) NOT NULL default '',\r\n\t\t\t\t\t ADD COLUMN `sync_addr` VARCHAR( 100 ) NOT NULL default '',\r\n\t\t\t\t\t ADD COLUMN `sync_pass` VARCHAR( 40 ) NOT NULL default '',\r\n\t\t\t\t\t ADD COLUMN `sync_server` VARCHAR( 100 ) NOT NULL default '',\r\n\t\t\t\t\t ADD COLUMN `sync_ssl` BOOL NOT NULL DEFAULT '0',\r\n\t\t\t\t\t ADD COLUMN `sync_ssl_port` INT( 11 ) NOT NULL DEFAULT '993',\r\n\t\t\t\t\t ADD COLUMN `sync_folder` VARCHAR( 100 ) NOT NULL default '';\r\n\t\t\t\t\tALTER TABLE `" . TABLE_PREFIX . "mail_account_users` ADD COLUMN `last_error_state` INT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '0:no error,1:err unread, 2:err read';\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "user_ws_config_options` (`category_name`, `name`, `default_value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES \r\n\t\t\t\t\t ('mails panel', 'mail_account_err_check_interval', '300', 'IntegerConfigHandler', 0, 120, NULL),\r\n\t\t\t\t\t ('mails panel', 'classify_mail_with_conversation', '1', 'BoolConfigHandler', 0, 130, NULL),\r\n\t\t\t\t\t ('task panel', 'tasksShowEmptyMilestones', '1', 'BoolConfigHandler', 1, 0, '')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "file_types` (`extension`, `icon`, `is_searchable`, `is_image`) VALUES\r\n\t\t\t\t\t\t('docx', 'doc.png', 0, 0),\r\n\t\t\t\t\t\t('xlsx', 'xls.png', 0, 0)\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES\r\n\t\t\t\t\t\t('system', 'min_chars_for_match', '3', 'IntegerConfigHandler', 1, 0, 'If search criteria len is less than this, then use always LIKE'),\r\n\t\t\t\t\t\t('mailing', 'sent_mails_sync', '1', 'BoolConfigHandler', '0', '0', 'imap email accounts synchronization possibility')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t\tALTER TABLE `" . TABLE_PREFIX . "application_logs` MODIFY COLUMN `action` enum('upload','open','close','delete','edit','add','trash','untrash','subscribe','unsubscribe','tag','untag','comment','link','unlink','login','logout','archive','unarchive','move','copy','read','download','checkin','checkout') collate utf8_unicode_ci default NULL;\r\n\t\t\t\t\tALTER TABLE `" . TABLE_PREFIX . "mail_contents` ADD COLUMN `sync` BOOL NOT NULL DEFAULT '0';\r\n\t\t\t\t";
         }
         if (version_compare($installed_version, '1.7.2') <= 0) {
             $upgrade_script .= "\r\n\t\t\t\t\tINSERT INTO `" . TABLE_PREFIX . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES\r\n\t\t\t\t\t\t('passwords', 'block_login_after_x_tries', '0', 'BoolConfigHandler', '0', '20', NULL),\r\n\t\t\t\t\t\t('mailing', 'check_spam_in_subject', '0', 'BoolConfigHandler', 0, 0, '')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE id=id;\r\n\t\t\t\t";
         }
         if (!$this->checkTableExists(TABLE_PREFIX . 'administration_logs', $this->database_connection)) {
             $upgrade_script .= "\r\n\t\t\t\t\tCREATE TABLE  `" . TABLE_PREFIX . "administration_logs` (\r\n\t\t\t\t\t  `id` int(10) unsigned NOT NULL auto_increment,\r\n\t\t\t\t\t  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\r\n\t\t\t\t\t  `title` varchar(50) NOT NULL default '',\r\n\t\t\t\t\t  `log_data` text NOT NULL,\r\n\t\t\t\t\t  `category` enum('system','security') NOT NULL,\r\n\t\t\t\t\t  PRIMARY KEY  (`id`),\r\n\t\t\t\t\t  KEY `created_on` (`created_on`),\r\n\t\t\t\t\t  KEY `category` (`category`)\r\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\r\n\t\t\t\t";
         }
     }
     if ($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) {
         $this->printMessage("Database schema transformations executed (total queries: {$total_queries})");
     } else {
         $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true);
         return false;
     }
     // if
     $this->printMessage('Feng Office has been upgraded. You are now running Feng Office ' . $this->getVersionTo() . ' Enjoy!');
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:69,代码来源:PastafrolaUpgradeScript.class.php

示例10: setContentFromTemplate

 /**
  * Set content from template
  *
  * @access public
  * @param void
  * @return null
  */
 function setContentFromTemplate($template)
 {
     tpl_assign('content_for_layout', tpl_fetch(get_template_path($template)));
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:11,代码来源:ScriptInstallerStep.class.php

示例11: writeConfigFile

 /**
  * Write $constants in config file
  *
  * @access public
  * @param array $constants
  * @return boolean
  */
 function writeConfigFile($constants)
 {
     tpl_assign('config_file_constants', $constants);
     return file_put_contents(INSTALLATION_PATH . '/config/config.php', tpl_fetch(get_template_path('config_file.php')));
 }
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:12,代码来源:installation.class.php

示例12: render

 /**
  * Render content... If template and/layout are NULL script will resolve 
  * their names based on controller name and action. 
  * 
  * PageController::index will map with:
  *  - template => views/page/index.php
  *  - layout => layouts/page.php
  *
  * @param string $template
  * @param string $layout
  * @param boolean $die
  * @return boolean
  * @throws FileDnxError
  */
 function render($template = null, $layout = null, $die = true)
 {
     trace(__FILE__, "render({$template}, {$layout}, {$die})");
     // Set template and layout...
     if (!is_null($template)) {
         $this->setTemplate($template);
     }
     // if
     if (!is_null($layout)) {
         $this->setLayout($layout);
     }
     // if
     // Get template and layout paths
     $template_path = $this->getTemplatePath();
     $layout_path = $this->getLayoutPath();
     trace(__FILE__, "tpl_fetch({$template_path})");
     // Fetch content...
     $content = tpl_fetch($template_path);
     trace(__FILE__, "renderLayout({$layout_path} <xmp>{$content}</xmp>)");
     // Assign content and render layout
     $this->renderLayout($layout_path, $content);
     // Die!
     if ($die) {
         session_write_close();
         die;
     }
     // if
     // We are done here...
     return true;
 }
开发者ID:469306621,项目名称:Languages,代码行数:44,代码来源:PageController.class.php

示例13: render_co_view_member_path

/**
 * 
 * Renders members vinculations for the object
 * @param ContentDataObject $object
 */
function render_co_view_member_path(ContentDataObject $object) {
	tpl_assign('object', $object);
	return tpl_fetch(get_template_path('member_path', 'co'));
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:9,代码来源:application.php

示例14: execute

 /**
  * Execute the script
  *
  * @param void
  * @return boolean
  */
 function execute()
 {
     // ---------------------------------------------------
     //  Check MySQL version
     // ---------------------------------------------------
     $mysql_version = mysql_get_server_info($this->database_connection);
     if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) {
         $constants['DB_CHARSET'] = 'utf8';
         @mysql_query("SET NAMES 'utf8'", $this->database_connection);
         tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci');
         tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
     } else {
         tpl_assign('default_collation', $default_collation = '');
         tpl_assign('default_charset', $default_charset = '');
     }
     // if
     $installed_version = installed_version();
     $t_prefix = TABLE_PREFIX;
     if (version_compare($installed_version, '1.7.5') <= 0 && TABLE_PREFIX != "fo_") {
         $t_prefix = "fo_";
     }
     tpl_assign('table_prefix', $t_prefix);
     if (defined('DB_ENGINE')) {
         tpl_assign('engine', DB_ENGINE);
     } else {
         tpl_assign('engine', 'InnoDB');
     }
     // ---------------------------------------------------
     //  Execute migration
     // ---------------------------------------------------
     $additional_upgrade_steps = array();
     // RUN QUERIES
     $total_queries = 0;
     $executed_queries = 0;
     $upgrade_script = "";
     // upgrading from version 1.x
     if (version_compare($installed_version, '2.0.0.0-beta') < 0) {
         ini_set('memory_limit', '1024M');
         @set_time_limit(0);
         $upgrade_script .= tpl_fetch(get_template_path('db_migration/2_0_asado'));
         if ($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) {
             $this->printMessage("Database schema transformations executed (total queries: {$total_queries})");
         } else {
             $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true);
             return false;
         }
         $_SESSION['from_feng1'] = true;
         $upgrade_script = "";
         @unlink(ROOT . '/cache/autoloader.php');
         include ROOT . '/environment/classes/AutoLoader.class.php';
         include ROOT . '/environment/constants.php';
         if (!($callbacks = spl_autoload_functions())) {
             $callbacks = array();
         }
         foreach ($callbacks as $callback) {
             spl_autoload_unregister($callback);
         }
         spl_autoload_register('feng_upg_autoload');
         foreach ($callbacks as $callback) {
             spl_autoload_register($callback);
         }
         @(include ROOT . '/cache/autoloader.php');
         define('DONT_LOG', true);
         define('FORCED_TABLE_PREFIX', 'fo_');
         if (!defined('FILE_STORAGE_FILE_SYSTEM')) {
             define('FILE_STORAGE_FILE_SYSTEM', 'fs');
         }
         if (!defined('FILE_STORAGE_MYSQL')) {
             define('FILE_STORAGE_MYSQL', 'mysql');
         }
         if (!defined('MAX_SEARCHABLE_FILE_SIZE')) {
             define('MAX_SEARCHABLE_FILE_SIZE', 1048576);
         }
         try {
             DB::connect(DB_ADAPTER, array('host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASS, 'name' => DB_NAME, 'persist' => DB_PERSIST));
             if (defined('DB_CHARSET') && trim(DB_CHARSET)) {
                 DB::execute("SET NAMES ?", DB_CHARSET);
             }
         } catch (Exception $e) {
             $this->printMessage("Error connecting to database: " . $e->getMessage() . "\n" . $e->getTraceAsString());
         }
         try {
             $db_result = DB::execute("SELECT value FROM " . $t_prefix . "config_options WHERE name = 'file_storage_adapter'");
             $db_result_row = $db_result->fetchRow();
             if ($db_result_row['value'] == FILE_STORAGE_FILE_SYSTEM) {
                 if (!defined('FILES_DIR')) {
                     define('FILES_DIR', ROOT . '/upload');
                 }
                 FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR, TABLE_PREFIX));
             } else {
                 FileRepository::setBackend(new FileRepository_Backend_DB(TABLE_PREFIX));
             }
             PublicFiles::setRepositoryPath(ROOT . '/public/files');
             if (!defined('PUBLIC_FOLDER')) {
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:101,代码来源:AsadoUpgradeScript.class.php

示例15: upgrade


//.........这里部分代码省略.........
                     $this->printMessage("File '{$relative_path}' exists and is writable");
                 } else {
                     $this->printMessage("File '{$relative_path}' is not writable", true);
                     return false;
                 }
                 // if
             } else {
                 if (is_dir($path)) {
                     if (folder_is_writable($path)) {
                         $this->printMessage("Folder '{$relative_path}' exists and is writable");
                     } else {
                         $this->printMessage("Folder '{$relative_path}' is not writable", true);
                         return false;
                     }
                     // if
                 } else {
                     $this->printMessage("'{$relative_path}' does not exists on the system", true);
                     return false;
                 }
             }
             // if
         }
         // foreach
         // check for loaded extensions
         foreach ($ext_checks as $extension_name) {
             if (extension_loaded($extension_name)) {
                 $this->printMessage("Extension '{$extension_name}' is loaded");
             } else {
                 $this->printMessage("Extension '{$extension_name}' is not loaded", true);
                 return false;
             }
             // if
         }
         // foreach
         // connect to database
         if ($dbc = mysql_connect(DB_HOST, DB_USER, DB_PASS)) {
             if (mysql_select_db(DB_NAME, $dbc)) {
                 $this->printMessage('Upgrade script has connected to the database.');
             } else {
                 $this->printMessage('Failed to select database ' . DB_NAME);
                 return false;
             }
             // if
         } else {
             $this->printMessage('Failed to connect to database');
             return false;
         }
         // if
         // check MySQL version
         $mysql_version = mysql_get_server_info($dbc);
         if ($mysql_version && version_compare($mysql_version, "4.1", '>=')) {
             $constants['DB_CHARSET'] = 'utf8';
             @mysql_query("SET NAMES 'utf8'", $dbc);
             tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci');
             tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
         } else {
             tpl_assign('default_collation', $default_collation = '');
             tpl_assign('default_charset', $default_charset = '');
         }
         // if
         tpl_assign('table_prefix', TABLE_PREFIX);
         if (defined('DB_ENGINE')) {
             tpl_assign('engine', DB_ENGINE);
         } else {
             tpl_assign('engine', 'InnoDB');
         }
         // check test query
         $test_table_name = TABLE_PREFIX . 'test_table';
         $test_table_sql = "CREATE TABLE `{$test_table_name}` (\n\t\t\t\t`id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t\t`name` varchar(50) {$default_collation} NOT NULL default '',\n\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=InnoDB {$default_charset};";
         if (@mysql_query($test_table_sql, $dbc)) {
             $this->printMessage('Test query has been executed. Its safe to proceed with database migration.');
             @mysql_query("DROP TABLE `{$test_table_name}`", $dbc);
         } else {
             $this->printMessage('Failed to executed test query. MySQL said: ' . mysql_error($dbc), true);
             return false;
         }
         // if
         // execute scripts
         foreach ($scripts as $script) {
             if (version_compare($script->getVersionTo(), $version_from) > 0 && version_compare($script->getVersionTo(), $version_to) <= 0) {
                 $script->setDatabaseConnection($dbc);
                 if ($script->execute() === false) {
                     $this->printMessage("Error upgrading to version " . $script->getVersionTo());
                     break;
                 }
                 $last_correct_version = $script->getVersionTo();
                 tpl_assign('version', $last_correct_version);
                 file_put_contents(INSTALLATION_PATH . '/config/installed_version.php', tpl_fetch(get_template_path('installed_version')));
             }
             // if
         }
         // foreach
         if (isset($last_correct_version)) {
             @mysql_query("UPDATE `" . TABLE_PREFIX . "config_options` SET `value` = 0 WHERE `name` = 'upgrade_last_check_new_version'");
             tpl_assign('version', $last_correct_version);
             return file_put_contents(INSTALLATION_PATH . '/config/installed_version.php', tpl_fetch(get_template_path('installed_version')));
         }
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:ScriptUpgrader.class.php


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