{"id":16296794,"url":"https://github.com/pgaultier/sweekit","last_synced_at":"2025-03-20T04:31:43.346Z","repository":{"id":2496541,"uuid":"3470893","full_name":"pgaultier/sweekit","owner":"pgaultier","description":"Sweelix development kit","archived":false,"fork":false,"pushed_at":"2014-01-20T09:20:11.000Z","size":1587,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-11T20:23:58.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.sweelix.net/sweekit/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgaultier.png","metadata":{"files":{"readme":"readme.mkd","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-17T15:10:20.000Z","updated_at":"2016-03-23T04:42:22.000Z","dependencies_parsed_at":"2022-08-02T20:31:11.357Z","dependency_job_id":null,"html_url":"https://github.com/pgaultier/sweekit","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fsweekit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fsweekit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fsweekit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fsweekit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgaultier","download_url":"https://codeload.github.com/pgaultier/sweekit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221734430,"owners_count":16872097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:23:59.448Z","updated_at":"2024-10-27T21:18:28.396Z","avatar_url":"https://github.com/pgaultier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sweekit - aka Sweelix toolkit\n\nThe toolkit is under new BSD License except for 3rdParty elements which are under their own\nlicenses.\n\n3rd party tools used in the toolkit are \n\n* http://www.shadowbox-js.com - Shadowbox, dual license http://www.shadowbox-js.com/LICENSE\n* http://www.plupload.com/ - PLupload, dual license http://www.plupload.com/license.php\n\n\nThis toolkit was written to ease javascript access during our developments.\nIn order to not create conflict, Sweekit classes are prefixed with _Sw_\n\nA short explain is available in the doc directory.\n\nAvailable features :\n\n* javascript - see doc/sweekit.mkd and doc.javascript.mkd\n* components - some usefull components\n* helpers - Sweeml (extends CHtml) - see doc/sweekit.mkd\n* behaviors - SwAjaxBehavior, SwClientScriptBehavior, SwRenderBehavior - see doc/behaviors.mkd\n* filters - SwProtocolFilter - see doc/filters.mkd\n* validators - SwFileValidator (for plupload)\n* actions - SwDeleteAction, SwUploadAction (for plupload)\n* commands - SwUploadCommand (to purge plupload temporary directory)\n* web - SwUploadedFile (Retrieve files uploaded with plupload)\n\n## Samples - because it's always easier to understand what can be done\n\nA sample application has been built and is available in the \"samples\" directory.\n\n## Quick code\n\n### Mobile notifier\n\nThe mobile notifier allow the developper to send notification to iOS and/or\nAndroid system.\n\nOf course, you'll need account information from Google or Apple to be able\nto send notifications.\n\nAdding the notifier component to the application\n\n````php\n\t/* configuration array */\n\tmobileNotification' =\u003e array(\n\t\t'class' =\u003e 'ext.sweekit.actions.SwMobileNotifier',\n\t\t'mode' =\u003e 'production', // can be development to use the sandbox\n\t\t'apnsCertificateFile' =\u003e 'my_apple_certificate_for_push.pem',\n\t\t'apnsCertificatePassphrase' =\u003e 'my_apple_certificate_passphrase', // comment out if there is no passphrase\n\t\t'apnsEmbeddedCaFile'=\u003etrue, // embed entrust ca file if needed (ssl errors, ...)\n\t\t'c2dmUsername' =\u003e 'my_gmail_push_account@gmail.com',\n\t\t'c2dmPassword' =\u003e 'my_gmail_push_account_password',\n\t\t'c2dmApplicationIdentifier' =\u003e 'my_gmail_push_app_identifier',\n\t),\n````\n\nYou are now able to push messages to mobile devices\n\n#### Sample for Android\n\n````php\n// send message to device\n$res = Yii::app()-\u003egetComponent('mobileNotification')-\u003esendC2dmMessage(\n\t'the_android_device_id', // look like base64 encoded data\n\tarray('badge' =\u003e 12, 'message' =\u003e 'My message to send') // the payload to send to the device\n);\n````\n\n#### Sample for iOS\n\n````php\n// send message to device\n$res = Yii::app()-\u003egetComponent('mobileNotification')-\u003esendApnsMessage(\n\t'the_ios_device_id', // 64 characters hex id\n\tarray('aps' =\u003e array(\n\t\t'badge' =\u003e CPropertyValue::ensureInteger(12), // make sure data is an integer\n\t\t'alert' =\u003e 'My message to send',\n\t))\n);\n````\n\nApple added a function to check if device should still receive notification.\n\nThis method should be called using a cron system in order to purge old pushId from\nyour database to avoid sending useless notifications\n\n````php\n$res = Yii::app()-\u003egetComponent('mobileNotification')-\u003ereadApnsFeedback();\n/**\n * $res is an array of array : \n * $res = array(\n *\t\tarray($timeStamp, $pushId1),\n *\t\tarray($timeStamp, $pushId2),\n *\t\t// ...\n * );\n */\n````\n\n\n\n### Callback system\n\nAs an example, you have created an online shop and in several places, the cart is updated.\nIf in the header there is a widget which shows the number of products, this widget \nshould be updated when the cart is updated.\n\nUsing the callback system you can : \n\nRegister an event in the widget using Sweeml\n\n````php\n    \u003c?php Sweeml::registerEvent('updateCart', \"function(data){jQuery('#cart.nb').html(data+' products');}\"); ?\u003e\n    \u003cdiv id=\"cart\"\u003e0 product\u003c/div\u003e\n````\n\nWhereever the cart is updated you can raise an event.\n\n````php\n    \u003cscript type=\"text/javascript\"\u003e\n        function refreshCart() {\n            // perform ajax call to refresh info\n            jQuery.ajax({\n                url : 'http://targeturl',\n                success : function(nbOfProducts) {\n                    // nbOfProducts is an integer with the number of products in cart\n                    \u003c?php echo Sweeml::raiseEvent('updateCart', nbOfProducts); ?\u003e\n                }\n            });\n        }\n    \u003c/script\u003e\n    \u003ca href=\"#\" onclick=\"refreshCart()\"\u003erefresh cart\u003c/a\u003e\n````\n\n### Multi file upload\n\nThe basic model \n\n````php\n    \u003c?php \n    class MyFile extends CFormModel {\n        public $thefile;\n        public function rules() {\n            // NOTE: you should only define rules for those attributes that\n            // will receive user inputs.\n            return array(\n                array('thefile', 'SwFileValidator', 'maxFiles' =\u003e 2, 'allowEmpty' =\u003e true),\n            );\n        }\n    }\n````\n\nThe controller\n\n````php\n    \u003c?php \n    class UploadController extends CController {\n        /**\n         * Attach generic actions to handle async uploads\n         *\n         * @return array\n         */\n        public function actions() {\n            return array(\n                'asyncUpload' =\u003e 'ext.sweekit.actions.SwUploadAction',\n                'asyncDelete' =\u003e 'ext.sweekit.actions.SwDeleteAction',\n            );\n        }\n     \n        /**\n         * initial action\n         *\n         * @return void\n         */\n        public function actionIndex() {\n            $file = new MyFile();\n            if(isset($_POST['MyFile']) == true) {\n                // get uploaded files\n                $realFiles = SwUploadedFile::getInstances($file, 'thefile');\n                foreach($realFiles as $realFile) {\n                    // save uploaded files\n                    $realFile-\u003esaveAs('files/'.$realFile-\u003egetName());\n                }\n            }\n            $this-\u003erender('index', array('file' =\u003e $file));\n        }\n    }\n````\n\nThe view\n\n````php\n    \u003c?php echo Sweeml::activeAsyncFileUpload($file, 'thefile',array(\n        'config' =\u003e array(\n            'runtimes' =\u003e 'html5, flash',\n            'auto' =\u003e true,\n            'ui' =\u003e true,\n            'maxFileSize' =\u003e '512mb',\n            'multiSelection' =\u003e true,\n        ),\n        'events'=\u003earray(\n            'beforeUpload' =\u003e 'js:function(up, file){ \n                $(\\'#submitButton\\').attr(\\'disabled\\', \\'disabled\\'); \n            }',\n            'uploadComplete' =\u003e 'js:function(up, files){\n                $(\\'#submitButton\\').removeAttr(\\'disabled\\'); \n            }',\n        )\n    )); ?\u003e\n    \n    \u003c?php echo Sweeml::htmlButton('submit', array('type' =\u003e 'submit', 'id' =\u003e 'submitButton')); ?\u003e\n````\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Fsweekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgaultier%2Fsweekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Fsweekit/lists"}