From: vincent@cubedesigners.com Date: Wed, 12 Feb 2020 18:09:49 +0000 (+0000) Subject: done #3411 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e8a512c1a69c84ef6f43717f9f2dde38279cc341;p=cubeextranet.git done #3411 @1 --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 0c28941aa..7f048ea7b 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1525,6 +1525,239 @@ class commonTools exit; } + public static function ipGlobal($error = "") + { + global $core; + + commonDroits::min(1); + + if (is_array($error)) { + $errorMessage = ''; + } else { + $errorMessage = $error; + } + + $res = commonPage::barre(); + $res .= commonPage::tMain(); + $res .= commonPage::bh(); + $res .= '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Générer une bibliothèque IPGlobal') . '
Veuillez charger les données de la bibliothèque (Un fichier zip contenant le fichier data.xml et les images) | Télécharger un modèle | le dernier chargé
' . $errorMessage . '
' . $core->typo->BoutonOK(__('Genérer la bibliothèque')) . '
'; + $res .= '
'; + $res .= ''; + $res .= commonPage::bf(); + $res .= commonPage::bMain(); + return $res; + } + + public static function buildIpGlobal() + { + + commonDroits::min(1); + if (!count($_FILES) || !isset($_FILES['file']) || $_FILES['file']['error'] > 0) { + return self::ipGlobal(__('Erreur lors du chargement du fichier')); + } + $valid = isset($_POST['valid']) && $_POST['valid'] === 'ok'; + + copy($_FILES['file']['tmp_name'], ROOT . '/ipglobal/ipglobal-latest.zip'); + + // Update git repository + $repos = ROOT . '/../ipglobal-library/'; + + `cd $repos;git reset --hard;git pull`; + + // Handle zip upload + $uploaded = new ZipArchive(); + $uploaded->open($_FILES['file']['tmp_name']); + $data = simplexml_load_string(str_replace('&', '&', $uploaded->getFromName('data.xml'))); + if (!$data) { + return self::ipGlobal(__('Erreur lors de l\'analyse du fichier XML')); + } + + // Generate the html + $html = ''; + foreach ($data->xpath('/ipglobal/library') as $library) { + $id = (string)$library->id; + $title = (string)$library->title; + $html .= '
'; + $html .= '
'; + if ($title !== '') { + $html .= '

' . $title . '

'; + } + + foreach ($library->shelf as $shelf) { + $html .= '
'; + $id = (string)$shelf->id; + $title = (string)$shelf->title; + if ($title !== '') { + $html .= '

' . $title . '

'; + } + $image = (string)$shelf->image; + $imagecontent = $uploaded->getFromName($image); + if ($imagecontent) { + file_put_contents($repos . '/images/' . $image, $imagecontent); + } + $html .= '' . $title . ''; + $html .= '' . $shelf->map->asXML() . ''; + $html .= '
'; + } + $html .= '
'; + $html .= '
'; + } + // Replace the html in the source + file_put_contents($repos . '/index.html', str_replace('', $html, file_get_contents($repos . '/index.html'))); + + // Copy files to the server + if ($valid) { + $dir = 'library'; + } else { + $dir = 'library_' . date('Ymd'); + } + $dest = '/mnt/sshfs/fluidbook/data/fluidbook/hosting/ipglobal/' . $dir; + if ($valid) { + // IF valid checkbox, we make a backup + $old = $dest . '_old_' . date('Ymd'); + `mv $dest $old`; + } else { + // We just remove the dest + if (file_exists($dest)) { + `rm -rf $dest`; + } + } + // Create the dest dir + mkdir($dest, 0777, true); + $papath = implode(PATH_SEPARATOR, array('/usr/bin', getenv('PATH'))); + putenv($papath); + // Run the command to build the library + $cmd = "export PATH=$papath;echo \$PATH;cd $repos;yarn install 2>&1;yarn alien 2>&1;cp -r ./dist/* $dest/ 2>&1"; + $output = shell_exec($cmd); + // Display error if no index.html + if (!file_exists($dest . '/index.html')) { + echo $cmd . ':' . $output; + exit; + } + // Redirect to the library + header('Location: https://hosting.fluidbook.com/ipglobal/' . $dir . '/'); + + /* + *
+
+

Project Brochures

+
+

UK Projects

+ + + + UK projects + + Bishton Fletcher Building (EN) + Bishton Fletcher Building (CN) + Crossbank (CN) + Crossbank (EN) + Kent Street Residence (CN) + Kent Street Residence (EN) + Lucent Square Leeds (CN) + Lucent Square Leeds (EN) + Wellington Quarter London + The Loom + Centenary House + The Curve II + The Curve (EN) + The Curve (CN) + River Wandle + Horizon + No.1 Trafford Wharf (EN) + No.1 Trafford Wharf (CN) + Quay Central (EN) + Quay Central (CN) + The Cartwright (EN) + The Cartwright (CN) + + +
+
+

Portuguese Projects

+ + + Alvaro Porto (CN) + Alvaro Porto (EN) + The Carvalho Lisbon + Bela Vista Lisbon (EN) + Bela Vista Lisbon (CN) + +
+
+

Irish Projects

+ + + William Beckett House (EN) + William Beckett House (CN) + +
+
+

German Projects

+ + + Ruststrasse 4 Leipzig + Köda Berlin + The Galleries + River Gardens Berlin + Konstanzer Berlin (EN) + Konstanzer Berlin (CN) + Gartenhaus Berlin (EN) + Gartenhaus Berlin (CN) + Eden West Berlin (EN) + Eden West Berlin (CN) + Einbecker 47 Berlin (EN) + Einbecker 47 Berlin (CN) + Beautique Apartments Berlin (EN) + Beautique Apartments Berlin (CN) + +
+
+
+ +
+
+

Investor Guide Series

+ + + Global Real Estate Outlook 2020 (CN) + Global Real Estate Outlook 2020 (EN) + Portugal (CN) + Portugal (EN) + Global investor sentiment survey 2018 + England & Wales (CN) + England & Wales (EN) + Chicago + Crossrail Update (CN) + Crossrail Update (EN) + Crossrail + Berlin + +
+
+ */ + } + } diff --git a/ipglobal/ipglobal-template.zip b/ipglobal/ipglobal-template.zip new file mode 100644 index 000000000..e1277fc6f Binary files /dev/null and b/ipglobal/ipglobal-template.zip differ