Commit ad360f23 authored by Dmitriy Samoshenko's avatar Dmitriy Samoshenko
Browse files

fixed #30

parent 76afbd35
......@@ -36,12 +36,13 @@ class iaCommon extends abstractCore
$out = '';
$iaCore = iaCore::instance();
$iaView = &$iaCore->iaView;
$title = 'title_'. $this->iaCore->language['iso'];
$isBackend = (iaCore::ACCESS_ADMIN == $iaCore->getAccessType());
foreach ($categories as $cat) {
if ($cat['parent_id'] == $parentId) {
$cat['title'] = ($cat['level'] > 1 || $isBackend ? str_repeat('  ', $cat['level'] - ($isBackend ? 0 : 1)) : '') . $cat['title'];
$cat[$title] = ($cat['level'] > 1 || $isBackend ? str_repeat('  ', $cat[$title] - ($isBackend ? 0 : 1)) : '') . $cat[$title];
if ($isBackend && $iaView->name() == 'articlecat_edit' && isset($_GET['id']) && $_GET['id'] == $cat['id']) {
$out .= '<optgroup label="' . $cat['title'] . ' [' . iaLanguage::get('self', 'SELF CATEGORY') . ']" disabled="disabled">';
$out .= $this->_buildCategoriesTree($categories, $cat['id'], $selected);
......@@ -55,7 +56,7 @@ class iaCommon extends abstractCore
if (!$locked && iaCore::ACCESS_FRONT == $iaCore->getAccessType()
|| iaCore::ACCESS_ADMIN == $iaCore->getAccessType()) {
$out .= '<option value="' . $cat['id'] . '" ' . ($selected == $cat['id'] ? ' selected="selected"' : '') . ' ' . ($isBackend ? ' alias="' . $cat['title_alias'] . '"' : '') . '>' . $cat['title'] . '</option>';
$out .= '<option value="' . $cat['id'] . '" ' . ($selected == $cat['id'] ? ' selected="selected"' : '') . ' ' . ($isBackend ? ' alias="' . $cat['title_alias'] . '"' : '') . '>' . $cat[$title] . '</option>';
} else {
$out .= '<optgroup label="' . $cat['title'] . '"></optgroup>';
}
......@@ -76,9 +77,11 @@ class iaCommon extends abstractCore
*/
public function getCategoriesTree($selected = false)
{
$fields = ['id', 'parent_id', 'title', 'level', 'locked', 'title_alias'];
$title = 'title_'. $this->iaCore->language['iso'];
$fields = ['id', 'parent_id', $title, 'level', 'locked', 'title_alias'];
$stmt = '`status` = :status AND `locked` = 0 ';
$order = 'ORDER BY `' . ('by title' == $this->iaCore->get('articles_categs_sort', 'by title') ? 'title' : 'order') . '`';
$order = 'ORDER BY `' . ('by ' . $title == $this->iaCore->get('articles_categs_sort', 'by ' . $title) ? $title : 'order') . '`';
$this->iaDb->bind($stmt, ['status' => iaCore::STATUS_ACTIVE]);
......
......@@ -308,6 +308,7 @@
<phrase category="frontend" key="valid_google_adsense_format">Valid format is ca-pub-XXXX... (16 chars length number). Otherwise will be ignored.</phrase>
<phrase category="frontend" key="continue_reading"><![CDATA[Continue reading &rarr;]]></phrase>
<phrase category="frontend" key="subcategory">Subcategory</phrase>
<phrase category="frontend" key="field_category_id_annotation">Category</phrase>
</phrases>
<blocks>
......
......@@ -81,7 +81,11 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$messages[] = iaLanguage::get('confirmation_code_incorrect');
}
$itemData['category_id'] = (int)$_POST['tree_id'];
if ($iaCore->get('articles_categories_selector') == 'Handy javascript tree') {
$itemData['category_id'] = (int)$_POST['tree_id'];
} else {
$itemData['category_id'] = (int)$_POST['category_id'];
}
if (empty($itemData['category_id'])) {
$messages[] = iaLanguage::getf('field_is_not_selected', ['field' => iaLanguage::get('category')]);
......@@ -175,7 +179,7 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$url || $url = 'http://';
$article = [
'title' => '',
'title'. $iaView->language => '',
'body' => '',
'category_id' => empty($_GET['category']) ? 0 : (int)$_GET['category_id'],
'url' => $url,
......@@ -193,6 +197,7 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$category = $aiArticlecat->getById($article['category_id']);
$iaView->assign('category', $category);
$iaView->assign('tree', $aiArticlecat->getTreeVars($category['id'], $category['title']));
} else {
$categoryOptions = $iaCore->factoryModule('common', IA_CURRENT_MODULE, iaCore::FRONT)
->getCategoriesTree($article['category_id']);
......@@ -201,7 +206,6 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
}
$iaView->assign('sections', $iaField->getTabs($iaArticle->getItemName(), $article));
$iaView->assign('tree', $aiArticlecat->getTreeVars($category['id'], $category['title']));
$iaView->display('manage');
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment