ďťż

[Zend Framework][OPT] Integracja

       

Podstrony


telcocafe

Witam. Jak zintegrować ze sobą OPT z ZF?? Znalazłem coś takiego
<?php define('OPT_DIR', '../library/OPT/'); require_once(OPT_DIR.'opt.class.php'); Zend_Loader::loadClass('Zend_View_Interface'); class Zend_View_Opt implements Zend_View_Interface { /** * OPT Engine * * @var optClass */ private $_optEngine; public function __construct($tplDir = null, $compileDir = null) { $this->_optEngine = new optClass(); if ($tplDir === null) { $this->_optEngine->root = realpath("../tmp/view/"); } else { $this->_optEngine->root = $tplDir; } if ($compileDir === null) { $this->_optEngine->compile = realpath("../application/"); } else { $this->_optEngine->compile = $compileDir; } $this->_optEngine->gzipCompression = 1; } /** * Zwraca obiekt silnika szablonów OPT * * @return optClass */ public function getEngine() { return $this->_optEngine; } /** * Set the path to find the view script used by render() * * @param string|array The directory (-ies) to set as the path. Note that * the concrete view implentation may not necessarily support multiple * directories. * @return void */ public function setScriptPath($path) { if (is_readable($path)) { $this->_optEngine->root = $path; return; } throw new Exception('Nieprawidłowa ścieżka'); } /** * Assign a variable to the view * * @param string $key The variable name. * @param mixed $val The variable value. * @return void */ public function __set($key, $val) { $this->_optEngine->assign($key, $val); } public function __get($key) { return $this->_optEngine->data[$key]; } /** * Allows testing with empty() and isset() to work * * @param string $key * @return boolean */ public function __isset($key) { if (array_key_exists($key, $this->_optEngine->data)) { return true; } else { return false; } } /** * Allows unset() on object properties to work * * @param string $key * @return void */ public function __unset($key) { unset($this->_optEngine->data[$key]); } /** * Assign variables to the view script via differing strategies. * * Suggested implementation is to allow setting a specific key to the * specified value, OR passing an array of key => value pairs to set en * masse. * * @see __set() * @param string|array $spec The assignment strategy to use (key or array of key * => value pairs) * @param mixed $value (Optional) If assigning a named variable, use this * as the value. * @return void */ public function assign($spec, $value = null) { if (is_array($spec)) { $this->_optEngine->assignGroup($spec); return; } $this->_optEngine->assign($spec, $value); } /** * Clear all assigned variables * * Clears all variables assigned to Zend_View either via {@link assign()} or * property overloading ({@link __get()}/{@link __set()}). * * @return void */ public function clearVars() { $this->_optEngine->data = array(); } /** * Processes a view script and returns the output. * * @param string $name The script script name to process. * @return string The script output. */ public function render($name) { return $this->_optEngine->parse(); } } ?>

Dodałem parę rzeczy i kilka zmieniłem np. na class Zend_View_Opt extends Zend_View_Abstract
<?php set_include_path('../zend_framework'.PATH_SEPARATOR. get_include_path()); require_once 'Zend/Loader.php'; function __autoload($class) { Zend_Loader::loadClass($class); } define('OPT_DIR', '../lib/'); require_once(OPT_DIR.'opt.class.php'); class Zend_View_Opt extends Zend_View_Abstract { private $_optEngine; public function __construct($tplDir = null, $compileDir = null) { $this->_optEngine = new optClass(); if ($tplDir === null) { $this->_optEngine->root = realpath("../application/views/index/"); } else { $this->_optEngine->root = $tplDir; } if ($compileDir === null) { $this->_optEngine->compile = realpath("../application/"); } else { $this->_optEngine->compile = $compileDir; } $this->_optEngine->gzipCompression = 1; } public function getEngine() { return $this->_optEngine; } protected function _run() { include func_get_arg(0); } ...
I nadal nie działa :( Może coś pominąłem
Użytkownik web_dd edytował ten post 12 wrzesień 2007, 20:48
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • nvm.keep.pl

  • Sitedesign by AltusUmbrae.