Skip to content

Instantly share code, notes, and snippets.

/**
* The base view from which all Customer module views inherit.
*/
class MyProjectCustomerBaseView extends TallimestariBaseView
{
public function setupHtml(AgaviRequestDataHolder $rd, $layoutName = null)
{
parent::setupHtml($rd, $layoutName);
$this->getLayer('content')->setSlot('mainmenu', $this->createSlotContainer(
'Customer',
ServiceQuery::create()
->join('ServiceWeb', 'INNER JOIN')
->join('ServiceWeb.ServiceWebDomain', 'LEFT JOINT')
->join('ServiceWeb.ServiceWebHosting', 'LEFT JOIN')
->withColumn('COUNT(DISTINCT(ServiceWeb.ID))', 'accounts')
->withColumn('COUNT(DISTINCT(ServiceWebDomain.ID))', 'domains')
->withColumn('COUNT(DISTINCT(ServiceWebHosting.ID)), 'hosting')
->select(array('accounts', 'domains', 'hosting'))
->find();
<?php
$start = new DateTime();
$end = new DateTime("+1 month");
echo $end->setTime(0,0,0)->diff($start->setTime(0,0,0))->format("%d");
<validator class="isset" provides="foo_set" required="false">
<arguments base="foos[]">
<argument />
</arguments>
</validator>
<validator class="number" depends="foos[%2$s][foo_set]">
<arguments base="bars[]">
<argument />
</arguments>
</validator>
@nnarhinen
nnarhinen / gist:632034
Created October 18, 2010 10:55
routing.xml
<xi:include href="%core.app_dir%/config/routing.%locale%.xml" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:fallback>
<routes>
<!-- default routes -->
</routes>
</xi:fallback>
</xi:include>
public function executeHtml(AgaviRequestDataHolder $rd) {
$this->setupHtml($rd);
$this->setAttribute('foo', 'bar');
//dom something complicated
}
public function executeAJAX(AgaviRequestDataHolder $rd) {
$this->setupHtml($rd);
$this->setAttribute('foo', 'bar');
//dom something complicated
$(this).find('form').submit(function() {
$.post($(this).attr('action'), $(this).serialize(), $this._handleSearchResult, 'json')
return false;
});
var foo = {
someMethod: function() {
var $this = this;
$this.someForm.submit(function() {
$.post($(this).attr('action'), $(this).serialize(), $this._handleSearchResult, 'json');
return false;
});
},
_handleSearchResult: function(data) {
//do something but have to access the widget here. this is just an ajax callback object
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https") {
$_SERVER['SERVER_PORT'] = 443;
$_SERVER['HTTPS'] = 'on';
}
array(31) {
["SCRIPT_URL"]=>
string(9) "/test.php"
["SCRIPT_URI"]=>
string(31) "http://foo.domain.tld/test.php"
["HTTP_HOST"]=>
string(15) "foo.domain.tld"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_ACCEPT"]=>