Exemple #1
0
function ew_GetFileViewTag(&$fld, $val)
{
    global $Page;
    if (!ew_EmptyStr($val)) {
        if ($fld->UploadMultiple) {
            $wrkfiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $val);
        } else {
            $wrkfiles = array($val);
        }
        $bMultiple = count($wrkfiles) > 1;
        $href = $fld->HrefValue;
        $images = "";
        foreach ($wrkfiles as $wrkfile) {
            if ($fld->FldDataType == EW_DATATYPE_BLOB) {
                $fn = $val;
            } elseif ($Page && ($Page->TableType == "REPORT" && ($Page->Export == "excel" && defined('EW_USE_PHPEXCEL') || $Page->Export == "word" && defined('EW_USE_PHPWORD')) || $Page->TableType != "REPORT" && ($Page->CustomExport == "pdf" || $Page->CustomExport == "email"))) {
                $fn = ew_GetFileTempImage($fld, $wrkfile);
            } else {
                $fn = ew_GetFileUploadUrl($fld, $wrkfile, $fld->ImageResize);
            }
            if ($fld->FldViewTag == "IMAGE" && ($fld->IsBlobImage || ew_IsImageFile($wrkfile))) {
                if ($href == "" && !$fld->UseColorbox) {
                    $image = "<img class=\"ewImage\" src=\"" . $fn . "\"" . $fld->ViewAttributes() . ">";
                    //***
                } else {
                    if ($fld->UploadMultiple && strpos($href, "%u") !== FALSE) {
                        $fld->HrefValue = str_replace("%u", ew_GetFileUploadUrl($fld, $wrkfile), $href);
                    }
                    $image = "<a" . $fld->LinkAttributes() . "><img class=\"ewImage\" src=\"" . $fn . "\"" . $fld->ViewAttributes() . "></a>";
                    //***
                }
            } else {
                if ($fld->FldDataType == EW_DATATYPE_BLOB) {
                    $name = $fld->Upload->FileName != "" ? $fld->Upload->FileName : $fld->FldCaption();
                } else {
                    $name = basename($wrkfile);
                }
                $image = "<a href=\"" . $fn . "\">" . $name . "</a>";
            }
            if ($bMultiple) {
                $images .= "<li>" . $image . "</li>";
            } else {
                $images .= $image;
            }
        }
        if ($bMultiple && $images != "") {
            $images = "<ul class=\"list-inline\">" . $images . "</ul>";
        }
        return $images;
    } else {
        return "";
    }
}
 function RenderRow()
 {
     global $Security, $Language, $gsLanguage;
     // Initialize URLs
     // Call Row_Rendering event
     $this->Row_Rendering();
     // Common render codes for all row types
     // vl_media_id
     // vl_media_type
     // vl_media_name
     // vl_media_file
     // vl_media_file_custom
     if ($this->RowType == EW_ROWTYPE_VIEW) {
         // View row
         // vl_media_id
         $this->vl_media_id->ViewValue = $this->vl_media_id->CurrentValue;
         $this->vl_media_id->ViewCustomAttributes = "";
         // vl_media_type
         if (strval($this->vl_media_type->CurrentValue) != "") {
             $sFilterWrk = "`vl_media_type_id`" . ew_SearchString("=", $this->vl_media_type->CurrentValue, EW_DATATYPE_NUMBER, "");
             $sSqlWrk = "SELECT `vl_media_type_id`, `vl_media_type_name` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `vl_media_type_list`";
             $sWhereWrk = "";
             ew_AddFilter($sWhereWrk, $sFilterWrk);
             $this->Lookup_Selecting($this->vl_media_type, $sWhereWrk);
             // Call Lookup selecting
             if ($sWhereWrk != "") {
                 $sSqlWrk .= " WHERE " . $sWhereWrk;
             }
             $sSqlWrk .= " ORDER BY `vl_media_type_name` ASC";
             $rswrk = Conn()->Execute($sSqlWrk);
             if ($rswrk && !$rswrk->EOF) {
                 // Lookup values found
                 $arwrk = array();
                 $arwrk[1] = $rswrk->fields('DispFld');
                 $this->vl_media_type->ViewValue = $this->vl_media_type->DisplayValue($arwrk);
                 $rswrk->Close();
             } else {
                 $this->vl_media_type->ViewValue = $this->vl_media_type->CurrentValue;
             }
         } else {
             $this->vl_media_type->ViewValue = NULL;
         }
         $this->vl_media_type->ViewCustomAttributes = "";
         // vl_media_name
         $this->vl_media_name->ViewValue = $this->vl_media_name->CurrentValue;
         $this->vl_media_name->ViewCustomAttributes = "";
         // vl_media_file
         if (!ew_Empty($this->vl_media_file->Upload->DbValue)) {
             $this->vl_media_file->ImageWidth = 200;
             $this->vl_media_file->ImageHeight = 200;
             $this->vl_media_file->ImageAlt = $this->vl_media_file->FldAlt();
             $this->vl_media_file->ViewValue = $this->vl_media_file->Upload->DbValue;
         } else {
             $this->vl_media_file->ViewValue = "";
         }
         $this->vl_media_file->ViewCustomAttributes = "";
         // vl_media_file_custom
         $this->vl_media_file_custom->UploadPath = "uploads_custom/";
         if (!ew_Empty($this->vl_media_file_custom->Upload->DbValue)) {
             $this->vl_media_file_custom->ImageWidth = 200;
             $this->vl_media_file_custom->ImageHeight = 200;
             $this->vl_media_file_custom->ImageAlt = $this->vl_media_file_custom->FldAlt();
             $this->vl_media_file_custom->ViewValue = $this->vl_media_file_custom->Upload->DbValue;
         } else {
             $this->vl_media_file_custom->ViewValue = "";
         }
         $this->vl_media_file_custom->ViewCustomAttributes = "";
         // vl_media_id
         $this->vl_media_id->LinkCustomAttributes = "";
         $this->vl_media_id->HrefValue = "";
         $this->vl_media_id->TooltipValue = "";
         // vl_media_type
         $this->vl_media_type->LinkCustomAttributes = "";
         $this->vl_media_type->HrefValue = "";
         $this->vl_media_type->TooltipValue = "";
         // vl_media_name
         $this->vl_media_name->LinkCustomAttributes = "";
         $this->vl_media_name->HrefValue = "";
         $this->vl_media_name->TooltipValue = "";
         // vl_media_file
         $this->vl_media_file->LinkCustomAttributes = "";
         if (!ew_Empty($this->vl_media_file->Upload->DbValue)) {
             $this->vl_media_file->HrefValue = ew_GetFileUploadUrl($this->vl_media_file, $this->vl_media_file->Upload->DbValue);
             // Add prefix/suffix
             $this->vl_media_file->LinkAttrs["target"] = "_blank";
             // Add target
             if ($this->Export != "") {
                 $this->vl_media_file->HrefValue = ew_ConvertFullUrl($this->vl_media_file->HrefValue);
             }
         } else {
             $this->vl_media_file->HrefValue = "";
         }
         $this->vl_media_file->HrefValue2 = $this->vl_media_file->UploadPath . $this->vl_media_file->Upload->DbValue;
         $this->vl_media_file->TooltipValue = "";
         if ($this->vl_media_file->UseColorbox) {
             if (ew_Empty($this->vl_media_file->TooltipValue)) {
                 $this->vl_media_file->LinkAttrs["title"] = $Language->Phrase("ViewImageGallery");
             }
             $this->vl_media_file->LinkAttrs["data-rel"] = "vl_media_list_x_vl_media_file";
             ew_AppendClass($this->vl_media_file->LinkAttrs["class"], "ewLightbox");
         }
         // vl_media_file_custom
         $this->vl_media_file_custom->LinkCustomAttributes = "";
         $this->vl_media_file_custom->UploadPath = "uploads_custom/";
         if (!ew_Empty($this->vl_media_file_custom->Upload->DbValue)) {
             $this->vl_media_file_custom->HrefValue = ew_GetFileUploadUrl($this->vl_media_file_custom, $this->vl_media_file_custom->Upload->DbValue);
             // Add prefix/suffix
             $this->vl_media_file_custom->LinkAttrs["target"] = "_blank";
             // Add target
             if ($this->Export != "") {
                 $this->vl_media_file_custom->HrefValue = ew_ConvertFullUrl($this->vl_media_file_custom->HrefValue);
             }
         } else {
             $this->vl_media_file_custom->HrefValue = "";
         }
         $this->vl_media_file_custom->HrefValue2 = $this->vl_media_file_custom->UploadPath . $this->vl_media_file_custom->Upload->DbValue;
         $this->vl_media_file_custom->TooltipValue = "";
         if ($this->vl_media_file_custom->UseColorbox) {
             if (ew_Empty($this->vl_media_file_custom->TooltipValue)) {
                 $this->vl_media_file_custom->LinkAttrs["title"] = $Language->Phrase("ViewImageGallery");
             }
             $this->vl_media_file_custom->LinkAttrs["data-rel"] = "vl_media_list_x_vl_media_file_custom";
             ew_AppendClass($this->vl_media_file_custom->LinkAttrs["class"], "ewLightbox");
         }
     }
     // Call Row Rendered event
     if ($this->RowType != EW_ROWTYPE_AGGREGATEINIT) {
         $this->Row_Rendered();
     }
 }