public function getValueHighlighted($value, $highlightData)
 {
     $searchWordArr = array();
     foreach ($highlightData['searchWords'] as $searchWord) {
         $curSearchWord = $searchWord;
         $isStringOfNumbers = preg_match('/^[\\d]+$/', $searchWord);
         if (!$isStringOfNumbers) {
             $decimals = $this->container->pSet->isDecimalDigits($this->field);
             $curSearchWord = str_format_number($searchWord, $decimals);
             $quantifier = '{1,' . $decimals . '}';
             if ($decimals <= 1) {
                 $quantifier = '?';
             }
             $curSearchWord = preg_replace('/0' . $quantifier . '$/', '', $searchWord);
             $curSearchWord = preg_replace('/\\.$/', '', $searchWord);
         }
         $searchWordArray = str_split($curSearchWord);
         $curSearchWord = implode('[^\\d]?', $searchWordArray);
         $searchWordArr[] = $curSearchWord;
     }
     $searchWord = implode('|', $searchWordArr);
     $searchOpt = $highlightData['searchOpt'];
     switch ($searchOpt) {
         case 'Equals':
             return $this->addHighlightingSpan($value);
         case 'Starts with':
             return preg_replace('/^(' . $searchWord . ')/', $this->addHighlightingSpan('$1'), $value);
         case 'Contains':
             return preg_replace('/(' . $searchWord . ')/', $this->addHighlightingSpan('$1'), $value);
         default:
             return $value;
     }
 }
 public function showDBValue(&$data, $keylink)
 {
     $value = "";
     $this->upload_handler->tkeys = $keylink;
     $filesArray = $this->getFilesArray($data[$this->field]);
     $showThumbnails = $this->container->pSet->showThumbnail($this->field);
     $isExport = $this->container->pageType == PAGE_EXPORT || $this->container->forExport != '';
     if ($showThumbnails) {
         $zoomboxRand = rand(11111, 99999);
     }
     foreach ($filesArray as $file) {
         $userFile = $this->upload_handler->buildUserFile($file);
         if (!$isExport) {
             $value .= $value != "" ? "</br>" : "";
             if ($showThumbnails && $userFile["thumbnail_url"] != "" && CheckImageExtension($file["name"])) {
                 $value .= "<a target=_blank href=\"" . runner_htmlspecialchars($userFile["url"]) . "\" class='zoombox zgallery" . $zoomboxRand . "'><img  border='0'";
                 if ($this->is508) {
                     $value .= " alt=\"" . runner_htmlspecialchars($userFile["name"]) . "\"";
                 }
                 $value .= " src=\"" . runner_htmlspecialchars(GetRootPathForResources($userFile["thumbnail_url"])) . "\" /></a>";
             } else {
                 if ($this->container->pSet->showIcon($this->field)) {
                     $value .= '<a href="' . runner_htmlspecialchars($userFile["url"]) . '"><img style="vertical-align: middle;" src="' . GetRootPathForResources('images/icons/' . $this->getFileIconByType($file["name"], $file["type"])) . '" /></a>';
                 }
             }
         }
         if ($this->container->pSet->showCustomExpr($this->field)) {
             $value .= fileCustomExpression($file, $data, $this->field, $this->container->pageType);
         } else {
             if ($isExport) {
                 $value .= ($value != "" ? ", " : "") . $file["usrName"];
             } else {
                 if ($showThumbnails && $userFile["thumbnail_url"] != "" && CheckImageExtension($file["name"]) && $value != "") {
                     $value .= "<br />";
                 }
                 $label = runner_htmlspecialchars($file["usrName"] != "" ? $file["usrName"] : $file["name"]);
                 if ($this->searchHighlight) {
                     $label = $this->highlightSearchWord($label, true, "");
                 }
                 $value .= '<a dir="LTR" href="' . runner_htmlspecialchars($userFile["url"]) . '">' . $label . '</a>';
             }
         }
         if ($this->container->pSet->showFileSize($this->field)) {
             $fileSizeAndUnit = $this->getFileSizeAndUnits($file["size"]);
             $value .= " " . str_format_number(round($fileSizeAndUnit["size"], 2)) . " " . $this->sizeUnits[$fileSizeAndUnit["unitIndex"]];
         }
     }
     return $value;
 }
function format_number($val, $valDigits = false)
{
    return str_format_number($val, $valDigits);
}
Exemple #4
0
function GetTotals($field, $value, $stype, $iNumberOfRows, $sFormat, $ptype)
{
    global $strTableName;
    $pSet = new ProjectSettings($strTableName, $ptype);
    $days = 0;
    if ($stype == "AVERAGE") {
        if ($iNumberOfRows) {
            if ($sFormat == FORMAT_TIME) {
                if ($value) {
                    $value = round($value / $iNumberOfRows, 0);
                    $s = $value % 60;
                    $value -= $s;
                    $value /= 60;
                    $m = $value % 60;
                    $value -= $m;
                    $value /= 60;
                    $h = $value % 24;
                    $value -= $h;
                    $value /= 24;
                    $d = $value;
                    $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s));
                }
            } else {
                $value = round($value / $iNumberOfRows, 2);
            }
        } else {
            return "";
        }
    }
    if ($stype == "TOTAL") {
        if ($sFormat == FORMAT_TIME) {
            if ($value) {
                $s = $value % 60;
                $value -= $s;
                $value /= 60;
                $m = $value % 60;
                $value -= $m;
                $value /= 60;
                $h = $value % 24;
                $value -= $h;
                $value /= 24;
                $d = $value;
                $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s));
            }
        }
    }
    $sValue = "";
    $data = array($field => $value);
    if ($sFormat == FORMAT_CURRENCY) {
        $sValue = str_format_currency($value);
    } else {
        if ($sFormat == FORMAT_PERCENT) {
            $sValue = str_format_number($value * 100) . "%";
        } else {
            if ($sFormat == FORMAT_NUMBER) {
                $sValue = str_format_number($value, $pSet->isDecimalDigits($field));
            } else {
                if ($sFormat == FORMAT_CUSTOM && $stype != "COUNT") {
                    include_once getabspath('classes/controls/ViewControlsContainer.php');
                    $viewControls = new ViewControlsContainer($pSet, $ptype);
                    $sValue = $viewControls->showDBValue($field, $data);
                } else {
                    $sValue = $value;
                }
            }
        }
    }
    if ($stype == "COUNT") {
        return $value;
    }
    if ($stype == "TOTAL") {
        return $sValue;
    }
    if ($stype == "AVERAGE") {
        return $sValue;
    }
    return "";
}
function GetTotals($field, $value, $stype, $iNumberOfRows, $sFormat)
{
    global $strTableName;
    $days = 0;
    if ($stype == "AVERAGE") {
        if ($iNumberOfRows) {
            if ($sFormat == FORMAT_TIME) {
                if ($value) {
                    $value = round($value / $iNumberOfRows, 0);
                    $s = $value % 60;
                    $value -= $s;
                    $value /= 60;
                    $m = $value % 60;
                    $value -= $m;
                    $value /= 60;
                    $h = $value % 24;
                    $value -= $h;
                    $value /= 24;
                    $d = $value;
                    $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s));
                }
            } else {
                $value = round($value / $iNumberOfRows, 2);
            }
        } else {
            return "";
        }
    }
    if ($stype == "TOTAL") {
        if ($sFormat == FORMAT_TIME) {
            if ($value) {
                $s = $value % 60;
                $value -= $s;
                $value /= 60;
                $m = $value % 60;
                $value -= $m;
                $value /= 60;
                $h = $value % 24;
                $value -= $h;
                $value /= 24;
                $d = $value;
                $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s));
            }
        }
    }
    $sValue = "";
    $data = array($field => $value);
    if ($sFormat == FORMAT_CURRENCY) {
        $sValue = str_format_currency($value);
    } else {
        if ($sFormat == FORMAT_PERCENT) {
            $sValue = str_format_number($value * 100) . "%";
        } else {
            if ($sFormat == FORMAT_NUMBER) {
                $sValue = str_format_number($value, GetFieldData($strTableName, $field, "DecimalDigits", false));
            } else {
                if ($sFormat == FORMAT_CUSTOM && $stype != "COUNT") {
                    $sValue = GetData($data, $field, $sFormat);
                } else {
                    $sValue = $value;
                }
            }
        }
    }
    if ($stype == "COUNT") {
        return $value;
    }
    if ($stype == "TOTAL") {
        return $sValue;
    }
    if ($stype == "AVERAGE") {
        return $sValue;
    }
    return "";
}
Exemple #6
0
 function suggestValue($value, $searchFor, &$response, &$row)
 {
     $viewFormat = $this->pageObject->pSetEdit->getViewFormat($this->field);
     if ($viewFormat == FORMAT_NUMBER) {
         $value = str_format_number($value, $this->pageObject->pSetEdit->isDecimalDigits($this->field));
         $dotPosition = strpos($value, '.');
         if ($dotPosition !== FALSE) {
             for ($i = strlen($value) - 1; $i > $dotPosition; $i--) {
                 if (substr($value, $i, 1) != '0') {
                     if ($i < strlen($value) - 1) {
                         $value = substr($value, 0, $i + 1);
                     }
                     break;
                 } else {
                     if ($i == $dotPosition + 1 && $dotPosition > 0) {
                         $value = substr($value, 0, $dotPosition);
                         break;
                     }
                 }
             }
         }
     }
     $searchStringSize = GetGlobalData("suggestStringSize", 40);
     if ($searchStringSize <= strlen($searchFor)) {
         $response[$searchFor . ""] = $searchFor . "";
     } else {
         $realValue = $value;
         if ($searchStringSize < strlen($value)) {
             $diff = $searchStringSize - strlen($searchFor);
             $lDiff = floor($diff / 2);
             $rDiff = $diff - $lDiff;
             if ($this->pageObject->pSetEdit->getNCSearch()) {
                 $startPos = stripos($value, $searchFor);
             } else {
                 $startPos = strpos($value, $searchFor);
             }
             $searchStartPos = $startPos;
             $valueLength = strlen($value);
             if ($startPos - $lDiff < 0) {
                 $rDiff -= $startPos - $lDiff;
                 $startPos = 0;
             } else {
                 $startPos -= $lDiff;
             }
             if ($startPos > 0) {
                 $found = false;
                 for ($i = $startPos - 1; $i >= $startPos - 5 && $i >= 0; $i--) {
                     if ($i == 0 || $this->isStopSimbol(substr($value, $i, 1))) {
                         if ($i == 0) {
                             $startPos = 0;
                         } else {
                             $startPos = $i + 1;
                         }
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     for ($i = $startPos; $i <= $startPos + 5 && $i < $searchStartPos; $i++) {
                         if ($this->isStopSimbol(substr($value, $i, 1))) {
                             $startPos = $i + 1;
                             break;
                         }
                     }
                 }
                 $brakePos = strrpos($value, "\n", $searchStartPos - $valueLength);
                 if ($brakePos !== FALSE && $brakePos > $startPos) {
                     $startPos = $brakePos + 1;
                 }
                 $brakePos = strrpos($value, "\r", $searchStartPos - $valueLength);
                 if ($brakePos !== FALSE && $brakePos > $startPos) {
                     $startPos = $brakePos + 1;
                 }
             }
             if ($startPos + $searchStringSize > $valueLength) {
                 $searchStringSize = $valueLength - $startPos;
             }
             if ($startPos + $searchStringSize < $valueLength) {
                 $found = false;
                 $tempStartPos = $startPos + $searchStringSize;
                 for ($i = $tempStartPos + 1; $i <= $tempStartPos + 5 && $i < $valueLength; $i++) {
                     if ($i == $valueLength - 1 || $this->isStopSimbol(substr($value, $i, 1))) {
                         if ($i == $valueLength - 1) {
                             $searchStringSize = $i - $startPos + 1;
                         } else {
                             $searchStringSize = $i - $startPos;
                         }
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     for ($i = $tempStartPos; $i >= $tempStartPos - 5; $i--) {
                         if ($this->isStopSimbol(substr($value, $i, 1))) {
                             $searchStringSize = $i - $startPos;
                             break;
                         }
                     }
                 }
                 $brakePos = strpos($value, "\n", $searchStartPos + strlen($searchFor));
                 if ($brakePos !== FALSE && $brakePos < $startPos + $searchStringSize) {
                     $searchStringSize = $brakePos - $startPos - 1;
                 }
                 $brakePos = strpos($value, "\r", $searchStartPos + strlen($searchFor));
                 if ($brakePos !== FALSE && $brakePos < $startPos + $searchStringSize) {
                     $searchStringSize = $brakePos - $startPos - 1;
                 }
             }
             $value = substr($value, $startPos, $searchStringSize);
             $realValue = $value;
             if ($startPos > 0) {
                 $value = "..." . $value;
             }
             if ($startPos + $substrLength != $valueLength) {
                 $value .= "...";
             }
         }
         $response[$value . ""] = $realValue . "";
     }
 }
Exemple #7
0
 public function showDBValue(&$data, $keylink)
 {
     return str_format_number($data[$this->field], $this->container->pSet->isDecimalDigits($this->field));
 }
 function writeGlobalSummary($source)
 {
     $result = array();
     if (!$this->repGlobalSummary) {
         return $result;
     }
     if (is_array($source["summary"])) {
         for ($i = 0; $i < count($this->fieldsArr); $i++) {
             $field =& $this->fieldsArr[$i];
             $fieldName = $field['name'];
             $fGoodName = $field['goodName'];
             if (is_array($source["summary"][$fieldName])) {
                 if ($field['totalMax']) {
                     $result["global_total" . $fGoodName . "_max"] = getFormattedValue($this->pageObject, $source['summary'][$fieldName]['MAX'], $fieldName, $field['viewFormat'], $field['editFormat'], $this->mode);
                 }
                 if ($field['totalMin']) {
                     $result["global_total" . $fGoodName . "_min"] = getFormattedValue($this->pageObject, $source['summary'][$fieldName]['MIN'], $fieldName, $field['viewFormat'], $field['editFormat'], $this->mode);
                 }
                 if ($field['totalAvg']) {
                     $result["global_total" . $fGoodName . "_avg"] = getFormattedValue($this->pageObject, $source['summary'][$fieldName]['AVG'], $fieldName, $field['viewFormat'], $field['editFormat'], $this->mode);
                 }
                 if ($field['totalSum']) {
                     $result["global_total" . $fGoodName . "_sum"] = getFormattedValue($this->pageObject, $source['summary'][$fieldName]['SUM'], $fieldName, $field['viewFormat'], $field['editFormat'], $this->mode);
                 }
             }
         }
     }
     $result["global_total_cnt"] = str_format_number($source['count'], 0);
     return $result;
 }