|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
Lib::loadClass('RouteBase');
|
|
Lib::loadClass('RouteBase');
|
|
|
|
|
+Lib::loadClass('UI');
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @requires config file config/.cnf--zasob_638-biuro.biall-net.pl.ini.php:
|
|
* @requires config file config/.cnf--zasob_638-biuro.biall-net.pl.ini.php:
|
|
@@ -15,15 +16,303 @@ pass="***"
|
|
|
*/
|
|
*/
|
|
|
class Route_BiallNet_SyncProjectFiles extends RouteBase {
|
|
class Route_BiallNet_SyncProjectFiles extends RouteBase {
|
|
|
|
|
|
|
|
|
|
+ public $sync_projekty_tmp_folder = '/Users/plabudda/sync-projekty-files-to-www';
|
|
|
|
|
+ public $toyaTvUrl = 'https://toya.net.pl/telewizja';
|
|
|
|
|
+
|
|
|
public function handleAuth() {
|
|
public function handleAuth() {
|
|
|
if (!User::logged()) {
|
|
if (!User::logged()) {
|
|
|
throw new HttpException('Unauthorized', 401);
|
|
throw new HttpException('Unauthorized', 401);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function updateProjectDescFromToya($idProject) {
|
|
|
|
|
+ if (!$idProject) return;
|
|
|
|
|
+ $project = DB::getPDO()->fetchFirst("
|
|
|
|
|
+ select p.ID
|
|
|
|
|
+ , p.P_ID
|
|
|
|
|
+ , p.M_DIST_TYPE
|
|
|
|
|
+ , p.M_DIST_DESC
|
|
|
|
|
+ , p.M_DIST_DESC_HTML
|
|
|
|
|
+ , p.TV_KARTA_DEVICE_SERIAL
|
|
|
|
|
+ from IN7_MK_BAZA_DYSTRYBUCJI p
|
|
|
|
|
+ where p.M_DIST_TYPE in ('TV__UMOWA ZAKUPU KANALU')
|
|
|
|
|
+ and p.A_STATUS in ('NORMAL','WAITING')
|
|
|
|
|
+ and p.ID = {$idProject}
|
|
|
|
|
+ ");
|
|
|
|
|
+ // DBG::nicePrint($project, '$project');
|
|
|
|
|
+ if (!$project) throw new Exception("Brak projektu '{$idProject}'");
|
|
|
|
|
+ if (empty($project['TV_KARTA_DEVICE_SERIAL'])) throw new Exception("Brak sid dla projektu '{$idProject}' (TV_KARTA_DEVICE_SERIAL)");
|
|
|
|
|
+ $sid = $project['TV_KARTA_DEVICE_SERIAL'];
|
|
|
|
|
+ $imgsToya = $this->fetchImagesFromToya();
|
|
|
|
|
+ // DBG::nicePrint($imgsToya[$sid], '$imgsToya['.$sid.']');
|
|
|
|
|
+ if (empty($imgsToya[$sid])) throw new Exception("Brak na stronie toya programu o takim sid '{$sid}'");
|
|
|
|
|
+ if (!empty($imgsToya[$sid]['desc'])) {
|
|
|
|
|
+ $affected = DBG::getPDO()->update('IN7_MK_BAZA_DYSTRYBUCJI', 'ID', $idProject, [
|
|
|
|
|
+ 'A_RECORD_UPDATE_DATE' => 'NOW()',
|
|
|
|
|
+ 'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
|
|
|
|
|
+ 'M_DIST_DESC_HTML' => $imgsToya[$sid]['desc'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if ($affected) DB::getPDO()->insert('IN7_MK_BAZA_DYSTRYBUCJI_HIST', [
|
|
|
|
|
+ 'A_RECORD_CREATE_DATE' => 'NOW()',
|
|
|
|
|
+ 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
|
|
|
+ 'A_RECORD_UPDATE_DATE' => 'NOW()',
|
|
|
|
|
+ 'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
|
|
|
|
|
+ 'M_DIST_DESC_HTML' => $imgsToya[$sid]['desc'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function updateProjectLogoFromToya($idProject) {
|
|
|
|
|
+ if (!$idProject) return;
|
|
|
|
|
+ $project = DB::getPDO()->fetchFirst("
|
|
|
|
|
+ select p.ID
|
|
|
|
|
+ , p.P_ID
|
|
|
|
|
+ , p.M_DIST_TYPE
|
|
|
|
|
+ , p.M_DIST_DESC
|
|
|
|
|
+ , p.M_DIST_DESC_HTML
|
|
|
|
|
+ , p.TV_KARTA_DEVICE_SERIAL
|
|
|
|
|
+ from IN7_MK_BAZA_DYSTRYBUCJI p
|
|
|
|
|
+ where p.M_DIST_TYPE in ('TV__UMOWA ZAKUPU KANALU')
|
|
|
|
|
+ and p.A_STATUS in ('NORMAL','WAITING')
|
|
|
|
|
+ and p.ID = {$idProject}
|
|
|
|
|
+ ");
|
|
|
|
|
+ // DBG::nicePrint($project, '$project');
|
|
|
|
|
+ if (!$project) throw new Exception("Brak projektu '{$idProject}'");
|
|
|
|
|
+ if (empty($project['TV_KARTA_DEVICE_SERIAL'])) throw new Exception("Brak sid dla projektu '{$idProject}' (TV_KARTA_DEVICE_SERIAL)");
|
|
|
|
|
+ $sid = $project['TV_KARTA_DEVICE_SERIAL'];
|
|
|
|
|
+ $imgsToya = $this->fetchImagesFromToya();
|
|
|
|
|
+ // DBG::nicePrint($imgsToya[$sid], '$imgsToya['.$sid.']');
|
|
|
|
|
+ if (!empty($imgsToya[$sid])) {
|
|
|
|
|
+ UI::alert('info', "Pobieram logo '{$imgsToya[$sid]['url']}' ...");
|
|
|
|
|
+ $curl_handle = curl_init();
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_URL, $imgsToya[$sid]['url']);
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
+ // curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
|
|
|
|
|
+ $logo = curl_exec($curl_handle);
|
|
|
|
|
+ curl_close($curl_handle);
|
|
|
|
|
+ $projectDir = $this->_findProjectDir($idProject);
|
|
|
|
|
+ if (!$projectDir) throw new Exception("Brak katalogu projektu!");
|
|
|
|
|
+ UI::alert('info', "Wgrywam logo '{$imgsToya[$sid]['url']}' do katalogu '{$projectDir}' ...");
|
|
|
|
|
+ $today = date('Y-m-d');
|
|
|
|
|
+ $title = preg_replace('/\W/', '_', $imgsToya[$sid]['title']);
|
|
|
|
|
+ $logoImg = "{$projectDir}/{$idProject}.ZDJECIE.{$title}.{$today}.1.jpg";
|
|
|
|
|
+ // if (file_exists($logoImg))
|
|
|
|
|
+ UI::alert('info', "Zapisuje logo jako '{$logoImg}' ...");
|
|
|
|
|
+ file_put_contents($this->_getProjectBasePath() . '/' . $logoImg, $logo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function logaTVAction() {
|
|
|
|
|
+ UI::gora();
|
|
|
|
|
+ UI::startContainer();
|
|
|
|
|
+ echo UI::h('a', [
|
|
|
|
|
+ 'href' => $this->getLink(),
|
|
|
|
|
+ 'class' => 'btn btn-md btn-default'
|
|
|
|
|
+ ], "wróć");
|
|
|
|
|
+ echo UI::h('div', [], [
|
|
|
|
|
+ UI::h('div', [], [
|
|
|
|
|
+ 'Loga pobierane są ze strony <a href="'.$this->toyaTvUrl.'">'.$this->toyaTvUrl.'</a> ',
|
|
|
|
|
+ UI::hButtonPost("Pobierz ponownie", [
|
|
|
|
|
+ 'class' => 'btn btn-xs btn-default',
|
|
|
|
|
+ 'data' => [
|
|
|
|
|
+ 'force' => '1'
|
|
|
|
|
+ ]
|
|
|
|
|
+ ])
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $updateLogoProjID = V::get('fetch_logo_from_toya', 0, $_POST, 'int');
|
|
|
|
|
+ if ($updateLogoProjID > 0) $this->updateProjectLogoFromToya($updateLogoProjID);
|
|
|
|
|
+ $updateDescProjID = V::get('fetch_desc_from_toya', 0, $_POST, 'int');
|
|
|
|
|
+ if ($updateDescProjID > 0) $this->updateProjectDescFromToya($updateDescProjID);
|
|
|
|
|
+
|
|
|
|
|
+ $projects = DB::getPDO()->fetchAll("
|
|
|
|
|
+ select p.ID
|
|
|
|
|
+ , p.P_ID
|
|
|
|
|
+ , p.M_DIST_TYPE
|
|
|
|
|
+ , p.M_DIST_DESC
|
|
|
|
|
+ , p.M_DIST_DESC_HTML
|
|
|
|
|
+ , p.TV_KARTA_DEVICE_SERIAL
|
|
|
|
|
+ from IN7_MK_BAZA_DYSTRYBUCJI p
|
|
|
|
|
+ where p.M_DIST_TYPE in ('TV__UMOWA ZAKUPU KANALU')
|
|
|
|
|
+ and p.A_STATUS in ('NORMAL','WAITING')
|
|
|
|
|
+ ");
|
|
|
|
|
+
|
|
|
|
|
+ $imgsToya = $this->fetchImagesFromToya($force = V::get('force', '', $_REQUEST));
|
|
|
|
|
+
|
|
|
|
|
+ UI::table([
|
|
|
|
|
+ 'cols_help' => [
|
|
|
|
|
+ 'sid' => "TV_KARTA_DEVICE_SERIAL",
|
|
|
|
|
+ 'type' => "M_DIST_TYPE",
|
|
|
|
|
+ 'desc' => "M_DIST_DESC",
|
|
|
|
|
+ 'html' => "M_DIST_DESC_HTML",
|
|
|
|
|
+ 'se' => "Logo wgrane do SE",
|
|
|
|
|
+ // 'www' => "Logo na stronie www.biall.net.pl",
|
|
|
|
|
+ 'toya' => "Logo na stronie toya.net.pl",
|
|
|
|
|
+ ],
|
|
|
|
|
+ 'rows' => array_map(function ($row) use ($imgsToya) {
|
|
|
|
|
+ $imgSE = '';
|
|
|
|
|
+ $imgWWW = '?';
|
|
|
|
|
+ $sid = (int)$row['TV_KARTA_DEVICE_SERIAL'];
|
|
|
|
|
+ $sid = ($sid > 0 && $sid < 1000) ? $sid : 0;
|
|
|
|
|
+ $imgTOYA = ($sid > 0)
|
|
|
|
|
+ ? UI::h('img', [
|
|
|
|
|
+ 'src' => "https://toya.net.pl/telewizja/kanaly/logo/sid/{$sid}"
|
|
|
|
|
+ ])
|
|
|
|
|
+ : 'brak sid!';
|
|
|
|
|
+
|
|
|
|
|
+ $filesToAdd = $this->_findProjectFiles($row['ID'], 'ZDJECIE', array('jpg','png','gif'));
|
|
|
|
|
+ // "name":"5641.ZDJECIE.TVPULS2.2016-09-26.1.jpg"
|
|
|
|
|
+ // "path":"\/Library\/Server\/Web\/Data\/Sites\/Default\/PLIKI\/PROJEKTY\/5641.sprawy_zwiazane_z_dy_\/5641.ZDJECIE.TVPULS2.2016-09-26.1.jpg"
|
|
|
|
|
+ // "www":""
|
|
|
|
|
+ $imgSE = implode(' ', array_map(function ($file) {
|
|
|
|
|
+ return UI::h('img', [
|
|
|
|
|
+ 'src' => $file['www']
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }, $filesToAdd));
|
|
|
|
|
+
|
|
|
|
|
+ $imgSE .= '<br>' . UI::hButtonPost("Pobierz z Toya", [
|
|
|
|
|
+ 'class' => 'btn btn-xs btn-link',
|
|
|
|
|
+ 'data' => [
|
|
|
|
|
+ 'fetch_logo_from_toya' => $row['ID'],
|
|
|
|
|
+ '_route' => 'BiallNet_SyncProjectFiles',
|
|
|
|
|
+ '_task' => 'logaTV',
|
|
|
|
|
+ ]
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $descHtml = UI::h('div', [], substr($row['M_DIST_DESC_HTML'], 0, 100) . '...');
|
|
|
|
|
+ if (!empty($imgsToya[$sid]['html'])) {
|
|
|
|
|
+ $descHtml .= '<br>' . UI::hButtonPost("Pobierz z Toya", [
|
|
|
|
|
+ 'class' => 'btn btn-xs btn-link',
|
|
|
|
|
+ 'title' => htmlspecialchars($imgsToya[$sid]['html']),
|
|
|
|
|
+ 'data' => [
|
|
|
|
|
+ 'fetch_desc_from_toya' => $row['ID'],
|
|
|
|
|
+ '_route' => 'BiallNet_SyncProjectFiles',
|
|
|
|
|
+ '_task' => 'logaTV',
|
|
|
|
|
+ ]
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [
|
|
|
|
|
+ 'ID' => UI::h('a', [
|
|
|
|
|
+ 'href' => Request::getPathUri() . 'index.php?_route=ViewTableAjax&namespace=default_db/IN7_MK_BAZA_DYSTRYBUCJI#FILES/' . $row['ID']
|
|
|
|
|
+ ], $row['ID']),
|
|
|
|
|
+ 'sid' => (!empty($row['TV_KARTA_DEVICE_SERIAL']) && !$sid)
|
|
|
|
|
+ ? "<span style=\"color:red\">błędny sid! ({$row['TV_KARTA_DEVICE_SERIAL']})</span>"
|
|
|
|
|
+ : $sid,
|
|
|
|
|
+ 'P_ID' => $row['P_ID'],
|
|
|
|
|
+ 'type' => $row['M_DIST_TYPE'],
|
|
|
|
|
+ 'desc' => $row['M_DIST_DESC'],
|
|
|
|
|
+ 'html' => $descHtml,
|
|
|
|
|
+ 'se' => $imgSE,
|
|
|
|
|
+ // 'www' => $imgWWW,
|
|
|
|
|
+ 'toya' => $imgTOYA,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }, $projects)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ UI::endContainer();
|
|
|
|
|
+ UI::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function fetchImagesFromToya($force = false) {
|
|
|
|
|
+ // $html = file_get_contents($this->toyaTvUrl);
|
|
|
|
|
+ if (!$force && file_exists('/tmp/toya-net-pl-telewizja.json')) {
|
|
|
|
|
+ $json = file_get_contents('/tmp/toya-net-pl-telewizja.json');
|
|
|
|
|
+ if ($json) {
|
|
|
|
|
+ $listLogoToya = @json_decode($json, $assoc = true);
|
|
|
|
|
+ if (!empty($listLogoToya)) return $listLogoToya;
|
|
|
|
|
+ }
|
|
|
|
|
+ UI::alert('warning', "cache error - toya.net.pl/telewizja");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $listLogoToya = [];
|
|
|
|
|
+
|
|
|
|
|
+ $curl_handle = curl_init();
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_URL, $this->toyaTvUrl);
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
|
|
|
|
|
+ curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
+ // curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
|
|
|
|
|
+ $html = curl_exec($curl_handle);
|
|
|
|
|
+ curl_close($curl_handle);
|
|
|
|
|
+ if (!$html) throw new Exception("błąd pobierania strony '{$this->toyaTvUrl}'");
|
|
|
|
|
+ $pos = strpos($html, '<div class="offer-more-channel">');
|
|
|
|
|
+ if (!$pos) throw new Exception("błąd parsowania strony '{$this->toyaTvUrl}'");
|
|
|
|
|
+ $html = substr($html, $pos);
|
|
|
|
|
+
|
|
|
|
|
+ $pos = strpos($html, '<!-- grafika i tekst -->');
|
|
|
|
|
+ if ($pos) $html = substr($html, 0, $pos);
|
|
|
|
|
+
|
|
|
|
|
+ // echo UI::h('pre', ['style'=>"max-height:400px"], htmlspecialchars($html));
|
|
|
|
|
+ for ($pos = strpos($html, '<div class="offer-more-channel">'); $pos !== false; ) {
|
|
|
|
|
+ $logoToya = [];
|
|
|
|
|
+ $nextPos = strpos($html, '<div class="offer-more-channel">', $pos + 1);
|
|
|
|
|
+ $offset = strlen('<div class="offer-more-channel">');
|
|
|
|
|
+ if (false !== $nextPos) {
|
|
|
|
|
+ $tag = trim(substr($html, $pos + $offset, $nextPos - $pos - $offset));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $tag = trim(substr($html, $pos + $offset));
|
|
|
|
|
+ }
|
|
|
|
|
+ preg_match_all('/<img src="(.*)" alt="(.*)"/', $tag, $matches, PREG_SET_ORDER);
|
|
|
|
|
+ // DBG::nicePrint($matches, '$matches');
|
|
|
|
|
+ if (!empty($matches[0]) && 3 == count($matches[0])) {
|
|
|
|
|
+ $url = 'https://toya.net.pl' . $matches[0][1];
|
|
|
|
|
+ $logoToya['url'] = $url;
|
|
|
|
|
+ $logoToya['serial_nr'] = substr($url, strrpos($url, '/') + 1);
|
|
|
|
|
+ $logoToya['title'] = $matches[0][2];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DBG::nicePrint($matches, 'TODO: logo/title $matches');
|
|
|
|
|
+ }
|
|
|
|
|
+ preg_match_all('/Na kanale: (\d*)\W*<\/p>/', $tag, $matches, PREG_SET_ORDER);
|
|
|
|
|
+ // DBG::nicePrint($matches, '$matches');
|
|
|
|
|
+ if (!empty($matches[0]) && 2 == count($matches[0])) {
|
|
|
|
|
+ $logoToya['nr'] = $matches[0][1];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DBG::nicePrint($matches, 'TODO: "Na kanale .*" $matches');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ $pDesc = strpos($tag, '<div class="channel-tooltip-content">');
|
|
|
|
|
+ if ($pDesc) {
|
|
|
|
|
+ $pDesc = strpos($tag, '<p>', $pDesc);
|
|
|
|
|
+ if ($pDesc) {
|
|
|
|
|
+ $pEndDesc = strpos($tag, '</p>', $pDesc);
|
|
|
|
|
+ if ($pEndDesc) {
|
|
|
|
|
+ $desc = trim(substr($tag, $pDesc + strlen('<p>'), $pEndDesc - $pDesc));
|
|
|
|
|
+ if ('Na kanale' != substr($desc, 0, strlen('Na kanale'))) {
|
|
|
|
|
+ $logoToya['desc'] = $desc;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($logoToya['desc'])) {
|
|
|
|
|
+ $desc = '';
|
|
|
|
|
+ preg_match_all('/<\/span>\n(.*)\W*<p>\W*Na kanale: /', $tag, $matches, PREG_SET_ORDER);
|
|
|
|
|
+ if (!empty($matches[0]) && 2 == count($matches[0])) {
|
|
|
|
|
+ $desc = trim($matches[0][1]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DBG::nicePrint($matches, 'TODO: "Na kanale .*" $matches');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($desc) {
|
|
|
|
|
+ $logoToya['desc'] = $desc;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DBG::nicePrint(htmlspecialchars($tag), 'TODO: Brak opisu?');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // echo UI::h('pre', [], htmlspecialchars($tag));
|
|
|
|
|
+ if ($logoToya['serial_nr']) $listLogoToya[ $logoToya['serial_nr'] ] = $logoToya;
|
|
|
|
|
+ if (false === $nextPos || $pos > 100000000) break;
|
|
|
|
|
+ $pos = $nextPos;
|
|
|
|
|
+ }
|
|
|
|
|
+ // DBG::nicePrint($listLogoToya, '$listLogoToya');
|
|
|
|
|
+ file_put_contents('/tmp/toya-net-pl-telewizja.json', json_encode($listLogoToya));
|
|
|
|
|
+ return $listLogoToya;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function defaultAction() {
|
|
public function defaultAction() {
|
|
|
- SE_Layout::gora();
|
|
|
|
|
- SE_Layout::menu();
|
|
|
|
|
|
|
+ UI::gora();
|
|
|
|
|
+ UI::menu();
|
|
|
|
|
|
|
|
$configError = null;
|
|
$configError = null;
|
|
|
try {
|
|
try {
|
|
@@ -31,51 +320,36 @@ class Route_BiallNet_SyncProjectFiles extends RouteBase {
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
$configError = $e->getMessage();
|
|
$configError = $e->getMessage();
|
|
|
}
|
|
}
|
|
|
-?>
|
|
|
|
|
-<div class="container">
|
|
|
|
|
- <h1></h1>
|
|
|
|
|
-</div>
|
|
|
|
|
-<div class="jumbotron">
|
|
|
|
|
- <div class="container">
|
|
|
|
|
- <h3>Synchronizcja plików na stronę www.biall.net.pl z projektów</h3>
|
|
|
|
|
- <?php if (empty($configError)) : ?>
|
|
|
|
|
- <form class="form-inline" method="POST">
|
|
|
|
|
- <input type="hidden" name="_task" value="syncToWwwSite" />
|
|
|
|
|
- <button type="submit" id="submitBtn" class="btn btn-primary" autocomplete="off">
|
|
|
|
|
- Synchronizuj wszystkie projekty
|
|
|
|
|
- </button>
|
|
|
|
|
- </form>
|
|
|
|
|
- <!-- TODO: fast sync only one project? -->
|
|
|
|
|
- <!-- TODO: filter by project type?: 'WWW_PRACA', 'WWW_DOKUMENTY', 'WWW_AKTUALNOSCI', 'WWW_AKTUALNOSCI_TV', 'TV__UMOWA ZAKUPU KANALU'
|
|
|
|
|
- -->
|
|
|
|
|
- <!-- TODO: test - dont send and delete files, just show what to do -->
|
|
|
|
|
- <?php else : ?>
|
|
|
|
|
- <div class="alert alert-danger">
|
|
|
|
|
- <?php echo $configError; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
-</div>
|
|
|
|
|
-<script type="text/javascript">
|
|
|
|
|
-jQuery(document).ready(function () {
|
|
|
|
|
- jQuery('#submitBtn').on('click', function () {
|
|
|
|
|
- jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
|
|
- jQuery(this).parent().submit();
|
|
|
|
|
- });
|
|
|
|
|
-});
|
|
|
|
|
-</script>
|
|
|
|
|
- <?php
|
|
|
|
|
- SE_Layout::dol();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ UI::startTag('div', ['class'=>"jumbotron"]);
|
|
|
|
|
+ UI::startContainer(['style' => "text-align:center"]);
|
|
|
|
|
+ echo UI::h('h3', [], "Synchronizcja plików na stronę www.biall.net.pl z projektów");
|
|
|
|
|
+ if (!empty($configError)) {
|
|
|
|
|
+ UI::alert('danger', $configError);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ echo UI::h('a', [
|
|
|
|
|
+ 'href' => $this->getLink('syncToWwwSite'),
|
|
|
|
|
+ 'class' => 'btn btn-md btn-primary'
|
|
|
|
|
+ ], "Synchronizuj wszystkie projekty");
|
|
|
|
|
+ }
|
|
|
|
|
+ echo ' ';
|
|
|
|
|
+ echo UI::h('a', [
|
|
|
|
|
+ 'href' => $this->getLink('logaTV'),
|
|
|
|
|
+ 'class' => 'btn btn-md btn-primary'
|
|
|
|
|
+ ], "Synchronizuj loga TV ze strony toya.net.pl");
|
|
|
|
|
+ UI::endContainer();
|
|
|
|
|
+ UI::endTag('div');// .jumbotron
|
|
|
|
|
+ UI::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function syncToWwwSiteAction() {
|
|
public function syncToWwwSiteAction() {
|
|
|
- SE_Layout::gora();
|
|
|
|
|
- SE_Layout::menu();
|
|
|
|
|
- ?>
|
|
|
|
|
-<h1>Synchronizcja plików na stronę www.biall.net.pl z projektów:</h1>
|
|
|
|
|
-<pre style="max-height:400px;border:1px solid silver;overflow:auto;"><?php $this->syncToWwwSite(); ?></pre>
|
|
|
|
|
-<?php
|
|
|
|
|
- SE_Layout::dol();
|
|
|
|
|
|
|
+ UI::gora();
|
|
|
|
|
+ UI::menu();
|
|
|
|
|
+ echo UI::h('h1', [], "Synchronizcja plików na stronę www.biall.net.pl z projektów:");
|
|
|
|
|
+ UI::startTag('pre', ['style'=>"max-height:400px;border:1px solid silver;overflow:auto"]);
|
|
|
|
|
+ $this->syncToWwwSite();
|
|
|
|
|
+ UI::endTag('pre');
|
|
|
|
|
+ UI::dol();
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -200,13 +474,28 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function _findProjectFiles($project_id, $type = '', $suffix = 'pdf') {
|
|
|
|
|
|
|
+ private function _getProjectBasePath() {
|
|
|
global $FOLDERS;
|
|
global $FOLDERS;
|
|
|
|
|
+ return $FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN'];
|
|
|
|
|
+ }
|
|
|
|
|
+ private function _findProjectDir($project_id) {
|
|
|
|
|
+ $dir_projekty = $this->_getProjectBasePath();
|
|
|
|
|
+ //$www_projekty = "PROJEKTY/";
|
|
|
|
|
|
|
|
|
|
+ $pattern = $dir_projekty.'/'.$project_id.'.*';
|
|
|
|
|
+ $path_projekt = glob($pattern , GLOB_ONLYDIR);// array glob(pattern [, flags])
|
|
|
|
|
+ if (empty($path_projekt)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ $path_projekt = reset($path_projekt);
|
|
|
|
|
+ $dir_projekt = explode('/', $path_projekt);
|
|
|
|
|
+ $dir_projekt = end($dir_projekt);
|
|
|
|
|
+ return $dir_projekt;
|
|
|
|
|
+ }
|
|
|
|
|
+ private function _findProjectFiles($project_id, $type = '', $suffix = 'pdf') {
|
|
|
$ret = array();
|
|
$ret = array();
|
|
|
- //global $FOLDERS;
|
|
|
|
|
// @see .config:$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN]="/home/samba/PROJEKTY";
|
|
// @see .config:$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN]="/home/samba/PROJEKTY";
|
|
|
- $dir_projekty = $FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN'];
|
|
|
|
|
|
|
+ $dir_projekty = $this->_getProjectBasePath();
|
|
|
//$www_projekty = "PROJEKTY/";
|
|
//$www_projekty = "PROJEKTY/";
|
|
|
|
|
|
|
|
$pattern = $dir_projekty.'/'.$project_id.'.*';
|
|
$pattern = $dir_projekty.'/'.$project_id.'.*';
|
|
@@ -243,8 +532,12 @@ jQuery(document).ready(function () {
|
|
|
// TODO: f_www link do akryptu zmieniajacego nazwe pliku na nazwe projektu
|
|
// TODO: f_www link do akryptu zmieniajacego nazwe pliku na nazwe projektu
|
|
|
//$f_www = 'http://'.$host.'/'.$www_projekty.'/'.$dir_projekt.'/'.$f_name;
|
|
//$f_www = 'http://'.$host.'/'.$www_projekty.'/'.$dir_projekt.'/'.$f_name;
|
|
|
//$f_www = 'http://'.$host.'/index.php?action=project_file&project='.$project_id.'&f='.$f_name;
|
|
//$f_www = 'http://'.$host.'/index.php?action=project_file&project='.$project_id.'&f='.$f_name;
|
|
|
- $f_www = '';
|
|
|
|
|
- $ret[] = array('name'=>$f_name, 'path'=>$v, 'www'=>$f_www);
|
|
|
|
|
|
|
+ $f_www = str_replace($dir_projekty, 'https://biuro.biall-net.pl/PLIKI/PROJEKTY/', $v);
|
|
|
|
|
+ $ret[] = [
|
|
|
|
|
+ 'name' => $f_name,
|
|
|
|
|
+ 'path' => $v,
|
|
|
|
|
+ 'www' => $f_www
|
|
|
|
|
+ ];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
return $ret;
|