diff --git a/addressing.js b/addressing.js index 7ff6e84..c731182 100644 --- a/addressing.js +++ b/addressing.js @@ -126,7 +126,7 @@ function nameIsThere(params) { var typeElm = $('select[name="type"]'); var divNameItemElm = $('div[id="nameItem"]'); $.ajax({ - url: root_doc + '/plugins/addressing/front/addressing.php', + url: root_doc + '/front/addressing.php', type: "GET", dataType: "json", data: { diff --git a/addressing.xml b/addressing.xml index 7e4aa97..157a3a0 100644 --- a/addressing.xml +++ b/addressing.xml @@ -27,6 +27,10 @@ Nelly Mahu-Lasson + + 2.9.1 + 9.5 + 2.9.0 9.5 diff --git a/ajax/index.php b/ajax/index.php new file mode 100644 index 0000000..f2c28fe --- /dev/null +++ b/ajax/index.php @@ -0,0 +1,28 @@ +. + -------------------------------------------------------------------------- + */ diff --git a/front/index.php b/front/index.php new file mode 100644 index 0000000..f2c28fe --- /dev/null +++ b/front/index.php @@ -0,0 +1,28 @@ +. + -------------------------------------------------------------------------- + */ diff --git a/hook.php b/hook.php index 9b6eb2a..e110ba3 100644 --- a/hook.php +++ b/hook.php @@ -30,14 +30,14 @@ function plugin_addressing_install() { global $DB; - include_once(GLPI_ROOT . "/plugins/addressing/inc/profile.class.php"); + include_once(PLUGIN_ADDRESSING_DIR . "/inc/profile.class.php"); $update = false; if (!$DB->tableExists("glpi_plugin_addressing_display") && !$DB->tableExists("glpi_plugin_addressing") && !$DB->tableExists("glpi_plugin_addressing_configs")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-3.0.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/empty-3.0.0.sql"); } else { @@ -45,53 +45,53 @@ function plugin_addressing_install() { && $DB->tableExists("glpi_plugin_addressing_display") && !$DB->fieldExists("glpi_plugin_addressing_display", "ipconf1")) {//1.4 $update = true; - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.4.sql"); } if (!$DB->tableExists("glpi_plugin_addressing") && $DB->tableExists("glpi_plugin_addressing_display") && $DB->fieldExists("glpi_plugin_addressing_display", "ipconf1")) { $update = true; - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.5.sql"); } if ($DB->tableExists("glpi_plugin_addressing_display") && !$DB->fieldExists("glpi_plugin_addressing", "ipdeb")) { $update = true; - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.6.sql"); } if ($DB->tableExists("glpi_plugin_addressing_profiles") && $DB->fieldExists("glpi_plugin_addressing_profiles", "interface")) { $update = true; - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.7.0.sql"); } if (!$DB->tableExists("glpi_plugin_addressing_configs")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.8.0.sql"); $update = true; } if ($DB->tableExists("glpi_plugin_addressing_profiles") && !$DB->fieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-1.9.0.sql"); $update = true; } //Version 2.4.0 if (!$DB->tableExists("glpi_plugin_addressing_filters")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-2.4.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-2.4.0.sql"); } //Version 2.5.0 if (!$DB->fieldExists("glpi_plugin_addressing_addressings", "locations_id") && !$DB->fieldExists("glpi_plugin_addressing_addressings", "fqdns_id")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-2.5.0.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-2.5.0.sql"); } //Version 2.9.1 if (!$DB->tableExists("glpi_plugin_addressing_pinginfos")) { - $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-2.9.1.sql"); + $DB->runFile(PLUGIN_ADDRESSING_DIR . "/sql/update-2.9.1.sql"); } } @@ -143,8 +143,8 @@ function plugin_addressing_install() { function plugin_addressing_uninstall() { global $DB; - include_once(GLPI_ROOT . "/plugins/addressing/inc/profile.class.php"); - include_once(GLPI_ROOT . "/plugins/addressing/inc/menu.class.php"); + include_once(PLUGIN_ADDRESSING_DIR . "/inc/profile.class.php"); + include_once(PLUGIN_ADDRESSING_DIR . "/inc/menu.class.php"); $migration = new Migration("2.5.0"); $tables = ["glpi_plugin_addressing_addressings", diff --git a/inc/addressing.class.php b/inc/addressing.class.php index 07d295a..d1bed94 100644 --- a/inc/addressing.class.php +++ b/inc/addressing.class.php @@ -814,7 +814,7 @@ function showReport($params) { $('#ajax_loader').show(); $.ajax({ - url: '" . $CFG_GLPI["root_doc"] . PLUGIN_ADDRESSING_DIR_NOFULL . "/ajax/updatepinginfo.php', + url: '" . PLUGINADDRESSING_WEBDIR . "/ajax/updatepinginfo.php', type: 'POST', data: {'addressing_id' : addressing_id}, success: function(response){ diff --git a/inc/filter.class.php b/inc/filter.class.php index a7a1f8d..c05acda 100644 --- a/inc/filter.class.php +++ b/inc/filter.class.php @@ -270,7 +270,7 @@ static function showList($item, $options = []) { 'items_id' => $item_id, 'id' => -1]; Ajax::updateItemJsCode("viewfilter" . $item_id . "$rand", - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php", + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php", $params); echo "};"; echo "\n"; @@ -363,7 +363,7 @@ function showMinimalFilterForm($item, $filter, $canedit, $rand) { 'items_id' => $item["id"], 'id' => $filter['id']]; Ajax::updateItemJsCode("viewfilter" . $item["id"] . "$rand", - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php", + PLUGINADDRESSING_WEBDIR. "/ajax/addressing.php", $params); echo "};"; echo "\n"; diff --git a/inc/index.php b/inc/index.php new file mode 100644 index 0000000..f2c28fe --- /dev/null +++ b/inc/index.php @@ -0,0 +1,28 @@ +. + -------------------------------------------------------------------------- + */ diff --git a/inc/menu.class.php b/inc/menu.class.php index 7999366..768a211 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -41,8 +41,6 @@ static function getMenuContent() { $menu = []; $menu['title'] = self::getMenuName(); - $menu['page'] = "/plugins/addressing/front/addressing.php"; - $menu['title'] = PluginAddressingAddressing::getTypeName(2); $menu['page'] = PluginAddressingAddressing::getSearchURL(false); $menu['links']['search'] = PluginAddressingAddressing::getSearchURL(false); @@ -71,7 +69,7 @@ static function getMenuContent() { } static function getIcon() { - return "fas fa-map-pin"; + return "ti ti-map-pin"; } static function removeRightsFromSession() { diff --git a/inc/ping_equipment.class.php b/inc/ping_equipment.class.php index 5086cd4..d9e9d18 100644 --- a/inc/ping_equipment.class.php +++ b/inc/ping_equipment.class.php @@ -99,7 +99,7 @@ function showPingForm($itemtype, $items_id) echo ""; echo Html::scriptBlock("$(document).on('click', '#ping_ip', function(event) { - $('#ping_response').load('" . $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/ping.php', { + $('#ping_response').load('" . PLUGINADDRESSING_WEBDIR . "/ajax/ping.php', { 'ip': $('#ip').val(), 'itemtype': '$itemtype', 'items_id': '$items_id' diff --git a/inc/pinginfo.class.php b/inc/pinginfo.class.php index 51948c1..6ad0aaa 100644 --- a/inc/pinginfo.class.php +++ b/inc/pinginfo.class.php @@ -34,12 +34,10 @@ /** * Class PluginAddressingPinginfo */ -class PluginAddressingPinginfo extends CommonDBTM -{ +class PluginAddressingPinginfo extends CommonDBTM { static $rightname = "plugin_addressing"; - static function getTypeName($nb = 0) - { + static function getTypeName($nb = 0) { return _n('IP Adressing', 'IP Adressing', $nb, 'addressing'); } @@ -47,8 +45,7 @@ static function getTypeName($nb = 0) /** * @param $name **/ - static function cronInfo($name) - { + static function cronInfo($name) { switch ($name) { case 'UpdatePing' : @@ -66,12 +63,11 @@ static function cronInfo($name) * @param $task for log, if NULL display * **/ - static function cronUpdatePing($task = null) - { + static function cronUpdatePing($task = null) { $cron_status = 1; - $self = new self(); - $vol = $self->updateAllAddressing(); + $self = new self(); + $vol = $self->updateAllAddressing(); $task->addVolume($vol); // $task->log(Dropdown::getDropdownName("glpi_entities", // $entity) . ": $message\n"); @@ -80,17 +76,16 @@ static function cronUpdatePing($task = null) } - public function updateAllAddressing() - { - $old_memory = ini_set("memory_limit", "-1"); - $old_execution = ini_set("max_execution_time", "0"); - $addressing = new PluginAddressingAddressing(); - $addressings = $addressing->find(['is_deleted' => 0, - 'use_ping' => 1]); + public function updateAllAddressing() { + $old_memory = ini_set("memory_limit", "-1"); + $old_execution = ini_set("max_execution_time", "0"); + $addressing = new PluginAddressingAddressing(); + $addressings = $addressing->find(['is_deleted' => 0, + 'use_ping' => 1]); $total_ping_responses = 0; foreach ($addressings as $addressing_array) { $addressing->getFromDB($addressing_array['id']); - $ping_responses = $this->updateAnAddressing($addressing); + $ping_responses = $this->updateAnAddressing($addressing); $total_ping_responses += $ping_responses; } ini_set("memory_limit", $old_memory); @@ -98,15 +93,14 @@ public function updateAllAddressing() return $total_ping_responses; } - public function updateAnAddressing(PluginAddressingAddressing $addressing) - { + public function updateAnAddressing(PluginAddressingAddressing $addressing) { $ipdeb = sprintf("%u", ip2long($addressing->fields["begin_ip"])); $ipfin = sprintf("%u", ip2long($addressing->fields["end_ip"])); - $result = $addressing->compute(0, ['ipdeb' => $ipdeb, - 'ipfin' => $ipfin, - 'entities' => $addressing->fields['entities_id']]); + $result = $addressing->compute(0, ['ipdeb' => $ipdeb, + 'ipfin' => $ipfin, + 'entities' => $addressing->fields['entities_id']]); $plugin_addressing_pinginfo = new PluginAddressingPinginfo(); $plugin_addressing_pinginfo->deleteByCriteria(['plugin_addressing_addressings_id' => $addressing->getID()]); @@ -115,11 +109,10 @@ public function updateAnAddressing(PluginAddressingAddressing $addressing) return $ping_responses; } - private function updatePingInfos($result, PluginAddressingAddressing $PluginAddressingAddressing) - { + private function updatePingInfos($result, PluginAddressingAddressing $PluginAddressingAddressing) { // Get config - $PluginAddressingConfig = new PluginAddressingConfig(); + $PluginAddressingConfig = new PluginAddressingConfig(); $PluginAddressingPing_Equipment = new PluginAddressingPing_Equipment(); $PluginAddressingConfig->getFromDB('1'); $system = $PluginAddressingConfig->fields["used_system"]; @@ -131,15 +124,15 @@ private function updatePingInfos($result, PluginAddressingAddressing $PluginAddr foreach ($result as $num => $lines) { $ip = PluginAddressingReport::string2ip(substr($num, 2)); - $ping_value = $PluginAddressingPing_Equipment->ping($system, $ip, "true"); - $data = []; + $ping_value = $PluginAddressingPing_Equipment->ping($system, $ip, "true"); + $data = []; $data['plugin_addressing_addressings_id'] = $PluginAddressingAddressing->getID(); - $data['ipname'] = $num; + $data['ipname'] = $num; - $data['itemtype'] = isset($lines['0']['itemtype']) ? $lines['0']['itemtype'] : ""; - $data['items_id'] = isset($lines['0']['on_device']) ? $lines['0']['on_device'] : "0"; + $data['itemtype'] = isset($lines['0']['itemtype']) ? $lines['0']['itemtype'] : ""; + $data['items_id'] = isset($lines['0']['on_device']) ? $lines['0']['on_device'] : "0"; $data['ping_response'] = $ping_value ?? 0; - $data['ping_date'] = date('Y-m-d H:i:s'); + $data['ping_date'] = date('Y-m-d H:i:s'); $plugin_addressing_pinginfo->add($data); @@ -150,28 +143,27 @@ private function updatePingInfos($result, PluginAddressingAddressing $PluginAddr return $ping_response; } - static function getPingResponseForItem($params) - { + static function getPingResponseForItem($params) { global $CFG_GLPI; $ping_right = Session::haveRight('plugin_addressing_use_ping_in_equipment', '1'); - $item = $params['item']; + $item = $params['item']; if ($ping_right - && in_array($item->getType(), PluginAddressingAddressing::getTypes()) && $item->getID() > 0) { + && in_array($item->getType(), PluginAddressingAddressing::getTypes()) && $item->getID() > 0) { - $items_id = $item->getID(); - $itemtype = $item->getType(); + $items_id = $item->getID(); + $itemtype = $item->getType(); $plugin_addressing_pinginfo = new PluginAddressingPinginfo(); $ping_action = 0; - $ping_value = 0; + $ping_value = 0; if ($pings = $plugin_addressing_pinginfo->find(['itemtype' => $itemtype, - 'items_id' => $items_id])) { + 'items_id' => $items_id])) { foreach ($pings as $ping) { $ping_value = $ping['ping_response']; - $ping_date = $ping['ping_date']; - $ipname = $ping['ipname']; + $ping_date = $ping['ping_date']; + $ipname = $ping['ipname']; } $ping_action = 1; } @@ -182,14 +174,14 @@ static function getPingResponseForItem($params) } else { if ($ping_value == 1) { $content = "
" . __("Last ping attempt", 'addressing') . " : " - . Html::convDateTime($ping_date); - $content .= "
"._('IP')." ".$ip = PluginAddressingReport::string2ip(substr($ipname, 2)); + . Html::convDateTime($ping_date) . "'>
" . __("Last ping attempt", 'addressing') . " : " + . Html::convDateTime($ping_date); + $content .= "
" . _('IP') . " " . $ip = PluginAddressingReport::string2ip(substr($ipname, 2)); } else { $content = "
" . __("Last ping attempt", 'addressing') . " : " - . Html::convDateTime($ping_date); - $content .= "
"._('IP')." ".$ip = PluginAddressingReport::string2ip(substr($ipname, 2)); + . Html::convDateTime($ping_date) . "'>
" . __("Last ping attempt", 'addressing') . " : " + . Html::convDateTime($ping_date); + $content .= "
" . _('IP') . " " . $ip = PluginAddressingReport::string2ip(substr($ipname, 2)); } } echo ""; @@ -209,12 +201,12 @@ static function getPingResponseForItem($params) echo "\n"; @@ -222,7 +214,7 @@ static function getPingResponseForItem($params) echo ""; echo ""; echo "
"; echo "
"; - include(GLPI_ROOT . "/plugins/addressing/ajax/seePingTab.php"); + include(PLUGIN_ADDRESSING_DIR . "/ajax/seePingTab.php"); echo "
"; echo "
"; @@ -238,7 +230,7 @@ public static function cleanForItem(CommonDBTM $item) { $temp = new self(); $temp->deleteByCriteria( ['itemtype' => $item->getType(), - 'items_id' => $item->getField('id')] + 'items_id' => $item->getField('id')] ); } } diff --git a/inc/report.class.php b/inc/report.class.php index 245ac71..3446619 100644 --- a/inc/report.class.php +++ b/inc/report.class.php @@ -267,7 +267,7 @@ function displayReport(&$result, $PluginAddressingAddressing, $ping_status = []) echo Search::showItem($output_type, "$reserv ", $item_num, $row_num, "style='background-color:#e0e0e0' class='center'"); if (isset($params) && count($params) > 0) { echo Ajax::createIframeModalWindow('reservation'.$rand, - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], ['title' => __s('IP reservation', 'addressing'), 'display' => false]); } @@ -302,7 +302,7 @@ function displayReport(&$result, $PluginAddressingAddressing, $ping_status = []) echo Search::showItem($output_type, "$reserv ", $item_num, $row_num, "style='background-color:#e0e0e0' class='center'"); if (isset($params) && count($params) > 0) { echo Ajax::createIframeModalWindow('reservation'.$rand, - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], ['title' => __s('IP reservation', 'addressing'), 'display' => false]); } @@ -342,7 +342,7 @@ function displayReport(&$result, $PluginAddressingAddressing, $ping_status = []) "; if (isset($params) && count($params) > 0) { echo Ajax::createIframeModalWindow('reservation'.$rand, - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], ['title' => __s('IP reservation', 'addressing'), 'display' => false]); } @@ -435,7 +435,7 @@ function displayReport(&$result, $PluginAddressingAddressing, $ping_status = []) "; if (isset($params) && count($params) > 0) { echo Ajax::createIframeModalWindow('reservation'.$rand, - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php?action=showForm&ip=" . $params['ip'] . "&id_addressing=" . $params['id_addressing'] . "&rand=" . $params['rand'], ['title' => __s('IP reservation', 'addressing'), 'display' => false]); } diff --git a/inc/reserveip.class.php b/inc/reserveip.class.php index e23d5e0..5ed35f9 100644 --- a/inc/reserveip.class.php +++ b/inc/reserveip.class.php @@ -168,7 +168,7 @@ function checkMandatoryFields($input) { function showReservationForm($ip, $id_addressing, $rand) { global $CFG_GLPI; - echo Html::script("/plugins/addressing/addressing.js"); + echo Html::script(PLUGIN_ADDRESSING_DIR_NOFULL."/addressing.js"); $addressing = new PluginAddressingAddressing(); $addressing->getFromDB($id_addressing); @@ -213,19 +213,19 @@ function showReservationForm($ip, $id_addressing, $rand) { $params = ['action' => 'entities_networkip', 'entities_id' => '__VALUE__']; Ajax::updateItemOnEvent("dropdown_entities_id" . $rand, 'entities_networkip', - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php", + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php", $params); $params = ['action' => 'entities_location', 'entities_id' => '__VALUE__', 'value' => $addressing->fields["locations_id"]]; Ajax::updateItemOnEvent("dropdown_entities_id" . $rand, 'entities_location', - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php", + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php", $params); $params = ['action' => 'entities_fqdn', 'entities_id' => '__VALUE__', 'value' => $addressing->fields["fqdns_id"]]; Ajax::updateItemOnEvent("dropdown_entities_id" . $rand, 'entities_fqdn', - $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/addressing.php", + PLUGINADDRESSING_WEBDIR . "/ajax/addressing.php", $params); echo ""; @@ -250,12 +250,12 @@ function showReservationForm($ip, $id_addressing, $rand) { "; $types = PluginAddressingAddressing::dropdownItemtype(); Dropdown::showFromArray('type', $types, - ['on_change' => "nameIsThere(\"" . $CFG_GLPI['root_doc'] . "\");"]); + ['on_change' => "nameIsThere(\"" .PLUGINADDRESSING_WEBDIR . "\");"]); echo ""; echo ""; echo " " . __("Name") . " : "; - $option = ['onChange' => "nameIsThere(\"" . $CFG_GLPI['root_doc'] . "\");", 'id' => 'name_reserveip']; + $option = ['onChange' => "nameIsThere(\"" . PLUGINADDRESSING_WEBDIR . "\");", 'id' => 'name_reserveip']; echo Html::input('name_reserveip', $option); echo "
"; echo " "; diff --git a/index.php b/index.php new file mode 100644 index 0000000..f2c28fe --- /dev/null +++ b/index.php @@ -0,0 +1,28 @@ +. + -------------------------------------------------------------------------- + */ diff --git a/setup.php b/setup.php index 6ca5678..7444ed6 100644 --- a/setup.php +++ b/setup.php @@ -28,9 +28,11 @@ */ define('PLUGIN_ADDRESSING_VERSION', '3.0.0'); + if (!defined("PLUGIN_ADDRESSING_DIR")) { define("PLUGIN_ADDRESSING_DIR", Plugin::getPhpDir("addressing")); define("PLUGIN_ADDRESSING_DIR_NOFULL", Plugin::getPhpDir("addressing",false)); + define("PLUGINADDRESSING_WEBDIR", Plugin::getWebDir("addressing")); } // Init the hooks of the plugins -Needed @@ -65,7 +67,7 @@ function plugin_init_addressing() { if (isset($_SESSION['glpiactiveprofile']['interface']) && $_SESSION['glpiactiveprofile']['interface'] == 'central') { $PLUGIN_HOOKS['add_css']['addressing'] = "addressing.css"; - $PLUGIN_HOOKS["javascript"]['addressing'] = ["/plugins/addressing/addressing.js"]; + $PLUGIN_HOOKS["javascript"]['addressing'] = [PLUGIN_ADDRESSING_DIR_NOFULL."/addressing.js"]; $PLUGIN_HOOKS['add_javascript']['addressing'] = 'addressing.js'; } } diff --git a/tools/move_to_po.php b/tools/move_to_po.php deleted file mode 100644 index 6c93db0..0000000 --- a/tools/move_to_po.php +++ /dev/null @@ -1,313 +0,0 @@ -. - -------------------------------------------------------------------------- - */ - -// ---------------------------------------------------------------------- -// Original Author of file: Julien Dombre -// Purpose of file: -// ---------------------------------------------------------------------- - -chdir(dirname($_SERVER["SCRIPT_FILENAME"])); - -if ($argv) { - for ($i=1 ; $i'.$sing_trans.' '.$current_string_plural.'->'.$plural_trans."\n"; - if (!strlen($sing_trans) || !strlen($plural_trans)) { -// echo "clean\n"; - $sing_trans = ''; - $plural_trans = ''; - } - $content = "msgstr[0] \"$sing_trans\"\n"; - $content .= "msgstr[1] \"$plural_trans\"\n"; - } - } else { - $content=''; - } - } - $context = ''; - } - // Standard replacement - $content = preg_replace('/charset=CHARSET/','charset=UTF-8',$content); - - if (preg_match('/Plural-Forms/',$content)) { - $content = "\"Plural-Forms: nplurals=2; plural=(n != 1)\\n\"\n"; - } - - if (fwrite($po, $content) === FALSE) { - echo "unable to write in po file"; - exit; - } - - } -} -fclose($pot); -fclose($po); - - -/** - * @param $string - * @param $context - * - * @return string - */ -function search_in_dict($string, $context) { - global $REFLANG, $LANG; - - if ($context) { - $string = "$context/$string"; - } - - $ponctmatch = "([\.: \(\)]*)"; - $varmatch = "(%s)*"; - - if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U",$string,$reg)) { -// print_r($reg); - $left = $reg[1]; - $left .= $reg[2]; - $string = $reg[3]; - $right = $reg[4]; - if (isset($reg[5])) { - $right .= $reg[5]; - } - } - -// echo $left.' <- '.$string.' -> '.$right."\n"; - foreach ($REFLANG as $mod => $data) { - - foreach ($data as $key => $val) { - - if (!is_array($val)){ - if (!isset($LANG[$mod][$key])) { - continue; - } - - // Search same case with punc - if (strcmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - // Search same case with punc - if (strcasecmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - - // Search same case with left punc - if (strcmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - // Search same case with left punc - if (strcasecmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - - // Search same case with right punc - if (strcmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - // Search same case with right punc - if (strcasecmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - - // Search same case without punc - if (strcmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - // Search non case sensitive - if (strcasecmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - } else { - //toolbox::logdebug($val); - //toolbox::logdebug($key); - //toolbox::logdebug($mod); - foreach ($val as $k => $v) { - if (!isset($LANG[$mod][$key][$k])) { - continue; - } - - // Search same case with punc - if (strcmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - // Search same case with punc - if (strcasecmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - - // Search same case with left punc - if (strcmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - // Search same case with left punc - if (strcasecmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - - // Search same case with right punc - if (strcmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - // Search same case with right punc - if (strcasecmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - - // Search same case without punc - if (strcmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - // Search non case sensitive - if (strcasecmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - } - } - } - } - - return ""; -} -?> \ No newline at end of file