Booking, QI Content, Trees, Media

This commit is contained in:
Kevin Adametz 2019-10-02 20:03:55 +02:00
parent 1f340e96fa
commit 7fbac395a9
260 changed files with 27160 additions and 3773 deletions

View file

@ -0,0 +1,171 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
use App\Models\TravelGuide;
class CMSContentController extends Controller
{
public $successStatus = 200;
public function search()
{
$request = \Request::all();
if(!isset($request['url']) || !isset($request['key'])){
return response()->json(['error' => "request no found"], $this->successStatus);
}
if($request['key'] != 'f6077389c9ce710e554763a5de02c8ec'){
return response()->json(['error' => "key"], 401);
}
$urlArray = explode('/', $request['url']);
$ret = [];
if(is_array($urlArray)){
//tree
$tree_identifier = array_shift($urlArray);
$tree = IQContentTree::whereIdentifier($tree_identifier)->first();
$travel_guide = null;
$url = "";
if($tree){
$lvl = 0;
$ret['tree'] = $tree->toArray();
$ret['navi'] = $this->makeNaviTree($tree, $urlArray, "", 0, false);
$url = "/".$tree->identifier;
$ret['bread_crumb'][$lvl] = [
'title' => $tree->name,
'url' => $url,
];
while (!empty($urlArray))
{
$tree_node_identifier = array_shift($urlArray);
$tree_node = IQContentTreeNode::whereTreeId($tree->id)->whereIdentifier($tree_node_identifier)->whereLvl($lvl)->whereActive(true)->first();
if($tree_node){
$url = $url."/".$tree_node->identifier;
$ret['bread_crumb'][$lvl] = [
'title' => $tree_node->name,
'url' => $url,
];
$ret['nodes'][$lvl] = $tree_node->toArray();
$lvl ++;
}else{
return response()->json(['error' => 'no-node'], $this->successStatus);
}
}
if(isset($ret['nodes']) && is_array($ret['nodes'])){
//sites
if($tree_node->iq_content_sites->count()){
foreach ($tree_node->iq_content_sites as $iq_content_site){
if(isset($iq_content_site->travel_guide) && $iq_content_site->travel_guide && $iq_content_site->travel_guide->active){
$ret['sites'][] = $iq_content_site->travel_guide->toArray();
/*if(!$travel_guide){
//$travel_guide = $iq_content_site->travel_guide;
}*/
}
}
}
//children
if($tree_node->iq_content_tree_node_childs->count()){
foreach ($tree_node->iq_content_tree_node_childs as $iq_content_tree_node_child){
if($iq_content_tree_node_child->active){
$travel_guide = $iq_content_tree_node_child->iq_content_site_first();
$ret['children'][] = [
'name' => $iq_content_tree_node_child->name,
'identifier' => $iq_content_tree_node_child->identifier,
'url' => "/".$iq_content_tree_node_child->getUri(),
'box_image_url' => $travel_guide ? $travel_guide->box_image_url : '',
'description' => $travel_guide ? $travel_guide->meta_description : '',
'active' => $travel_guide ? $travel_guide->active : false,
];
}
}
}
return response()->json(['success' => "node", "ret"=>$ret], $this->successStatus);
}else{
return response()->json(['error' => 'no-node'], $this->successStatus);
}
}else{
return response()->json(['error' => 'no-tree'], $this->successStatus);
}
}
return response()->json(['error' => "not-found"], $this->successStatus);
}
public function keywords(){
$request = \Request::all();
if(!isset($request['key'])){
return response()->json(['error' => "request no found"], $this->successStatus);
}
if($request['key'] != 'f6077389c9ce710e554763a5de02c8ec'){
return response()->json(['error' => "key"], 401);
}
$ret = [];
$travel_guides = TravelGuide::whereNotNull('keyword')->where('active', true)->get();
foreach ($travel_guides as $travel_guide){
$tree_node = $travel_guide->iq_content_tree_node_first();
if($tree_node){
$ret[$travel_guide->keyword] = $tree_node->getUri();
}
}
return response()->json(['success' => "node", "ret"=>$ret], $this->successStatus);
}
public function makeNaviTree(IQContentTree $iq_content_tree, $urlArray = [], $url = "", $lvl = 0, $parent_id = false)
{
$link = false;
if (!empty($urlArray[$lvl])) {
$link = ($urlArray[$lvl]);
}
if ($parent_id) {
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->where('parent_id', $parent_id)->orderBy('pos', 'ASC')->get();
} else {
$url = "/" . $iq_content_tree->identifier . "/";
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->orderBy('pos', 'ASC')->get();
}
$out = [];
foreach ($tree_nodes as $node) {
$children = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl + 1)->where('active', true)->where('parent_id', $node->id)->count();
$out[] = [
'lvl' => $lvl,
'name' => $node->name,
'url' => $url . $node->identifier,
'active' => $link == $node->identifier ? true : false,
// 'children' => $this->makeNaviTree($iq_content_tree, $urlArray, $url . $node->identifier . "/", $lvl + 1, $node->id),
];
$tmp = [];
if ($children) {
$tmp = $this->makeNaviTree($iq_content_tree, $urlArray, $url . $node->identifier . "/", $lvl + 1, $node->id);
$out = array_merge($out, $tmp);
}
}
return $out;
}
}

View file

@ -348,13 +348,18 @@ class DraftController extends Controller
$this->option = $travel_option['name'];
$service = $this->replaceService($service);
/*
* if($travel_option['children'] < 1){
$travel_option['price_children'] = 0;
}
*/
$price_info_travel_options[] = [
'booking_id' => $data['booking_id'],
'travel_program_id' => $data['travel_program_id'],
'fewo_lodging_id' => null,
'travel_class_id' => null,
'draft_item_id' => null,
'draft_type_id' => 34,
'draft_type_id' => 41,
'request_date' => $data['request_date'],
'days_start' => null,
'days_duration' => null,

View file

@ -12,6 +12,7 @@ use App\User;
use Illuminate\Support\Facades\Mail;
use Input;
use Request;
use UniSharp\LaravelFilemanager\LaravelFilemanagerServiceProvider;
use Validator;
use DataTables;
@ -168,7 +169,7 @@ class AdminUserController extends Controller
return '<a href="' . route('admin_user_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
})
->addColumn('admin', function (User $user) {
return '<a href="#" data-url="'.route('admin_user_load_modal', $user->id).'" data-data="'.$user->id.'" class="update_modal_data_show">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
return '<a href="#" data-url="'.route('admin_user_load_modal', $user->id).'" data-data="'.$user->id.'" class="update_modal_data_show">'.HTMLHelper::getRoleLabel($user->admin, '<i class="fa fa-edit"></i> Rechte + ','').'</a>';
})
->addColumn('confirmed', function (User $user) {
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';

View file

@ -101,20 +101,21 @@ class BookingController extends Controller
if(isset($data['draft_item'])){
foreach ($data['draft_item'] as $booking_draft_item_id => $draft_item){
$di = BookingDraftItem::findOrFail($booking_draft_item_id);
$di->draft_type_id = $draft_item['draft_type_id'];
$di->start_date = $draft_item['start_date'];
$di->end_date = $draft_item['end_date'];
if(isset($draft_item['days_duration'])){
$di->days_duration = $draft_item['days_duration'];
}
if(isset($draft_item['price'])){
$di->price = $draft_item['price'];
}
$di->service = $draft_item['service'];
$di->in_pdf = isset($draft_item['in_pdf']) ? true : false;
$di->pos = $i++;
$di->save();
$BookingDraftItem = BookingDraftItem::findOrFail($booking_draft_item_id);
$draft_item['price_adult'] = isset($draft_item['price_adult']) ? $draft_item['price_adult'] : null;
$draft_item['adult'] = isset($draft_item['adult']) ? $draft_item['adult'] : null;
$draft_item['price_children'] = isset($draft_item['price_children']) ? $draft_item['price_children'] : null;
$draft_item['children'] = isset($draft_item['children']) ? $draft_item['children'] : null;
$draft_item['price'] = isset($draft_item['price']) ? $draft_item['price'] : null;
$draft_item['pos'] = $i++;
$draft_item['in_pdf'] = isset($draft_item['in_pdf']) ? true : false;
$BookingDraftItem->fill($draft_item);
$BookingDraftItem->save();
}
}
@ -151,6 +152,9 @@ class BookingController extends Controller
'comfort' => $comfort
]);
}
$booking->calculate_price_total();
if(strpos($data['action'], 'up_') !== false) {
$reId = intval(str_replace('up_', '', $data['action']));
$d_from = BookingDraftItem::findOrFail($reId);
@ -182,10 +186,12 @@ class BookingController extends Controller
public function draftItemDelete($id){
$boking_draft_item = BookingDraftItem::findOrFail($id);
$booking_id = $boking_draft_item->booking_id;
$booking = $boking_draft_item->booking;
$boking_draft_item->delete();
$booking->calculate_price_total();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('booking_detail', [$booking_id]));
return redirect(route('booking_detail', [$booking->id]));
}

View file

@ -32,7 +32,7 @@ class CMSContentController extends Controller
$data = [
'contents' => CMSContent::all()->sortByDesc('id')
];
return view('cms.content.index', $data);
return view('cms.content.all.index', $data);
}
@ -58,7 +58,7 @@ class CMSContentController extends Controller
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_content'));
return redirect(route('cms_content_all'));
}
@ -74,7 +74,7 @@ class CMSContentController extends Controller
}else {
$value = CMSContent::find($data['id']);
}
$returnHTML = view("cms.content.modal", compact('data','value') )->render();
$returnHTML = view("cms.content.all.modal", compact('data','value') )->render();
}
}
@ -88,7 +88,7 @@ class CMSContentController extends Controller
$content = CMSContent::findOrFail($id);
$content->delete();
\Session()->flash('alert-success', __('Content gelöscht'));
return redirect(route('cms_content'));
return redirect(route('cms_content_all'));
}

View file

@ -0,0 +1,80 @@
<?php
namespace App\Http\Controllers\CMS;
use App\Http\Controllers\Controller;
use App\Models\CMSContent;
use App\Models\TravelCountry;
use App\Models\TravelNationality;
use Input;
use Request;
use Validator;
class CMSContentCountryController extends Controller
{
/*
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('admin');
}
public function index($step = false)
{
$data = [
'travel_countries' => TravelCountry::all(),
];
return view('cms.content.country.index', $data);
}
public function detail($id, $step = false)
{
$model = TravelCountry::findOrFail($id);
$id = $model->id;
$data = [
'model' => $model,
'id' => $id,
'step' => $step,
'travel_nationalities' => TravelNationality::where('active', true)->get(),
];
return view('cms.content.country.detail', $data);
}
public function store($id)
{
$data = Input::all();
$model = TravelCountry::findOrFail($id);
$model->fill($data);
$model->save();
//travel_nationality_requirement
if (isset($data['travel_nationality_requirement'])) {
foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text) {
$model->setNationalityRequirement($travel_nationality_id, $text);
}
}
//TODO for this time
if ($data['action'] == 'contact') {
//we need an update in the old CRM v1 system DB
$tc = \App\Models\Sym\TravelCountry::findOrFail($model->crm_id);
$tc->fill($data);
$tc->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_content_country_detail', [$model->id, $data['action']]));
}
}

View file

@ -72,7 +72,7 @@ class CMSTravelGuideController extends Controller
}
if(Input::get('clean') == "true"){
$model->full_text = $this->cleanHTML($model->full_text);
$model->full_text = \App\Services\Util::cleanHTML($model->full_text);
}
@ -84,52 +84,8 @@ class CMSTravelGuideController extends Controller
}
public function cleanHTML($html)
{
$html = str_replace('font-size: 14px;', ' ', $html);
$html = str_replace('font-weight: lighter; ', ' ', $html);
$html = str_replace('font-family: Helvetica, Arial, sans-serif; ', ' ', $html);
$html = str_replace('font-family: Verdana, sans-serif; ', ' ', $html);
$html = str_replace('color: rgb(60, 60, 60); ', ' ', $html);
$html = str_replace(' style=" padding: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 20px !important; line-height: 20px !important;"', ' ', $html);
$html = str_replace('property="article"', ' ', $html);
$html = str_replace('&nbsp;', ' ', $html);
$html = str_replace('https://www.aegypten-online.de', 'https://www.sterntours.de', $html);
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
$removeFullTags = ['span', 'a'];
foreach ($removeFullTags as $removeFullTag){
$domElemsToRemove = [];
$elements = $dom->getElementsByTagName($removeFullTag);
foreach ($elements as $element) {
$domElemsToRemove[] = $element;
}
foreach ($domElemsToRemove as $domElem) {
if($removeFullTag == 'span' && strpos($domElem->getAttribute('style'), 'font-weight: 700') !== false){
$new_node = $dom->createTextNode("<strong>".$domElem->nodeValue."</strong>");
}else{
$new_node = $dom->createTextNode($domElem->nodeValue);
}
$domElem->parentNode->replaceChild($new_node, $domElem);
}
}
$removeStyleTags = ['ul', 'li', 'h1', 'h2', 'br'];
foreach ($removeStyleTags as $removeStyleTag){
$elements = $dom->getElementsByTagName($removeStyleTag);
foreach ($elements as $element) {
$element->removeAttribute('style');
}
}
$html = $dom->saveHTML();
return $html;
}
public function pageDetail($id)
{
if($id == "new") {

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\IQ;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use IqContent\LaravelFilemanager\Controllers\LfmController;
class ContentAssetController extends LfmController
{
public function index()
{
$data = [
'models' => [],
];
return view('iq.content.assets.index', $data)->withHelper($this->helper);
}
}

View file

@ -51,6 +51,10 @@ class ContentModalController extends Controller
case 'tree' :
$ret = $this->loadModal($data);
break;
case 'guide' :
$ret = $this->loadModal($data);
break;
}
}
return response()->json(['response' => $data, 'html'=>$ret]);
@ -89,6 +93,10 @@ class ContentModalController extends Controller
return $this->actionTreeSiteContent($data);
break;
case 'guide-tree-site' :
return $this->actionGuideTreeSite($data);
break;
}
}
@ -271,4 +279,38 @@ class ContentModalController extends Controller
return view("iq.modal.site", compact('data','value', 'url') )->render();
}
private function actionGuideTreeSite($data)
{
if(!isset($data['tree_id'])){
$value = new Collection();
$value->active = true;
$value->id = 'add';
$data['travel_guide_id'] = $data['request']['travel_guide_id'];
$data['title'] = "Tree zuordnen";
$url = route('cms_travel_guide_detail', [$data['request']['travel_guide_id']]);
}else {
$value = new Collection();
$value->active = true;
$value->id = $data['id'];
$data['title'] = "Tree zuordnen";
if(isset($data['tree_id'])){
}
$url = route('iq_content_tree_detail', [$data['tree_id']]);
}
$data['request'] = false;
return view("iq.modal.tree_site", compact('data','value', 'url') )->render();
}
}

View file

@ -4,12 +4,14 @@ namespace App\Http\Controllers\IQ;
use App\Http\Controllers\Controller;
use App\Models\IQContentSite;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
use App\Models\TravelGuide;
use App\Models\TravelPageGuide;
use App\Repositories\IQ\ContentSiteRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Input;
use Validator;
@ -38,14 +40,14 @@ class ContentTreeController extends Controller
}
public function detail($id, $node_id = false, $area_section_id = false)
public function detail($id, $node_id = false, $section_id = false)
{
$model = IQContentTree::findOrFail($id);
$tree_node = IQContentTreeNode::find($node_id);
$area_section = false;
$site_fields = false;
if($area_section_id){
if($section_id){
/*
* $area_section = IQContentAreaSection::findOrFail($area_section_id);
$site_fields = $this->contentSiteRepo->siteFieldPrepare($tree_node->iq_content_site, $area_section);
@ -53,16 +55,20 @@ class ContentTreeController extends Controller
}
$data = [
'model' => $model,
'area_section' => $area_section,
'site_fields' => $site_fields,
'tree_node' => $tree_node,
'id' => $id,
'section' => false,
];
return view('cms.travel_guide.tree-detail', $data);
}
public function repair($id=1){
die();
$model = IQContentTree::findOrFail($id);
$travel_guide_pages = TravelPageGuide::getPageGuides($model->root_id);
$page_parent_id = [];
@ -92,7 +98,10 @@ class ContentTreeController extends Controller
'meta_title' => $guide_page->pagetitle,
'meta_description' => $description,
'meta_keywords' => $keywords,
];
'country_id' => $guide_page->country_id,
'box_image_url' => $guide_page->box_image_url,
];
$TravelGuide = TravelGuide::create($data);
@ -122,14 +131,12 @@ class ContentTreeController extends Controller
$tree_node = IQContentTreeNode::create($tree_data);
$TravelGuide->tree_node_id = $tree_node->id;
$TravelGuide->save();
IQContentSite::create(['tree_node_id'=>$tree_node->id, 'travel_guide_id'=>$TravelGuide->id]);
if($guide_page->travel_guide_content_id > 0){
$TravelGuide = TravelGuide::find($guide_page->travel_guide_content_id);
if($TravelGuide){
$TravelGuide->tree_node_id = $tree_node->id;
$TravelGuide->save();
IQContentSite::create(['tree_node_id'=>$tree_node->id, 'travel_guide_id'=>$TravelGuide->id]);
}
}
@ -137,10 +144,30 @@ class ContentTreeController extends Controller
die("--");
}
public function store($id, $node_id = false, $area_section_id = false)
{
$data = Input::all();
//new sort
//from ajax
if(isset($data['action'])){
//set node active on off
if($data['action'] == 'node-set-active'){
//$model = IQContentTree::findOrFail($id);
$tree_node = IQContentTreeNode::findOrFail($node_id);
if($tree_node->active){
$tree_node->active = false;
}else{
$tree_node->active = true;
}
$tree_node->save();
return response()->json(['success' => 'tree-node-active', 'data'=>$tree_node->active], 200);
}
}
//new sort / save nestable
if(isset($data['nestable-output'])){
$model = IQContentTree::findOrFail($id);
$model->updated_at = now();
@ -150,17 +177,19 @@ class ContentTreeController extends Controller
\Session()->flash('alert-save', '1');
return redirect(route('iq_content_tree_detail', [$model->id]));
}
if(isset($data['iq_content_site_field']) && is_array($data['iq_content_site_field'])){
$model = IQContentTree::findOrFail($id);
$model->updated_at = now();
$model->save();
$this->contentSiteRepo->storeContentSideFields($data['iq_content_site_field']);
\Session()->flash('alert-save', '1');
return redirect(route('iq_content_tree_detail', [$model->id, $node_id, $area_section_id]));
}
$rules = array(
'name' => 'required',
);
@ -214,27 +243,52 @@ class ContentTreeController extends Controller
$model->save();
$tree_node = IQContentTreeNode::findOrFail($node_id);
// $tree_node->site_id = $contentSite->id;
$tree_node->save();
$travel_guide = TravelGuide::findOrFail($data['travel_guide_id']);
$travel_guide->tree_node_id = $tree_node->id;
$travel_guide->save();
\Session()->flash('alert-save', '1');
if(IQContentSite::whereTreeNodeId($tree_node->id)->whereTravelGuideId($travel_guide->id)->count() == 0){
IQContentSite::create(['tree_node_id'=>$tree_node->id, 'travel_guide_id'=>$travel_guide->id]);
\Session()->flash('alert-save', '1');
}else{
\Session()->flash('alert-error', 'Eintrag schon vorhanden');
}
return redirect(route('iq_content_tree_detail', [$id, $node_id]));
break;
case 'guide-tree-site' :
$model = IQContentTree::findOrFail($id);
$model->updated_at = now();
$model->save();
$tree_node = IQContentTreeNode::findOrFail($data['tree_node_id']);
$travel_guide = TravelGuide::findOrFail($data['travel_guide_id']);
if(IQContentSite::whereTreeNodeId($tree_node->id)->whereTravelGuideId($travel_guide->id)->count() == 0){
IQContentSite::create(['tree_node_id'=>$tree_node->id, 'travel_guide_id'=>$travel_guide->id]);
\Session()->flash('alert-save', '1');
}else{
\Session()->flash('alert-error', 'Eintrag schon vorhanden');
}
return redirect(route('cms_travel_guide_detail', [$travel_guide->id]));
break;
}
}
}
public function remove($id, $node_id, $travel_guide_id){
public function removeSite($id, $node_id, $travel_guide_id, $r=false){
$model = IQContentTree::findOrFail($id);
$tree_node = IQContentTreeNode::findOrFail($node_id);
$tavel_guide = TravelGuide::findOrFail($travel_guide_id);
$tavel_guide->tree_node_id = null;
$tavel_guide->save();
$iq_content_site = IQContentSite::whereTreeNodeId($node_id)->whereTravelGuideId($travel_guide_id)->first();
$iq_content_site->delete();
\Session()->flash('alert-success', __('Seite aus Tree entfernt.'));
if($r == "g"){
return redirect(route('cms_travel_guide_detail', [$travel_guide_id]));
}
return redirect(route('iq_content_tree_detail', [$id, $node_id]));

View file

@ -0,0 +1,322 @@
<?php
namespace App\Http\Controllers\IQ\Tools;
use App\Http\Controllers\Controller;
use App\Models\IQContentSite;
use App\Models\IQContentSiteField;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
use App\Models\TravelGuide;
use Input;
use Validator;
class ContentLinkController extends Controller
{
private $tree = [];
/**
* ContentSiteController constructor.
*/
public function __construct()
{
// $this->middleware('auth');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$data = [
'text' => "",
'values' => [],
];
return view('iq.tools.links', $data);
}
public function store()
{
die("nothing to set");
//$this->readNodeAndSaveToTree();
//$this->cleanTextTravelGuide();
//$this->h1ToTitleTravelGuide();
}
public function h1ToTitleTravelGuide()
{
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
if(strpos($travelGuide->full_text,'<html><body><h1>' )){
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$elements = $dom->getElementsByTagName('h1');
foreach ($elements as $element) {
if($element->nodeValue != ""){
var_dump($travelGuide->id);
var_dump($element->nodeValue);
echo "<br>";
var_dump($travelGuide->name);
echo "<br>";
echo "--";
echo "<br>";
$new_text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $travelGuide->full_text);
$travelGuide->name = $element->nodeValue;
$travelGuide->full_text = $new_text;
$travelGuide->save();
}
}
}
}
die("done");
}
public function cleanTextTravelGuide()
{
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$new_text = \App\Services\Util::cleanHTML($travelGuide->full_text);
if(strcmp($travelGuide->full_text, $new_text) != 0){
$travelGuide->full_text = $new_text;
$travelGuide->save();
var_dump($travelGuide->id);
echo "<br>";
}
}
die("done");
}
public function readNodeAndSaveToTree(){
$input = Input::all();
$ret = [];
if(isset($input['text'])){
$out = $this->ul_to_array($input['text']);
$this->array_to_nodes($out);
}
die("done");
$data = [
'text' => $input['text'],
'values' => $ret,
];
return view('iq.tools.links', $data);
}
public function array_to_nodes($array, $lvl = 1, $parent_id = 1, $pos=100){
if(is_array($array)){
foreach ($array as $node){
if(isset($node['slug'])){
$slug = substr($node['slug'], 0, 80);
// $slug = substr($node['slug'], 0, strrpos($slug, " "));
$name = substr($node['name'], 0, 255);
// $name = substr($node['name'], 0, strrpos($name, " "));
$data = [
'tree_id' => 1,
'parent_id' => $parent_id,
'lvl' => $lvl,
'name' => $name,
'identifier' => $slug,
'active' => false,
'pos' => $pos++,
];
$tree_node = IQContentTreeNode::create($data);
$travel_guides = TravelGuide::whereSlug($node['slug'])->get();
foreach ($travel_guides as $travel_guide){
if(IQContentSite::whereTreeNodeId($tree_node->id)->whereTravelGuideId($travel_guide->id)->count() == 0) {
IQContentSite::create(['tree_node_id' => $tree_node->id, 'travel_guide_id' => $travel_guide->id]);
}
}
}
if(isset($node['children']) && is_array($node['children'])){
$this->array_to_nodes($node['children'], $lvl + 1, $tree_node->id, $pos);
}
}
}
}
public function ul_to_array($ol){
if(is_string($ol)){
if(!$ol = simplexml_load_string($ol)) {
trigger_error("Syntax error in UL/LI structure");
return FALSE;
}
return $this->ul_to_array($ol);
} else if(is_object($ol)){
$output = array();
foreach($ol->li as $li){
$tmp = false;
if(isset($li->ol)){
$tmp = $this->ul_to_array($li->ol);
}
if($li->count()){
$str = (string) $li;
$a = new \SimpleXMLElement($li->children()->asXML());
$str = (string) $a[0]." ".$str;
$str = str_replace("\n", "", $str);
$str = str_replace("\r", "", $str);
$str = str_replace("\t", "", $str);
$str = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $str);
if(trim($str) !== "" && $str !== null){
$slug = (string) $a['href'];
$link = explode("/", $slug);
$link1 = array_pop($link);
$link1 = str_replace('.htm', '',$link1);
$output[] = ['slug'=> $link1, 'name'=>$str, 'children'=>$tmp];
}
}else{
$str = (string) $li;
$str = str_replace("\n", "", $str);
$str = str_replace("\r", "", $str);
$str = str_replace("\t", "", $str);
if(trim($str) !== "" && $str !== null){
$output[] = ['slug'=>'', 'name'=>$str, 'children'=>$tmp];
}
}
}
return $output;
} else {
return FALSE;
}
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function rindex()
{
$data = [
'text' => "",
'values' => [],
];
return view('iq.content.tools.redirects', $data);
}
public function rstore()
{
$iqContentTree = IQContentTree::find(2);
$this->makeTree($iqContentTree);
$input = Input::all();
$ret = [];
if(isset($input['text'])){
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($input['text'], 'HTML-ENTITIES', 'UTF-8'));
$tags = ['ol'];
foreach ($tags as $tag){
$domElements = [];
$elements = $dom->getElementsByTagName($tag)->item(0);
foreach($elements as $node){
foreach($node->childNodes as $child) {
$ret[] = array($child->nodeName => $child->nodeValue);
}
}
}
/* $tags = ['a']; foreach ($tags as $tag){
$domElements = [];
$elements = $dom->getElementsByTagName($tag);
foreach ($elements as $element) {
$domElements[] = $element;
}
foreach ($domElements as $domElement) {
$r = "-----";
$href = $domElement->getAttribute('href');
$link = explode("/", $href);
$link1 = array_pop($link);
$link1 = str_replace('.html', '',$link1);
$link1 = str_replace('-', '',$link1);
if(isset($this->tree[$link1])){
$r = $this->tree[$link1];
}else{
$link1 = array_pop($link);
$link1 = str_replace('.html', '',$link1);
$link1 = str_replace('-', '',$link1);
if(isset($this->tree[$link1])){
$r = $this->tree[$link1];
}
}
$ret[] = "Redirect 301 /".$href." ".$r;
}
}*/
}
$data = [
'text' => $input['text'],
'values' => $ret,
];
return view('iq.content.tools.redirects', $data);
}
public function makeTree(IQContentTree $iq_content_tree, $lvl = 0, $parent_id = false, $url = "")
{
if ($parent_id) {
//where('active', true)
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->where('parent_id', $parent_id)->orderBy('pos', 'ASC')->get();
} else {
$url = "/" . $iq_content_tree->identifier . "/";
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->orderBy('pos', 'ASC')->get();
}
foreach ($tree_nodes as $node) {
$children = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl + 1)->where('active', true)->where('parent_id', $node->id)->count();
$this->tree[str_replace('-', '', $node->identifier)] = url($url . $node->identifier);
if ($children) {
$this->makeTree($iq_content_tree, $lvl + 1, $node->id, $url . $node->identifier . "/");
}
}
return true;
}
}

View file

@ -70,7 +70,7 @@ class TravelCountryController extends Controller
}
}
//TODO for this thime
//TODO for this time
//we need an update in the old CRM v1 system DB
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
if(!$tc){

View file

@ -129,7 +129,49 @@ class Booking extends Model
}
public function calculate_price_total()
{
$travel_draft_item = false;
$travel_price_adult = 0;
$travel_price_children = 0;
$total_adult = 0;
$total_children = 0;
foreach ($this->booking_draft_items as $booking_draft_item) {
//24 Rundreise
if($booking_draft_item->draft_type_id == 24){
$travel_draft_item = $booking_draft_item;
continue;
}
$prices = $booking_draft_item->getItemPrice();
//Grundpreis Reise
if($booking_draft_item->draft_type_id == 30){
$travel_price_adult += $prices['adult'];
$travel_price_children += $prices['children'];
}
$total_adult += $prices['adult'];
$total_children += $prices['children'];
}
if($travel_draft_item){
$travel_draft_item->setPriceAdultRaw($travel_price_adult);
$travel_draft_item->setPriceChildrenRaw($travel_price_children);
$travel_draft_item->save();
}
$this->price = $total_adult + $total_children;
$this->save();
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
public function getPriceAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price']), 2, ',', '.');
}
public function findBeforeDraftItemRelation($reid)
{

View file

@ -114,6 +114,32 @@ class BookingDraftItem extends Model
return $this->belongsTo('App\Models\DraftType', 'draft_type_id');
}
public function getItemPrice(){
$adult = 0;
$children = 0;
$days_duration = 1;
if(isset($this->attributes['days_duration']) && in_array($this->draft_type_id, [36, 37])){
$days_duration = intval($this->days_duration);
}
if(isset($this->attributes['adult'])){
$adult = $this->attributes['price_adult'] * $this->attributes['adult'] * $days_duration;
}
if(isset($this->attributes['children'])){
$children = $this->attributes['price_children'] * $this->attributes['children'] * $days_duration;
}
/*
if(in_array($this->draft_type_id, [38, 39,40])){
$days_duration = $this->days_duration;
$price = $this->price;
}
*/
return ['adult'=>$adult, 'children'=>$children];
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
@ -141,21 +167,66 @@ class BookingDraftItem extends Model
}
}
//price_adult
public function setPriceAdultAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['price_adult'] = floatval(str_replace(',', '.', $value));
}
public function getPriceAdultAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price_adult']), 2, ',', '.');
}
public function getPriceAdultRaw()
{
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
}
public function setPriceAdultRaw($value)
{
return $this->attributes['price_adult'] = $value;
}
//price_children
public function setPriceChildrenAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['price_children'] = floatval(str_replace(',', '.', $value));
}
public function getPriceChildrenAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price_children']), 2, ',', '.');
}
public function getPriceChildrenRaw()
{
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
}
public function setPriceChildrenRaw($value)
{
return $this->attributes['price_children'] = $value;
}
//price
public function setPriceAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
}
public function getPriceAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price']), 2, ',', '.');
}
public function getPriceRaw()
{
return isset($this->attributes['price']) ? $this->attributes['price'] : 0;
}
public function setPriceRaw($value)
{
return $this->attributes['price'] = $value;
}
}

View file

@ -51,7 +51,7 @@ class CMSContent extends Model
protected $table = 'c_m_s_contents';
protected $fillable = [
'name', 'field', 'text', 'full_text', 'integer', 'decimal',
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
];
public function sluggable()

View file

@ -57,11 +57,10 @@ class DraftItem extends Model
protected $table = 'draft_items';
protected $fillable = [
'pos',
'pos'
];
public function draft()
{
return $this->belongsTo('App\Models\Draft', 'draft_id');

View file

@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\IQContentSite
*
* @property int $id
* @property int $tree_node_id
* @property int $travel_guide_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\IQContentTreeNode $iq_content_tree_node
* @property-read \App\Models\TravelGuide $travel_guide
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite whereTravelGuideId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite whereTreeNodeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentSite whereUpdatedAt($value)
* @mixin \Eloquent
*/
class IQContentSite extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_content_sites';
protected $fillable = [
'tree_node_id', 'travel_guide_id',
];
public function iq_content_tree_node()
{
return $this->belongsTo('App\Models\IQContentTreeNode', 'tree_node_id');
}
public function travel_guide()
{
return $this->belongsTo('App\Models\TravelGuide', 'travel_guide_id');
}
}

View file

@ -43,6 +43,10 @@ use Illuminate\Support\Str;
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withoutTrashed()
* @mixin \Eloquent
* @property int|null $page_id
* @property int|null $root_id
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree wherePageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereRootId($value)
*/
class IQContentTree extends Model
{
@ -83,4 +87,29 @@ class IQContentTree extends Model
}
}
public static function getTreesOptions($id = false, $html = true, $choose = true) {
$values = [];
$ret = "";
$models = IQContentTree::where('active', 1)->get();
if($html) {
if($choose){
$ret .= '<option value="">Bitte wählen</option>\n';
}
foreach ($models as $model) {
$attr = ($model->id == $id) ? ' selected="selected"' : '';
$ret .= '<option value="' . $model->id . '"' . $attr . '>' . $model->name . '</option>\n';
}
return $ret;
}else{
foreach ($models as $model) {
$values[$model->id] = $model->name;
}
return $values;
}
return false;
}
}

View file

@ -51,6 +51,8 @@ use Illuminate\Support\Str;
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTreeNode withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTreeNode withoutTrashed()
* @mixin \Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_site
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_sites
*/
class IQContentTreeNode extends Model
{
@ -59,7 +61,6 @@ class IQContentTreeNode extends Model
protected $connection = 'mysql_stern';
protected $dates = ['deleted_at'];
protected $table = 'i_q_content_tree_nodes';
@ -91,12 +92,21 @@ class IQContentTreeNode extends Model
public function iq_content_tree_node_childs()
{
return $this->hasMany('App\Models\IQContentTreeNode', 'parent_id', 'id');
return $this->hasMany('App\Models\IQContentTreeNode', 'parent_id', 'id')->orderBy('pos', 'ASC');
}
public function travel_guides()
public function iq_content_sites()
{
return $this->hasMany('App\Models\TravelGuide', 'tree_node_id', 'id');
return $this->hasMany('App\Models\IQContentSite', 'tree_node_id', 'id');
}
public function iq_content_site_first()
{
foreach ($this->iq_content_sites as $iq_content_site) {
if (isset($iq_content_site->travel_guide) && $iq_content_site->travel_guide->active) {
return $iq_content_site->travel_guide;
}
}
}
@ -122,6 +132,30 @@ class IQContentTreeNode extends Model
return $ret.$node_parent->identifier."/";
}
}
public static function getTreeNodeOptions($tree_id, $id = false, $html = true, $choose = true) {
$values = [];
$ret = "";
$models = IQContentTreeNode::where('tree_id', $tree_id)->where('active', 1)->get();
if($html) {
if($choose){
$ret .= '<option value="">Bitte wählen</option>\n';
}
foreach ($models as $model) {
$attr = ($model->id == $id) ? ' selected="selected"' : '';
$ret .= '<option value="' . $model->id . '"' . $attr . '>' . $model->name . '</option>\n';
}
return $ret;
}else{
foreach ($models as $model) {
$values[$model->id] = $model->name;
}
return $values;
}
return false;
}
//
}

View file

@ -31,7 +31,13 @@ class TravelCountry extends Model
protected $fillable = [
'name',
'is_customer_country',
'active_backend'
'active_backend',
'contact_headline',
'contact_text_1',
'contact_text_2',
'contact_text_3',
'contact_text_4',
'contact_footer',
];

View file

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
/**
* App\Models\TravelCountry
@ -47,7 +48,16 @@ class TravelCountry extends Model
protected $fillable = [
'name',
'slug',
'html_information',
'text_before',
'text_after',
'contact_headline',
'contact_text_1',
'contact_text_2',
'contact_text_3',
'contact_text_4',
'contact_footer',
'entry_requirements',
'is_customer_country',
'active_frontend',
@ -72,6 +82,13 @@ class TravelCountry extends Model
return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id');
}
public function setSlugAttribute( $value ) {
if(!isset($value) || $value == ""){
$this->attributes['slug'] = Str::slug(pre_slug($this->name), '-');
}else{
$this->attributes['slug'] = Str::slug(pre_slug($value), '-');
}
}
public function getNationalityRequirement($travel_nationality_id){

View file

@ -39,6 +39,14 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide query()
* @property string|null $keyword
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_site
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereKeyword($value)
* @property int|null $country_id
* @property string|null $box_image_url
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentSite[] $iq_content_sites
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereBoxImageUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereCountryId($value)
*/
class TravelGuide extends Model
{
@ -58,7 +66,7 @@ class TravelGuide extends Model
];
protected $fillable = [
'tree_node_id', 'name', 'slug', 'text', 'full_text', 'keyword', 'meta_title', 'meta_description', 'meta_keywords', 'pos', 'scope', 'active',
'name', 'slug', 'text', 'full_text', 'keyword', 'meta_title', 'meta_description', 'meta_keywords', 'country_id', 'box_image_url', 'pos', 'scope', 'active',
];
@ -72,9 +80,18 @@ class TravelGuide extends Model
}
public function iq_content_tree_node()
public function iq_content_sites()
{
return $this->belongsTo('App\Models\IQContentTreeNode', 'tree_node_id');
return $this->hasMany('App\Models\IQContentSite', 'travel_guide_id', 'id');
}
public function iq_content_tree_node_first()
{
foreach ($this->iq_content_sites as $iq_content_site) {
if (isset($iq_content_site->iq_content_tree_node) && $iq_content_site->iq_content_tree_node->active) {
return $iq_content_site->iq_content_tree_node;
}
}
}

View file

@ -429,6 +429,12 @@ class TravelUserBookingFewo extends Model
return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0;
}
public function calculate_price(){
$this->attributes['price_travel_total'] = $this->getPriceTravelRaw() + $this->getPriceBalanceRaw() + $this->getPriceExtraRaw();
$this->attributes['price_total'] = $this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw() + $this->getPriceDepositRaw();
}
public function getPriceTravelTotalFirstPay(){
if($this->attributes['price_travel'] == 0){
return 0;
@ -469,6 +475,10 @@ class TravelUserBookingFewo extends Model
}
public function getLastChangeAt(){
if(!isset($this->attributes['last_change_at']) || !$this->attributes['last_change_at']){ return ""; }
return Carbon::parse($this->attributes['last_change_at'])->format("H:i d.m.Y");
}
public function getBookingDateYear(){
return Carbon::parse($this->booking_date)->format('Y');
@ -530,7 +540,19 @@ class TravelUserBookingFewo extends Model
return false;
}
//get TravelInfos Name / Paths / ...
public function isChangeLowerInvoiceCreate(){
$dir = $this->getBookingDateYear()."/";
$filename = $this->getInvoiceFileName();
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
return Carbon::createFromTimestamp(Storage::disk('fewo_invoices')->lastModified($dir.$filename))->gt($this->last_change_at);
}
return false;
}
//get TravelInfos Name / Paths / ...
public function getTravelInfoFileName(){
if($this->invoice_number) {
return "Anreiseinfo-".Util::sanitize($this->invoice_number).".pdf";
@ -581,7 +603,15 @@ class TravelUserBookingFewo extends Model
$filename = $this->getTravelInfoFileName();
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
return Carbon::createFromTimestamp(Storage::disk('fewo_infos')->lastModified($dir.$filename))->format("H:i d.m.Y");
}
return false;
}
public function isChangeLowerTravelInfoCreate(){
$dir = $this->getBookingDateYear()."/";
$filename = $this->getTravelInfoFileName();
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
return Carbon::createFromTimestamp(Storage::disk('fewo_infos')->lastModified($dir.$filename))->gt($this->last_change_at);
}
return false;
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class LaravelFilemanager extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
}

View file

@ -107,6 +107,7 @@ class TravelUserBookingFewoRepository extends BaseRepository {
$model = TravelUserBookingFewo::findOrFail($id);
$model->fill($data)->save();
$res = $this->calculatePriceNew($model);
$model->daily_prices = $res['season'];
@ -189,7 +190,6 @@ class TravelUserBookingFewoRepository extends BaseRepository {
return back()->withInput(Input::all())->withErrors($validator);
}
$set_price = true;
$data['is_calendar_fewo_direct'] = isset($data['is_calendar_fewo_direct']) ? true : false;
$data['is_calendar_hrs'] = isset($data['is_calendar_hrs']) ? true : false;
$data['is_calendar_stern_tours'] = isset($data['is_calendar_stern_tours']) ? true : false;
@ -197,22 +197,25 @@ class TravelUserBookingFewoRepository extends BaseRepository {
if($id == "new") {
$model = TravelUserBookingFewo::create($data);
}else{
$model = TravelUserBookingFewo::findOrFail($id);
if($data['from_date'] == $model->from_date && $data['to_date'] == $model->to_date){
$set_price = false;
}
$model->fill($data)->save();
}
$model->last_change_at = now();
$model->save();
$res = $this->calculatePriceNew($model);
$model->daily_prices = $res['season'];
if($set_price){
if(isset($data['calculate_price_new'])){
$model->price_travel = $res['price_travel'];
$model->price_service = $res['price_service'];
$model->price_deposit = $res['price_deposit'];
$model->price_total = $res['price_total'] + $model->getPriceBalanceRaw();
$model->calculate_price();
$model->save();
if($fewo_reservation = $model->fewo_reservation){
$model->fewo_reservation->from_date = $model->getFromDateRaw();

View file

@ -68,8 +68,8 @@ class HTMLHelper
return self::$days[intval($i)];
}
public static function getRoleLabel($role_id = 0){
return '<span class="badge badge-pill '.self::getLable($role_id).'">'.self::$roles[$role_id].'</span>';
public static function getRoleLabel($role_id = 0, $pre = "", $post = ""){
return '<span class="badge badge-pill '.self::getLable($role_id).'">'.$pre.self::$roles[$role_id].$post.'</span>';
}
public static function getLable($id){

View file

@ -41,16 +41,16 @@ class HTMLTreeHelper
</div>
<div class="dd-content">
<a href="' . route('iq_content_tree_detail', [$iq_content_tree->id, $node->id]) . '">
<div class="dd-content-link">
' . ($tree_node_id == $node->id ? '<strong> <i class="fa fa-chevron-right"></i> ' : '') . $node->name . ($tree_node_id == $node->id ? '</strong>' : '') . '
' . ($tree_node_id == $node->id ? '<strong> <i class="fa fa-chevron-right"></i> ' : '').$node->name.($tree_node_id == $node->id ? '</strong>' : '') . '
</div>
<div class="float-right">
' . ($node->site_id ? '<span class="far fa-check fa-xs text-light"></span>' : '') . '
<span class="far fa-edit"></span>
' . ($node->active ? '<i class="fa fa-eye text-success"></i>' : '<i class="fa fa-eye-slash text-danger"></i>') . '
</div>
</a>
<div class="float-right">
' . ($node->iq_content_sites->count() ? '<span class="text-light">('.$node->iq_content_sites->count().')</span>' : '') . '
<a href="#" class="iq_update_data_load" data-action="node-set-active" data-target="self" data-url="'.route('iq_content_tree_detail', [$iq_content_tree->id, $node->id]).'">' . ($node->active ? '
<i class="fa fa-eye text-success"></i>' : '<i class="fa fa-eye-slash text-danger"></i>') . '
</a>
</div>
</div>';
if ($children) {

View file

@ -67,4 +67,51 @@ class Util
}
return $search;
}
public static function cleanHTML($html)
{
$html = str_replace('font-size: 14px;', ' ', $html);
$html = str_replace('font-weight: lighter; ', ' ', $html);
$html = str_replace('font-family: Helvetica, Arial, sans-serif; ', ' ', $html);
$html = str_replace('font-family: Verdana, sans-serif; ', ' ', $html);
$html = str_replace('color: rgb(60, 60, 60); ', ' ', $html);
$html = str_replace(' style=" padding: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 20px !important; line-height: 20px !important;"', ' ', $html);
$html = str_replace('property="article"', ' ', $html);
$html = str_replace('&nbsp;', ' ', $html);
$html = str_replace('https://www.aegypten-online.de', 'https://www.sterntours.de', $html);
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
$removeFullTags = ['span', 'a'];
foreach ($removeFullTags as $removeFullTag){
$domElemsToRemove = [];
$elements = $dom->getElementsByTagName($removeFullTag);
foreach ($elements as $element) {
$domElemsToRemove[] = $element;
}
foreach ($domElemsToRemove as $domElem) {
if($removeFullTag == 'span' && strpos($domElem->getAttribute('style'), 'font-weight: 700') !== false){
$new_node = $dom->createTextNode("<strong>".$domElem->nodeValue."</strong>");
}else{
$new_node = $dom->createTextNode($domElem->nodeValue);
}
$domElem->parentNode->replaceChild($new_node, $domElem);
}
}
$removeStyleTags = ['ul', 'li', 'h1', 'h2', 'br'];
foreach ($removeStyleTags as $removeStyleTag){
$elements = $dom->getElementsByTagName($removeStyleTag);
foreach ($elements as $element) {
$element->removeAttribute('style');
}
}
$html = $dom->saveHTML();
return $html;
}
}