本文整理汇总了PHP中file_check_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP file_check_directory函数的具体用法?PHP file_check_directory怎么用?PHP file_check_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_check_directory函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepareDirectory
/**
* Check that the directory exists and is writable, creating it if needed.
*
* @throws
* \ModuleBuilder\Exception
*/
function prepareDirectory($directory)
{
// Because we may have an absolute path whose base folders are not writable
// we can't use the standard recursive D6 pattern.
$pieces = explode('/', $directory);
// Work up through the folder's parentage until we find a directory that exists.
// (Or in other words, backwards in the array of pieces.)
$length = count($pieces);
for ($i = 0; $i < $length; $i++) {
//print $pieces[$length - $i];
$slice = array_slice($pieces, 0, $length - $i);
$path_slice = implode('/', $slice);
if (file_exists($path_slice)) {
$status = file_check_directory($path_slice, FILE_CREATE_DIRECTORY);
break;
}
}
// If we go right the way along to the base and still can't create a directory...
if ($i == $length) {
throw new \ModuleBuilder\Exception("The directory {$path_slice} cannot be created or is not writable.");
}
// print "status: $status for $path_slice - i: $i\n";
// Now work back down (or in other words, along the array of pieces).
for ($j = $length - $i; $j < $length; $j++) {
$slice[] = $pieces[$j];
$path_slice = implode('/', $slice);
//print "$path_slice\n";
$status = file_check_directory($path_slice, FILE_CREATE_DIRECTORY);
}
if (!$status) {
throw new \ModuleBuilder\Exception("The hooks directory cannot be created or is not writable.");
}
}
开发者ID:alexburrows,项目名称:training,代码行数:39,代码来源:VersionHelper6.php
示例2: singular_settings
/**
* Implementation of hook_settings() for themes.
*/
function singular_settings($settings)
{
// Add js & css
drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
drupal_add_js('misc/farbtastic/farbtastic.js');
drupal_add_js(drupal_get_path('theme', 'singular') . '/js/settings.js');
drupal_add_css(drupal_get_path('theme', 'singular') . '/css/settings.css');
file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY, 'file_directory_path');
// Check for a new uploaded logo, and use that instead.
if ($file = file_save_upload('background_file', array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = 'singular_background.' . $parts['extension'];
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['background_path'] = $file->filepath;
}
}
$form = array();
$form['layout'] = array('#title' => t('Layout'), '#type' => 'select', '#options' => array('fixed' => t('Fixed width'), 'fluid' => t('Fluid width')), '#default_value' => !empty($settings['layout']) ? $settings['layout'] : 'fixed');
$form['messages'] = array('#type' => 'fieldset', '#tree' => FALSE, '#title' => t('Autoclose messages'), '#descriptions' => t('Select the message types to close automatically after a few seconds.'));
$form['messages']['autoclose'] = array('#type' => 'checkboxes', '#options' => array('status' => t('Status'), 'warning' => t('Warning'), 'error' => t('Error')), '#default_value' => !empty($settings['autoclose']) ? $settings['autoclose'] : array('status'));
$form['style'] = array('#title' => t('Styles'), '#type' => 'select', '#options' => singular_get_styles(), '#default_value' => !empty($settings['style']) ? $settings['style'] : 'sea');
$form['custom'] = array('#tree' => FALSE, '#type' => 'fieldset', '#attributes' => array('class' => $form['style']['#default_value'] == 'custom' ? 'singular-custom-settings' : 'singular-custom-settings hidden'));
$form['custom']['background_file'] = array('#type' => 'file', '#title' => t('Background image'), '#maxlength' => 40);
if (!empty($settings['background_path'])) {
$form['custom']['background_preview'] = array('#type' => 'markup', '#value' => !empty($settings['background_path']) ? theme('image', $settings['background_path'], NULL, NULL, array('width' => '100'), FALSE) : '');
}
$form['custom']['background_path'] = array('#type' => 'value', '#value' => !empty($settings['background_path']) ? $settings['background_path'] : '');
$form['custom']['background_color'] = array('#title' => t('Background color'), '#type' => 'textfield', '#size' => '7', '#maxlength' => '7', '#default_value' => !empty($settings['background_color']) ? $settings['background_color'] : '#888888', '#suffix' => '<div id="singular-colorpicker"></div>');
$form['custom']['background_repeat'] = array('#title' => t('Tile'), '#type' => 'select', '#options' => array('no-repeat' => t('Don\'t tile'), 'repeat-x' => t('Horizontal'), 'repeat-y' => t('Vertical'), 'repeat' => t('Both')), '#default_value' => !empty($settings['background_repeat']) ? $settings['background_repeat'] : 'no-repeat');
return $form;
}
开发者ID:szczym,项目名称:tutturu,代码行数:34,代码来源:theme-settings.php
示例3: sunshine_build_css_cache
function sunshine_build_css_cache($css_files)
{
$data = '';
// Create the css/ within the files folder.
$csspath = file_create_path('css');
$orgpath = drupal_get_path('theme', 'sunshine') . '/css/';
file_check_directory($csspath, FILE_CREATE_DIRECTORY);
// Build aggregate CSS file.
foreach ($css_files as $key => $file) {
$contents = drupal_load_stylesheet($orgpath . $file, TRUE);
// Return the path to where this CSS file originated from.
$base = base_path() . $orgpath;
_drupal_build_css_path(NULL, $base);
// Prefix all paths within this CSS file, ignoring external and absolute paths.
$data .= preg_replace_callback('/url\\([\'"]?(?![a-z]+:|\\/+)([^\'")]+)[\'"]?\\)/i', '_drupal_build_css_path', $contents);
}
// Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
// @import rules must proceed any other style, so we move those to the top.
$regexp = '/@import[^;]+;/i';
preg_match_all($regexp, $data, $matches);
$data = preg_replace($regexp, '', $data);
$data = implode('', $matches[0]) . $data;
$checksum = md5($data);
$filename_cache = 'sunshine.cache.css';
// Create the CSS file.
if (!file_exists($csspath . '/' . $filename_cache) || md5(file_get_contents($csspath . '/' . $filename_cache)) != $checksum) {
// drupal_set_message('Sunshine CSS cache has been rebuilt.');
file_save_data($data, $csspath . '/' . $filename_cache, FILE_EXISTS_REPLACE);
}
return $csspath . '/' . $filename_cache;
}
开发者ID:upei,项目名称:drupal6-cms,代码行数:31,代码来源:template.php
示例4: _ad_blueprint_write_css
function _ad_blueprint_write_css()
{
// Set the location of the custom.css file
$file_path = file_directory_path() . '/ad_blueprint/custom.css';
// If the directory doesn't exist, create it
file_check_directory(dirname($file_path), FILE_CREATE_DIRECTORY);
// Generate the CSS
$file_contents = _ad_blueprint_build_css();
$output = '<div class="description">' . t('This CSS is generated by the settings chosen above and placed in the files directory: ' . l($file_path, $file_path) . '. The file is generated each time this page (and only this page) is loaded. <strong class="marker">Make sure to refresh your page to see the changes</strong>') . '</div>';
file_save_data($file_contents, $file_path, FILE_EXISTS_REPLACE);
return $output;
}
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:12,代码来源:theme-settings.php
示例5: setUp
/**
* Generates a random database prefix and runs the install scripts on the prefixed database.
* After installation many caches are flushed and the internal browser is setup so that the page
* requests will run on the new prefix. A temporary files directory is created with the same name
* as the database prefix.
*
* @param ... List modules to enable.
*/
function setUp()
{
global $db_prefix, $simpletest_ua_key;
if ($simpletest_ua_key) {
$this->db_prefix_original = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
include_once './includes/install.inc';
drupal_install_system();
$modules = array_unique(array_merge(func_get_args(), drupal_verify_profile('default', 'en')));
drupal_install_modules($modules);
$this->_modules = drupal_map_assoc($modules);
$this->_modules['system'] = 'system';
$task = 'profile';
default_profile_tasks($task, '');
menu_rebuild();
actions_synchronize();
_drupal_flush_css_js();
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
// Use temporary files directory with the same prefix as database.
$this->original_file_directory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
file_check_directory(file_directory_path(), TRUE);
// Create the files directory.
}
parent::setUp();
}
开发者ID:sdboyer,项目名称:sdboyer-test,代码行数:37,代码来源:drupal_web_test_case.php
示例6: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix;
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix = Database::getActiveConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_system();
$this->preloadRegistry();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
$modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
drupal_install_modules($modules);
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
file_check_directory($directory, FILE_CREATE_DIRECTORY);
// Create the files directory.
}
开发者ID:springnet,项目名称:drupal,代码行数:50,代码来源:drupal_web_test_case.php
示例7: hook_custom_formatters_field_prepare
/**
* Prepare a CCK field array for use with Devel Generate.
*
* @return
* A keyed array with keys defined as necessary for the $field array passed
* to your modules implementation of Devel Generates hook_content_generate().
*/
function hook_custom_formatters_field_prepare()
{
file_check_directory($path = file_directory_path() . '/._tmp.custom_formatters', TRUE);
return array('widget' => array('file_extensions' => 'jpg png', 'file_path' => '._tmp.custom_formatters'));
}
开发者ID:aakb,项目名称:Urban-media-space,代码行数:12,代码来源:custom_formatters.api.php
示例8: array
<?php
require_once '../../includes/bootstrap.inc';
require_once '../../includes/common.inc';
require_once '../../includes/module.inc';
$file_types = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png');
/**
* randomly select an image from the current directory and return it
*/
$cached = 0;
$origin = '';
if (module_exists('imagecache')) {
$directory = base_path() . '/' . file_directory_path() . '/banners/';
$origin = $directory;
file_check_directory($directory, FILE_CREATE_DIRECTORY);
$presetname = 'm4music_banner_image';
$preset = imagecache_preset_by_name($presetname);
while (FALSE !== ($file = readdir($directory))) {
if (preg_match($regex, $file)) {
$cached = 1;
}
}
if (!$cached) {
$directory = opendir("./banners/");
$origin = "./banners/";
} else {
$directory = opendir($origin);
}
} else {
$directory = opendir("./banners/");
$origin = "./banners/";
开发者ID:hiob1989,项目名称:m4Music,代码行数:31,代码来源:banner-img.php
示例9: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language;
// Store necessary current values before switching to prefixed database.
$this->originalLanguage = $language;
$this->originalLanguageDefault = variable_get('language_default');
$this->originalPrefix = $db_prefix;
$this->originalFileDirectory = file_directory_path();
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_system();
$this->preloadRegistry();
// Add the specified modules to the list of modules in the default profile.
// Install the modules specified by the default profile.
$core_modules = drupal_get_profile_modules('default', 'en');
drupal_install_modules($core_modules, TRUE);
node_type_clear();
// Install additional modules one at a time in order to make sure that the
// list of modules is updated between each module's installation.
$modules = func_get_args();
foreach ($modules as $module) {
drupal_install_modules(array($module), TRUE);
}
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
node_types_rebuild();
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
// Log in with a clean $user.
$this->originalUser = $user;
drupal_save_session(FALSE);
$user = user_load(1);
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// Set up English language.
unset($GLOBALS['conf']['language_default']);
$language = language_default();
// Make sure our drupal_mail_wrapper function is called instead of the
// default mail handler.
variable_set('smtp_library', drupal_get_path('module', 'simpletest') . '/drupal_web_test_case.php');
// Use temporary files directory with the same prefix as database.
variable_set('file_directory_path', $this->originalFileDirectory . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
set_time_limit($this->timeLimit);
}
开发者ID:unicorn-fail,项目名称:drupal-bootstrap.org,代码行数:71,代码来源:dwtc.php
示例10: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language;
// Store necessary current values before switching to prefixed database.
$this->originalLanguage = $language;
// $this->originalLanguageDefault = variable_get('language_default');
$this->originalPrefix = $db_prefix;
$this->originalFileDirectory = file_directory_path();
// $this->originalProfile = drupal_get_profile();
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix_new = $db_prefix . 'simpletest' . mt_rand(1000, 1000000);
// Workaround to insure we init the theme layer before going into prefixed
// environment. (Drupal 6)
$this->pass(t('Starting run with db_prefix %prefix', array('%prefix' => $db_prefix_new)), 'System');
// db_update('simpletest_test_id')
// ->fields(array('last_prefix' => $db_prefix_new))
// ->condition('test_id', $this->testId)
// ->execute();
db_query("UPDATE {simpletest_test_id}\n SET last_prefix = '%s'\n WHERE test_id = %d", $db_prefix_new, $this->testId);
$db_prefix = $db_prefix_new;
// Create test directory ahead of installation so fatal errors and debug
// information can be logged during installation process.
$directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
// file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Log fatal errors.
ini_set('log_errors', 1);
ini_set('error_log', $directory . '/error.log');
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// // Include the default profile
// variable_set('install_profile', 'default');
// $profile_details = install_profile_info('default', 'en');
// Add the specified modules to the list of modules in the default profile.
// Install the modules specified by the default profile.
// drupal_install_modules($profile_details['dependencies'], TRUE);
drupal_install_modules(drupal_verify_profile('default', 'en'));
// node_type_clear();
// Install additional modules one at a time in order to make sure that the
// list of modules is updated between each module's installation.
$modules = func_get_args();
foreach ($modules as $module) {
// drupal_install_modules(array($module), TRUE);
drupal_install_modules(array($module));
}
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
// $install_state = array();
// drupal_install_modules(array('default'), TRUE);
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
// node_types_rebuild();
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', 'default');
// variable_set('install_task', 'done');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// // Set up English language.
// unset($GLOBALS['conf']['language_default']);
// $language = language_default();
// Use the test mail class instead of the default mail handler class.
// variable_set('mail_sending_system', array('default-system' => 'TestingMailSystem'));
variable_set('smtp_library', drupal_get_path('module', 'simpletest') . '/simpletest.mail.inc');
//.........这里部分代码省略.........
开发者ID:knieper,项目名称:crltmich,代码行数:101,代码来源:drupal_web_test_case.php
示例11: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language;
// $language (Drupal 6).
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
$modules = array_unique(array_merge(drupal_verify_profile('default', 'en'), $args));
// drupal_install_modules($modules, TRUE);
drupal_install_modules($modules);
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
set_time_limit($this->timeLimit);
}
开发者ID:jhedstrom,项目名称:DonorRally,代码行数:69,代码来源:drupal_web_test_case.php
示例12: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
function setUp()
{
global $db_prefix, $user, $language;
// $language (Drupal 6).
global $install_locale;
// Store necessary current values before switching to prefixed database.
$this->db_prefix_original = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
include_once './includes/install.inc';
drupal_install_system();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// Add language and basic i18n modules
$install_locale = $this->install_locale;
$i18n_modules = array('locale', 'translation', 'i18n', 'i18n_test');
$modules = array_unique(array_merge(drupal_verify_profile('default', $this->install_locale), $args, $i18n_modules));
drupal_install_modules($modules);
// Install locale
if ($this->install_locale != 'en') {
$this->addLanguage($this->install_locale, TRUE);
}
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(1);
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
drupal_set_time_limit($this->timeLimit);
// Some more includes
require_once 'includes/language.inc';
// Refresh theme
$this->initTheme();
// Set path languages so we can retrieve pages in different languages
variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
}
开发者ID:rvilar,项目名称:i18n,代码行数:68,代码来源:drupal_i18n_test_case.php
示例13: move_pdf
/**
* Moves a PDF file to the appropriate location
*
* @param string $filename
*/
function move_pdf($filename)
{
global $mniblogpub_props;
// Get all our names and directories
$full_src = $mniblogpub_props["mniblogpub.shared"]["bloghome"] . "/pdfs/" . $filename;
$orig_src = $full_src;
$dst_dir = file_directory_path() . "/" . $mniblogpub_props["mniblogpub.php"]["dir.pdf.drupal"];
$full_dst = $dst_dir . "/" . $filename;
$dir_perms = !is_dir($dst_dir);
// Check our path
$p = file_create_path($dst_dir);
if (!file_check_directory($p, FILE_CREATE_DIRECTORY)) {
if (!file_check_directory($p, FILE_MODIFY_PERMISSIONS)) {
print "ERROR: Could create pdfs directory at: " . $dst_dir . "\n";
exit(5);
}
}
if ($dir_perms) {
if (!chgrp($dst_dir, "www-data")) {
print "WARN: Could not change dir to www-data group. " . $dst_dir . "\n";
}
if (!chmod($dst_dir, 0775)) {
print "WARN: Could not change permissions for dir. " . $dst_dir . "\n";
}
}
// Error Checking
if (!file_copy($full_src, $full_dst, FILE_EXISTS_REPLACE)) {
print "ERROR: Could not move file " . $full_src . "\n";
exit(5);
}
if (!file_exists($full_dst)) {
print "ERROR: File not actually moved. " . $full_src . "\n";
exit(5);
}
if (!chgrp($full_dst, "www-data")) {
print "WARN: Could not change file to www-data group. " . $full_dst . "\n";
}
if (!chmod($full_dst, 0664)) {
print "WARN: Could not change permissions for file. " . $full_dst . "\n";
}
$details = stat($full_dst);
$file = new stdClass();
$file->filename = basename($full_dst);
$file->filepath = $full_dst;
$file->filemime = file_get_mimetype($full_dst);
$file->filesize = $details['size'];
$file->filesource = basename($full_dst);
$file->uid = $mniblogpub_props["mniblogpub.php"]["user.use"] == 1 ? $mniblogpub_props["mniblogpub.php"]["user.id"] : 1;
$file->status = FILE_STATUS_PERMANENT;
$file->timestamp = time();
$file->list = 1;
$file->new = true;
drupal_write_record('files', $file);
if ($file != null && $file) {
if (!unlink($orig_src)) {
// !!! NOTE:
// I don't think it's necessary to exit out here. I'm
// commenting this out for now. If it causes errors later,
// come back here. -Gerg
// print "ERROR: Could not remove src file at: " . $orig_src;
// exit(5);
print "WARN: Could not remove src file at: " . $orig_src . "\n";
}
} else {
print "ERROR: Error saving file object in Drupal. " . $full_src . "\n";
exit(5);
}
file_set_status($file, 1);
return $file;
}
开发者ID:freighthouse,项目名称:code,代码行数:75,代码来源:mniblogpub.php
示例14: file_check_path
/**
* Checks path to see if it is a directory, or a dir/file.
*
* @param $path A string containing a file path. This will be set to the
* directory's path.
* @return If the directory is not in a Drupal writable directory, FALSE is
* returned. Otherwise, the base name of the path is returned.
*/
function file_check_path(&$path)
{
// Check if path is a directory.
// coder_format uses file_check_path() to check for files only. 26/01/2008 sun
// Check if path is a possible dir/file.
$filename = basename($path);
$path = dirname($path);
if (file_check_directory($path)) {
return $filename;
}
return FALSE;
}
开发者ID:NeformatDev,项目名称:v2,代码行数:20,代码来源:coder_format.php
示例15: setUp
/**
* Installs Atrium instead of Drupal
*
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language, $profile, $install_locale;
// $language (Drupal 6).
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
$this->originalLanguage = clone $language;
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
$install_locale = $this->install_locale;
$profile = $this->install_profile;
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// Set up theme system for the maintenance page.
// Otherwise we have trouble: https://ds.openatrium.com/dsi/node/18426#comment-38118
// @todo simpletest module patch
drupal_maintenance_theme();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
$modules = array_unique(array_merge(drupal_verify_profile($this->install_profile, $this->install_locale), $args));
// drupal_install_modules($modules, TRUE);
drupal_install_modules($modules);
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
if ($this->install_profile == 'openatrium') {
// Download and import translation if needed
if ($this->install_locale != 'en') {
$this->installLanguage($this->install_locale);
}
// Install more modules
$modules = _openatrium_atrium_modules();
drupal_install_modules($modules);
// Configure intranet
// $profile_tasks = $this->install_profile . '_profile_tasks';
_openatrium_intranet_configure();
_openatrium_intranet_configure_check();
variable_set('atrium_install', 1);
// Clear views cache before rebuilding menu tree. Requires patch
// [patch_here] to Views, as new modules have been included and
// default views need to be re-detected.
module_exists('views') ? views_get_all_views(TRUE) : TRUE;
menu_rebuild();
}
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', $this->install_profile);
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', '[email protected]');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
set_time_limit($this->timeLimit);
}
开发者ID:jamon8888,项目名称:atrium_features,代码行数:92,代码来源:atrium_web_test_case.php
示例16: node_save
$issue->changed = $issue->created;
$issue->format = 5;
// Markdown, allows filtered HTML, as well.
$issue->comment = 2;
// Allow comments, otherwise they're invisible!
if ($private) {
$issue->private = 1;
}
node_save($issue);
$nid = $issue->nid;
if ($validation || $configcheck || $collected) {
// Process attachments
$issue_dir = variable_get('project_directory_issues', 'issues');
$dest = file_directory_path() . '/' . $issue_dir;
// Drupal's standard files path
if (!file_check_directory($dest)) {
echo "<br>Error processing attachments. Event has been logged and an administrator notified.\n";
error_log("Attachment directory {$dest} does not exist or is not writable.");
exit;
}
foreach (array($validation, $configcheck, $collected) as $attachment) {
if (empty($attachment)) {
continue;
}
// Generate a randomish unique file name
$file_id = $nid . "_" . time() . posix_getpid() . ++$acount;
// Save the file and put the path into $file
$file = file_save_data($attachment, "{$dest}/{$file_id}", $replace = FILE_EXISTS_RENAME);
// Make it a node in Drupal
// Get the file size
$details = stat($file);
开发者ID:swelljoe,项目名称:project_issue_virtualmin,代码行数:31,代码来源:bug.php
注:本文中的file_check_directory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论