Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Pomocy

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: Polish
View previous topic :: View next topic  
Author Message
jadzia999222
Smarty n00b


Joined: 27 Oct 2013
Posts: 1

PostPosted: Sun Oct 27, 2013 12:11 pm    Post subject: Pomocy Reply with quote

Cześć dopiero co zaczynam zabawę ze smarty i już dostałam mega ciężkie zadanie jak dla mnie. A więc tak mam na stronie panel admina, a w nim można dodawać wizytówki, pokazujące się na stronie (nie ja to robiłam). Teraz na tej samej stronie mam dodać podobną funkcję tylko że do artykułów. Wzoruje się na tamtych plikach, ale mi nie wychodzi. Utknęłam na zapisaniu artykułu w bazie danych. Oto pliki na jakich się wzoruję:
objects.php:
Code:

<?php
/*********************************************************************
 * Avatec Framework - Wersja 1.5.2011
 * Copyright (c) 2010-2011 Avatec.pl
 * Wszystkie prawa zastrzeżone
 *
 * Poniższy skrypt objęty jest umową licencyjną dostępną na stronie
 * http://www.avatec.pl/licencje/bnpremium2010.html
 *********************************************************************/

   include "../header.php";
   
   if(!isset($_GET['rewrite']))   die("FATAL ERROR: Module not installed");
   
    $smarty->assign("regiony" ,
        $objects->getRegions()
    );
   
    switch($_GET['action']):
   
        case "abonament-wybierz":
            if(!is_array($_SESSION['logged']))    $kernel->redirect(APP_URL . "user/login/");
           
            $kernel->template("objects/form-subscription.smarty");   
            $error = $objects->subscription();

            if(is_array($error)):
                $smarty->assign("errorNotice" , $new);
         else:
                $smarty->assign("addedNotice" , true);
                $user->updateCredits();
            endif;
        break;
   
   /**
    * Moje obiekty (wymaga zalogowania)
    */
      case "przegladaj":
         if(!is_array($_SESSION['logged']))   $kernel->redirect(APP_URL . "user/login/");
         
         $kernel->template("objects/user-przegladaj.smarty");
         $smarty->assign("yourObjects"   ,   $objects->getUserObjects());
      break;
      
   /**
    * Edycja obiektu przez zwykłego użytkownika
     * --------------------------------------------------------------------------------------------------------
    */
      
      case "edycja":
         if(!is_array($_SESSION['logged']))   $kernel->redirect(APP_URL . "user/login/");
         
         $kernel->template("objects/form-dodaj.smarty");
         $smarty->assign("edycja"      , $object = $objects->editById($objects->getIdByIdent($_GET['id'])));
         $smarty->assign("languages"      , $object['languages']);
         $smarty->assign("improvement"   , $object['improvement']);
         $smarty->assign("equipment"       , $object['equipment']);
         $smarty->assign("distance"      , $object['distance']);
            $smarty->assign("google_map"    , "true");
      break;
   
      case "dodaj":
         if(!is_array($_SESSION['logged']))   $kernel->redirect(APP_URL . "user/login/");
           
         $kernel->template("objects/form-dodaj.smarty");
            $smarty->assign("google_map" , "true");
      break;
      
        case "usun":
            $error = $objects->deleteObject($objects->getIdByIdent($_GET['id']));
           
            $kernel->redirect(APP_URL . "obiekt/przegladaj/");
        break;
      
      case "utworz":
         $new = $objects->createNew();
            $smarty->assign("google_map" , "true");
         
         if(is_array($new)):
            $kernel->template("objects/form-dodaj.smarty");
            $smarty->assign("errorNotice" , $new);
         else:
            $kernel->template("objects/form-dodaj.smarty");
            $smarty->assign("addedNotice" , true);
         endif;
      break;
      
      case "zapisz":
         $error = $objects->save($_GET['id']);
         
         if(is_array($error)):
            $kernel->template("objects/form-dodaj.smarty");
            $smarty->assign("errorNotice" , $error);
         else:
            $kernel->redirect(APP_URL . "obiekt/przegladaj/");
         endif;
      break;
      
      case "zdjecia":
         $kernel->template("objects/form-galeria.smarty");
         $smarty->assign("objectPhotos" , $objects->getPhotos($objects->getIdByIdent($_GET['id'])));
         $smarty->assign("count" , $objects->countPhotos($objects->getIdByIdent($_GET['id'])));
         if(isset($_POST['modules'])):
            $photos = $objects->uploadObjectPhoto();
            
            if(is_array($photos)):
               $smarty->assign("errorNotice" , $photos);
            else:
               $kernel->redirect(APP_URL."obiekt/zdjecia/".$_GET['id']."/");
            endif;
         
         endif;
      break;
      
      case "zdjecia-usun":
         $kernel->template("objects/form-galeria.smarty");
         
         $returnId = $objects->getPhotoOid($_GET['id']);
            $returnId = $objects->getIdentById($returnId);
         $photos = $objects->deletePhoto($_GET['id']);
         
         if($photos==true):
            $kernel->redirect(APP_URL."obiekt/zdjecia/".$returnId."/");
         endif;
      break;
       
      case "zdjecia-ustaw-glowne":
         $kernel->template("objects/form-galeria.smarty");
         $objects->setMainPhoto($_GET['photo']);
         $returnId = $objects->getPhotoOid($_GET['id']);
            $returnId = $objects->getIdentById($returnId);
           
            if($_GET['return']=="admin"):
               $kernel->redirect(APP_URL . "admin/obiekty-zdjecia/".$_GET['ident']."/");
            else:
            $kernel->redirect(APP_URL . "obiekt/zdjecia/".$returnId."/");
         endif;
      break;   
       
        case "wideo":
         $kernel->template("objects/form-video-list.smarty");
         $smarty->assign("lista" , $objects->videoGet( $objects->getIdByIdent($_GET['id']) ));
            $smarty->assign("count" , $objects->videoCount($objects->getIdByIdent($_GET['id'])));
           
            if(isset($_POST['module'])):
            $error = $objects->videoCreate();
            $kernel->template("objects/form-video-list.smarty");
            if(is_array($error)):
                    $smarty->assign("errorNotice" , $error);
                else:
                $kernel->redirect(APP_URL . "obiekt/wideo/".$_POST['objectid']."/");
                endif;
         endif;
      break;
      
      case "wideo-usun":
         $objects->videoDelete();
         $kernel->redirect(APP_URL . "obiekt/wideo/".$objects->getIdentById($_GET['ident'])."/");
      break;   
   
   
   endswitch;
   
   
   include "../footer.php";
?>

objects.class.php:
[code:1:2a4ce636a3]
<?php
/*********************************************************************
* Avatec Framework - Wersja 1.5.2011
* Copyright (c) 2010-2011 Avatec.pl
* Wszystkie prawa zastrzeżone
*
* Poniższy skrypt objęty jest umową licencyjną dostępną na stronie
* http://www.avatec.pl/licencje/bnpremium2010.html
*********************************************************************/

class objects extends Kernel {

var $queryString = array();
var $equipment, $improvement;

function __construct()
{
define("SQLTABLE_STATES" , SQL_PREFIX . "states");
define("SQLTABLE_OBJECTS" , SQL_PREFIX . "objects");
define("SQLTABLE_OBJECTS_CATEGORY" , SQL_PREFIX . "objects_categoty");
define("SQLTABLE_OBJECTS_COMMENTS" , SQL_PREFIX . "objects_comments");
define("SQLTABLE_OBJECTS_IMPROVEMENT" , SQL_PREFIX . "objects_improvement");
define("SQLTABLE_OBJECTS_PAYMENTS" , SQL_PREFIX . "objects_payments");
define("SQLTABLE_OBJECTS_ORGANIZE" , SQL_PREFIX . "objects_organizes");
define("SQLTABLE_OBJECTS_OTHERS" , SQL_PREFIX . "objects_others");
define("SQLTABLE_OBJECTS_EQUIPMENT" , SQL_PREFIX . "objects_equipment");
define("SQLTABLE_OBJECTS_DISTANCE" , SQL_PREFIX . "objects_distance");
define("SQLTABLE_OBJECTS_LANGUAGES" , SQL_PREFIX . "objects_languages");
define("SQLTABLE_OBJECTS_TYPES" , SQL_PREFIX . "objects_types");
define("SQLTABLE_OBJECTS_PHOTOS" , SQL_PREFIX . "objects_photos");
define("SQLTABLE_OBJECTS_VIDEOS" , SQL_PREFIX . "objects_videos");
define("SQLTABLE_OBJECTS_REGIONS" , SQL_PREFIX . "objects_regions");
define("SQLTABLE_OBJECTS_PAYMENT_DISPLAY" , SQL_PREFIX . "objects_payment_display");
define("SQLTABLE_SUBSCRIPTION" , SQL_PREFIX . "subscriptions");
define("SQLTABLE_DOTPAY_CODES" , SQL_PREFIX . "dotpay_codes");
}

public function getStateByName( $name )
{
if($name=="malopolskie"): return 6; endif;
if($name=="lodzkie"): return 5; endif;
$state = $this->sqlRow("*" , SQLTABLE_STATES , "WHERE name='".$name."'");
return $state['id'];

}

public function getLanguages()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_LANGUAGES , "ORDER BY name");
}

public function getStates()
{
return $this->sqlExec("*" , SQLTABLE_STATES , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetIdByIdent( $ident )
* @description: Pobieranie numeru $id na podstawie numeru $ident
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getIdByIdent( $ident ) { return $this->objectsGetIdByIdent($ident); }
public function objectsGetIdByIdent($ident)
{
$row = $this->sqlRow("*" , SQLTABLE_OBJECTS , "WHERE ident='".$ident."'");
return $row['id'];
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetIdentById( $id )
* @description: Pobieranie numeru $ident na podstawie numeru $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getIdentById( $id ) { return $this->objectsGetIdentById($id); }
public function objectsGetIdentById($id)
{
$row = $this->sqlRow("*" , SQLTABLE_OBJECTS , "WHERE id='".$id."'");
return $row['ident'];
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetById( $id )
* @description: Pobieranie obiektów użytkownika na podstawie numeru $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getById($id) { return $this->objectsGetById($id); }
public function objectsGetById( $id )
{
if($_SESSION['config']['dotpay_add_object']=="true"):
$row = $this->sqlQuery("SELECT * FROM ".SQLTABLE_OBJECTS." as obj, ".SQLTABLE_OBJECTS_PAYMENT_DISPLAY." as disp WHERE
obj.id=disp.object_id AND disp.create_date<='".date('Y-m-d')."' AND disp.end_date>='".date('Y-m-d')."' AND id='".$id."'");
else:
$row['0'] = $this->sqlRow("*" , SQLTABLE_OBJECTS , "WHERE id='".$id."'");
endif;

if(is_array($row['0'])):
$object = $row['0'];
$object['languages'] = $this->makeArray($object['languages']);
$object['improvement'] = $this->makeArray($object['improvement']);
$object['equipment'] = $this->makeArray($object['equipment']);
$object['distance'] = unserialize($object['distance']);
return $object;
endif;
return false;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetByIdForAdmin( $id )
* @description: Pobieranie obiektów na podstawie numeru $id, dostęp dla użytkowników z prawami admina
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getByIdForAdmin($id) { return $this->objectsGetByIdForAdmin($id); }
public function objectsGetByIdForAdmin( $id )
{
$row['0'] = $this->sqlRow("*" , SQLTABLE_OBJECTS , "WHERE id='".$id."'");

if(is_array($row['0'])):
$object = $row['0'];
$object['languages'] = $this->makeArray($object['languages']);
$object['improvement'] = $this->makeArray($object['improvement']);
$object['equipment'] = $this->makeArray($object['equipment']);
$object['distance'] = unserialize($object['distance']);
return $object;
endif;
return false;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetUser( )
* @description: Pobieranie obiektów użytkownika
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getUserObjects() { return $this->objectsGetUser(); }
public function objectsGetUser()
{
if(isset($_SESSION['logged'])):
return $this->sqlExec("*" , SQLTABLE_OBJECTS , "WHERE uid='".$_SESSION['logged']['id']."'");
else:
die("FATAL ERROR: Try to use function without permission");
return false;
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: objectsGetBestRated( )
* @description: Pobieranie obiektów o najwyższej ocenie
* @status: deprecated
* -----------------------------------------------------------------------------------------------------------------------
**/

public function objectsGetBestRated( $quota=3 )
{
return $this->sqlExec("*, (select AVG(rank) from ".SQLTABLE_OBJECTS_RANKING." where objectid=".SQLTABLE_OBJECTS.".id) AS srednia " , SQLTABLE_OBJECTS , "order by srednia desc LIMIT ".$quota);
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: visitCount( $objectId )
* @package: Baza Noclegowa
* @description: Podliczanie wyświetleń obiektu - gdy użytkownik raz wyświetlił obiekt, to na jego komputerze
* zapisuje się cookie na 24 godziny przez co przez ten okres, dla tego wybranego usera
* nie podlicza ponownie wyświetlenia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function visitCount( $objectId ) { return $this->objectVisitCount( $objectId ); }
public function objectVisitCount( $object_id )
{
if(!empty($_COOKIE['objectVisitCounter'])):
$tab = $_COOKIE['objectVisitCounter'];
$tab = explode(";" , $tab);
if(is_array($tab)): foreach($tab as $item):
if($item==$object_id):
setcookie("objectVisitCounter", $object_id, time()+3600);
return true;
else:
$tab[] = $object_id;
$this->sqlUpdate(SQLTABLE_OBJECTS , "count=count+1" , "id='".$object_id."'");
$val = serialize($tab);
setcookie("objectVisitCounter", $val, time()+3600);
return false;
endif;
endforeach; endif;
else:
$tab[] = $object_id;
$this->sqlUpdate(SQLTABLE_OBJECTS , "count=count+1" , "id='".$object_id."'");
$val = implode(';',$tab);
setcookie("objectVisitCounter", $val, time()+3600);
return false;
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: getLast( $quota )
* @package: Baza Noclegowa
* @description: Pobieranie ostatnio dodanych obiektów $quota określa ich ilość. Gdy płatność wyłaczona, funkcja
* nie bierze pod uwagę tego czy płatność za wyświetlanie jest, czy jej nie ma
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getLast( $quota=3 )
{
if($_SESSION['config']['dotpay_add_object']=="true"):
return $this->sqlQuery("SELECT * FROM ".SQLTABLE_OBJECTS." as obj, ".SQLTABLE_OBJECTS_PAYMENT_DISPLAY." as disp WHERE
obj.id=disp.object_id AND disp.create_date<='".date('Y-m-d')."' AND disp.end_date>='".date('Y-m-d')."' ORDER BY id DESC LIMIT 0,".$quota);
else:
return $this->sqlExec("*" , SQLTABLE_OBJECTS , "ORDER BY id DESC LIMIT 0,".$quota);
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: getRandom( $quota )
* @package: Baza Noclegowa
* @description: Pobieranie losowo wybranych obiektów $quota określa ich ilość. Gdy płatność wyłaczona, funkcja
* nie bierze pod uwagę tego czy płatność za wyświetlanie jest, czy jej nie ma
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getRandom( $quota=3 )
{
if($_SESSION['config']['dotpay_add_object']=="true"):
return $this->sqlQuery("SELECT * FROM ".SQLTABLE_OBJECTS." as obj, ".SQLTABLE_OBJECTS_PAYMENT_DISPLAY." as disp WHERE
obj.id=disp.object_id AND disp.create_date<='".date('Y-m-d')."' AND disp.end_date>='".date('Y-m-d')."' ORDER BY RAND() DESC LIMIT 0,".$quota);
else:
return $this->sqlExec("*" , SQLTABLE_OBJECTS , "ORDER BY RAND() DESC LIMIT 0,".$quota);
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: getPromoted( $quota )
* @package: Baza Noclegowa
* @description: Pobieranie obiektów promowanych
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getPromoted( $quota=3 )
{
return $this->sqlQuery("SELECT * FROM ".SQLTABLE_OBJECTS." as obj,".SQLTABLE_SUBSCRIPTION." AS sub WHERE obj.id=sub.oid AND sub.from_date<='".date('Y-m-d')."' AND sub.to_date>='".date('Y-m-d')."' ORDER BY RAND() LIMIT 0,".$quota);
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @private: true
* @function: improvementSearch( $array )
* @access: $this->advantageSearch()
* @description: Przygotowywanie wyszukiwania udogodnień
* -----------------------------------------------------------------------------------------------------------------------
**/

private function improvementSearch( $array )
{
if(count($array)==1):
return " AND obj.improvement LIKE '%".$array[0]."%' ";
else:
$endArray = end($array);
$this->queryString = " AND (";
foreach($array as $item):
$this->queryString .= " obj.improvement LIKE '%".$item."%' ";
if($item != $endArray):
$this->queryString .= " AND ";
else:
$this->queryString .= ")";
endif;
endforeach;
return $this->queryString;
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGet( )
* @description: Zwraca wszystkie dostępne udogodnienia i zwraca je w postaci tablicy
* -----------------------------------------------------------------------------------------------------------------------
**/

public function improvementGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_IMPROVEMENT , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGetById( $id )
* @description: Zwraca informacje o udogodnieniu na podstawie jego ID
* -----------------------------------------------------------------------------------------------------------------------
**/

public function improvementGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_IMPROVEMENT , "WHERE id='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementCreate( $filetable )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function improvementCreate( $file )
{
if(is_array($file)):
$iconFile = $this->improvementUpload( $file );
if(is_array($iconFile)):
return $iconFile;
endif;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_IMPROVEMENT , "null,
'".$_POST['improvement_name']."',
'".$iconFile."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementSave( $id )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function improvementSave( $id, $file )
{
// Jeżeli zaznaczono, że należy usunąć stary plik - usuń go
if(isset($_POST['delete_old_file'])):
@unlink(APP_PATH . "userfiles/objects/improvements/" . $_POST['delete_old_file']);
$iconFile = $this->improvementUpload( $file );
endif;

// Jeżeli wgrany został nowy plik, zapisz zmiany w bazie danych
if(isset($iconFile)):
$this->sqlUpdate(SQLTABLE_OBJECTS_IMPROVEMENT , "icon = '".$iconFile."'" , "id='".$id."'");
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_IMPROVEMENT , "name = '".$_POST['improvement_name']."'" , "id='".$id."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementDelete( $id )
* @description: Usuwanie udogodnienia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function improvementDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_IMPROVEMENT , "id='".$id."'")==true):
$filename = $this->sqlRow("icon" , SQLTABLE_OBJECTS_IMPROVEMENT , "WHERE id='".$id."'");
@unlink(APP_PATH . "userfiles/objects/improvements/" . $filename[0]);
$this->sqlDelete(SQLTABLE_OBJECTS_IMPROVEMENT , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementUpload( $file )
* @description: Uploadowanie ikony
* -----------------------------------------------------------------------------------------------------------------------
**/

private function improvementUpload( $file )
{
$this->uploadIcon = $file;
$this->uploadImageX = 80;
$this->uploadImageResize = true;
$this->uploadImageRatioY = true;
$this->uploadPath = APP_PATH . "userfiles/objects/improvements/";
$filename = $this->upload($this->uploadIcon);
return $filename;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @private: true
* @function: equipmentSearch( $array )
* @access: $this->advantageSearch()
* @description: Przygotowywanie wyszukiwania udogodnień
* -----------------------------------------------------------------------------------------------------------------------
**/

private function equipmentSearch( $array )
{
unset($this->queryString);
if(count($array)==1):
return " AND obj.equipment LIKE '%".$array[0]."%' ";
else:
$endArray = end($array);
$this->queryString = " AND (";
foreach($array as $item):
$this->queryString .= " obj.equipment LIKE '%".$item."%' ";
if($item != $endArray):
$this->queryString .= " AND ";
else:
$this->queryString .= ")";
endif;
endforeach;
return $this->queryString;
endif;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentGet( )
* @access: $this->equipmentGet()
* @description: Pobieranie listy wyposażenia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function equipmentGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_EQUIPMENT , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentGetById( $id )
* @access: $this->equipmentGetById(5)
* @description: Pobieranie pojedyńczego wyposażenia na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function equipmentGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_EQUIPMENT , "WHERE id='".$id."' ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentCreate( )
* @access: $this->equipmentCreate()
* @description: Tworzenie wpisu z nazwą wyposażenia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function equipmentCreate()
{
if(!isset($_POST['equipment_name'])):
$error[] = "podaj nazwę dla wyposażenia";
endif;

if(is_array($error)):
return $error;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_EQUIPMENT , "null,
'".$_POST['equipment_name']."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentSave( $id )
* @access: $this->equipmentSave(5)
* @description: Zapisywanie zmian w wyposażeniu
* -----------------------------------------------------------------------------------------------------------------------
**/

public function equipmentSave( $id )
{
if(!isset($_POST['equipment_name'])):
$error[] = "podaj nazwę dla wyposażenia";
endif;

if(is_array($error)):
return $error;
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_EQUIPMENT , "name='".$_POST['equipment_name']."'" , "id='".$id."'");
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentDelete( $id )
* @access: $this->equipmentDelete(5)
* @description: Usuwanie wyposażenia na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function equipmentDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_EQUIPMENT , "id='".$id."'")==true):
$this->sqlDelete(SQLTABLE_OBJECTS_EQUIPMENT , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGet( )
* @description: Zwraca wszystkie dostępne udogodnienia i zwraca je w postaci tablicy
* -----------------------------------------------------------------------------------------------------------------------
**/

public function paymentGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_PAYMENTS , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGetById( $id )
* @description: Zwraca informacje o udogodnieniu na podstawie jego ID
* -----------------------------------------------------------------------------------------------------------------------
**/

public function paymentGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_PAYMENTS , "WHERE id='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementCreate( $filetable )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function paymentCreate( $file )
{
if(is_array($file)):
$iconFile = $this->paymentUpload( $file );
if(is_array($iconFile)):
return $iconFile;
endif;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_PAYMENTS , "null,
'".$_POST['payment_name']."',
'".$iconFile."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementSave( $id )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function paymentSave( $id, $file )
{
// Jeżeli zaznaczono, że należy usunąć stary plik - usuń go
if(isset($_POST['delete_old_file'])):
@unlink(APP_PATH . "userfiles/objects/payments/" . $_POST['delete_old_file']);
$iconFile = $this->paymentsUpload( $file );
endif;

// Jeżeli wgrany został nowy plik, zapisz zmiany w bazie danych
if(isset($iconFile)):
$this->sqlUpdate(SQLTABLE_OBJECTS_PAYMENTS , "icon = '".$iconFile."'" , "id='".$id."'");
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_PAYMENTS , "name = '".$_POST['payment_name']."'" , "id='".$id."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementDelete( $id )
* @description: Usuwanie udogodnienia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function paymentDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_PAYMENTS , "id='".$id."'")==true):
$filename = $this->sqlRow("icon" , SQLTABLE_OBJECTS_PAYMENTS , "WHERE id='".$id."'");
@unlink(APP_PATH . "userfiles/objects/payments/" . $filename[0]);
$this->sqlDelete(SQLTABLE_OBJECTS_PAYMENTS , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementUpload( $file )
* @description: Uploadowanie ikony
* -----------------------------------------------------------------------------------------------------------------------
**/

private function paymentUpload( $file )
{
$this->uploadIcon = $file;
$this->uploadImageX = 80;
$this->uploadImageResize = true;
$this->uploadImageRatioY = true;
$this->uploadPath = APP_PATH . "userfiles/objects/payments/";
$filename = $this->upload($this->uploadIcon);
return $filename;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGet( )
* @description: Zwraca wszystkie dostępne udogodnienia i zwraca je w postaci tablicy
* -----------------------------------------------------------------------------------------------------------------------
**/

public function organizeGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_ORGANIZE , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGetById( $id )
* @description: Zwraca informacje o udogodnieniu na podstawie jego ID
* -----------------------------------------------------------------------------------------------------------------------
**/

public function organizeGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_ORGANIZE , "WHERE id='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementCreate( $filetable )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function organizeCreate( $file )
{
if(is_array($file)):
$iconFile = $this->organizeUpload( $file );
if(is_array($iconFile)):
return $iconFile;
endif;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_ORGANIZE , "null,
'".$_POST['organize_name']."',
'".$iconFile."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementSave( $id )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function organizeSave( $id, $file )
{
// Jeżeli zaznaczono, że należy usunąć stary plik - usuń go
if(isset($_POST['delete_old_file'])):
@unlink(APP_PATH . "userfiles/objects/organize/" . $_POST['delete_old_file']);
$iconFile = $this->organizeUpload( $file );
endif;

// Jeżeli wgrany został nowy plik, zapisz zmiany w bazie danych
if(isset($iconFile)):
$this->sqlUpdate(SQLTABLE_OBJECTS_ORGANIZE , "icon = '".$iconFile."'" , "id='".$id."'");
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_ORGANIZE , "name = '".$_POST['organize_name']."'" , "id='".$id."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementDelete( $id )
* @description: Usuwanie udogodnienia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function organizeDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_ORGANIZE , "id='".$id."'")==true):
$filename = $this->sqlRow("icon" , SQLTABLE_OBJECTS_ORGANIZE , "WHERE id='".$id."'");
@unlink(APP_PATH . "userfiles/objects/organize/" . $filename[0]);
$this->sqlDelete(SQLTABLE_OBJECTS_ORGANIZE , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementUpload( $file )
* @description: Uploadowanie ikony
* -----------------------------------------------------------------------------------------------------------------------
**/

private function organizeUpload( $file )
{
$this->uploadIcon = $file;
$this->uploadImageX = 80;
$this->uploadImageResize = true;
$this->uploadImageRatioY = true;
$this->uploadPath = APP_PATH . "userfiles/objects/organize/";
$filename = $this->upload($this->uploadIcon);
return $filename;
}



/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGet( )
* @description: Zwraca wszystkie dostępne udogodnienia i zwraca je w postaci tablicy
* -----------------------------------------------------------------------------------------------------------------------
**/

public function otherGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_OTHERS , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementGetById( $id )
* @description: Zwraca informacje o udogodnieniu na podstawie jego ID
* -----------------------------------------------------------------------------------------------------------------------
**/

public function otherGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_OTHERS , "WHERE id='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementCreate( $filetable )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function otherCreate( $file )
{
if(is_array($file)):
$iconFile = $this->otherUpload( $file );
if(is_array($iconFile)):
return $iconFile;
endif;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_OTHERS , "null,
'".$_POST['other_name']."',
'".$iconFile."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementSave( $id )
* @description: Zapisuje wprowadzone zmiany, usuwa jeżeli zaznaczono starą ikonkę i wgrywa nową
* -----------------------------------------------------------------------------------------------------------------------
**/

public function otherSave( $id, $file )
{
// Jeżeli zaznaczono, że należy usunąć stary plik - usuń go
if(isset($_POST['delete_old_file'])):
@unlink(APP_PATH . "userfiles/objects/others/" . $_POST['delete_old_file']);
$iconFile = $this->otherUpload( $file );
endif;

// Jeżeli wgrany został nowy plik, zapisz zmiany w bazie danych
if(isset($iconFile)):
$this->sqlUpdate(SQLTABLE_OBJECTS_OTHERS , "icon = '".$iconFile."'" , "id='".$id."'");
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_OTHERS , "name = '".$_POST['other_name']."'" , "id='".$id."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementDelete( $id )
* @description: Usuwanie udogodnienia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function otherDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_OTHERS , "id='".$id."'")==true):
$filename = $this->sqlRow("icon" , SQLTABLE_OBJECTS_OTHERS , "WHERE id='".$id."'");
@unlink(APP_PATH . "userfiles/objects/others/" . $filename[0]);
$this->sqlDelete(SQLTABLE_OBJECTS_OTHERS , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: improvementUpload( $file )
* @description: Uploadowanie ikony
* -----------------------------------------------------------------------------------------------------------------------
**/

private function otherUpload( $file )
{
$this->uploadIcon = $file;
$this->uploadImageX = 80;
$this->uploadImageResize = true;
$this->uploadImageRatioY = true;
$this->uploadPath = APP_PATH . "userfiles/objects/others/";
$filename = $this->upload($this->uploadIcon);
return $filename;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: distanceGet( )
* @access: $this->distanceGet()
* @description: Pobieranie listy odglegość do
* -----------------------------------------------------------------------------------------------------------------------
**/

public function distanceGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_DISTANCE , "ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: distanceGetById( $id )
* @access: $this->distanceGetById(5)
* @description: Pobieranie pojedyńczego odległość do na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function distanceGetById( $id )
{
return $this->sqlRow("*" , SQLTABLE_OBJECTS_DISTANCE , "WHERE id='".$id."' ORDER BY name");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: equipmentCreate( )
* @access: $this->equipmentCreate()
* @description: Tworzenie wpisu z nazwą wyposażenia
* -----------------------------------------------------------------------------------------------------------------------
**/

public function distanceCreate()
{
if(!isset($_POST['distance_name'])):
$error[] = "podaj nazwę";
endif;

if(is_array($error)):
return $error;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_DISTANCE , "null,
'".$_POST['distance_name']."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: distanceSave( $id )
* @access: $this->distanceSave(5)
* @description: Zapisywanie zmian w odległość do
* -----------------------------------------------------------------------------------------------------------------------
**/

public function distanceSave( $id )
{
if(!isset($_POST['distance_name'])):
$error[] = "podaj nazwę";
endif;

if(is_array($error)):
return $error;
endif;

$this->sqlUpdate(SQLTABLE_OBJECTS_DISTANCE , "name='".$_POST['distance_name']."'" , "id='".$id."'");
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: distanceDelete( $id )
* @access: $this->distanceDelete(5)
* @description: Usuwanie odległość do na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function distanceDelete( $id )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_DISTANCE , "id='".$id."'")==true):
$this->sqlDelete(SQLTABLE_OBJECTS_DISTANCE , "id='".$id."'");
endif;
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: videoGet( )
* @access: $this->videoGet()
* @description: Pobieranie filmików wideo dla obiektów
* -----------------------------------------------------------------------------------------------------------------------
**/

public function videoGet()
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_VIDEOS , "WHERE oid='".$this->getIdByIdent($_GET['id'])."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: videoGet( )
* @access: $this->videoGet()
* @description: Pobieranie filmików wideo dla obiektów
* -----------------------------------------------------------------------------------------------------------------------
**/

public function videoCount( $id )
{
return $this->sqlCount(SQLTABLE_OBJECTS_VIDEOS , "oid='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: videoGetById( $id )
* @access: $this->videoGetById( $id )
* @description: Pobieranie filmiku wideo na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function videoGetById($id)
{
return $this->sqlExec("*" , SQLTABLE_OBJECTS_VIDEOS , "WHERE oid='".$id."'");
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: videoCreate( )
* @access: $this->videoCreate()
* @description: Dodawanie filmiku wideo z walidacją linku
* -----------------------------------------------------------------------------------------------------------------------
**/

public function videoCreate()
{
if(!isset($_POST['video_name'])) $error[] = "musisz podać nazwę tego filmu";
if(!isset($_POST['video_link'])) $error[] = "podaj link do filmu youtube";

preg_match_all("(youtube|vimeo)" , $_POST['video_link'] , $matches);

if(empty($matches[0])):
$error[] = "skrypt akceptuje jedynie linki youtube.com oraz vimeo.com";
endif;

if(is_array($error)):
return $error;
endif;

$this->sqlInsert(SQLTABLE_OBJECTS_VIDEOS , "null,
'".$this->getIdByIdent($_POST['objectid'])."',
'".$_POST['video_name']."',
'".$this->convertYouTubeLink($_POST['video_link'])."',
'".$this->generateIdent(20)."'");

return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: videoDelete( )
* @access: $this->videoDelete()
* @description: Usuwanie z bazy danych filmiku na podstawie jego $id
* -----------------------------------------------------------------------------------------------------------------------
**/

public function videoDelete()
{
$this->sqlDelete(SQLTABLE_OBJECTS_VIDEOS , "id='".$_GET['id']."'");
return true;
}

/**
* -----------------------------------------------------------------------------------------------------------------------
* @function: getPhotos( )
* @access: $this->getPhotos()
* @description: Pobieranie zdjęć z bazy danych
* -----------------------------------------------------------------------------------------------------------------------
**/

public function getPhotos( $id ) { return $this->photoGet($id); }
public function photoGet( $id )
{
if(!isset($id)): $id = null; endif;

if($id==null):
return $this->sqlExec("*" , SQLTABLE_OBJECTS_PHOTOS , "ORDER BY id DESC");
else:
return $this->sqlExec("*" , SQLTABLE_OBJECTS_PHOTOS , "WHERE oid='".$id."' ORDER BY id DESC");
endif;
}

public function countPhotos( $id ) { return $this->photoCount($id); }
public function photoCount( $id )
{
return $this->sqlCount(SQLTABLE_OBJECTS_PHOTOS , "oid='".$id."'");
}

public function setMainPhoto( $file ) { return $this->photoSetMain($file); }
public function photoSetMain( $file )
{
if($this->sqlCheck(SQLTABLE_OBJECTS_PHOTOS , "oid='".$_GET['object']."' AND main='TRUE'")==true):
$this->sqlUpdate(SQLTABLE_OBJECTS_PHOTOS , "main='FALSE'" , "oid='".$_GET['object']."' AND main='TRUE'");
$this->sqlUpdate(SQLTABLE_OBJECTS_PHOTOS , "main='TRUE'" , "ident='".$_GET['id']."' AND oid='".$_GET['object']."'");
else:
$this->sqlUpdate(SQLTABLE_OBJECTS_PHOTOS , "main='TRUE'" , "ident='".$_GET['id']."' AND oid='".$_GET['object']."'");
endif;
return true;
}

public function getPhotoOid( $ident ) { return $this->photoGetObjectID( $ident ); }
public function photoGetObjectID( $ident )
{
$oid=$this->sqlRow("oid" , SQLTABLE_OBJECTS_PHOTOS , "WHERE ident='".$ident."'");
return $oid['oid'];
}

public function deletePhoto($ident) { return $this->photoDelete($ident); }
public function photoDelete($ident)
{
$filename = $this->sqlRow("*" , SQLTABLE_OBJECTS_PHOTOS , "WHERE ident='".$ident."'");

if(file_exists&#
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: Polish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP