Migrating from old version

Version 0.2 09.01.2014

How to change deprecated coding style to new version style.

Version 2024.1

Page/Field method via API call

Restriction in calling Page/Filed methods via API call. Allows only basic getText() etc. -functions. Custom functions need to be added in Page::mapApiMethods() !!

Version 2023.1

Deprecated Recommended fix Additional information
$this->get('kansio') $this->get('pages') Remove use of old alias
$this->get('folder') $this->get('pages') Remove use of old alias
$this->get('pages', 'order', 'field=Value') $this->get('pages','order')->addWhere('field','Value') Use addWhere() instead of argument search, which uses direct search+populate collection. addWhere() prepairs query
$this->get('pages', 'order')->hae('field=Value') $this->get('pages','order')->addWhere('field','Value') Use addWhere() instead of hae(), which uses direct search+populate collection. addWhere() prepairs query.
$Pages->html() - Will not work in PHP 8.x
$Pages->sivu() $Pages->getPage() !!Note: sivu() return Empty class, getPage() return false.

Optimization

Deprecated Recommended fix Additional information
$Pages->calculate('total') $Pages->selectSum('total') calculate() iterates through sivut(), selectSum() calculates value with sql clause.

Version 4.1

Deprecated Recommended fix Additional information
$taulu->haku($ehto,$print[,data]) $Table->findAll($ehto,$print) Select page data from table
$taulu->haku($ehto,$print,'count') $Table->countAll($ehto,$print) Return the number of total rows.
$taulu->haku($ehto,$print,'query') $Table->getQuery($ehto,$print) Return SQL clause
$taulu->haku_rivi($ehto,$print[,data]) $Table->findAllCache($ehto,$print) Select page + cacherow data from table
$taulu->haku_rivi($ehto,$print,'query') $Table->getQueryCache($ehto,$print) Return SQL clause

Version 4.0

Version 4.0 brings resource -pattern, which allows all resources to be called via get() -method. This will replace all old direct shortcuts -methods.

$this->getUserName()
--->
$this->get('user')->getName()
Käyttö tarkastettu
D Dokumentaatio
E Tuotantoversio, eKansio koodi
A Tuotantoversio, asiakaskohtaiset koodit

Pages->page->field

Pages methods

Deprecated Recommended fix Additional information
nr() getId()
otsikko() getTitle()
kaikki($query) isAll($query)
joku($query) isAny($query)
laske($formula)  calculate($formula)
tulo($k1,$k2)  calculate('$k1*$k2')
summa($k1,$k2)  calculate('$k1+$k2')
erotus($k1,$k2)  calculate('$k1-$k2')
tyhjenna() setEmpty()

Page methods

Deprecated Recommended fix Additional information
nr() getId()
otsikko() getTitle()
otsikko($params) getText($params)
uusi() isNew()  isNew() can't take parameters !!
poistettu() isDeleted()
kentta($name) getField($name)  
kentat() getFields()  
kentat('tyyppi',$types) getFieldsByType($types)  
kenttaTyyppi($name) getField($name)->getType()  getType() return the english version of fieldtype name!!
kenttaArvo($name,$method) getFieldValue($name,$method)  
muokkaaja() muokkaaja->getText()  Use field property.
vanha($fieldname) $fieldname->getOldValue()
on_olemassa() ! isEmptyObject() Negation for old method!!
annettu() isGiven()  
annettu($fields) hasValue($fields)  
tyhja($fields) isEmpty($fields)  
muokattu() isChanged([$fields])
laske() calculate()
keskiarvo($field,$field) getAvg($field,$field)
keskiarvo($field,bool) getAvg($field,'',bool)
tallenna() save()
poista() delete()
palauta() delete()
tuhoa() delete()
kopioi_kentat() setValuesFrom()
haeSama($f,$self,$ehto) getPagesWithSame($f,$self) haeSama('kentta,kentta',true,'kentta=arvo') -> getPagesWithSame('kentta&kentta=arvo',true)
url_lomake($name,$valid)  getAction($name)->getUrl($valid)
laheta($name)  getAction($name)->send()
siirry()  getLink()->open()

Array variables in page save -code:

Deprecated Recommended fix Additional information
$tallenna[$field] $sivu->$field->getValue()  $tallenna[$field] has value only if it is given with save data.
$tallenna[$field] = $value $sivu->$field->setValue($value)  
$vanhat_tiedot[$field] $sivu->$field->getOldValue()  
$uudet_tiedot[$field] $sivu->$field->getValue()  
$data[$field]['arvo'] $sivu->$field->getValue() $data[$field]['arvo'] has value only if it is given with save data. 
$data[$field]['vanha'] $sivu->$field->getOldValue()  
$data[$field]['uusi'] $sivu->$field->getValue()
$data[$field]['muokattu'] $sivu->$field->isChanged()

Saving record

Deprecated Recommended fix Additional information
$this $taulu Code is run in Decorator, not in mad_taulu

Kentta methods

Deprecated Recommended fix Additional information
nr() getId()
nimi() getName()
otsikko() getTitle()
tyyppi() getType() getType() return the english version of fieldtype name!!
type() getType() getType() return the english version of fieldtype name!!
value() getValue()
luku() getNumber()  
arvo() getString()
nayta() ???
lomake() ???
muokkaa() ???
tyhja() isEmpty()  
annettu() hasValue()
onArvo(val) hasValue(val)
uusi() getValue()  
vanha() getOldValue() Value that object had when created.
syotetty() isInserted() Value set for the first time.
muokattutyhja() isInserted() Value set for the first time.
tyhjenna() setEmpty() Clear value
value(val) setValue()
aseta(val) setValue(val)
laske(string) calculateValue()
lisaa(val,...) addValue(val) lisaa() allowed to use multiple arguments, addValue() only one.
vahenna(val,...) reduceValue(val) vahenna() allowed to use multiple arguments, addValue() only one.
muokattu() isChanged() If value is changed, muokattu() returns new value but isChanged() returns 'true' !!!
muokattu(val) isChangedTo(val)
muutos() getChange()  Old/New value difference.
oletus(val) setDefault(val)
on_olemassa() isEmptyObject() Negotion to old method!!
on_kentta() isFieldObject()
suurin() getMinValue()  
pienin() getMaxValue()  

mad_taulu

mad_taulu madTable Description
$taulu->tbl_tallenna() $Table->getTbl() Write: Actual database name.
$taulu->tbl() $Table->getUserTbl() Read: Actual db or VIEW for this user.

Composition

In 4.0 all shortcut methods are deprecated and data should be referred through resource get() method.

Deprecated Recommended fix Additional information
new kansio($kansio) get('pages') DA Pages 
new mad_sivutiedot($kansio,$ehto)  get('pages',$kansio,$ehto)
newKansio($kansio,$ehto) get('pages',$kansio,$ehto) DA
avaaKansio($kansio,$ehto) get('pages',$kansio,$ehto) DA
haeKansio($kansio,$ehto) get('pages',$kansio,$ehto) DA
new sivu($rivi,$kansio) get('page',$kansio,$rivi) DA Page
new mad_sivutiedot_sivu($ehto,$kansio)  get('page',$kansio,$rivi)
newSivu($kansio,$rivi) get('page',$kansio,$rivi) DA
haeSivu($kansio,$rivi) get('page',$kansio,$rivi)   DA
uusiSivu($kansio) get('page',$kansio); DA
getAccount() get('account') DA Account
getAccountId() get('account')->getId() DA
getAccountConfig() get('account')->getConfig() DA
getAccountFile($file) get('account')->getFile($file) DA
getAccountAsset($file) get('account')->getAsset($file) DA
accountDir() get('account')->getDir() DA
getProfileId() get('profile')->getId() DA Profile
getProfileVariable($name) get('profile')->getVariable($name) DA
getProfilePage($name) get('profile')->getPage($name) DA
$_SESSION[sessio_user][ekansio][muuttuja][$name] get('profile')->getVariable($name) | D
getUser() get('user') DA User
getUserId() get('user')->getId() DA
newLink() get('link') DA Link
newMail() get('mail') DA Mail
sendMail() get('mail') DA
sendSms() get('sms') DA SMS
webservice->getResource($name,$resource) get('webservice',$name)->getResource($resource) DA Webservice
newWebservice($name,$conf) get('webservice',$name,$conf) DA
newWebresource($service,$resource,$conf) get('webservice',$service,$conf)->getResource($resource) DA
newAction($name) get('action',$name) DA Action
runAction($name,$page) get('action',$name)->runAction($sivu) DA
newPdf($name) get('pdf',$name) DA
uusiPdf($name) get('pdf',$name) DA
newTuloste($name) get('vienti',$name) DA
uusiTuloste($name) get('vienti',$name) DA
getText($text) get('lang',$text) D Lang
lang($text) get('lang',$text) D
palaute($text)  get('notification',$text) D Feedback
addMessage($text)  get('notification',$text) D
addMessageText($text)  get('notification',$text) D Text needs to be translated !!
virhe($text) get('notification',$text,'error') D
addError($text)  get('notification',$text,'error') D
addErrorText($text)  get('notification',$text,'error') D Text needs to be translated !!
addNotification($text)  get('notification',$text,'notification') D
timer($name) Log::addTime($name)  D
timerStart($name) Log::getCounter($name)  D

Functions

Deprecated Recommended fix
weeknumber(day) eDate::create(day)->getWeek()
laskePaiva(day,addD,addM,addY) eDate::create(day)->addDays(addD)->addMonths(addM)->addYears(addY)
laskeKuukausiMaara(start,end) eDate::create(start)->diffMonths(end)