예제 #1
0
 /**
  * @internal Entry point for translation admin.
  * @attribute[RequestParam('lang','string',false)]
  * @attribute[RequestParam('offset','int',0)]
  * @attribute[RequestParam('search','text','')]
  * @attribute[RequestParam('untranslated','bool',false)]
  */
 function Translate($lang, $offset, $search, $untranslated)
 {
     global $CONFIG;
     if ($untranslated) {
         $search = '';
     }
     $lang = $lang ? $lang : $CONFIG['localization']['default_language'];
     $_SESSION['trans_admin_lang'] = $lang;
     $_SESSION['trans_admin_offset'] = $offset;
     $_SESSION['trans_admin_search'] = $search;
     $form = $this->content(new Form());
     $form->css('margin-bottom', '20px')->action = buildQuery('TranslationAdmin', 'Translate');
     $form->content("Select language: ");
     $form->content($this->_languageSelect($lang))->script("\$('#{self}').change(function(){ \$('#{$form->id}').submit(); });")->name = 'lang';
     $form->content("   And/Or search: ");
     $form->AddText('search', $search);
     $form->AddHidden('offset', 0);
     $form->AddSubmit('Search');
     $form->content("<span style='color:gray'>(?:=single char, *:=any/no char)</span>");
     if ($lang != $CONFIG['localization']['default_language']) {
         $form->content("&nbsp;&nbsp;&nbsp;Or ");
         $form->AddHidden('untranslated', 0)->id = 'untranslated';
         Button::Make("Show untranslated", "\$('#untranslated').val('1').closest('form').submit();")->appendTo($form);
     }
     $tab = Table::Make()->addClass('translations')->SetHeader('Term', 'Default', 'Content', '', '')->setData('lang', $lang)->appendTo($this);
     $rs = $this->_searchQuery($offset, $lang, $search, $untranslated);
     foreach ($rs as $term) {
         $def = nl2br(htmlspecialchars($term['def']));
         $ta = new TextArea($untranslated ? '' : $term['trans']);
         $ta->class = $term['id'];
         $ta->rows = count(explode('<br />', $def)) + 1;
         $btn = new Button('Save');
         $btn->addClass('save')->setData('term', $term['id']);
         $tab->AddNewRow($term['id'], $def, $ta, $btn, '');
         $c = $tab->GetCurrentRow()->GetCell(4);
         $c->css('white-space', 'nowrap');
         $c->content(Control::Make("span"))->addClass('term_action rename')->setData('term', $term['id'])->content('rename');
         $c->content("&nbsp;");
         $c->content(Control::Make("span"))->addClass('term_action remove')->setData('term', $term['id'])->content('remove');
     }
     if ($tab->GetCurrentRow()) {
         $tab->GetCurrentRow()->GetCell(1)->style = 'width: 40%';
     }
     $pi = $rs->GetPagingInfo();
     for ($page = 1; $page <= $pi['total_pages']; $page++) {
         $offset = ($page - 1) * $pi['rows_per_page'];
         $label = $offset + 1 . "-" . $page * $pi['rows_per_page'];
         $label = "{$page}";
         if ($page == $pi['current_page']) {
             $this->content("<b>{$label}</b>");
         } else {
             $this->content(new Anchor(buildQuery('TranslationAdmin', 'Translate', "lang={$lang}&offset={$offset}&search={$search}&untranslated=" . ($untranslated ? 1 : 0)), "{$label}"));
         }
         $this->content("&nbsp;");
     }
 }
예제 #2
0
 /**
  * @internal SysAdmin phpinfo.
  * @attribute[RequestParam('extension','string',false)]
  * @attribute[RequestParam('search','string',false)]
  * @attribute[RequestParam('dump_server','bool',false)]
  */
 function PhpInfo($extension, $search, $dump_server)
 {
     if ($dump_server) {
         $search = $extension = "";
     }
     if ($search) {
         $extension = null;
     }
     foreach (ini_get_all() as $k => $v) {
         $k = explode('.', $k, 2);
         if (count($k) < 2) {
             $k = array('Core', $k[0]);
         }
         $data[$k[0]][$k[1]] = $v;
     }
     ksort($data);
     $tab = $this->content(Table::Make());
     $tab->addClass('phpinfo')->SetCaption("Basic information")->AddNewRow("PHP version", phpversion())->AddNewRow("PHP ini file", php_ini_loaded_file())->AddNewRow("SAPI", php_sapi_name())->AddNewRow("OS", php_uname())->AddNewRow("Apache version", apache_get_version())->AddNewRow("Apache modules", implode(', ', apache_get_modules()))->AddNewRow("Loaded extensions", implode(', ', get_loaded_extensions()))->AddNewRow("Stream wrappers", implode(', ', stream_get_wrappers()))->AddNewRow("Stream transports", implode(', ', stream_get_transports()))->AddNewRow("Stream filters", implode(', ', stream_get_filters()));
     $ext_nav = $this->content(new Control('div'))->css('margin-bottom', '25px');
     $ext_nav->content("Select extension: ");
     $sel = $ext_nav->content(new Select());
     $ext_nav->content("&nbsp;&nbsp;&nbsp;Or search: ");
     $tb = $ext_nav->content(new TextInput());
     $tb->value = $search;
     $q = buildQuery('sysadmin', 'phpinfo');
     $sel->onchange = "wdf.redirect({extension:\$(this).val()})";
     $tb->onkeydown = "if( event.which==13 ) wdf.redirect({search:\$(this).val()})";
     $ext_nav->content('&nbsp;&nbsp;&nbsp;Or ');
     $q = buildQuery('sysadmin', 'phpinfo', 'dump_server=1');
     $ext_nav->content(new Anchor($q, 'dump the $_SERVER variable'));
     $get_version = function ($ext) {
         $res = $ext == 'zend' ? zend_version() : phpversion($ext);
         return $res ? " [{$res}]" : '';
     };
     $sel->SetCurrentValue($extension)->AddOption('', '(select one)');
     $sel->AddOption('all', 'All values');
     foreach (array_keys($data) as $ext) {
         $ver = $ext == 'zend' ? zend_version() : phpversion($ext);
         $sel->AddOption($ext, $ext . $get_version($ext) . " (" . count($data[$ext]) . ")");
     }
     if ($dump_server) {
         $tab = $this->content(new Table())->addClass('phpinfo')->SetCaption('Contents of the $_SERVER variable')->SetHeader('Name', 'Value');
         foreach ($_SERVER as $k => $v) {
             $tab->AddNewRow($k, $v);
         }
     }
     if ($extension || $extension == 'all' || $search) {
         foreach ($data as $k => $config) {
             if (!$search && $k != $extension && $extension != 'all') {
                 continue;
             }
             $tab = false;
             foreach ($config as $ck => $v) {
                 if ($search && stripos($ck, $search) === false && stripos($v['local_value'], $search) === false && stripos($v['global_value'], $search) === false) {
                     continue;
                 }
                 if (!$tab) {
                     $tab = $this->content(new Table())->addClass('phpinfo')->SetCaption($k . $get_version($k))->SetHeader('Name', 'Local', 'Master');
                 }
                 $tr = $tab->NewRow(array($ck, $v['local_value'], $v['global_value']));
                 if ($v['local_value'] !== '' && $v['local_value'] != $v['global_value']) {
                     $tr->GetCell(2)->css('color', 'red');
                 }
             }
         }
     }
 }