From f1ab2f022fdc780aca0944d90e9a0e844a0820d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:12:17 +0200 Subject: =?UTF-8?q?2024-02-19:=20popravljen=20(prej=C5=A1nji=20commit=20je?= =?UTF-8?q?=20napa=C4=8Den)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/PHPExcel/Cell/AdvancedValueBinder.php | 190 --------- admin/survey/excel/PHPExcel/Cell/DataType.php | 114 ----- .../survey/excel/PHPExcel/Cell/DataValidation.php | 474 --------------------- .../excel/PHPExcel/Cell/DefaultValueBinder.php | 106 ----- admin/survey/excel/PHPExcel/Cell/Hyperlink.php | 127 ------ admin/survey/excel/PHPExcel/Cell/IValueBinder.php | 46 -- 6 files changed, 1057 deletions(-) delete mode 100644 admin/survey/excel/PHPExcel/Cell/AdvancedValueBinder.php delete mode 100644 admin/survey/excel/PHPExcel/Cell/DataType.php delete mode 100644 admin/survey/excel/PHPExcel/Cell/DataValidation.php delete mode 100644 admin/survey/excel/PHPExcel/Cell/DefaultValueBinder.php delete mode 100644 admin/survey/excel/PHPExcel/Cell/Hyperlink.php delete mode 100644 admin/survey/excel/PHPExcel/Cell/IValueBinder.php (limited to 'admin/survey/excel/PHPExcel/Cell') diff --git a/admin/survey/excel/PHPExcel/Cell/AdvancedValueBinder.php b/admin/survey/excel/PHPExcel/Cell/AdvancedValueBinder.php deleted file mode 100644 index 021d0a7..0000000 --- a/admin/survey/excel/PHPExcel/Cell/AdvancedValueBinder.php +++ /dev/null @@ -1,190 +0,0 @@ -setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); - return true; - } elseif($value == PHPExcel_Calculation::getFALSE()) { - $cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); - return true; - } - - // Check for number in scientific format - if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - return true; - } - - // Check for fraction - if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { - // Convert value to number - $value = $matches[2] / $matches[3]; - if ($matches[1] == '-') $value = 0 - $value; - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '??/??' ); - return true; - } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { - // Convert value to number - $value = $matches[2] + ($matches[3] / $matches[4]); - if ($matches[1] == '-') $value = 0 - $value; - $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '# ??/??' ); - return true; - } - - // Check for percentage - if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { - // Convert value to number - $value = (float) str_replace('%', '', $value) / 100; - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); - return true; - } - - // Check for currency - $currencyCode = PHPExcel_Shared_String::getCurrencyCode(); - if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { - // Convert value to number - $value = (float) trim(str_replace(array($currencyCode,','), '', $value)); - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( - str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) - ); - return true; - } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { - // Convert value to number - $value = (float) trim(str_replace(array('$',','), '', $value)); - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); - return true; - } - - // Check for time without seconds e.g. '9:45', '09:45' - if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) { - // Convert value to number - list($h, $m) = explode(':', $value); - $days = $h / 24 + $m / 1440; - $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); - return true; - } - - // Check for time with seconds '9:45:59', '09:45:59' - if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) { - // Convert value to number - list($h, $m, $s) = explode(':', $value); - $days = $h / 24 + $m / 1440 + $s / 86400; - // Convert value to number - $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); - return true; - } - - // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' - if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) { - // Convert value to number - $cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC); - // Determine style. Either there is a time part or not. Look for ':' - if (strpos($value, ':') !== false) { - $formatCode = 'yyyy-mm-dd h:mm'; - } else { - $formatCode = 'yyyy-mm-dd'; - } - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode($formatCode); - return true; - } - - // Check for newline character "\n" - if (strpos($value, "\n") !== FALSE) { - $value = PHPExcel_Shared_String::SanitizeUTF8($value); - $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); - // Set style - $cell->getParent()->getStyle( $cell->getCoordinate() ) - ->getAlignment()->setWrapText(TRUE); - return true; - } - } - - // Not bound yet? Use parent... - return parent::bindValue($cell, $value); - } -} diff --git a/admin/survey/excel/PHPExcel/Cell/DataType.php b/admin/survey/excel/PHPExcel/Cell/DataType.php deleted file mode 100644 index 5466851..0000000 --- a/admin/survey/excel/PHPExcel/Cell/DataType.php +++ /dev/null @@ -1,114 +0,0 @@ - 0, '#DIV/0!' => 1, '#VALUE!' => 2, '#REF!' => 3, '#NAME?' => 4, '#NUM!' => 5, '#N/A' => 6); - - /** - * Get list of error codes - * - * @return array - */ - public static function getErrorCodes() { - return self::$_errorCodes; - } - - /** - * DataType for value - * - * @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure - * @param mixed $pValue - * @return int - */ - public static function dataTypeForValue($pValue = null) { - return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); - } - - /** - * Check a string that it satisfies Excel requirements - * - * @param mixed Value to sanitize to an Excel string - * @return mixed Sanitized value - */ - public static function checkString($pValue = null) - { - if ($pValue instanceof PHPExcel_RichText) { - // TODO: Sanitize Rich-Text string (max. character count is 32,767) - return $pValue; - } - - // string must never be longer than 32,767 characters, truncate if necessary - $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767); - - // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" - $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); - - return $pValue; - } - - /** - * Check a value that it is a valid error code - * - * @param mixed Value to sanitize to an Excel error code - * @return string Sanitized value - */ - public static function checkErrorCode($pValue = null) - { - $pValue = (string)$pValue; - - if ( !array_key_exists($pValue, self::$_errorCodes) ) { - $pValue = '#NULL!'; - } - - return $pValue; - } - -} diff --git a/admin/survey/excel/PHPExcel/Cell/DataValidation.php b/admin/survey/excel/PHPExcel/Cell/DataValidation.php deleted file mode 100644 index 603a8b7..0000000 --- a/admin/survey/excel/PHPExcel/Cell/DataValidation.php +++ /dev/null @@ -1,474 +0,0 @@ -_formula1 = ''; - $this->_formula2 = ''; - $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; - $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; - $this->_operator = ''; - $this->_allowBlank = false; - $this->_showDropDown = false; - $this->_showInputMessage = false; - $this->_showErrorMessage = false; - $this->_errorTitle = ''; - $this->_error = ''; - $this->_promptTitle = ''; - $this->_prompt = ''; - } - - /** - * Get Formula 1 - * - * @return string - */ - public function getFormula1() { - return $this->_formula1; - } - - /** - * Set Formula 1 - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setFormula1($value = '') { - $this->_formula1 = $value; - return $this; - } - - /** - * Get Formula 2 - * - * @return string - */ - public function getFormula2() { - return $this->_formula2; - } - - /** - * Set Formula 2 - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setFormula2($value = '') { - $this->_formula2 = $value; - return $this; - } - - /** - * Get Type - * - * @return string - */ - public function getType() { - return $this->_type; - } - - /** - * Set Type - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { - $this->_type = $value; - return $this; - } - - /** - * Get Error style - * - * @return string - */ - public function getErrorStyle() { - return $this->_errorStyle; - } - - /** - * Set Error style - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { - $this->_errorStyle = $value; - return $this; - } - - /** - * Get Operator - * - * @return string - */ - public function getOperator() { - return $this->_operator; - } - - /** - * Set Operator - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setOperator($value = '') { - $this->_operator = $value; - return $this; - } - - /** - * Get Allow Blank - * - * @return boolean - */ - public function getAllowBlank() { - return $this->_allowBlank; - } - - /** - * Set Allow Blank - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setAllowBlank($value = false) { - $this->_allowBlank = $value; - return $this; - } - - /** - * Get Show DropDown - * - * @return boolean - */ - public function getShowDropDown() { - return $this->_showDropDown; - } - - /** - * Set Show DropDown - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowDropDown($value = false) { - $this->_showDropDown = $value; - return $this; - } - - /** - * Get Show InputMessage - * - * @return boolean - */ - public function getShowInputMessage() { - return $this->_showInputMessage; - } - - /** - * Set Show InputMessage - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowInputMessage($value = false) { - $this->_showInputMessage = $value; - return $this; - } - - /** - * Get Show ErrorMessage - * - * @return boolean - */ - public function getShowErrorMessage() { - return $this->_showErrorMessage; - } - - /** - * Set Show ErrorMessage - * - * @param boolean $value - * @return PHPExcel_Cell_DataValidation - */ - public function setShowErrorMessage($value = false) { - $this->_showErrorMessage = $value; - return $this; - } - - /** - * Get Error title - * - * @return string - */ - public function getErrorTitle() { - return $this->_errorTitle; - } - - /** - * Set Error title - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setErrorTitle($value = '') { - $this->_errorTitle = $value; - return $this; - } - - /** - * Get Error - * - * @return string - */ - public function getError() { - return $this->_error; - } - - /** - * Set Error - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setError($value = '') { - $this->_error = $value; - return $this; - } - - /** - * Get Prompt title - * - * @return string - */ - public function getPromptTitle() { - return $this->_promptTitle; - } - - /** - * Set Prompt title - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setPromptTitle($value = '') { - $this->_promptTitle = $value; - return $this; - } - - /** - * Get Prompt - * - * @return string - */ - public function getPrompt() { - return $this->_prompt; - } - - /** - * Set Prompt - * - * @param string $value - * @return PHPExcel_Cell_DataValidation - */ - public function setPrompt($value = '') { - $this->_prompt = $value; - return $this; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_formula1 - . $this->_formula2 - . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE - . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP - . $this->_operator - . ($this->_allowBlank ? 't' : 'f') - . ($this->_showDropDown ? 't' : 'f') - . ($this->_showInputMessage ? 't' : 'f') - . ($this->_showErrorMessage ? 't' : 'f') - . $this->_errorTitle - . $this->_error - . $this->_promptTitle - . $this->_prompt - . __CLASS__ - ); - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } -} diff --git a/admin/survey/excel/PHPExcel/Cell/DefaultValueBinder.php b/admin/survey/excel/PHPExcel/Cell/DefaultValueBinder.php deleted file mode 100644 index 26750f5..0000000 --- a/admin/survey/excel/PHPExcel/Cell/DefaultValueBinder.php +++ /dev/null @@ -1,106 +0,0 @@ -setValueExplicit( $value, self::dataTypeForValue($value) ); - - // Done! - return true; - } - - /** - * DataType for value - * - * @param mixed $pValue - * @return int - */ - public static function dataTypeForValue($pValue = null) { - // Match the value against a few data types - if (is_null($pValue)) { - return PHPExcel_Cell_DataType::TYPE_NULL; - - } elseif ($pValue === '') { - return PHPExcel_Cell_DataType::TYPE_STRING; - - } elseif ($pValue instanceof PHPExcel_RichText) { - return PHPExcel_Cell_DataType::TYPE_INLINE; - - } elseif ($pValue{0} === '=' && strlen($pValue) > 1) { - return PHPExcel_Cell_DataType::TYPE_FORMULA; - - } elseif (is_bool($pValue)) { - return PHPExcel_Cell_DataType::TYPE_BOOL; - - } elseif (is_float($pValue) || is_int($pValue)) { - return PHPExcel_Cell_DataType::TYPE_NUMERIC; - - } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { - return PHPExcel_Cell_DataType::TYPE_NUMERIC; - - } elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { - return PHPExcel_Cell_DataType::TYPE_ERROR; - - } else { - return PHPExcel_Cell_DataType::TYPE_STRING; - - } - } -} diff --git a/admin/survey/excel/PHPExcel/Cell/Hyperlink.php b/admin/survey/excel/PHPExcel/Cell/Hyperlink.php deleted file mode 100644 index be52d40..0000000 --- a/admin/survey/excel/PHPExcel/Cell/Hyperlink.php +++ /dev/null @@ -1,127 +0,0 @@ -_url = $pUrl; - $this->_tooltip = $pTooltip; - } - - /** - * Get URL - * - * @return string - */ - public function getUrl() { - return $this->_url; - } - - /** - * Set URL - * - * @param string $value - * @return PHPExcel_Cell_Hyperlink - */ - public function setUrl($value = '') { - $this->_url = $value; - return $this; - } - - /** - * Get tooltip - * - * @return string - */ - public function getTooltip() { - return $this->_tooltip; - } - - /** - * Set tooltip - * - * @param string $value - * @return PHPExcel_Cell_Hyperlink - */ - public function setTooltip($value = '') { - $this->_tooltip = $value; - return $this; - } - - /** - * Is this hyperlink internal? (to another sheet) - * - * @return boolean - */ - public function isInternal() { - return strpos($this->_url, 'sheet://') !== false; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_url - . $this->_tooltip - . __CLASS__ - ); - } -} diff --git a/admin/survey/excel/PHPExcel/Cell/IValueBinder.php b/admin/survey/excel/PHPExcel/Cell/IValueBinder.php deleted file mode 100644 index d869ec9..0000000 --- a/admin/survey/excel/PHPExcel/Cell/IValueBinder.php +++ /dev/null @@ -1,46 +0,0 @@ -