You are here

function textimage_install in Textimage 7.3

Same name and namespace in other branches
  1. 5.2 textimage.install \textimage_install()
  2. 5 textimage.install \textimage_install()
  3. 6.2 textimage.install \textimage_install()

Implements hook_install().

File

./textimage.install, line 138
Textimage - Installation scripts.

Code

function textimage_install() {
  $t = get_t();

  // Add database fields required by Textimage.
  $table_fields = _textimage_define_table_fields();
  foreach ($table_fields as $table_name => $fields) {
    foreach ($fields as $field_name => $field) {
      if (!db_field_exists($table_name, $field_name)) {
        db_add_field($table_name, $field_name, $field);
      }
    }
  }

  // Create fonts and background directories.
  $fonts_path = _textimage_get_variable('fonts_path');
  if (!file_prepare_directory($fonts_path, FILE_CREATE_DIRECTORY)) {
    _textimage_diag($t('Failed to create directory "%path". Visit the <a href="@url">configuration page</a> to setup font management.', array(
      '%path' => _textimage_get_variable('fonts_path'),
      '@url' => url('admin/config/media/textimage'),
    )), WATCHDOG_ERROR);
  }
  $backgrounds_path = _textimage_get_variable('backgrounds_path');
  if (!file_prepare_directory($backgrounds_path, FILE_CREATE_DIRECTORY)) {
    _textimage_diag($t('Failed to create directory "%path". Visit the <a href="@url">configuration page</a> to setup background images management.', array(
      '%path' => _textimage_get_variable('backgrounds_path'),
      '@url' => url('admin/config/media/textimage'),
    )), WATCHDOG_ERROR);
  }
}