- Posts: 57
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Is this necessary?
- sodiumchl
- Topic Author
- Offline
- Senior Member
Less
More
3 years 2 months ago #212450
by sodiumchl
Is this necessary? was created by sodiumchl
Is the following if/return for "Quit if is done" neccesary? I noticed it only in answersAsReadonly but not other plugins. I don't understand it...
Code:
public function answersAsReadonlyAddScript() { /* Quit if is done */ if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) { return; } /* Add package if not exist (allow to use another one in config) */ if(!Yii::app()->clientScript->hasPackage(get_class($this))) { Yii::setPathOfAlias(get_class($this),dirname(__FILE__)); Yii::app()->clientScript->addPackage(get_class($this), array( 'basePath' => get_class($this).'.assets', 'css' => array(get_class($this).'.css'), 'js' => array(get_class($this).'.js'), 'depends' =>array('limesurvey-public'), )); } /* Registering the package */ Yii::app()->getClientScript()->registerPackage(get_class($this)); }
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13644
- Thank you received: 2491
3 years 2 months ago #212458
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Is this necessary?
You can have multiple readonly question : then : do it once.
It's to allow to use own package by other developer too since packlage can be set by config
It's to allow to use own package by other developer too since packlage can be set by config
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: sodiumchl
The topic has been locked.
- sodiumchl
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 1
3 years 1 month ago - 3 years 1 month ago #212859
by sodiumchl
Replied by sodiumchl on topic Is this necessary?
Aren't these two lines equivalent?
Code:
if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) { if(!Yii::app()->clientScript->hasPackage(get_class($this))) {
Last edit: 3 years 1 month ago by sodiumchl.
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13644
- Thank you received: 2491
3 years 1 month ago #212937
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Is this necessary?
www.yiiframework.com/doc/api/1.1/CClientScript#packages-detail
www.yiiframework.com/doc/api/1.1/CClient...pt#hasPackage-detail
Seem yes
www.yiiframework.com/doc/api/1.1/CClient...pt#hasPackage-detail
Seem yes
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- sodiumchl
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 1
3 years 1 month ago #212959
by sodiumchl
Replied by sodiumchl on topic Is this necessary?
If they are equivalent, then it appears to me that the code in the original post should be:
Then why do most plugins have it like the following?
Code:
public function answersAsReadonlyAddScript() { if(!Yii::app()->clientScript->hasPackage(get_class($this))) { Yii::setPathOfAlias(get_class($this),dirname(__FILE__)); Yii::app()->clientScript->addPackage(get_class($this), array( 'basePath' => get_class($this).'.assets', 'css' => array(get_class($this).'.css'), 'js' => array(get_class($this).'.js'), 'depends' =>array('limesurvey-public'), )); Yii::app()->getClientScript()->registerPackage(get_class($this)); } }
Then why do most plugins have it like the following?
Code:
public function answersAsReadonlyAddScript() { if(!Yii::app()->clientScript->hasPackage(get_class($this))) { Yii::setPathOfAlias(get_class($this),dirname(__FILE__)); Yii::app()->clientScript->addPackage(get_class($this), array( 'basePath' => get_class($this).'.assets', 'css' => array(get_class($this).'.css'), 'js' => array(get_class($this).'.js'), 'depends' =>array('limesurvey-public'), )); } Yii::app()->getClientScript()->registerPackage(get_class($this)); }
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13644
- Thank you received: 2491
3 years 1 month ago #213002
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Is this necessary?
Because i'm human maybe ?
I don't understand :
- if there are issue : report and make a pull request
- if it' improve without real issue : make a pull request directly.
I don't understand :
- if there are issue : report and make a pull request
- if it' improve without real issue : make a pull request directly.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13644
- Thank you received: 2491
3 years 1 month ago #213003
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Is this necessary?
Got it :
if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) {
the idea is to not register , i must find something like Yii::app()->getClientScript()->isPackageRegistered
if(array_key_exists(get_class($this),Yii::app()->getClientScript()->packages)) {
the idea is to not register , i must find something like Yii::app()->getClientScript()->isPackageRegistered
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: sodiumchl
The topic has been locked.