Exemplo n.º 1
0
 public function serialize(IResource $resource)
 {
     $snippet = $resource->getCleanFields()['snippet'];
     $snippet = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*\$/", "\n", $snippet);
     // remove empty lines from the end
     //$snippet = preg_replace("/\r\n/", "\n", $snippet); // remove empty lines from the end
     $snippet = preg_replace('/^\\s+$/s', "\n", $snippet);
     $content = Templating::render('php.html.twig', ['comment_data' => $resource->getStringInfo(), 'content' => $snippet]);
     return $content;
 }
Exemplo n.º 2
0
 public function compare(IResource $resourceA, IResource $resourceB)
 {
     $data_a = $resourceA->getCleanFields();
     $data_b = $resourceB->getCleanFields();
     $a = explode("\n", $data_a['snippet']);
     $b = explode("\n", $data_b['snippet']);
     $d = new \Diff($a, $b, []);
     $renderer = new \Diff_Renderer_Html_SideBySide();
     $diffc = $d->render($renderer);
     return !empty($diffc);
 }
Exemplo n.º 3
0
 public function insert(IResource $resource)
 {
     try {
         if (ResourceType::TV === $resource->getType()) {
             $tv_data = $resource->getRawData();
             unset($tv_data['content_values'], $tv_data['templates']);
             $this->connection->insertQuery()->table($this->table_map[$resource->getType()])->data($tv_data)->execute();
             $templates = [];
             foreach ($resource->getTemplates() as $templateid) {
                 $templates[] = [$templateid, $resource->getId()];
             }
             if (count($templates)) {
                 $this->connection->insertQuery()->table($this->tv_templates_table)->batchData(['templateid', 'tmplvarid'], $templates)->execute();
             }
             $content_values = [];
             foreach ($resource->getContentValues() as $contentid => $value) {
                 $content_values[] = [$contentid, $resource->getId(), $value];
             }
             if (count($content_values)) {
                 $this->connection->insertQuery()->table($this->tv_content_values_table)->batchData(['contentid', 'tmplvarid', 'value'], $content_values)->execute();
             }
         } else {
             $this->connection->insertQuery()->table($this->table_map[$resource->getType()])->data($resource->getRawData())->execute();
         }
     } catch (\Exception $ex) {
         die(dump($resource, $ex->getMessage()));
     }
 }
Exemplo n.º 4
0
 public function serialize(IResource $resource)
 {
     $content = Templating::render('simple.html.twig', ['data' => $resource->getStringInfo()]);
     return $content;
 }
Exemplo n.º 5
0
 public function serialize(IResource $resource)
 {
     $content = Templating::render('raw.html.twig', ['comment_data' => $resource->getStringInfo(), 'content' => $resource->getContent()]);
     return $content;
 }