Exemplo n.º 1
0
$aPath = array();
if (!empty($mValue)) {
    $aPath = explode($vars["#uploadseparator"], $mValue);
}
$sBasePath = empty($oField->savepath) ? "" : $oField->savepath . "/";
$aPhoto = array();
$c = 1;
foreach ($aPath as $sPath) {
    $sPath = trim($sPath);
    if (!empty($sPath)) {
        try {
            $sPhotoPath = (empty($vars["#savepath"]) ? "" : $vars["#savepath"] . "/") . $sPath;
            //echo "path: " . $sPhotoPath . "<br/>\n";
            $sURL = FlexiFileUtil::getMediaURL($sPhotoPath);
            //echo "thumb: " . $sURL . "<br/>\n";
            $sThumbURL = FlexiFileUtil::getMediaURL($sPhotoPath, null, null, array("maxwidth" => $vars["#maximagewidth"]));
            $aPhoto[$c - 1] = array("photopath" => $sPhotoPath, "thumburl" => $sThumbURL, "url" => $sURL, "error" => 0);
        } catch (Exception $e) {
            $aPhoto[$c - 1] = array("error" => 1, "message" => $e->getMessage());
        }
    } else {
        $aPhoto[$c - 1] = array("error" => 0);
    }
    $c++;
}
//for
echo isset($vars["#prefix"]) ? $vars["#prefix"] : "";
?>
  <div class="fieldUploadDisplay">
  <?php 
echo empty($mValue) ? "(No file uploaded)" : "";
Exemplo n.º 2
0
 /**
  * get value safe for html display
  * @param FlexiTableFieldObject $oField
  * @param array $oRow
  * @return String
  */
 public function getFieldDisplay(FlexiTableFieldObject $oField, $oRow)
 {
     $sName = $oField->getName();
     $mValue = $oRow[$sName];
     $bAllowHTML = $oField->allowhtml;
     switch ($oField->type) {
         case "select-text":
         case "select-tinyint":
         case "select-smallint":
         case "select-bigint":
         case "select-mediumint":
         case "select-enum":
         case "select-int":
             if ($oField->existsOption($mValue)) {
                 $mValue = $oField->getOptionLabel($mValue);
             }
             break;
         case "timestamp-int":
             $sFormat = FlexiDateUtil::getPHPDateTimeFormat(FlexiConfig::$sInputDateTimeFormat);
             if (!empty($mValue) && $mValue > 0) {
                 $mValue = date($sFormat, $mValue);
             } else {
                 $mValue = "";
             }
             break;
         case "datetime":
             $sFormat = FlexiDateUtil::getPHPDateTimeFormat(FlexiConfig::$sInputDateTimeFormat);
             if (!empty($mValue) && $mValue != "0000-00-00" && $mValue != "0000-00-00 00:00:00") {
                 $mValue = date($sFormat, strtotime($mValue));
             } else {
                 $mValue = "";
             }
             break;
         case "date":
             $sFormat = FlexiDateUtil::getPHPDateTimeFormat(FlexiConfig::$sDisplayDateFormat);
             if (!empty($mValue) && $mValue != "0000-00-00" && $mValue != "0000-00-00 00:00:00") {
                 $mValue = date($sFormat, strtotime($mValue));
             } else {
                 $mValue = "";
             }
             break;
         case "file-varchar":
         case "file-text":
             if (!empty($mValue)) {
                 try {
                     $sPath = (empty($oField->savepath) ? "" : $oField->savepath . "/") . $mValue;
                     $sURL = FlexiFileUtil::getMediaURL($sPath);
                     $mValue = "<a href='" . $sURL . "' target='_blank'>Open</a>";
                 } catch (Exception $e) {
                     $mValue = $e->getMessage();
                 }
                 $oField->allowtag = "a";
             }
             $bAllowHTML = true;
             break;
         case "image-varchar":
         case "image-text":
             if (!empty($mValue)) {
                 try {
                     $sPath = (empty($oField->savepath) ? "" : $oField->savepath . "/") . $mValue;
                     //echo "path: " . $sPath;
                     $sURL = FlexiFileUtil::getMediaURL($sPath);
                     $sThumbURL = FlexiFileUtil::getMediaURL($sPath, null, null, array("maxwidth" => $this->iMaxImageWidth));
                     $mValue = "<a href='" . $sURL . "' target='_blank'>" . "<img src='" . $sThumbURL . "'/>" . "</a>";
                 } catch (Exception $e) {
                     $mValue = $e->getMessage();
                 }
                 $oField->allowtag = "a,img";
             }
             $bAllowHTML = true;
             break;
         case "multiimage-text":
             if (!empty($mValue)) {
                 $mValue = "";
                 $aPath = explode($oField->uploadseparator, $oRow[$sName]);
                 $sBasePath = empty($oField->savepath) ? "" : $oField->savepath . "/";
                 foreach ($aPath as $sPath) {
                     $sPath = trim($sPath);
                     try {
                         if (!empty($sPath)) {
                             $sPath = $sBasePath . $sPath;
                             $sURL = FlexiFileUtil::getMediaURL($sPath);
                             $sThumbURL = FlexiFileUtil::getMediaURL($sPath, null, null, array("maxwidth" => $this->iMaxImageWidth));
                             $mValue .= "<a href='" . $sURL . "' target='_blank'>" . "<img src='" . $sThumbURL . "'/>" . "</a>";
                         }
                     } catch (Exception $e) {
                         $mValue .= $e->getMessage();
                     }
                 }
                 //foreach
                 $oField->allowtag = "a,img";
             }
             $bAllowHTML = true;
             break;
         case "email":
             if (!empty($mValue)) {
                 $oField->allowtag = "a";
                 $sURL = "mailto:" . $mValue;
                 $mValue = "<a href='" . $sURL . "'>" . $mValue . "</a>";
             }
             $bAllowHTML = true;
             break;
     }
     //switch type
     if (is_null($mValue)) {
         $mValue = "";
     }
     if ($bAllowHTML) {
         if (!empty($oField->allowtag)) {
             $aSafe = $this->getFieldSafeTags($oField);
             $sTag = implode(",", $aSafe["tag"]);
             $aAttribute = $aSafe["attribute"];
             $mValue = FlexiStringUtil::stripTagsAttributes($mValue, $sTag, $aAttribute);
         }
     } else {
         $mValue = strip_tags($mValue);
     }
     $this->onGetFieldDisplay($oField, $oRow, $mValue);
     return $mValue;
 }
Exemplo n.º 3
0
<?php

$mValue = isset($vars["#value"]) ? $vars["#value"] : (isset($vars["#default_value"]) ? $vars["#default_value"] : null);
$sMaxLen = isset($vars["#maxlength"]) ? " maxlength=\"" . $vars["#maxlength"] . "\"" : "";
$bDisabled = isset($vars["#disabled"]) ? $vars["#disabled"] : false;
$sRequired = isset($vars["#required"]) ? $vars["#required"] ? "<span class=\"required\">*</span>" : "" : "";
if (empty($vars["#maximagewidth"])) {
    throw new Exception("w not set");
}
$sError = "";
try {
    $sPath = (empty($vars["#savepath"]) ? "" : $vars["#savepath"] . "/") . $mValue;
    $sURL = !empty($mValue) ? FlexiFileUtil::getMediaURL($sPath) : "";
    $sThumbURL = !empty($mValue) ? FlexiFileUtil::getMediaURL($sPath, null, null, array("maxwidth" => $vars["#maximagewidth"])) : "";
} catch (Exception $e) {
    $sError = $e->getMessage();
}
echo isset($vars["#prefix"]) ? $vars["#prefix"] : "";
?>
  <div class="fieldUploadDisplay">
  <?php 
echo empty($mValue) ? "(No file uploaded)" : "";
?>
  <? if(!empty($mValue) && empty($sError)) { ?>
  <br/><a href="<?php 
echo $sURL;
?>
" target='_blank'><img src="<?php 
echo $sThumbURL;
?>
" /></a>