From bfc448fa7f465412e4283be764ae8248e4193d8b Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 8 Jan 2008 06:41:55 +0000 Subject: [PATCH] Added package tags and docblock info for API documentation Fixed whitespace git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@47726 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/AssetAdmin.php | 5 + code/AssetTableField.php | 8 + code/BulkLoader.php | 9 + code/BulkLoaderAdmin.php | 5 + code/CMSActionOptionsForm.php | 5 + code/CMSMain.php | 5 + code/CommentAdmin.php | 8 + code/CommentTableField.php | 8 + code/Diff.php | 6 + code/FileList.php | 8 + code/GenericDataAdmin.php | 5 + code/ImageEditor.php | 454 +++++++++++---------- code/ImprintStats.php | 8 + code/LeftAndMain.php | 5 + code/MemberList.php | 8 + code/MemberTableField.php | 6 + code/Newsletter/BatchProcess.php | 6 + code/Newsletter/BouncedList.php | 9 + code/Newsletter/Newsletter.php | 8 + code/Newsletter/NewsletterEmailProcess.php | 9 + code/Newsletter/NewsletterList.php | 8 + code/Newsletter/NewsletterType.php | 9 + code/Newsletter/RecipientImportField.php | 8 +- code/Newsletter/SubscribeForm.php | 9 + code/Newsletter/TemplateList.php | 8 +- code/Newsletter/Unsubscribe.php | 10 +- code/Newsletter/UnsubscribedList.php | 10 +- code/NewsletterAdmin.php | 8 + code/PageTypes/UserDefinedForm.php | 8 + code/ReportAdmin.php | 8 + code/SecurityAdmin.php | 8 + code/SideReport.php | 15 + code/StaticExporter.php | 5 + code/StatisticsAdmin.php | 8 + code/ThumbnailStripField.php | 5 + code/WidgetAreaEditor.php | 8 + code/sitefeatures/Akismet.php | 6 +- code/sitefeatures/MathSpamProtection.php | 6 + code/sitefeatures/PageComment.php | 8 + code/sitefeatures/PageCommentInterface.php | 5 + code/sitefeatures/SSAkismet.php | 6 + 41 files changed, 516 insertions(+), 235 deletions(-) diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index 2dce649f..c4016808 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -1,5 +1,10 @@ requestParams['fileToEdit'])) $this->raiseError(); - $fileWithPath = $this->requestParams['fileToEdit']; - $this->fileToEdit = $this->file2Origin($fileWithPath); - $this->fileToEditOnlyName = $this->urlToFilename($this->fileToEdit); - return $this->renderWith(__CLASS__); + if(!isset($this->requestParams['fileToEdit'])) $this->raiseError(); + $fileWithPath = $this->requestParams['fileToEdit']; + $this->fileToEdit = $this->file2Origin($fileWithPath); + $this->fileToEditOnlyName = $this->urlToFilename($this->fileToEdit); + return $this->renderWith(__CLASS__); + } + + /** + * Method is used for manipulating photos. + * Method requires two params set in POST + * file - file on which operation will be performed + * command - name of operation(crop|rotate|resize) + * + * Each operation requires additional parameters. + * + * @return String - JSON array with image properties (width,height,url). + */ + public function manipulate() { + $fileName = $this->requestParams['file']; + if(strpos($fileName,'?') !== false) $fileName = substr($fileName,0,strpos($fileName,'?')); + $command = $this->requestParams['command']; + $this->checkFileExists($fileName); + $fileInfo = pathinfo($fileName); + $gd = new GD($this->url2File($fileName)); + switch($command) { + case 'rotate': + $angle = $_POST['angle']; + $gd = $gd->rotate($angle); + break; + case 'resize': + $imageNewWidth = $_POST['newImageWidth']; + $imageNewHeight = $_POST['newImageHeight']; + $gd = $gd->resize($imageNewWidth,$imageNewHeight); + break; + case 'crop': + $top = $_POST['top']; + $left = $_POST['left']; + $width = $_POST['width']; + $height = $_POST['height']; + $gd = $gd->crop($top,$left,$width,$height); + break; } - - /** - * Method is used for manipulating photos. - * Method requires two params set in POST - * file - file on which operation will be performed - * command - name of operation(crop|rotate|resize) - * - * Each operation requires additional parameters. - * - * @return String - JSON array with image properties (width,height,url). - */ - public function manipulate() { - $fileName = $this->requestParams['file']; - if(strpos($fileName,'?') !== false) $fileName = substr($fileName,0,strpos($fileName,'?')); - $command = $this->requestParams['command']; - $this->checkFileExists($fileName); - $fileInfo = pathinfo($fileName); - $gd = new GD($this->url2File($fileName)); - switch($command) { - case 'rotate': - $angle = $_POST['angle']; - $gd = $gd->rotate($angle); - break; - case 'resize': - $imageNewWidth = $_POST['newImageWidth']; - $imageNewHeight = $_POST['newImageHeight']; - $gd = $gd->resize($imageNewWidth,$imageNewHeight); - break; - case 'crop': - $top = $_POST['top']; - $left = $_POST['left']; - $width = $_POST['width']; - $height = $_POST['height']; - $gd = $gd->crop($top,$left,$width,$height); - break; - } - $rand = md5(rand(1,100000)); - $gd->writeTo('../assets/_tmp/' . $rand . '.' . $fileInfo['extension']); - return $this->getImageInfoInJSON($gd,'assets/_tmp/' . $rand . '.' . $fileInfo['extension']); - } - - /** - * Method is used for saving photos. - * Method requires two params set in POST - * originalFile - this file will be replaced by second file - * editedFile - this file will replace first file. - * - * After replacing original file all thumbnails created from it are removed. - * - * @return String - Message that everything went ok. - */ - - public function save() { - if(isset($this->requestParams['originalFile']) && isset($this->requestParams['editedFile'])) { - $originalFile = $this->requestParams['originalFile']; - $editedFile = $this->requestParams['editedFile']; - if(strpos($originalFile,'?') !== false) $originalFile = substr($originalFile,0,strpos($originalFile,'?')); - if($this->checkFileExists($originalFile) && $this->checkFileExists($editedFile)) { - if($editedFile != $originalFile && copy($this->url2File($editedFile),$this->url2File($originalFile))) { - $image = DataObject::get_one('File','Filename = \'' . substr($this->url2File($originalFile),3) . '\''); - $image->deleteFormattedImages(); - $image->generateFormattedImage('AssetLibraryPreview'); - } else { - $this->raiseError(); - } + $rand = md5(rand(1,100000)); + $gd->writeTo('../assets/_tmp/' . $rand . '.' . $fileInfo['extension']); + return $this->getImageInfoInJSON($gd,'assets/_tmp/' . $rand . '.' . $fileInfo['extension']); + } + + /** + * Method is used for saving photos. + * Method requires two params set in POST + * originalFile - this file will be replaced by second file + * editedFile - this file will replace first file. + * + * After replacing original file all thumbnails created from it are removed. + * + * @return String - Message that everything went ok. + */ + + public function save() { + if(isset($this->requestParams['originalFile']) && isset($this->requestParams['editedFile'])) { + $originalFile = $this->requestParams['originalFile']; + $editedFile = $this->requestParams['editedFile']; + if(strpos($originalFile,'?') !== false) $originalFile = substr($originalFile,0,strpos($originalFile,'?')); + if($this->checkFileExists($originalFile) && $this->checkFileExists($editedFile)) { + if($editedFile != $originalFile && copy($this->url2File($editedFile),$this->url2File($originalFile))) { + $image = DataObject::get_one('File','Filename = \'' . substr($this->url2File($originalFile),3) . '\''); + $image->deleteFormattedImages(); + $image->generateFormattedImage('AssetLibraryPreview'); } else { $this->raiseError(); - } + } } else { $this->raiseError(); } - return 'parent.parent.parent.statusMessage(\'Image saved\',\'good\',false);'; + } else { + $this->raiseError(); } - - /** - * Method is invoked when ImageEditor is closed whether image is saved or not. - * - * /assets/tmp is folder where we store temporary images created during editing so - * after closing they are no necessity to keep them. - * - * @return null - */ - - public function close() { - $tmpDir = '../assets/_tmp'; - if(file_exists($tmpDir)) { - Filesystem::removeFolder($tmpDir); - mkdir($tmpDir, Filesystem::$folder_create_mask); - } - } - - /** - * Method return JSON array containing info about image. - * - * @param gd - GD object used for retrieving info about image - * @param file - * - * @return string JSON array explained in manipulate method comment - */ - - private function getImageInfoInJSON(GD $gd,$file) { - return '{"fileName":"' . $file . '","width":' . $gd->getWidth() . ',"height":' . $gd->getHeight() . '}'; - } - - /** - * Method converts thumbnail file name to file name of it's "parent" - * - * @param file - name of thumbnail file - * - * @return string name of parent file. - */ - - private function file2Origin($file) { - $file = str_replace('_resampled/','',$file); - $file = str_replace('_resampled/','',$file); - $file = str_replace('AssetLibraryPreview-','',$file); - $this->checkFileExists($file); - return $file; - } - /** - * Method converts URL of file to file path in file system. - * - * @param url - url of file - * - * @return string path of file in file system - */ - - private function url2File($url) { - return '..' . substr($url,strpos($url,'/assets')); - } - - /** - * Method checks if file exists and have proper name and extension. - * - * If any of constraints aren't fulfilled method will generate error. - * - * @param url - url of file - * - * @return boolean - */ - - private function checkFileExists($url) { - if(strpos($url,'?') !== false) $url = substr($url,0,strpos($url,'?')); - $pathInfo = pathinfo($url); - if(count($pathInfo) < 3) $this->raiseError(); - if(!in_array($pathInfo['extension'],array('jpeg','jpg','jpe','png','gif','JPEG','JPG','JPE','PNG','GIF'))) $this->raiseError(); - $path = explode('/',$pathInfo['dirname']); - if(count($path) > 1) { - $assetId = array_search('assets',$path); - if($assetId > 0) { - $realPath = '../' . implode('/',array_slice($path,$assetId,count($path) - $assetId)); - if(strpos($pathInfo['basename'],'AssetLibraryPreview') !== false) { - $realPath .= '/' . substr($pathInfo['basename'],strpos($pathInfo['basename'],'-')); - } else { - $realPath .= '/' . $pathInfo['basename']; - } - } else { - $this->raiseError(); - } - if(file_exists($realPath)) { - return true; - } else { - $this->raiseError(); - } - } else { - $this->raiseError(); - } - } - - /** - * Method raiser error. Error is showed using statusMessage function. - * - * @param message - error message - * - */ - - private function raiseError($message = "") { - echo "parent.parent.parent.statusMessage('Error: " . $message . "','bad',false);"; - exit(); - } - - /** - * Method converts retrieves filename from url - * - * @param url - * - */ - - private function urlToFilename($url) { - $path = pathinfo($url); - return $path['filename'] . "." . substr($path['extension'],0,strpos($path['extension'],'?')); + return 'parent.parent.parent.statusMessage(\'Image saved\',\'good\',false);'; + } + + /** + * Method is invoked when ImageEditor is closed whether image is saved or not. + * + * /assets/tmp is folder where we store temporary images created during editing so + * after closing they are no necessity to keep them. + * + * @return null + */ + + public function close() { + $tmpDir = '../assets/_tmp'; + if(file_exists($tmpDir)) { + Filesystem::removeFolder($tmpDir); + mkdir($tmpDir, Filesystem::$folder_create_mask); } } + + /** + * Method return JSON array containing info about image. + * + * @param gd - GD object used for retrieving info about image + * @param file + * + * @return string JSON array explained in manipulate method comment + */ + + private function getImageInfoInJSON(GD $gd,$file) { + return '{"fileName":"' . $file . '","width":' . $gd->getWidth() . ',"height":' . $gd->getHeight() . '}'; + } + + /** + * Method converts thumbnail file name to file name of it's "parent" + * + * @param file - name of thumbnail file + * + * @return string name of parent file. + */ + + private function file2Origin($file) { + $file = str_replace('_resampled/','',$file); + $file = str_replace('_resampled/','',$file); + $file = str_replace('AssetLibraryPreview-','',$file); + $this->checkFileExists($file); + return $file; + } + /** + * Method converts URL of file to file path in file system. + * + * @param url - url of file + * + * @return string path of file in file system + */ + + private function url2File($url) { + return '..' . substr($url,strpos($url,'/assets')); + } + + /** + * Method checks if file exists and have proper name and extension. + * + * If any of constraints aren't fulfilled method will generate error. + * + * @param url - url of file + * + * @return boolean + */ + + private function checkFileExists($url) { + if(strpos($url,'?') !== false) $url = substr($url,0,strpos($url,'?')); + $pathInfo = pathinfo($url); + if(count($pathInfo) < 3) $this->raiseError(); + if(!in_array($pathInfo['extension'],array('jpeg','jpg','jpe','png','gif','JPEG','JPG','JPE','PNG','GIF'))) $this->raiseError(); + $path = explode('/',$pathInfo['dirname']); + if(count($path) > 1) { + $assetId = array_search('assets',$path); + if($assetId > 0) { + $realPath = '../' . implode('/',array_slice($path,$assetId,count($path) - $assetId)); + if(strpos($pathInfo['basename'],'AssetLibraryPreview') !== false) { + $realPath .= '/' . substr($pathInfo['basename'],strpos($pathInfo['basename'],'-')); + } else { + $realPath .= '/' . $pathInfo['basename']; + } + } else { + $this->raiseError(); + } + if(file_exists($realPath)) { + return true; + } else { + $this->raiseError(); + } + } else { + $this->raiseError(); + } + } + + /** + * Method raiser error. Error is showed using statusMessage function. + * + * @param message - error message + * + */ + + private function raiseError($message = "") { + echo "parent.parent.parent.statusMessage('Error: " . $message . "','bad',false);"; + exit(); + } + + /** + * Method converts retrieves filename from url + * + * @param url + * + */ + + private function urlToFilename($url) { + $path = pathinfo($url); + return $path['filename'] . "." . substr($path['extension'],0,strpos($path['extension'],'?')); + } +} diff --git a/code/ImprintStats.php b/code/ImprintStats.php index 2213982c..b2b62ff5 100755 --- a/code/ImprintStats.php +++ b/code/ImprintStats.php @@ -1,5 +1,13 @@ mailType = $mailtype; diff --git a/code/Newsletter/NewsletterType.php b/code/Newsletter/NewsletterType.php index be323b79..f62e9c22 100755 --- a/code/Newsletter/NewsletterType.php +++ b/code/Newsletter/NewsletterType.php @@ -1,5 +1,14 @@ renderWith("WidgetAreaEditor"); diff --git a/code/sitefeatures/Akismet.php b/code/sitefeatures/Akismet.php index b5582414..a7304f4b 100644 --- a/code/sitefeatures/Akismet.php +++ b/code/sitefeatures/Akismet.php @@ -15,7 +15,8 @@ * * See the Akismet class documentation page linked to below for usage information. * - * @package Akismet + * @package cms + * @subpackage * @author Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net} * @version 0.1 * @copyright Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net} @@ -43,8 +44,6 @@ * // store the comment normally * * - * @package akismet - * @name Akismet * @version 0.2 * @author Alex Potsides * @link http://www.achingbrain.net/ @@ -298,7 +297,6 @@ class Akismet * * N.B. It is not necessary to call this class directly to use the Akismet class. This is included here mainly out of a sense of completeness. * - * @package akismet * @name SocketWriteRead * @version 0.1 * @author Alex Potsides diff --git a/code/sitefeatures/MathSpamProtection.php b/code/sitefeatures/MathSpamProtection.php index d60b53c6..a769505b 100644 --- a/code/sitefeatures/MathSpamProtection.php +++ b/code/sitefeatures/MathSpamProtection.php @@ -1,4 +1,10 @@ "Varchar", diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index 2769afb0..74bd927e 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -1,5 +1,10 @@