TCEMainHook.php 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484
  1. <?php
  2. namespace Meramo\mrm_be\Hooks\TCE;
  3. use DOMDocument;
  4. use \TYPO3\CMS\Core\Utility\GeneralUtility;
  5. use \TYPO3\CMS\Core\Database\ConnectionPool;
  6. use \TYPO3\CMS\Core\Database\Connection;
  7. use \TYPO3\CMS\Core\Service\FlexFormService;
  8. use \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
  9. use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
  10. use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
  11. use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
  12. use \Meramo\mrm_be\Mongoer as Mongoer;
  13. require_once GeneralUtility::getFileAbsFileName('typo3conf/ext/mrm_be/Resources/Private/PHP/phpqrcode/qrlib.php');
  14. class TCEMainHook
  15. {
  16. protected $imageSizes = array(
  17. 'mrm_be_cm_publication' => array(
  18. 'passthru' => array(
  19. 'small' => array('width' => 256),
  20. 'big' => array('width' => 512)
  21. )
  22. ),
  23. 'mrm_be_cm_homeheaderinfo' => array(
  24. 'i_1_1' => array(
  25. 'i_1_1' => array('width' => 140, 'height' => 140),
  26. ),
  27. 'i_16_9' => array(
  28. 'i_16_9' => array('width' => 140, 'height' => 79),
  29. ),
  30. 'default' => array(
  31. 'default' => array('width' => 140, 'height' => 94),
  32. )
  33. ),
  34. 'mrm_be_cm_explorerbox' => array(
  35. 'i_1_1' => array(
  36. 'img' => array('width' => 500, 'height' => 500),
  37. )
  38. ),
  39. 'mrm_be_cm_statementbox' => array(
  40. 'i_1_1' => array(
  41. 'img' => array('width' => 160, 'height' => 160),
  42. )
  43. ),
  44. 'mrm_be_cm_checklist-radiorange' => array(
  45. 'i_1_1' => array(
  46. 'img' => array('width' => 160, 'height' => 160),
  47. )
  48. ),
  49. 'mrm_be_cm_tileoverview' => array(
  50. 'default' => array(
  51. 'default_hero_lte600' => array('width' => 560, 'height' => 373),
  52. )
  53. ),
  54. 'mrm_be_cm_heroimage' => array(
  55. 'default' => array(
  56. 'lte600' => array('width' => 560, 'height' => 373),
  57. 'gt600' => array('width' => 408, 'height' => 272)
  58. ),
  59. ),
  60. 'mrm_be_cm_imageplus' => array(
  61. 'default' => array(
  62. 'ratio32' => array('width' => 439, 'height' => 293)
  63. ),
  64. 'i_16_9' => array(
  65. 'ratio169' => array('width' => 727, 'height' => 409)
  66. ),
  67. 'i_21_9' => array(
  68. 'ratio219' => array('width' => 984, 'height' => 422)
  69. )
  70. ),
  71. 'mrm_be_cm_contentimage' => array(
  72. 'i_1_1' => array(
  73. 'content_image' => array('width' => 160, 'height' => 160),
  74. 'content_image_maximized_lte600' => array('width' => 560, 'height' => 560),
  75. 'content_image_maximized_gt600' => array('width' => 460, 'height' => 460),
  76. ),
  77. ),
  78. 'mrm_be_cm_rawimage' => array('passthru' => true),
  79. 'mrm_be_cm_animation' => array('passthru' => true),
  80. 'mrm_be_cm_picturechoice' => array(
  81. 'i_1_1' => array(
  82. 'pic' => array('width' => 300, 'height' => 300)
  83. )
  84. ),
  85. 'overview_image' => array(
  86. 'default' => array(
  87. 'home_topics_lte767' => array('width' => 725, 'height' => 484),
  88. 'home_topics_gt767' => array('width' => 313, 'height' => 209),
  89. 'sidebar_banner_lte840' => array('width' => 100, 'height' => 66),
  90. 'rubrik_overview' => array('width' => 318, 'height' => 212),
  91. 'default_hero_lte600' => array('width' => 560, 'height' => 373),
  92. 'default_hero_gt600' => array('width' => 408, 'height' => 272, 'allowed_doktypes' => ['102']),
  93. ),
  94. 'i_1_1' => array(
  95. 'home_rubrik' => array('width' => 95, 'height' => 95),
  96. 'archive_block' => array('width' => 160, 'height' => 160),
  97. 'square_big' => array('width' => 520, 'height' => 520),
  98. ),
  99. 'i_16_9' => array(
  100. 'og' => array('width' => 1200, 'height' => 675),
  101. 'sidebar_banner_gt840' => array('width' => 282, 'height' => 159),
  102. ),
  103. 'i_21_9' => array(
  104. 'flat_tile' => array('width' => 400, 'height' => 171),
  105. 'flat_big' => array('width' => 700, 'height' => 300),
  106. ),
  107. )
  108. );
  109. private $imageService;
  110. private $resourceFactory;
  111. private $fileRepository;
  112. private $environmentService;
  113. private $queryBuilder;
  114. private $pageQueryBuilder;
  115. private $pageRepository;
  116. private $linkService;
  117. private $connection;
  118. function __construct()
  119. {
  120. $this->environmentService = GeneralUtility::makeInstance("TYPO3\CMS\Extbase\Service\EnvironmentService");
  121. $this->resourceFactory = GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\ResourceFactory');
  122. $this->imageService = GeneralUtility::makeInstance("TYPO3\CMS\Extbase\Service\ImageService");
  123. $this->fileRepository = GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\FileRepository');
  124. $this->pageRepository = GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Page\PageRepository');
  125. $this->linkService = GeneralUtility::makeInstance('TYPO3\CMS\Core\LinkHandling\LinkService');
  126. $connection = GeneralUtility::makeInstance(ConnectionPool::class);
  127. $this->connection = $connection;
  128. $this->queryBuilder = $connection->getQueryBuilderForTable('tt_content');
  129. $this->queryBuilder->getRestrictions()->removeAll()
  130. ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
  131. ->add(GeneralUtility::makeInstance(HiddenRestriction::class));
  132. $this->pageQueryBuilder = $connection->getQueryBuilderForTable('pages');
  133. $this->pageQueryBuilder->getRestrictions()->removeAll();
  134. }
  135. public function processDatamap_beforeStart($pObj)
  136. {
  137. if (!isset($pObj->datamap['pages'])) return;
  138. foreach ($pObj->datamap['pages'] as $pid => &$_d) {
  139. if (!$pid || $pid < 0) continue;
  140. $starttime = $_d["starttime"];
  141. if ($starttime != 0)
  142. $_d["starttime"] = $this->startOfDay($starttime, null, true, true);
  143. $endtime = $_d["endtime"];
  144. if ($endtime != 0)
  145. $_d["endtime"] = $this->endOfDay($endtime, null, true, true);
  146. switch ($_d["red_status"]) {
  147. case "-1": //neu angelegt
  148. case "1": //in Bearbeitung
  149. case "2": //vorbereitet
  150. case "3": //geprüft
  151. case "21": //gesperrt
  152. case "22": //archiviert
  153. $_d["hidden"] = 1;
  154. break;
  155. case "11": //frei
  156. case "12": //online
  157. $_d["hidden"] = 0;
  158. break;
  159. default:
  160. break;
  161. }
  162. }
  163. }
  164. public function processCmdmap_afterFinish(\TYPO3\CMS\Core\DataHandling\DataHandler &$pObj)
  165. {
  166. if (!isset($pObj->datamap['pages'])) return;
  167. foreach ($pObj->datamap['pages'] as $pid => $_d) {
  168. if (!$pid || $pid < 0) continue;
  169. $this->log('processing PID: ' . $pid);
  170. $pageStatement = $this->pageQueryBuilder
  171. ->select('*')
  172. ->from('pages')
  173. ->setMaxResults(1)
  174. ->where(
  175. $this->pageQueryBuilder->expr()->eq('uid', $this->pageQueryBuilder->createNamedParameter($pid))
  176. )
  177. ->execute();
  178. $post = $pageStatement->fetchAll();
  179. $post = $post[0];
  180. if (!$post) continue;
  181. if ($post['doktype'] == 254) {
  182. $this->processFolderContent($post);
  183. continue;
  184. }
  185. if ($post['hidden'] == 1 || $post['deleted'] == 1) {
  186. Mongoer::sendRequest("pages", "delete", array("pageuid" => $pid));
  187. Mongoer::sendRequest("abialtcache", "delete", array("pageuid" => $pid));
  188. Mongoer::sendRequest("search", "delete", array("pageuid" => $pid));
  189. Mongoer::sendRequest("security", "delete", array("pageuid" => $pid));
  190. // DELETE existing page PDF
  191. $this->deletePagePDFIfExists($post['slug']);
  192. //continue;
  193. }
  194. $rootlineutil = GeneralUtility::makeInstance('TYPO3\CMS\Core\Utility\RootlineUtility', $pid);
  195. $rootline = array_reverse($rootlineutil->get($pid));
  196. $processedImages = array();
  197. $slugData = $this->constructSlug($pid);
  198. if (!$slugData) {
  199. $this->log($pid . " slugData empty");
  200. continue;
  201. }
  202. $qrfilename = '/var/www/html/public/typo3temp/' . mt_rand(0, 0xffffff) . '_' . mt_rand(0, 0xffffff) . '.svg';
  203. \QRcode::svg("https://abi.de" . $slugData, $qrfilename);
  204. $qrsvg = file_get_contents($qrfilename);
  205. unlink($qrfilename);
  206. $statement = $this->queryBuilder
  207. ->select('*')
  208. ->from('tt_content')
  209. ->where(
  210. $this->queryBuilder->expr()->eq('pid', $this->queryBuilder->createNamedParameter($pid))
  211. )
  212. ->execute();
  213. $fetchedTTContent = array();
  214. $pageType = "article";
  215. //$this->log($post["doktype"]);
  216. if ($post["doktype"] == 100) $pageType = "event-page";
  217. if ($post["doktype"] == 101) $pageType = "blog-page";
  218. if ($post["doktype"] == 102) $pageType = "blogger-page";
  219. if ($post["doktype"] == 103) $pageType = "archive";
  220. if ($post["doktype"] == 104) $pageType = "video-page";
  221. if ($post['is_siteroot'] == 1) $pageType = "home";
  222. // $overview_image = null;
  223. while ($row = $statement->fetch()) {
  224. $fetchedTTContent[] = $row;
  225. $row["doktype"] = $post["doktype"];
  226. }
  227. /* look for overview_image start */
  228. if ($pageType == "blogger-page" || $pageType == "video-page") {
  229. $overview_image = $this->processImagesTTContent($post, 'overview_image', 'pages', 'overview_image');
  230. $overview_image = $overview_image[0] ? $overview_image[0] : null;
  231. }
  232. if (!$overview_image) {
  233. $x = $this->findFirstAppearingElementByType("mrm_be_cm_postimage", $fetchedTTContent, "CType");
  234. if ($x) {
  235. $overview_image = $this->processImagesTTContent($x, 'overview_image');
  236. $overview_image = $overview_image[0] ? $overview_image[0] : null;
  237. }
  238. }
  239. if (!$overview_image) {
  240. foreach ($fetchedTTContent as $row) {
  241. if (!$overview_image && ($row['CType'] == "mrm_be_cm_heroimage" || $row['CType'] == "mrm_be_cm_contentimage" || $row['CType'] == "mrm_be_cm_rawimage")) {
  242. $overview_image = $this->processImagesTTContent($row, 'overview_image');
  243. $overview_image = $overview_image[0] ? $overview_image[0] : null;
  244. }
  245. }
  246. }
  247. /* look for overview_image end */
  248. if ($pageType != "home") {
  249. $initialContent = $this->createContentElement($pageType, array(), (object) array(), array());
  250. $initialH1Attribs = array();
  251. if ($post["roof"] && $post["roof"] != '') $initialH1Attribs["roof"] = $post["roof"];
  252. if ($post["title"] && $post["title"] != '') $initialH1Attribs["text"] = $post["title"];
  253. if (sizeof($initialH1Attribs) > 0) $initialContent["subElements"][] = $this->createContentElement("h1", array(), $initialH1Attribs);
  254. }
  255. $processedData = array(
  256. 'pageuid' => $pid,
  257. 'documentLanguage' => $post['documentlanguage'],
  258. 'url' => $slugData,
  259. 'shareableUrl' => "https://abi.de" . $slugData,
  260. 'title' => ($post['roof'] != '' ? $post['roof'] . ": " : "") . $post['title'],
  261. 'activeMenuPage' => $post['targetgroup'],
  262. 'overviewImage' => $overview_image,
  263. 'teasers' => array(
  264. 'teaserHome' => $post['teaserHome'],
  265. 'abstract' => $this->removeLinebreaks($post['abstract']),
  266. 'teaserOverview' => $post['teaserOverview'],
  267. 'title' => $post['title'],
  268. 'roof' => $post['roof'],
  269. 'intro' => ($pageType == 'blogger-page') ? $post['overview'] : $post['intro']
  270. ),
  271. 'sharingActivated' => $post['sharing_activated'] == 1 ? true : false,
  272. 'linkableInHTMLSitemap' => $post['forHTMLSitemap'] == 1 ? true : false,
  273. 'linkableOnHome' => $post['forHome'] == 1 ? true : false,
  274. 'linkableOnCategoryOverview' => $post['forCategoryOverview'] == 1 ? true : false,
  275. 'moveToTopPositionOnCategoryOverview' => $post['forCategoryOverviewTopPosition'] == 1 ? true : false,
  276. 'pageType' => $pageType,
  277. 'pageData' => array(
  278. 'title' => ($post['roof'] != '' ? $post['roof'] . ": " : "") . $post['title'],
  279. 'metas' => array(
  280. "<meta name=\"keywords\" content=\"" . $post["keywords"] . "\">",
  281. "<meta name=\"dcterms.date\" content=\"" . date("Y-m-d", $post['tstamp'] > $post['starttime'] ? $post['tstamp'] : $post['starttime']) . "\">",
  282. "<meta name=\"robots\" content=\"" . ($post['no_index'] == 0 ? "index" : "noindex") . ", " . ($post['no_follow'] == 0 ? "follow" : "nofollow") . "\" />",
  283. "<meta property=\"og:title\" content=\"" . ($post['roof'] != '' ? $post['roof'] . ": " : "") . $post['title'] . "\">",
  284. ($overview_image ? "<meta property=\"og:image\" content=\"https://abi.de/cdn/" . $overview_image["sources"]["og"] . "\" >" : ""),
  285. ),
  286. 'breadcrumbs' => $this->constructBreadCrumb($rootline, $post, $pageType),
  287. 'content' => $initialContent,
  288. 'sidebar' => $this->createContentElement("sidebar", array(), (object) array(), array()),
  289. ),
  290. 'linkedPosts' => array(),
  291. 'injections' => array(),
  292. 'qr2page' => $qrsvg,
  293. 'status' => $this->constructStatus($post)
  294. );
  295. //before content
  296. switch ($pageType) {
  297. case "blog-page":
  298. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "blog-author-info"));
  299. $processedData["injections"][] = "blog-author-info";
  300. $processedData["pageData"]["sidebar"]["subElements"][] = $this->createContentElement("injection", array("type" => "blog-page-sidebar"));
  301. $processedData["injections"][] = "blog-page-sidebar";
  302. break;
  303. case "blogger-page":
  304. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "blogger-page-author-image"));
  305. $processedData["injections"][] = "blogger-page-author-image";
  306. $text = $post['overview'] ?? $post['abstract'];
  307. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("typo3_paragraph", array(), array('text' => '<p>' . $this->exchangeLinkBreaksWithBr($text) . '</p>'), null);
  308. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "blogger-page-author-latest-blogs"));
  309. $processedData["injections"][] = "blogger-page-author-latest-blogs";
  310. $processedData["pageData"]["sidebar"]["subElements"][] = $this->createContentElement("injection", array("type" => "blogger-page-sidebar"));
  311. $processedData["injections"][] = "blogger-page-sidebar";
  312. break;
  313. case "video-page":
  314. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "video-date-category"));
  315. $processedData["injections"][] = "video-date-category";
  316. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "video-info"));
  317. $processedData["injections"][] = "video-info";
  318. break;
  319. }
  320. foreach ($fetchedTTContent as $row) {
  321. $this->processData($row, $processedData, $processedImages);
  322. }
  323. //after content
  324. $processedData['pageData']['metas'][] = $this->constructMetaDescription($post['abstract'], $processedData['pageData']['content']);
  325. $processedData['pageData']['metas'][] = $this->constructMetaDescription($post['abstract'], $processedData['pageData']['content'], true);
  326. if ($pageType == "blog-page") {
  327. $processedData['pageData']['metas'][] = $this->constructMetaDescriptionForBlogPage('', $processedData['pageData']['content']);
  328. $processedData['pageData']['metas'][] = $this->constructMetaDescriptionForBlogPage('', $processedData['pageData']['content'], true);
  329. }
  330. $processedData['pageData']['metas'] = array_filter($processedData['pageData']['metas'], function ($val) {
  331. return $val != "";
  332. });
  333. switch ($pageType) {
  334. case "archive":
  335. $hasSpecificOverviewInjection = false;
  336. foreach ($processedData["injections"] as $inj) {
  337. if (str_contains($inj, "-archive-")) {
  338. $hasSpecificOverviewInjection = true;
  339. break;
  340. }
  341. }
  342. if (!$hasSpecificOverviewInjection) {
  343. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("injection", array("type" => "archive-of-direct-childurls"));
  344. $processedData["injections"][] = "archive-of-direct-childurls";
  345. }
  346. break;
  347. case "event-page":
  348. if ($post["event_link"] && $post["event_link"] != "") {
  349. $processedData["pageData"]["content"]["subElements"][] = $this->createContentElement("typo3_paragraph", array(), array('text' => '<p><a href="' . $post["event_link"] . '" target="_blank">Weitere Infos zu dieser Veranstaltung »</a></p>'));
  350. }
  351. break;
  352. }
  353. if (sizeof($processedData['pageData']['sidebar']['subElements']) == 0) {
  354. $processedData['pageData']['sidebar'] = null;
  355. }
  356. if (sizeof($processedData['linkedPosts']) == 0) $processedData['linkedPosts'] = null;
  357. else
  358. $processedData['linkedPosts'] = array_values(array_unique($processedData['linkedPosts']));
  359. if (sizeof($processedData['injections']) == 0) $processedData['injections'] = null;
  360. else
  361. $processedData['injections'] = array_unique($processedData['injections']);
  362. if ($post['hidden'] == 1) {
  363. //TODO: SET STATUS ..
  364. }
  365. $this->deletePagePDFIfExists($processedData['url']);
  366. Mongoer::sendRequest("pages", "save", $processedData);
  367. $this->generatePDFPath($processedData['pageuid'], $processedData['url']);
  368. Mongoer::sendRequest("abialtcache", "delete", array("pageuid" => $pid));
  369. $security_user_pass = $post["security_user_pass"];
  370. if (!$security_user_pass || $security_user_pass == '')
  371. Mongoer::sendRequest("security", "delete", array("pageuid" => $pid));
  372. else {
  373. $tmp = array();
  374. foreach (preg_split('/\n|\r\n?/', $security_user_pass) as $itm) {
  375. $itm = trim($itm);
  376. $itm = explode('|', $itm);
  377. $tmp[$itm[0]] = $itm[1];
  378. }
  379. $security_user_pass = $tmp;
  380. Mongoer::sendRequest("security", "save", array("pageuid" => $pid, "url" => $processedData["url"], "data" => $security_user_pass));
  381. }
  382. //if($post['doktype'] != 1) continue;
  383. if ($post['no_search'] == 0) {
  384. $dkzer = new \Meramo\mrm_be\DKZer();
  385. $searchwords = $dkzer->getSearchWords($post['dkz_code_nrs']);
  386. $freesearchwords = preg_split('/\n|\r|,\n?/', $post['free_searchwords']);
  387. foreach ($freesearchwords as $sw) {
  388. $searchwords[] = $this->convertStringToTechnicalName($sw);
  389. }
  390. $ignoredsearchwords = preg_split('/\n|\r|,\n?/', $post['ignored_searchwords']);
  391. foreach ($ignoredsearchwords as &$sw) {
  392. $sw = $this->convertStringToTechnicalName($sw);
  393. }
  394. $searchwords = array_values(array_diff($searchwords, $ignoredsearchwords));
  395. $searchabletext = $this->constructSearchableText($processedData, true);
  396. $searchabletext_full = $this->constructSearchableText($processedData, false);
  397. $arra = array("pageuid" => $pid, "searchwords" => $searchwords, "text" => $searchabletext, "fulltext" => $searchabletext_full, "lesson" => null);
  398. $lessons = array_values(explode(',', $post['lesson']));
  399. if (sizeof($lessons) == 1 && $lessons[0] == "") $lessons = [];
  400. if (sizeof($lessons) > 0) {
  401. foreach ($lessons as &$l) $l = (int) $l;
  402. $arra['lesson'] = $lessons;
  403. }
  404. Mongoer::sendRequest("search", "save", $arra);
  405. } else Mongoer::sendRequest("search", "delete", array("pageuid" => $pid));
  406. }
  407. }
  408. private function createPDFHash($url)
  409. {
  410. $page = md5($url);
  411. return $page[0] . $page[1] . '/' . $page[2] . $page[3] . '/' . $page . '.pdf';
  412. }
  413. private function deletePagePDFIfExists($url)
  414. {
  415. $partialpath = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/pdf-storage/';
  416. $file = $this->createPDFHash($url);
  417. $filepath = $partialpath . $file;
  418. if (file_exists($filepath)) {
  419. unlink($filepath);
  420. return true;
  421. } else {
  422. return false;
  423. }
  424. }
  425. private function generatePDFPath($pageuid, $url)
  426. {
  427. $urlencoded = urlencode($url);
  428. // $this->log($url, true);
  429. $urlpart = "https://abi.de/pdfgen?u=";
  430. $pdfgenurl = $urlpart . $urlencoded;
  431. $data = [
  432. 'pageuid' => $pageuid,
  433. 'url' => $pdfgenurl,
  434. 'pdfhash' => $this->createPDFHash($url)
  435. ];
  436. Mongoer::sendRequest('pdfgenjobs', 'save', $data);
  437. }
  438. private function processFolderContent(&$post)
  439. {
  440. $statement = $this->queryBuilder
  441. ->select('*')
  442. ->from('tt_content')
  443. ->where(
  444. $this->queryBuilder->expr()->eq('pid', $this->queryBuilder->createNamedParameter($post["uid"]))
  445. )
  446. ->execute();
  447. $fetchedTTContent = array();
  448. while ($row = $statement->fetch()) {
  449. $fetchedTTContent[] = $row;
  450. }
  451. if ($post['backend_layout'] == 'pagets__19') {
  452. $themenderwoche = array();
  453. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  454. foreach ($fetchedTTContent as $row) {
  455. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  456. $themenderwoche[] = array(
  457. "key" => $flex['key'],
  458. "starttime" => $this->startOfDay($flex['starttime']),
  459. "endtime" => $this->endOfDay($flex['starttime'], '+6 days'),
  460. "monday" => (int) $this->parseUIDFromT3Url($flex['monday']),
  461. "tuesday" => (int) $this->parseUIDFromT3Url($flex['tuesday']),
  462. "wednesday" => (int) $this->parseUIDFromT3Url($flex['wednesday']),
  463. "thursday" => (int) $this->parseUIDFromT3Url($flex['thursday']),
  464. "friday" => (int) $this->parseUIDFromT3Url($flex['friday']),
  465. "saturday" => (int) $this->parseUIDFromT3Url($flex['saturday']),
  466. "sunday" => (int) $this->parseUIDFromT3Url($flex['sunday']),
  467. );
  468. }
  469. Mongoer::sendRequest("themaderwoche", "save", array("data" => $themenderwoche));
  470. }
  471. if ($post['backend_layout'] == 'pagets__20') {
  472. $menus = array();
  473. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  474. foreach ($fetchedTTContent as $row) {
  475. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  476. $items = array();
  477. foreach ((array) $flex["dynamicComponents"] as $link) {
  478. $linkedPostIds = array();
  479. $itm = $this->parseFlexFormLink($link["links"]["link"], null, $linkedPostIds);
  480. //$this->log($itm, false);
  481. unset($itm["href"]);
  482. $itm["pageuid"] = $linkedPostIds["linkedPosts"][0];
  483. $items[] = $itm;
  484. }
  485. $menus[] = array(
  486. 'headline' => $flex['headline'],
  487. 'menu_id' => $flex['mid'],
  488. 'items' => $items
  489. );
  490. }
  491. Mongoer::sendRequest("menues", "save", array("data" => $menus));
  492. }
  493. if ($post['backend_layout'] == 'pagets__21') {
  494. $topthemen = array();
  495. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  496. foreach ($fetchedTTContent as $row) {
  497. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  498. $topthemen[] = array(
  499. "key" => $flex['key'],
  500. "starttime" => $this->startOfDay($flex['starttime']),
  501. "endtime" => $this->endOfDay($flex['starttime'], '+13 days'),
  502. "section1" => (int) $this->parseUIDFromT3Url($flex['section1']),
  503. "section2" => (int) $this->parseUIDFromT3Url($flex['section2']),
  504. "section3" => (int) $this->parseUIDFromT3Url($flex['section3']),
  505. "section4" => (int) $this->parseUIDFromT3Url($flex['section4']),
  506. "section5" => (int) $this->parseUIDFromT3Url($flex['section5']),
  507. );
  508. }
  509. Mongoer::sendRequest("topthemen", "save", array("data" => $topthemen));
  510. }
  511. if ($post['backend_layout'] == 'pagets__23') {
  512. $maintenance = array();
  513. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  514. foreach ($fetchedTTContent as $row) {
  515. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  516. $maintenance[] = array(
  517. "starttime" => $flex['starttime'],
  518. "endtime" => $flex['endtime'],
  519. "infotext" => $flex['infotext']
  520. );
  521. }
  522. Mongoer::sendRequest("maintenance", "save", array("data" => $maintenance));
  523. }
  524. if ($post['backend_layout'] == 'pagets__27' || $post['backend_layout' == 'pagets__28']) {
  525. $chatbot = array();
  526. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  527. foreach ($fetchedTTContent as $row) {
  528. $isDirect = $row['CType'] == 'mrm_be_cm_chatbot-direct';
  529. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  530. $item = array();
  531. $item['terms'] = explode("\n", str_replace(',', '', $flex['settings']['terms']));
  532. $item['type'] = $isDirect ? 'direct' : $flex['settings']['type'];
  533. if ($isDirect) {
  534. $item['url'] = $this->replaceT3Link($flex['settings']['url'], null, $row, false);
  535. }
  536. if ($flex['settings']['type'] == 'reverse') {
  537. $item["category"] = (($flex['settings']['category'] == "Auswählen") ? '' : $flex['settings']['category']);
  538. }
  539. $chatbot[] = $item;
  540. }
  541. Mongoer::sendRequest("chatbot", "save", array("data" => $chatbot));
  542. }
  543. }
  544. private function removeLinebreaks($str)
  545. {
  546. return trim(preg_replace('/\s+/', ' ', $str));
  547. }
  548. private function exchangeLinkBreaksWithBr($str)
  549. {
  550. return trim(preg_replace('/\r\n/', '<br />', $str));
  551. }
  552. private function startOfDay($ts, $modify = null, $isAtomDate = false, $returnAtomDate = false)
  553. {
  554. $dt = null;
  555. if ($isAtomDate) {
  556. if (is_numeric($ts)) {
  557. $ts = $ts + 0;
  558. $dt = new \DateTime();
  559. $dt->setTimezone(new \DateTimeZone('UTC'));
  560. $dt->setTimestamp($ts);
  561. } else {
  562. $dt = new \DateTime($ts);
  563. $dt->setTimezone(new \DateTimeZone('UTC'));
  564. }
  565. } else {
  566. $dt = new \DateTime(null, new \DateTimeZone('Europe/Berlin'));
  567. $dt->setTimestamp($ts);
  568. }
  569. if ($modify) $dt->modify($modify);
  570. $bodStr = $dt->format('Y-m-d 00:00:00');
  571. $bodObj = \DateTime::createFromFormat('Y-m-d H:i:s', $bodStr, $returnAtomDate ? new \DateTimeZone('UTC') : new \DateTimeZone('Europe/Berlin'));
  572. if ($returnAtomDate) return $bodObj->format(\DateTimeInterface::ATOM);
  573. return (int) $bodObj->getTimestamp();
  574. }
  575. private function endOfDay($ts, $modify = null, $isAtomDate = false, $returnAtomDate = false)
  576. {
  577. $dt = null;
  578. if ($isAtomDate) {
  579. if (is_numeric($ts)) {
  580. $ts = $ts + 0;
  581. $dt = new \DateTime();
  582. $dt->setTimezone(new \DateTimeZone('UTC'));
  583. $dt->setTimestamp($ts);
  584. } else {
  585. $dt = new \DateTime($ts);
  586. $dt->setTimezone(new \DateTimeZone('UTC'));
  587. }
  588. } else {
  589. $dt = new \DateTime(null, new \DateTimeZone('Europe/Berlin'));
  590. $dt->setTimestamp($ts);
  591. }
  592. if ($modify) $dt->modify($modify);
  593. $eodStr = $dt->format('Y-m-d 23:59:59');
  594. $eodObj = \DateTime::createFromFormat('Y-m-d H:i:s', $eodStr, $returnAtomDate ? new \DateTimeZone('UTC') : new \DateTimeZone('Europe/Berlin'));
  595. if ($returnAtomDate) return $eodObj->format(\DateTimeInterface::ATOM);
  596. return (int) $eodObj->getTimestamp();
  597. }
  598. function array_search_by_key_recursive($needle, array $haystack, &$return)
  599. {
  600. foreach ($haystack as $k => $v) {
  601. if (is_array($v)) {
  602. $this->array_search_by_key_recursive($needle, $v, $return);
  603. } else {
  604. if ($k === $needle) {
  605. $return[] = $v;
  606. }
  607. }
  608. }
  609. }
  610. private function findFirstAppearingElementByType($type, $subs, $typeKey = "type")
  611. {
  612. foreach ($subs as $v) {
  613. if ($v[$typeKey] == $type) return $v;
  614. }
  615. return null;
  616. }
  617. private function checkOrReduceDescriptionLength($desc, $len)
  618. {
  619. $newStr = '';
  620. $desc = $this->removeLinebreaks($desc);
  621. if (is_string($desc) && mb_strlen($desc) < $len) {
  622. $newStr = $desc;
  623. } else {
  624. $newStr = substr($desc, 0, $len);
  625. $pos = strrpos($newStr, ' ');
  626. $newStr = substr($desc, 0, $pos);
  627. }
  628. return $newStr;
  629. }
  630. private function constructMetaDescription($abstract = '', $content, $isOgTag = false)
  631. {
  632. $desc = '';
  633. if ($abstract != '') $desc = $abstract;
  634. if (!$desc || $desc == '') {
  635. $desc = $this->findFirstAppearingElementByType("introtext", $content["subElements"]);
  636. if ($desc)
  637. $desc = $desc["attributes"]["text"];
  638. }
  639. if (!$desc || $desc == '')
  640. return '';
  641. if ($isOgTag)
  642. return "<meta property=\"og:description\" content=\"" . $this->checkOrReduceDescriptionLength($desc, 320) . "\">";
  643. return "<meta name=\"description\" content=\"" . $this->checkOrReduceDescriptionLength($desc, 320) . "\">";
  644. }
  645. private function constructMetaDescriptionForBlogPage($text = '', $content, $isOgTag = false)
  646. {
  647. $desc = '';
  648. if ($text != '') $desc = $text;
  649. if (!$desc || $desc == '') {
  650. $desc = $this->findFirstAppearingElementByType('typo3_paragraph', $content["subElements"]);
  651. if ($desc)
  652. $desc = strip_tags($desc["attributes"]["text"]);
  653. }
  654. if (!$desc || $desc == '')
  655. return '';
  656. if ($isOgTag)
  657. return "<meta property=\"og:description\" content=\"" . $this->checkOrReduceDescriptionLength($desc, 165) . ' …' . "\">";
  658. return "<meta name=\"description\" content=\"" . $this->checkOrReduceDescriptionLength($desc, 165) . ' …' . "\">";
  659. }
  660. private function constructSearchableText($content, $minimum = true)
  661. {
  662. $cr = [];
  663. if (!$minimum) {
  664. $this->array_search_by_key_recursive("text", $content["pageData"]["content"], $cr);
  665. } else {
  666. //$roof = $this->findFirstAppearingElementByType("roof", $content["pageData"]["content"]["subElements"]);
  667. //if($roof) $cr[] = $roof["attributes"]["text"];
  668. $h1 = $this->findFirstAppearingElementByType("h1", $content["pageData"]["content"]["subElements"]);
  669. if ($h1) {
  670. $cr[] = $h1["attributes"]["roof"];
  671. $cr[] = $h1["attributes"]["text"];
  672. }
  673. $introtext = $this->findFirstAppearingElementByType("introtext", $content["pageData"]["content"]["subElements"]);
  674. if ($introtext) $cr[] = $introtext["attributes"]["text"];
  675. }
  676. $cr = preg_replace("/\r|\n/", " ", strip_tags(implode(" ", $cr)));
  677. return $cr;
  678. }
  679. private function constructStatus($post)
  680. {
  681. $publicationType = null;
  682. switch ($post["red_status"]) {
  683. case "-1": //neu angelegt
  684. case "1": //in Bearbeitung
  685. case "2": //vorbereitet
  686. case "3": //geprüft
  687. case "21": //gesperrt
  688. case "22": //archiviert
  689. $publicationType = "preview";
  690. break;
  691. case "11": //frei
  692. case "12": //online
  693. $publicationType = "live";
  694. break;
  695. default:
  696. break;
  697. }
  698. $status = array(
  699. 'isLiveFrom' => -1,
  700. 'isLiveTill' => -1,
  701. 'publicationType' => $publicationType,
  702. 'orderStatus' => $post['orderStatus'],
  703. 'date-updated' => ($post['orderStatus'] === 'neu') ? $post['starttime'] : (($post['orderStatus'] === 'aktualisiert') ? $post['red_end'] : ''),
  704. 'seo' => array(
  705. 'sitemap_changefreq' => $post['sitemap_changefreq'],
  706. 'sitemap_priority' => $post['sitemap_priority'],
  707. 'sitemap_lastmod' => time(),
  708. ),
  709. );
  710. if ($post['starttime'] != 0) {
  711. $status['isLiveFrom'] = $this->startOfDay($post['starttime']);
  712. }
  713. if ($post['endtime'] != 0) {
  714. $status['isLiveTill'] = $this->endOfDay($post['endtime']);
  715. }
  716. if ($post['doktype'] == '101') {
  717. $status['blog_author'] = $post['blog_author'];
  718. $status['blog_category'] = $post['blog_category'];
  719. }
  720. if ($post['doktype'] == '100') {
  721. $status['event_state'] = $post['event_state'];
  722. $status['event_category'] = $post['event_category'];
  723. }
  724. if ($post['doktype'] == '104') {
  725. $status['video_category'] = $post['event_category'];
  726. }
  727. //$this->log($status, false);
  728. return $status;
  729. }
  730. private function constructRedirects($pageData)
  731. {
  732. $redirects = array(
  733. '/?id=' . $pageData['uid']
  734. );
  735. //TODO: Add a single \r to match old Macs line breaks?
  736. foreach (preg_split('/\n|\r\n?/', $pageData['redirects']) as $redir) {
  737. $redir = trim($redir);
  738. if ($redir == '') continue;
  739. $redirects[] = $redir;
  740. }
  741. return $redirects;
  742. }
  743. private function convertStringToTechnicalName($string)
  744. {
  745. $string = $this->sanitizeString($string);
  746. $string = preg_replace('/-/', '', $string);
  747. return strtoupper($string);
  748. }
  749. private function sanitizeString($string)
  750. {
  751. $table = array(
  752. 'Š' => 'S', 'š' => 's', 'Đ' => 'Dj', 'đ' => 'dj', 'Ž' => 'Z', 'ž' => 'z', 'Č' => 'C', 'č' => 'c', 'Ć' => 'C', 'ć' => 'c',
  753. 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'AE', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E',
  754. 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
  755. 'Õ' => 'O', 'Ö' => 'OE', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'UE', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss',
  756. 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'ae', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e',
  757. 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o',
  758. 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe', 'ø' => 'o', 'ü' => 'ue', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y',
  759. 'þ' => 'b', 'ÿ' => 'y', 'Ŕ' => 'R', 'ŕ' => 'r', '/' => ''
  760. );
  761. $x = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $string);
  762. $x = trim(strtr($x, $table));
  763. $x = preg_replace('/[^A-Za-z0-9]+/', ' ', $x);
  764. $x = trim($x);
  765. $x = preg_replace('/ {1,}/', '-', $x);
  766. $x = trim($x, "-");
  767. return $x;
  768. }
  769. private function constructSlug($pid)
  770. {
  771. $postStatement = $this->pageQueryBuilder
  772. ->select('slug')
  773. ->from('pages')
  774. ->setMaxResults(1)
  775. ->where(
  776. $this->pageQueryBuilder->expr()->eq('uid', $this->pageQueryBuilder->createNamedParameter($pid))
  777. )
  778. ->execute();
  779. $postSlug = $postStatement->fetchAll();
  780. $postSlug = $postSlug[0];
  781. return $postSlug ? $postSlug["slug"] : null;
  782. }
  783. private function constructBreadCrumb($rootline, $page, $pageType)
  784. {
  785. $breadCrumb = $this->createContentElement('breadcrumbs');
  786. foreach ($rootline as $post) {
  787. if ($post['doktype'] == 254) continue;
  788. if ($post['is_siteroot'] == 1) continue;
  789. if ($page['uid'] == $post['uid'] && ($pageType == "blogger-page" || $pageType == "video-page"))
  790. $tit = $post['title'];
  791. else
  792. if ($post['use_roof_as_breadcrumb_text'] == 0)
  793. $tit = $post['title'];
  794. else
  795. $tit = $post['roof'] && $post['roof'] != '' ? $post['roof'] : $post['title'];
  796. $breadCrumb['subElements'][] = $this->createContentElement(
  797. 'breadcrumblink',
  798. array(
  799. 'title' => $tit,
  800. 'alt' => $tit,
  801. 'text' => $tit,
  802. 'href' => $this->constructSlug($post['uid'])
  803. )
  804. );
  805. }
  806. return $breadCrumb;
  807. }
  808. private function processData($dbReference, &$processedData, &$processedImages)
  809. {
  810. $isSidebar = $dbReference['colPos'] == 1;
  811. if ($isSidebar)
  812. $subs = &$processedData['pageData']['sidebar']['subElements'];
  813. else
  814. $subs = &$processedData['pageData']['content']['subElements'];
  815. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  816. $flex = $ffs->convertFlexFormContentToArray($dbReference['pi_flexform']);
  817. // print_r($flex);
  818. // die();
  819. switch ($dbReference['CType']) {
  820. case "mrm_be_cm_postimage":
  821. break;
  822. case "mrm_be_cm_voting":
  823. $s = $this->createContentElement(
  824. "voting",
  825. array(
  826. "labels" => array(
  827. "startbutton" => $flex["startbuttontext"],
  828. ),
  829. "resultscreen" => array(
  830. "headingTop" => $flex["resultheadingtop"],
  831. ),
  832. ),
  833. array(
  834. "items" => array(array(
  835. "text" => $flex["questiontext"],
  836. "type" => $flex["questiontype"] == "1" || $flex["questiontype"] == 1 ? "multi" : "single",
  837. "answers" => array_values(array_map(function ($x) {
  838. return array("text" => $x["settings"]["answer"]["text"], "value" => null);
  839. }, $flex["dynamicComponents"]))
  840. )),
  841. "validation" => array(
  842. "alreadyVoted" => $this->createContentElement("injection", array("type" => "voting-alreadyVoted")),
  843. "chartData" => $this->createContentElement("injection", array("type" => "voting-chartData|")),
  844. ),
  845. )
  846. );
  847. $cntr = 0;
  848. foreach ($s["attributes"]["items"][0]["answers"] as &$a) {
  849. $a["value"] = $cntr;
  850. $cntr++;
  851. }
  852. $s["attributes"]["validation"]["chartData"]["props"]["type"] .= $cntr;
  853. $processedData["injections"][] = "voting-alreadyVoted";
  854. $processedData["injections"][] = "voting-chartData|" . $cntr;
  855. $subs[] = $s;
  856. $processedData["status"]["hasVoting"] = true;
  857. break;
  858. case "mrm_be_cm_checklist-todo":
  859. $elements = $this->createContentElement(
  860. "checklist-todo",
  861. array(
  862. "headlines" => array(
  863. "main" => $flex["headline_main"],
  864. "done" => $flex["headline_done"],
  865. "not_done" => $flex["headline_not_done"],
  866. ),
  867. "controls" => array(
  868. "print" => $flex["enable_print"] == "1",
  869. "pdf" => $flex["enable_pdf"] == "1",
  870. ),
  871. "labels" => array(
  872. "submit" => $flex["label_submit"],
  873. "print" => $flex["label_print"],
  874. "pdf" => $flex["label_pdf"],
  875. ),
  876. "items" => (function ($flex, $dbReference) {
  877. $itms = array();
  878. $imgs = array();
  879. if ($flex["images"] != "0" && $flex["images"] != 0) {
  880. $imgs = $this->processImagesTTContent($dbReference, 'mrm_be_cm_contentimage', 'tt_content', 'image', 'uid', true, true);
  881. }
  882. foreach ($flex["items"] as $itm) {
  883. $i = $itm["item"];
  884. $a = array();
  885. if ($i["text"] != "") $a["text"] = $i["text"];
  886. if ($i["contains_image"] == "1" || $i["contains_image"] == 1) {
  887. $im = array_shift($imgs);
  888. if (isset($im)) $a["img"] = $im;
  889. }
  890. $itms[] = $a;
  891. }
  892. return $itms;
  893. })($flex, $dbReference),
  894. )
  895. );
  896. $subs[] = $elements;
  897. $processedData["status"]["hasChecklist"] = true;
  898. break;
  899. case "mrm_be_cm_checklist_todo_multi":
  900. $elements = $this->createContentElement(
  901. 'checklist-todo-multi',
  902. array(
  903. "texts" => array(
  904. "mainhead" => $flex['mainhead'],
  905. "description" => $flex['description'],
  906. ),
  907. "controls" => array(
  908. "print" => $flex["enable_print"] == "1",
  909. "pdf" => $flex["enable_pdf"] == "1",
  910. ),
  911. "labels" => array(
  912. "print" => $flex["label_print"],
  913. "pdf" => $flex["label_pdf"],
  914. ),
  915. "items" => (function ($flex) {
  916. $itms = [];
  917. $a = array();
  918. foreach ($flex['items'] as $itm) {
  919. if (is_array($itm)) {
  920. $a['head'] = $itm['item']['head'];
  921. $list = $itm['item']['list'];
  922. $doc = new \DOMDocument('1.0', 'utf-8');
  923. $doc->loadHTML('<?xml encoding="UTF-8">' . $list);
  924. $listitems = $doc->getElementsByTagName('li');
  925. $list = [];
  926. foreach ($listitems as $node) {
  927. foreach ($node->childNodes as $child) {
  928. $list[] = array('text' => $child->nodeValue);
  929. }
  930. $a['items'] = $list;
  931. }
  932. }
  933. $itms[] = $a;
  934. }
  935. return $itms;
  936. })($flex),
  937. ),
  938. );
  939. $subs[] = $elements;
  940. break;
  941. case "mrm_be_cm_checklist-input":
  942. $items = array();
  943. $dynContentCounter = 0;
  944. while (true) {
  945. $dynContentCounter++;
  946. if (!isset($flex["label" . $dynContentCounter])) break;
  947. if ($flex["label" . $dynContentCounter] === "") continue;
  948. $label = array(
  949. "label" => $flex["label" . $dynContentCounter]
  950. );
  951. $items[] = $label;
  952. }
  953. $elements = $this->createContentElement(
  954. "checklist-input",
  955. array(
  956. "headlines" => array(
  957. "main" => $flex["headline_main"],
  958. "results" => $flex["headline_result"],
  959. ),
  960. "intro" => $flex["intro"],
  961. "controls" => array(
  962. "print" => $flex["enable_print"] == "1",
  963. "pdf" => $flex["enable_pdf"] == "1",
  964. ),
  965. "labels" => array(
  966. "submit" => $flex["label_submit"],
  967. "print" => $flex["label_print"],
  968. "pdf" => $flex["label_pdf"],
  969. ),
  970. "items" => $items,
  971. )
  972. );
  973. $subs[] = $elements;
  974. $processedData["status"]["hasChecklist"] = true;
  975. break;
  976. case "mrm_be_cm_checklist-scale":
  977. $items = array();
  978. $dynContentCounter = 0;
  979. while (true) {
  980. $dynContentCounter++;
  981. if (!isset($flex["label" . $dynContentCounter])) break;
  982. if ($flex["label" . $dynContentCounter] === "") continue;
  983. $label = array(
  984. "label" => $flex["label" . $dynContentCounter]
  985. );
  986. $items[] = $label;
  987. }
  988. $elements = $this->createContentElement(
  989. "checklist-scale",
  990. array(
  991. "headlines" => array(
  992. "main" => $flex["headline_main"],
  993. "results" => $flex["headline_result"],
  994. ),
  995. "intro" => $flex["intro"],
  996. "maxPoints" => (int)$flex["maxpoints"],
  997. "controls" => array(
  998. "print" => $flex["enable_print"] == "1",
  999. "pdf" => $flex["enable_pdf"] == "1",
  1000. ),
  1001. "labels" => array(
  1002. "nextbutton" => $flex["label_nextbutton"],
  1003. "lastbutton" => $flex["label_lastbutton"],
  1004. "print" => $flex["label_print"],
  1005. "pdf" => $flex["label_pdf"],
  1006. ),
  1007. "items" => $items,
  1008. )
  1009. );
  1010. $subs[] = $elements;
  1011. $processedData["status"]["hasChecklist"] = true;
  1012. break;
  1013. case "mrm_be_cm_checklist-radiorange":
  1014. $items = array();
  1015. $dynContentCounter = 0;
  1016. while (true) {
  1017. $dynContentCounter++;
  1018. if (!isset($flex["pointsFrom" . $dynContentCounter])) break;
  1019. if ($flex["pointsFrom" . $dynContentCounter] === "") continue;
  1020. $item = array(
  1021. "pointsFrom" => (int)$flex["pointsFrom" . $dynContentCounter],
  1022. "pointsTo" => (int)$flex["pointsTo" . $dynContentCounter],
  1023. "validationText" => $flex["validationText" . $dynContentCounter]
  1024. );
  1025. if ($flex["image" . $dynContentCounter] == 1) {
  1026. $images = $this->processImagesTTContent($dbReference, 'mrm_be_cm_checklist-radiorange', 'tt_content', 'flex_image_' . $dynContentCounter, 'uid', false, true);
  1027. $images = $images[0];
  1028. $images["src"] = $images["sources"]["img"];
  1029. unset($images["sources"]);
  1030. $item["img"] = $images;
  1031. }
  1032. $items[] = $item;
  1033. }
  1034. $elements = $this->createContentElement(
  1035. "checklist-radiorange",
  1036. array(
  1037. "headlines" => array(
  1038. "main" => $flex["headline_main"],
  1039. ),
  1040. "intro" => $flex["intro"],
  1041. "validation" => array(
  1042. "maxPoints" => (int)$flex["maxpoints"],
  1043. "items" => $items,
  1044. )
  1045. )
  1046. );
  1047. $subs[] = $elements;
  1048. $processedData["status"]["hasChecklist"] = true;
  1049. break;
  1050. case "mrm_be_cm_checklist-yesmaybeno":
  1051. $items = array();
  1052. foreach ($flex["dynamicComponents"] as $component) {
  1053. foreach ($component as $key => $value) {
  1054. $item = array(
  1055. "heading" => $value["headline"],
  1056. "text" => $value["text"]
  1057. );
  1058. }
  1059. if ($item) {
  1060. $items[] = $item;
  1061. }
  1062. unset($value);
  1063. }
  1064. $choices = array();
  1065. $choice_yes = array(
  1066. "label" => $flex["choice_value_yes"],
  1067. "value" => "yes"
  1068. );
  1069. $choice_maybe = array(
  1070. "label" => $flex["choice_value_maybe"],
  1071. "value" => "maybe"
  1072. );
  1073. $choice_no = array(
  1074. "label" => $flex["choice_value_no"],
  1075. "value" => "no"
  1076. );
  1077. $choices[] = $choice_yes;
  1078. $choices[] = $choice_maybe;
  1079. $choices[] = $choice_no;
  1080. $elements = $this->createContentElement(
  1081. "checklist-yesmaybeno",
  1082. array(
  1083. "headlines" => array(
  1084. "main" => $flex["headline_main"],
  1085. "results" => $flex["headline_result"],
  1086. ),
  1087. "intro" => $flex["intro"],
  1088. "controls" => array(
  1089. "print" => $flex["enable_print"] == "1",
  1090. "pdf" => $flex["enable_pdf"] == "1",
  1091. ),
  1092. "labels" => array(
  1093. "nextbutton" => $flex["label_nextbutton"],
  1094. "lastbutton" => $flex["label_lastbutton"],
  1095. "print" => $flex["label_print"],
  1096. "pdf" => $flex["label_pdf"],
  1097. ),
  1098. "choices" => $choices,
  1099. "items" => $items,
  1100. )
  1101. );
  1102. $subs[] = $elements;
  1103. $processedData["status"]["hasChecklist"] = true;
  1104. break;
  1105. case "mrm_be_cm_picturechoice":
  1106. $s = $this->createContentElement(
  1107. "picturechoice",
  1108. array(
  1109. "labels" => array(
  1110. "startbutton" => $flex["startbuttontext"],
  1111. "nextbutton" => $flex["nextbuttontext"],
  1112. "lastbutton" => $flex["lastbuttontext"],
  1113. "question" => $flex["question"],
  1114. "repeatbutton" => $flex["repeatbuttontext"],
  1115. ),
  1116. "resultscreen" => array(
  1117. "headingTop" => $flex["resultheadingtop"],
  1118. "end" => $flex["thanks"]
  1119. ),
  1120. "isRestartAble" => $flex["isRestartAble"] == 1 || $flex["isRestartAble"] == "1",
  1121. ),
  1122. array(
  1123. "items" => (function ($flex, $dbReference) {
  1124. $ret = array();
  1125. for ($i = 1; $i <= 3; $i++) {
  1126. $item = array();
  1127. for ($j = 1; $j <= 5; $j++) {
  1128. if ($flex["image" . $i . "_" . $j] == "1") {
  1129. $img = $this->processImagesTTContent($dbReference, 'mrm_be_cm_picturechoice', 'tt_content', 'flex_image_' . $i . "_" . $j, 'uid', false, true);
  1130. $img = $img[0];
  1131. $item[] = array(
  1132. "image" => $img,
  1133. "points" => (int) $flex["pointsOfImage" . $i . "_" . $j]
  1134. );
  1135. }
  1136. }
  1137. if (sizeof($item) > 0)
  1138. $ret[] = $item;
  1139. }
  1140. return $ret;
  1141. })($flex, $dbReference),
  1142. "validation" => array(
  1143. "maxPoints" => (int)$flex["maxpoints"],
  1144. "alreadyReachedPoints" => $this->createContentElement("injection", array("type" => "picturechoice-alreadyReachedPoints")),
  1145. "items" => array_map(
  1146. function ($i) {
  1147. $i["validationText"] = $this->checkTextForInternalLinks($i["validationText"], $dbReference, $processedData);
  1148. $i["pointsFrom"] = (int)$i["pointsFrom"];
  1149. $i["pointsTo"] = (int)$i["pointsTo"];
  1150. return $i;
  1151. },
  1152. array_filter(array_values(array_map(function ($v) {
  1153. return $v['settings']['validation'];
  1154. }, $flex["validations"])), function ($x) {
  1155. return $x != null;
  1156. })
  1157. //TODO: Core: Error handler (BE): PHP Warning: array_filter() expects parameter 1 (or 2 in another error message) to be array, null given in /var/www/html/typo3conf/ext/mrm_be/Classes/Hooks/TCE/TCEMainHook.php line 830
  1158. ),
  1159. ),
  1160. )
  1161. );
  1162. $processedData["injections"][] = "picturechoice-alreadyReachedPoints";
  1163. $subs[] = $s;
  1164. $processedData["status"]["hasPicturechoice"] = true;
  1165. break;
  1166. case "mrm_be_cm_quiz":
  1167. $s = $this->createContentElement(
  1168. "quiz",
  1169. array(
  1170. "labels" => array(
  1171. "startbutton" => $flex["startbuttontext"],
  1172. "nextbutton" => $flex["nextbuttontext"],
  1173. "lastbutton" => $flex["lastbuttontext"],
  1174. "question" => $flex["question"],
  1175. "repeatbutton" => $flex["repeatbuttontext"],
  1176. ),
  1177. "resultscreen" => array(
  1178. "headingTop" => $flex["resultheadingtop"],
  1179. "headingSub" => $flex["resultheadingsub"],
  1180. "validation" => $flex["validationstr"],
  1181. "end" => $flex["thanks"]
  1182. ),
  1183. "isRestartAble" => $flex["isRestartAble"] == 1 || $flex["isRestartAble"] == "1",
  1184. ),
  1185. array(
  1186. "items" => array_values(array_map(function ($v) {
  1187. $questionType = null;
  1188. $quest = $v['settings']['question'];
  1189. if (!isset($quest)) {
  1190. $quest = $v['settings']['question_multi'];
  1191. $questionType = "multi";
  1192. }
  1193. if (isset($quest["additional_text"]) && $quest["additional_text"] != "") {
  1194. $quest["text"] = $quest["text"] . " (" . $quest["additional_text"] . ")";
  1195. unset($quest["additional_text"]);
  1196. }
  1197. if ($questionType) $quest["type"] = $questionType;
  1198. unset($quest["rightanswer"]);
  1199. $i = 0;
  1200. $quest["answers"] = array();
  1201. while (1) {
  1202. $i++;
  1203. if (!isset($quest["answertext" . $i])) break;
  1204. if ($quest["answertext" . $i] === "") continue;
  1205. $quest["answers"][] = array("text" => $quest["answertext" . $i], "points" => (int)$quest["answerpoints" . $i]);
  1206. unset($quest["answertext" . $i]);
  1207. unset($quest["answerpoints" . $i]);
  1208. }
  1209. /* NOTE: DEPRECATED BY SINGLE INPUTS
  1210. $quest["answers"] = array_map(function($x) {
  1211. $x = explode("|", $x);
  1212. $x = array("text" => $x[0], "points" => (int)$x[1]);
  1213. return $x;
  1214. }, explode("\n", $quest["answers"]));
  1215. */
  1216. return $quest;
  1217. }, $flex["dynamicComponents"])),
  1218. "validation" => array(
  1219. "maxPoints" => (int)$flex["maxpoints"],
  1220. "averagePoints" => $this->createContentElement("injection", array("type" => "quiz-averagePoints")),
  1221. "alreadyReachedPoints" => $this->createContentElement("injection", array("type" => "quiz-alreadyReachedPoints")),
  1222. "items" => array_map(
  1223. function ($i) {
  1224. $i["validationText"] = $this->checkTextForInternalLinks($i["validationText"], $dbReference, $processedData);
  1225. return $i;
  1226. },
  1227. array_filter(array_values(array_map(function ($v) {
  1228. return $v['settings']['validation'];
  1229. }, $flex["dynamicComponents2"])), function ($x) {
  1230. return $x != null;
  1231. })
  1232. ),
  1233. ),
  1234. )
  1235. );
  1236. $processedData["injections"][] = "quiz-averagePoints";
  1237. $processedData["injections"][] = "quiz-alreadyReachedPoints";
  1238. $subs[] = $s;
  1239. $processedData["status"]["hasQuiz"] = true;
  1240. break;
  1241. case "mrm_be_cm_animation":
  1242. $script = $flex["script"];
  1243. if ($flex["staticfiles"] != "0" && $flex["staticfiles"] != 0) {
  1244. $imgs = $this->processImagesTTContent($dbReference);
  1245. foreach ($imgs as $idx => $v) {
  1246. $script = implode("#cdnurl#/" . $v["sources"]["passthru"], explode("%ASSET_" . ($idx + 1) . "%", $script));
  1247. }
  1248. }
  1249. $subs[] = $this->createContentElement("animation", array("addJQuery" => $flex["addJQuery"] == 1 || $flex["addJQuery"] == "1"), array("script" => $script));
  1250. $processedData["status"]["hasAnimation"] = true;
  1251. break;
  1252. case "mrm_be_cm_injection":
  1253. $subs[] = $this->createContentElement("injection", array("type" => $flex["text"]));
  1254. $processedData["injections"][] = $flex["text"];
  1255. break;
  1256. case "mrm_be_cm_roof":
  1257. $subs[] = $this->createContentElement("roof", array(), array("text" => $flex["text"]));
  1258. break;
  1259. case "mrm_be_cm_h1":
  1260. $subs[] = $this->createContentElement("h1", array(), array("text" => $flex["text"]));
  1261. break;
  1262. case "mrm_be_cm_h2":
  1263. $subs[] = $this->createContentElement("h2", array(), array("text" => $flex["text"]));
  1264. break;
  1265. case "mrm_be_cm_h3":
  1266. $subs[] = $this->createContentElement("h3", array(), array("text" => $flex["text"]));
  1267. break;
  1268. case "mrm_be_cm_introtext":
  1269. $text = preg_replace("/\n/", "<br />", $flex["text"]);
  1270. $subs[] = $this->createContentElement("introtext", array(), array("text" => $text));
  1271. break;
  1272. case "mrm_be_cm_button":
  1273. $href = $this->parseFlexFormLink($flex["button"], $dbReference, $processedData);
  1274. $buttonType = ($flex['buttonType'] == "0") ? 'button-link' : 'button-scream';
  1275. $button = $this->createContentElement("button", array('buttonType' => $buttonType), array("text" => $flex["text"], "href" => $href["href"], "target" => $href["target"]));
  1276. $subs[] = $button;
  1277. break;
  1278. case "mrm_be_cm_html":
  1279. $subs[] = $this->createContentElement("html", array(), array("text" => $flex["html"]));
  1280. break;
  1281. case "mrm_be_cm_heroimage":
  1282. $props = $this->processImagesTTContent($dbReference)[0];
  1283. $props["type"] = "typo3_hero";
  1284. $subs[] = $this->createContentElement("image", $props);
  1285. break;
  1286. case "mrm_be_cm_contentimage":
  1287. $props = $this->processImagesTTContent($dbReference)[0];
  1288. $props["type"] = "typo3_content";
  1289. $subs[] = $this->createContentElement("image", $props);
  1290. break;
  1291. case "mrm_be_cm_publication":
  1292. $imgprops = $this->processImagesTTContent($dbReference, 'mrm_be_cm_publication')[0];
  1293. $imgprops["type"] = "typo3_publication";
  1294. $publication = $this->createContentElement(
  1295. "publication",
  1296. array(
  1297. "starttime" => $this->startOfDay($flex['starttime']),
  1298. "endtime" => $this->endOfDay($flex['endtime']),
  1299. "issuekey" => $flex['issuekey'],
  1300. ),
  1301. array(
  1302. "image" => $imgprops,
  1303. "number" => $flex["issuenumber"],
  1304. "title" => $flex["issuetitle"],
  1305. "headline" => $flex["issueheadline"],
  1306. "link" => $this->parseFlexFormLink($flex["htmllink"], $dbReference, $processedData),
  1307. "pdf" => $this->parseFlexFormLink($flex["pdflink"], $dbReference, $processedData),
  1308. )
  1309. );
  1310. $subs[] = $publication;
  1311. break;
  1312. case "mrm_be_cm_rawimage":
  1313. $props = $this->processImagesTTContent($dbReference)[0];
  1314. $props["type"] = "typo3_raw";
  1315. $subs[] = $this->createContentElement("image", $props);
  1316. break;
  1317. case "mrm_be_cm_movingimagesvideo":
  1318. $subs[] = $this->createContentElement(
  1319. "movingimagesvideo",
  1320. array(
  1321. "hasNoticeForCrossPromotion" => $flex["hasNoticeForCrossPromotion"] == 1,
  1322. "hasNoticeForAccessibility" => $flex["hasNoticeForAccessibility"] == 1
  1323. ),
  1324. array("vid" => $flex["vid"])
  1325. );
  1326. break;
  1327. case "mrm_be_cm_paragraph":
  1328. $elements = $this->checkText($flex["text"], $dbReference, $processedData, "typo3_paragraph");
  1329. $subs = array_merge($subs, $elements);
  1330. break;
  1331. case "mrm_be_cm_additionalinfobox":
  1332. case "mrm_be_cm_infobox":
  1333. case "mrm_be_cm_extra_infosbox":
  1334. $type = null;
  1335. $open = null;
  1336. $noAutoOpen = null;
  1337. if ($dbReference['CType'] == "mrm_be_cm_additionalinfobox") $type = "typo3_additionalinfobox";
  1338. elseif ($dbReference['CType'] == "mrm_be_cm_infobox") $type = "typo3_infobox";
  1339. else $type = "typo3_extrainfosbox";
  1340. if ($dbReference['CType'] == "mrm_be_cm_additionalinfobox" || $dbReference['CType'] == "mrm_me_cm_extra_infosbox") $open = true;
  1341. else $open = $flex["isInitialyOpen"] == "1";
  1342. if ($dbReference['CType'] == "mrm_be_cm_additionalinfobox" || $dbReference['CType'] == "mrm_be_cm_infobox") $headline = $flex["headline"];
  1343. elseif ($dbReference['CType'] == "mrm_be_cm_extra_infosbox") $headline = '';
  1344. $this->log('Headline: ' . $headline, true);
  1345. $sub = $this->createContentElement(
  1346. $type,
  1347. array("open" => $open, "noAutoOpen" => $flex["noAutoOpen"] == 1),
  1348. array("headline" => $flex["headline"])
  1349. );
  1350. if ($flex["image"] == "1") {
  1351. $props = $this->processImagesTTContent($dbReference, "mrm_be_cm_contentimage")[0];
  1352. $props["type"] = "typo3_content";
  1353. $sub["subElements"][] = $this->createContentElement("image", $props);
  1354. } else {
  1355. switch ($flex["icon"]) {
  1356. case "1":
  1357. $sub["attributes"]["icon"] = "stadtinfo_basics";
  1358. break;
  1359. case "2":
  1360. $sub["attributes"]["icon"] = "geschichte";
  1361. break;
  1362. case "3":
  1363. $sub["attributes"]["icon"] = "kultur_freizeit";
  1364. break;
  1365. case "4":
  1366. $sub["attributes"]["icon"] = "besonderheiten";
  1367. break;
  1368. case "5":
  1369. $sub["attributes"]["icon"] = "kosten_geld";
  1370. break;
  1371. case "6":
  1372. $sub["attributes"]["icon"] = "hochschulen";
  1373. break;
  1374. case "7":
  1375. $sub["attributes"]["icon"] = "studieren";
  1376. break;
  1377. }
  1378. }
  1379. if ($flex["dynamicComponents"] && sizeof($flex["dynamicComponents"]) > 0)
  1380. foreach ($flex["dynamicComponents"] as $comp) {
  1381. $stype = array_keys($comp['settings'])[0];
  1382. $elements = [];
  1383. switch ($stype) {
  1384. case "box":
  1385. $box = $this->createContentElement("boxwrapper");
  1386. $box["subElements"] = array_merge($box["subElements"], $this->checkText($comp['settings']['box']['boxheadline'], $dbReference, $processedData, "h3"));
  1387. $box["subElements"] = array_merge($box["subElements"], $this->checkText($comp['settings']['box']['boxtext'], $dbReference, $processedData, "typo3_paragraph"));
  1388. $elements = [$box];
  1389. break;
  1390. case "boxheadline":
  1391. $elements = $this->checkText($comp['settings'][$stype][$stype], $dbReference, $processedData, "h3");
  1392. //$this->log($elements, false);
  1393. break;
  1394. case "boxtext":
  1395. $elements = $this->checkText($comp['settings'][$stype][$stype], $dbReference, $processedData, "typo3_paragraph");
  1396. break;
  1397. case "html":
  1398. $elements = $this->checkText($comp['settings'][$stype][$stype], $dbReference, $processedData, "html");
  1399. break;
  1400. }
  1401. $sub["subElements"] = array_merge($sub["subElements"], $elements);
  1402. $this->log($sub["subElements"], false);
  1403. }
  1404. $subs[] = $sub;
  1405. break;
  1406. case "mrm_be_cm_extra_infosbox_prefilled":
  1407. $type = "typo3_extrainfosbox_prefilled";
  1408. $open = $flex["isInitialyOpen"] == "0" ? true : false;
  1409. $headline = $flex['headline'];
  1410. $elements = [];
  1411. $sub = $this->createContentElement(
  1412. $type,
  1413. array("open" => $open, "noAutoOpen" => $flex["noAutoOpen"] == 1),
  1414. array("headline" => $flex["headline"])
  1415. );
  1416. if ($flex["image"] == "1") {
  1417. $props = $this->processImagesTTContent($dbReference, "mrm_be_cm_contentimage")[0];
  1418. $props["type"] = "typo3_content";
  1419. $sub["subElements"][] = $this->createContentElement("image", $props);
  1420. } else {
  1421. switch ($flex["icon"]) {
  1422. case "1":
  1423. $sub["attributes"]["icon"] = "stadtinfo_basics";
  1424. break;
  1425. case "2":
  1426. $sub["attributes"]["icon"] = "geschichte";
  1427. break;
  1428. case "3":
  1429. $sub["attributes"]["icon"] = "kultur_freizeit";
  1430. break;
  1431. case "4":
  1432. $sub["attributes"]["icon"] = "besonderheiten";
  1433. break;
  1434. case "5":
  1435. $sub["attributes"]["icon"] = "kosten_geld";
  1436. break;
  1437. case "6":
  1438. $sub["attributes"]["icon"] = "hochschulen";
  1439. break;
  1440. case "7":
  1441. $sub["attributes"]["icon"] = "studieren";
  1442. break;
  1443. }
  1444. }
  1445. $cleaned = [];
  1446. $keys = ["healine", "image", "icon", "isInitialyOpen", "noAutoOpen"];
  1447. foreach ($keys as $k) {
  1448. unset($k);
  1449. }
  1450. foreach ($flex as $key => $val) {
  1451. if (strpos($key, 'headline') != false) {
  1452. $new_value = str_replace('headline', '', $key);
  1453. if (array_key_exists($new_value, $cleaned)) {
  1454. continue;
  1455. } else {
  1456. $cleaned[$new_value]['headline'] = $val;
  1457. }
  1458. } elseif (strpos($key, 'text') != false) {
  1459. $new_value = str_replace('text', '', $key);
  1460. if (!array_key_exists($new_value, $cleaned)) {
  1461. continue;
  1462. } else {
  1463. $cleaned[$new_value]['text'] = $val;
  1464. }
  1465. }
  1466. elseif (strpos($key, 'url') != false) {
  1467. $new_value = str_replace('url', '', $key);
  1468. if (!array_key_exists($new_value, $cleaned)) {
  1469. continue;
  1470. } else {
  1471. $cleaned[$new_value]['url'] = $val;
  1472. }
  1473. }
  1474. }
  1475. $data = [];
  1476. foreach($cleaned as $k => $val) {
  1477. foreach($val as $field => $value) {
  1478. if(isset($value) && !empty($value)) {
  1479. $data[$k][$field] = $value;
  1480. }
  1481. else {
  1482. continue;
  1483. }
  1484. }
  1485. }
  1486. foreach($data as $key => $value) {
  1487. $box = $this->createContentElement("boxwrapper");
  1488. if(isset($value['headline']) && !empty($value['headline'])) {
  1489. $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['headline'], $dbReference, $processedData, "h3"));
  1490. }
  1491. if(isset($value['text']) && !empty($value['text'])) {
  1492. $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['text'], $dbReference, $processedData, "typo3_paragraph"));
  1493. }
  1494. if(isset($value['url']) && !empty($value['url'])) {
  1495. $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['url'], $dbReference, $processedData, "link"));
  1496. }
  1497. $elements[] = $box;
  1498. }
  1499. $sub["subElements"] = array_merge($sub["subElements"], $elements);
  1500. $subs[] = $sub;
  1501. break;
  1502. case "mrm_be_cm_foldout":
  1503. $sub = $this->createContentElement("typo3_foldout", array("open" => $flex["isInitialyOpen"] == "1", "noAutoOpen" => $flex["noAutoOpen"] == "1"), array("headline" => $flex["headline"]), array());
  1504. if ($flex["image"] == "1") {
  1505. $props = $this->processImagesTTContent($dbReference, "mrm_be_cm_contentimage")[0];
  1506. $props["type"] = "typo3_content";
  1507. $sub["subElements"][] = $this->createContentElement("image", $props);
  1508. } else {
  1509. switch ($flex["icon"]) {
  1510. case "1":
  1511. $sub["attributes"]["icon"] = "stadtinfo_basics";
  1512. break;
  1513. case "2":
  1514. $sub["attributes"]["icon"] = "geschichte";
  1515. break;
  1516. case "3":
  1517. $sub["attributes"]["icon"] = "kultur_freizeit";
  1518. break;
  1519. case "4":
  1520. $sub["attributes"]["icon"] = "besonderheiten";
  1521. break;
  1522. case "5":
  1523. $sub["attributes"]["icon"] = "kosten_geld";
  1524. break;
  1525. case "6":
  1526. $sub["attributes"]["icon"] = "hochschulen";
  1527. break;
  1528. case "7":
  1529. $sub["attributes"]["icon"] = "studieren";
  1530. break;
  1531. }
  1532. }
  1533. if ($flex["dynamicComponents"] && sizeof($flex["dynamicComponents"]) > 0)
  1534. foreach ($flex["dynamicComponents"] as $comp) {
  1535. $stype = array_keys($comp['settings'])[0];
  1536. $elements = $this->checkText($comp['settings'][$stype][$stype], $dbReference, $processedData, $stype == "paragraph" ? "typo3_paragraph" : ($stype == "headline" ? "h3" : $stype));
  1537. $sub["subElements"] = array_merge($sub["subElements"], $elements);
  1538. }
  1539. $subs[] = $sub;
  1540. break;
  1541. case "mrm_be_cm_newsletterabo":
  1542. $newsletterabo = $this->createContentElement("newsletterabo", array("cr_url" => $flex["cr_url"], "cr_url_BIZ" => $flex["cr_url_BIZ"]));
  1543. $subs[] = $newsletterabo;
  1544. break;
  1545. case "mrm_be_cm_linkage":
  1546. $subs[] = $this->createContentElement("sidebarheadline", array(), array("text" => $flex['headline']));
  1547. $banners = $this->createContentElement("sidebarbanners");
  1548. if ($flex['dynamicComponents'] && sizeof($flex['dynamicComponents']) > 0)
  1549. foreach ($flex['dynamicComponents'] as $banner) {
  1550. $banners["subElements"][] = $this->createContentElement("banner", $this->parseFlexFormLink($banner["settings"]["link"]["link"], $dbReference, $processedData));
  1551. }
  1552. $subs[] = $banners;
  1553. $subs[] = $this->createContentElement("injection", array("type" => "rubrik_content"));
  1554. $processedData["injections"][] = "rubrik_content";
  1555. $berufenet = $this->createContentElement("sidebarexternallinks", array("type" => "berufenet"), array("items" => []));
  1556. if ($flex['dynamicComponentsBerufeNet'] && sizeof($flex['dynamicComponentsBerufeNet']) != 0)
  1557. foreach ($flex['dynamicComponentsBerufeNet'] as $itm) {
  1558. $link = $this->parseFlexFormLink($itm["settings"]["link"]["link"], $dbReference, $processedData);
  1559. $link = '<a href="' . $link['href'] . '" target="' . $link['target'] . '" aria-label="Externer Link">' . $link['alt'] . '</a>';
  1560. $berufenet["attributes"]["items"][] = $link;
  1561. }
  1562. if (sizeof($berufenet["attributes"]["items"]) > 0) $subs[] = $berufenet;
  1563. $berufetv = $this->createContentElement("sidebarexternallinks", array("type" => "berufetv"), array("items" => []));
  1564. if ($flex['dynamicComponentsBerufeTV'] && sizeof($flex['dynamicComponentsBerufeTV']) != 0)
  1565. foreach ($flex['dynamicComponentsBerufeTV'] as $itm) {
  1566. $link = $this->parseFlexFormLink($itm["settings"]["link"]["link"], $dbReference, $processedData);
  1567. $link = '<a href="' . $link['href'] . '" target="' . $link['target'] . '" aria-label="Externer Link">' . $link['alt'] . '</a>';
  1568. $berufetv["attributes"]["items"][] = $link;
  1569. }
  1570. if (sizeof($berufetv["attributes"]["items"]) > 0) $subs[] = $berufetv;
  1571. $berufsausbildung = $this->createContentElement("sidebarexternallinks", array("type" => "berufsausbildung"), array("items" => []));
  1572. if ($flex['dynamicComponentsBerufsausbildung'] && sizeof($flex['dynamicComponentsBerufsausbildung']) != 0)
  1573. foreach ($flex['dynamicComponentsBerufsausbildung'] as $itm) {
  1574. $link = $this->parseFlexFormLink($itm["settings"]["link"]["link"], $dbReference, $processedData);
  1575. $link = '<a href="' . $link['href'] . '" target="' . $link['target'] . '" aria-label="Externer Link">' . $link['alt'] . '</a>';
  1576. $berufsausbildung["attributes"]["items"][] = $link;
  1577. }
  1578. if (sizeof($berufsausbildung["attributes"]["items"]) > 0) $subs[] = $berufsausbildung;
  1579. $ba_search = $this->createContentElement("sidebarexternallinks", array("type" => "ba_search"), array("items" => []));
  1580. if ($flex['dynamicComponentsBASearch'] && sizeof($flex['dynamicComponentsBASearch']) != 0)
  1581. foreach ($flex['dynamicComponentsBASearch'] as $itm) {
  1582. $link = $this->parseFlexFormLink($itm["settings"]["link"]["link"], $dbReference, $processedData);
  1583. $link = '<a href="' . $link['href'] . '" target="' . $link['target'] . '" aria-label="Externer Link">' . $link['alt'] . '</a>';
  1584. $ba_search["attributes"]["items"][] = $link;
  1585. }
  1586. if (sizeof($ba_search["attributes"]["items"]) > 0) $subs[] = $ba_search;
  1587. $studienwahl = $this->createContentElement("sidebarexternallinks", array("type" => "studienwahl"), array("items" => []));
  1588. if ($flex['dynamicComponentsStudienwahl'] && sizeof($flex['dynamicComponentsStudienwahl']) != 0)
  1589. foreach ($flex['dynamicComponentsStudienwahl'] as $itm) {
  1590. $link = $this->parseFlexFormLink($itm["settings"]["link"]["link"], $dbReference, $processedData);
  1591. $link = '<a href="' . $link['href'] . '" target="' . $link['target'] . '" aria-label="Externer Link">' . $link['alt'] . '</a>';
  1592. $studienwahl["attributes"]["items"][] = $link;
  1593. }
  1594. if (sizeof($studienwahl["attributes"]["items"]) > 0) $subs[] = $studienwahl;
  1595. if ($flex['enable_check_u']) {
  1596. $check_u = $this->createContentElement("extimgbutton", array("ariaLabel" => "Zur Check-U-Website", "href" => "https://www.arbeitsagentur.de/bildung/welche-ausbildung-welches-studium-passt", "target" => "_blank"), array("imgsrc" => "/public/media/ext-link_check_u.png"));
  1597. $subs[] = $check_u;
  1598. }
  1599. if ($flex['enable_studiencheck']) {
  1600. $studiencheck = $this->createContentElement("extimgbutton", array("ariaLabel" => "Zur Studiencheck-Website", "href" => "https://studiencheck.de/", "target" => "_blank"), array("imgsrc" => "/public/media/ext-link_studiencheck.png"));
  1601. $subs[] = $studiencheck;
  1602. }
  1603. break;
  1604. case "mrm_be_cm_homeheaderinfo":
  1605. $items = array();
  1606. for ($i = 1; $i <= 3; $i++) {
  1607. if ($flex["headline" . $i] != "" && $flex["text" . $i] != "") {
  1608. $item = array("heading" => $flex["headline" . $i], "text" => $flex["text" . $i]);
  1609. if ($flex["link" . $i] != "") {
  1610. $link = $this->parseFlexFormLink($flex["link" . $i], $dbReference, $processedData);
  1611. $item["href"] = $link["href"];
  1612. $item["linkTarget"] = $link["target"];
  1613. }
  1614. if ($flex["image" . $i] == "1") {
  1615. $imgs = $this->processImagesTTContent($dbReference, 'mrm_be_cm_homeheaderinfo', 'tt_content', 'flex_image_' . $i, 'uid', false);
  1616. $item["image"] = "#cdnurl#/" . $imgs[0]["sources"][$flex["imagesize" . $i]];
  1617. }
  1618. $items[] = $item;
  1619. }
  1620. }
  1621. $subs[] = $this->createContentElement("abimessages", array("data" => $items));
  1622. break;
  1623. case "mrm_be_cm_tileoverview":
  1624. $items = array();
  1625. for ($i = 1; $i <= 8; $i++) {
  1626. if ($flex["link" . $i] == "") continue;
  1627. $item = array();
  1628. $link = $this->parseFlexFormLink($flex["link" . $i], $dbReference, $processedData);
  1629. $item["href"] = $link["href"];
  1630. $item["linkTarget"] = $link["target"];
  1631. $item["text"] = $link["alt"];
  1632. if ($flex["image" . $i] == "1") {
  1633. $imgs = $this->processImagesTTContent($dbReference, 'mrm_be_cm_tileoverview', 'tt_content', 'flex_image_' . $i, 'uid', false);
  1634. $item["image"] = "#cdnurl#/" . $imgs[0]["sources"]["default_hero_lte600"];
  1635. }
  1636. $items[] = $item;
  1637. }
  1638. $subs[] = $this->createContentElement("tileoverview", array("items" => $items));
  1639. break;
  1640. case "mrm_be_cm_highlightbox":
  1641. $elements = $this->checkText($flex["text"], $dbReference, $processedData, "typo3_paragraph");
  1642. $subs[] = $this->createContentElement("highlightbox", array("icon" => $flex["icon"]), array(), $elements);
  1643. break;
  1644. case "mrm_be_cm_statementbox":
  1645. $items = array();
  1646. $dynContentCounter = 0;
  1647. while (1) {
  1648. $dynContentCounter++;
  1649. if (!isset($flex['text' . $dynContentCounter])) break;
  1650. if ($flex['text' . $dynContentCounter] === '' || $flex['name' . $dynContentCounter] === '') continue;
  1651. $item = array(
  1652. 'quote' => $flex['text' . $dynContentCounter],
  1653. 'cite' => $flex['name' . $dynContentCounter]
  1654. );
  1655. if ($flex['image' . $dynContentCounter] == 1) {
  1656. $imgs = $this->processImagesTTContent($dbReference, 'mrm_be_cm_statementbox', 'tt_content', 'flex_image_' . $dynContentCounter, 'uid', false);
  1657. $imgs = $imgs[0];
  1658. $imgs['src'] = "#cdnurl#/" . $imgs['sources']['img'];
  1659. unset($imgs['sources']);
  1660. $item['img'] = $imgs;
  1661. }
  1662. $items[] = $item;
  1663. }
  1664. $subs[] = $this->createContentElement('statementbox', array('items' => $items));
  1665. break;
  1666. case "mrm_be_cm_explorerbox":
  1667. $items = array();
  1668. $dynContentCounter = 0;
  1669. while (1) {
  1670. $dynContentCounter++;
  1671. if (!isset($flex['head' . $dynContentCounter])) break;
  1672. if ($flex['head' . $dynContentCounter] === '' || $flex['claim' . $dynContentCounter] === '' || $flex['image' . $dynContentCounter] == 0) continue;
  1673. $item = array(
  1674. 'heading' => $flex['head' . $dynContentCounter],
  1675. 'subheading' => $flex['claim' . $dynContentCounter],
  1676. 'text' => $flex['text' . $dynContentCounter]
  1677. );
  1678. if ($flex['image' . $dynContentCounter] == 1) {
  1679. $imgs = $this->processImagesTTContent($dbReference, 'mrm_be_cm_explorerbox', 'tt_content', 'flex_image_' . $dynContentCounter, 'uid', false);
  1680. $imgs = $imgs[0];
  1681. $imgs['src'] = "#cdnurl#/" . $imgs['sources']['img'];
  1682. unset($imgs['sources']);
  1683. $item['img'] = $imgs;
  1684. }
  1685. if ($flex['link' . $dynContentCounter] !== '') {
  1686. $button = $this->parseFlexFormLink($flex['link' . $dynContentCounter], $dbReference, $processedData);
  1687. $item['button'] = $button;
  1688. }
  1689. $items[] = $item;
  1690. }
  1691. $subs[] = $this->createContentElement('explorerbox', array('items' => $items));
  1692. break;
  1693. case "mrm_be_cm_dynamic_tileoverview":
  1694. $items = array();
  1695. foreach ($flex["dynamicComponents"] as $comp) {
  1696. foreach ($comp as $k => $v) {
  1697. $itm = null;
  1698. switch ($k) {
  1699. case "links":
  1700. $lnk = $this->parseFlexFormLink($v["link"], $dbReference, $processedData);
  1701. $itm = $this->createContentElement("tile_default", array("link" => $lnk, "coloured" => $v["coloured"] == 1, "allowed" => preg_split('/\+/', $v["type"]), "format" => $v["format"]));
  1702. if ($lnk["alt"]) $itm["props"]["headline"] = $lnk["alt"];
  1703. break;
  1704. case "buttons":
  1705. $itm = $this->createContentElement(
  1706. "tile_content",
  1707. array(
  1708. "headline" => $v["headline"],
  1709. "content" => $this->checkTextForInternalLinks($v["buttons"], $dbReference, $processedData)
  1710. )
  1711. );
  1712. break;
  1713. case "icons":
  1714. $lnk = $this->parseFlexFormLink($v["link"], $dbReference, $processedData);
  1715. $itm = $this->createContentElement("tile_icon", array("link" => $lnk, "icon" => $v["icon"]), array());
  1716. if ($lnk["alt"]) $itm["props"]["headline"] = $lnk["alt"];
  1717. break;
  1718. case "flat":
  1719. $lnk = $this->parseFlexFormLink($v["link"], $dbReference, $processedData);
  1720. $itm = $this->createContentElement("tile_flat", array("link" => $lnk));
  1721. if ($lnk["alt"]) $itm["props"]["headline"] = $lnk["alt"];
  1722. break;
  1723. case "injections":
  1724. $itm = $this->createContentElement("injection", array("type" => $v["text"]));
  1725. $processedData["injections"][] = $v["text"];
  1726. break;
  1727. }
  1728. if ($itm)
  1729. $items[] = $itm;
  1730. }
  1731. }
  1732. $dto = $this->createContentElement('dynamic_tileoverview', array(), array(), $items);
  1733. if ($flex["cssClass"] && $flex["cssClass"] !== "")
  1734. $dto["attributes"]["cssClassName"] = $flex["cssClass"];
  1735. $subs[] = $dto;
  1736. $processedData["status"]["hasDynamicTileOverview"] = true;
  1737. break;
  1738. case "mrm_be_cm_podcast":
  1739. //$items = array();
  1740. if ($flex['media'] == "1")
  1741. $media = $this->processAudio($dbReference, 'mrm_be_cm_podcast', 'tt_content', 'media', 'uid', true, true);
  1742. if ($flex['transcript'])
  1743. $transcript = $flex['transcript'];
  1744. $subs[] = $this->createContentElement('podcast', array(), array('media' => $media, 'transcript' => $transcript));
  1745. break;
  1746. case "mrm_be_cm_imageplus":
  1747. $props = $this->processImagesTTContent($dbReference)[0];
  1748. $props["type"] = "imageplus";
  1749. $props["headline"] = $flex['headline'] ?? '';
  1750. $props["description"] = $flex['description'] ?? '';
  1751. $props["link"] = $this->parseFlexFormLink($flex["link"], $dbReference, $processedData);
  1752. $props["customcss"] = $flex['customcss'] ?? '';
  1753. $subs[] = $this->createContentElement('imageplus', $props);
  1754. break;
  1755. case "mrm_be_cm_interviewfrage":
  1756. $props['lang'] = $flex['lang'] ?? '';
  1757. $subs[] = $this->createContentElement("interviewfrage", $props, array("question" => trim($flex['question'])));
  1758. break;
  1759. case "mrm_be_cm_interviewantwort":
  1760. $props['lang'] = $flex['lang'] ?? '';
  1761. $subs[] = $this->createContentElement("interviewantwort", $props, array("interviewee" => trim($flex['interviewee']), "answer" => trim($flex['answer'])));
  1762. break;
  1763. case "mrm_be_cm_foldout_h3":
  1764. $sub = $this->createContentElement("typo3_foldout_h3", array("open" => $flex["isInitialyOpen"] == "1", "noAutoOpen" => $flex["noAutoOpen"] == "1"), array("headline" => $flex["headline"]), array());
  1765. if ($flex["image"] == "1") {
  1766. $props = $this->processImagesTTContent($dbReference, "mrm_be_cm_contentimage")[0];
  1767. $props["type"] = "typo3_content";
  1768. $sub["subElements"][] = $this->createContentElement("image", $props);
  1769. } else {
  1770. switch ($flex["icon"]) {
  1771. case "1":
  1772. $sub["attributes"]["icon"] = "stadtinfo_basics";
  1773. break;
  1774. case "2":
  1775. $sub["attributes"]["icon"] = "geschichte";
  1776. break;
  1777. case "3":
  1778. $sub["attributes"]["icon"] = "kultur_freizeit";
  1779. break;
  1780. case "4":
  1781. $sub["attributes"]["icon"] = "besonderheiten";
  1782. break;
  1783. case "5":
  1784. $sub["attributes"]["icon"] = "kosten_geld";
  1785. break;
  1786. case "6":
  1787. $sub["attributes"]["icon"] = "hochschulen";
  1788. break;
  1789. case "7":
  1790. $sub["attributes"]["icon"] = "studieren";
  1791. break;
  1792. }
  1793. }
  1794. if ($flex["dynamicComponents"] && sizeof($flex["dynamicComponents"]) > 0)
  1795. foreach ($flex["dynamicComponents"] as $comp) {
  1796. $stype = array_keys($comp['settings'])[0];
  1797. $elements = $this->checkText($comp['settings'][$stype][$stype], $dbReference, $processedData, $stype == "paragraph" ? "typo3_paragraph" : ($stype == "headline" ? "h4" : $stype));
  1798. $sub["subElements"] = array_merge($sub["subElements"], $elements);
  1799. }
  1800. $subs[] = $sub;
  1801. break;
  1802. case "mrm_be_cm_quiz_direct":
  1803. //print_r($flex); die();
  1804. $s = $this->createContentElement(
  1805. "quizdirect",
  1806. array(
  1807. "labels" => array(
  1808. "startbutton" => $flex["startbuttontext"],
  1809. "submitbutton" => $flex["submitbuttontext"],
  1810. "nextbutton" => $flex["nextbuttontext"],
  1811. "lastbutton" => $flex["lastbuttontext"],
  1812. "question" => $flex["question"],
  1813. "repeatbutton" => $flex["repeatbuttontext"],
  1814. "qsuccess" => $flex["questionsuccesstext"],
  1815. "qfail" => $flex["questionfailtext"],
  1816. ),
  1817. "resultscreen" => array(
  1818. "headingTop" => $flex["resultheadingtop"],
  1819. "headingSub" => $flex["resultheadingsub"],
  1820. "validation" => $flex["validationstr"],
  1821. "end" => $flex["thanks"]
  1822. ),
  1823. "isRestartAble" => $flex["isRestartAble"] == 1 || $flex["isRestartAble"] == "1",
  1824. ),
  1825. array(
  1826. "items" => array_values(array_map(function ($v) {
  1827. $questionType = null;
  1828. $quest = $v['settings']['question'];
  1829. if (!isset($quest)) {
  1830. $quest = $v['settings']['question_multi'];
  1831. $questionType = "multi";
  1832. }
  1833. if (isset($quest["additional_text"]) && $quest["additional_text"] != "") {
  1834. $quest["text"] = $quest["text"] . " (" . $quest["additional_text"] . ")";
  1835. unset($quest["additional_text"]);
  1836. }
  1837. if ($questionType) $quest["type"] = $questionType;
  1838. unset($quest["rightanswer"]);
  1839. if (isset($quest['solutionText'])) $solution = $quest['solutionText'];
  1840. unset($quest['solutionText']);
  1841. $i = 0;
  1842. $quest["answers"] = array();
  1843. while (1) {
  1844. $i++;
  1845. if (!isset($quest["answertext" . $i])) break;
  1846. if ($quest["answertext" . $i] === "") continue;
  1847. $quest["answers"][] = array("text" => $quest["answertext" . $i], "points" => (int)$quest["answerpoints" . $i]);
  1848. unset($quest["answertext" . $i]);
  1849. unset($quest["answerpoints" . $i]);
  1850. }
  1851. $quest["solution"] = $solution;
  1852. return $quest;
  1853. }, $flex["dynamicComponents"])),
  1854. "validation" => array(
  1855. "maxPoints" => (int)$flex["maxpoints"],
  1856. "averagePoints" => $this->createContentElement("injection", array("type" => "quiz-averagePoints")),
  1857. "alreadyReachedPoints" => $this->createContentElement("injection", array("type" => "quiz-alreadyReachedPoints")),
  1858. "items" => ($flex["dynamicComponents2"] == 0) ? [] : array_map(
  1859. function ($i) {
  1860. if (empty($i["validationText"])) $i["validationText"] = "";
  1861. else $i["validationText"] = $this->checkTextForInternalLinks($i["validationText"], $dbReference, $processedData);
  1862. return $i;
  1863. },
  1864. array_filter(array_values(array_map(function ($v) {
  1865. return $v['settings']['validation'];
  1866. }, $flex["dynamicComponents2"])), function ($x) {
  1867. return $x != null;
  1868. })
  1869. ),
  1870. ),
  1871. )
  1872. );
  1873. $processedData["injections"][] = "quiz-averagePoints";
  1874. $processedData["injections"][] = "quiz-alreadyReachedPoints";
  1875. $subs[] = $s;
  1876. $processedData["status"]["hasQuiz"] = true;
  1877. break;
  1878. default:
  1879. $this->log("MISSING PROCESSDATA 4 " . $dbReference['CType']);
  1880. $this->log($flex, false);
  1881. break;
  1882. }
  1883. }
  1884. private function checkText($txt, $dbReference, &$processedData, $defaultElementType = "typo3_paragraph")
  1885. {
  1886. $txt = $this->checkTextForInternalLinks($txt, $dbReference, $processedData);
  1887. $txt = $this->refactorTextElements($txt, $defaultElementType);
  1888. return $txt;
  1889. }
  1890. private function refactorTextElements($txt, $defaultElementType)
  1891. {
  1892. if (strpos($txt, "<table") === FALSE) return [$this->createContentElement($defaultElementType, array(), array("text" => $txt))];
  1893. $elements = [];
  1894. while (($tablepos = strpos($txt, "<table")) !== FALSE) {
  1895. if ($tablepos != 0) {
  1896. //$this->log(trim(substr($txt, 0, $tablepos)));
  1897. $elements[] = $this->createContentElement($defaultElementType, array(), array("text" => trim(substr($txt, 0, $tablepos))));
  1898. $txt = substr($txt, $tablepos);
  1899. }
  1900. $tablepos = strpos($txt, "</table>") + 8;
  1901. $dom = new \DOMDocument();
  1902. @$dom->loadHTML('<?xml encoding="utf-8" ?><div id="sexy">' . trim(substr($txt, 0, $tablepos)) . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  1903. $tab = $this->createContentElement("table", array("rows" => array(), "columnCount" => 0));
  1904. foreach ($dom->getElementsByTagName('tr') as $tr) {
  1905. $par = $tr->parentNode;
  1906. $row = [];
  1907. if ($tab["props"]["columnCount"] == 0) {
  1908. foreach ($tr->childNodes as $e) {
  1909. if ($e->tagName == "td" || $e->tagName == "th") {
  1910. $tab["props"]["columnCount"]++;
  1911. }
  1912. }
  1913. }
  1914. foreach ($tr->childNodes as $e) {
  1915. if ($e->tagName != "td" && $e->tagName != "th") continue;
  1916. $innerHTML = '';
  1917. foreach ($e->childNodes as $n) $innerHTML .= $dom->saveHtml($n);
  1918. $row[] = array(
  1919. "html" => "<p>" . $innerHTML . "</p>",
  1920. "isHeader" => $par->tagName == "thead",
  1921. "isRowHeader" => $e->tagName == "th" && $par->tagName != "thead",
  1922. );
  1923. }
  1924. $tab["props"]["rows"][] = $row;
  1925. }
  1926. $elements[] = $tab;
  1927. $txt = substr($txt, $tablepos);
  1928. }
  1929. $txt = trim($txt);
  1930. if ($txt != "")
  1931. $elements[] = $this->createContentElement($defaultElementType, array(), array("text" => $txt));
  1932. return $elements;
  1933. }
  1934. private function checkTextForInternalLinks($txt, $dbReference, &$processedData)
  1935. {
  1936. $dom = new \DOMDocument();
  1937. @$dom->loadHTML('<?xml encoding="utf-8" ?><div id="sexy">' . $txt . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  1938. foreach ($dom->getElementsByTagName('a') as $link) {
  1939. $emptyHref = false;
  1940. $title = null;
  1941. $alt = null;
  1942. $href = null;
  1943. for ($i = 0; $i < $link->attributes->length; ++$i) {
  1944. $node = $link->attributes->item($i);
  1945. if ($node->nodeName == "href" && strpos($node->nodeValue, 'smartadserver.com') === FALSE) {
  1946. $nv = $node->nodeValue;
  1947. $nv = str_replace('&amp;', '&', $nv);
  1948. $href = $this->replaceT3Link($nv, $dbReference, $processedData);
  1949. $node->nodeValue = htmlspecialchars($href);
  1950. if ($node->nodeValue == '') $emptyHref = true;
  1951. }
  1952. if ($node->nodeName == "title" && $node->nodeValue != '') $title = $node->nodeValue;
  1953. if ($node->nodeName == "alt" && $node->nodeValue != '') $alt = $node->nodeValue;
  1954. }
  1955. if ($emptyHref) $link->removeAttribute('href');
  1956. else {
  1957. if (!$alt) {
  1958. //check for pdf files (AS-337)
  1959. if (strtolower(pathinfo($href, PATHINFO_EXTENSION)) == "pdf") {
  1960. $alt = "PDF-Download (öffnet sich in neuem Fenster)";
  1961. $link->setAttribute('target', '_blank');
  1962. $link->setAttribute('alt', $alt);
  1963. }
  1964. }
  1965. }
  1966. if ($title && !$alt) $link->setAttribute('alt', $title);
  1967. if ($title) $link->removeAttribute('title');
  1968. }
  1969. $txt = $dom->saveHTML($dom->getElementById('sexy'));
  1970. $txt = str_replace('<div id="sexy">', '', $txt);
  1971. $txt = substr($txt, 0, -6);
  1972. return trim($txt);
  1973. }
  1974. private function parseFlexFormLink($link, $dbReference, &$processedData)
  1975. {
  1976. $link = implode("/", explode("\/", $link));
  1977. [$href, $target, $css] = explode(" ", $link);
  1978. $alt = substr($link, strlen($href . $target . $css) + 3);
  1979. $alt = preg_replace('/&quot;/', '', trim($alt, " \""));
  1980. if ($href == "-") return null;
  1981. $href = $this->replaceT3Link($href, $dbReference, $processedData, true);
  1982. $ret = array("href" => $href);
  1983. if (!$target || $target == "-") $ret["target"] = "_top";
  1984. else $ret["target"] = $target;
  1985. if ($alt && $alt != "-") $ret["alt"] = $alt;
  1986. return $ret;
  1987. }
  1988. private function replaceT3Link($link, $dbReference, &$processedData, $addToLinkedPosts = false)
  1989. {
  1990. $uid = $this->parseUIDFromT3Url($link);
  1991. if (!$uid || $uid == '') return $link;
  1992. if (strpos($link, 't3://page?') !== false) {
  1993. if ($uid == "current") {
  1994. $link = str_replace('t3://page?uid=current', '', $link);
  1995. } else {
  1996. if ($addToLinkedPosts) {
  1997. $processedData['linkedPosts'][] = (int)$uid;
  1998. $link = "#linkedPost#" . $uid . "#/linkedPost#";
  1999. } else {
  2000. $pageStatement = $this->pageQueryBuilder
  2001. ->select('*')
  2002. ->from('pages')
  2003. ->setMaxResults(1)
  2004. ->where(
  2005. $this->pageQueryBuilder->expr()->eq('uid', $this->pageQueryBuilder->createNamedParameter($uid))
  2006. )
  2007. ->execute();
  2008. $post = $pageStatement->fetchAll();
  2009. $post = $post[0];
  2010. $link = $post['slug'];
  2011. }
  2012. }
  2013. }
  2014. if (strpos($link, 't3://file?') !== false)
  2015. $link = $this->setStaticFile($dbReference, $uid);
  2016. return $link;
  2017. }
  2018. private function setStaticFile($dbReference, $uid, $publicUrl = null)
  2019. {
  2020. $fnNameRef = $dbReference['pid'] . "|" . $dbReference['uid'] . "|" . $dbReference['CType'] . "|file|" . $uid;
  2021. if (!$publicUrl) {
  2022. $file = $this->resourceFactory->getFileObject($uid);
  2023. $publicUrl = $file->getPublicUrl();
  2024. }
  2025. try {
  2026. $fnName = basename($publicUrl);
  2027. $fnName = explode(".", $fnName);
  2028. $extension = array_pop($fnName);
  2029. $fnName = implode(".", $fnName);
  2030. } catch (Exception $e) {
  2031. $fnName = null;
  2032. }
  2033. return "#cdnurl#/" . $this->copyAndRenameFile($fnNameRef, "/" . $publicUrl, $fnName);
  2034. }
  2035. private function parseUIDFromT3Url($t3url)
  2036. {
  2037. $uid = null;
  2038. if ($t3url && $t3url != '' && substr($t3url, 0, 2) == "t3")
  2039. try {
  2040. parse_str(parse_url($t3url)['query'], $query);
  2041. $uid = $query['uid'];
  2042. } catch (Exception $e) {
  2043. }
  2044. return $uid;
  2045. }
  2046. private function createContentElement($type, $props = null, $attributes = null, $subElements = null)
  2047. {
  2048. if (is_null($props)) $props = array();
  2049. if (is_null($attributes)) $attributes = (object) array();
  2050. $props["__hbs_uid"] = '_ab' . mt_rand(0, 0xffffff) . '_' . mt_rand(0, 0xffffff);
  2051. $ele = array(
  2052. 'type' => $type,
  2053. 'props' => $props,
  2054. 'attributes' => $attributes,
  2055. );
  2056. if (!is_null($subElements)) $ele['subElements'] = $subElements;
  2057. else $ele['subElements'] = [];
  2058. return $ele;
  2059. }
  2060. private function processVideo($dbReference)
  2061. {
  2062. $data = $this->resourceFactory->convertFlexFormDataToConfigurationArray($dbReference['pi_flexform']);
  2063. $vids = array();
  2064. foreach ($data['settings']['video'] as $value) {
  2065. if ($value['posterConfiguration'] && $value['posterConfiguration'] != '') $vids['poster'] = $value['posterConfiguration']['image'];
  2066. if ($value['mp4Configuration'] && $value['mp4Configuration'] != '') $vids['mp4'] = $value['mp4Configuration']['video'];
  2067. if ($value['ogvConfiguration'] && $value['ogvConfiguration'] != '') $vids['ogv'] = $value['ogvConfiguration']['video'];
  2068. if ($value['webmConfiguration'] && $value['webmConfiguration'] != '') $vids['webm'] = $value['webmConfiguration']['video'];
  2069. if ($value['threegpConfiguration'] && $value['threegpConfiguration'] != '') $vids['3gp'] = $value['threegpConfiguration']['video'];
  2070. }
  2071. foreach ($vids as $key => &$value) {
  2072. $value = "/" . $value;
  2073. $fnNameRef = $dbReference['pid'] . "|" . $dbReference['uid'] . "|" . $dbReference['CType'] . "|" . $key;
  2074. $value = $this->copyAndRenameFile($fnNameRef, $value);
  2075. }
  2076. return $vids;
  2077. }
  2078. private function processImagesTTContent($dbReference, $ctypeOverride = '', $table = 'tt_content', $tableColumn = 'image', $refField = 'uid', $useRelationFetch = true, $addCDNPrefix = false)
  2079. {
  2080. if ($useRelationFetch)
  2081. $fileObjects = $this->fileRepository->findByRelation($table, $tableColumn, $dbReference[$refField]);
  2082. else {
  2083. $sysfilerefQueryBuilder = $this->connection->getQueryBuilderForTable('sys_file_reference');
  2084. $sysfileStatement = $sysfilerefQueryBuilder
  2085. ->select('uid')
  2086. ->from('sys_file_reference')
  2087. ->andWhere(
  2088. $sysfilerefQueryBuilder->expr()->eq('uid_foreign', intval($dbReference[$refField])),
  2089. $sysfilerefQueryBuilder->expr()->eq('tablenames', $sysfilerefQueryBuilder->createNamedParameter($table)),
  2090. $sysfilerefQueryBuilder->expr()->eq('fieldname', $sysfilerefQueryBuilder->createNamedParameter($tableColumn)),
  2091. )
  2092. ->execute();
  2093. $frows = $sysfileStatement->fetchAll();
  2094. foreach ($frows as $fileuid) {
  2095. $fileObjects[] = $this->fileRepository->findFileReferenceByUid(intval($fileuid['uid']));
  2096. }
  2097. }
  2098. $processedImages = array();
  2099. $ctypeOverride = $ctypeOverride != '' ? $ctypeOverride : $dbReference['CType'];
  2100. foreach ($fileObjects as $key => $value) {
  2101. $img = array(
  2102. 'reference' => $value->getReferenceProperties(),
  2103. 'original' => $value->getOriginalFile()->getProperties(),
  2104. );
  2105. $imgfn = rtrim($img['original']['identifier'], "/");
  2106. $image = $this->imageService->getImage('fileadmin/' . $imgfn, null, false);
  2107. $cropvariantcollection = \TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection::create($img['reference']['crop']);
  2108. $cropareas = $this->imageSizes[$ctypeOverride];
  2109. $processArray = array(
  2110. 'sources' => array()
  2111. );
  2112. $alt = $img['reference']['alternative'] != NULL ? $img['reference']['alternative'] : ($img['original']['alternative'] != NULL ? $img['original']['alternative'] : NULL);
  2113. $title = $img['reference']['title'] != NULL ? $img['reference']['title'] : ($img['original']['title'] != NULL ? $img['original']['title'] : NULL);
  2114. $caption = $img['reference']['description'] != NULL ? $img['reference']['description'] : ($img['original']['description'] != NULL ? $img['original']['description'] : NULL);
  2115. $copyright = $img['reference']['copyright'] != NULL ? $img['reference']['copyright'] : ($img['original']['copyright'] != NULL ? $img['original']['copyright'] : NULL);
  2116. if ($alt != NULL) $processArray['alt'] = $alt;
  2117. if ($title != NULL) $processArray['title'] = $title;
  2118. if ($caption != NULL) $processArray['caption'] = $caption;
  2119. if ($copyright != NULL) $processArray['copyright'] = $copyright;
  2120. if ($cropareas['passthru']) {
  2121. if (is_array($cropareas['passthru'])) {
  2122. foreach ($cropareas['passthru'] as $sizename => $size) {
  2123. $processingInstructions = array(
  2124. 'width' => $size['width'],
  2125. 'minWidth' => $size['width'],
  2126. 'maxWidth' => $size['width'],
  2127. 'crop' => null
  2128. );
  2129. if ($size['height']) {
  2130. $processingInstructions = array_merge(
  2131. $processingInstructions,
  2132. array(
  2133. 'height' => $size['height'],
  2134. 'minHeight' => $size['height'],
  2135. 'maxHeight' => $size['height']
  2136. )
  2137. );
  2138. }
  2139. if ($size['maxHeight'])
  2140. $processingInstructions['maxHeight'] = $size['maxHeight'];
  2141. if ($size['minHeight'])
  2142. $processingInstructions['minHeight'] = $size['minHeight'];
  2143. $processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);
  2144. $imageUri = $this->imageService->getImageUri($processedImage);
  2145. $fnNameRef = $dbReference['pid'] . "|" . $dbReference['uid'] . "|" . $ctypeOverride . "|" . $img['reference']['uid'] . "|passthru|" . $sizename;
  2146. $processArray['sources'][$sizename] = $this->copyAndRenameFile($fnNameRef, $imageUri, $processArray['alt']);
  2147. }
  2148. } else {
  2149. $fnNameRef = $dbReference['pid'] . "|" . $dbReference['uid'] . "|" . $ctypeOverride . "|" . $img['reference']['uid'] . "|passthru";
  2150. $imageUri = $this->imageService->getImageUri($image);
  2151. $processArray['sources']['passthru'] = ($addCDNPrefix ? "#cdnurl#/" : "") . $this->copyAndRenameFile($fnNameRef, $imageUri, $processArray['alt']);
  2152. }
  2153. } else
  2154. foreach ($cropareas as $cropareaname => $sizes) {
  2155. $croparea = $cropvariantcollection->getCropArea($cropareaname);
  2156. foreach ($sizes as $sizename => $size) {
  2157. if ($dbReference["doktype"] && $size['allowed_doktypes'] && !in_array($dbReference["doktype"], $size['allowed_doktypes'])) continue;
  2158. $processingInstructions = array(
  2159. 'width' => $size['width'],
  2160. 'minWidth' => $size['width'],
  2161. 'maxWidth' => $size['width'],
  2162. 'crop' => $croparea->isEmpty() ? null : $croparea->makeAbsoluteBasedOnFile($image)
  2163. );
  2164. if ($size['height']) {
  2165. $processingInstructions = array_merge(
  2166. $processingInstructions,
  2167. array(
  2168. 'height' => $size['height'],
  2169. 'minHeight' => $size['height'],
  2170. 'maxHeight' => $size['height']
  2171. )
  2172. );
  2173. }
  2174. if ($size['maxHeight'])
  2175. $processingInstructions['maxHeight'] = $size['maxHeight'];
  2176. if ($size['minHeight'])
  2177. $processingInstructions['minHeight'] = $size['minHeight'];
  2178. $processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);
  2179. $imageUri = $this->imageService->getImageUri($processedImage);
  2180. $fnNameRef = $dbReference['pid'] . "|" . $dbReference['uid'] . "|" . $ctypeOverride . "|" . $img['reference']['uid'] . "|" . $cropareaname . "|" . $sizename;
  2181. $processArray['sources'][$sizename] = ($addCDNPrefix ? "#cdnurl#/" : "") . $this->copyAndRenameFile($fnNameRef, $imageUri, $processArray['alt']);
  2182. }
  2183. }
  2184. $processedImages[] = $processArray;
  2185. }
  2186. return $processedImages;
  2187. }
  2188. private function processAudio($dbReference, $ctypeOverride = '', $table = 'tt_content', $tableColumn = 'media', $refField = 'uid', $useRelationFetch = true, $copyToCDN = false)
  2189. {
  2190. if ($useRelationFetch)
  2191. $fileObjects = $this->fileRepository->findByRelation($table, $tableColumn, $dbReference[$refField]);
  2192. else {
  2193. $sysfilerefQueryBuilder = $this->connection->getQueryBuilderForTable('sys_file_reference');
  2194. $sysfileStatement = $sysfilerefQueryBuilder
  2195. ->select('uid')
  2196. ->from('sys_file_reference')
  2197. ->andWhere(
  2198. $sysfilerefQueryBuilder->expr()->eq('uid_foreign', intval($dbReference[$refField])),
  2199. $sysfilerefQueryBuilder->expr()->eq('tablenames', $sysfilerefQueryBuilder->createNamedParameter($table)),
  2200. $sysfilerefQueryBuilder->expr()->eq('fieldname', $sysfilerefQueryBuilder->createNamedParameter($tableColumn)),
  2201. )
  2202. ->execute();
  2203. $frows = $sysfileStatement->fetchAll();
  2204. foreach ($frows as $fileuid) {
  2205. $fileObjects[] = $this->fileRepository->findFileReferenceByUid(intval($fileuid['uid']));
  2206. }
  2207. }
  2208. $processedAudio = array();
  2209. $audio = [];
  2210. $ctypeOverride = $ctypeOverride != '' ? $ctypeOverride : $dbReference['CType'];
  2211. foreach ($fileObjects as $key => $value) {
  2212. $processedAudio = array(
  2213. 'reference' => $value->getReferenceProperties(),
  2214. 'original' => $value->getOriginalFile()->getProperties(),
  2215. );
  2216. if ($copyToCDN) {
  2217. $oringalFile = $processedAudio['original']['identifier'];
  2218. $extension = pathinfo($processedAudio['original']['identifier'], PATHINFO_EXTENSION);
  2219. $targetFile = substr(sha1($processedAudio['original']['identifier']), 0, 5) . '_podcast.' . $extension;
  2220. $oringalFile = '/fileadmin' . $oringalFile;
  2221. $url = $this->copyPodcastAudioFileToCDN($oringalFile, $targetFile);
  2222. }
  2223. $audio['name'] = $processedAudio['original']['name'];
  2224. $audio['url'] = $url;
  2225. $audio['title'] = $processedAudio['reference']['title'];
  2226. $audio['description'] = $processedAudio['reference']['description'];
  2227. }
  2228. return $audio;
  2229. }
  2230. private function copyAndRenameFile($destinationFnRef, $sourceUri, $altText = null)
  2231. {
  2232. $shaFileRef = sha1($destinationFnRef);
  2233. $workPath = substr($shaFileRef, 0, 2) . "/" . substr($shaFileRef, 2, 2);
  2234. $workFnPrefix = $shaFileRef;
  2235. if ($altText) {
  2236. $altText = substr($altText, 0, 100);
  2237. $workFnPrefix = $this->sanitizeString($altText) . "-" . $shaFileRef;
  2238. }
  2239. $workFn = $workFnPrefix . "." . pathinfo($sourceUri, PATHINFO_EXTENSION);
  2240. if (!file_exists(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $workPath)) {
  2241. mkdir(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $workPath, 0777, true);
  2242. }
  2243. copy(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . $sourceUri, \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $workPath . '/' . $workFn);
  2244. return $workPath . '/' . $workFn;
  2245. }
  2246. private function copyPodcastAudioFileToCDN($sourceFile, $destinationFile)
  2247. {
  2248. $dir = 'podcast';
  2249. if (!file_exists(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $dir)) {
  2250. mkdir(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $dir, 0777, true);
  2251. }
  2252. copy(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . $sourceFile, \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/cdn/' . $dir . '/' . $destinationFile);
  2253. return '#cdnurl#/' . $dir . '/' . $destinationFile;
  2254. }
  2255. public function processCmdmap_deleteAction($table, $id, $recordToDelete, $recordWasDeleted = NULL, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj)
  2256. {
  2257. //$this->log('processCmdmap_deleteAction');
  2258. if ($table == "pages") {
  2259. Mongoer::sendRequest("pages", "delete", array("pageuid" => $id));
  2260. Mongoer::sendRequest("abialtcache", "delete", array("pageuid" => $pid));
  2261. Mongoer::sendRequest("search", "delete", array("pageuid" => $id));
  2262. Mongoer::sendRequest("security", "delete", array("pageuid" => $id));
  2263. Mongoer::sendRequest("previews", "delete", array("pageuid" => $id));
  2264. }
  2265. }
  2266. /* PRIVATES */
  2267. private function log($msg, $isString = true)
  2268. {
  2269. if (!$isString) {
  2270. $msg = json_encode($msg, JSON_PRETTY_PRINT);
  2271. }
  2272. file_put_contents('/var/www/html/public/typo3temp/debug.log', $msg . PHP_EOL, FILE_APPEND);
  2273. }
  2274. }