private function getGroupsViewValue(\Nethgui\View\ViewInterface $view) { static $groupsState; if (isset($groupsState)) { return $groupsState; } $groupsState = array(); foreach (iterator_to_array($this->getAdapter()) as $id => $yumGroup) { if ($yumGroup['status'] === 'available') { continue; // skip installed groups } if (isset($this->parameters['groups'][$id])) { $groupsState[$id] = $this->parameters['groups'][$id]; } else { $groupsState[$id]['opackages_selected'] = array(); } $groupsState[$id]['id'] = $yumGroup['id']; $groupsState[$id]['name'] = $yumGroup['name']; $groupsState[$id]['description'] = $yumGroup['description']; $groupsState[$id]['Edit'] = array($view->getModuleUrl('../../EditModule/' . $id), $view->translate('Edit_label')); $groupsState[$id]['Remove'] = array($view->getModuleUrl('../../Review?removeGroup=' . $id), $view->translate('Remove_label')); } foreach ($this->getCategories($view) as $category) { foreach ($category['groups'] as $id) { if (isset($groupsState[$id])) { $groupsState[$id]['categories'][] = $category['name']; } } } usort($groupsState, function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); return $groupsState; }
public function prepareView(\Nethgui\View\ViewInterface $view) { if (!$this->getRequest()->isValidated()) { $this->getAdapter()->setLoader(NULL); } else { $view->getCommandList()->show(); } if ($this->getRequest()->hasParameter('installSuccess')) { $this->getAction('AdminTodo')->emitNotifications = TRUE; $this->notifications->yumSuccess(array('message' => $view->translate('YumSuccess_message'), 'description' => $view->translate('YumSuccess_description'), 'buttonLabel' => $view->translate('YumSuccess_button_label'), 'action' => $view->getModuleUrl('..'))); } elseif ($this->getRequest()->hasParameter('installFailure')) { $taskStatus = $this->systemTasks->getTaskStatus($this->getRequest()->getParameter('taskId')); if (isset($taskStatus['children'][0]['message'])) { $message = $taskStatus['children'][0]['message']; } else { $message = $view->translate('An unknown installation error has occurred'); } $this->notifications->yumError(array('message' => $message, 'description' => $view->translate('ClearYumCache_description'), 'buttonLabel' => $view->translate('ClearYumCache_label'), 'action' => $view->getModuleUrl('../ClearYumCache'))); } parent::prepareView($view); if (isset($this->yumError)) { $this->notifications->yumError(array('message' => $this->yumError, 'description' => $view->translate('ClearYumCache_description'), 'buttonLabel' => $view->translate('ClearYumCache_label'), 'action' => $view->getModuleUrl('../ClearYumCache'))); } }
public function prepareView(\Nethgui\View\ViewInterface $view) { if ($this->getRequest()->isMutation()) { $this->getPlatform()->setDetachedProcessCondition('success', array('location' => array('url' => $view->getModuleUrl('/Account/DomainController?installSuccess'), 'freeze' => TRUE))); } parent::prepareView($view); $view['NetbiosDomain'] = $this->getPlatform()->getDatabase('configuration')->getProp('smb', 'Workgroup'); if (!$view['NetbiosDomain']) { $domainName = $this->getPlatform()->getDatabase('configuration')->getType('DomainName'); $view['NetbiosDomain'] = \Nethgui\array_head(explode('.', $domainName)); } $view['NetbiosDomain'] = strtoupper(substr($view['NetbiosDomain'], 0, 15)); if ($this->getRequest()->hasParameter('installSuccess')) { $view->getCommandList('/Main')->sendQuery($view->getModuleUrl('/Account')); } }
private function searchTags(\Nethgui\View\ViewInterface $view, $query) { if (is_null($this->moduleSet)) { return array(); } $translator = $view->getTranslator(); $results = array(); foreach ($this->moduleSet as $module) { if (!$module instanceof \Nethgui\Module\ModuleInterface) { continue; } if (!$module->isInitialized()) { $module->setPlatform($this->getPlatform()); $module->initialize(); } $tags = array_map('trim', explode(' ', $module->getAttributesProvider()->getTags())); foreach ($tags as $tag) { $tagTranslated = $translator->translate($module, $tag); if (stripos($tagTranslated, $query) !== FALSE) { $results[] = $view->getModuleUrl('/' . $module->getIdentifier()); } } } return $results; }
/** * XXX: experimental -> CSS injection **/ public function prepareView(\Nethgui\View\ViewInterface $view) { $cssCode = "\n tr.running td:nth-child(3) { color: green }\n tr.stopped td:nth-child(3) { color: red }\n "; $view->getCommandList('/Resource/css')->appendCode($cssCode, 'css'); $moduleUrl = json_encode($view->getModuleUrl("/Dashboard/Services")); $jsCode = "\n(function ( \$ ) {\n \$(document).ready(function() {\n \$.Nethgui.Server.ajaxMessage({\n isMutation: false,\n url: {$moduleUrl}\n });\n });\n} ( jQuery ));\n "; $view->getCommandList('/Resource/js')->appendCode($jsCode, 'js'); parent::prepareView($view); }
public function prepareView(\Nethgui\View\ViewInterface $view) { if ($this->getRequest()->isMutation()) { $this->getPlatform()->setDetachedProcessCondition('success', array('location' => array('url' => $view->getModuleUrl('Modules?installSuccess'), 'freeze' => TRUE))); $this->getPlatform()->setDetachedProcessCondition('failure', array('location' => array('url' => $view->getModuleUrl('Modules?installFailure&taskId={taskId}'), 'freeze' => TRUE))); } parent::prepareView($view); }
public function getModuleUrl($path = '') { return $this->view->getModuleUrl($path); }
/** * Save a request/response round, putting the next view data in the response * * @param \Nethgui\View\ViewInterface $view */ private function prepareNextViewOptimized(\Nethgui\View\ViewInterface $view) { $np = $this->currentAction->nextPath(); if ($np === FALSE) { return; } $nextModule = $this->getAction(\Nethgui\array_head(explode('/', $np))); $location = $view->getModuleUrl($np); if ($nextModule instanceof \Nethgui\View\ViewableInterface) { // spawn and prepare the next view data: $nextView = $view->spawnView($nextModule, TRUE); $nextModule->prepareView($nextView); if ($view->getTargetFormat() === $view::TARGET_JSON) { $nextView->getCommandList()->prefetched(); // placeholder. $nextView->getCommandList()->show(); // Display the prefetched view $this->getPlatform()->setDetachedProcessCondition('success', array('location' => array('url' => $location . '?taskStatus=success&taskId={taskId}'), 'freeze' => TRUE))->setDetachedProcessCondition('failure', array('location' => array('url' => $location . '?taskStatus=failure&taskId={taskId}'), 'freeze' => TRUE)); } else { // show is implemented as HTTP redirection. Avoid self-loops: if ($nextModule !== $this->currentAction) { $view->getCommandList()->sendQuery($location); } } } else { // next path does not corresponds to a child action: start // a new query request to get the next view data: $view->getCommandList()->sendQuery($location); } }
private function prepareInitializationView(\Nethgui\View\ViewInterface $view) { $firstRunningTask = \Nethgui\array_head(array_keys($this->systemTasks->getRunningTasks())); if ($firstRunningTask) { // Notify that the task is running: $this->notifications->trackerRunning(array('taskId' => $firstRunningTask)); $view['trackerState'] = FALSE; $view['progress'] = FALSE; $view['message'] = ''; return; } $firstStartingTask = \Nethgui\array_head(array_keys($this->systemTasks->getStartingTasks())); if ($firstStartingTask) { $view['progress'] = 0; $view['message'] = '...'; $view['trackerState'] = array('dialog' => array('title' => $view->translate('Tracker_title_taskStarting'), 'action' => 'open'), 'location' => array('sleep' => 2000, 'url' => $view->getModuleUrl($firstStartingTask))); return; } }
public function prepareView(\Nethgui\View\ViewInterface $view) { $view->getCommandList()->sendQuery($view->getModuleUrl('/UserProfile')); }