Recursos JClic Aula
settings->title;
}
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
return $rsc_name;
} // try
catch(Exception $e) {
echo 'Caught exception: '.$e->getMessage()."\n";
return $dir;
}
}
function CreateButton($dir, $resource, $class){
if ($class=="html"){
print(" ");
} else{
$rsc_name=getNameFromZip($dir, $resource);
if (!$rsc_name){$rsc_name=$dir;}
print(" ");
}
}
function LoadResourcesFromDir($jclicdirectory){
$rscfound=0; // Resources found
$jclicconten = opendir($jclicdirectory);
$lista = array();
while($jclicfile = readdir($jclicconten))
{
if (substr("$jclicfile", 0, 1) != ".")
{
$lista[] = $jclicfile;
}
}
if(count($lista)>0)
{
sort($lista);
// Search .html
$resource="";
foreach($lista as $item)
if($item=="index.html"){
$resource=$item;
break; }
if ($resource!=""){ // Found .html
// Button for resource
CreateButton($jclicdirectory, $resource, "html");
} else{ // Not found .html... search jclic.jclic
foreach($lista as $item){
if($item=="jclic.jclic"){
$resource=$item;
break;
}
}
if($resource!=""){ // Found jclic.jclic
//Button for jclic.jclic
CreateButton($jclicdirectory, $resource, "jclic");
} else {
foreach($lista as $item){
if((substr($item, -6 )==".jclic")){
$resource=$item;
break;
}
}
if($resource!=""){ // Found any .jclic
//Button for *.jclic
CreateButton($jclicdirectory, $resource, "jclic");
} else {
foreach($lista as $item){
if((substr($item, -10 )==".jclic.zip")){
//echo "FOUND JCLIC LISTS!!!!!";
$resource=$item;
if ($resource!=""){
// Button for .jclic.zip
CreateButton($jclicdirectory, $resource, "jclic");
// Increasing number of elements
$rscfound++;
}
//break;
}
}
/*if ($resource!=""){ -------> MOVED UP
// Button for .jclic.zip
CreateButton($jclicdirectory, $resource, "jclic");
}*/
}
}
}
}
return ($rscfound);
}
function LoadResourcesFromMainDir($basePath, $locale){
// Loads any jclic resource from basepath
$numrsc=0;
// loop through the array of files and print them all
$rootdirectory = opendir($basePath);
//Read directory
while($jclicdirectory = readdir($rootdirectory))
{
//Only list directories (or zips)
//echo($jclicdirectory." is ".mime_content_type($jclicdirectory).""); if (filetype($jclicdirectory) == "dir" || filetype($jclicdirectory) == "link") { //if (substr($jclicdirectory, -4)==".zip") echo "ES UN ZIP"; //Only enter non hide directory if (substr("$jclicdirectory", 0, 1) != "."&&$jclicdirectory!="jclic_uploads") { $rscs=LoadResourcesFromDir($jclicdirectory, $locale); $numrsc+=$rscs; } } // if filetype... } // While if($numrsc==0){ if ($locale=="valencia") echo "
No hi ha recursos disponibles en esta secció
";
else echo "No hay recursos disponibles en esta sección
";
}
}
//obtener el locale
$locale= get_locale();
// buscar title
$titles = array();
$titles = preg_find("/\.title/", "./");
foreach ($titles as $title) {
$txt="";
// comprobamos si no tiene extension "localizada"
if ( ereg("\.title$", $title) )
{
// lo mostraremos solamente si no existe version especifica para nuestro "locale"
$testfile=$title . "." . $locale ;
if ( ! is_file( $testfile ) ) $txt = file_get_contents($title);
// en caso contrario, se muestra sólo si tiene extension para el "locale" actual
} elseif ( ereg("\.title." . $locale, $title) )
{
$txt = file_get_contents($title);
}
echo "$txt
"; } ?>
No hi ha recursos disponibles en esta secció
";
else echo "No hay recursos disponibles en esta sección
";
}
?>