--- template_file.inc 2008-07-13 22:10:24.000000000 -0400 +++ template_file.inc.new 2008-08-12 07:11:30.000000000 -0400 @@ -10,19 +10,6 @@ * and javascript page injection mechanisms to function correctly. */ -//------------------------------------------------------------------------------ -// Template File constants (just in case we change the names later) - -/** - * Once again, prefix these constants with ([T]emplate [A]pplication - * [P]rograming [I]nterface) so that constants have a much smaller chance of - * conflicting with constants defined in the Drupal core and other Drupal - * modules. - */ -define('TAPI_ROOT_DIR', 'files/template'); -define('TAPI_CSS_DIR', TAPI_ROOT_DIR . '/css'); -define('TAPI_JS_DIR', TAPI_ROOT_DIR . '/javascript'); - /** * This module optionally uses a Javascript packer obtained from: * @@ -38,46 +25,24 @@ * * @return boolean */ -function template_api_create_template_directories() { - // Create top level file directory for template api module - if (!template_api_create_directory(TAPI_ROOT_DIR)) { - return FALSE; - } - // Create css file directory - if (!template_api_create_directory(TAPI_CSS_DIR)) { - return FALSE; - } - // Create javascript file directory - if (!template_api_create_directory(TAPI_JS_DIR)) { - return FALSE; - } - return TRUE; -} - -/******************************************************************************* - * Create a single template directory - * - * This function is meant for internal use only! - * - * @param string $path - directory path - * @return boolean - */ -function template_api_create_directory($path) { - - $real_path = realpath($path); - - if (!is_dir($real_path)) { - // Directory does not yet exist. - if (mkdir($real_path)) { - return template_api_log_status('Folder "' . $path . '" created'); - } - else { - return template_api_log_status('Unable to create "' . $path . '"', - WATCHDOG_ERROR); - } - } - // Directory already exists. - return TRUE; +function template_api_create_directories() { + $files_directory = file_directory_path(); + $template_path = "$files_directory/active_template"; + $css_path = "$template_path/css"; + $js_path = "$template_path/javascript"; + if (!file_check_directory($template_path, FILE_CREATE_DIRECTORY)) { + drupal_set_message("Unable to create or write to a template directory in $files_directory"); + $fail = TRUE; + } + if (!file_check_directory($css_path, FILE_CREATE_DIRECTORY)) { + drupal_set_message("Unable to create or write a css directory in $template_path"); + $fail = TRUE; + } + if (!file_check_directory($js_path, FILE_CREATE_DIRECTORY)) { + drupal_set_message("Unable to create or write a javascript directory in $template_path"); + $fail = TRUE; + } + return $fail ? FALSE : TRUE; } /******************************************************************************* @@ -97,9 +62,10 @@ // Make sure all the proper directories exist. This should not have too much // of a performance penalty because it is only called when we are saving a // template. - if (!template_api_create_template_directories()) { - return FALSE; - } + if (!template_api_create_directories()) { + drupal_set_message('Unable to create or write to the needed template directories. Contact your server administrator if you need assistance.'); + return; + } // Save css template file. if (strlen($css_data)) { @@ -249,4 +215,4 @@ if (file_exists($js_path) && filesize($js_path) > 0) { drupal_add_js($js_path, 'theme'); } -} \ No newline at end of file +}