<?php
/* Copyright (C) 2020       MB Informatique         <info@mb-informatique.fr>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/**
 * \file    mbisignature/lib/mbisignature.lib.php
 * \ingroup mbisignature
 * \brief   Library files with common functions for MBISignature
 */

/**
 * Prepare admin pages header
 *
 * @return array
 */
function mbisignatureAdminPrepareHead()
{
	global $langs, $conf;

    $langs->loadLangs(array("mbisignature@mbisignature"));

	$h = 0;
	$head = array();

	$head[$h][0] = dol_buildpath("/mbisignature/admin/setup.php", 1);
	$head[$h][1] = $langs->trans("Settings");
	$head[$h][2] = 'settings';
	$h++;
    $head[$h][0] = dol_buildpath("/mbisignature/admin/mail_templates.php", 1);
    $head[$h][1] = $langs->trans("EMailTemplates");
    $head[$h][2] = 'mail_templates';
    $h++;
    $head[$h][0] = dol_buildpath("/mbisignature/admin/customization.php", 1);
    $head[$h][1] = $langs->trans("GUISetup");
    $head[$h][2] = 'customization';
    $h++;
	$head[$h][0] = dol_buildpath("/mbisignature/admin/about.php", 1);
	$head[$h][1] = $langs->trans("About");
	$head[$h][2] = 'about';
	$h++;

	complete_head_from_modules($conf, $langs, null, $head, $h, 'mbisignature');

	return $head;
}

function getLineWithString($fileName, $str) {
    $lines = file($fileName);
    $line_array = ['nb' => '', 'content' => ''];
    foreach ($lines as $lineNumber => $line) {
        if (strpos($line, $str) !== false) {
            $line_array['nb'] = $lineNumber;
            $line_array['content'] = $line;
            return $line_array;
        }
    }
    return -1;
}