diff --git a/e107_admin/db.php b/e107_admin/db.php index cdd9bda27..9389dbe18 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -359,89 +359,18 @@ class system_tools // Developer Mode ONly.. No LANS. private function githubSyncProcess() { + $result = e107::getFile()->unzipGithubArchive('core'); - // Delete any existing file. - if(file_exists(e_TEMP."e107-master.zip")) - { - unlink(e_TEMP."e107-master.zip"); - } - - $result = e107::getFile()->getRemoteFile('https://codeload.github.com/e107inc/e107/zip/master', 'e107-master.zip', 'temp'); - - if($result == false) + if($result === false) { e107::getMessage()->addError( DBLAN_118 ); + return null; } + $success = $result['success']; + $error = $result['error']; - $localfile = 'e107-master.zip'; - - chmod(e_TEMP.$localfile, 0755); - require_once(e_HANDLER."pclzip.lib.php"); - -// $base = realpath(dirname(__FILE__)); - - - $newFolders = array( - 'e107-master/e107_admin/' => e_BASE.e107::getFolder('ADMIN'), - 'e107-master/e107_core/' => e_BASE.e107::getFolder('CORE'), - 'e107-master/e107_docs/' => e_BASE.e107::getFolder('DOCS'), - 'e107-master/e107_handlers/' => e_BASE.e107::getFolder('HANDLERS'), - 'e107-master/e107_images/' => e_BASE.e107::getFolder('IMAGES'), - 'e107-master/e107_languages/' => e_BASE.e107::getFolder('LANGUAGES'), - 'e107-master/e107_media/' => e_BASE.e107::getFolder('MEDIA'), - 'e107-master/e107_plugins/' => e_BASE.e107::getFolder('PLUGINS'), - 'e107-master/e107_system/' => e_BASE.e107::getFolder('SYSTEM'), - 'e107-master/e107_themes/' => e_BASE.e107::getFolder('THEMES'), - 'e107-master/e107_web/' => e_BASE.e107::getFolder('WEB'), - 'e107-master/' => e_BASE - ); - - $srch = array_keys($newFolders); - $repl = array_values($newFolders); - - $archive = new PclZip(e_TEMP.$localfile); - $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first. - - $error = array(); - $success = array(); - $skipped = array(); -// print_a($unarc); - - - $excludes = array('e107-master/','e107-master/install.php','e107-master/favicon.ico'); - - foreach($unarc as $k=>$v) - { - if(in_array($v['stored_filename'],$excludes)) - { - continue; - } - - $oldPath = $v['filename']; - $newPath = str_replace($srch,$repl, $v['stored_filename']); - - $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath)); - - if($v['folder'] ==1 && is_dir($newPath)) - { - // $skipped[] = $newPath. " (already exists)"; - continue; - } - - if(!rename($oldPath,$newPath)) - { - $error[] = $message; - } - else - { - $success[] = $message; - } - - - // echo $message."
"; - - } + // $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath)); if(!empty($success)) { @@ -458,9 +387,6 @@ class system_tools e107::getMessage()->addError(print_a($error,true)); } - - - e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_112, e107::getMessage()->render()); } diff --git a/e107_admin/lancheck.php b/e107_admin/lancheck.php index 97c6ae494..f406794b4 100644 --- a/e107_admin/lancheck.php +++ b/e107_admin/lancheck.php @@ -314,6 +314,7 @@ class lancheck private $deprecatedFiles = array('lan_download.php', 'lan_parser_functions.php', 'lan_prefs.php', 'admin/lan_download.php', 'admin/lan_modcomment.php'); + private $installed_languages = array(); function __construct() { @@ -346,8 +347,12 @@ class lancheck $pref = e107::getPref(); // Check current theme also (but do NOT add to generated zip) - $this->core_themes[] = $pref['sitetheme']; - $this->core_themes = array_unique($this->core_themes); + + if(deftrue('e_DEBUG')) + { + $this->core_themes[] = $pref['sitetheme']; + $this->core_themes = array_unique($this->core_themes); + } if(E107_DEBUG_LEVEL > 0) { @@ -791,63 +796,34 @@ class lancheck return $pzip; } - - /** - * List the installed language packs. - * @return + * Get Installed Language-Pack Meta Data. + * @return array */ - function showLanguagePacks() + function getLocalLanguagePacks() { - $frm = e107::getForm(); - $ns = e107::getRender(); - $tp = e107::getParser(); + $this->installed_languages = e107::getLanguage()->installed(); - if(is_readable(e_ADMIN."ver.php")) - { - include(e_ADMIN."ver.php"); - list($ver, $tmp) = explode(" ", $e107info['e107_version']); - } + $xml = e107::getXml(); - $lans = e107::getLanguage()->installed(); + $arr = array(); - $release_diz = defined("LANG_LAN_30") ? LANG_LAN_30 : "Release Date"; - $compat_diz = defined("LANG_LAN_31") ? LANG_LAN_31 : "Compatibility"; - $lan_pleasewait = (deftrue('LAN_PLEASEWAIT')) ? $tp->toJS(LAN_PLEASEWAIT) : "Please Wait"; - - - - $text = "
- "; - $text .= " - - - - - - - "; - - require_once(e_HANDLER."xml_class.php"); - $xm = new XMLParse(); - - foreach($lans as $language) + foreach($this->installed_languages as $language) { if($language == "English") { continue; } + $metaFile = e_LANGUAGEDIR.$language."/".$language.".xml"; if(is_readable($metaFile)) { - $rawData = file_get_contents($metaFile); + $rawData = $xml->loadXMLfile($metaFile,true); + if($rawData) { - $array = $xm->parse($rawData); - $value = $array['e107Language']['attributes']; + $value = $rawData['@attributes']; } else { @@ -865,148 +841,68 @@ class lancheck ); } - $errFound = (isset($_SESSION['lancheck'][$language]['total']) && $_SESSION['lancheck'][$language]['total'] > 0) ? TRUE : FALSE; + $value['type'] = 'local'; - - $text .= " - - - - - - "; + $arr[$language] = $value; } - $text .= " - -
".ADLAN_132."".$release_diz."".$compat_diz."".LAN_STATUS." - ".LAN_OPTIONS." -
".$language."".$value['date']."".$value['compatibility']."".($ver != $value['compatibility'] || $errFound ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON ).""; - - // $text .= ""; - $text .= "".LAN_CHECK_2.""; - - $text .= " -
"; - - $text .= ""; - - $text .= ""; - - $srch = array("[","]"); - $repl = array("",""); - $diz = (deftrue("LANG_LAN_28")) ? LANG_LAN_28 : "Check this box if you are a member of the [e107 translation team]."; - - $checked = varset($_COOKIE['e107_certified']) == 1 ? true : false; - - $text .= " - - - - - "; - -// $text .= " -// -// -// -// "; - - $text .= "
".LAN_OPTIONS."
"; - $text .= $frm->checkbox('contribute_pack',1,$checked,array('label'=>str_replace($srch,$repl,$diz))); - ; - - - $text .= "
"; - - // $echecked = varset($_SESSION['lancheck-errors-only']) == 1 ? true : false; - // $text .= $frm->checkbox('errorsonly',1,$echecked,array('label'=>$lan_displayerrors)); - $text .= "
".$frm->checkbox('non-core-plugs-themes',1,$echecked,array('label'=>$lan_displayerrors))."
"; - - - $text .= "
"; - - $text .= "
".LANG_LAN_AGR."
"; - - $text .= $this->onlineLanguagePacks(); - - return $text; - - return; - + return $arr; } - private function onlineLanguagePacks() + + + /** + * Get Online Language-Pack Meta Data. + * @return array|bool + */ + public function getOnlineLanguagePacks() { $xml = e107::getXml(); - $feed = e107::getPref('xmlfeed_languagepacks'); + $feed = 'https://e107.org/languagepacks.xml'; - $text = ''; + $languages = array(); if($rawData = $xml -> loadXMLfile($feed, TRUE)) { - if(!varset($rawData['language'])) + + if(empty($rawData['language'])) { - return FALSE; + return false; } - $text .= "
".LANG_LAN_35."
"; - $text .= ""; foreach($rawData['language'] as $val) { $att = $val['@attributes']; - $name = $att['folder']; - $languages[$name] = array( - 'name' => $att['name'], - 'author' => $att['author'], - 'authorURL' => $att['authorURL'], - 'folder' => $att['folder'], - 'version' => $att['version'], - 'date' => $att['date'], + + $id = $att['name']; + + $languages[$id] = array( + 'name' => $att['name'], + 'author' => $att['author'], + 'infoURL' => $att['infourl'], + // 'folder' => $att['folder'], + 'version' => $att['version'], + 'date' => $att['date'], 'compatibility' => $att['compatibility'], - 'url' => $att['url'] + 'url' => $att['url'], + 'type' => 'online' + ); } - ksort($languages); - - $text .= " - - - - - - - - - - "; - - foreach($languages as $value) - { - $text .= " - - - - - - - - "; - } - - $text .= "
".LAN_NAME."".LAN_VERSION."".LAN_AUTHOR."".LANG_LAN_111."".LANG_LAN_112."".LAN_DOWNLOAD."
".$value['name']."".$value['version']."".$value['author']."".$value['date']."".$value['compatibility']."".LANG_LAN_114."
"; } - return $text; - - - + return $languages; } + + + function check_all($mode='render', $lan=null) { // global $ns,$tp; @@ -1081,14 +977,14 @@ class lancheck } $message = " -
+
\n"; $icon = ($_SESSION['lancheck'][$lan]['total']>0) ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON; $errors_diz = (deftrue('LAN_CHECK_23')) ? LAN_CHECK_23 : "Errors Found"; - + $message .= $errors_diz.": ".$_SESSION['lancheck'][$lan]['total']; $just_go_diz = (deftrue('LAN_CHECK_20')) ? LAN_CHECK_20 : "Generate Language Pack"; @@ -1361,7 +1257,7 @@ class lancheck $style = ($er) ? "forumheader2" : "forumheader3"; $text .= "
"; $text .= $bom_error . $utf_error; - $text .= (!$er && !$bom_error && !$utf_error) ? "".LAN_OK."" : $er."
"; + $text .= (!$er && !$bom_error && !$utf_error) ? ADMIN_TRUE_ICON : $er."
"; $text .= "
"; } else @@ -1722,7 +1618,7 @@ class lancheck $style = ($er) ? "forumheader2" : "forumheader3"; $text .= "
"; $text .= $bom_error . $utf_error; - $text .= (!$er && !$bom_error && !$utf_error) ? "".LAN_OK."" : $er."
"; + $text .= (!$er && !$bom_error && !$utf_error) ? ADMIN_TRUE_ICON : $er."
"; $text .= "
"; } else diff --git a/e107_admin/language.php b/e107_admin/language.php index b90ea26e9..f77cbe31a 100644 --- a/e107_admin/language.php +++ b/e107_admin/language.php @@ -54,7 +54,8 @@ if(!empty($_GET['iframe'])) ); protected $adminMenuAliases = array( - 'main/edit' => 'main/list' + 'main/edit' => 'main/list', + // 'main/download' => 'main/tools' ); protected $adminMenuIcon = 'e-language-24'; @@ -123,12 +124,31 @@ if(!empty($_GET['iframe'])) ); protected $installedLanguages = array(); + protected $localPacks = array(); + protected $onlinePacks = array(); public function init() { $this->installedLanguages = e107::getLanguage()->installed(); $this->prefs['sitelanguage']['writeParms']['optArray'] = $this->installedLanguages; $this->prefs['adminlanguage']['writeParms']['optArray'] = $this->installedLanguages; + + e107::css('inline', " + + .language-name { padding-left:15px } + + "); + + + } + + private function loadPackInfo() + { + $lck = e107::getSingleton('lancheck', e_ADMIN."lancheck.php"); + + $this->onlinePacks = $lck->getOnlineLanguagePacks(); + $this->localPacks = $lck->getLocalLanguagePacks(); + } @@ -153,8 +173,11 @@ if(!empty($_GET['iframe'])) return $text; } - function toolsPage() + + + function ToolsPage() { + $this->loadPackInfo(); $pref = e107::getPref(); $lck = e107::getSingleton('lancheck', e_ADMIN."lancheck.php"); @@ -172,24 +195,234 @@ if(!empty($_GET['iframe'])) } - $text = $lck->showLanguagePacks(); + return $this->renderLanguagePacks(); - //e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_32, $text); - - //return; + } - // e107::getRender()->tablerender(ADLAN_132.SEP."Core Language-Pack Developer", ); + function DownloadPage() + { + $this->loadPackInfo(); + + $lan = $this->getId(); + + if(empty($lan)) + { + return LAN_ERROR; + } + + if(empty($this->onlinePacks[$lan]['url'])) + { + return LAN_ERROR; + } + + + $result = e107::getFile()->unzipGithubArchive($this->onlinePacks[$lan]['url']); + + if(!empty($result['success'])) + { + e107::getMessage()->addSuccess(print_a($result['success'],true)); + $_SESSION['lancheck'][$lan]['total'] = 0; // reset errors to zero. + } + + if(!empty($result['error'])) + { + e107::getMessage()->addError(print_a($result['error'],true)); + } + + $this->addTitle(LANG_LAN_114); + $this->addTitle($lan); + + + return e107::getMessage()->render(); + } + + + + + + /** + * List the installed language packs. + * @return string + */ + private function renderLanguagePacks() + { + $frm = e107::getForm(); + $ns = e107::getRender(); + $tp = e107::getParser(); + + if(is_readable(e_ADMIN."ver.php")) + { + include(e_ADMIN."ver.php"); + list($ver, $tmp) = explode(" ", $e107info['e107_version']); + } + + $lck = e107::getSingleton('lancheck', e_ADMIN."lancheck.php"); + + $release_diz = defset("LANG_LAN_30","Release Date"); + $compat_diz = defset("LANG_LAN_31", "Compatibility"); + $lan_pleasewait = (deftrue('LAN_PLEASEWAIT')) ? $tp->toJS(LAN_PLEASEWAIT) : "Please Wait"; + + + $text = " + + + + + + + + "; + $text .= " + + + + + + + "; + + $text .= ""; + + // $onlinePacks = $lck->getOnlineLanguagePacks(); + // $localPacks = $lck->getLocalLanguagePacks(); + + foreach($this->localPacks as $language=>$value) + { + + $errFound = (isset($_SESSION['lancheck'][$language]['total']) && $_SESSION['lancheck'][$language]['total'] > 0) ? TRUE : FALSE; + + + $text .= " + + + + + + "; + } + + $text .= ""; // don't translate this. + + $text .= $this->renderOnlineLanguagePacks(); + + $text .= " +
".ADLAN_132."".$release_diz."".$compat_diz."".LAN_STATUS." + ".LAN_OPTIONS." +
".LAN_INSTALLED."
".$language."".$value['date']."".$value['compatibility']."".( $errFound ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON ).""; + + // $text .= ""; + $text .= "".$tp->toGlyph('fa-search').LAN_CHECK_2.""; + + /* $text .= " + "; + */ + $text .= "
".defset('LANG_LAN_151','Available')."
"; + + $creditLan = defset('LANG_LAN_152', "Courtesy of the [e107 translation team]"); // don't translate this. + + $srch = array("[","]"); + $repl = array("",""); + + $text .= ""; + + + +/* + $text .= ""; + + $text .= ""; + + $srch = array("[","]"); + $repl = array("",""); + $diz = (deftrue("LANG_LAN_28")) ? LANG_LAN_28 : "Check this box if you are a member of the [e107 translation team]."; + + $checked = varset($_COOKIE['e107_certified']) == 1 ? true : false; + + $text .= " + + + + "; + + $text .= "
".LAN_OPTIONS."
"; + $text .= $frm->checkbox('contribute_pack',1,$checked,array('label'=>str_replace($srch,$repl,$diz))); + ; + + + $text .= "
"; + + $text .= "
"; + */ + + $text .= ""; + + // $text .= "
".LANG_LAN_AGR."
"; + return $text; + + } + private function renderOnlineLanguagePacks() + { + + $text = ''; + + $tp = e107::getParser(); + + foreach($this->onlinePacks as $lan=>$value) + { + + if(!empty($this->localPacks[$lan])) + { + + if($this->localPacks[$lan]['compatibility'] == $value['compatibility'] && !deftrue('e_DEBUG')) + { + continue; + } + + // $status = $tp->toGlyph('fa-star'); + $class = 'btn-primary'; + } + else + { + $status = " "; + $class = 'btn-default'; + } + + + $text .= " + ".$value['name'].""; + + /* $text .= " + ".$value['version']." + ".$value['author']."";*/ + + + $url = 'language.php?mode=main&action=download&id='.$value['name']; // $value['url'] + + $text .= " + ".$value['date']." + ".$value['compatibility']." + ".$status." + ".ADLAN_121." + "; + } + + return $text; + + } + + + private function getTables() { // grab default language lists. diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index 925561c6b..f3ae6ee09 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -1511,4 +1511,143 @@ class e_file return $limits; } + + + + + public function unzipGithubArchive($url='core') + { + + switch($url) + { + case "core": + $localfile = 'e107-master.zip'; + $remotefile = 'https://codeload.github.com/e107inc/e107/zip/master'; + $excludes = array('e107-master/install.php','e107-master/favicon.ico'); + $excludeMatch = false; + break; + + // language. + // eg. https://github.com/e107translations/Spanish/archive/v2.1.5.zip + default: + $localfile = str_replace('https://github.com/e107translations/','',$url); // 'e107-master.zip'; + $localfile = str_replace('/archive/v','-',$localfile); //remove dirs. + $remotefile = $url; + $excludes = array(); + $excludeMatch = array('alt_auth','tagwords','faqs'); + + } + + // Delete any existing file. + if(file_exists(e_TEMP.$localfile)) + { + unlink(e_TEMP.$localfile); + } + + $result = $this->getRemoteFile($remotefile, $localfile, 'temp'); + + if($result === false) + { + return false; + } + + + + chmod(e_TEMP.$localfile, 0755); + require_once(e_HANDLER."pclzip.lib.php"); + + $zipBase = str_replace('.zip','',$localfile); // eg. e107-master + $excludes[] = $zipBase; + + $newFolders = array( + $zipBase.'/e107_admin/' => e_BASE.e107::getFolder('ADMIN'), + $zipBase.'/e107_core/' => e_BASE.e107::getFolder('CORE'), + $zipBase.'/e107_docs/' => e_BASE.e107::getFolder('DOCS'), + $zipBase.'/e107_handlers/' => e_BASE.e107::getFolder('HANDLERS'), + $zipBase.'/e107_images/' => e_BASE.e107::getFolder('IMAGES'), + $zipBase.'/e107_languages/' => e_BASE.e107::getFolder('LANGUAGES'), + $zipBase.'/e107_media/' => e_BASE.e107::getFolder('MEDIA'), + $zipBase.'/e107_plugins/' => e_BASE.e107::getFolder('PLUGINS'), + $zipBase.'/e107_system/' => e_BASE.e107::getFolder('SYSTEM'), + $zipBase.'/e107_themes/' => e_BASE.e107::getFolder('THEMES'), + $zipBase.'/e107_web/' => e_BASE.e107::getFolder('WEB'), + $zipBase.'/' => e_BASE + ); + + $srch = array_keys($newFolders); + $repl = array_values($newFolders); + + $archive = new PclZip(e_TEMP.$localfile); + $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first. + + $error = array(); + $success = array(); + // $skipped = array(); + + + + foreach($unarc as $k=>$v) + { + if($this->matchFound($v['stored_filename'],$excludeMatch)) + { + continue; + } + + if(in_array($v['stored_filename'],$excludes)) + { + continue; + } + + $oldPath = $v['filename']; + $newPath = str_replace($srch,$repl, $v['stored_filename']); + +/* + $success[] = $newPath; + continue;*/ + + if($v['folder'] ==1 && is_dir($newPath)) + { + // $skipped[] = $newPath. " (already exists)"; + continue; + } + + if(!rename($oldPath,$newPath)) + { + $error[] = $newPath; + } + else + { + $success[] = $newPath; + } + + } + + + return array('success'=>$success, 'error'=>$error); + + } + + + + + private function matchFound($file,$array) + { + if(empty($array)) + { + return false; + } + + foreach($array as $term) + { + if(strpos($file,$term)!==false) + { + return true; + } + + } + + return false; + + } + } diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index cac3ae919..99acebc55 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -894,13 +894,13 @@ class e107plugin protected $core_plugins = array( - "_blank","admin_menu","alt_auth","banner","blogcalendar_menu", + "_blank","admin_menu","banner","blogcalendar_menu", "chatbox_menu", "clock_menu","comment_menu", - "contact", "download","faqs", "featurebox", "forum","gallery", + "contact", "download", "featurebox", "forum","gallery", "gsitemap","import", "linkwords", "list_new", "log", "login_menu", "metaweblog", "newforumposts_main", "news", "newsfeed", "newsletter","online", "page", "pm","poll", - "rss_menu","search_menu","siteinfo", "social", "tagwords", "tinymce4", + "rss_menu","search_menu","siteinfo", "social", "tagcloud", "tinymce4", "trackback","tree_menu","user" ); diff --git a/e107_languages/English/admin/lan_lancheck.php b/e107_languages/English/admin/lan_lancheck.php index 2e5ecc0dd..49540abcb 100644 --- a/e107_languages/English/admin/lan_lancheck.php +++ b/e107_languages/English/admin/lan_lancheck.php @@ -43,4 +43,4 @@ define("LANG_LAN_120", "Please make sure you are using default folder names in e define("LANG_LAN_AGR", "Note: By using these tools you agree to share your language pack(s) with the e107 community."); -?> +?> \ No newline at end of file diff --git a/e107_languages/English/admin/lan_language.php b/e107_languages/English/admin/lan_language.php index a13c8f7b6..98237db70 100644 --- a/e107_languages/English/admin/lan_language.php +++ b/e107_languages/English/admin/lan_language.php @@ -65,4 +65,9 @@ define("LANG_LAN_144", "Must be re-enabled"); define("LANG_LAN_148", "Normal Mode"); define("LANG_LAN_149", "Value"); define("LANG_LAN_150", "[b]Search ENTIRE core before commenting out ANY LAN from ANY language file.[/b]"); -?> + +define("LANG_LAN_151", "Available"); +define("LANG_LAN_152", "Courtesy of the [e107 translations team]"); + + +?> \ No newline at end of file