コード例 #1
0
 private function getAccounts(\Nethgui\View\ViewInterface $view)
 {
     static $ds;
     if (isset($ds)) {
         return $ds;
     }
     $data = json_decode($this->getPlatform()->exec("/usr/bin/sudo /usr/libexec/nethserver/read-mail-accounts")->getOutput(), TRUE);
     $users = \Nethgui\Widget\XhtmlWidget::hashToDatasource($data['users'], TRUE);
     $groups = \Nethgui\Widget\XhtmlWidget::hashToDatasource($data['groups'], TRUE);
     $ds = array();
     if ($users) {
         $ds[] = array($users, $view->translate('Users_label'));
     }
     if ($groups) {
         $ds[] = array($groups, $view->translate('Groups_label'));
     }
     return $ds;
 }
コード例 #2
0
 protected function wrapChild($childOutput)
 {
     if (!$this->childWrapTag) {
         return parent::wrapChild($childOutput);
     }
     $childTag = explode('.', $this->childWrapTag) + array(FALSE, FALSE);
     $content = '';
     if (strlen($childTag[0]) > 0) {
         $content .= $this->openTag($childTag[0]);
         $content .= parent::wrapChild($childOutput);
         $content .= $this->closeTag($childTag[0]);
     } else {
         $content .= parent::wrapChild($childOutput);
     }
     if (strlen($childTag[1]) > 0) {
         $content .= htmlspecialchars($childTag[1]);
     }
     return $content;
 }
コード例 #3
0
 public function insert(\Nethgui\Renderer\WidgetInterface $child)
 {
     if (!$child instanceof CheckBox) {
         throw new \InvalidArgumentException(sprintf('%s: Unsupported widget class: %s', get_class($this), get_class($child)), 1322149476);
     }
     if (!$child->hasAttribute('uncheckedValue')) {
         $child->setAttribute('uncheckedValue', FALSE);
     }
     // Force help id to FALSE (disabled) - No help context can be specified here.
     $child->setAttribute('helpId', FALSE);
     $childFlags = $child->getAttribute('flags', 0);
     // Mask LABEL_* flags:
     $childFlags &= ~(\Nethgui\Renderer\WidgetFactoryInterface::LABEL_ABOVE | \Nethgui\Renderer\WidgetFactoryInterface::LABEL_RIGHT | \Nethgui\Renderer\WidgetFactoryInterface::LABEL_LEFT);
     // Force to STATE_DISABLED & LABEL_RIGHT
     $childFlags |= \Nethgui\Renderer\WidgetFactoryInterface::LABEL_RIGHT | \Nethgui\Renderer\WidgetFactoryInterface::STATE_DISABLED;
     // Fix the flags:
     $child->setAttribute('flags', $childFlags);
     return parent::insert($child);
 }
コード例 #4
0
 /**
  * Find interfaces names with a role and associated to a non-existent MAC address
  */
 private function getCards($T)
 {
     $formatInterface = function ($e) {
         return strtr($e['bootproto'] === 'dhcp' ? 'role DHCP(hwaddr)' : 'role ipaddr', $e);
     };
     $basicDatasource = array('' => $T('[leave untouched]'));
     $interfaceDatasource = array_merge($basicDatasource, array_map($formatInterface, $this->getUnassignedInterfaces()));
     $ndb = $this->getPlatform()->getDatabase('networks')->getAll('ethernet');
     if (count($interfaceDatasource) === 1) {
         return array();
     }
     $fields = explode(' ', 'name hwaddr type model driver speed link');
     $parsef = function ($line) use($fields, $interfaceDatasource, $basicDatasource, $ndb, $T) {
         $values = str_getcsv($line);
         $h = array_combine($fields, $values);
         $h['linkText'] = $h['link'] ? $T('Link is up') : $T('Link is down');
         $h['link'] = $h['link'] ? 'linkup' : 'linkdown';
         $h['currentRole'] = isset($ndb[$h['name']], $ndb[$h['name']]['role']) ? $ndb[$h['name']]['role'] : 'black';
         $isPresent = isset($ndb[$h['name']]) && isset($ndb[$h['name']]['role']) && $ndb[$h['name']]['role'] != '' && strtolower($ndb[$h['name']]['hwaddr']) === strtolower($h['hwaddr']);
         $h['interfaceDatasource'] = \Nethgui\Widget\XhtmlWidget::hashToDatasource($isPresent ? $basicDatasource : $interfaceDatasource);
         $h['configuration'] = $isPresent ? 'configured' : 'unconfigured';
         return $h;
     };
     $cards = array_map($parsef, $this->getNicInfo());
     if ($this->getRequest()->isMutation()) {
         return $this->requestAssignment($cards);
     } else {
         return $cards;
     }
 }
コード例 #5
0
ファイル: TextInput.php プロジェクト: SystemEd-Jacob/nethgui
 protected function getJsWidgetTypes()
 {
     return array_merge(array('Nethgui:inputcontrol', 'Nethgui:tooltip'), parent::getJsWidgetTypes());
 }
コード例 #6
0
 public function getAccountDatasource()
 {
     $userProvider = new \NethServer\Tool\UserProvider($this->getPlatform());
     $groupProvider = new \NethServer\Tool\GroupProvider($this->getPlatform());
     $mbxProvider = new \NethServer\Module\MailAccount\SharedMailbox\SharedMailboxAdapter($this->getPlatform());
     $users = $userProvider->getUsers();
     $hash = array();
     if ($this->parameters['Account'] instanceof \Traversable) {
         foreach ($this->parameters['Account'] as $a) {
             $hash[$a] = $a;
         }
     }
     foreach ($users as $key => $prop) {
         $hash[$key] = $key;
     }
     foreach ($groupProvider->getGroups() as $key => $prop) {
         $hash[$key] = $key;
     }
     foreach ($mbxProvider->getSharedMailboxList() as $mbx) {
         $hash['vmail+' . $mbx['name']] = $mbx['name'];
     }
     return \Nethgui\Widget\XhtmlWidget::hashToDatasource($hash, TRUE);
 }
コード例 #7
0
<?php

/* @var $view \Nethgui\Renderer\Xhtml */
echo $view->header()->setAttribute('template', $T('SetPppoeParameters_header'));
echo $view->selector('PppoeInterface', $view::SELECTOR_DROPDOWN)->setAttribute('choices', 'PppoeInterfaceDatasource');
echo $view->textInput('PppoeProvider');
echo $view->textInput('PppoeUser');
echo $view->textInput('PppoePassword');
echo $view->selector('PppoeAuthType', $view::SELECTOR_DROPDOWN)->setAttribute('choices', \Nethgui\Widget\XhtmlWidget::hashToDatasource(array('auto' => $T('AuthType_auto'), 'pap' => $T('AuthType_pap'), 'chap' => $T('AuthType_chap'))));
echo $view->buttonList($view::BUTTON_HELP)->insert($view->button('Submit', $view::BUTTON_SUBMIT))->insert($view->button('Back', $view::BUTTON_CANCEL));
コード例 #8
0
ファイル: Button.php プロジェクト: SystemEd-Jacob/nethgui
 public function executeCommand(\Nethgui\View\ViewInterface $origin, $selector, $name, $arguments)
 {
     $this->getLog()->deprecated(sprintf("%%s %%s: %s() command is DEPRECATED on Xhtml widget!", __CLASS__, $name));
     switch ($name) {
         case 'setLabel':
             $this->setAttribute('label', $arguments[0]);
             break;
         default:
             parent::executeCommand($origin, $selector, $name, $arguments);
     }
 }
コード例 #9
0
 /**
  * Convert the given hash to the array format accepted from UI widgets as
  * "datasource".
  *
  * Deprecated here. Moved to \Nethgui\Widget\XhtmlWidget::hashToDatasource.
  *
  * @api
  * @param array $h
  * @param boolean $sort -- default FALSE
  * @return array
  * @deprecated since 1.6
  * @see \Nethgui\Widget\XhtmlWidget::hashToDatasource
  */
 public static function hashToDatasource($H, $sort = FALSE)
 {
     $log = new \Nethgui\Log\Syslog(E_WARNING);
     $log->deprecated();
     return \Nethgui\Widget\XhtmlWidget::hashToDatasource($H, $sort);
 }