function moodbile_templates_load_html() { //Cargamos en un array, los templates que son por defecto //Comprobamos si existen templates en el directorio del tema, si es si, substituimos el default por el del tema. Si es no, nada. global $CFG, $Moodbile; $theme = $CFG['theme']; $templatepath = $CFG['basepath'] . 'misc/templates'; $theme_templatepath = $CFG['basepath'] . 'themes/' . $theme . '/templates'; if ($templates_files = scandir($templatepath)) { $templates_files = array_diff($templates_files, array('.', '..')); //_debug($templates_files); //Comprobamos si los templates existen en el directorio del tema y a su vez, formamos la url donde estan los templates $templates_html = '<div id="templates">'; foreach ($templates_files as $template_filename) { if (!file_exists($theme_templatepath . '/' . $value)) { $templates_html .= file_get_contents($templatepath . '/' . $template_filename); } else { // $templates_html .= file_get_contents($theme_templatepath.'/'.$template_filename); } } $templates_html .= '</div>'; return trim($templates_html); } else { moodbile_add_alert("error", "No_templates"); return FALSE; } }
function moodbile_performance_make_cacheable($source, $type = NULL) { global $CFG; $file_cache_path = $CFG['basepath'] . 'misc/cache/files'; $file_cache_path_by_type = $CFG['basepath'] . 'misc/cache/files/' . $type . '/'; if (!file_exists($file_cache_path)) { mkdir($file_cache_path); chmod($file_cache_path, 0777); } if (!file_exists($file_cache_path_by_type)) { mkdir($file_cache_path_by_type); chmod($file_cache_path_by_type, 0777); } if (is_file($source)) { $filename = explode('/', $source); $filename = $filename[count($filename) - 1]; copy($source, $file_cache_path . $filename); } else { if ($files = scandir($source)) { $files = array_diff($files, array('.', '..')); foreach ($files as $file) { $filename = explode('/', $file); $filename = $filename[count($filename) - 1]; if (!copy($source . '/' . $file, 'misc/cache/files/' . $type . '/' . $filename)) { moodbile_add_alert("error", "files_not_cached"); } } } } }