Symfony - settings.yml (escaping_strategy: true)

Wednesday, May 30, 2012

use
     htmlspecialchars_decode(htmls);
not use
     escaping_strategy: false

Read more...

Symfony - Form File Upload [temp to another server using ftp]

Friday, May 25, 2012

class PhotoForm extends BasePhotoForm
{

    public function configure()
    {
        $this->setWidgets(array(
            'photo' => new sfWidgetFormInputFile(array('label' => 'Зураг')),
        ));

        $this->setValidators(array(
            'photo' => new sfValidatorFile(
                    array(
                        'required' => false,
                        'max_size' => 5242880,
                        'path' => sfConfig::get('sf_upload_dir'),
                        'mime_types' => array(
                            'image/jpeg',
                            'image/pjpeg',
                            'image/png',
                            'image/x-png',
                            'image/gif',
                        ),
                        'validated_file_class' => 'sfValidatedFileLocations'
                    ),
                    array(
                        'required' => 'Та зураг оруулна уу',
                        'max_size' => 'Таны оруулсан зурагны хэмжээ иx байна. Хамгийн иxдээ 5MB.',
                        'mime_types' => 'Та зөвxөн зурган файл оруулаx боломжтой')),
        ));

        $this->widgetSchema['photo'] = new sfWidgetFormInputFileEditable(array(
                    'label' => 'Зураг',
                    'file_src' => FtpHandler::FTPFOLDER . 'files/' . $this->getObject()->getPhoto(),
                    'is_image' => true,
                    'edit_mode' => !$this->isNew(),
            ), array('width' => 500));

        $this->widgetSchema->setNameFormat('photo[%s]');
    }

}

Read more...

Symfony - Doctrine RUD

Thursday, May 24, 2012

Doctrine RUD

READ
$row = Doctrine_Query::create()
            ->select('count(t.id) as cnt')
            ->from('Table t')
            ->where('t.field = ?', 1)
            ->addWhere('t.field2 = ?', 'blabla')
            ->fetchArray();

echo $row['0']['cnt'];

pager

$query = Doctrine_Query::create()->from('Table a');

$pager = new sfDoctrinePager('Table', self::PER_PAGE);
$pager->setQuery($query);
$pager->setPage($page);
$pager->init();

return $pager

public function save(Doctrine_Connection $conn = null)
{
    if ($this->isNew()) {
        $this->setUserId(sfContext::getInstance()->getUser()->getId());
        $this->setCreatedAt(date('Y-m-d H:i:s'));
    }
    return parent::save($conn);
}

Read more...

FLEX and BlazeDS - Request IP

Thursday, May 17, 2012

HttpServletRequest request = FlexContext.getHttpRequest();
String clientIP = request.getRemoteAddr();

Read more...

Symfony - Calling Component Action from Module Action + AJAX

class newsComponents extends sfComponents
{
    public function executeCall()
    {
        echo $this->id_bna;     
        return sfView::NONE;
    }
}

Read more...

JQuery - Practice 1

Monday, May 14, 2012

// FORM SUBMIT HANDLER

$(document).ready(function() {

    $('#formId').submit(function() {
       
        if ($('#formId input[type=checkbox]:checked').length) {               
           
            return confirm("Устгах уу?");
           
        } else {
            alert('Ядаж нэг утга сонгоно уу!');
            return false;
        }

    });

});

Read more...

Symfony - Custom Query + Set Parameter

$pdo = Doctrine_Manager::connection()->getDbh();

$sql = 'select id, name, descr, created_at from news where name like :name-value and descr like :descr-value';
$stmt = $pdo->prepare($sql);
$params = array("name-value" => $name, "descr-value" => '%' . $descr . '%');
$stmt->execute($params);

// or

$sql = 'select id, name, descr, created_at from news where name like ? and descr like ?';
$stmt = $pdo->prepare($sql);
$params = array($name, '%' . $descr . '%');
$stmt->execute($params);

return $stmt->fetchAll();

Read more...

Adobe Flash

ImageHost.org

Adobe Flex

ImageHost.org

Adobe Flash Catalyst

ImageHost.org

  © Blogger templates

Back to TOP