本文整理汇总了PHP中JUDownloadHelper::getDocumentById方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::getDocumentById方法的具体用法?PHP JUDownloadHelper::getDocumentById怎么用?PHP JUDownloadHelper::getDocumentById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDownloadHelper
的用法示例。
在下文中一共展示了JUDownloadHelper::getDocumentById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAssetParentId
protected function _getAssetParentId(JTable $table = null, $id = null)
{
$assetId = null;
if (isset($this->cat_id) && $this->cat_id) {
$cat_id = $this->cat_id;
} elseif ($this->id) {
$cat_id = JUDownloadHelper::getDocumentById($this->id)->cat_id;
}
if ($cat_id) {
$query = $this->_db->getQuery(true);
$query->select($this->_db->quoteName('asset_id'));
$query->from($this->_db->quoteName('#__judownload_categories'));
$query->where($this->_db->quoteName('id') . ' = ' . $cat_id);
$this->_db->setQuery($query);
if ($result = $this->_db->loadResult()) {
$assetId = (int) $result;
}
}
if ($assetId === null) {
$query = $this->_db->getQuery(true);
$query->select($this->_db->quoteName('id'));
$query->from($this->_db->quoteName('#__assets'));
$query->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote('com_judownload'));
$this->_db->setQuery($query);
if ($result = $this->_db->loadResult()) {
$assetId = (int) $result;
}
}
if ($assetId) {
return $assetId;
} else {
return parent::_getAssetParentId($table, $id);
}
}
示例2: back
public function back()
{
$app = JFactory::getApplication();
$doc_id = $app->input->getInt('doc_id', 0);
$cat_id = JUDownloadFrontHelperCategory::getRootCategory()->id;
if ($doc_id) {
$docObj = JUDownloadHelper::getDocumentById($doc_id);
if (isset($docObj->cat_id) && $docObj->cat_id) {
$cat_id = $docObj->cat_id;
}
}
$this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id={$cat_id}");
}
示例3: getInput
public function getInput()
{
$db = JFactory::getDbo();
$groups = array();
$app = JFactory::getApplication();
$appendInherit = '';
if ($app->input->get("view") == "document") {
if ($this->form->getValue("id")) {
$doc = JUDownloadHelper::getDocumentById($this->form->getValue("id"));
$appendInherit = "(" . $this->calculatorInheritStyle($doc->cat_id) . ")";
}
} else {
if ($this->form->getValue("parent_id")) {
$appendInherit = "(" . $this->calculatorInheritStyle($this->form->getValue("parent_id")) . ")";
}
}
$appendDefault = "(" . $this->getStyle() . ")";
$groups['inherit'] = array();
$groups['inherit']['id'] = $this->id . '_inherit';
$groups['inherit']['text'] = '---' . JText::_('COM_JUDOWNLOAD_INHERIT') . '---';
$groups['inherit']['items'] = array();
$groups['inherit']['items'][] = JHtml::_('select.option', '-2', JText::_('COM_JUDOWNLOAD_DEFAULT') . ' ' . $appendDefault);
$groups['inherit']['items'][] = JHtml::_('select.option', '-1', JText::_('COM_JUDOWNLOAD_INHERIT') . ' ' . $appendInherit);
$query = $db->getQuery(true);
$query->select('style.*');
$query->select('plg.title AS template_title, plg.folder');
$query->from('#__judownload_template_styles AS style');
$query->join('', '#__judownload_templates AS tpl ON tpl.id = style.template_id');
$query->join('', '#__judownload_plugins AS plg ON plg.id = tpl.plugin_id');
$query->where('style.lft > 0');
$query->order('style.lft ASC');
$db->setQuery($query);
$styles = $db->loadObjectList();
for ($i = 0, $n = count($styles); $i < $n; $i++) {
$styles[$i]->text = str_repeat('- ', $styles[$i]->level - 1) . $styles[$i]->title . " [ " . $styles[$i]->template_title . " ]";
}
$groups['style'] = array();
$groups['style']['id'] = 'template_style';
$groups['style']['text'] = JText::_('COM_JUDOWNLOAD_TEMPLATE_STYLES');
$groups['style']['items'] = array();
foreach ($styles as $style) {
$groups['style']['items'][] = JHtml::_('select.option', $style->id, $style->text);
}
$html = JHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => "", 'list.select' => $this->value));
return $html;
}
示例4: display
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);
}
示例5: getInput
protected function getInput()
{
$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
$size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
$maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
$readonly = $this->readonly ? ' readonly' : '';
$disabled = $this->disabled ? ' disabled' : '';
$required = $this->required ? ' required aria-required="true"' : '';
$hint = $hint ? ' placeholder="' . $hint . '"' : '';
$autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
$autofocus = $this->autofocus ? ' autofocus' : '';
$spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
$pattern = !empty($this->pattern) ? ' pattern="' . $this->pattern . '"' : '';
$inputmode = !empty($this->inputmode) ? ' inputmode="' . $this->inputmode . '"' : '';
$dirname = !empty($this->dirname) ? ' dirname="' . $this->dirname . '"' : '';
$onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
$documentObject = JUDownloadHelper::getDocumentById($this->value);
$documentLink = JRoute::_('index.php?option=com_judownload&task=document.edit&id=' . $documentObject->id);
$html[] = '<div class="btn"><a href="' . $documentLink . '" target="_blank">' . $documentObject->title . '</a></div>';
$html[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . $dirname . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $hint . $onchange . $maxLength . $required . $autocomplete . $autofocus . $spellcheck . $inputmode . $pattern . ' />';
return implode($html);
}
示例6: parse
//.........这里部分代码省略.........
{
if (preg_match('/^\d+\-.+/', $segmentItem))
{
$indexAlias = $indexLastSegment - $segmentItemKey;
break;
}
}
if (isset($indexAlias) && isset($segments[$indexAlias]))
{
if (strpos($segments[$indexAlias], '-') === false)
{
$itemId = (int) $segments[$indexAlias];
$itemAlias = substr($segments[$indexAlias], strlen($itemId) + 1);
}
else
{
list($itemId, $itemAlias) = explode('-', $segments[$indexAlias], 2);
}
if (is_numeric($itemId))
{
$categoryObject = JUDownloadHelper::getCategoryById($itemId);
if (is_object($categoryObject) && isset($categoryObject->alias) && $categoryObject->alias == $itemAlias)
{
$vars['view'] = 'category';
$vars['id'] = $itemId;
JUDownloadHelperRoute::parsePagination($vars, $segments, $params);
return $vars;
}
$documentObject = JUDownloadHelper::getDocumentById($itemId);
if (is_object($documentObject) && isset($documentObject->alias) && $documentObject->alias == $itemAlias)
{
$vars['id'] = $itemId;
if (isset($vars['layout']))
{
if ($vars['layout'] == 'edit')
{
$vars['view'] = 'form';
}
else
{
$vars['view'] = 'document';
}
}
if (!isset($vars['view']))
{
$vars['view'] = 'document';
}
if ($vars['view'] == 'document')
{
if (isset($segments[$indexAlias + 1]))
{
if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print'))
{
$vars['print'] = 1;
$vars['tmpl'] = 'component';
$vars['layout'] = 'print';
}
elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('changelogs'))
{
示例7: getFields
public static function getFields($doc, $view = null, $includedOnlyFields = array(), $ignoredFields = array(), $additionFields = array())
{
$user = JFactory::getUser();
$accessLevel = implode(',', $user->getAuthorisedViewLevels());
$date = JFactory::getDate();
$db = JFactory::getDbo();
if (is_object($doc) && !isset($doc->cat_id))
{
$doc = JUDownloadHelper::getDocumentById($doc->id);
}
if (is_numeric($doc))
{
$doc = JUDownloadHelper::getDocumentById($doc);
}
$catId = $doc->cat_id;
$catObjStoreId = md5(__METHOD__ . "::catObj::$catId::$accessLevel");
if (!isset(self::$cache[$catObjStoreId]))
{
$query = $db->getQuery(true);
$query->select('c.id, c.field_ordering_type');
$query->select('fg.id AS field_group_id, fg.field_ordering_type AS fg_field_ordering_type');
$query->from('#__judownload_categories AS c');
$query->join('LEFT', '#__judownload_fields_groups AS fg ON (fg.id = c.fieldgroup_id AND fg.published = 1 AND fg.access IN (' . $accessLevel . '))');
$query->where('c.id = ' . $catId);
$db->setQuery($query);
self::$cache[$catObjStoreId] = $db->loadObject();
}
$catObj = self::$cache[$catObjStoreId];
if (empty($catObj))
{
return false;
}
if ($catObj->field_ordering_type == 1)
{
$item_id = $catObj->id;
$type = 'category';
$field_group_id = $catObj->field_group_id;
}
else
{
if ($catObj->fg_field_ordering_type == 1)
{
$item_id = $catObj->field_group_id;
$type = 'fieldgroup';
$field_group_id = $catObj->field_group_id;
}
else
{
$item_id = 0;
$type = '';
$field_group_id = $catObj->field_group_id;
}
}
$fieldsStoreId = md5(__METHOD__ . "::fieldsObj::$item_id::$type::$field_group_id::$view::" . "::" . serialize($includedOnlyFields) . "::" . serialize($ignoredFields) . "::" . serialize($additionFields));
if (!isset(self::$cache[$fieldsStoreId]))
{
$query = $db->getQuery(true);
$query->select("field.*, plg.folder");
$query->from("#__judownload_fields AS field");
$query->join("", "#__judownload_plugins AS plg ON (field.plugin_id = plg.id)");
if ($item_id)
{
$query->select("fordering.ordering");
$query->join("LEFT", "#__judownload_fields_ordering AS fordering ON (fordering.field_id = field.id AND fordering.item_id = " . (int) $item_id . " AND fordering.type = '$type')");
$query->order("fordering.ordering");
}
$query->join("", "#__judownload_fields_groups AS fg ON (fg.id = field.group_id)");
$query->where('fg.access IN (' . $accessLevel . ')');
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote($date->toSql());
$query->where('field.published = 1');
$query->where('field.publish_up <= ' . $nowDate);
$query->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')');
$query->where('(field.access IN (' . $accessLevel . ') OR field.who_can_download_can_access = 1)');
if ($field_group_id > 1)
{
//.........这里部分代码省略.........
示例8: getDownloadRuleErrorMessages
public static function getDownloadRuleErrorMessages($docId)
{
$error_messages = array();
$user = JFactory::getUser();
$asset = 'com_judownload.document.' . $docId;
if ($user->authorise('judl.document.download', $asset))
{
return true;
}
else
{
$error_messages[] = JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_DOWNLOAD');
}
$docObj = JUDownloadHelper::getDocumentById($docId);
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('judownload');
$pluginTriggerResults = $dispatcher->trigger('canDownload', array($docObj));
foreach ($pluginTriggerResults AS $result)
{
if ($result === true)
{
return true;
}
else
{
if (is_string($result))
{
$error_messages[] = $result;
}
}
}
return $error_messages;
}
示例9: getInput
public function getInput($fieldValue = null)
{
if (!$this->isPublished())
{
return "";
}
if ((JUDownloadHelper::getDocumentSubmitType($this->doc_id) == 'submit' && $this->canSubmit())
|| (JUDownloadHelper::getDocumentSubmitType($this->doc_id) == 'edit' && $this->canEdit())
)
{
$disabled = false;
}
else
{
$disabled = true;
}
$document = JFactory::getDocument();
$rootCat = JUDownloadFrontHelperCategory::getRootCategory();
JText::script('COM_JUDOWNLOAD_TOTAL_CATS_OVER_MAXIMUM_N_CATS');
JText::script('COM_JUDOWNLOAD_CATEGORY_X_ALREADY_EXIST');
$app = JFactory::getApplication();
if (isset($this->doc) && $this->doc->cat_id)
{
$params = JUDownloadHelper::getParams($this->doc->cat_id);
}
else
{
$params = JUDownloadHelper::getParams(null, $this->doc_id);
}
$db = JFactory::getDbo();
$docId = $this->doc_id;
$documentObject = JUDownloadHelper::getDocumentById($docId);
$secondaryCatIds = $secondaryCatIdsStr = "";
if ($fieldValue && !empty($fieldValue['main']))
{
$categoryId = (int) $fieldValue['main'];
if ($fieldValue['secondary'])
{
$secondaryCatIdsStr = $fieldValue['secondary'];
$secondaryCatIds = explode(",", $secondaryCatIdsStr);
}
$query = $db->getQuery(true);
$query->select("c.id, c.parent_id");
$query->from("#__judownload_categories AS c");
$query->select("field_group.id AS fieldgroup_id, field_group.name AS fieldgroup_name");
$query->join("LEFT", "#__judownload_fields_groups AS field_group ON (field_group.id = c.fieldgroup_id AND field_group.published = 1)");
$query->where("c.id = " . $categoryId);
$db->setQuery($query);
$mainCategory = $db->loadObject();
}
elseif ($docId)
{
$categories = $this->value;
foreach ($categories AS $category)
{
if ($category->main == 1)
{
$mainCategory = $category;
$query = $db->getQuery(true);
$query->select("field_group.id, field_group.name");
$query->from("#__judownload_fields_groups AS field_group");
$query->join("", "#__judownload_categories AS c on c.fieldgroup_id = field_group.id");
$query->where("c.id = " . $mainCategory->id);
$query->where("field_group.published = 1");
$db->setQuery($query);
$fieldGroup = $db->loadObject();
if (is_object($fieldGroup))
{
$mainCategory->fieldgroup_name = $fieldGroup->name;
$mainCategory->fieldgroup_id = $fieldGroup->id;
}
else
{
$mainCategory->fieldgroup_name = null;
$mainCategory->fieldgroup_id = null;
}
}
else
{
$secondaryCatIds[] = $category->id;
}
}
if ($secondaryCatIds)
{
$secondaryCatIdsStr = implode(",", $secondaryCatIds);
}
}
elseif ($app->input->getInt('cat_id'))
{
$categoryId = $app->input->getInt('cat_id');
//.........这里部分代码省略.........
示例10: getDocumentSubmitType
public function getDocumentSubmitType($documentId, $documentObject = null, $isNew = null)
{
if (!is_null($isNew)) {
if ($isNew) {
return 'submit';
}
}
if ($documentId == 0) {
return 'submit';
}
if (!is_object($documentObject)) {
$documentObject = JUDownloadHelper::getDocumentById($documentId);
}
if ($documentObject->approved == 0) {
return 'submit';
} else {
return 'edit';
}
}
示例11: insertUpdateDocument
public function insertUpdateDocument($data, $isInsert = true)
{
$db = JFactory::getDbo();
$iconDir = JPATH_ROOT . '/' . JUDownloadFrontHelper::getDirectory('document_icon_directory', 'media/com_judownload/images/document/');
$originalDir = $iconDir . 'original/';
$newMainCatId = $data['main_cat'];
$gallery = $data['gallery'];
$files = $data['files'];
$fieldsData = $data['fieldsData'];
$relatedDocs = $data['related_docs'];
$data = $data['data'];
$messages = array();
if (!$isInsert) {
$docObj = JUDownloadHelper::getDocumentById($data['id']);
if ($docObj->cat_id != $newMainCatId) {
$oldFieldGroup = JUDownloadHelper::getCategoryById($docObj->cat_id);
$newFieldGroup = JUDownloadHelper::getCategoryById($newMainCatId);
if ($oldFieldGroup->fieldgroup_id != $newFieldGroup->fieldgroup_id) {
$query = $db->getQuery(true);
$query->select("field.*");
$query->from("#__judownload_fields AS field");
$query->select("plg.folder");
$query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
$query->join("", "#__judownload_categories AS c ON (c.fieldgroup_id = field.group_id AND field.group_id != 1)");
$query->join("", "#__judownload_documents_xref AS dxref ON (dxref.cat_id = c.id AND dxref.main = 1)");
$query->join("", "#__judownload_documents AS d ON dxref.doc_id = d.id");
$query->where("d.id = " . $data['id']);
$query->group('field.id');
$query->order('field.ordering');
$db->setQuery($query);
$fields = $db->loadObjectList();
foreach ($fields as $field) {
$fieldObj = JUDownloadFrontHelperField::getField($field, $data['id']);
$fieldObj->onDelete();
}
}
}
}
$iconPath = '';
$iconFieldId = $this->field_name_id_array['icon'];
if (!empty($data['icon'])) {
$iconPath = $data['icon'];
unset($data['icon']);
}
if (!empty($fieldsData[$iconFieldId])) {
$iconPath = $fieldsData[$iconFieldId];
unset($fieldsData[$iconFieldId]);
}
$table = JTable::getInstance("Document", "JUDownloadTable");
if (!$table->bind($data) || !$table->check() || !$table->store()) {
return array('doc_id' => 0, 'messages' => $table->getErrors());
}
$docId = $table->id;
$categoriesField = new JUDownloadFieldCore_categories(null, $docId);
$categoriesField->is_new_doc = $isInsert;
$result = $categoriesField->storeValue($fieldsData[$this->field_name_id_array['cat_id']]);
if (!$result) {
$table->delete($docId);
return array('doc_id' => 0, 'messages' => $db->getErrorMsg());
}
$query = $db->getQuery(true);
$query->select("field.*");
$query->from("#__judownload_fields AS field");
$query->select("plg.folder");
$query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
$query->join("", "#__judownload_categories AS c ON (c.fieldgroup_id = field.group_id OR field.group_id = 1)");
$query->join("", "#__judownload_documents_xref AS dxref ON (dxref.cat_id = c.id AND dxref.main = 1)");
$query->join("", "#__judownload_documents AS d ON dxref.doc_id = d.id");
$query->where("d.id = {$docId}");
$query->where("field.field_name != 'id'");
$query->where("field.field_name != 'cat_id'");
$query->group('field.id');
$query->order('ordering ASC');
$db->setQuery($query);
$fields = $db->loadObjectList();
$docObj = JUDownloadHelper::getDocumentById($docId);
foreach ($fields as $field) {
if (isset($fieldsData[$field->id])) {
$fieldObj = JUDownloadFrontHelperField::getField($field, $docObj);
$fieldObj->fields_data = $fieldsData;
$fieldValue = $fieldsData[$field->id];
$fieldObj->is_new_doc = $isInsert;
$fieldValue = $fieldObj->onImportDocument($fieldValue);
$fieldObj->storeValue($fieldValue);
}
}
if ($iconPath) {
$iconPath = JUDownloadHelper::getPhysicalPath($iconPath);
if (!$iconPath) {
$messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_FILE_S_NOT_FOUND', $iconPath);
} else {
if ($data['id'] > 0) {
if ($table->icon) {
if (JFile::exists($iconDir . $table->icon)) {
JFile::delete($iconDir . $table->icon);
JFile::delete($originalDir . $table->icon);
}
}
}
$iconName = basename($iconPath);
//.........这里部分代码省略.........
示例12: foreach
?>
" name="documentid[]" id="doc<?php
echo $i;
?>
" />
<?php
}
?>
</td>
<?php
foreach ($this->model->fields_use as $field) {
echo '<td>';
switch ($field->field_name) {
case "title":
if (!$item->main) {
$main_cat_id = JUDownloadHelper::getDocumentById($item->id)->cat_id;
?>
<a href="<?php
echo JRoute::_('index.php?option=com_judownload&view=listcats&cat_id=' . $main_cat_id);
?>
"><?php
echo JUDownloadHelper::generateCategoryPath($main_cat_id);
?>
</a> >
<?php
}
if ($item->checked_out) {
echo JHtml::_('jgrid.checkedout', $i, $item->checked_out_name, $item->checked_out_time, 'documents.', $canCheckin || $user->authorise('core.manage', 'com_checkin'), 'doc');
}
if ($canEdit || $canEditOwn) {
?>
示例13: getCurrentTemplateStyle
public static function getCurrentTemplateStyle($view = '', $id = null)
{
$app = JFactory::getApplication();
$jInput = $app->input;
if (!$view)
{
$view = $jInput->getString('view', '');
}
if ($jInput->getString('option', '') != 'com_judownload')
{
$view = '';
}
if (!$id)
{
switch ($view)
{
case 'form':
$id = $jInput->getInt('id', 0);
$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
$cat_id = $jInput->getInt('cat_id', $rootCategory->id);
break;
case 'document':
$id = $jInput->getInt('id', 0);
break;
case 'category':
$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
$id = $jInput->getInt('id', $rootCategory->id);
break;
}
}
switch ($view)
{
case 'form':
if ($id)
{
$templateStyleObject = self::getTemplateStyleOfDocument($id);
$documentObject = JUDownloadHelper::getDocumentById($id);
$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $documentObject->template_params);
}
else
{
$templateStyleObject = self::getTemplateStyleOfCategory($cat_id);
$categoryObject = JUDownloadHelper::getCategoryById($cat_id);
$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params);
}
break;
case 'document':
$templateStyleObject = self::getTemplateStyleOfDocument($id);
$documentObject = JUDownloadHelper::getDocumentById($id);
$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $documentObject->template_params);
break;
case 'category':
$templateStyleObject = self::getTemplateStyleOfCategory($id);
$categoryObject = JUDownloadHelper::getCategoryById($id);
$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params);
break;
default:
$templateStyleObject = self::getDefaultTemplateStyle();
$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id);
break;
}
return $templateStyleObject;
}
示例14: getDocumentSubmitType
public static function getDocumentSubmitType($documentId)
{
if ($documentId == 0) {
return 'submit';
}
$documentObject = JUDownloadHelper::getDocumentById($documentId);
if ($documentObject->approved == 0) {
return 'submit';
} else {
return 'edit';
}
}
示例15: canDownloadDocument
public function canDownloadDocument($documentId, $checkPassword = true)
{
$storeId = md5(__METHOD__ . "::$documentId::" . (int) $checkPassword);
if (!isset($this->cache[$storeId]))
{
$mainCategoryId = JUDownloadFrontHelperCategory::getMainCategoryId($documentId);
$canDoCategory = JUDownloadFrontHelperPermission::canDoCategory($mainCategoryId);
if (!$canDoCategory)
{
$this->cache[$storeId] = false;
return $this->cache[$storeId];
}
$isDocumentOwner = JUDownloadFrontHelperPermission::isDocumentOwner($documentId);
if ($isDocumentOwner)
{
$asset = 'com_judownload.document.' . $documentId;
$user = JFactory::getUser();
if ($user->authorise('judl.document.download.own.no_restrict', $asset))
{
$this->cache[$storeId] = true;
return $this->cache[$storeId];
}
}
$isModerator = JUDownloadFrontHelperModerator::isModerator();
if ($isModerator)
{
$documentObject = JUDownloadHelper::getDocumentById($documentId);
if ($documentObject->approved < 1)
{
$modCanApprove = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCategoryId, 'document_approve');
if ($modCanApprove)
{
$this->cache[$storeId] = true;
return $this->cache[$storeId];
}
}
$modCanDownload = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCategoryId, 'document_download');
if ($modCanDownload)
{
$this->cache[$storeId] = true;
return $this->cache[$storeId];
}
}
if ($isDocumentOwner)
{
$userCanDoDocument = true;
}
else
{
$userCanDoDocument = JUDownloadFrontHelperPermission::userCanDoDocument($documentId, true);
}
if (!$userCanDoDocument)
{
$this->cache[$storeId] = false;
return $this->cache[$storeId];
}
if (!$isModerator || ($isModerator && !$modCanDownload))
{
$validDownloadRules = JUDownloadFrontHelperDocument::getDownloadRuleErrorMessages($documentId);
if ($validDownloadRules !== true)
{
$message = array();
$message = array_merge($message, $validDownloadRules);
$this->setError(implode("<br/>", $message));
$this->cache[$storeId] = false;
return $this->cache[$storeId];
}
}
$documentObject = JUDownloadHelper::getDocumentById($documentId);
$hasPassword = JUDownloadFrontHelperDocument::documentHasPassword($documentObject);
if ($hasPassword && $checkPassword)
//.........这里部分代码省略.........