Fonts, Travel Program
This commit is contained in:
parent
93d1bea8e3
commit
561c5875a7
173 changed files with 12359 additions and 1070 deletions
|
|
@ -3,15 +3,8 @@
|
|||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Arrangement;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingServiceItem;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Lead;
|
||||
use App\Models\Participant;
|
||||
use App\Models\TravelBooking;
|
||||
use App\Repositories\DraftRepository;
|
||||
|
||||
use App\Services\BookingImport;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
|
|
@ -20,9 +13,9 @@ class BookingController extends Controller
|
|||
|
||||
protected $draftRepo;
|
||||
|
||||
public function __construct(DraftRepository $draftRepo)
|
||||
public function __construct()
|
||||
{
|
||||
$this->draftRepo = $draftRepo;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
|
|
@ -40,158 +33,12 @@ class BookingController extends Controller
|
|||
return response()->json(['error' => 'no-booking-found'], $this->successStatus);
|
||||
}
|
||||
|
||||
// ---- createCustomer
|
||||
$data = [
|
||||
'salutation_id' => $travel_booking->salutation_id,
|
||||
'name' => $travel_booking->last_name,
|
||||
'firstname' => $travel_booking->first_name,
|
||||
'street' => $travel_booking->street,
|
||||
'zip' => $travel_booking->zipcode,
|
||||
'city' => $travel_booking->city,
|
||||
'country_id' => $travel_booking->country_id,
|
||||
'phone' => $travel_booking->phone,
|
||||
'phonemobile' => $travel_booking->mobile,
|
||||
'email' => $travel_booking->email
|
||||
];
|
||||
$customer = Customer::create($data);
|
||||
$booking = BookingImport::importFrom($travel_booking);
|
||||
|
||||
// ---- createLead
|
||||
$data = [
|
||||
'customer_id' => $customer->id,
|
||||
'request_date' => $travel_booking->created,
|
||||
'travelperiod_start' => $travel_booking->selected_start_date,
|
||||
'travelperiod_end' => $travel_booking->selected_end_date,
|
||||
'remarks' => $travel_booking->comments,
|
||||
'sf_guard_user_id' => 15,
|
||||
'is_closed' => true,
|
||||
'initialcontacttype_id' => 14,
|
||||
'status_id' => 7,
|
||||
'website_id' => 1,
|
||||
];
|
||||
$lead = Lead::create($data);
|
||||
$lead->updateNextDueDate();
|
||||
|
||||
$comfort = false;
|
||||
if(isset($travel_booking->drafts['comfort']) && $travel_booking->drafts['comfort']){
|
||||
$comfort = true;
|
||||
}
|
||||
$data = [
|
||||
'booking_date' => $travel_booking->created->format('Y-m-d'),
|
||||
'customer_id' => $customer->id,
|
||||
'lead_id' => $lead->id,
|
||||
'new_drafts' => $travel_booking->drafts === null ? 0 : 1,
|
||||
'sf_guard_user_id' => 15,
|
||||
'branch_id' => 4,
|
||||
'pax' => $travel_booking->selected_adults,
|
||||
'title' => isset($travel_booking->selected_travel['travel_title']) ? $travel_booking->selected_travel['travel_title'] : "",
|
||||
'comfort' => $comfort,
|
||||
'start_date' => $travel_booking->selected_start_date->format('Y-m-d'),
|
||||
'end_date' => $travel_booking->selected_end_date->format('Y-m-d'),
|
||||
'website_id' => 1,
|
||||
'travel_number' => isset($travel_booking->selected_travel['travel_number']) ? $travel_booking->selected_travel['travel_number'] : null,
|
||||
/*'participant_name' => isset($travel_booking->participants[0]['last_name']) ? $travel_booking->participants[0]['last_name'] : null,
|
||||
'participant_firstname' => isset($travel_booking->participants[0]['first_name']) ? $travel_booking->participants[0]['first_name'] : null,
|
||||
'participant_birthdate' => isset($travel_booking->participants[0]['birthday']) ? date( "Y-m-d", strtotime($travel_booking->participants[0]['birthday'])) : null,
|
||||
'participant_salutation_id' => isset($travel_booking->participants[0]['gender']) ? $travel_booking->participants[0]['gender'] : null,
|
||||
'nationality_id' => isset($travel_booking->participants[0]['nationality']) ? $travel_booking->participants[0]['nationality'] : null,*/
|
||||
'participant_name' => null,
|
||||
'participant_firstname' => null,
|
||||
'participant_birthdate' => null,
|
||||
'participant_salutation_id' => null,
|
||||
'nationality_id' => null,
|
||||
'price' => $travel_booking->price,
|
||||
'price_total' => $travel_booking->price_total,
|
||||
'deposit_total' => $travel_booking->deposit_total,
|
||||
'final_payment' => $travel_booking->final_payment,
|
||||
'final_payment_date' => $travel_booking->final_payment_date->format('Y-m-d'),
|
||||
'travel_country_id' => isset($travel_booking->selected_travel['travel_country_id'][0]) ? $travel_booking->selected_travel['travel_country_id'][0] : null,
|
||||
'travel_category_id' => isset($travel_booking->selected_travel['travel_category_id']) ? $travel_booking->selected_travel['travel_category_id'] : null,
|
||||
'travelagenda_id' => isset($travel_booking->selected_travel['travelagenda_id']) ? $travel_booking->selected_travel['travelagenda_id'] : null,
|
||||
'travel_company_id' => isset($travel_booking->selected_travel['travel_company_id']) ? $travel_booking->selected_travel['travel_company_id'] : 4,
|
||||
];
|
||||
|
||||
//createBooking
|
||||
$booking = Booking::create($data);
|
||||
|
||||
//createTraveler
|
||||
if($travel_booking->participants){
|
||||
foreach ($travel_booking->participants as $key => $participant){
|
||||
Participant::create([
|
||||
'booking_id' => $booking->id,
|
||||
'participant_name' => $participant['last_name'],
|
||||
'participant_firstname' => $participant['first_name'],
|
||||
'participant_birthdate' => date( "Y-m-d", strtotime($participant['birthday'])),
|
||||
'participant_salutation_id' => $participant['gender'],
|
||||
'participant_child' => $participant['child'],
|
||||
'nationality_id' =>$participant['nationality'],
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//createServiceItem //service_items
|
||||
if($travel_booking->service_items){
|
||||
foreach ($travel_booking->service_items as $key => $service_item){
|
||||
BookingServiceItem::create([
|
||||
'booking_id' => $booking->id,
|
||||
'travel_company_id' => $service_item['travel_company_id'],
|
||||
'service_price' => $service_item['service_price'],
|
||||
'service_price_refund' => 0,
|
||||
'commission' => $service_item['commission'],
|
||||
'travel_date' => $service_item['travel_date'],
|
||||
'name' => $service_item['name'],
|
||||
'is_commission_locked' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//createServiceItem //insurances
|
||||
if($travel_booking->insurances){
|
||||
foreach ($travel_booking->insurances as $key => $service_item){
|
||||
BookingServiceItem::create([
|
||||
'booking_id' => $booking->id,
|
||||
'travel_company_id' => $service_item['travel_company_id'],
|
||||
'service_price' => $service_item['price'],
|
||||
'service_price_refund' => 0,
|
||||
'commission' => $service_item['commission'],
|
||||
'travel_date' => $service_item['travel_date'],
|
||||
'name' => $service_item['name'],
|
||||
'is_commission_locked' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//createArrangement
|
||||
if($travel_booking->arrangements) {
|
||||
foreach ($travel_booking->arrangements as $key => $arrangement){
|
||||
Arrangement::create([
|
||||
'state' => isset($arrangement['state']) ? $arrangement['state'] : null,
|
||||
'begin' => isset($arrangement['end']) ? $arrangement['end'] : null,
|
||||
'end' => isset($arrangement['end']) ? $arrangement['end'] : null,
|
||||
'type_s' => isset($arrangement['type_s']) ? $arrangement['type_s'] : null,
|
||||
'data_s' => isset($arrangement['data_s']) ? $arrangement['data_s'] : null,
|
||||
'view_position' => isset($arrangement['view_position']) ? $arrangement['view_position'] : null,
|
||||
'booking_id' => $booking->id,
|
||||
'type_id' => $arrangement['type_id'],
|
||||
'in_pdf' => isset($arrangement['in_pdf']) ? $arrangement['in_pdf'] : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//createDrafts
|
||||
|
||||
if($travel_booking->drafts) {
|
||||
$this->draftRepo->create_drafts_from_booking($booking->id, $travel_booking->drafts);
|
||||
}
|
||||
|
||||
$travel_booking->crm_booking_id = $booking->id;
|
||||
$travel_booking->save();
|
||||
$ret= [
|
||||
'url_v1' => make_old_url('/index.php/booking/'.$booking->id.'/edit'),
|
||||
'url_v3' => route('booking_detail', $booking->id),
|
||||
'lead_id' => $lead->id
|
||||
'lead_id' => $booking->lead_id
|
||||
];
|
||||
return response()->json(['success' => "import", "ret" => $ret], $this->successStatus);
|
||||
//return response()->json(['error' => 'no-node'], $this->successStatus);
|
||||
|
|
|
|||
102
app/Http/Controllers/SyS/ContentLinkController.php
Executable file
102
app/Http/Controllers/SyS/ContentLinkController.php
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS\Tools;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Booking;
|
||||
use App\Models\IQContentSite;
|
||||
use App\Models\IQContentSiteField;
|
||||
use App\Models\IQContentTree;
|
||||
use App\Models\IQContentTreeNode;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelGuide;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelBooking;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use IqContent\LaravelFilemanager\Controllers\FileController;
|
||||
use IqContent\LaravelFilemanager\Controllers\FolderController;
|
||||
use IqContent\LaravelFilemanager\Models\IQContentFile;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
class SysController extends Controller
|
||||
{
|
||||
|
||||
private $tree = [];
|
||||
/**
|
||||
* ContentSiteController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['sysadmin', '2fa']);
|
||||
}
|
||||
|
||||
public function filterHTML(){
|
||||
|
||||
}
|
||||
//content_links
|
||||
public function calcu()
|
||||
{
|
||||
|
||||
/*$query = Booking::with('booking_draft_items')->select('booking.*')->where('new_drafts', true);
|
||||
|
||||
$query->whereHas('booking_draft_items', function ($q) {
|
||||
$q->where('comfort', true);
|
||||
});
|
||||
$bookings = $query->get();
|
||||
foreach ($bookings as $booking){
|
||||
$booking->comfort = true;
|
||||
$booking->save();
|
||||
}
|
||||
*/
|
||||
|
||||
$bookings = Booking::orderBy('id', 'DESC')->offset(0)->limit(1000)->get();
|
||||
|
||||
|
||||
|
||||
|
||||
// dd("nothing");
|
||||
$val = [];
|
||||
$text = "";
|
||||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'bookings' => $bookings,
|
||||
];
|
||||
return view('sys.tools.links', $data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
clean code
|
||||
$travelGuides = TravelGuide::all();
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1><br></h1>") !== false){
|
||||
$val[$travelGuide->id] = "<h1><br></h1>";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1") !== false){
|
||||
$val[$travelGuide->id] = "<h1";
|
||||
}
|
||||
}
|
||||
|
||||
$travelGuide = TravelGuide::find(203);
|
||||
$text = $travelGuide->full_text;
|
||||
|
||||
// $new_text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $TravelGuide->full_text);
|
||||
|
||||
*/
|
||||
|
||||
public function calcuStore()
|
||||
{
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
65
app/Http/Controllers/SyS/SysController.php
Normal file
65
app/Http/Controllers/SyS/SysController.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\SyS\Import;
|
||||
use App\Services\SyS\ReCalcu;
|
||||
use App\Services\SyS\ReImport;
|
||||
|
||||
class SysController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['sysadmin', '2fa']);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('sys.index');
|
||||
}
|
||||
|
||||
public function tool($serve)
|
||||
{
|
||||
switch ($serve) {
|
||||
case 'reimport':
|
||||
return ReImport::show();
|
||||
break;
|
||||
case 'calcu':
|
||||
dd('check App\Services\SyS\ReCalcu');
|
||||
break;
|
||||
case 'tree':
|
||||
dd('check App\Services\SyS\Import');
|
||||
break;
|
||||
case 'clean_tree_code':
|
||||
dd('check App\Services\SyS\Import');
|
||||
break;
|
||||
case 'media_insert':
|
||||
dd('check App\Services\SyS\Import');
|
||||
break;
|
||||
case 'import':
|
||||
dd('check App\Services\SyS\Import');
|
||||
break;
|
||||
}
|
||||
abort(403, 'not found tool');
|
||||
}
|
||||
|
||||
|
||||
public function store($serve)
|
||||
{
|
||||
switch ($serve) {
|
||||
case 'reimport':
|
||||
return ReImport::store();
|
||||
break;
|
||||
|
||||
}
|
||||
abort(403, 'not found tool');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,742 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS\Tools;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Booking;
|
||||
use App\Models\IQContentSite;
|
||||
use App\Models\IQContentSiteField;
|
||||
use App\Models\IQContentTree;
|
||||
use App\Models\IQContentTreeNode;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelGuide;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelBooking;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use IqContent\LaravelFilemanager\Controllers\FileController;
|
||||
use IqContent\LaravelFilemanager\Controllers\FolderController;
|
||||
use IqContent\LaravelFilemanager\Models\IQContentFile;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
class ContentLinkController extends Controller
|
||||
{
|
||||
|
||||
private $tree = [];
|
||||
/**
|
||||
* ContentSiteController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['sysadmin', '2fa']);
|
||||
}
|
||||
|
||||
public function filterHTML(){
|
||||
|
||||
}
|
||||
//content_links
|
||||
public function index()
|
||||
{
|
||||
|
||||
/*$query = Booking::with('booking_draft_items')->select('booking.*')->where('new_drafts', true);
|
||||
|
||||
$query->whereHas('booking_draft_items', function ($q) {
|
||||
$q->where('comfort', true);
|
||||
});
|
||||
$bookings = $query->get();
|
||||
foreach ($bookings as $booking){
|
||||
$booking->comfort = true;
|
||||
$booking->save();
|
||||
}
|
||||
*/
|
||||
|
||||
$bookings = Booking::orderBy('id', 'DESC')->offset(0)->limit(1000)->get();
|
||||
|
||||
|
||||
|
||||
|
||||
// dd("nothing");
|
||||
$val = [];
|
||||
$text = "";
|
||||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'bookings' => $bookings,
|
||||
];
|
||||
return view('sys.tools.links', $data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
clean code
|
||||
$travelGuides = TravelGuide::all();
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1><br></h1>") !== false){
|
||||
$val[$travelGuide->id] = "<h1><br></h1>";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1") !== false){
|
||||
$val[$travelGuide->id] = "<h1";
|
||||
}
|
||||
}
|
||||
|
||||
$travelGuide = TravelGuide::find(203);
|
||||
$text = $travelGuide->full_text;
|
||||
|
||||
// $new_text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $TravelGuide->full_text);
|
||||
|
||||
*/
|
||||
|
||||
public function store()
|
||||
{
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
//tree
|
||||
public function tree()
|
||||
{
|
||||
$text = "";
|
||||
$val = [];
|
||||
$trees = IQContentTree::all();
|
||||
foreach ($trees as $tree){
|
||||
foreach ($tree->iq_content_tree_nodes as $tree_node){
|
||||
|
||||
$text .= $tree_node->id." -- ".$tree_node->title."\n";
|
||||
foreach ($tree_node->iq_content_sites as $site){
|
||||
if($site->travel_guide && $site->identifier === null){
|
||||
$identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
|
||||
//$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
|
||||
$text .= "-- ".$site->id." -- ".$identifier."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.trees', $data);
|
||||
}
|
||||
|
||||
public function treeStore()
|
||||
{
|
||||
$trees = IQContentTree::all();
|
||||
foreach ($trees as $tree){
|
||||
foreach ($tree->iq_content_tree_nodes as $tree_node){
|
||||
|
||||
foreach ($tree_node->iq_content_sites as $site){
|
||||
if($site->travel_guide){
|
||||
$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
|
||||
$site->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
//clean_tree_code
|
||||
public function cleanTreeCode(){
|
||||
$val = [];
|
||||
$text = "";
|
||||
|
||||
$travelGuide = TravelGuide::find(166);
|
||||
$text = $travelGuide->full_text;
|
||||
|
||||
$data = [
|
||||
'new_text' => \App\Services\Util::cleanHTML($text),
|
||||
'full_text' => $travelGuide->full_text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.clean', $data);
|
||||
}
|
||||
|
||||
public function cleanTreeCodeStore(){
|
||||
$this->cleanTextTravelGuide();
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
//media_insert
|
||||
public function mediaInsert(){
|
||||
$val = [];
|
||||
$text = "";
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.insert', $data);
|
||||
}
|
||||
|
||||
public function mediaInsertStore(){
|
||||
$val = [];
|
||||
|
||||
$data = Request::all();
|
||||
$text = $data['text'];
|
||||
|
||||
if($data['action'] === 'insert'){
|
||||
$lines = explode(PHP_EOL, $text);
|
||||
$FolderC = new FolderController();
|
||||
$FileC = new FileController();
|
||||
|
||||
foreach ($lines as $line){
|
||||
$sep = explode(';', $line);
|
||||
if(isset($sep[0]) && isset($sep[1]) && isset($sep[2])){
|
||||
//youtube //main dir
|
||||
$working_dir = "/shares/youtube/".$sep[0];
|
||||
$folder_name = $sep[1];
|
||||
|
||||
$folder = $FolderC->makeFolder($working_dir, $folder_name);
|
||||
$working_dir = $working_dir."/".$folder_name;
|
||||
$file = $FileC->makeYoutube($working_dir, $sep[2]);
|
||||
$val[] = $file.' - '.$sep[2]." | ".$working_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'youtube_ids'){
|
||||
$TravelGuides = TravelGuide::all();
|
||||
foreach ($TravelGuides as $travelGuide){
|
||||
$this->findYoutubeLinks($val, $travelGuide);
|
||||
|
||||
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'replace_youtube_links') {
|
||||
$TravelGuides = TravelGuide::all();
|
||||
foreach ($TravelGuides as $travelGuide){
|
||||
$this->replaceYoutubeLinks($val, $travelGuide);
|
||||
|
||||
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'replace_youtube_div') {
|
||||
$this->replaceYoutubeDiv($val, TravelGuide::find(335));
|
||||
$TravelGuides = TravelGuide::all();
|
||||
foreach ($TravelGuides as $travelGuide){
|
||||
$this->replaceYoutubeDiv($val, $travelGuide);
|
||||
|
||||
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.insert', $data);
|
||||
|
||||
}
|
||||
|
||||
//import
|
||||
public function import()
|
||||
{
|
||||
$text = "";
|
||||
$val = [];
|
||||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.import', $data);
|
||||
}
|
||||
|
||||
public function importStore()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
$lines = explode(PHP_EOL, $data['text']);
|
||||
|
||||
if($data['action'] === 'import_TN'){
|
||||
foreach ($lines as $line){
|
||||
$ex = explode(';', $line);
|
||||
$t_n = TravelNationality::whereName(trim($ex[1]))->first();
|
||||
if($t_n){
|
||||
$t_n->nat = $ex[0];
|
||||
$t_n->save();
|
||||
}else{
|
||||
TravelNationality::create([
|
||||
'name' => trim($ex[1]),
|
||||
'nat' => $ex[0],
|
||||
'active' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'import_CT') {
|
||||
foreach ($lines as $line){
|
||||
$ex = explode(';', $line);
|
||||
$t_c = TravelCountry::whereName(trim($ex[1]))->first();
|
||||
if($t_c){
|
||||
dump($t_c->name);
|
||||
$t_c->destco = $ex[0];
|
||||
$t_c->save();
|
||||
|
||||
$tc = \App\Models\Sym\TravelCountry::find($t_c->crm_id);
|
||||
$tc->destco = $ex[0];
|
||||
$tc->save();
|
||||
}
|
||||
}
|
||||
dd("");
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
private function replaceYoutubeDiv(&$val, $travelGuide)
|
||||
{
|
||||
$ret = [];
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
|
||||
$links = $dom->getElementsByTagName('iframe');
|
||||
foreach ($links as $link) {
|
||||
if($link->parentNode->parentNode->nodeName === 'div'){
|
||||
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
|
||||
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA'){
|
||||
if($link->parentNode->parentNode->parentNode->getAttribute('itemprop') === 'video'){
|
||||
|
||||
$need = $link->parentNode->parentNode;
|
||||
$replace = $link->parentNode->parentNode->parentNode;
|
||||
$replace->parentNode->insertBefore($dom->importNode($need, true), $replace->nextSibling);
|
||||
$replace->parentNode->removeChild($replace);
|
||||
$html = $dom->saveHTML();
|
||||
|
||||
$travelGuide->full_text = $html;
|
||||
$travelGuide->save();
|
||||
$val[] = 'replace - '.$travelGuide->id;
|
||||
|
||||
}else{
|
||||
// dump("notfound itemprop over class mediaA".$travelGuide->id);
|
||||
$val[] = 'notfound - itemprop over class mediaA - '.$travelGuide->id;
|
||||
|
||||
//in
|
||||
|
||||
foreach ($link->parentNode->parentNode->childNodes as $node){
|
||||
if($node->nodeName === 'h2'){
|
||||
|
||||
if($node->firstChild->nodeName === '#text'){
|
||||
|
||||
$span = $dom->createElement('span', htmlspecialchars($node->nodeValue));
|
||||
|
||||
$span->setAttribute('itemprop', 'name');
|
||||
$h2 = $dom->createElement('h2');
|
||||
$h2->appendChild($span);
|
||||
|
||||
$node->parentNode->replaceChild($h2, $node);
|
||||
$html = $dom->saveHTML();
|
||||
|
||||
$travelGuide->full_text = $html;
|
||||
$travelGuide->save();
|
||||
$val[] = 'replace h2 - '.$travelGuide->id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//<span itemprop="name">
|
||||
|
||||
}
|
||||
//dump("found M div ".$travelGuide->id);
|
||||
}else{
|
||||
// dump("notfound class mediaA".$travelGuide->id);
|
||||
$val[] = 'notfound - class mediaA - '.$travelGuide->id;
|
||||
}
|
||||
}else{
|
||||
// dump("notfound div ".$travelGuide->id);
|
||||
$val[] = 'notfound - video - '.$travelGuide->id;
|
||||
|
||||
|
||||
}
|
||||
// dump($travelGuide->id);
|
||||
}else{
|
||||
//dump("notfound".$travelGuide->id);
|
||||
$val[] = 'notfound - div - '.$travelGuide->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function replaceYoutubeLinks(&$val, $travelGuide)
|
||||
{
|
||||
$ret = [];
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
|
||||
$links = $dom->getElementsByTagName('iframe');
|
||||
foreach ($links as $link) {
|
||||
|
||||
$src = $link->getAttribute('src');
|
||||
|
||||
|
||||
//
|
||||
$replace = false;
|
||||
$reLink = false;
|
||||
if($link->parentNode->nodeName === 'div'){
|
||||
if($link->parentNode->getAttribute('class') === 'video-container'){
|
||||
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA' && $link->parentNode->parentNode->getAttribute('itemprop') !== 'video'){
|
||||
$replace = $link->parentNode->parentNode;
|
||||
$reLink = $link->parentNode;
|
||||
}else{
|
||||
$val[] = 'found - manual - '.$travelGuide->id;
|
||||
}
|
||||
}else{
|
||||
$val[] = 'first div - manual - '.$travelGuide->id;
|
||||
|
||||
}
|
||||
|
||||
}elseif ($link->parentNode->nodeName === 'p'){
|
||||
if($link->parentNode->parentNode->nodeName === 'div'){
|
||||
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
|
||||
//replace div
|
||||
$replace = $link->parentNode->parentNode;
|
||||
$reLink = $link->parentNode;
|
||||
}else{
|
||||
//replace p
|
||||
$replace = $link->parentNode;
|
||||
$reLink = $link;
|
||||
}
|
||||
}else{
|
||||
$replace = $link->parentNode;
|
||||
$reLink = $link;
|
||||
}
|
||||
|
||||
}else{
|
||||
$val[] = 'else div - manual - '.$travelGuide->id;
|
||||
}
|
||||
if($replace){
|
||||
|
||||
$id = preg_replace('/http.*?embed\//i', '', $src);
|
||||
$videoID = preg_replace('#[&\?].+$#', '', $id);
|
||||
$identifier = Str::slug(pre_slug($videoID), '-');
|
||||
$IQContentFile = IQContentFile::whereIdentifier($identifier)->first();
|
||||
if($IQContentFile) {
|
||||
|
||||
$video = new \DOMDocument('1.0', 'utf-8');
|
||||
$makeText = '<?xml encoding="utf-8" ?><div class="mediaA" itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
|
||||
$makeText .= '<h2><span itemprop="name">' . $IQContentFile->content['title'] . '</span></h2>';
|
||||
$makeText .= '<meta itemprop="duration" content="' . $IQContentFile->content['duration'] . '" />';
|
||||
$makeText .= '<meta itemprop="uploadDate" content="' . $IQContentFile->content['uploadDate'] . '"/>';
|
||||
$makeText .= '<meta itemprop="thumbnailURL" content="' . $IQContentFile->content['thumbnailURL'] . '" />';
|
||||
$makeText .= '<meta itemprop="embedURL" content="https://youtube.googleapis.com/v/' . $IQContentFile->content['id'] . '" />';
|
||||
$makeText .= '<div class="video-container"><iframe src="https://www.youtube.com/embed/' . $IQContentFile->content['id'] . '?rel=0&controls=0&showinfo=0" data-identifier="' . $IQContentFile->identifier . '" data-slug="' . $IQContentFile->slug . '" frameborder="0" allowfullscreen></iframe></div>';
|
||||
$makeText .= '<div class="mediaInfo"><p class="infotext" itemprop="description">'.$IQContentFile->content['description'].'</p></div></div>';
|
||||
$makeText = str_replace('&', '&', $makeText);
|
||||
$video->loadHTML($makeText);
|
||||
$replace->insertBefore($dom->importNode($video->documentElement, true), $reLink->nextSibling);
|
||||
$replace->removeChild($reLink);
|
||||
$html = $dom->saveHTML();
|
||||
|
||||
$travelGuide->full_text = $html;
|
||||
$travelGuide->save();
|
||||
|
||||
$val[] = 'replace - '.$travelGuide->id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function findYoutubeLinks(&$val, $travelGuide)
|
||||
{
|
||||
$ret = [];
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
$links = $dom->getElementsByTagName('iframe');
|
||||
foreach ($links as $link) {
|
||||
|
||||
$src = $link->getAttribute('src');
|
||||
|
||||
$id = preg_replace('/http.*?embed\//i', '', $src);
|
||||
$videoID = preg_replace('#[&\?].+$#', '', $id);
|
||||
|
||||
$identifier = Str::slug(pre_slug($videoID), '-');
|
||||
$count = IQContentFile::whereIdentifier($identifier)->count();
|
||||
|
||||
if($count === 0){
|
||||
$ret[$videoID] = $count;
|
||||
$val[] = "weitere;Travel-Guide;".$videoID.";";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
//private?
|
||||
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 readNodeAndSaveToTree(){
|
||||
$input = Request::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;
|
||||
}
|
||||
}
|
||||
|
||||
public function rindex()
|
||||
{
|
||||
$data = [
|
||||
'text' => "",
|
||||
'values' => [],
|
||||
];
|
||||
return view('iq.content.tools.redirects', $data);
|
||||
}
|
||||
|
||||
public function rstore()
|
||||
{
|
||||
|
||||
$iqContentTree = IQContentTree::find(2);
|
||||
$this->makeTree($iqContentTree);
|
||||
$input = Request::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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue