um mit dem squidclient veraltete dateien aus dem cache zu entfernen, geht man wie folgt vor:
user@server:/www$ squidclient -m PURGE http://www.example.com/js/javascript.js
um mit dem squidclient veraltete dateien aus dem cache zu entfernen, geht man wie folgt vor:
user@server:/www$ squidclient -m PURGE http://www.example.com/js/javascript.js
um den output type einer agavi action auch nach dem routing zu ändern, kann man innerhalb der action den output type überschreiben.
/**
* assume that 'html' is the standard GET output for this action
* when this action is called via POST you want to change the output type to 'json'
* because on error or success you want to show small messages per json instead full html
*/
public function executeRead(AgaviRequestDataHolder $rd)
{
return 'Input';
}
public function executeWrite(AgaviRequestDataHolder $rd)
{
$this->getContainer()->setOutputType($this->getContext()->getController()->getOutputType('json'));
try
{
// do POST stuff
}
catch(Exception $e)
{
$this->setAttribute('message', $e->getMessage());
return 'Error';
}
return 'Success';
}
hier könnt ihr euch fusioncharts ansehen (und downloaden)
Um modular und agil in Kohana zu entwickeln, wurde ein Skript Kollektor notwendig, der aus allen Controllern (Template- oder Standard-Controllern) Skripte (CSS, Javascript) sammeln kann.
Diese Scripte werden dann auf den jeweiligen Mastertemplates wieder an den richtigen Stellen eingebunden.
Dazu habe ich einen neuen Helper unter application/helpers/collector.php eingerichtet.
class Collector_Core
{
/**
* Arrays containing URL's to scripts/styles (fill with standards)
* @var string
*/
static protected $scripts = array();
static protected $styles = array();
/**
* Adds a url to store
* @param string $file the local path to file
* @return void
*/
static public function addJs($file)
{
self::$scripts[] = $file;
}
/**
* Adds a url to store
* @param string $file the local path to file
* @return void
*/
static public function addCss($file)
{
self::$styles[] = $file;
}
/**
* Generates/renders collectors items
* @param boolean $print whether to echo the output or just return rendered string
* @return string the rendered output
*/
static public function renderJs($print = false)
{
$scripts = array_unique(self::$scripts);
$output = html::script($scripts);
if ($print)
{
echo $output;
}
else
{
return $output;
}
}
/**
* Generates/renders collectors items
* @param boolean $print whether to echo the output or just return rendered string
* @param string|array $media type for this style (all, screen, print, media)
* @return string the rendered output
*/
static public function renderCss($print = false, $media = 'all')
{
$styles = array_unique(self::$styles);
$output = html::stylesheet($styles, $media);
if ($print)
{
echo $output;
}
else
{
return $output;
}
}
} // end of Collector_Core
Dieser Helper kann nun aus allen Controllern heraus befüllt werden.
class Welcome_Controller extends Template_Controller
{
/**
* set master template
*/
public $template = 'master_default.tpl';
/**
* default constructor
* @param void
* @return void
*/
public function __construct()
{
// load parent constructor
parent::__construct();
// collect scripts and styles
collector::addCss('/css/fancybox');
collector::addJs('/js/jquery.1.3.2');
collector::addJs('/js/jquery.fancybox');
}
/** more code here */
} // end of Welcome_Controller
Nachdem nun alle relevanten Skripte eingesammelt wurden, kann man diese auf dem Template wieder ausgeben lassen.
<?php collector::renderCss(true, 'all'); ?> <!-- html code here --> <?php collector::renderJs(true); ?>
Der Kollektor sorgt dafür das keine doppelten Skripte geladen werden.