コード例 #1
0
ファイル: controller.php プロジェクト: site4com/prometheus
 /**
  * Return the attachments list as HTML (for use by Ajax)
  */
 public function attachmentsList()
 {
     $parent_id = JRequest::getInt('parent_id', false);
     $parent_type = JRequest::getWord('parent_type', '');
     $parent_entity = JRequest::getWord('parent_entity', 'default');
     $show_links = JRequest::getBool('show_links', true);
     $allow_edit = JRequest::getBool('allow_edit', true);
     $from = JRequest::getWord('from', 'closeme');
     $title = '';
     $response = '';
     if ($parent_id === false || $parent_type == '') {
         return '';
     }
     // Allow remapping of parent ID (eg, for Joomfish)
     $lang = JRequest::getWord('lang', '');
     if ($lang and jimport('attachments_remapper.remapper')) {
         $parent_id = AttachmentsRemapper::remapParentID($parent_id, $parent_type, $parent_entity);
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_attachments/controllers/list.php';
     $controller = new AttachmentsControllerList();
     $response = $controller->displayString($parent_id, $parent_type, $parent_entity, $title, $show_links, $allow_edit, false, $from);
     echo $response;
 }
コード例 #2
0
ファイル: default.php プロジェクト: appukonrad/attachments
echo $this->from;
?>
" />
<input type="hidden" name="task" value="attachment.edit" />
<?php 
if ($this->in_popup) {
    ?>
<div class="form_buttons" align="center">
	<input type="submit" name="submit" onclick="javascript: submitbutton('attachment.save')" value="<?php 
    echo JText::_('ATTACH_SAVE');
    ?>
" />
	<span class="right"><input type="button" name="cancel" value="<?php 
    echo JText::_('ATTACH_CANCEL');
    ?>
"
			  onClick="window.parent.SqueezeBox.close();" /></span>
</div>
<?php 
}
echo JHtml::_('form.token');
?>
</form>
<?php 
// Show the existing attachments (if any)
if ($attachment->parent_id and $update == 'file') {
    /** Get the attachments controller class */
    require_once JPATH_ADMINISTRATOR . '/components/com_attachments/controllers/list.php';
    $controller = new AttachmentsControllerList();
    $controller->displayString($attachment->parent_id, $attachment->parent_type, $attachment->parent_entity, 'ATTACH_EXISTING_ATTACHMENTS', false, false, true, $this->from);
}
コード例 #3
0
ファイル: helper.php プロジェクト: appukonrad/attachments
 /**
  * Construct and return the attachments list (as HTML)
  *
  * @param int $parent_id the id of the parent
  * @param string $parent_type the type of the parent (usually $option)
  * @param string $parent_entity the parent entity
  * @param bool $user_can_add true if the user can add attachments to this parent
  * @param int $Itemid the system item id (for menus)
  * @param string $from a token indicating where to return to
  * @param bool $show_file_links true if the files should be shown as links
  * @param bool $allow_edit true if the user can edit/delete attachments for this parent
  *
  * @return the html as a string
  */
 public static function attachmentsListHTML($parent_id, $parent_type, $parent_entity, $user_can_add, $Itemid, $from, $show_file_links = true, $allow_edit = true)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $user_levels = implode(',', array_unique($user->getAuthorisedViewLevels()));
     // Make sure there are some potentially accessible attachments for
     // this parent before proceeding.  Note that this check is not as
     // careful as the check in the Attachments model which is used by
     // the 'Attachments' view which is invoked below.
     $alist = '';
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('count(*)')->from('#__attachments');
     $query->where('((parent_id=' . (int) $parent_id . ') OR (parent_id is NULL))' . ' AND parent_type=' . $db->quote($parent_type) . ' AND parent_entity=' . $db->quote($parent_entity));
     if (!$user->authorise('core.admin')) {
         $query->where('access in (' . $user_levels . ')');
     }
     $db->setQuery($query);
     $total = $db->loadResult();
     if ($db->getErrorNum()) {
         $errmsg = $db->stderr() . ' (ERR 47)';
         JError::raiseError(500, $errmsg);
     }
     // Generate the HTML for the attachments for the specified parent
     if ($total > 0) {
         // Get the component parameters
         jimport('joomla.application.component.helper');
         $params = JComponentHelper::getParams('com_attachments');
         // Check the security status
         $attach_dir = JPATH_SITE . '/' . AttachmentsDefines::$ATTACHMENTS_SUBDIR;
         $secure = $params->get('secure', false);
         $hta_filename = $attach_dir . '/.htaccess';
         if ($secure && !file_exists($hta_filename) || !$secure && file_exists($hta_filename)) {
             require_once JPATH_SITE . '/components/com_attachments/helper.php';
             AttachmentsHelper::setup_upload_directory($attach_dir, $secure);
         }
         if ($app->isAdmin()) {
             // Get the html for the attachments list
             require_once JPATH_ADMINISTRATOR . '/components/com_attachments/controllers/list.php';
             $controller = new AttachmentsControllerList();
             $alist = $controller->displayString($parent_id, $parent_type, $parent_entity, null, $show_file_links, $allow_edit, false, $from);
         } else {
             // Get the html for the attachments list
             require_once JPATH_SITE . '/components/com_attachments/controllers/attachments.php';
             $controller = new AttachmentsControllerAttachments();
             $alist = $controller->displayString($parent_id, $parent_type, $parent_entity, null, $show_file_links, $allow_edit, false, $from);
         }
     }
     return $alist;
 }