示例#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
文件: files.php 项目: pashakiz/crowdf
 /**
  * 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;
 }