Запись [z:util_help] < dev.sky.1.001
Версия 1.001
• N1: WRITE FILE: _dev/util/help_edit.php
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 | <?php defined('START') and AUTH_OK or die; eval(cell(250)); if (isset($p_code)) { sql("insert into _dev_help values($g_id, '$p_code', '$p_lang', '$p_txt', now(), '$u_sky_inet_login')") and $mess = 'New translation added'; } elseif ($_POST) { sql("update _dev_help set txt='$p_txt' where id=$g_id") and $mess = 'Saved' or $mess = '!No changes!'; } if ($tt = isset($g_tt)) { $id = sql("+select max(ifnull(id,0))+1 from _dev_help"); $g_id = $g_tt; $TOP = ' < translate article from HELP section'; } elseif (isset($g_id)) { $TOP = ' < edit article from HELP section'; } elseif ($WHAT) { jump("?utility=help_edit&id=" . sql("insert into _dev_help values(null, '$WHAT', 'en', '', now(), '$u_sky_inet_login')")); } if (isset($g_id) && eval(sql("^select * from _dev_help where id=$g_id"))): $txt = $r_txt; if ('commands' == $r_code) require '_dev/main/commands.php' ?> <?if($tt):?> <form method="post" action="?utility=help_edit&id=<?=$id?>"> <h3>Sourse for translation:</h3> <input type="hidden" name="code" value="<?=$r_code?>" /> <?else:?> <form method="post" id="f1"> <?endif?> Page code: <b><?=$r_code?></b><?=pad()?>Language: <b><?="$r_lang, $all_lang_list[$r_lang]"?><br> <?if($tt):?> <h3>Select destination language for translation:</h3> <select name="lang" onchange="this.form.submit()"><option>---<?=option('', $all_lang_list)?></select> <div style="display:none"> <?else:?> <div> <?endif?> <textarea name="txt" style="width:95%"><?=html($txt)?></textarea><br> <input type="submit" value="Save - F2" /> <input type="button" value="Cancel - Esc" onclick="key_Esc()" /> </div> <form> <script type="text/javascript"> var f1 = $('f1'); <?if(isset($p_code)):?>mtop('Please translate this article, use text in textarea as a sourse');<?endif?> <?if(!$d_snapshot) echo sql("+select concat('auto_store(',ifnull(max(imemo)+1,1),');') from _dev_memory where id>1000") ?> function adjust(x, y) { f1.txt.$({height: y - 200}); $('utbl', {height: y - 120}); } $().body.$({overflow:'hidden'}); f1.txt.focus(); function key_F2() { f1.submit() } function key_Esc() { document.location.href='?help=<?=$r_code?>' } </script> <?else:?> <h3>Translate HELP section</h3> You can translate help section of DEV.SKY. app. Save the snapshot of an existent data, hit `translate` link in help section for some article and do translation. After please create script (from the snapshot) and send to server, read http://coresky.net/dev <h3>Translate DEV interface</h3> Table _dev_codebase (records 251-300) have a translations of a DEV interface to different languages. Just click `Run this` in selected record. Please use English language as default language when you submit modifications for DEV.SKY. which is NOT related to languages. <h3>Translate Codebase records DESC: commands</h3> Open [1]a:dev.sky. for editing... You will see commands like this - # DESC: en #. Commands `DESC` have no any effect to script, so translation to different languages can be added to local parts of scripts. Please use English for default lang. <?endif?> |
• N2: WRITE FILE: _dev/util/help_api.php
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 |
2do:
<br>
<br>
<br>
develop api for user supplied help based on requests to remote servers using keywords
(when users will ready to be suppliers)
<br>
<br>
<br>
<textarea rows="5" cols="50"></textarea>
<br>
<input type="submit" value="Save servers list" />
|
• N3: WRITE FILE: _dev/util/help_wiki.php
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 | <?php defined('START') and AUTH_OK or die; if (START == 'ajax'): # 2do: https://www.mediawiki.org/wiki/API:Main_page/ru if ($PVAL) { set('u_help_lang', $u_help_lang = substr($PVAL, 0, 2)); $content = @file_get_contents("https://$PVAL"); $s = substr($PVAL, 1 + strrpos($PVAL, '/')); } else { $s = substr($ajax, 1); $content = @file_get_contents('https://' . ($PVAL = "$u_help_lang.wikipedia.org/wiki/$s")); } $ok = preg_match('|^.*?<div id=\"bodyContent\"[^>]*>(.*?)</div>\s*</div>\s*<div id=\"mw\-navigation\">(.*)$|s', $content, $m); $ary = []; if ($ok) { set('u_wiki_s', $s); $content = "<h1>$s</h1>" . $m[1]; $langs = preg_replace('|[\t]+|s', "", preg_replace('|^.*?<ul>\s*(<li class=\"interlanguage\-link .*?)</ul>.*|s', "$1", $m[2])); $langs = preg_replace('|</?li[^>]*>|s', "", $langs); $regexp = '|href="//([a-z]{2})\.wikipedia\.org/wiki/[^"]+"|'; if (preg_match_all($regexp, $langs, $m)) { foreach ($u_lang_priority as $one) { if ($u_help_lang == $one) $ary[$PVAL] = $one; else { if (false == ($i = array_search($one, $m[1]))) continue; $ary[substr($m[0][$i], 8, -1)] = $one; } } } } else $content = ''; $top = menu($PVAL, $ary, "javascript:wiki('','%s')") . pad() . 'search: '; $top .= '<form style="display:inline" onsubmit="return wiki($(\'s\').value)"><input id="s" class="si" />'; $top .= '<input type="submit" class="si" value="do" /></form>' . pad() . a('native src', "https://$PVAL", 'target="_blank"'); echo_json([ 'help' => preg_replace('|href="/wiki/([^"]+)"|', "href=\"javascript:wiki('$1')\"", $content), 'top' => "<span class=\"green\"> $s </span> < available in: $top", ]); else: # HTML PAGE $TOP = '> <span id="top"></span>'; ?> see: https://www.mediawiki.org/wiki/API:Main_page/ru <div id="contents"></div> <script type="text/javascript"> function wiki(q, lg) { html('contents', ''); if (lg) q += '&lg=' + e$(lg); ajax('help_wiki=' + q, function(r, err) { var json = callback(r, err); html('contents', json.help).$$('span', 'mw-editsection', function(el) { el.$(''); }); html('top', json.top); if (!json.help) mtop('Search error', red); }); return false; } wiki('<?=$u_wiki_s?>'); </script> <?php endif; |