Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pgaultier/sweekit
Sweelix development kit
https://github.com/pgaultier/sweekit
Last synced: 2 months ago
JSON representation
Sweelix development kit
- Host: GitHub
- URL: https://github.com/pgaultier/sweekit
- Owner: pgaultier
- License: other
- Created: 2012-02-17T15:10:20.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-01-20T09:20:11.000Z (almost 11 years ago)
- Last Synced: 2024-10-11T20:23:58.638Z (3 months ago)
- Language: JavaScript
- Homepage: http://www.sweelix.net/sweekit/
- Size: 1.51 MB
- Stars: 11
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.mkd
- License: license
Awesome Lists containing this project
README
# Sweekit - aka Sweelix toolkit
The toolkit is under new BSD License except for 3rdParty elements which are under their own
licenses.3rd party tools used in the toolkit are
* http://www.shadowbox-js.com - Shadowbox, dual license http://www.shadowbox-js.com/LICENSE
* http://www.plupload.com/ - PLupload, dual license http://www.plupload.com/license.phpThis toolkit was written to ease javascript access during our developments.
In order to not create conflict, Sweekit classes are prefixed with _Sw_A short explain is available in the doc directory.
Available features :
* javascript - see doc/sweekit.mkd and doc.javascript.mkd
* components - some usefull components
* helpers - Sweeml (extends CHtml) - see doc/sweekit.mkd
* behaviors - SwAjaxBehavior, SwClientScriptBehavior, SwRenderBehavior - see doc/behaviors.mkd
* filters - SwProtocolFilter - see doc/filters.mkd
* validators - SwFileValidator (for plupload)
* actions - SwDeleteAction, SwUploadAction (for plupload)
* commands - SwUploadCommand (to purge plupload temporary directory)
* web - SwUploadedFile (Retrieve files uploaded with plupload)## Samples - because it's always easier to understand what can be done
A sample application has been built and is available in the "samples" directory.
## Quick code
### Mobile notifier
The mobile notifier allow the developper to send notification to iOS and/or
Android system.Of course, you'll need account information from Google or Apple to be able
to send notifications.Adding the notifier component to the application
````php
/* configuration array */
mobileNotification' => array(
'class' => 'ext.sweekit.actions.SwMobileNotifier',
'mode' => 'production', // can be development to use the sandbox
'apnsCertificateFile' => 'my_apple_certificate_for_push.pem',
'apnsCertificatePassphrase' => 'my_apple_certificate_passphrase', // comment out if there is no passphrase
'apnsEmbeddedCaFile'=>true, // embed entrust ca file if needed (ssl errors, ...)
'c2dmUsername' => '[email protected]',
'c2dmPassword' => 'my_gmail_push_account_password',
'c2dmApplicationIdentifier' => 'my_gmail_push_app_identifier',
),
````You are now able to push messages to mobile devices
#### Sample for Android
````php
// send message to device
$res = Yii::app()->getComponent('mobileNotification')->sendC2dmMessage(
'the_android_device_id', // look like base64 encoded data
array('badge' => 12, 'message' => 'My message to send') // the payload to send to the device
);
````#### Sample for iOS
````php
// send message to device
$res = Yii::app()->getComponent('mobileNotification')->sendApnsMessage(
'the_ios_device_id', // 64 characters hex id
array('aps' => array(
'badge' => CPropertyValue::ensureInteger(12), // make sure data is an integer
'alert' => 'My message to send',
))
);
````Apple added a function to check if device should still receive notification.
This method should be called using a cron system in order to purge old pushId from
your database to avoid sending useless notifications````php
$res = Yii::app()->getComponent('mobileNotification')->readApnsFeedback();
/**
* $res is an array of array :
* $res = array(
* array($timeStamp, $pushId1),
* array($timeStamp, $pushId2),
* // ...
* );
*/
````### Callback system
As an example, you have created an online shop and in several places, the cart is updated.
If in the header there is a widget which shows the number of products, this widget
should be updated when the cart is updated.Using the callback system you can :
Register an event in the widget using Sweeml
````php
0 product
````Whereever the cart is updated you can raise an event.
````php
function refreshCart() {
// perform ajax call to refresh info
jQuery.ajax({
url : 'http://targeturl',
success : function(nbOfProducts) {
// nbOfProducts is an integer with the number of products in cart
<?php echo Sweeml::raiseEvent('updateCart', nbOfProducts); ?>
}
});
}
refresh cart
````### Multi file upload
The basic model
````php
2, 'allowEmpty' => true),
);
}
}
````The controller
````php
'ext.sweekit.actions.SwUploadAction',
'asyncDelete' => 'ext.sweekit.actions.SwDeleteAction',
);
}
/**
* initial action
*
* @return void
*/
public function actionIndex() {
$file = new MyFile();
if(isset($_POST['MyFile']) == true) {
// get uploaded files
$realFiles = SwUploadedFile::getInstances($file, 'thefile');
foreach($realFiles as $realFile) {
// save uploaded files
$realFile->saveAs('files/'.$realFile->getName());
}
}
$this->render('index', array('file' => $file));
}
}
````The view
````php
array(
'runtimes' => 'html5, flash',
'auto' => true,
'ui' => true,
'maxFileSize' => '512mb',
'multiSelection' => true,
),
'events'=>array(
'beforeUpload' => 'js:function(up, file){
$(\'#submitButton\').attr(\'disabled\', \'disabled\');
}',
'uploadComplete' => 'js:function(up, files){
$(\'#submitButton\').removeAttr(\'disabled\');
}',
)
)); ?>
'submit', 'id' => 'submitButton')); ?>
````