$tableFormularioDiseno->addCell(3000)->addText($lang_concurso_etapa_mayus_minus . " " . ($j + 1) . " - " . $lang_concurso_actividad . " " . ($baseNumero + $i), $_estilo_titulo_actividad); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText($lang_concurso_nombre, $styleCelda); $tableFormularioDiseno->addCell($anchoContenido)->addText($_actividades[$i]['ac_nombre']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText($lang_concurso_aprendizaje_esperado, $styleCelda); //$tableFormularioDiseno->addCell($anchoContenido)->addText($_actividades[$i]['ac_aprendizaje_esperado']); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_aprendizaje_esperado']); // $tableFormularioDiseno->addRow(400); // $tableFormularioDiseno->addCell($anchoEtiqueta,$styleTableFormularioDisenoCelda2)->addText("Evidencia de aprendizaje",$styleCelda); // //$tableFormularioDiseno->addCell($anchoContenido)->addText($_actividades[$i]['ac_evidencia_aprendizaje']); // replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_evidencia_aprendizaje']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText($lang_concurso_desc_gral, $styleCelda); //$tableFormularioDiseno->addCell($anchoContenido)->addText($_actividades[$i]['ac_descripcion']); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_descripcion']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText($lang_concurso_tipo_lugar, $styleCelda); for ($z = 0; $z < count($_act_tipo); $z++) { if ($_act_tipo[$z]['valor'] == $_actividades[$i]['ac_tipo']) { $tableFormularioDiseno->addCell($anchoContenido)->addText($_act_tipo[$z]['nombre']); } } // $tableFormularioDiseno->addRow(400); // $tableFormularioDiseno->addCell($anchoEtiqueta,$styleTableFormularioDisenoCelda2)->addText("Materiales",$styleCelda); // $textMateriales = ''; // $_materiales = obtenerArchivosFuncion($_actividades[$i]['ac_id_actividad'], $conexion); // if(count($_materiales) > 0 ){ // for($t=0; $t < count($_materiales); $t++){ // $textMateriales .= $_materiales[$t]['a_nombre_archivo'].'<br>'; // }
$texto .= "<br> " . $lang_crear_diseno_word_h_web20 . ": " . $lang_crear_diseno_word_no; } //Herramienta de trabajos: REVISIÖN replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $texto); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText(cText($lang_nueva_actividad_inicio), $styleCelda); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_instrucciones_inicio']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText(cText($lang_nueva_actividad_desarrollo), $styleCelda); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_instrucciones_desarrollo']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText(cText($lang_nueva_actividad_cierre), $styleCelda); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_instrucciones_cierre']); $tableFormularioDiseno->addRow(400); $tableFormularioDiseno->addCell($anchoEtiqueta, $styleTableFormularioDisenoCelda2)->addText(cText($lang_nueva_actividad_consejos_practicos), $styleCelda); replaceHtml($tableFormularioDiseno->addCell($anchoContenido), $_actividades[$i]['ac_consejos_practicos']); } $section->addTextBreak(1); } $footer = $section->createFooter(); $footer->addPreserveText('{PAGE}'); $nombre_temp = str_replace(" ", "_", $fcd_nombre); $nombre_temp = str_replace(array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú"), array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"), $nombre_temp); $nombre_temp = preg_replace('/[^A-Za-z0-9_]/', '', $nombre_temp); $nombreArchivo = $nombre_temp . "_" . date('dmY') . ".docx"; // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('./data/' . $nombreArchivo); // Download the file: header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream');
function jwGallery($site_httppath, $site_absolutepath, $srcimgfolder, $thbimgfolder, $thb_width, $thb_height, $keepratio, $jpg_quality, $singlethumbmode, $sortorder, $showcaptions, $dynamic_caption, $wordlimit, $cache_expire_time, $html_template, $modulehtml, $downloadfile) { // Internal parameters $prefix = "jwsigpro_cache_"; $captionFile = "labels.txt"; $captionDummyTitle = "Title"; $captionDummyDesc = "<b>Description</b><br />You can use HTML as you can see!"; // Initiate $result $result = ''; // Execute code if the folder can be opened, or fail silently if ($dir = @opendir($site_absolutepath . $srcimgfolder)) { // initialize an array for matching files $found = array(); // Create an array of file types $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Traverse the folder, and add filename to $found array if type matches while (false !== ($item = readdir($dir))) { $fileInfo = pathinfo($item); if (array_key_exists('extension', $fileInfo) && in_array(strtolower($fileInfo['extension']), $fileTypes)) { $found[] = $item; } } // Check if the $found array is not empty if ($found) { // Sort array switch ($sortorder) { case 0: sort($found); break; case 1: natsort($found); break; // Sort in natural, case-sensitive order // Sort in natural, case-sensitive order case 2: natcasesort($found); break; // Sort in natural, case-insensitive order // Sort in natural, case-insensitive order case 3: rsort($found); break; case 4: shuffle($found); break; } // Caption handling if (file_exists($site_absolutepath . $srcimgfolder . $captionFile) && is_readable($site_absolutepath . $srcimgfolder . $captionFile)) { // read the captions file into an array $captionsfile = file($site_absolutepath . $srcimgfolder . $captionFile); foreach ($captionsfile as $caption) { $temp = explode("|", $caption); if (isset($temp[0]) && file_exists($site_absolutepath . $srcimgfolder . "/" . $temp[0])) { $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($temp[0])]['title'] = @$temp[1]; // maintain backwards compatibility regarding captions if (isset($temp[2])) { $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($temp[0])]['description'] = @$temp[2]; } else { $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($temp[0])]['description'] = @$temp[1]; } } } } else { if ($showcaptions == 2) { // Check if a captions file exists and if not write a new captions file and fill it with the image file list and content placeholders $captionsfile = fopen($site_absolutepath . $srcimgfolder . $captionFile, 'w'); foreach ($found as $filename) { fwrite($captionsfile, "{$filename}|{$captionDummyTitle}|{$captionDummyDesc}\n"); } fclose($captionsfile); // Read the new file $newcaptionsfile = file($site_absolutepath . $srcimgfolder . $captionFile); foreach ($newcaptionsfile as $caption) { $temp = explode("|", $caption); if (isset($temp[0]) && file_exists($site_absolutepath . $srcimgfolder . "/" . $temp[0])) { $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($temp[0])]['title'] = @$temp[1]; $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($temp[0])]['description'] = @$temp[2]; } } } } // Loop through the image file list for ($i = 0; $i < count($found); $i++) { // Assign source image and path to a variable $filename = $found[$i]; $original = $site_absolutepath . $srcimgfolder . $filename; // Single thumb mode conditions if ($singlethumbmode) { if ($i == 0) { $li_style = ""; $leftcomment = ""; $rightcomment = ""; } else { $li_style = " style=\"display:none;\""; $leftcomment = "<!--"; $rightcomment = "-->"; } } else { $li_style = ""; $leftcomment = ""; // <!-- $rightcomment = ""; // --> } // Caption display if ($showcaptions == 2) { $captiontitle = $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($filename)]['title']; $captiondescription = $captions[$site_absolutepath . $srcimgfolder . "/" . strtolower($filename)]['description'] . "<br /><br />"; $dynamic_caption = ''; } elseif ($showcaptions == 1) { $captiontitle = JText::_('JWSP_FE_CPNTITLE'); $captiondescription = JText::_('JWSP_FE_CPNDESCRIPTION') . "<br />" . $dynamic_caption . "<br /><br />"; } else { $captiontitle = ''; $captiondescription = ''; } if ($wordlimit) { $captiontitle = wordLimit($captiontitle, $wordlimit); } if ($downloadfile) { $download_html = replaceHtml('<a class="sig-download-link" href="' . $downloadfile . '?file=' . $srcimgfolder . replaceWhiteSpace($filename) . '">' . JText::_('JWSP_FE_DOWNLOAD') . '</a><br /><br />'); } else { $download_html = ''; } // Template assignments $template_variables = array("/{FILENAME}/", "/{SOURCE IMAGE FILEPATH}/", "/{THUMB IMAGE FILEPATH}/", "/{CAPTION TITLE}/", "/{CAPTION DESCRIPTION}/", "/{THUMB CLASS}/", "/{LEFT HTML COMMENT}/", "/{RIGHT HTML COMMENT}/", "/{DOWNLOAD LINK}/", "/{LOAD MODULE POSITION}/"); $real_variables = array($filename, $site_httppath . $srcimgfolder . replaceWhiteSpace($filename), $site_httppath . $thbimgfolder . $prefix . substr(md5($srcimgfolder), 1, 10) . strtolower(replaceWhiteSpace($filename)), replaceHtml($captiontitle), replaceHtml($captiondescription), $li_style, $leftcomment, $rightcomment, $download_html, replaceHtml($modulehtml)); // Check if thumb image exists already $thumbimage = $site_absolutepath . $thbimgfolder . $prefix . substr(md5($srcimgfolder), 1, 10) . strtolower($filename); if (file_exists($thumbimage) && is_readable($thumbimage) && filemtime($thumbimage) + $cache_expire_time > time()) { // OUTPUT $result .= preg_replace($template_variables, $real_variables, $html_template); } else { // Otherwise create the thumb image // begin by getting the details of the original list($width, $height, $type) = getimagesize($original); // strip the extension off the image filename (case insensitive) $imagetypes = array('/\\.gif$/i', '/\\.jpg$/i', '/\\.jpeg$/i', '/\\.png$/i'); $name = preg_replace($imagetypes, '', basename($original)); // create an image resource for the original switch ($type) { case 1: $source = @imagecreatefromgif($original); if (!$source) { $result = JText::_('JWSP_MSG_ERRGIF'); } break; case 2: $source = imagecreatefromjpeg($original); break; case 3: $source = imagecreatefrompng($original); break; default: $source = NULL; $result = JText::_('JWSP_MSG_NOFILETYPE'); } // make sure the image resource is OK if (!$source) { $result = JText::_('JWSP_MSG_COPYPROBLEM'); } else { // calculate the dimensions of the thumbnail if ($keepratio) { if ($width > $height) { $thumb_width = $thb_width; $thumb_height = $thb_width * $height / $width; } elseif ($width < $height) { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } else { $thumb_width = $thb_width; $thumb_height = $thb_height; } } else { // thumb ratio bigger that container ratio if ($width / $height > $thb_width / $thb_height) { // wide containers if ($thb_width >= $thb_height) { // wide thumbs if ($width > $height) { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } else { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } // high containers } else { // wide thumbs if ($width > $height) { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } else { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } } } else { // wide containers if ($thb_width >= $thb_height) { // wide thumbs if ($width > $height) { $thumb_width = $thb_width; $thumb_height = $thb_width * $height / $width; } else { $thumb_width = $thb_width; $thumb_height = $thb_width * $height / $width; } // high containers } else { // wide thumbs if ($width > $height) { $thumb_width = $thb_height * $width / $height; $thumb_height = $thb_height; } else { $thumb_width = $thb_width; $thumb_height = $thb_width * $height / $width; } } } } $thumb_width = round($thumb_width); $thumb_height = round($thumb_height); // create an image resource for the thumbnail $thumb = imagecreatetruecolor($thumb_width, $thumb_height); // create the resized copy imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); // save the resized copy $thumbname = $thbimgfolder . $prefix . substr(md5($srcimgfolder), 1, 10) . strtolower($name); switch ($type) { case 1: if (function_exists('imagegif')) { $success = imagegif($thumb, $site_absolutepath . $thumbname . '.gif'); } else { $success = imagejpeg($thumb, $site_absolutepath . $thumbname . '.jpg', $jpg_quality); } break; case 2: $success = imagejpeg($thumb, $site_absolutepath . $thumbname . '.jpg', $jpg_quality); break; case 3: $success = imagepng($thumb, $site_absolutepath . $thumbname . '.png'); } if ($success) { // OUTPUT $result .= preg_replace($template_variables, $real_variables, $html_template); } // remove the image resources from memory imagedestroy($source); imagedestroy($thumb); } } } } closedir($dir); } else { $result = '<li class="message">' . JText::_('JWSP_MSG_ERRFOLDER') . '</li>'; } // Return output return $result; }