Пример #1
0
 public function onContentAfterDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     $html = "";
     $files = new CrowdfundingFiles\Files(JFactory::getDbo());
     $files->load(array("project_id" => $item->id));
     if (count($files) > 0) {
         $mediaFolderUri = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id);
         // Get the path for the layout file
         $path = JPath::clean(JPluginHelper::getLayoutPath('content', 'crowdfundingfiles'));
         // Render the login form.
         ob_start();
         include $path;
         $html = ob_get_clean();
     }
     return $html;
 }
Пример #2
0
 /**
  * This method prepares a code that will be included to step "Extras" on project wizard.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onExtrasDisplay($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.project.extras", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (empty($item->user_id)) {
         return null;
     }
     // Create a media folder.
     $mediaFolder = CrowdfundingFilesHelper::getMediaFolder();
     if (!JFolder::exists($mediaFolder)) {
         CrowdfundingHelper::createFolder($mediaFolder);
     }
     // Create a media folder for a user.
     $mediaFolder = CrowdfundingFilesHelper::getMediaFolder($item->user_id);
     if (!JFolder::exists($mediaFolder)) {
         CrowdfundingHelper::createFolder($mediaFolder);
     }
     $componentParams = JComponentHelper::getParams("com_crowdfundingfiles");
     /** @var  $componentParams Joomla\Registry\Registry */
     $mediaUri = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id);
     $options = array("project_id" => $item->id, "user_id" => $item->user_id);
     $files = new CrowdfundingFiles\Files(JFactory::getDbo());
     $files->load($options);
     // Load jQuery
     JHtml::_("jquery.framework");
     JHtml::_("prism.ui.pnotify");
     JHtml::_('prism.ui.fileupload');
     JHtml::_('prism.ui.joomlaHelper');
     // Include the translation of the confirmation question.
     JText::script('PLG_CROWDFUNDING_FILES_DELETE_QUESTION');
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'files'));
     // Render the login form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Пример #3
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Add submenu
     CrowdfundingFilesHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Пример #4
0
 public function display($tpl = null)
 {
     $this->version = new CrowdfundingFiles\Version();
     // Load ITPrism library version
     if (!class_exists("Prism\\Version")) {
         $this->itprismVersion = JText::_("COM_CROWDFUNDINGFILES_PRISM_LIBRARY_DOWNLOAD");
     } else {
         $itprismVersion = new Prism\Version();
         $this->itprismVersion = $itprismVersion->getShortVersion();
     }
     // Add submenu
     CrowdfundingFilesHelper::addSubmenu($this->getName());
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Пример #5
0
 /**
  * Pre-processor for $table->delete($pk)
  *
  * @param   mixed $pks An optional primary key value to delete.  If not set the instance property value is used.
  *
  * @return  void
  *
  * @since   3.1.2
  * @throws  UnexpectedValueException
  */
 public function onBeforeDelete($pks)
 {
     $db = $this->table->getDbo();
     foreach ($pks as $fileId) {
         $query = $db->getQuery(true);
         $query->select("a.filename, a.user_id")->from($db->quoteName("#__cffiles_files", "a"))->where("a.id =" . (int) $fileId);
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row->user_id)) {
             $mediaFolder = CrowdfundingFilesHelper::getMediaFolder($row->user_id);
             $fileSource = JPath::clean($mediaFolder . "/" . $row->filename);
             if (JFile::exists($fileSource)) {
                 JFile::delete($fileSource);
             }
         }
     }
 }
Пример #6
0
 /**
  * Delete a file.
  */
 public function remove()
 {
     // Create response object
     $response = new Prism\Response\Json();
     $userId = JFactory::getUser()->get("id");
     if (!$userId) {
         $response->setTitle(JText::_('COM_CROWDFUNDINGFILES_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFILES_ERROR_NOT_LOG_IN'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     // Get file ID.
     $fileId = $this->input->post->get("id");
     // Get the folder where the images are stored.
     $mediaFolder = CrowdfundingFilesHelper::getMediaFolder($userId);
     try {
         // Get the model
         $model = $this->getModel();
         /** @var $model CrowdfundingFilesModelFiles */
         $model->removeFile($fileId, $mediaFolder, $userId);
     } catch (RuntimeException $e) {
         $response->setTitle(JText::_('COM_CROWDFUNDINGFILES_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFILES_ERROR_INVALID_PROJECT'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception($e->getMessage());
     }
     $response->setTitle(JText::_('COM_CROWDFUNDINGFILES_SUCCESS'))->setText(JText::_('COM_CROWDFUNDINGFILES_FILE_DELETED'))->setData(array("file_id" => $fileId))->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Пример #7
0
<?php

/**
 * @package      CrowdfundingFiles
 * @subpackage   Component
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2014 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
// no direct access
defined('_JEXEC') or die;
foreach ($this->items as $i => $item) {
    $mediaFolder = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id);
    ?>
    <tr class="row<?php 
    echo $i % 2;
    ?>
">
        <td class="center hidden-phone">
            <?php 
    echo JHtml::_('grid.id', $i, $item->id);
    ?>
        </td>
        <td class="has-context">
            <a href="<?php 
    echo JRoute::_("index.php?option=com_crowdfundingfiles&view=file&layout=edit&id=" . $item->id);
    ?>
">
            <?php 
    echo $this->escape($item->title);
    ?>