/** * Render a template. * @param {string} $template Path to file. * @param {mixed} $data Data to make available. */ public function render($template, $data = NULL) { if (!(include $this->basePath . $template)) { $msg = sprintf('[%s] Failed to include file <code>"%s"</code>.', get_class(), htmlspecialchars($this->basePath . $template)); ae_Log::error($msg); } }
/** * Prepare and execute an SQL statement. * @param {string} $statement The statement to prepare and execute. * @param {array} $params Parameters for the statement. (Optional.) * @return {array|boolean} The query result as array or FALSE if an error occured. */ public static function query($statement, $params = array()) { $pdoStatement = self::$pdo->prepare($statement); if (!$pdoStatement || $pdoStatement->execute($params) === FALSE) { $errorInfo = @$pdoStatement->errorInfo(); $msg = sprintf('[%s] Statement failed: <code>%s</code>. %s', get_class(), htmlspecialchars($statement), @$errorInfo[2]); ae_Log::error($msg); return FALSE; } self::$numQueries++; return $pdoStatement->fetchAll(PDO::FETCH_ASSOC); }
/** * Delete the associated file from the file system. * @return {boolean} TRUE, if file could be deleted, FALSE otherwise. */ public function deleteFile() { $file = $this->mediaPath . $this->getFilePath(); if (!unlink($file)) { $msg = sprintf('[%s] Failed to delete file: %s', get_class(), htmlspecialchars($file)); ae_Log::error($msg); return FALSE; } if ($this->isImage()) { $file = $this->mediaPath . $this->getFilePathNoName() . 'tiny/' . $this->getName(); if (!unlink($file)) { $msg = sprintf('[%s] Failed to delete preview image: %s', get_class(), htmlspecialchars($file)); ae_Log::error($msg); return FALSE; } } return TRUE; }
/** * Save all uploaded file data to the DB. * @return {boolean} TRUE, if all files could be saved, FALSE otherwise. */ public function saveToDB() { foreach ($this->items as $m) { if (!$m->save()) { $msg = sprintf('[%s] Failed to save <code>%s</code> to the DB.', get_class(), htmlspecialchars($m->getName())); ae_Log::error($msg); return FALSE; } } return TRUE; }