|
@@ -160,14 +160,37 @@ class Pages extends Controller
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function Templates($f3, $args)
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * General Commands controller
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param $f3
|
|
|
|
|
+ */
|
|
|
|
|
+ public function Commands($f3)
|
|
|
{
|
|
{
|
|
|
- global $frameworkUtils;
|
|
|
|
|
|
|
+ $bodyPostData = $f3->get('BODY');
|
|
|
|
|
+ if (strlen($bodyPostData) == 0) {
|
|
|
|
|
+ echo json_encode([
|
|
|
|
|
+ "err" => "Empty body command"
|
|
|
|
|
+ ]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $Command = json_decode($bodyPostData);
|
|
|
|
|
+ switch ($Command->method) {
|
|
|
|
|
+ case 'TemplateSelector':
|
|
|
|
|
+ $this->TemplateSelector($f3, $Command);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function TemplateSelector($f3, $Command)
|
|
|
|
|
+ {
|
|
|
|
|
+ global $f3, $frameworkUtils;
|
|
|
|
|
|
|
|
$fb_template = $this->findBoxCore->CallAPI('/1.0.0/index.php/smartesl.gettemplates/1.0.0/', '[]');
|
|
$fb_template = $this->findBoxCore->CallAPI('/1.0.0/index.php/smartesl.gettemplates/1.0.0/', '[]');
|
|
|
$templates = $this->findBoxCore->getLabelsFromResponse($fb_template);
|
|
$templates = $this->findBoxCore->getLabelsFromResponse($fb_template);
|
|
|
|
|
|
|
|
- if ($args['clearcache'] == 1)
|
|
|
|
|
|
|
+ if ($Command->clearCache == 1)
|
|
|
$frameworkUtils->rrmdir("fbtpl");
|
|
$frameworkUtils->rrmdir("fbtpl");
|
|
|
|
|
|
|
|
$tplFileNames = [];
|
|
$tplFileNames = [];
|
|
@@ -175,17 +198,23 @@ class Pages extends Controller
|
|
|
foreach($templates as $item) {
|
|
foreach($templates as $item) {
|
|
|
|
|
|
|
|
$DTs = explode(',', $item['labeltypes']);
|
|
$DTs = explode(',', $item['labeltypes']);
|
|
|
- if (($args['dt'] != 0) && !in_array($args['dt'], $DTs))
|
|
|
|
|
|
|
+ if (($Command->dt != 0) && !in_array($Command->dt, $DTs))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
if (!file_exists("fbtpl/{$item['template_id']}.svg"))
|
|
if (!file_exists("fbtpl/{$item['template_id']}.svg"))
|
|
|
$this->findBoxCore->GetTemplateImage($item['template_id']);
|
|
$this->findBoxCore->GetTemplateImage($item['template_id']);
|
|
|
|
|
|
|
|
- $tplFileNames[$item['template_id']] = file_get_contents("fbtpl/{$item['template_id']}.svg");
|
|
|
|
|
|
|
+ $tplFileNames["[{$item['template_id']}] {$item['name']}"] = file_get_contents("fbtpl/{$item['template_id']}.svg");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $f3->set('TPLPATH', $tplFileNames);
|
|
|
|
|
- echo Template::instance()->render('templates.tpl');
|
|
|
|
|
|
|
+ $f3->set('TPLOBJ', $tplFileNames);
|
|
|
|
|
+ $tpl = Template::instance()->render('templates.tpl');
|
|
|
|
|
+
|
|
|
|
|
+ echo json_encode([
|
|
|
|
|
+ "err" => 0,
|
|
|
|
|
+ "value" => $tpl
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|