Skip to content

Instantly share code, notes, and snippets.

View stephaneerard's full-sized avatar

Stéphane Erard stephaneerard

  • Pragmatism & Enthusiasm
  • Nice, France
View GitHub Profile
@stephaneerard
stephaneerard / gist:720143
Created November 29, 2010 16:20
A sf Task for diem to manage module/action security
<?php
class dmSecureModuleActionTask extends dmContextTask
{
protected $module, $modulePath, $permissionName, $_options, $_arguments, $dbConn;
protected function configure()
{
parent::configure();
@stephaneerard
stephaneerard / html tags php
Created December 26, 2010 15:12
Returns an array with html tags
public function getHtmlTags() {
$tags = array(
'html','head','body',
'base','link','meta','object','script','style','title','basefont','isindex',
'p','h1','h2','h3','h4','h5','h6','dl','dt','dd','ol','ul','li','adress','blockquote','center','del','div','hr','ins','noscript','pre',
'a','abbr','acronym','dfn','em','strong','code','samp','kbd','var',
'b','i','big','small','strike','tt','u','font','span','br','bdo','cite','del','ins','q','sub','sup',
'applet','area','img','map','param',
'form','button','fieldset','input','label','legend','option','optgroup','select','textarea',
'table','tr','th','td','colgroup','col','caption','thead','tbody','tfoot',
@stephaneerard
stephaneerard / dmPageSynchronizer.php
Created February 7, 2011 12:58
Fixing pdo queries with table connection parameter
<?php
class dmPageSynchronizer
{
protected
$moduleManager,
$nodeParentIdStmt;
public function __construct(dmModuleManager $moduleManager)
{
@stephaneerard
stephaneerard / gist:822121
Created February 11, 2011 09:23
My BaseFormDoctrine to manage setup for edit || save (+some dm behaviors management)
<?php
/**
* Project doctrine form base class.
*/
abstract class BaseFormDoctrine extends dmFormDoctrine
{
/**
* @var sfDateFormat
*/
<script type="text/javascript">
(function($){
var printProcess = function(){
var imgSrc = '<?php echo $product->getTicketGeneration()->get('Image')->getFullWebPath()?>';
var subWnd = window.open('', 'stayTicketPrinterWindow', 'width=1024,height=800,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
if($('img', subWnd.document.body).size() === 0)
{
var imgTag = $('<img/>').attr('src', imgSrc);
$(subWnd.document.body).append(imgTag);
Hello Community,
When considering writting large apps with sf2, with a back and a front, some questions are occuring, about how to structure things.
Say we have one large website with a front-end for end-users and a back-end to feed the front-end, control objects, etc.
The two "apps" will use same models, obviously.
We'd like to separate our "views" on the models for the two apps (I call them "perspectives").
<?php
class ItSsLoadPhpDataTask extends dmContextTask
{
protected function configure()
{
parent::configure();
$this->addOption('files', 'f', sfCommandOption::PARAMETER_OPTIONAL | sfCommandOption::IS_ARRAY, 'Give files to load');
$this->addOption('load-dump', 'l', sfCommandOption::PARAMETER_NONE, 'Loads db dump before');
@stephaneerard
stephaneerard / gist:1020865
Created June 11, 2011 19:26
Diem - Securing Front application
The trick:
- overload sfBasicSecurityFilter->execute() method to check if $request->hasParameter('bypass_security')
and if this parameter is set to true
- overload dmUser actions executeSignin() and add request parameter bypass_security and set it to true
//apps/front/config/filters.yml
rendering: ~
def by_recipients(recipients)
@messages_query ||= db.prepare "SELECT id, sender, recipients, subject, size, created_at FROM message WHERE recipients LIKE ?"
@messages_query.execute("%#{recipients}%").map do |row|
Hash[row.fields.zip(row)].tap do |message|
message["recipients"] &&= ActiveSupport::JSON.decode message["recipients"]
end
end
end
function _download() {
return new Promise(function (resolve, reject) {
debug("download", image.url);
var tmpName = tmp.tmpNameSync();
var writable = fs.createWriteStream(tmpName);
var streamSource = request(image.url);
streamSource