本文整理汇总了PHP中JUDownloadHelper::getCategoryById方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::getCategoryById方法的具体用法?PHP JUDownloadHelper::getCategoryById怎么用?PHP JUDownloadHelper::getCategoryById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDownloadHelper
的用法示例。
在下文中一共展示了JUDownloadHelper::getCategoryById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
protected function getInput()
{
$html = '';
$db = JFactory::getDbo();
$options = JUDownloadHelper::getFieldGroupOptions();
if ($this->element['usenone'] == 'true') {
array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
}
if ($this->element['useinherit'] == 'true') {
$appendInherit = "";
if ($this->form->getValue("id")) {
$appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
if ($this->form->getValue("id") > 0) {
$catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
if ($catObj->fieldgroup_id > 1) {
$query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
$db->setQuery($query);
$fieldgroup = $db->loadObject();
$groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
$appendInherit = "( " . $groupName . " )";
}
}
}
array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
} else {
array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
}
$required_class = $this->element['required'] == 'true' ? 'required' : '';
$attributes = "class=\"inputbox {$required_class}\"";
$html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
return $html;
}
示例2: getCriteriaGroupIdByCategoryId
public static function getCriteriaGroupIdByCategoryId($mainCatId)
{
$catObj = JUDownloadHelper::getCategoryById($mainCatId);
if ($catObj)
{
return $catObj->criteriagroup_id;
}
return null;
}
示例3: calculatorInheritStyle
protected function calculatorInheritStyle($cat_id)
{
do {
$category = JUDownloadHelper::getCategoryById($cat_id);
$style_id = $category->style_id;
$cat_id = $category->parent_id;
} while ($style_id == -1 && $cat_id != 0);
if ($style_id == -2) {
return $this->getStyle();
} else {
return $this->getStyle($style_id);
}
}
示例4: getInput
protected function getInput()
{
$db = JFactory::getDbo();
$query = 'SELECT id AS value, name AS text, published FROM #__judownload_criterias_groups ';
$db->setQuery($query);
$options = $db->loadObjectList();
$users = JFactory::getUser();
foreach ($options as $key => $option) {
if ($option->published != 1) {
$option->text = '[ ' . $option->text . ' ]';
}
if (!$users->authorise('core.create', 'com_judownload.criteriagroup.' . $option->value)) {
unset($options[$key]);
}
}
$required_class = $this->element['required'] == 'true' ? 'required' : '';
$class = $this->element['class'];
if ($this->element['usenone'] == 'true') {
array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
}
if ($this->element['useinherit'] == 'true') {
$appendInherit = "";
if ($this->form->getValue("id")) {
if ($this->form->getValue("criteriagroup_id") > 0) {
$appendInherit = $this->getCriteriaGroupName($this->form->getValue("criteriagroup_id"));
} else {
$category = JUDownloadHelper::getCategoryById($this->form->getValue("id"));
$parent = JUDownloadHelper::getCategoryById($category->parent_id);
$appendInherit = $this->getCriteriaGroupName($parent->criteriagroup_id);
}
}
array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
} else {
array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_CRITERIAL_GROUP')));
}
$canChange = true;
if ($this->form->getValue('id')) {
$query = "SELECT COUNT(*) FROM #__judownload_criterias_values WHERE criteria_id = " . $this->form->getValue('id');
$db->setQuery($query);
$canChange = $db->loadResult() ? false : true;
}
if ($canChange) {
$attributes = "class=\"inputbox {$class} {$required_class}\"";
$html = JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
} else {
$attributes = "class=\"inputbox {$class}\" disabled";
$html = JHtml::_('select.genericlist', $options, "_" . $this->name, $attributes, 'value', 'text', $this->value, $this->id);
$html .= "<input class=\"{$required_class}\" type=\"hidden\" value=\"" . $this->value . "\" name=\"" . $this->name . "\" />";
}
return $html;
}
示例5: getInput
protected function getInput()
{
$db = JFactory::getDbo();
$query = 'SELECT id AS value, name AS text, published FROM #__judownload_criterias_groups ';
$db->setQuery($query);
$options = $db->loadObjectList();
if (!empty($options)) {
foreach ($options as $option) {
if ($option->published != 1) {
$option->text = "[" . $option->text . "]";
}
}
}
$users = JFactory::getUser();
$required_class = $this->element['required'] == 'true' ? 'required' : '';
$class = $this->element['class'];
$attributes = "class=\"inputbox {$class} {$required_class}\"";
if ($this->element['usenone'] == 'true') {
array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
}
if ($this->element['useinherit'] == 'true') {
$appendInherit = "";
if ($this->form->getValue("id")) {
if ($this->form->getValue("criteriagroup_id") > 0) {
$appendInherit = $this->getCriteriaGroupName($this->form->getValue("criteriagroup_id"));
} else {
$category = JUDownloadHelper::getCategoryById($this->form->getValue("id"));
$parent = JUDownloadHelper::getCategoryById($category->parent_id);
$appendInherit = $this->getCriteriaGroupName($parent->criteriagroup_id);
}
}
array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
} else {
array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_CRITERIAL_GROUP')));
}
$html = JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
return $html;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: docChangeCategory
public function docChangeCategory()
{
$app = JFactory::getApplication();
if ($app->input->get('action', '') == 'update-maincat') {
$ori_cat_id = $app->input->getInt('ori_cat_id', 0);
$ori_cat = JUDownloadHelper::getCategoryById($ori_cat_id);
$data['ori_field_group_id'] = 0;
$data['new_field_group_id'] = 0;
$data['new_field_group_name'] = "";
$data['path'] = "";
if ($ori_cat) {
$data['ori_field_group_id'] = $ori_cat->fieldgroup_id;
}
$new_cat_id = $app->input->getInt('new_cat_id', 0);
$rootCat = JUDownloadFrontHelperCategory::getRootCategory();
$params = JUDownloadHelper::getParams();
if ($rootCat->id == $new_cat_id && !$params->get('allow_add_doc_to_root', 0)) {
return "";
}
$new_cat = JUDownloadHelper::getCategoryById($new_cat_id);
if ($new_cat) {
$db = JFactory::getDbo();
$query = "SELECT id, name FROM #__judownload_fields_groups WHERE id = " . $new_cat->fieldgroup_id . " AND published = 1";
$db->setQuery($query);
$fieldgroup = $db->loadObject();
if ($fieldgroup) {
$data['new_field_group_id'] = $fieldgroup->id;
$data['new_field_group_name'] = $fieldgroup->name;
}
$data['path'] = JUDownloadHelper::generateCategoryPath($new_cat_id);
}
if ($data['ori_field_group_id'] != $data['new_field_group_id']) {
$data['msg_field_group'] = JText::_('COM_JUDOWNLOAD_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_FIELD_GROUP_WARNING');
}
$documentId = $app->input->getInt('id', 0);
$data['message_style'] = JText::_('COM_JUDOWNLOAD_INHERIT');
if ($documentId) {
$documentObject = JUDownloadHelper::getDocumentById($documentId);
if ($documentObject->style_id == -1) {
$oldStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($documentId->cat_id);
$newStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id);
if ($oldStyleObject->template_id != $newStyleObject->template_id) {
$data['msg_style'] = JText::_('COM_JUDOWNLOAD_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_TEMPLATE_WARNING');
}
}
$newTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id);
$data['message_style'] = JText::_('COM_JUDOWNLOAD_INHERIT') . ' (' . $newTemplateStyleObject->title . ' [' . $newTemplateStyleObject->template_title . ' ]' . ')';
}
return json_encode($data);
} elseif ($app->input->getInt('action', '') == 'insert_secondary_cat') {
$cat_id_str = $app->input->get('secondary_cat_id', '', 'string');
$html = '';
if (!empty($cat_id_str)) {
$cat_id_arr = explode(",", $cat_id_str);
foreach ($cat_id_arr as $key => $cat_id) {
$html .= "<li id=\"cat-" . $cat_id . "\"><a class=\"drag-icon\"></a><span>" . JUDownloadHelper::generateCategoryPath($cat_id) . "</span><a href=\"#\" onclick=\"return false\" class=\"remove-secondary-cat\" ><i class=\"icon-minus fa fa-minus-circle\"></i> " . JText::_('COM_JUDOWNLOAD_REMOVE') . "</a></li>";
}
}
return $html;
}
}
示例8: implode
case "featured":
echo '<td>';
echo JHtml::_('judownloadadministrator.featured', $item->featured, $i, $canChange, 'categories');
echo '</td>';
break;
case "rel_cats":
echo '<td>';
$rel_categories = $model->getRelatedCategories($item->id);
if ($rel_categories) {
echo implode(", ", $rel_categories);
}
echo '</td>';
break;
case "parent_id":
echo '<td>';
$_category = JUDownloadHelper::getCategoryById($item->parent_id);
if ($_category) {
echo $_category->title;
}
echo '</td>';
break;
case "intro_image":
case "detail_image":
echo '<td>';
if ($item->images) {
$imgObj = json_decode($item->images);
if (isset($imgObj->{$field}) && $imgObj->{$field}) {
$image_path = $field == "intro_image" ? $intro_image_path : $detail_image_path;
echo '<a class="modal" href="' . $image_path . $imgObj->{$field} . '"><img src="' . $image_path . $imgObj->{$field} . '" style="max-width:30px; max-height:30px" /></a>';
} else {
echo ' ';
示例9: PHPValidate
public function PHPValidate($values)
{
$rootCat = JUDownloadFrontHelperCategory::getRootCategory();
if (isset($this->doc) && $this->doc->cat_id)
{
$params = JUDownloadHelper::getParams($this->doc->cat_id);
}
else
{
$params = JUDownloadHelper::getParams(null, $this->doc_id);
}
$mainCatId = $values['main'];
$secondaryCatIds = array_filter(explode(",", $values['secondary']));
if (!$mainCatId)
{
return JText::_("COM_JUDOWNLOAD_PLEASE_SELECT_A_CATEGORY");
}
if ($mainCatId == $rootCat->id && !$params->get('allow_add_doc_to_root', 0))
{
return JText::_("COM_JUDOWNLOAD_CAN_NOT_ADD_DOCUMENT_TO_ROOT_CATEGORY");
}
if (!JUDownloadHelper::getCategoryById($mainCatId))
{
return JText::_("COM_JUDOWNLOAD_INVALID_CATEGORY");
}
if (1 && (count($secondaryCatIds) + 1 > 1))
{
return JText::sprintf("COM_JUDOWNLOAD_NUMBER_OF_CATEGORY_OVER_MAX_N_CATEGORIES", 1);
}
if (!$this->doc_id)
{
if (!JUDownloadFrontHelperPermission::canSubmitDocument($mainCatId))
{
$category = JUDownloadHelper::getCategoryById($mainCatId);
return JText::sprintf("COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_SUBMIT_DOCUMENT_TO_THIS_CATEGORY", $category->title);
}
}
else
{
$mainCatIdDB = JUDownloadFrontHelperCategory::getMainCategoryId($this->doc_id);
if ($mainCatId != $mainCatIdDB)
{
if (!JUDownloadFrontHelperPermission::canSubmitDocument($mainCatId))
{
$category = JUDownloadHelper::getCategoryById($mainCatId);
return JText::sprintf("COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_SUBMIT_DOCUMENT_TO_THIS_CATEGORY", $category->title);
}
}
$app = JFactory::getApplication();
if ($app->isSite())
{
if ($mainCatId != $mainCatIdDB)
{
if (!$params->get('can_change_main_category', 1))
{
return false;
}
}
if (!$params->get('can_change_secondary_categories', 1))
{
$secondaryCatIdsDB = $this->getSecondaryCategoryIds($this->doc_id);
if (count($secondaryCatIds) && count($secondaryCatIdsDB))
{
if (array_diff($secondaryCatIds, $secondaryCatIdsDB) || array_diff($secondaryCatIdsDB, $secondaryCatIds))
{
return false;
}
}
}
}
}
return true;
}
示例10: calculatorInheritLayout
protected function calculatorInheritLayout($items, $cat_id)
{
do {
$category = JUDownloadHelper::getCategoryById($cat_id);
$layout = $category->layout;
$cat_id = $category->parent_id;
} while ($layout == -1);
if ($layout == -2) {
return $this->getLayout($items);
} else {
return $this->getLayout($items, $layout);
}
}
示例11: moveDocuments
//.........这里部分代码省略.........
if (!$canDoEdit) {
if (!$user->id) {
JError::raiseWarning(100, JText::sprintf('COM_JUDOWNLOAD_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_DOCUMENT', $table->title));
continue;
} else {
if ($user->id == $table->created_by) {
$canDoEditOwn = $user->authorise('judl.document.edit.own', $assetName);
if (!$canDoEditOwn) {
JError::raiseWarning(100, JText::sprintf('COM_JUDOWNLOAD_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_DOCUMENT', $table->title));
continue;
}
}
}
}
$query = "SELECT cat_id FROM #__judownload_documents_xref WHERE doc_id = " . $doc_id . " AND main=1";
$db->setQuery($query);
$cat_id = $db->loadResult();
if ($tocat_id == $cat_id) {
continue;
}
$result = $dispatcher->trigger($this->onContentBeforeMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
if ($table->style_id == -1) {
$oldTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($cat_id);
$newTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($tocat_id);
if ($oldTemplateStyleObject->template_id != $newTemplateStyleObject->template_id) {
if (in_array('keep_template_params', $move_option_arr)) {
$table->style_id = $oldTemplateStyleObject->id;
} else {
$query = "UPDATE #__judownload_documents SET template_params = '' WHERE id=" . $doc_id;
$db->setQuery($query);
$db->execute();
}
}
}
$query = "SELECT COUNT(*) FROM #__judownload_documents_xref WHERE cat_id=" . $tocat_id . " AND doc_id=" . $doc_id . " AND main=0";
$db->setQuery($query);
$is_secondary_cat = $db->loadResult();
if ($is_secondary_cat) {
$query = "DELETE FROM #__judownload_documents_xref WHERE doc_id=" . $doc_id . " AND main=1";
$db->setQuery($query);
$db->execute();
$query = "UPDATE #__judownload_documents_xref SET main=1 WHERE cat_id=" . $tocat_id . " AND doc_id=" . $doc_id;
$db->setQuery($query);
$db->execute();
} else {
$query = "UPDATE #__judownload_documents_xref SET cat_id=" . $tocat_id . " WHERE doc_id=" . $doc_id . " AND main=1";
$db->setQuery($query);
$db->execute();
}
if (in_array('keep_permission', $move_option_arr)) {
$query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ' WHERE name="com_judownload.document.' . $doc_id . '"';
$db->setQuery($query);
$db->execute();
} else {
$query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ', `rules` = "{}" WHERE name="com_judownload.document.' . $doc_id . '"';
$db->setQuery($query);
$db->execute();
}
$moved_documents[] = $doc_id;
$this->cleanCache();
$dispatcher->trigger($this->onContentAfterMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
}
$total_moved_documents = count($moved_documents);
if ($total_moved_documents) {
$old_field_groupid = JUDownloadHelper::getCategoryById($cat_id)->fieldgroup_id;
$new_field_groupid = JUDownloadHelper::getCategoryById($tocat_id)->fieldgroup_id;
$keep_extra_fields = in_array("keep_extra_fields", $move_option_arr);
if ($keep_extra_fields) {
$keep_extra_fields = $old_field_groupid == $new_field_groupid ? true : false;
}
if (!$keep_extra_fields) {
foreach ($moved_documents as $doc_id) {
JUDownloadHelper::deleteFieldValuesOfDocument($doc_id);
}
}
$old_criteria_groupid = JUDownloadHelper::getCategoryById($cat_id)->criteriagroup_id;
$new_criteria_groupid = JUDownloadHelper::getCategoryById($tocat_id)->criteriagroup_id;
$keep_rates = in_array("keep_rates", $move_option_arr);
if ($keep_rates) {
$keep_rates = $old_criteria_groupid == $new_criteria_groupid ? true : false;
}
if (!$keep_rates) {
JTable::addIncludePath(JPATH_ADMINISTRATOR . "/components/com_judownload/tables");
$ratingTable = JTable::getInstance("Rating", "JUDownloadTable");
foreach ($moved_documents as $doc_id) {
$query = "SELECT id FROM #__judownload_rating WHERE doc_id = " . $doc_id;
$db->setQuery($query);
$ratingIds = $db->loadColumn();
foreach ($ratingIds as $ratingId) {
$ratingTable->delete($ratingId);
}
}
}
}
return $total_moved_documents;
}
示例12: getInput
protected function getInput()
{
$html = '';
$db = JFactory::getDbo();
$core_plugin = false;
if ($this->form->getValue("id") && $this->form->getValue("plugin_id")) {
$query = "SELECT core FROM #__judownload_plugins WHERE id = " . $this->form->getValue("plugin_id");
$db->setQuery($query);
$core_plugin = $db->loadResult();
}
if ($core_plugin) {
$query = "SELECT name FROM #__judownload_fields_groups WHERE id = " . $this->value;
$db->setQuery($query);
$group_name = $db->loadResult();
$html .= '<span class="readonly">' . $group_name . '</span>';
$html .= '<input type="hidden" name="' . $this->name . '" value="1" />';
} else {
$document = JFactory::getDocument();
$script = "function changeFieldGroup(self, select ,value){\r\n\t\t\t\t\t\t\tif(value){\r\n\t\t\t\t\t\t\t\tif (self.value != select){ alert('" . JText::_('COM_JUDOWNLOAD_CHANGE_FIELD_GROUP_WARNING') . "');}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}";
$document->addScriptDeclaration($script);
$app = JFactory::getApplication();
if ($app->input->get('view') == 'field') {
$options = JUDownloadHelper::getFieldGroupOptions(true, false);
} else {
$options = JUDownloadHelper::getFieldGroupOptions();
}
if ($this->element['usenone'] == 'true') {
array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
}
if ($this->element['useinherit'] == 'true') {
$appendInherit = "";
if ($this->form->getValue("id")) {
$appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
if ($this->form->getValue("id") > 0) {
$catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
if ($catObj->fieldgroup_id > 1) {
$query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
$db->setQuery($query);
$fieldgroup = $db->loadObject();
$groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
$appendInherit = "( " . $groupName . " )";
}
}
}
array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
} else {
array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
}
$required_class = $this->element['required'] == 'true' ? 'required' : '';
if ($app->input->get('view') == 'field') {
$canChange = true;
if ($this->form->getValue('id')) {
$query = "SELECT COUNT(*) FROM #__judownload_fields_values WHERE field_id = " . $this->form->getValue('id');
$db->setQuery($query);
$canChange = $db->loadResult() ? false : true;
}
if ($canChange) {
$attributes = "class=\"inputbox {$required_class}\"";
$html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
} else {
$attributes = "class=\"inputbox\" disabled";
$html .= JHtml::_('select.genericlist', $options, "_" . $this->name, $attributes, 'value', 'text', $this->value, $this->id);
$html .= "<input class=\"{$required_class}\" type=\"hidden\" value=\"" . $this->value . "\" name=\"" . $this->name . "\" />";
}
} else {
$onchange = "onchange=\"changeFieldGroup(this, " . $this->value . ", " . $this->form->getValue("fieldgroup_id") . " );\"";
$attributes = "class=\"inputbox {$required_class}\" {$onchange}";
$html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
}
}
return $html;
}
示例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: parseCommentTxt
public function parseCommentTxt($comment, $catId = 0, $docId = 0)
{
$user = JFactory::getUser();
if ($user->get('guest'))
{
$userName = JText::_('COM_JUDOWNLOAD_GUEST');
}
else
{
$userName = $user->name;
}
$catTitle = $docTitle = '';
if ($catId)
{
$catObj = JUDownloadHelper::getCategoryById($catId);
$catTitle = $catObj->title;
}
if ($docId)
{
$docObj = JUDownloadHelper::getDocumentById($docId);
$docTitle = $docObj->title;
}
$comment = str_replace("{user_id}", $user->id, $comment);
if ($catTitle)
{
$comment = str_replace("{cat_title}", $catTitle, $comment);
}
else
{
$comment = str_replace("{cat_title}", '', $comment);
}
if ($docTitle)
{
$comment = str_replace("{doc_title}", $docTitle, $comment);
}
else
{
$comment = str_replace("{doc_title}", '', $comment);
}
$comment = str_replace("{user_name}", $userName, $comment);
preg_match('/{date:?(.*?)}/', $comment, $matches);
if (!empty($matches))
{
if (empty($matches[1]))
{
$dateFormat = 'Y-m-d H:i:s';
}
else
{
$dateFormat = $matches[1];
}
$timeNow = JHtml::date('now', 'Y-m-d H:i:s', true);
$date = date($dateFormat, strtotime($timeNow));
$comment = str_replace($matches[0], $date, $comment);
}
return $comment;
}
示例15: getFieldGroupsByCatIds
public static function getFieldGroupsByCatIds($catIds, $search_sub_categories = false)
{
if (!$catIds) {
return null;
}
$field_groups = array();
foreach ($catIds as $catId) {
if ($search_sub_categories) {
$categoryTree = JUDownloadHelper::getCategoryTree($catId, true, true);
foreach ($categoryTree as $sub_category) {
if ($sub_category->fieldgroup_id > 0) {
$field_groups[] = $sub_category->fieldgroup_id;
}
}
} else {
$catObj = JUDownloadHelper::getCategoryById($catId);
$field_groups[] = $catObj->fieldgroup_id ? $catObj->fieldgroup_id : 1;
}
}
$field_groups = array_unique($field_groups);
if ($field_groups) {
return implode(",", $field_groups);
} else {
return null;
}
}