Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • AlphaController
  • CacheManager
  • Create
  • CreateArticle
  • Detail
  • Edit
  • EditArticle
  • EditDEnum
  • EditTags
  • GenSecureQueryStrings
  • Install
  • ListAll
  • ListBusinessObjects
  • ListDEnums
  • ListSequences
  • Login
  • Logout
  • PreviewArticle
  • Search
  • TagManager
  • ViewArticle
  • ViewArticleFile
  • ViewArticlePDF
  • ViewArticlePrint
  • ViewArticleTitle
  • ViewAttachment
  • ViewExcel
  • ViewFeed
  • ViewImage
  • ViewLog
  • ViewMetrics
  • ViewRecordSelector
  • ViewTestResults

Interfaces

  • AlphaControllerInterface
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: // include the config file
  4: if(!isset($config)) {
  5:     require_once '../util/AlphaConfig.inc';
  6:     $config = AlphaConfig::getInstance();
  7: 
  8:     require_once $config->get('app.root').'alpha/util/AlphaAutoLoader.inc';
  9: }
 10: 
 11: /**
 12:  *
 13:  * Controller used to display a Markdown version of a page article where the name of the
 14:  * .text file containing the Markdown/HTML content is provided
 15:  *
 16:  * @package alpha::controller
 17:  * @since 1.0
 18:  * @author John Collins <dev@alphaframework.org>
 19:  * @version $Id: ViewArticleFile.php 1654 2013-03-08 17:13:14Z alphadevx $
 20:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 21:  * @copyright Copyright (c) 2013, John Collins (founder of Alpha Framework).
 22:  * All rights reserved.
 23:  *
 24:  * <pre>
 25:  * Redistribution and use in source and binary forms, with or
 26:  * without modification, are permitted provided that the
 27:  * following conditions are met:
 28:  *
 29:  * * Redistributions of source code must retain the above
 30:  *   copyright notice, this list of conditions and the
 31:  *   following disclaimer.
 32:  * * Redistributions in binary form must reproduce the above
 33:  *   copyright notice, this list of conditions and the
 34:  *   following disclaimer in the documentation and/or other
 35:  *   materials provided with the distribution.
 36:  * * Neither the name of the Alpha Framework nor the names
 37:  *   of its contributors may be used to endorse or promote
 38:  *   products derived from this software without specific
 39:  *   prior written permission.
 40:  *
 41:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 42:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 43:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 44:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 45:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 46:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 47:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 48:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 49:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 50:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 51:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 52:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 53:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 54:  * </pre>
 55:  *
 56:  */
 57: class ViewArticleFile extends ViewArticle {
 58:     /**
 59:      * Trace logger
 60:      *
 61:      * @var Logger
 62:      * @since 1.0
 63:      */
 64:     private static $logger = null;
 65: 
 66:     /**
 67:      * Handle GET requests
 68:      *
 69:      * @param array $params
 70:      * @since 1.0
 71:      * @throws ResourceNotFoundException
 72:      */
 73:     public function doGET($params) {
 74:         self::$logger = new Logger('ViewArticleFile');
 75: 
 76:         global $config;
 77: 
 78:         try {
 79:             // ensure that a file path is provided
 80:             if (!isset($params['file'])) {
 81:                 throw new IllegalArguementException('Could not load the article as a file name was not supplied!');
 82:             }
 83: 
 84:             $this->BO = new ArticleObject();
 85: 
 86:             // just checking to see if the file path is absolute or not
 87:             if(substr($params['file'], 0, 1) == '/')
 88:                 $this->BO->loadContentFromFile($params['file']);
 89:             else
 90:                 $this->BO->loadContentFromFile($config->get('app.root').'alpha/docs/'.$params['file']);
 91: 
 92:         }catch(IllegalArguementException $e) {
 93:             self::$logger->error($e->getMessage());
 94:             throw new ResourceNotFoundException($e->getMessage());
 95:         }catch(FileNotFoundException $e) {
 96:             self::$logger->warn($e->getMessage().' File path is ['.$params['file'].']');
 97:             throw new ResourceNotFoundException('Failed to load the requested article from the file system!');
 98:         }
 99: 
100:         $this->setTitle($this->BO->get('title'));
101: 
102:         $BOView = AlphaView::getInstance($this->BO);
103: 
104:         echo AlphaView::displayPageHead($this, false);
105: 
106:         echo $BOView->markdownView();
107: 
108:         echo AlphaView::displayPageFoot($this);
109:     }
110: 
111:     /**
112:      * Overidding the parent here as we want an empty footer on file-based articles
113:      *
114:      * @return string
115:      * @since 1.0
116:      */
117:     public function before_displayPageFoot_callback() {
118:         return '';
119:     }
120: }
121: 
122: // now build the new controller
123: if(basename($_SERVER['PHP_SELF']) == 'ViewArticleFile.php') {
124:     $controller = new ViewArticleFile();
125: 
126:     if(!empty($_POST)) {
127:         $controller->doPOST($_REQUEST);
128:     }else{
129:         $controller->doGET($_GET);
130:     }
131: }
132: 
133: ?>
Alpha Framework ${alpha.version.new} API Documentation API documentation generated by ApiGen 2.8.0