Skip to content

Commit

Permalink
Fix session
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bohollo committed Nov 18, 2019
1 parent 9d8145e commit 444c07d
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/admin/accions/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Omatech\Editora\Admin\Middleware\EditoraAuth;
use Omatech\Editora\Admin\Middleware\EditoraLocale;
use Omatech\Editora\Admin\Models\layout;

use Illuminate\Support\Facades\Session;

class AuthController extends BaseController
{
Expand Down
2 changes: 2 additions & 0 deletions src/admin/accions/admin_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Omatech\Editora\Admin\Accions;

use Illuminate\Support\Facades\Session;

class AdminDefault extends BaseController
{
public function render()
Expand Down
36 changes: 18 additions & 18 deletions src/admin/accions/admin_delete_image.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php
//à
$sc=new security();
if ($sc->testSession()==0) {
$sc->endSession();
}
else {
$params=get_params_info();
use Illuminate\Support\Facades\Session;

$ly=new layout();
$in=new instances();
$at=new attributes();
$ly_t=new layout_template();
$in_t=new instances_template();
$sc=new security();
if ($sc->testSession()==0) {
$sc->endSession();
} else {
$params=get_params_info();

$params['p_mode']='V';
$ly=new layout();
$in=new instances();
$at=new attributes();
$ly_t=new layout_template();
$in_t=new instances_template();

$title=EDITORA_NAME." -> ".getMessage('info_delete_image');
$ly_t->pinta_CommonLayout($top_menu, $buscador, $last_accessed, $favorites, $special, $ly, $in, $lg, $params);
$body=$in_t->imagesConfirm();
$params['p_mode']='V';

$_REQUEST['view']='container';
}
?>
$title=EDITORA_NAME." -> ".getMessage('info_delete_image');
$ly_t->pinta_CommonLayout($top_menu, $buscador, $last_accessed, $favorites, $special, $ly, $in, $lg, $params);
$body=$in_t->imagesConfirm();

$_REQUEST['view']='container';
}
1 change: 1 addition & 0 deletions src/admin/accions/admin_delete_image2.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Omatech\Editora\Admin\Models\Instances;
use Omatech\Editora\Admin\Templates\InstancesTemplate;
use Illuminate\Support\Facades\Session;

class AdminDeleteImage2 extends AuthController
{
Expand Down
49 changes: 26 additions & 23 deletions src/admin/accions/admin_delete_relation_instance_all.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<?php
//à
$sc=new security();
if ($sc->testSession()==0) {
$sc->endSession();
}
else {
$params=get_params_info();
use Illuminate\Support\Facades\Session;

$ly=new layout();
$in=new instances();
$at=new attributes();
$ly_t=new layout_template();
$at_t=new attributes_template();
$sc=new security();
if ($sc->testSession()==0) {
$sc->endSession();
} else {
$params=get_params_info();

$in->deleteRelationInstance($params);
$in->refreshCache($params);
if ($in) $message=html_message_ok(getMessage('info_word_deletejoin'));
else $message=html_message_ok(getMessage('info_word_deletejoin_error'));

$title=EDITORA_NAME." -> ".getMessage('info_view_object');
$ly_t->pinta_CommonLayout($top_menu, $buscador, $last_accessed, $favorites, $special, $ly, $in, $lg, $params);
$body=$at_t->instanceAttributes_view($at->getInstanceAttributes('V', $params), $params);
$parents=$ly_t->paintParentsList($in->getParents($params),$params);
$ly=new layout();
$in=new instances();
$at=new attributes();
$ly_t=new layout_template();
$at_t=new attributes_template();

$_REQUEST['view']='container';
}
?>
$in->deleteRelationInstance($params);
$in->refreshCache($params);
if ($in) {
$message=html_message_ok(getMessage('info_word_deletejoin'));
} else {
$message=html_message_ok(getMessage('info_word_deletejoin_error'));
}

$title=EDITORA_NAME." -> ".getMessage('info_view_object');
$ly_t->pinta_CommonLayout($top_menu, $buscador, $last_accessed, $favorites, $special, $ly, $in, $lg, $params);
$body=$at_t->instanceAttributes_view($at->getInstanceAttributes('V', $params), $params);
$parents=$ly_t->paintParentsList($in->getParents($params), $params);

$_REQUEST['view']='container';
}
1 change: 1 addition & 0 deletions src/admin/accions/admin_get_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Omatech\Editora\Admin\Models\Instances;
use Omatech\Editora\Admin\Templates\InstancesTemplate;
use Illuminate\Support\Facades\Session;

class AdminGetMain extends AuthController
{
Expand Down
8 changes: 4 additions & 4 deletions src/admin/accions/admin_list_class_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Omatech\Editora\Admin\Accions;


use Omatech\Editora\Admin\Models\Instances;
use Omatech\Editora\Admin\Models\Security;
use Omatech\Editora\Admin\Models\statictext;
Expand All @@ -12,6 +11,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use Illuminate\Support\Facades\Session;

class AdminListClassExport extends AuthController
{
Expand All @@ -38,9 +38,9 @@ public function render()

//$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1 , 'S#nom_intern');

foreach ($attributes as $key=>$attribute){
foreach ($attributes as $key => $attribute) {
//Nomes camps strings per ara
$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow($key+1, 1 , $attribute['type'].'#'.$attribute['name']);
$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow($key+1, 1, $attribute['type'].'#'.$attribute['name']);
}

$writer = new Xlsx($spreadsheet);
Expand All @@ -52,4 +52,4 @@ public function render()
header('Cache-Control: max-age=0');
$writer->save('php://output');
}
}
}
55 changes: 14 additions & 41 deletions src/admin/accions/admin_list_class_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Omatech\Editora\Admin\Accions;


use Omatech\Editora\Admin\Models\Instances;
use Omatech\Editora\Admin\Models\Security;
use Omatech\Editora\Admin\Models\statictext;
Expand All @@ -13,6 +12,7 @@
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use SKAgarwal\GoogleApi\PlacesApi;
use Illuminate\Support\Facades\Session;

class AdminListClassImport extends AuthController
{
Expand Down Expand Up @@ -53,15 +53,12 @@ public function render()
$count_rows = 0;

foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {

$values = '';
$count = 0;

$have_niceurl = false;

foreach ($worksheet->getRowIterator() as $row) {


$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true); // Loop all cells, even if it is not set

Expand All @@ -70,12 +67,9 @@ public function render()
foreach ($cellIterator as $key => $cell) {
$attributes[$key] = $cell->getValue();
}

} else {

$instance = array();
foreach ($cellIterator as $key => $cell) {

$type_attribute = explode('#', $attributes[$key]);

//S, U, K, T, Y
Expand All @@ -88,10 +82,8 @@ public function render()
$value_attr = $cell->getValue();


if ( !empty($value) ) {

if (!empty($value)) {
switch ($excel_type_attribute) {

case 'B':
$instance[$excel_attribute] = $value;
break;
Expand Down Expand Up @@ -127,7 +119,7 @@ public function render()
case 'M':
//map
$maps = $this->searchAddressOnGoogle($value);
if(isset($maps['geometry']) && isset($maps['geometry']['location']) && isset($maps['geometry']['location']['lat']) && isset($maps['geometry']['location']['lng']) ){
if (isset($maps['geometry']) && isset($maps['geometry']['location']) && isset($maps['geometry']['location']['lat']) && isset($maps['geometry']['location']['lng'])) {
$instance[$excel_attribute] = $maps['geometry']['location']['lat'].':'.$maps['geometry']['location']['lng'].'@'.$value;
}

Expand All @@ -144,9 +136,7 @@ public function render()
break;

case 'S':

if (strcmp($excel_attribute, 'nom_intern') == 0) {

$inst_id = 1;
$count = 0;

Expand All @@ -158,15 +148,13 @@ public function render()
$count++;
}
$instance[$excel_attribute] = $value;

} else {
$instance[$excel_attribute] = $value;
}

break;

case 'T':

$instance[$excel_attribute] = $value;
break;

Expand All @@ -181,16 +169,15 @@ public function render()
break;

case 'Z':

if (!empty($value)) {
$value = str_replace(".","-",$value);
$value = str_replace(",","-",$value);
$value = str_replace(" ","-",$value);
$value = str_replace("-----","-",$value);
$value = str_replace("----","-",$value);
$value = str_replace("---","-",$value);
$value = str_replace("--","-",$value);
if(strcmp(substr("value", -1) == '-' ) == 0 ){
$value = str_replace(".", "-", $value);
$value = str_replace(",", "-", $value);
$value = str_replace(" ", "-", $value);
$value = str_replace("-----", "-", $value);
$value = str_replace("----", "-", $value);
$value = str_replace("---", "-", $value);
$value = str_replace("--", "-", $value);
if (strcmp(substr("value", -1) == '-') == 0) {
$value = substr($value, 0, -1);
}

Expand All @@ -201,10 +188,8 @@ public function render()
$search = false;

while ($end == false) {

//languages: 'all', 'ca', 'es', 'en'
foreach ($langs as $lang) {

$nice_url = $loader->clean_url($value);

if ($search == false) {
Expand All @@ -224,67 +209,56 @@ public function render()
$count++;
$search = false;
}

}

$instance[$excel_attribute] = $loader->clean_url($value);
$niceurls[$excel_attribute] = $loader->clean_url($value);
}

break;

}
}


}
if( !empty($instance) ){
if (!empty($instance)) {
$inst_id = $loader->insertInstanceWithExternalID($id_class, $instance['nom_intern'], '', $batch_id, $instance, 'P');

if (isset($inst_id) && !empty($inst_id) && $have_niceurl == true && isset($niceurls) && !empty($niceurls)) {
foreach ($niceurls as $name_atr => $urlnice) {

$lang = explode('_', $name_atr);
$lang = end($lang);

if (!empty($urlnice)) {

$result = $loader->insertUrlNice($urlnice, $inst_id, $lang);
}
}
}

if (isset($inst_id) && !empty($inst_id)) {
$count_rows++;

}
}
}
}

}

$viewData['message'] = 'Good!';
$viewData['count_rows'] = $count_rows;
return response()->view('editora::pages.list_classes_export', $viewData);

}



public function searchAddressOnGoogle($address)

{
$key = env('GOOGLE_API_KEY');
$googlePlaces = new PlacesApi($key);
$response = $googlePlaces->placeAutocomplete($address);

if ($response['status'] !== 'ZERO_RESULTS') {

$placeId = $response->first()[0]['place_id'];
$response = $googlePlaces->placeDetails($placeId)['result'];

return $response;
return $response;

$componentAddress = [
'street_number' => 'short_name',
Expand All @@ -309,6 +283,5 @@ public function searchAddressOnGoogle($address)
];
}
return false;

}
}
}
Loading

0 comments on commit 444c07d

Please sign in to comment.