/** * Logs the given variable output to a file. * * @param mixed $mValue The value to log. * @param string $sFilePath The log file path. * @return void **/ public static function log($mValue, $sFilePath = null) { if (!self::isDebugModeEnabled()) { return; } parent::log($mValue, $sFilePath); }
private function _outputDataByType($vData, $sFormatType) { switch (strtolower($sFormatType)) { case 'text': if (in_array(gettype($vData), array('array', 'object'))) { echo AmazonAutoLinks_AdminPageFramework_Debug::get($vData, null, false); } echo $vData; return; case 'json': echo json_encode((array) $vData); return; case 'array': default: echo serialize((array) $vData); return; } }
/** * Performs exporting data. * * @since 2.0.0 */ public function doExport($vData, $strFileName = null, $strFormatType = null) { /* * Sample HTML elements that triggers the method. * e.g. * <input type="hidden" name="__export[export_sinble][file_name]" value="APF_GettingStarted_20130708.txt"> * <input type="hidden" name="__export[export_sinble][format]" value="json"> * <input id="export_and_import_export_sinble_0" * type="submit" * name="__export[submit][export_sinble]" * value="Export Options"> */ $strFileName = isset($strFileName) ? $strFileName : $this->strFileName; $strFormatType = isset($strFormatType) ? $strFormatType : $this->strFormatType; // Do export. header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=' . $strFileName); switch (strtolower($strFormatType)) { case 'text': // for plain text. if (is_array($vData) || is_object($vData)) { $oDebug = new AmazonAutoLinks_AdminPageFramework_Debug(); $strData = $oDebug->getArray($vData); die($strData); } die($vData); case 'json': // for json. die(json_encode((array) $vData)); case 'array': // for serialized PHP array. // for serialized PHP array. default: // for anything else, die(serialize((array) $vData)); } }