You are here

function Smarty::_get_auto_filename in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/lib/smarty/Smarty.class.php \Smarty::_get_auto_filename()

get a concrete filename for automagically created content

@staticvar string|null @staticvar string|null

Parameters

string $auto_base:

string $auto_source:

string $auto_id:

Return value

string

1 call to Smarty::_get_auto_filename()
Smarty::_get_compile_path in includes/moodle/lib/smarty/Smarty.class.php
Get the compile path for this resource

File

includes/moodle/lib/smarty/Smarty.class.php, line 1728

Class

Smarty
@package Smarty

Code

function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) {
  $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
  $_return = $auto_base . DIRECTORY_SEPARATOR;
  if (isset($auto_id)) {

    // make auto_id safe for directory names
    $auto_id = str_replace('%7C', $_compile_dir_sep, urlencode($auto_id));

    // split into separate directories
    $_return .= $auto_id . $_compile_dir_sep;
  }
  if (isset($auto_source)) {

    // make source name safe for filename
    $_filename = urlencode(basename($auto_source));
    $_crc32 = sprintf('%08X', crc32($auto_source));

    // prepend %% to avoid name conflicts with
    // with $params['auto_id'] names
    $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
    $_return .= '%%' . $_crc32 . '%%' . $_filename;
  }
  return $_return;
}