public function display($tpl = null) { $this->params = JUDownloadHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if (!$this->params->get('activate_maintenance', 0)) { $app = JFactory::getApplication(); $app->redirect(JUri::root()); } $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public function display($tpl = null) { $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->params = JUDownloadHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->listOrder = $this->escape($this->state->get('list.ordering', 'tag.title')); $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); $this->order_name_array = array( 'tag.id' => JText::_('COM_JUDOWNLOAD_FIELD_ID'), 'tag.title' => JText::_('COM_JUDOWNLOAD_FIELD_TITLE'), 'tag.created' => JText::_('COM_JUDOWNLOAD_FIELD_CREATED'), 'tag.ordering' => JText::_('COM_JUDOWNLOAD_FIELD_ORDERING') ); $this->order_dir_array = array('ASC' => JText::_('COM_JUDOWNLOAD_ASC'), 'DESC' => JText::_('COM_JUDOWNLOAD_DESC')); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
protected function populateState($ordering = null, $direction = null) { $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''); $this->setState('filter.search', $search); $featured = $this->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured', ''); $this->setState('filter.featured', $featured); $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_catid', ''); $this->setState('filter.catid', $categoryId); $license = $this->getUserStateFromRequest($this->context . '.filter.license', 'filter_licenseid', ''); $this->setState('filter.licenseid', $license); $params = JUDownloadHelper::getParams(); $this->setState('params', $params); parent::populateState('d.title', 'asc'); $field_display = $this->getUserStateFromRequest($this->context . '.field_display', 'field_display', array()); $this->setState('field_display', $field_display); }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $catId = $app->input->getInt('id', 1); $params = JUDownloadHelper::getParams($catId); $this->setState('params', $params); }
public function canView($options = array()) { $storeId = md5(__METHOD__ . "::" . $this->doc_id . "::" . $this->id . "::" . serialize($options)); if (!isset(self::$cache[$storeId])) { if (!$this->isPublished()) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } if (isset($this->doc) && $this->doc->cat_id) { $params = JUDownloadHelper::getParams($this->doc->cat_id); } else { $params = JUDownloadHelper::getParams(null, $this->doc_id); } $show_empty_field = $params->get('show_empty_field', 0); if ($this->doc_id && !$show_empty_field) { $app = JFactory::getApplication(); if ($app->isSite()) { if (!is_object($this->value) || !$this->value->published) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } else { if (!is_object($this->value)) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } } self::$cache[$storeId] = parent::canView($options); return self::$cache[$storeId]; } return self::$cache[$storeId]; }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $categoryId = $app->input->getInt('id', $rootCategory->id); $this->setState('category.id', $categoryId); $params = JUDownloadHelper::getParams($categoryId); $this->setState('params', $params); if ($this->context) { $documentPagination = $params->get('document_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', $documentPagination, 'uint'); } else { $limit = $documentPagination; } } else { $limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $documentPagination, 'uint'); } $this->setState('list.limit', $limit); $this->setState('list.start', $app->input->getUint('limitstart', 0)); $orderCol = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', ''); $this->setState('list.ordering', $orderCol); $listOrder = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', 'ASC'); $this->setState('list.direction', $listOrder); } else { $this->setState('list.start', 0); $this->state->set('list.limit', 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); } }
public static function getDefaultAvatar($params = null) { if (!$params) { $params = JUDownloadHelper::getParams(); } $linkAvatar = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("avatar_directory", "media/com_judownload/images/avatar/", true) . "default/" . $params->get('default_avatar', 'default-avatar.png'); $avatar_source = $params->get('avatar_source', 'juavatar'); if ($avatar_source == 'gavatar') { $linkAvatar = self::getGAvatar(); } return $linkAvatar; }
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\" /> " . 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; }
public static function getCaptcha($hiddenCaptcha = false, $captchaNameSpaceValue = null, $label = true, $name = "security_code", $id = "security_code", $captchaNameSpaceName = "captcha_namespace") { $document = JFactory::getDocument(); $document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/captcha.js"); $params = JUDownloadHelper::getParams(); $captchaNameSpaceValue = !$captchaNameSpaceValue ? md5(time()) : $captchaNameSpaceValue; $html = ''; if ($label) { $html .= '<div class="control-group">'; $html .= '<label class="control-label" for="' . $id . '">' . JText::_('COM_JUDOWNLOAD_CAPTCHA') . '<span class="required" style="color: red">*</span></label>'; $html .= '<div class="controls">'; } $html .= '<div class="judl-captcha pull-left">'; $html .= '<div class="clearfix">'; if ($hiddenCaptcha == false) { $html .= '<img class="captcha-image" alt="' . JText::_('COM_JUDOWNLOAD_CAPTCHA') . '" src="' . JUri::root(true) . '/index.php?option=com_judownload&task=captcha&captcha_namespace=' . $captchaNameSpaceValue . '&tmpl=component" width="' . $params->get('captcha_width', '155') . 'px" height="' . $params->get('captcha_height', '50') . 'px"/>'; } else { $html .= '<img class="captcha-image" alt="' . JText::_('COM_JUDOWNLOAD_CAPTCHA') . '" src="" width="' . $params->get('captcha_width', '155') . 'px" height="' . $params->get('captcha_height', '50') . 'px"/>'; } $html .= '<input type="hidden" class="captcha-namespace" name="' . $captchaNameSpaceName . '" value="' . $captchaNameSpaceValue . '" />'; $html .= '</div>'; $html .= '<div class="input-group input-group-sm">'; $html .= '<input type="text" id="' . $id . '" name="' . $name . '" class="security_code form-control required" autocomplete="off"/>'; $html .= '<span class="input-group-addon btn btn-default reload-captcha" title="' . JText::_('COM_JUDOWNLOAD_RELOAD_CAPTCHA') . '"><i class="fa fa-refresh" ></i></span>'; $html .= '</div>'; $html .= '</div>'; if ($label) { $html .= '</div>'; $html .= '</div>'; } return $html; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->model = $this->getModel(); $this->app = JFactory::getApplication(); $cat_id = $this->item->cat_id ? $this->item->cat_id : $this->app->input->get('cat_id'); $this->params = JUDownloadHelper::getParams(null, $this->item->id); if ($cat_id == JUDownloadFrontHelperCategory::getRootCategory()->id && !$this->params->get('allow_add_doc_to_root', 0)) { JError::raiseError(500, JText::_('COM_JUDOWNLOAD_CAN_NOT_ADD_DOCUMENT_TO_ROOT_CATEGORY')); return false; } if ($tempDocument = JUDownloadHelper::getTempDocument($this->item->id)) { $editPendingDocLink = '<a href="index.php?option=com_judownload&task=document.edit&approve=1&id=' . $tempDocument->id . '">' . $tempDocument->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_THIS_DOCUMENT_HAS_PENDING_DOCUMENT_X_PLEASE_APPROVE_PENDING_DOCUMENT_FIRST', $editPendingDocLink)); } if ($this->item->approved < 0) { $oriDocId = abs($this->item->approved); $oriDocObj = JUDownloadHelper::getDocumentById($oriDocId); $editOriDocLink = '<a href="index.php?option=com_judownload&task=document.edit&id=' . $oriDocId . '">' . $oriDocObj->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_ORIGINAL_DOCUMENT_X', $editOriDocLink)); } $this->script = $this->get('Script'); $this->plugins = $this->get('Plugins'); $this->fieldsetDetails = $this->model->getCoreFields('details'); $this->fieldsetPublishing = $this->model->getCoreFields('publishing'); $this->fieldsetTemplateStyleAndLayout = $this->model->getCoreFields('template_style'); $this->fieldsetMetadata = $this->model->getCoreFields('metadata'); $this->fieldCatid = JUDownloadFrontHelperField::getField('cat_id', $this->item); $this->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item); $this->files = $this->get('Files'); $this->changeLogs = $this->get('ChangeLogs'); $this->versions = $this->get('Versions'); $this->extraFields = $this->get('ExtraFields'); $this->fieldsData = $this->app->getUserState("com_judownload.edit.document.fieldsdata", array()); $this->relatedDocuments = $this->get('RelatedDocuments'); $this->canDo = JUDownloadHelper::getActions('com_judownload', 'category', $this->item->cat_id); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->_prepareDocument(); $this->_setBreadcrumb(); $this->params = JUDownloadHelper::getParams(); parent::display($tpl); }
public function display($tpl = null) { $app = JFactory::getApplication(); $licenseId = $app->input->getInt('id', 0); $this->item = JUDownloadFrontHelper::getLicense($licenseId); if (!is_object($this->item)) { return JError::raiseError(403, JText::_('COM_JUDOWNLOAD_LICENSE_NOT_FOUND')); } $this->params = JUDownloadHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $limitStart = $app->input->getUint('limitstart', 0); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $this->item->event = new stdClass(); $context = 'com_judownload.license'; $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$this->item, &$this->item->params, $limitStart)); $this->item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->item->params, $limitStart)); $this->item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->item->params, $limitStart)); $this->item->event->afterDisplayContent = trim(implode("\n", $results)); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public function display($cachable = false, $urlparams = false) { $app = JFactory::getApplication(); $cachable = true; $id = $app->input->getInt('id', 0); $vName = $app->input->getCmd('view', 'categories'); $app->input->set('view', $vName); $user = JFactory::getUser(); if ($user->get('id') || ($_SERVER['REQUEST_METHOD'] == 'POST' && (($vName == 'category' && $app->input->get('layout') != 'blog') || $vName == 'archive')) ) { $cachable = false; } $safeurlparams = array('catid' => 'INT', 'id' => 'INT', 'cid' => 'ARRAY', 'year' => 'INT', 'month' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'showall' => 'INT', 'return' => 'BASE64', 'filter' => 'STRING', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'filter-search' => 'STRING', 'print' => 'BOOLEAN', 'lang' => 'CMD', 'Itemid' => 'INT'); $params = JUDownloadHelper::getParams(); if (!$user->authorise('core.admin', 'com_judownload') && $params->get('activate_maintenance', 0) && $app->input->getString('view', '') != 'maintenance') { $this->setRedirect(JUDownloadHelperRoute::getMaintenanceRoute()); } if ($vName == 'form' && $id > 0 && !$this->checkEditId('com_judownload.edit.document', $id)) { return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } parent::display($cachable, $safeurlparams); return $this; }
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") . ' <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; }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = JUDownloadHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->_prepareDocument(); parent::display($tpl); }
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); } }
public function display($tpl = null) { $this->user = JFactory::getUser(); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->authors = $this->get('Authors'); $this->params = JUDownloadHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $levelOptions = array(); $levelOptions[] = JHtml::_('select.option', 5, 5); $levelOptions[] = JHtml::_('select.option', 10, 10); $levelOptions[] = JHtml::_('select.option', 15, 15); $levelOptions[] = JHtml::_('select.option', 20, 20); $levelOptions[] = JHtml::_('select.option', 25, 25); $levelOptions[] = JHtml::_('select.option', 30, 30); $this->levelOptions = $levelOptions; $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $app = JFactory::getApplication(); $this->function = $app->input->get('function', 'jSelectDocument'); $this->totalDocs = $this->get('Total'); $this->_prepareDocument(); parent::display($tpl); }
protected function getInput() { $params = JUDownloadHelper::getParams($this->form->getValue('id')); if ($this->element['directory'] == "intro") { $path = $params->get('category_intro_image_directory', 'media/com_judownload/images/category/intro/'); $document = JFactory::getDocument(); $script = 'jQuery(document).ready(function($){ $("#use-detail-image").change(function(){ if($(this).is(":checked")){ $(this).parent().find("input[type=\'file\']").attr("disabled", true); $(this).parent().find("#remove-image-intro").prop("checked", false).attr("disabled", true); }else{ $(this).parent().find("input[type=\'file\']").attr("disabled", false); $(this).parent().find("#remove-image-intro").prop("checked", true).attr("disabled", false); } }); })'; $document->addScriptDeclaration($script); $html = '<input type="file" name="images[intro]" class="validate-images" />'; } else { $html = '<input type="file" name="images[detail]" class="validate-images" />'; $path = $params->get('category_detail_image_directory', 'media/com_judownload/images/category/detail/'); } $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" />'; if (!empty($this->value)) { $src = JUri::root() . $path . $this->value; $html .= '<label></label><img style="border: 5px solid #c0c0c0; max-width:100px; max-height:100px;" src="' . $src . '" />'; $html .= '<div><input id="remove-image-' . $this->element['directory'] . '" type="checkbox" name="remove_' . $this->id . '" value="1" style="float: left; margin-right: 5px;"/>'; $html .= '<label for="remove-image-' . $this->element['directory'] . '" >' . JText::_('COM_JUDOWNLOAD_REMOVE_THIS_IMAGE') . '</label></div>'; } if ($this->element['directory'] == "intro") { $html .= '<div><input id="use-detail-image" type="checkbox" name="use_detail_image" value="1" style="float: left; margin-right: 5px;"/>'; $html .= '<label class="hasTip" title="' . JText::_('COM_JUDOWNLOAD_USE_DETAIL_IMAGE_AS_INTRO_IMAGE') . '::' . JText::_('COM_JUDOWNLOAD_USE_DETAIL_IMAGE_AS_INTRO_IMAGE_DESC') . '" for="use-detail-image">'; $html .= JText::_('COM_JUDOWNLOAD_USE_DETAIL_IMAGE_AS_INTRO_IMAGE'); $html .= '</label></div>'; } return $html; }
public static function allowEnterPassword($documentId) { $params = JUDownloadHelper::getParams(null, $documentId); $maxWrongPasswordTimes = $params->get('max_wrong_password_times', 5); $blockEnterPasswordTime = $params->get('block_enter_password_time', 600); $session = JFactory::getSession(); $timeNow = JFactory::getDate()->toSql(); $timeNowStamp = strtotime($timeNow); $ss_wrongPasswordTimes = 'judl-wrong-password-' . $documentId; $ss_blockDownloadTime = 'judl-block-download-time-' . $documentId; if ($session->has($ss_blockDownloadTime)) { $waitTime = $timeNowStamp - $session->get($ss_blockDownloadTime); } else { $waitTime = 0; } if ($session->has($ss_wrongPasswordTimes)) { $ss_wrongPasswordTimes = (int) $session->get($ss_wrongPasswordTimes); } else { $ss_wrongPasswordTimes = 0; } if ($ss_wrongPasswordTimes < $maxWrongPasswordTimes || $waitTime > $blockEnterPasswordTime) { return true; } return false; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $app = JFactory::getApplication(); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $fastAddError = $app->getUserState('com_judownload.categories.fastadderror'); $fastAddSuccess = $app->getUserState('com_judownload.categories.fastaddsuccess'); $this->cat_id = $app->input->getInt('cat_id', $rootCat->id); $this->params = JUDownloadHelper::getParams($this->cat_id); $this->canDoCat = JUDownloadHelper::getActions('com_judownload', 'category', $this->cat_id); $this->rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $this->allowAddDoc = $this->params->get('allow_add_doc_to_root', 0) && $this->cat_id == $this->rootCat->id || $this->cat_id != $this->rootCat->id; $this->docGroupCanDoManage = $this->groupCanDoCatManage = JUDownloadHelper::checkGroupPermission("document.edit"); $this->docGroupCanDoDelete = $this->groupCanDoCatDelete = JUDownloadHelper::checkGroupPermission("documents.delete"); $this->catGroupCanDoManage = $this->groupCanDoCatManage = JUDownloadHelper::checkGroupPermission("category.edit"); $this->catGroupCanDoDelete = $this->groupCanDoCatDelete = JUDownloadHelper::checkGroupPermission("categories.delete"); // if ($fastAddSuccess) { $app->enqueueMessage($fastAddSuccess); $app->setUserState('com_judownload.categories.fastaddsuccess', ''); } if ($fastAddError) { $app->enqueueMessage($fastAddError, 'error'); $app->setUserState('com_judownload.categories.fastadderror', ''); } $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->model = $this->getModel(); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->items = $this->get('Items'); $this->params = JUDownloadHelper::getParams(); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->root_comment = JUDownloadFrontHelperComment::getRootComment(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->order_name_array = array( 'cm.title' => JText::_('COM_JUDOWNLOAD_FIELD_TITLE'), 'cm.created' => JText::_('COM_JUDOWNLOAD_FIELD_CREATED'), 'r.score' => JText::_('COM_JUDOWNLOAD_FIELD_RATING_SCORE'), 'cm.helpful_votes' => JText::_('COM_JUDOWNLOAD_FIELD_HELPFUL_VOTES'), 'cm.total_votes' => JText::_('COM_JUDOWNLOAD_FIELD_TOTAL_VOTES')); $this->order_dir_array = array( 'ASC' => JText::_('COM_JUDOWNLOAD_ASC'), 'DESC' => JText::_('COM_JUDOWNLOAD_DESC')); $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
protected function getLayout($items, $layout = null) { if ($layout == null) { $params = JUDownloadHelper::getParams($this->form->getValue('id')); $layout = $params->get("layout_category", '_:default'); } if ($layout) { $layout = explode(":", $layout); if ($layout[0] == "_") { return "(Component > " . $items['_'][$layout[1]] . ")"; } else { return "({$layout['0']} > " . $items[$layout[0]][$layout[1]] . ")"; } } }
protected static function autoLinkVideo($text, $docId = null) { $params = JUDownloadHelper::getParams(null, $docId); $auto_embed_youtube_in_comment = $params->get('auto_embed_youtube_in_comment', 0); $auto_embed_vimeo_in_comment = $params->get('auto_embed_vimeo_in_comment', 0); $video_width_in_comment = $params->get('video_width_in_comment', 360); $video_height_in_comment = $params->get('video_height_in_comment', 240); $regexYoutube = "#(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:v|vi|user)\/))([^\?&\"'<>\/\s]+)(?:$|\/|\?|\&)?#i"; preg_match_all($regexYoutube, $text, $matchesYoutube); if ($auto_embed_youtube_in_comment && count($matchesYoutube[0])) { foreach ($matchesYoutube[0] AS $key => $match) { $youtube_html = JUDownloadFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment); $text = str_replace($matchesYoutube[0][$key], $youtube_html . '<br/>', $text); } } $regexVimeo = "#(?:http(?:s)?:\/\/)?(?:www\.)?vimeo.com\/(\d+)(?:$|\/|\?)?#"; preg_match_all($regexVimeo, $text, $matchesVimeo); if ($auto_embed_vimeo_in_comment && count($matchesVimeo[0])) { $arrIdVimeo = array_unique($matchesVimeo[0]); foreach ($arrIdVimeo AS $key => $match) { $vimeo_html = JUDownloadFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment); $text = str_replace($matchesVimeo[0][$key], $vimeo_html, $text); } } return $text; }
public function check() { $app = JFactory::getApplication(); if ($app->isSite()) { $params = JUDownloadHelper::getParams(null, $this->doc_id); $this->_comment_interval = $params->get('comment_interval', 60); if ($this->_comment_interval > 0) { $this->_comment_latest = strtotime($this->getLatestCommentTime()); } $this->_comment_interval_same_document = $params->get('comment_interval_in_same_document', 60); if ($this->_comment_interval_same_document > 0) { $this->_comment_latest_same_document = strtotime($this->getLatestCommentTime($this->doc_id)); } } if (!parent::check()) { $this->setError(JText::_('COM_JUDOWNLOAD_COMMENT_FAILED')); return false; } return true; }
public static function getAllRatingScoresOfDocument($documentId) { $params = JUDownloadHelper::getParams(null, $documentId); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('r.score'); $query->from('#__judownload_rating AS r'); $query->where('r.doc_id = ' . $documentId); $query->join('LEFT', '#__judownload_comments AS cm ON r.id = cm.rating_id'); $query->where('(cm.approved = 1 OR cm.approved IS NULL)'); $query->where('r.user_id > 0'); if ($params->get('only_calculate_last_rating', 0)) { $subQuery = '(SELECT MAX(lastrated_tbl.created) FROM #__judownload_rating AS lastrated_tbl WHERE r.user_id = lastrated_tbl.user_id)'; $query->where('(r.created = ' . $subQuery . ')'); $query->group('r.user_id, r.created'); } $db->setQuery($query); $userRating = $db->loadObjectList(); if (!is_array($userRating)) { $userRating = array(); } $query = $db->getQuery(true); $query->select('r.score'); $query->from('#__judownload_rating AS r'); $query->where('r.doc_id = ' . $documentId); $query->join('LEFT', '#__judownload_comments AS cm ON r.id = cm.rating_id'); $query->where('(cm.approved = 1 OR cm.approved IS NULL)'); $query->where('r.user_id = 0'); $db->setQuery($query); $guestRating = $db->loadObjectList(); if (!is_array($guestRating)) { $guestRating = array(); } $documentRatings = array_merge($userRating, $guestRating); return $documentRatings; }
public function uploadFileScript($doc_id = null, $selector = "#judl-files") { $params = JUDownloadHelper::getParams(null, $doc_id); $max_upload_file_size = (int) $params->get("max_upload_file_size", 10) * 1024 * 1024; $post_max_size = JUDownloadHelper::getPostMaxSize(); if ($max_upload_file_size < $post_max_size) { $runtimes = 'html5,flash,silverlight,html4'; } else { $runtimes = 'html5,silverlight,html4'; } $chunk_size = JUDownloadHelper::getPostMaxSize() - 4000; $max_upload_files = 1; $legal_upload_extensions = $params->get("legal_upload_extensions", "bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,swf,txt,xcf,xls,zip,rar"); $legal_upload_extensions = str_replace("\n", ",", trim($legal_upload_extensions)); $check_mime_uploaded_file = (int) $params->get("check_mime_uploaded_file", 0); $legal_mime_types = $check_mime_uploaded_file ? $params->get("legal_mime_types", 'image/jpeg,image/gif,image/png,image/bmp,application/x-shockwave-flash,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/zip,application/zip') : ""; if ($legal_mime_types) { $legal_mime_types = str_replace("\n", ",", trim($legal_mime_types)); } $requiredFile = $params->get("document_require_file", 1); $time = time(); $secret = JFactory::getConfig()->get('secret'); $code = md5($time . $secret); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $script = ' jQuery(document).ready(function ($) { var options = { doc_id : ' . (int) $doc_id . ', juri_root : "' . JUri::root() . '", juri_base : "' . JUri::base() . '", runtimes : "' . $runtimes . '", chunk_size : "' . $chunk_size . '", max_upload_file_size : ' . $max_upload_file_size . ', max_upload_files : ' . $max_upload_files . ', extensions : "' . $legal_upload_extensions . '", mime_types : "' . $legal_mime_types . '", is_required : ' . (int) $requiredFile . ', time : ' . $time . ', code : "' . $code . '", is_site : ' . (int) $app->isSite() . ' }; $("' . $selector . '").files(options); });'; $document->addScriptDeclaration($script); }
$doc_id = $app->input->getInt('doc_id', 0); $fieldObj = JUDownloadFrontHelperField::getField($field_id, $doc_id); JUDownloadHelper::obCleanData(); $fieldObj->getRawData(); exit; break; case 'cron': JUDownloadFrontHelperMail::sendMailq(); exit; break; default: $controller = JControllerLegacy::getInstance('judownload'); $controller->execute($app->input->get('task')); $controller->redirect(); break; } $params = JUDownloadHelper::getParams(); if ($params->get('send_mailqs_on_pageload', 0)) { JUDownloadFrontHelperMail::sendMailq(); }
protected function getValue() { $app = JFactory::getApplication(); if ($app->isSite() && isset($this->doc->total_comments) && !is_null($this->doc->total_comments)) { return $this->doc->total_comments; } $user = JFactory::getUser(); $db = JFactory::getDbo(); if ($app->isSite()) { $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judownload_comments AS cm'); $query->where('doc_id =' . $this->doc_id); $query->where('level = 1'); $query->where('approved = 1'); $moderator = JUDownloadFrontHelperModerator::getModerator($this->doc->cat_id); $getAll = false; if ($user->authorise('core.admin', 'com_judownload')) { $getAll = true; } if (is_object($moderator)) { if ($moderator->comment_edit || $moderator->comment_edit_state || $moderator->comment_delete) { $getAll = true; } } if (!$getAll) { $query->where('published = 1'); $params = JUDownloadHelper::getParams(null, $this->doc_id); $negative_vote_comment = $params->get('negative_vote_comment'); if (is_numeric($negative_vote_comment) && $negative_vote_comment > 0) { $query->where('(total_votes - helpful_votes) <' . $negative_vote_comment); } } } else { $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judownload_comments AS cm'); $query->where('doc_id =' . $this->doc_id); $query->where('level = 1'); $query->where('approved = 1'); } $db->setQuery($query); $totalComments = $db->loadResult(); return $totalComments; }
public static function getWysibbEditor($jQuerySelector = '.wysibb', $returnJS = false, $readmore = false) { $params = JUDownloadHelper::getParams(); $wysibbButtons['bold,'] = $params->get('bb_bold_tag', 'Bold'); $wysibbButtons['italic,'] = $params->get('bb_italic_tag', 'Italic'); $wysibbButtons['underline,'] = $params->get('bb_underline_tag', 'Underline'); $wysibbButtons['img,'] = $params->get('bb_img_tag', 'Picture'); $wysibbButtons['link,'] = $params->get('bb_link_tag', 'Link'); $wysibbButtons['video,'] = $params->get('bb_video_tag', 'Video'); $wysibbButtons['smilebox,'] = $params->get('bb_smilebox_tag', 'Smilebox'); $wysibbButtons['fontcolor,'] = $params->get('bb_color_tag', 'Colors'); $wysibbButtons['fontsize,'] = $params->get('bb_fontsize_tag', 'Fontsize'); $wysibbButtons['justifyleft,'] = $params->get('bb_align_left', 'alignleft'); $wysibbButtons['justifycenter,'] = $params->get('bb_align_center', 'aligncenter'); $wysibbButtons['justifyright,'] = $params->get('bb_align_right', 'alignright'); $wysibbButtons['bullist,'] = $params->get('bb_bulleted_list', 'Bulleted-list'); $wysibbButtons['numlist,'] = $params->get('bb_numeric_list', 'Numeric-list'); $wysibbButtons['quote,'] = $params->get('bb_quote_tag', 'Quotes'); if ($readmore == true) { $wysibbButtons['readmore,'] = $params->get('bb_readmore_tag', 'Readmore'); } $buttons = ''; $i = 0; foreach ($wysibbButtons AS $key => $value) { if ($i % 3 == 0) { $buttons .= "|,"; } if ($value) { $buttons .= $key; } $i++; } $script = " jQuery(document).ready(function($){ judlWbbOpt.minCommentChar = " . (int) $params->get('min_comment_characters', 20) . "; judlWbbOpt.maxCommentChar = " . (int) $params->get('max_comment_characters', 1000) . "; judlWbbOpt.buttons = '$buttons'; judlWbbOpt.lang = 'en'; $('$jQuerySelector').wysibb(judlWbbOpt); }); "; if ($returnJS == true) { return '<script type="text/javascript">' . $script . '</script>'; } else { JText::script('COM_JUDOWNLOAD_READMORE_WYSIBB_ALREADY_EXISTS'); JText::script('COM_JUDOWNLOAD_PLEASE_ENTER_AT_LEAST_N_CHARACTERS'); JText::script('COM_JUDOWNLOAD_CONTENT_LENGTH_REACH_MAX_N_CHARACTERS'); $document = JFactory::getDocument(); $document->addStyleSheet(JUri::root(true) . "/components/com_judownload/assets/wysibb/theme/default/wbbtheme.css"); $document->addScript(JUri::root(true) . "/components/com_judownload/assets/wysibb/jquery.wysibb.js"); $document->addScript(JUri::root(true) . "/components/com_judownload/assets/wysibb/override.jquery.wysibb.js"); $document->addScript(JUri::root(true) . "/components/com_judownload/assets/wysibb/preset/phpbb3.js"); $document->addScriptDeclaration($script); } }