public function showDBValue($value, $keyLink) { $imageValue = ""; $this->initUploadHandler(); $this->upload_handler->tkeys = $keyLink; $filesArray = my_json_decode($value); if (!is_array($filesArray) || count($filesArray) == 0) { if ($value == "") { $filesArray = array(); } else { $uploadedFile = $this->upload_handler->get_file_object($value); if (is_null($uploadedFile)) { $filesArray = array(); } else { $filesArray = array($uploadedFile); } } } foreach ($filesArray as $imageFile) { $userFile = $this->upload_handler->buildUserFile($imageFile); if ($this->pageObject->pSet->getViewFormat($this->field) == FORMAT_FILE) { $imageValue .= $imageValue != "" ? "</br>" : ""; $imageValue .= '<a href="' . htmlspecialchars($userFile["url"]) . '">' . htmlspecialchars($imageFile["usrName"] != "" ? $imageFile["usrName"] : $imageFile["name"]) . '</a>'; } else { if (CheckImageExtension($imageFile["name"])) { $imageValue .= $imageValue != "" ? "</br>" : ""; if ($this->pageObject->pSet->showThumbnail($this->field)) { $thumbname = $userFile["thumbnail_url"]; $imageValue .= "<a target=_blank"; $imageValue .= " href=\"" . htmlspecialchars($userFile["url"]) . "\" class='zoombox'>"; $imageValue .= "<img"; if ($thumbname == "" || $imageFile["name"] == $imageFile["thumbnail"]) { $imgWidth = $this->pageObject->pSet->getImageWidth($this->field); $imageValue .= $imgWidth ? " width=" . $imgWidth : ""; $imgHeight = $this->pageObject->pSet->getImageHeight($this->field); $imageValue .= $imgHeight ? " height=" . $imgHeight : ""; } $imageValue .= " border=0"; if ($this->is508) { $imageValue .= " alt=\"" . htmlspecialchars($userFile["name"]) . "\""; } $imageValue .= " src=\"" . htmlspecialchars($userFile["thumbnail_url"]) . "\"></a>"; } else { $imageValue .= "<img"; $imgWidth = $this->pageObject->pSet->getImageWidth($this->field); $imageValue .= $imgWidth ? " width=" . $imgWidth : ""; $imgHeight = $this->pageObject->pSet->getImageHeight($this->field); $imageValue .= $imgHeight ? " height=" . $imgHeight : ""; $imageValue .= " border=0"; if ($this->is508) { $imageValue .= " alt=\"" . htmlspecialchars($userFile["name"]) . "\""; } $imageValue .= " src=\"" . htmlspecialchars($userFile["url"]) . "\">"; } } } } return $imageValue; }
function getFilesArray($value) { $filesArray = my_json_decode($value); if (!is_array($filesArray) || count($filesArray) == 0) { if ($value == "") { $filesArray = array(); } else { $uploadedFile = $this->upload_handler->get_file_object($value); if (is_null($uploadedFile)) { $filesArray = array(); } else { $filesArray = array(my_json_decode(my_json_encode($uploadedFile))); } } } return $filesArray; }
/** * buildFieldLabels * Draw arrows near field label if field engaged in sorting and build sorting links */ function buildFieldLabels() { for ($i = 0; $i < count($this->fieldsList); $i++) { $order_field = $this->listObject->pSet->GetFieldByIndex($this->fieldsList[$i]->fieldIndex); $orderFieldName = GoodFieldName($order_field); $order_dir = $this->fieldsList[$i]->orderDirection == "ASC" ? "a" : "d"; if ($this->fieldsList[$i]->userDefined) { $this->listObject->xt->assign_section($orderFieldName . "_fieldheader", "", "<span data-icon=\"" . ($order_dir == "a" ? "sortasc" : "sortdesc") . "\"></span>"); } // default ASC for key fields $orderlinkattrs = $this->listObject->setLinksAttr($orderFieldName, $order_dir, $this->fieldsList[$i]->userDefined); $this->listObject->xt->assign($orderFieldName . "_orderlinkattrs", $orderlinkattrs); } }
/** * buildFieldLabels * Draw arrows near field label if field engaged in sorting and build sorting links */ function buildFieldLabels() { for ($i = 0; $i < count($this->fieldsList); $i++) { $order_field = $this->listObject->pSet->GetFieldByIndex($this->fieldsList[$i]->fieldIndex); $order_dir = $this->fieldsList[$i]->orderDirection == "ASC" ? "a" : "d"; if ($this->fieldsList[$i]->userDefined) { $this->listObject->xt->assign_section(GoodFieldName($order_field) . "_fieldheader", "", "<img " . ($this->listObject->is508 ? "alt=\" \" " : "") . "src=\"images/" . ($order_dir == "a" ? "up" : "down") . ".gif\" border=0>"); } // default ASC for key fields if (!$this->fieldsList[$i]->userDefined) { $orderlinkattrs = $this->listObject->setLinksAttr(GoodFieldName($order_field)); } else { $orderlinkattrs = $this->listObject->setLinksAttr(GoodFieldName($order_field), $order_dir); } $this->listObject->xt->assign(GoodFieldName($order_field) . "_orderlinkattrs", $orderlinkattrs); } }
/** * @param String fieldValue * @return String */ function getFieldValueCopy($fieldValue) { $this->initUploadHandler(); $uploadFolder = $this->pageObject->pSetEdit->getUploadFolder($this->field); $absoluteUploadDirPath = $this->pageObject->pSetEdit->getFinalUploadFolder($this->field); $filesData = my_json_decode($fieldValue); if (!is_array($filesData) || count($filesData) == 0) { return $fieldValue; } foreach ($filesData as $idx => $fileData) { $info = $this->upload_handler->pathinfo_local($fileData["usrName"]); $newFieldName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $info['filename'], $info['extension']); runner_copy_file(getabspath($fileData["name"]), $absoluteUploadDirPath . $newFieldName); $filesData[$idx]["name"] = $uploadFolder . $newFieldName; if ($this->pageObject->pSetEdit->getCreateThumbnail($this->field)) { $thumbnailPrefix = $this->pageObject->pSetEdit->getStrThumbnail($this->field); $newThumbName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $thumbnailPrefix . $info['filename'], $info['extension']); runner_copy_file(getabspath($fileData["thumbnail"]), $absoluteUploadDirPath . $newThumbName); $filesData[$idx]["thumbnail"] = $uploadFolder . $newThumbName; } } return my_json_encode($filesData); }
public function handle_file_upload($uploadedFile, $index) { $tmpName = $uploadedFile["tmp_name"]; $name = $uploadedFile["name"]; $size = $uploadedFile["size"]; $type = $uploadedFile["type"]; $error = $uploadedFile["error"]; $fileInfo = array("name" => $name, "size" => intval($size), "type" => $type, "isThumbnail" => false); $uploadDir = $this->pSet->getFinalUploadFolder($this->field, $fileInfo); $uploadDirRelative = $this->pSet->getUploadFolder($this->field, $fileInfo); $file = array(); $file["error"] = false; $file["name"] = trim_file_name($name, $type, $index, $this); $file["usrName"] = $file["name"]; $file["size"] = intval($size); switch ($type) { case "image/png": case "image/x-png": $file["type"] = "image/png"; break; case "image/jpeg": case "image/pjpeg": $file["type"] = "image/jpeg"; break; default: $file["type"] = $type; } $path_parts = $this->pathinfo_local($name); if ($file["type"] == "") { $file["type"] = getContentTypeByExtension($path_parts["extension"]); } $file["isImg"] = false; $file["thumbnail"] = ""; if ($this->pSet->isMakeDirectoryNeeded($this->field)) { if (!makeSurePathExists($uploadDir)) { $file["error"] = "Upload folder doesn't exist"; return $file; } } else { if (!is_dir($uploadDir)) { $file["error"] = "Upload folder doesn't exist"; return $file; } } if ($this->validate($uploadedFile, $file, $error, $size, $index, $uploadDir)) { $file["isImg"] = CheckImageExtension($tmpName) != false; $this->handle_form_data($file, $index); $file["name"] = $this->tempnam_sfx($uploadDir, $path_parts["filename"], $path_parts["extension"]); $file_path = $uploadDir . $file["name"]; clearstatcache(); upload_File($uploadedFile, $file_path); $file_size = filesize($file_path); if ($this->options["resizeOnUpload"]) { $tempOptions = array('max_width' => $this->options["max_width"], 'max_height' => $this->options["max_width"]); $new_file_name = $this->tempnam_sfx($uploadDir, $path_parts["filename"], $path_parts["extension"]); if ($this->create_scaled_image($uploadDir . $file["name"], $uploadDir, $new_file_name, $tempOptions, $file, false, $uploadDirRelative, $uploadedFile)) { unlink($file_path); $file["name"] = $new_file_name; $file_path = $uploadDir . $new_file_name; $file_size = filesize($file_path); } } if ($file_size === $file["size"]) { $file["url"] = $uploadDir . rawurlencode($file["name"]); foreach ($this->options['image_versions'] as $version => $options) { $fileInfoThimbnail = array("name" => $name, "size" => intval($size), "type" => $type, "isThumbnail" => true); $thumbUploadDir = $this->pSet->getFinalUploadFolder($this->field, $fileInfoThimbnail); $thumbUploadDirRelative = $this->pSet->getUploadFolder($this->field, $fileInfoThimbnail); if ($this->pSet->isMakeDirectoryNeeded($this->field)) { if (!makeSurePathExists($thumbUploadDir)) { continue; } } $thumbnail_name = $this->tempnam_sfx($thumbUploadDir, $options['thumbnailPrefix'] . $path_parts["filename"], $path_parts["extension"]); if ($this->create_scaled_image($uploadDir . $file["name"], $thumbUploadDir, $thumbnail_name, $options, $file, true, $thumbUploadDirRelative, $uploadedFile)) { clearstatcache(); $file_size = filesize($file_path); } } } else { unlink($file_path); $file["error"] = 'abort'; } $file["size"] = $file_size; $file["name"] = $uploadDirRelative . $file["name"]; $this->set_file_delete_url($file); } return $file; }
/** * Pagina de resultados de la jornada ordenados por grado/categoría/puesto * @param {array} $jornada datos de la jornada * @param {object} $insc objeto de tipo Inscripcion con las inscripciones de la prueba */ function createJornadaDataPage($jornada, $insc) { // create Excel sheet $jdatapage = $this->myWriter->addNewSheetAndMakeItCurrent(); $name = $this->normalizeSheetName("Data " . $jornada['Nombre']); $jdatapage->setName($name); // write table header $this->writeTableHeader(); $rondas = Jornadas::enumerateRondasByJornada($jornada['ID'])['rows']; // obtenemos los datos "personales" de los perros de la jornada $lista = $insc->inscritosByJornada($jornada['ID'], false)['rows']; $eq = new Equipos("excel_printInscripciones", $this->prueba['ID'], $jornada['ID']); $inscritos = array(); foreach ($lista as $perro) { // add team information $perro['Equipo'] = $eq->getTeamByPerro($perro['Perro'])['Nombre']; // reindexamos las inscripciones por el PerroID $inscritos[$perro['Perro']] = $perro; } // obtenemos todas las clasificaciones de la jornada $clas = new Clasificaciones("excel_Clasificaciones", $this->prueba['ID'], $jornada['ID']); $results = array(); foreach ($rondas as $ronda) { $mangas = array($ronda['Manga1'], $ronda['Manga2']); $clasifRonda = $clas->clasificacionFinal($ronda['Rondas'], $mangas, $ronda['Mode']); $results = array_merge($results, $clasifRonda['rows']); } // OK ya tenemos los datos de toda la jornada; ahora a ordenar por grado,categoría y puesto usort($results, function ($a, $b) { $res = strcmp($a['Grado'], $b['Grado']); if ($res != 0) { return $res; } $res = strcmp($a['Categoria'], $b['Categoria']); if ($res != 0) { return $res; } return $a['Puesto'] > $b['Puesto'] ? 1 : -1; }); // componemos la fila Excel anyiadiendo datos personales // // 'Dorsal', // 'Nombre','NombreLargo','Genero','Raza','Licencia','LOE_RRC','Categoria','Grado','NombreGuia','NombreClub','Pais', // datos del perro // 'Equipo','Celo','Observaciones', // datos de la inscripcion en la jornada // 'F1','R1','E1','N1','Tiempo1','Penal1', // datos de la manga 1 // 'F2','R2','E2','N2','Tiempo2','Penal2', // datos de la manga 2 // // TODO: handle series with more than 2 rounds // 'Tiempo','Penalizacion','Calificacion' foreach ($results as $perro) { $row = array(); // si el perro no esta en la lista de inscritos, marca error e ignora entrada if (!array_key_exists($perro['Perro'], $inscritos)) { $this->myLogger->error("Encontrada Clasificacion para perro no inscrito:" . $perro['Perro']); continue; } $pdata =& $inscritos[$perro['Perro']]; $pdata['Done'] = 1; // mark perro inscrito _and_ with clasification // datos personales $row[] = $perro['Dorsal']; $row[] = $pdata['Nombre']; $row[] = $pdata['NombreLargo']; $row[] = $pdata['Genero']; $row[] = $pdata['Raza']; $row[] = $pdata['Licencia']; $row[] = $pdata['LOE_RRC']; $row[] = $pdata['Categoria']; $row[] = $pdata['Grado']; $row[] = $pdata['NombreGuia']; $row[] = $pdata['NombreClub']; $row[] = $pdata['Pais']; // Datos de la inscripcion $row[] = $pdata['Equipo']; $row[] = $pdata['Celo']; $row[] = $pdata['Observaciones']; // resultados manga 1 $row[] = $perro['F1']; // Manga 1: faltas + tocados $row[] = $perro['R1']; // Manga 1: rehuses $row[] = $perro['E1']; // Manga 1: eliminado $row[] = $perro['N1']; // manga 1: no presentado $row[] = $perro['T1']; // manga 1: tiempo $row[] = $perro['P1']; // manga 1: penalizacion // resultados manga 2 $row[] = $perro['F2']; // Manga 2: faltas + tocados $row[] = $perro['R2']; // Manga 2: rehuses $row[] = $perro['E2']; // Manga 2: eliminado $row[] = $perro['N2']; // manga 2: no presentado $row[] = $perro['T2']; // manga 2: tiempo $row[] = $perro['P2']; // manga 2: penalizacion // datos globales de clasificacion $row[] = $perro['Tiempo']; $row[] = $perro['Penalizacion']; $row[] = $perro['Calificacion']; // !!finaly!! add perro to excel table $this->myWriter->addRow($row); } // por ultimo metemos las inscripciones que no tienen resultado asociado foreach ($inscritos as $pdata) { if (array_key_exists('Done', $pdata)) { continue; } // already done $row = array(); // datos personales $row[] = $pdata['Dorsal']; $row[] = $pdata['Nombre']; $row[] = $pdata['NombreLargo']; $row[] = $pdata['Genero']; $row[] = $pdata['Raza']; $row[] = $pdata['Licencia']; $row[] = $pdata['LOE_RRC']; $row[] = $pdata['Categoria']; $row[] = $pdata['Grado']; $row[] = $pdata['NombreGuia']; $row[] = $pdata['NombreClub']; $row[] = $pdata['Pais']; // add perro without results to excel table $this->myWriter->addRow($row); } }
function setForExportVar($forExport) { $this->viewControls->setForExportVar($forExport); }
/** * Executes the child query and ties the result to the output of the parent query * * @param {array} $parentRows Query output of the parent query * @param {object} $child */ private function bindChild(&$parentRows, &$child) { $generalErrorMessage = "Cannot nest queries " . $this->name() . " and " . $child->name() . " - "; // This error should never occur, since the parser constructs the two childs automatically if (!$child->children || count($child->children) != 2) { throw new \Exception($generalErrorMessage . "child does not have 2 children"); } $paramID = $child->defaultParam; // Fall back in case there is no default param (should not occur anymore) if (!$paramID) { // Get parameters of second (last) child of $child. // Suppose you have "a(b)". This corresponds to parent = "a" and child = "b:a" // "b:a" has two childs: "b" and "b.a" // We should get the param of the link-query "b.a" which is the second child of $child $paramIDs = array_keys(get_object_vars($child->children[1]->params)); // There should be exactly 1 parameter if (count($paramIDs) != 1) { throw new \Exception($generalErrorMessage . "link-query " . $child->children[1]->name() . " should have exactly one parameter"); } $paramID = $paramIDs[0]; } // Get the parent key which should be matched with the childs parameter $keyIDs = array_keys(get_object_vars($this->keys)); if (count($keyIDs) != 1) { throw new \Exception($generalErrorMessage . "parent should have exactly one key"); } $parentKey = $this->keys->{$keyIDs[0]}; if (!is_array($parentRows)) { throw new \Exception($generalErrorMessage . "parentRows should be an array of associative arrays"); } if (count($parentRows) > 0 && !is_array($parentRows[0])) { throw new \Exception($generalErrorMessage . "parentRows should be an array of associative arrays"); } if (count($parentRows) > 0 && !array_key_exists($parentKey, $parentRows[0])) { throw new \Exception($generalErrorMessage . "parentRows should consist of associative arrays containing the field '" . $parentKey . "'"); } // Take root parameters as default params for child $params = $this->paramValues; // Select the child param values from the parent query output $values = array(); foreach ($parentRows as $row) { if (!in_array($row[$parentKey], $values)) { $values[] = $row[$parentKey]; } } $params[$paramID] = $values; // Execute child query and group results; cleanUp can also be done at this point $childRows = $child->group()->select($params, $paramID, true); $childFieldName = $child->prefix(); // Combine child rows with parent rows for ($i = 0; $i < count($parentRows); $i++) { $keyValue = $parentRows[$i][$parentKey]; $parentRows[$i][$childFieldName] = array_key_exists($keyValue, $childRows) ? $childRows[$keyValue] : array(); } }