Skip to content

Commit

Permalink
close #560
Browse files Browse the repository at this point in the history
виджет офновостей в админке,
+ разное по мелочи
  • Loading branch information
fuzegit committed Jul 23, 2017
1 parent 866c9d3 commit ea42a4c
Show file tree
Hide file tree
Showing 23 changed files with 717 additions and 92 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/system/controllers/api/
/system/languages/ru/controllers/api/
/system/languages/en/controllers/api/
/templates/default/controllers/api/
/templates/default/controllers/api/
/cache/rsscache/
4 changes: 4 additions & 0 deletions credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ Third-party plugins, libraries and resources included in InstantCMS:
jQuery UI Touch Punch
by David Furfero
http://touchpunch.furf.com/

jQuery CSS Customizable Scrollbar
by Yuriy Khabarov
https://github.com/gromo/jquery.scrollbar/
10 changes: 5 additions & 5 deletions install/steps/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function step($is_submit){

function check_requirements(){

$min_php_version = '5.3.0';
$vars = array('magic_quotes_gpc' => 0, 'register_globals' => 0);
$extensions = array('date', 'gd', 'json', 'mbstring', 'mysqli', 'session', 'filter');
$min_php_version = '5.4.0';
$vars = array('magic_quotes_gpc' => 0, 'register_globals' => 0);
$extensions = array('date', 'gd', 'json', 'mbstring', 'mysqli', 'session', 'filter');
$extensions_extra = array('ftp', 'memcache', 'zip', 'curl');

sort($extensions);
Expand All @@ -30,7 +30,7 @@ function check_requirements(){

$info['php'] = array(
'version' => PHP_VERSION,
'valid' => (version_compare(PHP_VERSION, $min_php_version) >= 0)
'valid' => (version_compare(PHP_VERSION, $min_php_version) >= 0)
);

$info['valid'] = $info['valid'] && $info['php']['valid'];
Expand All @@ -56,4 +56,4 @@ function check_requirements(){

return $info;

}
}
5 changes: 5 additions & 0 deletions system/controllers/admin/actions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function run(){
LANG_CP_DASHBOARD_SI_ZENDG => in_array('Zend Guard Loader', $extensions)
);

$dashboard_blocks[] = array(
'title' => LANG_CP_DASHBOARD_NEWS,
'html' => $this->cms_template->getRenderedChild('index_news', array())
);

$dashboard_blocks[] = array(
'title' => LANG_CP_DASHBOARD_SYSINFO,
'html' => $this->cms_template->getRenderedChild('index_sysinfo', array(
Expand Down
57 changes: 57 additions & 0 deletions system/controllers/admin/actions/load_icms_news.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

class actionAdminLoadIcmsNews extends cmsAction {

private $news_link = array(
'icms' => 'http://www.instantcms.ru/rss/content/2/feed.rss',
'icms_addons' => 'http://addons.instantcms.ru/rss/feed/addons',
'icms_docs' => 'http://docs.instantcms.ru/feed.php'
);

private $news_count = 10;

public function run($target){

if (!$this->request->isAjax()) { cmsCore::error404(); }

if (!$target || !in_array($target, array_keys($this->news_link))) { cmsCore::error404(); }

cmsCore::loadLib('lastrss.class');

$rss = new lastRSS;

$rss->cache_dir = cmsConfig::get('cache_path');
$rss->cache_time = 3600;
$rss->stripHTML = true;
$rss->cp = 'UTF-8';
$rss->items_limit = $this->news_count;

$items = array();

$res = $rss->get($this->news_link[$target]);

if(!empty($res['items'])){
foreach ($res['items'] as $item) {

$item['target_title'] = empty($res['title']) ?
(empty($res['image_title']) ? '' : $res['image_title']) :
$res['title'];

$item['target_description'] = empty($res['description']) ?
(empty($res['image_description']) ? '' : $res['image_description']) :
$res['description'];

$items[] = $item;

}
}

if(!$items){ $this->halt(LANG_NO_ITEMS); }

$this->cms_template->renderPlain('index_news_data', array(
'items' => $items
));

}

}
29 changes: 28 additions & 1 deletion system/controllers/content/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ public function renderItemsList($ctype, $page_url, $hide_filter=false, $category

// Получаем количество и список записей
$total = $this->model->getContentItemsCount($ctype['name']);
$items = $this->model->getContentItems($ctype['name'], function ($item, $model) use ($ctype, $hide_except_title){
$items = $this->model->getContentItems($ctype['name'], function ($item, $model, $ctype_name, $user)
use ($ctype, $hide_except_title, $fields){

$item['ctype'] = $ctype;
$item['ctype_name'] = $ctype['name'];
Expand All @@ -210,6 +211,32 @@ public function renderItemsList($ctype, $page_url, $hide_filter=false, $category
$item['private_item_hint'] = LANG_PRIVACY_PRIVATE_HINT;
}

// строим поля списка
foreach($fields as $field){

if ($field['is_system'] || !$field['is_in_list'] || !isset($item[$field['name']])) { continue; }
if ($field['groups_read'] && !$user->isInGroups($field['groups_read'])) { continue; }
if (!$item[$field['name']] && $item[$field['name']] !== '0') { continue; }

if (!isset($field['options']['label_in_list'])) {
$label_pos = 'none';
} else {
$label_pos = $field['options']['label_in_list'];
}

$field_html = $field['handler']->setItem($item)->parseTeaser($item[$field['name']]);
if (!$field_html) { continue; }

$item['fields'][$field['name']] = array(
'label_pos' => $label_pos,
'type' => $field['type'],
'name' => $field['name'],
'title' => $field['title'],
'html' => $field_html
);

}

return $item;

});
Expand Down
2 changes: 1 addition & 1 deletion system/controllers/content/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2298,7 +2298,7 @@ public function getContentItems($ctype_name, $callback = null){
);

if (is_callable($callback)){
$item = $callback($item, $model, $ctype_name);
$item = $callback($item, $model, $ctype_name, $user);
}

return $item;
Expand Down
7 changes: 5 additions & 2 deletions system/controllers/groups/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,15 @@ public function renderGroupsList($page_url, $dataset_name = false){
$label_pos = $field['options']['label_in_list'];
}

$groups[$key]['fields'][] = array(
$field_html = $field['handler']->setItem($group)->parseTeaser($group[$field['name']]);
if (!$field_html) { continue; }

$groups[$key]['fields'][$field['name']] = array(
'label_pos' => $label_pos,
'type' => $field['type'],
'name' => $field['name'],
'title' => $field['title'],
'html' => $field['handler']->setItem($group)->parseTeaser($group[$field['name']])
'html' => $field_html
);

}
Expand Down
3 changes: 3 additions & 0 deletions system/languages/en/controllers/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
define('LANG_CP_DASHBOARD_STATS', 'Site Stats');
define('LANG_CP_DASHBOARD_SYSINFO', 'System Info');
define('LANG_CP_DASHBOARD_RESOURCES', 'Useful Resources');
define('LANG_CP_DASHBOARD_NEWS', 'InstantCMS news');
define('LANG_CP_DASHBOARD_NEWS_O', 'Official');
define('LANG_CP_DASHBOARD_NEWS_A', 'Addons');

define('LANG_CP_DASHBOARD_SI_ICMS', 'InstantCMS version');
define('LANG_CP_DASHBOARD_SI_PHP', 'PHP version');
Expand Down
3 changes: 3 additions & 0 deletions system/languages/ru/controllers/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
define('LANG_CP_DASHBOARD_STATS', 'Статистика');
define('LANG_CP_DASHBOARD_SYSINFO', 'Информация о системе');
define('LANG_CP_DASHBOARD_RESOURCES', 'Полезные ресурсы');
define('LANG_CP_DASHBOARD_NEWS', 'Новости InstantCMS');
define('LANG_CP_DASHBOARD_NEWS_O', 'Официальные');
define('LANG_CP_DASHBOARD_NEWS_A', 'Дополнения');

define('LANG_CP_DASHBOARD_SI_ICMS', 'Версия InstantCMS');
define('LANG_CP_DASHBOARD_SI_PHP', 'Версия PHP');
Expand Down
Loading

0 comments on commit ea42a4c

Please sign in to comment.