Source for file ArticleView.inc
Documentation is available at ArticleView.inc
require_once $config->get('sysRoot'). 'alpha/model/PersonObject.inc';
require_once $config->get('sysRoot'). 'alpha/view/AlphaView.inc';
require_once $config->get('sysRoot'). 'alpha/util/MarkdownFacade.inc';
* The rendering class for the ArticleObject class
* @author John Collins <dev@alphaframework.org>
* @version $Id: ArticleView.inc 1341 2011-03-17 15:02:02Z johnc $
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
* * Neither the name of the Alpha Framework nor the names
* of its contributors may be used to endorse or promote
* products derived from this software without specific
* prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Method to generate the markdown HTML render of the article content
* @param array $fields Hash array of HTML fields to pass to the template.
$fields['markdownContent'] = $markdown->getContent();
* Adds a note to the create article screen
echo '<p><strong>Please note</strong> that you will only be able to attach files to the article once it has been created.</p><br>';
* Renders the list view (adds the dateAdded field for the list template)
* @param array $fields hash array of HTML fields to pass to the template
public function listView($fields= array()) {
$fields['dateAdded'] = $this->BO->getCreateTS()->getDate();
* Renders a form to enable article editing with attachments options
* @param array $fields hash array of HTML fields to pass to the template
public function editView($fields= array()) {
$this->before_editView_callback();
$fields['formAction'] = $_SERVER['REQUEST_URI'];
// buffer form fields to $formFields
// buffer HTML output for Create and Cancel buttons
$button = new button('submit', 'Save', 'saveBut');
$fields['saveButton'] = $button->render();
$js = "$('#dialogDiv').text('Are you sure you wish to delete this item?');
'OK': function(event, ui) {
$('#deleteOID').attr('value', '". $this->BO->getOID(). "');
$('#deleteForm').submit();
'Cancel': function(event, ui) {
$('#dialogDiv').dialog('open');
$button = new Button($js, "Delete", "deleteBut");
$fields['deleteButton'] = $button->render();
$fields['cancelButton'] = $button->render();
$tags = $this->BO->getPropObject('tags')->getRelatedObjects();
$fields['tagsButton'] = $button->render();
// buffer security fields to $formSecurityFields variable
// OID will need to be posted for optimistic lock checking
$fields['version_num'] = $this->BO->getVersionNumber();
// file attachments section
$this->after_editView_callback();
* Renders the HTML for the file upload section
$html = '<tr><td colspan="2"> </td></tr><tr><th colspan="2" style="text-align:left;">File Attachments:</th></tr>';
if (is_dir($this->BO->getAttachmentsLocation())) {
$handle = opendir($this->BO->getAttachmentsLocation());
// loop over the attachments directory
while (false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..') {
$html .= ' '. $file. ' <em>('. number_format(filesize($this->BO->getAttachmentsLocation(). '/'. $file)/ 1024). ' KB)</em>';
$js = "$('#dialogDiv').text('Are you sure you want to delete the file ". $file. "');
'OK': function(event, ui) {
$('#file_to_delete').attr('value', '". $file. "');
'Cancel': function(event, ui) {
$('#dialogDiv').dialog('open');
$button = new Button($js, "Delete", "deleteBut");
$html .= $button->render();
$html .= 'Attachment file location';
// we will take this opportunity to create the attachments folder is it does
$this->BO->createAttachmentsFolder();
$html .= '<input name="userfile" type="file" value="Browse..." size="70"/>';
$html .= '<tr><td colspan="2">';
$temp = new button('submit', 'Upload', 'uploadBut');
$html .= $temp->render();
$html .= '<input type="hidden" name="file_to_delete" id="file_to_delete" value=""/>';
|