Beispiel #1
0
 private function _getRemotePlugins($start, $limit, $dir, $filter)
 {
     $pluginsData = array();
     if ($cachedData = $this->_iaCore->iaCache->get('subrion_plugins', 3600, true)) {
         $pluginsData = $cachedData;
     } else {
         if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/plugin/' . IA_VERSION)) {
             $response = iaUtil::jsonDecode($response);
             if (!empty($response['error'])) {
                 $this->addMessage($response['error']);
             } elseif ($response['total'] > 0) {
                 if (isset($response['extensions']) && is_array($response['extensions'])) {
                     $pluginsData = array();
                     $installedPlugins = $this->_iaDb->keyvalue(array('name', 'version'), iaDb::convertIds(iaExtra::TYPE_PLUGIN, 'type'));
                     foreach ($response['extensions'] as $entry) {
                         $pluginInfo = (array) $entry;
                         $pluginInfo['install'] = 0;
                         // exclude installed plugins
                         if (!array_key_exists($pluginInfo['name'], $installedPlugins)) {
                             $pluginsData['pluginsList'][$pluginInfo['name']] = $pluginInfo['title'];
                             if (isset($pluginInfo['compatibility']) && version_compare($pluginInfo['compatibility'], IA_VERSION, '<=')) {
                                 $pluginInfo['install'] = 1;
                             }
                             $pluginInfo['date'] = gmdate(iaDb::DATE_FORMAT, $pluginInfo['date']);
                             $pluginInfo['file'] = $pluginInfo['name'];
                             $pluginInfo['readme'] = false;
                             $pluginInfo['reinstall'] = false;
                             $pluginInfo['uninstall'] = false;
                             $pluginInfo['remove'] = false;
                             $pluginInfo['removable'] = false;
                             $pluginsData['plugins'][$pluginInfo['name']] = $pluginInfo;
                         }
                     }
                     // cache well-formed results
                     $this->_iaCore->iaCache->write('subrion_plugins', $pluginsData);
                 } else {
                     $this->addMessage('error_incorrect_format_from_subrion');
                 }
             }
         } else {
             $this->addMessage('error_incorrect_response_from_subrion');
         }
     }
     return $this->getMessages() ? array('result' => false, 'message' => $this->getMessages()) : $this->_sortPlugins($pluginsData, $start, $limit, $dir, $filter);
 }
Beispiel #2
0
 private function _getList()
 {
     $templates = $this->getHelper()->getList();
     // get list of available local templates
     $remoteTemplates = array();
     if ($this->_iaCore->get('allow_remote_templates')) {
         if ($cachedData = $this->_iaCore->iaCache->get('subrion_templates', 3600, true)) {
             $remoteTemplates = $cachedData;
             // get templates list from cache, cache lives for 1 hour
         } else {
             if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/template/' . IA_VERSION)) {
                 $response = iaUtil::jsonDecode($response);
                 if (!empty($response['error'])) {
                     $this->_messages[] = $response['error'];
                     $this->_error = true;
                 } elseif ($response['total'] > 0) {
                     if (isset($response['extensions']) && is_array($response['extensions'])) {
                         foreach ($response['extensions'] as $entry) {
                             $templateInfo = (array) $entry;
                             // exclude installed templates
                             if (!array_key_exists($templateInfo['name'], $templates)) {
                                 $templateInfo['date'] = gmdate(iaDb::DATE_FORMAT, $templateInfo['date']);
                                 $templateInfo['buttons'] = '';
                                 $templateInfo['notes'] = array();
                                 $templateInfo['remote'] = true;
                                 $remoteTemplates[] = $templateInfo;
                             }
                         }
                         // cache well-formed results
                         $this->_iaCore->iaCache->write('subrion_templates', $remoteTemplates);
                     } else {
                         $this->addMessage('error_incorrect_format_from_subrion');
                         $this->_error = true;
                     }
                 }
             } else {
                 $this->addMessage('error_incorrect_response_from_subrion');
                 $this->_error = true;
             }
         }
     }
     return array_merge($templates, $remoteTemplates);
 }
Beispiel #3
0
 protected function _postSaveEntry(array &$entry, array $data, $action)
 {
     function recursive_read_menu($menus, $pages, &$list, $menuId)
     {
         foreach ($menus as $menu) {
             $pageId = reset(explode('_', $menu['id']));
             $list[] = array('parent_id' => 'root' == $menu['parentId'] ? 0 : $menu['parentId'], 'menu_id' => $menuId, 'el_id' => $menu['id'], 'level' => $menu['depth'] - 1, 'page_name' => $pageId > 0 && isset($pages[$pageId]) ? $pages[$pageId] : 'node');
         }
     }
     $menus = isset($data['menus']) && $data['menus'] ? $data['menus'] : '';
     $menus = iaUtil::jsonDecode($menus);
     array_shift($menus);
     $rows = array();
     $pages = $this->_iaDb->keyvalue(array('id', 'name'), null, 'pages');
     recursive_read_menu($menus, $pages, $rows, $this->getEntryId());
     $this->_iaDb->setTable(iaBlock::getMenusTable());
     $this->_iaDb->delete(iaDb::convertIds($this->getEntryId(), 'menu_id'));
     empty($rows) || $this->_iaDb->insert($rows);
     $this->_iaDb->resetTable();
     if (iaCore::ACTION_EDIT == $action) {
         $this->_iaCore->iaCache->remove('menu_' . $this->getEntryId() . '.inc');
     }
 }
Beispiel #4
0
 private function _checkForUpdates()
 {
     $url = sprintf(iaUtil::REMOTE_TOOLS_URL . 'get/updates/%s/', IA_VERSION);
     $content = iaUtil::getPageContent($url);
     if (!$content) {
         return;
     }
     $content = iaUtil::jsonDecode($content);
     if (is_array($content) && $content) {
         $messages = array();
         foreach ($content as $entry) {
             switch ($entry['type']) {
                 case self::UPDATE_TYPE_INFO:
                     $messages[] = array($entry['id'], $entry['message']);
                     break;
                 case self::UPDATE_TYPE_PATCH:
                     $version = explode('.', $entry['version']);
                     if (count($version) > 3) {
                         if ($this->_iaCore->get('auto_apply_critical_upgrades')) {
                             $result = iaSystem::forceUpgrade($entry['version']);
                             if (is_bool($result) && $result) {
                                 $this->_iaCore->factory('cache')->clearGlobalCache();
                                 $message = iaLanguage::getf('script_upgraded', array('version' => $entry['version']));
                                 $this->_iaCore->iaView->setMessages($message, iaView::SUCCESS);
                                 iaUtil::go_to(IA_SELF);
                             } else {
                                 iaDebug::debug($result, 'Forced upgrade to the version ' . $entry['version']);
                             }
                         }
                     } else {
                         $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $entry['version']);
                         $this->_iaCore->iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $entry['version'])), iaView::SYSTEM);
                     }
             }
         }
         $this->_iaCore->iaView->assign('updatesInfo', $messages);
     }
 }
Beispiel #5
0
 protected function _parseTreeNodes($packedNodes)
 {
     $result = array();
     $nodes = iaUtil::jsonDecode($packedNodes);
     $indent = array();
     foreach ($nodes as $node) {
         $id = $node['id'];
         $parent = $node['parent'];
         $indent[$id] = 0;
         '#' != $parent && ++$indent[$id] && (isset($indent[$parent]) ? $indent[$id] += $indent[$parent] : ($indent[$parent] = 0));
     }
     foreach ($nodes as $node) {
         $result[$node['id']] = str_repeat('&nbsp;&nbsp;&nbsp;', $indent[$node['id']]) . ' &mdash; ' . $node['text'];
     }
     return $result;
 }
Beispiel #6
0
 private function getRemoteList($localPackages)
 {
     $remotePackages = array();
     if ($cachedData = $this->_iaCore->iaCache->get('subrion_packages', 3600 * 24 * 7, true)) {
         $remotePackages = $cachedData;
         // get templates list from cache, cache lives for 1 hour
     } else {
         if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/package/' . IA_VERSION)) {
             $response = iaUtil::jsonDecode($response);
             if (!empty($response['error'])) {
                 $this->_messages[] = $response['error'];
                 $this->_error = true;
             } elseif ($response['total'] > 0) {
                 if (isset($response['extensions']) && is_array($response['extensions'])) {
                     foreach ($response['extensions'] as $entry) {
                         $packageInfo = (array) $entry;
                         // exclude uploaded packages
                         if (!in_array($packageInfo['name'], $localPackages)) {
                             $packageInfo['date'] = gmdate(iaDb::DATE_FORMAT, $packageInfo['date']);
                             $packageInfo['status'] = '';
                             $packageInfo['summary'] = $packageInfo['description'];
                             $packageInfo['buttons'] = false;
                             $packageInfo['remote'] = true;
                             $remotePackages[] = $packageInfo;
                         }
                     }
                     // cache well-formed results
                     $this->_iaCore->iaCache->write('subrion_packages', $remotePackages);
                 } else {
                     $this->addMessage('error_incorrect_format_from_subrion');
                     $this->_error = true;
                 }
             }
         } else {
             $this->addMessage('error_incorrect_response_from_subrion');
             $this->_error = true;
         }
     }
     return $remotePackages;
 }
<?php

//##copyright##
if (iaView::REQUEST_HTML == $iaView->getRequestType() && $iaView->blockExists('current_weather')) {
    $city = urlencode($iaCore->get('current_weather_city'));
    $units = array('Celsius' => 'metric', 'Fahrenheit' => 'imperial');
    $unitParam = $units[$iaCore->get('current_weather_unit')];
    $degrees = array('Celsius' => 'C', 'Fahrenheit' => 'F');
    $degreesParam = $degrees[$iaCore->get('current_weather_unit')];
    $appID = $iaCore->get('current_weather_key');
    $weatherData = iaUtil::jsonDecode(file_get_contents("http://api.openweathermap.org/data/2.5/weather?q={$city}&mode=json&units={$unitParam}&appid={$appID}"));
    $weatherTemp = round($weatherData['main']['temp']);
    if ($weatherData) {
        $images = array('Mist' => 'img/mist.png', 'Snow' => 'img/snow.png', 'Thunderstorm' => 'img/thunderstorm.png', 'Rain' => 'img/rain.png', 'Shower rain' => 'img/shower_rain.png', 'Broken clouds' => 'img/clouds.png', 'Clouds' => 'img/clouds.png', 'Scattered clouds' => 'img/clouds.png', 'Few clouds' => 'img/cloudy_day.png', 'Clear sky' => 'img/clear_sky.png', 'Clear' => 'img/clear_sky.png');
        $weatherIcon = str_replace('img/', 'img/' . $iaCore->get('current_weather_scheme') . '/', $images[$weatherData['weather'][0]['main']]);
        $iaView->assign('icon', $weatherIcon);
        $iaView->assign('weather_temp', $weatherTemp);
        $iaView->add_css('_IA_URL_plugins/current_weather/templates/front/css/style');
    }
    $iaView->assign('degrees', $degreesParam);
    $iaView->assign('weather_data', $weatherData);
}
Beispiel #8
0
 private function _parseTreeNodes($nodesFlatData)
 {
     $nestedIds = array();
     $preservedKeys = array('id', 'text', 'parent');
     $data = iaUtil::jsonDecode($nodesFlatData);
     foreach ($data as $i => $node) {
         foreach ($node as $key => $value) {
             if (!in_array($key, $preservedKeys)) {
                 unset($data[$i][$key]);
             }
         }
         $alias = strtolower(iaSanitize::alias($node['text']));
         $nestedIds[$node['id']] = array('node_id' => $node['id'], 'text' => $node['text'], 'parent_node_id' => '#' != $node['parent'] ? $node['parent'] : '', 'alias' => '#' != $node['parent'] && isset($nestedIds[$node['parent']]) ? $nestedIds[$node['parent']]['alias'] . $alias . IA_URL_DELIMITER : $alias . IA_URL_DELIMITER);
     }
     return array(iaUtil::jsonEncode($data), $nestedIds);
 }
Beispiel #9
0
 private function _parseTreeNodes($nodesFlatData)
 {
     $preservedKeys = array('id', 'text', 'parent');
     $data = iaUtil::jsonDecode($nodesFlatData);
     foreach ($data as $i => $node) {
         foreach ($node as $key => $value) {
             if (!in_array($key, $preservedKeys)) {
                 unset($data[$i][$key]);
             }
         }
     }
     return iaUtil::jsonEncode($data);
 }
Beispiel #10
0
 protected function _indexPage(&$iaView)
 {
     $iaView->display('index');
     $iaCore =& $this->_iaCore;
     $iaDb =& $this->_iaDb;
     if (isset($_GET['reset']) || isset($_GET['save'])) {
         $data = isset($_GET['list']) ? $_GET['list'] : '';
         if ($iaDb->update(array('admin_columns' => $data), iaDb::convertIds(iaUsers::getIdentity()->id), null, iaUsers::getTable())) {
             iaUsers::reloadIdentity();
         }
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         iaUtil::go_to(IA_SELF);
     }
     $disabledWidgets = iaUsers::getIdentity()->admin_columns;
     $disabledWidgets = empty($disabledWidgets) ? array() : explode(',', trim($disabledWidgets, ','));
     $iaView->assign('disabled_widgets', $disabledWidgets);
     $customizationMode = isset($_GET['customize']) && empty($_GET['customize']);
     if ($customizationMode) {
         $iaView->setMessages(iaLanguage::get('customization_mode_alert'));
         $iaView->assign('customization_mode', true);
     }
     // populate statistics
     $iaItem = $iaCore->factory('item');
     $itemsList = $iaItem->getPackageItems();
     $validSizes = array('small', 'medium', 'package');
     $iaCore->startHook('adminDashboardStatistics', array('items' => &$itemsList));
     natcasesort($itemsList);
     $statistics = array();
     foreach ($validSizes as $size) {
         $statistics[$size] = array();
     }
     foreach ($itemsList as $itemName => $pluginType) {
         $itemName = substr($itemName, 0, -1);
         switch ($pluginType) {
             case 'core':
                 $classInstance = $iaCore->factory('member' == $itemName ? 'users' : $itemName);
                 break;
             case 'plugin':
                 $array = explode(':', $itemName);
                 $itemName = isset($array[1]) ? $array[1] : $itemName;
                 $classInstance = $iaCore->factoryPlugin($array[0], iaCore::ADMIN, isset($array[1]) ? $array[1] : null);
                 break;
             default:
                 $classInstance = $iaCore->factoryPackage($itemName, $pluginType, iaCore::ADMIN);
         }
         if (!$customizationMode && in_array($itemName, $disabledWidgets)) {
             continue;
         }
         if ($classInstance) {
             if (method_exists($classInstance, self::STATISTICS_GETTER_METHOD)) {
                 if ($classInstance->dashboardStatistics) {
                     $data = $classInstance->{self::STATISTICS_GETTER_METHOD}();
                     isset($data['icon']) || ($data['icon'] = $itemName);
                     isset($data['caption']) || ($data['caption'] = $itemName);
                     $data['caption'] = iaLanguage::get($data['caption'], $data['caption']);
                     $widgetFormat = isset($data['_format']) && in_array($data['_format'], $validSizes) ? $data['_format'] : $validSizes[0];
                     $statistics[$widgetFormat][$itemName] = $data;
                 }
             }
         }
     }
     $iaView->assign('statistics', $statistics);
     //
     if (($customizationMode || !in_array('changelog', $disabledWidgets)) && $iaCore->get('display_changelog') && is_file(IA_HOME . 'changelog.txt')) {
         $index = 0;
         $log = array();
         $titles = array();
         $lines = file(IA_HOME . 'changelog.txt');
         foreach ($lines as $line_num => $line) {
             $line = trim($line);
             if ($line) {
                 if ($line[0] == '>') {
                     $index++;
                     $log[$index] = array('title' => trim($line, '<> '), 'added' => '', 'modified' => '', 'bugfixes' => '', 'other' => '');
                     $titles[trim($line, '<> ')] = $index;
                 } elseif ($index > 0) {
                     switch ($line[0]) {
                         case '+':
                             $class = 'added';
                             break;
                         case '-':
                             $class = 'bugfixes';
                             break;
                         case '*':
                             $class = 'modified';
                             break;
                         default:
                             $class = 'other';
                     }
                     $issue = preg_replace('/#(\\d+)/', '<a href="http://dev.subrion.org/issues/$1" target="_blank">#$1</a>', ltrim($line, '+-* '));
                     $log[$index][$class] .= '<li>' . $issue . '</li>';
                 }
             }
         }
         unset($log[0]);
         ksort($titles);
         $titles = array_reverse($titles);
         $iaView->assign('changelog_titles', $titles);
         $iaView->assign('changelog', $log);
     }
     // twitter widget
     if ($customizationMode || !in_array('twitter', $disabledWidgets)) {
         $data = iaUtil::getPageContent('http://tools.intelliants.com/timeline/');
         $iaView->assign('timeline', iaUtil::jsonDecode($data));
     }
     if ($customizationMode || !in_array('recent-activity', $disabledWidgets)) {
         $data = $iaCore->factory('log')->get();
         $iaView->assign('activity_log', $data);
     }
     if ($customizationMode || !in_array('website-visits', $disabledWidgets)) {
         $data = $iaCore->factory('users')->getVisitorsInfo();
         $iaView->assign('online_members', $data);
     }
     if ($iaCore->get('check_for_updates')) {
         if ($content = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'get/patch/')) {
             $content = iaUtil::jsonDecode($content);
             if (is_array($content) && $content) {
                 foreach ($content as $versionFrom => $versionTo) {
                     if (version_compare($versionFrom, IA_VERSION) === 0 && version_compare($versionTo, IA_VERSION)) {
                         $version = explode('.', $versionTo);
                         if (count($version) > 3) {
                             if ($iaCore->get('auto_apply_critical_upgrades')) {
                                 $result = iaSystem::forceUpgrade($versionTo);
                                 if (is_bool($result) && $result) {
                                     $iaCore->factory('cache')->clearGlobalCache();
                                     $message = iaLanguage::getf('script_upgraded', array('version' => $versionTo));
                                     $iaView->setMessages($message, iaView::SUCCESS);
                                     iaUtil::go_to(IA_SELF);
                                 } else {
                                     iaDebug::debug($result, 'Forced upgrade to the version ' . $versionTo);
                                 }
                             }
                         } else {
                             $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $versionTo);
                             $iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $versionTo)), iaView::SYSTEM);
                         }
                     }
                 }
             }
         }
     }
 }