Skip to content

Instantly share code, notes, and snippets.

View eminetto's full-sized avatar
:octocat:
always learning

Elton Minetto eminetto

:octocat:
always learning
View GitHub Profile
//criando a paginaçao
Zend_Paginator::setDefaultScrollingStyle('Sliding');
                        Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/paginator.phtml');
//manda o paginador usar os dados vindos do banco
$paginator = Zend_Paginator::factory($posts->fetchAll());
//pagina atual. Se nao vier nenhuma pagina, mostra a primeira
$currentPage = $this->_getParam('page', 1);
//5 ítens por página
$paginator->setCurrentPageNumber($currentPage)->setItemCountPerPage(5);
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->previous)); ?>">
< Previous
</a> |
<?php else: ?>
<span class="disabled">< Previous</span> |
<?php endif; ?>
@eminetto
eminetto / EmailController.php
Created May 23, 2011 19:43
EmailController
<?php
class EmailController extends Zend_Controller_Action {
        //configuração do exemplo
        private $smtp = 'smtp.gmail.com';
        private $conta = '[email protected]';
        private $senha = 'senha';
        private $de = '[email protected]';
        private $para = '[email protected]';
       
        //envio de e-mail texto
<form method="post" enctype="multipart/form-data" name="form" action="anexo">
Arquivo: <input type="file" name="file" size="30" /> <br />
<input name="Enviar" type="submit" id="Enviar" value="Enviar" />
</form>
$writer = new Zend_Log_Writer_Stream(DATA_PATH . 'zf_log.txt');
$log = new Zend_Log($writer);
Zend_Registry::set('log', $log);
$writer = new Zend_Log_Writer_Stream(DATA_PATH . 'zf_log.txt');
$db = Zend_Db::factory("pdo_sqlite", array('dbname'=>DATA_PATH.'zf_log.db'));
$columnMapping = array('pri' => 'priority', 'msg' => 'message');
$dbWriter = new Zend_Log_Writer_Db($db, 'log', $columnMapping);
$log = new Zend_Log();
$log->addWriter($writer);
$log->addWriter($dbWriter);
Zend_Registry::set('log', $log);
// Configuring Profiler
$profiler = new Zend_Db_Profiler_Firebug('db-profiling');
$profiler->setEnabled(true);
$Connection->setProfiler($profiler);
<?php
class UsersController extends Zend_Controller_Scaffolding {
public function init() {
parent::init();
//configuração dos campos a serem mostrados
$fields = array (
'name' => array (
'title' => 'Nome',
'required' => true,
@eminetto
eminetto / ApiController.php
Created June 27, 2011 16:46
ApiController
<?php
class ApiController extends Zend_Rest_Controller
{
public function init()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
if($this->getRequest()->getHeader('apiKey') != 'chave1') {
$this->getResponse()
@eminetto
eminetto / gist:1093224
Created July 19, 2011 17:41
server.js
//http://net.tutsplus.com/tutorials/javascript-ajax/learning-serverside-javascript-with-node-js/
//http://www.toxiccoma.com/random/nodejs-0195-http-post-handling-of-form-data
var sys = require("sys"),
http = require("http"),
querystring = require('querystring');
//cria o servidor
http.createServer(function(request, response) {
post_handler(request, function(request_data)
{