Example #1
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     $blacklisted_objects = explode(',', HSetting::GetText('showFilesWidgetBlacklist', 'file'));
     if (!in_array(get_class($this->object), $blacklisted_objects)) {
         $files = File::getFilesOfObject($this->object);
         $this->render('showFiles', array('files' => $files, 'maxPreviewImageWidth' => HSetting::Get('maxPreviewImageWidth', 'file'), 'maxPreviewImageHeight' => HSetting::Get('maxPreviewImageHeight', 'file'), 'hideImageFileInfo' => HSetting::Get('hideImageFileInfo', 'file')));
     }
 }
 /**
  * Draw the widget
  */
 public function run()
 {
     $files = array();
     if ($this->object !== null) {
         $files = File::getFilesOfObject($this->object);
     }
     Yii::app()->clientScript->setJavaScriptVariable('file_delete_url', $this->createUrl('//file/file/delete'));
     $this->render('fileUploadList', array('uploaderId' => $this->uploaderId, 'files' => $files));
 }
 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->item->href != '') {
         $this->render('libraryLink', array('item' => $this->item, 'category' => $this->category, 'editable' => $this->editable));
     } else {
         $files = File::getFilesOfObject($this->item);
         $file = array_pop($files);
         // If there is no file attached, deliver a dummy object. That's better than completely breaking the rendering.
         if (!is_object($file)) {
             $file = new File();
         }
         $mime = HHtml::getMimeIconClassByExtension($file->getExtension());
         $this->render('libraryDocument', array('file' => $file, 'mime' => $mime, 'item' => $this->item, 'category' => $this->category, 'editable' => $this->editable));
     }
 }
    ?>
	    	<div id="library-widget-category_<?php 
    echo $category->id;
    ?>
" class="media">
	    		<div class="media-heading"><?php 
    echo $category->title;
    ?>
</div>
				<ul class="media-list">
					<?php 
    foreach ($items[$category->id] as $item) {
        ?>
						<?php 
        if ($item->href == '') {
            $files = File::getFilesOfObject($item);
            $file = array_pop($files);
            // If there is no file attached, deliver a dummy object. That's better than completely breaking the rendering.
            if (!is_object($file)) {
                $file = new File();
            }
            $item->href = $file->getUrl();
        }
        ?>
						<li id="library-widget-item_<?php 
        echo $item->id;
        ?>
"><a href="<?php 
        echo $item->href;
        ?>
" title="<?php 
Example #5
0
<div class="panel panel-default">
    <div class="panel-body">

        <?php 
$this->beginContent('application.modules_core.wall.views.wallDocumentLayout', array('object' => $document));
?>


        <?php 
echo CHtml::beginForm();
?>
        <?php 
$first_file = array();
?>
        <?php 
$files = File::getFilesOfObject($document);
?>

        <?php 
if (count($files) != 0) {
    ?>
        <?php 
    $first_file = $files[0];
    ?>
        <?php 
}
?>
	        <!-- start: show document's img -->
		<!--
<a <?php 
//if (count($first_file) != 0) :
 /**
  * Action that renders the view to edit an item.<br />
  * The request has to provide the id of the category the document should be created in, in the url parameter 'category_id'.<br />
  * If an existing document should be edited, the document's id has to be given in 'document_id'.<br />
  * @see views/library/editCategory.php
  * @throws CHttpException 404, if the logged in User misses the rights to access this view.
  */
 public function actionEditItem()
 {
     $this->checkContainerAccess();
     $item_id = (int) Yii::app()->request->getQuery('item_id');
     $category_id = (int) Yii::app()->request->getQuery('category_id');
     $item = LibraryItem::model()->findByAttributes(array('id' => $item_id));
     $category = LibraryCategory::model()->findByAttributes(array('id' => $category_id));
     $isCreated = false;
     $publicCategory = $category->content->isPublic();
     // access level 0 may neither create nor edit
     if ($this->accessLevel == 0) {
         throw new CHttpException(404, Yii::t('LibraryModule.exception', 'You miss the rights to add/edit items!'));
     } else {
         if ($item == null) {
             throw new CHttpException(404, Yii::t('LibraryModule.exception', 'The item you want to edit could not be found!'));
         } else {
             if ($this->accessLevel == 1 && ($item->content->visiblity == '1' || $item->content->created_by != Yii::app()->user->id)) {
                 throw new CHttpException(404, Yii::t('LibraryModule.exception', 'You miss the rights to edit this document!'));
             }
         }
     }
     // if form content is sent back, validate and save
     if (isset($_POST['LibraryDocument']) || isset($_POST['LibraryLink'])) {
         $_POST = Yii::app()->input->stripClean($_POST);
         if (isset($_POST['LibraryDocument'])) {
             $item->attributes = $_POST['LibraryDocument'];
         }
         if (isset($_POST['LibraryLink'])) {
             $item->attributes = $_POST['LibraryLink'];
         }
         $item->content->container = $this->contentContainer;
         $item->content->visibility = $category->content->visibility;
         // Clean up files: Keep only the last uploaded file.
         // TODO: Fix the ugly mess with multiple uploaded files.
         $files = File::getFilesOfObject($item);
         $has_files = count($files) > 0;
         $keep_file = array_pop($files);
         foreach ($files as $file) {
             $file->delete();
         }
         // Validate and save item. At least one file needs to be attached with documents. Links don't have a file.
         if (isset($_POST['LibraryDocument']) && !$has_files) {
             $item->addError('file', Yii::t('LibraryModule.base', 'You must upload a file.'));
         } elseif ($item->validate()) {
             $item->save();
             $this->redirect(Yii::app()->createUrl('library/library/showlibrary', array($this->guidParamName => $this->contentContainer->guid)));
         }
     }
     // If the item is a document, render document edit form
     if (get_class($item) == 'LibraryDocument') {
         $this->render('editDocument', array($this->guidParamName => $this->contentContainer->guid, 'document' => $item, 'isCreated' => $isCreated));
     } elseif (get_class($item) == 'LibraryLink') {
         $this->render('editLink', array($this->guidParamName => $this->contentContainer->guid, 'link' => $item, 'isCreated' => $isCreated));
     } else {
         $this->redirect(Yii::app()->createUrl('library/library/showlibrary', array($this->guidParamName => $this->contentContainer->guid)));
     }
 }