/[drupal]/contributions/modules/active_template/template_file.inc
ViewVC logotype

Diff of /contributions/modules/active_template/template_file.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Mon Jul 14 02:10:24 2008 UTC revision 1.2, Fri Aug 15 06:12:26 2008 UTC
# Line 19  Line 19 
19   * conflicting with constants defined in the Drupal core and other Drupal   * conflicting with constants defined in the Drupal core and other Drupal
20   * modules.   * modules.
21   */   */
22  define('TAPI_ROOT_DIR', 'files/template');  define('TAPI_ROOT_DIR', file_directory_path() . '/template');
23  define('TAPI_CSS_DIR',  TAPI_ROOT_DIR . '/css');  define('TAPI_CSS_DIR',  TAPI_ROOT_DIR . '/css');
24  define('TAPI_JS_DIR',   TAPI_ROOT_DIR . '/javascript');  define('TAPI_JS_DIR',   TAPI_ROOT_DIR . '/javascript');
25    
# Line 39  define('TAPI_PACKER_CLASS_FILE', 'class. Line 39  define('TAPI_PACKER_CLASS_FILE', 'class.
39   * @return boolean   * @return boolean
40   */   */
41  function template_api_create_template_directories() {  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;  
 }  
42    
43  /*******************************************************************************    // Only variables can be passed by reference to Drupals file_check_directory() and we need these
44   * Create a single template directory    // constants elsewhere in this file.
45   *    $root_dir = TAPI_ROOT_DIR;
46   * This function is meant for internal use only!    $css_dir  = TAPI_CSS_DIR;
47   *    $js_dir   = TAPI_JS_DIR;
  * @param string $path - directory path  
  * @return boolean  
  */  
 function template_api_create_directory($path) {  
48    
49    $real_path = realpath($path);    if (!file_check_directory($root_dir, FILE_CREATE_DIRECTORY))  {
50        drupal_set_message('Unable to create or write to a template directory in '
51    if (!is_dir($real_path)) {                         . file_directory_path());
52                  // Directory does not yet exist.      $fail = TRUE;
53      if (mkdir($real_path)) {    }
54                    return template_api_log_status('Folder "' . $path . '" created');    if (!file_check_directory($css_dir, FILE_CREATE_DIRECTORY)) {
55                  }      drupal_set_message('Unable to create or write a css directory in ' . TAPI_ROOT_DIR);
56                  else {      $fail = TRUE;
57                    return template_api_log_status('Unable to create "' . $path . '"',    }
58                                                   WATCHDOG_ERROR);    if (!file_check_directory($js_dir, FILE_CREATE_DIRECTORY)) {
59                  }      drupal_set_message('Unable to create or write a javascript directory in ' . TAPI_ROOT_DIR);
60          }      $fail = TRUE;
61          // Directory already exists.    }
62          return TRUE;    return $fail ? FALSE : TRUE;
63  }  }
64    
65    
66  /*******************************************************************************  /*******************************************************************************
67   * Save all template files to the file system   * Save all template files to the file system
68   *   *
# Line 98  function template_api_save_template_file Line 81  function template_api_save_template_file
81          // of a performance penalty because it is only called when we are saving a          // of a performance penalty because it is only called when we are saving a
82          // template.          // template.
83          if (!template_api_create_template_directories()) {          if (!template_api_create_template_directories()) {
84              drupal_set_message('Unable to create or write to the needed template directories. '
85                           . 'Contact your server administrator if you need assistance.');
86            return FALSE;            return FALSE;
87          }          }
88    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2