Ejemplo n.º 1
1
 public function uploader()
 {
     error_reporting(0);
     JLoader::register('PluploadHandler', JPATH_SITE . '/components/com_judownload/helpers/pluploadhandler.php');
     $targetDir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/") . "tmp";
     $cleanupTargetDir = true;
     $maxFileAge = 5 * 3600;
     $this->cleanup($targetDir, $maxFileAge);
     if (!JFolder::exists($targetDir)) {
         JFolder::create($targetDir);
         $indexHtml = $targetDir . 'index.html';
         $buffer = "<!DOCTYPE html><title></title>";
         JFile::write($indexHtml, $buffer);
     }
     if (!is_writable($targetDir)) {
         $targetDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "plupload";
         if (!file_exists($targetDir)) {
             @mkdir($targetDir);
         }
     }
     PluploadHandler::no_cache_headers();
     PluploadHandler::cors_headers();
     if (!PluploadHandler::handle(array('target_dir' => $targetDir, 'cleanup' => $cleanupTargetDir, 'max_file_age' => $maxFileAge, 'cb_check_file' => array(__CLASS__, 'canUpload')))) {
         die(json_encode(array('OK' => 0, 'error' => array('code' => PluploadHandler::get_error_code(), 'message' => PluploadHandler::get_error_message()))));
     } else {
         die(json_encode(array('OK' => 1)));
     }
 }
Ejemplo n.º 2
0
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $directory = JUDownloadFrontHelper::getDirectory((string) $this->element['rel'], (string) $this->element['defaultRel']) . "default/";
         $this->directory = $directory;
     }
     return $return;
 }
Ejemplo n.º 3
0
	public function parseValue($value)
	{
		if ($value && is_numeric($value))
		{
			return JUDownloadFrontHelper::getLicense($value, '*', false);
		}

		return null;
	}
Ejemplo n.º 4
0
	protected function _prepareDocument()
	{
		$uri = clone JUri::getInstance();
		
		$domain        = $uri->toString(array('scheme', 'host', 'port'));
		$canonicalLink = $domain . JRoute::_(JUDownloadHelperRoute::getLicenseRoute($this->item->id, true, $this->_layout), false);
		JUDownloadFrontHelper::setCanonical($canonicalLink);

		
		JUDownloadFrontHelperSeo::seo($this);
	}
Ejemplo n.º 5
0
	public static function getJUAvatar($id)
	{
		$user = JUDownloadFrontHelper::getUser($id, true);
		if ($user && isset($user->avatar))
		{
			$avatar = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('avatar_directory', 'media/com_judownload/images/avatar/', true) . $user->avatar;
		}
		else
		{
			$avatar = self::getDefaultAvatar();
		}

		return $avatar;
	}
Ejemplo n.º 6
0
	public function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		$params = JUDownloadHelper::getParams();
		$this->setState('params', $params);

		
		if ($this->context)
		{
			$commentPagination = $params->get('comment_pagination', 10);

			$limitArray = JUDownloadFrontHelper::customLimitBox();

			if (is_array($limitArray) && count($limitArray))
			{
				$limit = $app->input->getUint('limit', null);
				if (is_null($limit) || in_array($limit, $limitArray))
				{
					$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $commentPagination, 'uint');
				}
				else
				{
					$limit = $commentPagination;
				}
			}
			else
			{
				$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $commentPagination, 'uint');
			}

			$this->setState('list.limit', $limit);

			$this->setState('list.start', $app->input->get('limitstart', 0, 'uint'));

			$commentOrdering = $params->get('comment_ordering', 'cm.created');
			$orderCol        = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', $commentOrdering);
			$this->setState('list.ordering', $orderCol);

			$commentDirection = $params->get('comment_direction', 'DESC');
			$listOrder        = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', $commentDirection);
			$this->setState('list.direction', $listOrder);
		}
		else
		{
			$this->setState('list.start', 0);
			$this->state->set('list.limit', 0);
		}
	}
Ejemplo n.º 7
0
	public function search()
	{
		
		JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));

		$app        = JFactory::getApplication();
		$searchWord = $app->input->post->getString('searchword', '');
		$cat_id     = $app->input->post->getInt('cat_id', 0);
		$sub_cat    = $app->input->post->getInt('sub_cat', 0);
		
		$searchWord = JUDownloadFrontHelper::UrlEncode($searchWord);

		$this->setRedirect(JRoute::_(JUDownloadHelperRoute::getSearchRoute($cat_id, $sub_cat, $searchWord), false));
	}
Ejemplo n.º 8
0
	protected function _prepareDocument()
	{
		$uri = clone JUri::getInstance();
		
		$domain        = $uri->toString(array('scheme', 'host', 'port'));
		$canonicalLink = $domain . JRoute::_(JUDownloadHelperRoute::getMaintenanceRoute(true, $this->_layout), false);
		JUDownloadFrontHelper::setCanonical($canonicalLink);

		$seoData = array(
			"metatitle"       => JText::_('COM_JUDOWNLOAD_SEO_TITLE_MAINTENANCE'),
			"metadescription" => "",
			"metakeyword"     => ""
		);
		JUDownloadFrontHelperSeo::seo($this, $seoData);
	}
Ejemplo n.º 9
0
 protected function getInput()
 {
     $params = JUDownloadHelper::getParams();
     $max_upload = ini_get('upload_max_filesize');
     $src = JUri::root() . JUDownloadFrontHelper::getDirectory("collection_icon_directory", "media/com_judownload/images/collection/", true) . $this->value;
     $html = "<div class=\"avatar\" style=\"float: left;\">";
     if ($this->value) {
         $html .= "<div class=\"clearfix\"><img src=\"" . $src . "\" width=\"" . $params->get('collection_icon_width', 100) . "px\" height=\"" . $params->get('collection_icon_height', 100) . "px\" /></div>";
         $html .= "<label><input type=\"checkbox\" name=\"remove_icon\" value=\"1\" />&nbsp;" . JText::_('COM_JUDOWNLOAD_REMOVE_ICON') . "</label>";
     }
     $html .= "<div class=\"clearfix\"><input type=\"file\" name=\"collection_icon\"  id=\"" . $this->id . "\" />";
     $html .= "<input type=\"hidden\" name=\"" . $this->name . "\" value=\"" . $this->value . "\" /></div>";
     $html .= "<div class=\"clearfix\"><i>" . JText::_('COM_JUDOWNLOAD_MAX_UPLOAD_FILESIZE') . " <strong>" . JUDownloadHelper::formatBytes($this->convertBytes($max_upload)) . "</strong></i></div>";
     $html .= "</div>";
     return $html;
 }
Ejemplo n.º 10
0
	public function display($tpl = null)
	{
		
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode('<br />', $errors));

			return false;
		}

		$app = JFactory::getApplication();

		$this->type = $app->input->get('type', '');

		if (!$this->type || $this->type == 'icon')
		{
			$this->icon_url       = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("document_image_directory", "media/com_judownload/images/document/", true) . "default/";
			$this->icon_directory = JPath::clean(JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_image_directory", "media/com_judownload/images/document/") . "default/");
		}
		elseif ($this->type == 'marker')
		{
			$this->icon_url       = JUri::root(true) . "/media/com_judownload/markers/";
			$this->icon_directory = JPath::clean(JPATH_ROOT . "/media/com_judownload/images/markers/");
		}

		$this->folders = $this->getFolders();
		$this->folder  = $app->input->get('folder', '', 'string');
		
		if (!in_array($this->folder, $this->folders))
		{
			$this->folder = '';
		}

		$this->icons = $this->getIcons();

		

		$this->setDocument();

		
		parent::display($tpl);
	}
Ejemplo n.º 11
0
 protected function getInput()
 {
     $params = JUDownloadHelper::getParams();
     $max_upload = ini_get('upload_max_filesize');
     if ($this->value) {
         $src = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("avatar_directory", "media/com_judownload/images/avatar/", true) . $this->value;
     } else {
         $src = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("avatar_directory", "media/com_judownload/images/avatar/", true) . "default/" . $params->get('default_avatar', 'default-avatar.png');
     }
     $html = '<div class="avatar" style="float: left;">';
     $html .= '<div class="clearfix"><img src="' . $src . '" alt="Avatar" style="width:' . $params->get("avatar_width", 120) . 'px; height:' . $params->get("avatar_height", 120) . 'px;" /></div>';
     if ($this->value) {
         $html .= '<label for="remove-avatar">' . JText::_("COM_JUDOWNLOAD_REMOVE_AVATAR") . '&nbsp;<input id="remove-avatar" type="checkbox" name="remove_avatar" value="1" /></label>';
     }
     $html .= '<div class="clearfix"><input type="file" name="avatar"  id="' . $this->id . '" />';
     $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" /></div>';
     $html .= '<div class="clearfix"><i>' . JText::_("COM_JUDOWNLOAD_MAX_UPLOAD_FILESIZE") . ' <strong>' . JUDownloadHelper::formatBytes($this->convertBytes($max_upload)) . '</strong></i></div>';
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 12
0
	protected function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		$params = JUDownloadHelper::getParams();
		$this->setState('params', $params);

		
		if ($this->context)
		{
			$limitArray = JUDownloadFrontHelper::customLimitBox();

			if (is_array($limitArray) && count($limitArray))
			{
				$limit = $app->input->getUint('limit', null);
				if (is_null($limit) || in_array($limit, $limitArray))
				{
					$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
				}
				else
				{
					$limit = $app->getCfg('list_limit');
				}
			}
			else
			{
				$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
			}

			$this->setState('list.limit', $limit);

			$this->setState('list.start', $app->input->get('limitstart', 0, 'uint'));

			$orderCol = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', 'tag.title');
			$this->setState('list.ordering', $orderCol);

			$listOrder = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', 'ASC');
			$this->setState('list.direction', $listOrder);
		}
	}
Ejemplo n.º 13
0
	protected function _prepareDocument()
	{
		$app           = JFactory::getApplication();
		$parent_cat_id = $app->input->getInt('parent_cat_id', 0);
		$uri           = clone JUri::getInstance();
		
		$domain        = $uri->toString(array('scheme', 'host', 'port'));
		$linkCanonical = $domain . JRoute::_(JUDownloadHelperRoute::getSearchRoute($this->cat_id, $parent_cat_id, $this->searchword, true, $this->_layout), false);
		JUDownloadFrontHelper::setCanonical($linkCanonical);

		$seoData = array(
			"metatitle"       => JText::_('COM_JUDOWNLOAD_SEO_TITLE_SEARCH'),
			"metadescription" => "",
			"metakeyword"     => ""
		);
		JUDownloadFrontHelperSeo::seo($this, $seoData);
	}
Ejemplo n.º 14
0
 public function getLatestCommentTime($docId = 0)
 {
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('created')->from('#__judownload_comments')->order('id DESC');
     if ($docId > 0) {
         $query->where('doc_id = ' . $docId);
     }
     if ($user->id > 0) {
         $query->where('user_id =' . $user->id);
     } else {
         $ipAddress = JUDownloadFrontHelper::getIpAddress();
         $query->where('ip_address = "' . $ipAddress . '"');
     }
     $db->setQuery($query, 0, 1);
     $result = $db->loadResult();
     return $result;
 }
Ejemplo n.º 15
0
	public static function getDocumentsSearch($searchword, $state, $cat_id = null)
	{
		
		$searchword = trim($searchword);

		$app        = JFactory::getApplication();
		$user       = JFactory::getUser();
		$levels     = $user->getAuthorisedViewLevels();
		$levels_str = implode(',', $levels);
		$db         = JFactory::getDbo();
		$nullDate   = $db->getNullDate();
		$nowDate    = JFactory::getDate()->toSql();
		$query      = $db->getQuery(true);

		$listOrder = $state->get('list.ordering');
		$listDirn  = $state->get('list.direction');
		
		if ($app->isAdmin())
		{
			$query->SELECT('d.id, d.title, d.alias, d.published, d.publish_up, d.publish_down, d.checked_out, d.checked_out_time, d.featured, d.access, d.created_by, d.downloads, d.language');

			$query->SELECT('c.id AS category_id, c.title AS category_title');

			$where_str = $app->isSite() ? ' AND cm.published = 1' : '';
			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_comments AS cm WHERE (cm.doc_id = d.id AND cm.approved = 1' . $where_str . ')) AS comments');

			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_reports AS r WHERE r.item_id = d.id AND r.type="document") AS reports');

			$where_str = $app->isSite() ? ' AND s.published = 1' : '';
			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_subscriptions AS s WHERE s.item_id = d.id AND s.type="document"' . $where_str . ') AS subscriptions');

			$query->SELECT('ua.name AS created_by_name');
			$query->JOIN("LEFT", "#__users AS ua ON d.created_by = ua.id");

			$query->SELECT('ua3.name AS checked_out_name');
			$query->JOIN("LEFT", "#__users AS ua3 ON d.checked_out = ua3.id");

			$query->SELECT("vl.title AS access_title");
			$query->JOIN("LEFT", "#__viewlevels AS vl ON d.access = vl.id");
		}
		
		else
		{
			$query->SELECT('d.*');
			if ($app->isSite())
			{
				JUDownloadFrontHelper::optimizeListDocumentQuery($query);
			}
		}

		$query->FROM('#__judownload_documents AS d');
		$query->JOIN('', '#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id');
		$query->JOIN('', '#__judownload_categories AS c ON (c.id = dxref.cat_id)');

		
		$field_query = $db->getQuery(true);
		
		$field_query->select("field.*");
		$field_query->from("#__judownload_fields AS field");
		$field_query->select("plg.folder");
		$field_query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
		$field_query->join("", "#__judownload_fields_groups AS field_group ON field_group.id = field.group_id");
		$field_query->join("", "#__judownload_categories AS c2 ON (c2.fieldgroup_id = field_group.id OR field.group_id = 1)");
		if ($app->isSite())
		{
			if (is_array($cat_id))
			{
				$cat_id = (array) $cat_id;
				$field_query->where('(c2.id IN (' . implode(",", $cat_id) . ') OR field.group_id = 1)');
			}
			elseif ($cat_id)
			{
				$cat_id = (int) $cat_id;
				$field_query->where('(c2.id = ' . $cat_id . ' OR field.group_id = 1)');
			}
			$field_query->where('c2.published = 1');
			$field_query->where('c2.publish_up <= ' . $db->quote($nowDate));
			$field_query->where('(c2.publish_down = ' . $db->quote($nullDate) . ' OR c2.publish_down > ' . $db->quote($nowDate) . ')');
		}
		
		$field_query->where('field.simple_search = 1');
		$field_query->where('field.published = 1');
		$field_query->where('field.publish_up <= ' . $db->quote($nowDate));
		$field_query->where('(field.publish_down = ' . $db->quote($nullDate) . ' OR field.publish_down > ' . $db->quote($nowDate) . ')');
		$field_query->where('(field.field_name != "cat_id"');
		$field_query->where("field_group.published = 1)");
		$field_query->group('field.id');
		$db->setQuery($field_query);
		$fields = $db->loadObjectList();
		$where  = array();
		if ($fields)
		{
			foreach ($fields AS $field)
			{
				if ($searchword)
				{
					$fieldClass = JUDownloadFrontHelperField::getField($field);
					$fieldClass->onSimpleSearch($query, $where, $searchword);
				}
			}

			if (!empty($where))
			{
				$query->WHERE("(" . implode(" OR ", $where) . ")");
			}
		}

		$app = JFactory::getApplication();
		if ($app->isAdmin())
		{
			$published = $state->get('filter.state');
			if (is_numeric($published))
			{
				$query->WHERE('d.published = ' . (int) $published);
			}

			$cat_id = $state->get('filter.category');
			if (is_numeric($cat_id))
			{
				$query->WHERE('dxref.cat_id = ' . (int) $cat_id);
			}

			$access_level = $state->get('filter.access');
			if (is_numeric($access_level) && ($access_level != 0))
			{
				$query->WHERE('d.access = ' . (int) $access_level);
			}

			
			$language = $state->get('filter.language');
			if ($language)
			{
				$query->where('d.language = ' . $db->quote($language));
			}
		}
		else
		{
			$query->where('d.published = 1');
			if ($cat_id)
			{
				if (is_array($cat_id))
				{
					$cat_id = (array) $cat_id;
					$query->where('c.id IN (' . implode(",", $cat_id) . ')');
				}
				elseif ($cat_id)
				{
					$cat_id = (int) $cat_id;
					$query->where('c.id = ' . $cat_id);
				}
			}

			$query->where('d.publish_up <= ' . $db->quote($nowDate));
			$query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down > ' . $db->quote($nowDate) . ')');

			
			if ($user->get('guest'))
			{
				$query->where('d.access IN (' . $levels_str . ')');
			}
			else
			{
				$query->where('(d.access IN (' . $levels_str . ') OR (d.created_by = ' . $user->id . '))');
			}
		}

		$query->where('d.approved = 1');

		JUDownloadFrontHelperField::appendFieldOrderingPriority($query, null, $listOrder, $listDirn);

		
		$query->group('d.id');

		return $query;
	}
Ejemplo n.º 16
0
/**
 * ------------------------------------------------------------------------
 * JUDownload for Joomla 2.5, 3.x
 * ------------------------------------------------------------------------
 *
 * @copyright      Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 * @author         JoomUltra Co., Ltd
 * @website        http://www.joomultra.com
 * @----------------------------------------------------------------------@
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$this->model->uploadFileScript($this->item->id, "#judl-files");
$file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
?>
<fieldset class="adminform">
	<div id="judl-files" class="judl-files">
		<ul id="file-list" class="file-list nav clearfix">
			<?php 
if ($this->files) {
    $canChangeDownloads = '';
    if (!JFactory::getUser()->authorise('core.admin', 'com_judownload')) {
        $canChangeDownloads = 'readonly="readonly"';
    }
    foreach ($this->files as $key => $file) {
        if ($file['id']) {
            $file_exists = JFile::exists($file_directory . $this->item->id . "/" . $file['file_name']);
        }
        ?>
Ejemplo n.º 17
0
	public function getItems()
	{
		$params             = $this->getState('params');
		$documentObjectList = parent::getItems();

		JUDownloadFrontHelper::appendDataToDocumentObjList($documentObjectList, $params);

		return $documentObjectList;
	}
Ejemplo n.º 18
0
 * JUDownload for Joomla 2.5, 3.x
 * ------------------------------------------------------------------------
 *
 * @copyright      Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 * @author         JoomUltra Co., Ltd
 * @website        http://www.joomultra.com
 * @----------------------------------------------------------------------@
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<script type="text/javascript">
	var default_icon = "<?php echo JUDownloadHelper::getDefaultDocumentIcon(); ?>";
	var document_icon_url = "<?php echo JUri::root(true) . "/". JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/", true); ?>";
	function jSelectDocument_related() {
		var $ul = jQuery(".related-document-list").find(".related-documents");
		var $document = $ul.find("li#document-" + arguments[0]);
		if (!$document.length && arguments[0] != <?php echo (int)$this->item->id; ?>) {
			var $li = '<li id="document-' + arguments[0] + '">';
			$li += '<div class="document-inner">';
			var icon_src = arguments[2] ? document_icon_url + arguments[2] : default_icon;
			if (icon_src) {
				$li += '<img class="image" src="' + icon_src + '" title="' + arguments[1] + '" width="<?php echo $this->params->get('document_icon_width', 150)?>px" height="<?php echo $this->params->get('document_icon_height', 150); ?>px" />';
			}
			var href = 'index.php?option=com_judownload&task=document.edit&id=' + arguments[0];
			$li += '<a class="rel-document-title" target="_blank" href="' + href + '">' + arguments[1] + '</a>';
			$li += '<a class="remove-rel-document" href="#" title="<?php echo JText::_('COM_JUDOWNLOAD_REMOVE_DOCUMENT'); ?>" ><?php echo JText::_('COM_JUDOWNLOAD_REMOVE_DOCUMENT'); ?></a>';
			$li += '<input type="hidden" name="related_documents[]" value="' + arguments[0] + '" />';
			$li += '</div>';
Ejemplo n.º 19
0
	public function getOutput($options = array())
	{
		if (!$this->isPublished())
		{
			return "";
		}

		$_value = $this->value;

		if ($_value == "")
		{
			return "";
		}

		$value = '';
		if ($_value)
		{
			$predefined_values = $this->getPredefinedValues();

			
			foreach ($predefined_values AS $option)
			{
				if ($option->value == $_value)
				{
					
					if ($this->params->get("tag_search", 0))
					{
						$value = "<a href =\"" . JRoute::_("index.php?option=com_judownload&view=searchby&field_id=" . $this->id . "&value=" . JUDownloadFrontHelper::UrlEncode($option->value)) . "\">" . $option->text . "</a>";
					}
					else
					{
						$value = $option->text;
					}

					break;
				}
			}
		}

		$this->setVariable('value', $value);

		return $this->fetch('output.php', __CLASS__);
	}
Ejemplo n.º 20
0
	protected function removeIcon()
	{
		$iconDirectory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/");

		
		if (JFile::exists($iconDirectory . $this->doc->icon))
		{
			JFile::delete($iconDirectory . $this->doc->icon);
		}

		if (JFile::exists($iconDirectory . "original/" . $this->doc->icon))
		{
			JFile::delete($iconDirectory . "original/" . $this->doc->icon);
		}
	}
Ejemplo n.º 21
0
	protected function _prepareDocument()
	{
		$document = JFactory::getDocument();
		$uri      = clone JUri::getInstance();

		
		$domain        = $uri->toString(array('scheme', 'host', 'port'));
		$canonicalLink = $domain . JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id, $this->_layout), false);

		JUDownloadFrontHelper::setCanonical($canonicalLink);

		$imageUrl = JUDownloadHelper::getDocumentIcon($this->item->icon);
		
		$document->addCustomTag('<meta property="og:title" content="' . $this->item->title . '" />');
		$document->addCustomTag('<meta property="og:type" content="website" />');
		if ($imageUrl)
		{
			$document->addCustomTag('<meta property="og:image" content="' . JUri::root(true) . "/media/com_judownload/images/document/" . $this->item->icon . '" />');
		}
		$document->addCustomTag('<meta property="og:url" content="' . $canonicalLink . '" />');

		JUDownloadFrontHelperSeo::seo($this);
	}
Ejemplo n.º 22
0
		{
			$class = "";
		}

		$description = '';
		if ($image->title)
		{
			$description .= "<h4 class='img-title'>" . htmlspecialchars($image->title, ENT_QUOTES) . "</h4>";
		}

		if ($image->description)
		{
			$description .= "<div class='img-description'>" . htmlspecialchars($image->description, ENT_QUOTES) . '</div>';
		}
		?>
		<li class="image<?php echo $class; ?>">
			<a href="<?php echo JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('document_big_image_directory', 'media/com_judownload/images/gallery/big/', true) . $this->doc_id . '/' . $image->file_name; ?>"
			   class="fancybox" rel="gallery">
				<img
					src="<?php echo JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('document_small_image_directory', 'media/com_judownload/images/gallery/small/', true) . $this->doc_id . '/' . $image->file_name; ?>"
					width="<?php echo $params->get('document_small_image_width', 100); ?>"
					height="<?php echo $params->get('document_small_image_height', 100); ?>"
					alt="<?php echo htmlspecialchars($image->title, ENT_QUOTES); ?>"/>
			</a>

			<div class="title" style="display: none;"><?php echo $description; ?></div>
		</li>
	<?php
	} ?>
</ul>
Ejemplo n.º 23
0
 protected function prepareTable($table)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if (empty($table->id)) {
         if (!$table->created) {
             $table->created = $date->toSql();
         }
         if (!$table->guest_name || !$table->guest_email) {
             $table->user_id = $user->id;
         }
         if (!$table->ip_address) {
             $table->ip_address = JUDownloadFrontHelper::getIpAddress();
         }
     } else {
         $table->modified_by = $user->id;
         $table->modified = $date->toSql();
     }
 }
Ejemplo n.º 24
0
 public function delete(&$pks)
 {
     $dispatcher = JDispatcher::getInstance();
     $pks = (array) $pks;
     $table = $this->getTable();
     JPluginHelper::importPlugin('content');
     $modelDocument = JModelLegacy::getInstance('Document', 'JUDownloadModel');
     $documentTable = JTable::getInstance("Document", "JUDownloadTable");
     $canDeleteCatIds = $canNotDeleteCatIds = $canDeleteDocIds = $canNotDeleteDocIds = array();
     $db = JFactory::getDbo();
     while (!empty($pks)) {
         $pk = array_shift($pks);
         $table->reset();
         if ($table->load($pk)) {
             $deleteCurrentCat = true;
             if ($this->canDelete($table)) {
                 $query = $db->getQuery(true);
                 $query->SELECT('doc_id');
                 $query->FROM('#__judownload_documents_xref');
                 $query->WHERE('cat_id=' . $pk . ' AND main=1');
                 $db->setQuery($query);
                 $docIds = $db->loadColumn();
                 if ($docIds) {
                     foreach ($docIds as $docId) {
                         $documentTable->reset();
                         if ($documentTable->load($docId)) {
                             if ($modelDocument->canDelete($documentTable)) {
                                 $canDeleteDocIds[] = $docId;
                             } else {
                                 $canNotDeleteDocIds[] = $docId;
                                 $deleteCurrentCat = false;
                             }
                         }
                     }
                 }
             } else {
                 $deleteCurrentCat = false;
             }
             if (!$deleteCurrentCat) {
                 $canNotDeleteCatIds[] = $pk;
             } else {
                 $canDeleteCatIds[] = $pk;
             }
             $query = $db->getQuery(true);
             $query->select('id');
             $query->from('#__judownload_categories');
             $query->where('lft > ' . (int) $table->lft);
             $query->where('rgt < ' . (int) $table->rgt);
             $query->order('lft');
             $db->setQuery($query);
             $childIds = $db->loadColumn();
             foreach ($childIds as $childId) {
                 if (!in_array($childId, $pks)) {
                     array_push($pks, $childId);
                 }
             }
         }
     }
     if ($canNotDeleteCatIds) {
         foreach ($canNotDeleteCatIds as $caNotDeleteCatId) {
             $categories = $table->getPath($caNotDeleteCatId);
             if ($categories) {
                 foreach ($categories as $category) {
                     $canDeleteCatIdIndex = array_search($category->id, $canDeleteCatIds);
                     if ($canDeleteCatIdIndex !== false) {
                         unset($canDeleteCatIds[$canDeleteCatIdIndex]);
                         $canNotDeleteCatIds[] = $category->id;
                     }
                 }
             }
         }
     }
     $canDeleteDocIds = array_unique($canDeleteDocIds);
     if ($canDeleteDocIds) {
         foreach ($canDeleteDocIds as $docId) {
             if (!$documentTable->delete($docId)) {
                 $this->setError($documentTable->getError());
                 return false;
             }
         }
     }
     $canDeleteCatIds = array_unique($canDeleteCatIds);
     if ($canDeleteCatIds) {
         foreach ($canDeleteCatIds as $pk) {
             if ($table->load($pk)) {
                 $context = $this->option . '.' . $this->name;
                 $result = $dispatcher->trigger($this->event_before_delete, array($context, $table));
                 if (in_array(false, $result, true)) {
                     $this->setError($table->getError());
                     return false;
                 }
                 if (!$table->delete($pk, false)) {
                     $this->setError($table->getError());
                     return false;
                 } else {
                     $query = "DELETE FROM #__judownload_categories_relations WHERE cat_id=" . $pk;
                     $db->setQuery($query);
                     $db->execute();
                     $query = "DELETE FROM #__judownload_documents_xref WHERE main=0 AND cat_id=" . $pk;
                     $db->setQuery($query);
                     $db->execute();
                     $query = "SELECT mod_id FROM #__judownload_moderators_xref WHERE cat_id = " . $pk;
                     $db->setQuery($query);
                     $moderatorIds = $db->loadColumn();
                     $query = "DELETE FROM #__judownload_moderators_xref WHERE cat_id=" . $pk;
                     $db->setQuery($query);
                     $db->execute();
                     if ($moderatorIds) {
                         $modTable = JTable::getInstance("Moderator", "JUDownloadTable");
                         foreach ($moderatorIds as $moderatorId) {
                             $query = $db->getQuery(true);
                             $query->select('COUNT(*)');
                             $query->from('#__judownload_moderators AS m');
                             $query->join('', '#__judownload_moderators_xref AS mxref ON m.id = mxref.mod_id');
                             $query->where('m.id =' . $moderatorId);
                             $db->setQuery($query);
                             $totalModeratedCats = $db->loadResult();
                             if ($totalModeratedCats <= 0) {
                                 $modTable->reset();
                                 if ($modTable->load(array($moderatorId))) {
                                     $modTable->delete();
                                 }
                             }
                         }
                     }
                     $images = json_decode($table->images);
                     if (is_object($images)) {
                         if ($images->intro_image) {
                             $intro_image = JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/') . $images->intro_image;
                             $ori_intro_image = JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/') . "original/" . $images->intro_image;
                             if (JFile::exists(JPATH_ROOT . "/" . $ori_intro_image)) {
                                 JFile::delete(JPATH_ROOT . "/" . $ori_intro_image);
                             }
                             if (JFile::exists(JPATH_ROOT . "/" . $intro_image)) {
                                 JFile::delete(JPATH_ROOT . "/" . $intro_image);
                             }
                         }
                         if ($images->detail_image) {
                             $detail_image = JUDownloadFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judownload/images/category/detail/') . $images->detail_image;
                             $ori_detail_image = JUDownloadFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judownload/images/category/detail/') . "original/" . $images->detail_image;
                             if (JFile::exists(JPATH_ROOT . "/" . $detail_image)) {
                                 JFile::delete(JPATH_ROOT . "/" . $detail_image);
                             }
                             if (JFile::exists(JPATH_ROOT . "/" . $ori_detail_image)) {
                                 JFile::delete(JPATH_ROOT . "/" . $ori_detail_image);
                             }
                         }
                     }
                     if ($table->level == 0 || $table->level == 1) {
                         $query = "DELETE FROM #__judownload_emails_xref WHERE cat_id = " . $table->id;
                         $db->setQuery($query);
                         $db->execute();
                     }
                     JUDownloadHelper::deleteLogs('category', $pk);
                     $query = "DELETE FROM #__judownload_fields_ordering WHERE `item_id` = " . $table->id . " AND `type` = 'category'";
                     $db->setQuery($query);
                     $db->execute();
                     $dispatcher->trigger($this->event_after_delete, array($context, $table));
                 }
             }
         }
     }
     if ($canDeleteCatIds) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::plural('COM_JUDOWNLOAD_CATEGORIES_N_ITEMS_DELETED', count($canDeleteCatIds)));
     }
     $canNotDeleteCatIds = array_unique($canNotDeleteCatIds);
     if ($canNotDeleteCatIds) {
         JError::raiseWarning(500, JText::plural('COM_JUDOWNLOAD_CATEGORIES_N_ITEMS_NOT_DELETED', count($canNotDeleteCatIds)));
     }
     $this->cleanCache();
     return true;
 }
Ejemplo n.º 25
0
 public function getExportData($exportColumns, $filter)
 {
     $db = JFactory::getDbo();
     $exportData = array();
     $selectFields = $this->getDocumentTableFieldsName();
     foreach ($selectFields as $index => $field) {
         if ($field == 'id') {
             continue;
         }
         if (isset($this->field_name_id_array[$field])) {
             $fieldId = $this->field_name_id_array[$field];
             if (!in_array($fieldId, $exportColumns)) {
                 unset($selectFields[$index]);
             } else {
                 $indexField = array_search($fieldId, $exportColumns);
                 unset($exportColumns[$indexField]);
             }
         } else {
             if (!in_array($field, $exportColumns)) {
                 unset($selectFields[$index]);
             } else {
                 $indexField = array_search($field, $exportColumns);
                 unset($exportColumns[$indexField]);
             }
         }
     }
     if (in_array($this->field_name_id_array['description'], $exportColumns)) {
         $selectFields[] = 'introtext';
         $selectFields[] = 'fulltext';
         $indexField = array_search($this->field_name_id_array['description'], $exportColumns);
         unset($exportColumns[$indexField]);
     }
     $query = $this->_prepareQuery($selectFields, $filter);
     $limit = 0;
     if (!empty($filter['csv_limit_export']) && is_numeric($filter['csv_limit_export'])) {
         $limit = $filter['csv_limit_export'];
     }
     $db->setQuery($query, 0, $limit);
     $documents = $db->loadObjectList();
     if (!empty($documents)) {
         foreach ($documents as $document) {
             $docId = $document->id;
             $mainCatId = JUDownloadFrontHelperCategory::getMainCategoryId($docId);
             $data = get_object_vars($document);
             if (!in_array($this->field_name_id_array['id'], $exportColumns)) {
                 unset($data['id']);
             }
             if (isset($data['introtext'])) {
                 $data['description'] = !empty($data['fulltext']) ? $data['introtext'] . "<hr id=\"system-readmore\" />" . $data['fulltext'] : $data['introtext'];
                 unset($data['introtext']);
                 unset($data['fulltext']);
             }
             if (in_array($this->field_name_id_array['rating'], $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select('score')->from('#__judownload_rating')->where('doc_id = ' . $docId);
                 $db->setQuery($query);
                 $data['rating'] = $db->loadResult();
             }
             foreach ($exportColumns as $fieldId) {
                 if (is_numeric($fieldId) && $fieldId != $this->field_name_id_array['id'] && $fieldId != $this->field_name_id_array['tags']) {
                     $query = $db->getQuery(true);
                     $query->select('value')->from('#__judownload_fields_values')->where('doc_id = ' . $docId)->where('field_id = ' . $fieldId);
                     $db->setQuery($query);
                     $data['field_' . $fieldId] = $db->loadColumn();
                 }
             }
             if (in_array($this->field_name_id_array['tags'], $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select('t.title')->from('#__judownload_tags AS t')->join('', '#__judownload_tags_xref AS txref ON txref.tag_id = t.id')->where('txref.doc_id = ' . $docId);
                 $db->setQuery($query);
                 $tags = $db->loadColumn();
                 $data['tags'] = $tags;
             }
             if (in_array('main_cat', $exportColumns)) {
                 $data['main_cat'] = $mainCatId;
             }
             if (in_array('secondary_cats', $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select("c.id");
                 $query->from("#__judownload_categories AS c");
                 $query->join("", "#__judownload_documents_xref AS dxref ON (c.id = dxref.cat_id)");
                 $query->where("dxref.doc_id = " . $docId);
                 $query->where("dxref.main = 0");
                 $query->order('dxref.ordering ASC');
                 $db->setQuery($query);
                 $cats = $db->loadColumn();
                 if (!empty($cats)) {
                     $data['secondary_cats'] = $cats;
                 } else {
                     $data['secondary_cats'] = '';
                 }
             }
             if (in_array('gallery', $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select('file_name')->from('#__judownload_images')->where('doc_id = ' . $docId);
                 $db->setQuery($query);
                 $imagesName = $db->loadColumn();
                 foreach ($imagesName as $index => $imageName) {
                     $imagesName[$index] = JUDownloadFrontHelper::getDirectory('document_original_image_directory', 'media/com_judownload/images/gallery/original/', true) . $docId . '/' . $imageName;
                 }
                 $data['gallery'] = $imagesName;
             }
             if (in_array('files', $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select('file_name')->from('#__judownload_files')->where('doc_id = ' . $docId);
                 $db->setQuery($query);
                 $filesName = $db->loadColumn();
                 foreach ($filesName as $index => $fileName) {
                     $filesName[$index] = JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/", true) . $docId . '/' . $fileName;
                 }
                 $data['files'] = $filesName;
             }
             if (in_array('related_docs', $exportColumns)) {
                 $query = $db->getQuery(true);
                 $query->select('doc_id_related')->from('#__judownload_documents_relations')->where('doc_id = ' . $docId);
                 $db->setQuery($query);
                 $relatedDocs = $db->loadColumn();
                 $data['related_docs'] = $relatedDocs;
             }
             $exportData[] = $this->filterExportFieldValue($data);
         }
     }
     $columns = array_keys($exportData[0]);
     array_unshift($exportData, $columns);
     return $exportData;
 }
Ejemplo n.º 26
0
					<tr>
						<th><?php 
echo JText::_('COM_JUDOWNLOAD_DIRECTORIES');
?>
</th>
						<th style="width:100px"><?php 
echo JText::_('COM_JUDOWNLOAD_STATUS');
?>
</th>
					</tr>
					</thead>

					<tbody>
					<?php 
foreach ($configs as $config) {
    $value = JUDownloadFrontHelper::getDirectory($config['name'], $config['default']);
    $status = is_writable(JPATH_ROOT . "/" . $value) ? "<span class='badge badge-success'>" . JText::_('COM_JUDOWNLOAD_WRITEABLE') . "</span>" : "<span class='badge badge-important'>" . JText::_('COM_JUDOWNLOAD_UNWRITEABLE') . "</span>";
    echo "<tr>";
    echo "<td>" . $value . "</td>";
    echo "<td>" . $status . "</td>";
    echo "</tr>";
}
?>
					</tbody>
				</table>

				<table class="table table-striped table-bordered">
					<thead>
					<tr>
						<th><?php 
echo JText::_('COM_JUDOWNLOAD_LIBRARIES');
Ejemplo n.º 27
0
	public function addCommentSubscription($commentId)
	{
		$user                           = JFactory::getUser();
		$subscriptionData               = array();
		$subscriptionData['user_id']    = $user->id;
		$subscriptionData['type']       = 'comment';
		$subscriptionData['name']       = $user->username;
		$subscriptionData['email']      = $user->email;
		$subscriptionData['created']    = JHtml::date('now', 'Y-m-d H:i:s', true);
		$subscriptionData['item_id']    = $commentId;
		$subscriptionData['ip_address'] = JUDownloadFrontHelper::getIpAddress();
		$subscriptionData['published']  = 1;
		
		require_once JPATH_SITE . '/components/com_judownload/models/subscribe.php';
		JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_judownload/models');
		$subcribeModel = JModelLegacy::getInstance('Subscribe', 'JUDownloadModel');
		if (!$subcribeModel->add($subscriptionData))
		{
			return false;
		}

		return true;

	}
Ejemplo n.º 28
0
/**
 * ------------------------------------------------------------------------
 * JUDownload for Joomla 2.5, 3.x
 * ------------------------------------------------------------------------
 *
 * @copyright      Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 * @author         JoomUltra Co., Ltd
 * @website        http://www.joomultra.com
 * @----------------------------------------------------------------------@
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

$small_image_dir = JUDownloadFrontHelper::getDirectory("document_small_image_directory", "media/com_judownload/images/gallery/small/", true) . $this->doc_id . "/";
$params          = JUDownloadHelper::getParams();
$requiredImage   = $this->isRequired();
?>

<!-- New gallery image template -->
<script id="gallery-template" type="text/x-handlebars-template">
	<li>
		<input type="file" name="field_<?php echo $this->id; ?>[]" class="validate-images" {{multiple}}/>
		<a href="#" class="btn btn-mini btn-xs btn-danger remove_image" onclick="return false;"><i
				class="icon-minus"></i> <?php echo JText::_('COM_JUDOWNLOAD_REMOVE'); ?></a>
	</li>
</script>

<!-- Gallery image form template -->
<script id="imageform-template" type="text/x-handlebars-template">
Ejemplo n.º 29
0
									</div>

									<?php if ($commentObj->website != '')
									{
										?>
										<div class="comment-website">
											<?php echo JText::_('COM_JUDOWNLOAD_COMMENT_WEBSITE') . " : " . $commentObj->website; ?>
										</div>
									<?php
									} ?>

								</div>
								<!-- /.judl-metadata -->

								<?php
									$commentObj->comment = JUDownloadFrontHelper::BBCode2Html($commentObj->comment);
									$commentObj->comment = JUDownloadFrontHelperComment::parseCommentText($commentObj->comment, $this->doc_id);
								?>

								<div class="see-more" itemprop="description">
									<?php echo $commentObj->comment; ?>
								</div>
							</div>
						</div>
						<?php
						$totalChildComments = $this->getModel()->getTotalChildComments($commentObj->id);
						if ($totalChildComments > 0)
						{
							$this->comment_parent_id = $commentObj->id;
							echo $this->loadTemplate('comments');
						} ?>
Ejemplo n.º 30
0
		// Load primary javascript
		$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/core.js");

		$JUDLTemplateDefaultHelper->loadTooltipster();

		// Load switch mode view
		if ($this->allow_user_select_view_mode)
		{
			$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/switch.js");
		}
		break;

	case 'form' :
		$document->addStyleSheet(JUri::root(true) . "/components/com_judownload/templates/" . $self_template . "/assets/css/view.form.css");

		JUDownloadFrontHelper::loadjQueryUI();
		$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/handlebars.min.js");
		$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/jquery.dragsort.min.js");
		$document->addStyleSheet(JUri::root(true) . "/components/com_judownload/assets/plupload/css/jquery.plupload.queue.css");
		$document->addScript(JUri::root(true) . "/components/com_judownload/assets/plupload/js/plupload.full.min.js");
		$document->addScript(JUri::root(true) . "/components/com_judownload/assets/plupload/js/jquery.plupload.queue.min.js");

		JUDownloadHelper::formValidation();

		// JText in forms/document.js
		JText::script('COM_JUDOWNLOAD_INVALID_IMAGE');
		JText::script('COM_JUDOWNLOAD_INVALID_FILE_NAME');
		JText::script('COM_JUDOWNLOAD_CAN_NOT_UPLOAD_FILE_BECAUSE_IT_IS_EMPTY');
		JText::script('COM_JUDOWNLOAD_CAN_NOT_UPLOAD_THIS_FILE_PLEASE_RECHECK_MIMETYPE_FILE');
		JText::script('COM_JUDOWNLOAD_CAN_NOT_TRANSFER_FILE');
		JText::script('COM_JUDOWNLOAD_OTHER_FILE_IS_UPLOADING_DO_YOU_WANT_TO_CANCEL_TO_UPLOAD_NEW_FILE');