2009年10月2日星期五

[fw-mvc] Plugin by name 'Dojo' was not found in the registry when there is *no* Dojo elements in view !

I reach a problem : views with Dojo elements works well, but I reach "Plugin
by name 'Dojo' was not found in the registry" when there is *no* Dojo
elements in the view !

It fails in layout when : if ($this->dojo()->isEnabled()) {.....}

The error notice :
2009-10-01T09:06:25+02:00 DEBUG (7): Plugin by name 'Dojo' was not found in
the registry; used paths: ( see the "/" and "\" . Where do they comes from ?
)
Zend_View_Helper_:
Zend/View/Helper/;./views\helpers/;C:/travail/www/vivier/application/modules/default/views\helpers/
#0 C:\travail\www\vivier\library\Zend\View\Abstract.php(1118):
Zend_Loader_PluginLoader->load('Dojo')

// index.php
<?php

defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) .
'/../application'));

defined('LIBRARY_PATH')
|| define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));

defined('LOGFILES_PATH')
|| define('LOGFILES_PATH', realpath(dirname(__FILE__) .
'/../logfiles'));
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
getenv('APPLICATION_ENV') : 'production'));

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));


/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

// application.ini

[production]

phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH
"/controllers"

autoloaderNamespaces[] = "App_"

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "default"
resources.frontController.prefixDefaultModule = true

resources.frontController.plugins.layout = "Plugin_ModuleLayout"
resources.frontController.plugins.modulesetup = "Plugin_ModuleSetup"

resources.layout.layoutpath = APPLICATION_PATH "/layouts"

resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "vivier"
resources.db.params.password = "vivier"
resources.db.params.dbname = "vivier"
resources.db.params.date_format = "YYYY-MM-ddTHH:mm:ss"
resources.db.params.charset = "UTF8"
resources.db.isDefaultTableAdapter = true

; View
resources.view[]=""

// bootstrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

protected function _initAutoload()
{
$loader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));

return $loader;
}

protected function _initView()
{
$view = new Zend_View();
$view->setEncoding('UTF-8');
$view->doctype('XHTML1_STRICT');
// Helper DOJO
$view->addHelperPath('Zend/Dojo/View/Helper/','Zend_Dojo_View_Helper');

$view->headMeta('Vivier des Candidatures, TOS','keywords')
->headMeta('Content-Type','text/html; charset=utf-8')
->headMeta()->appendHttpEquiv('Content-Language', 'fr');

$view->headTitle(App_Globals::getConfig()->title);

$view->headLink()->appendStylesheet(App_Globals::getConfig()->css->file,
'screen, projection, print');

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);

return $view;
}
}

// Layout default.phtml

<?php echo $this->partial('header.phtml') ?>

<body class="<?php echo App_Globals::getConfig()->css->theme; ?>" >
<?php echo $this->partial('bandeauaccueil.phtml') ?>
<?php echo $this->partial('bandeaumenu.phtml') ?>
</div>
<div id="middle">
<div id="left-column">
<h3>Header</h3>
etc. .....


// Header.phtml

<?php header('Content-type: text/html; charset=UTF-8'); ?>
<?php echo '<?xml version="1.0" encoding="UTF-8" ?>' ; ?>

<?php echo $this->docType() ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">

<head>

<?PHP echo $this->headTitle()->setIndent(4); ?>
<?PHP echo $this->headMeta()->setIndent(4);?>
<?PHP echo $this->headLink()->setIndent(4);?>
<?PHP echo $this->headStyle()->setIndent(4);?>

<?PHP

// ==> Error here where there is *no* Dojo element in the view !!!!
if ($this->dojo()->isEnabled())
{
$theme = "dijit.themes." . App_Globals::getConfig()->css->theme ;
$dojofile = App_Globals::getConfig()->css->dojofile ;

$this->dojo()->setLocalPath($dojofile)
->setDjConfigOption('locale','fr')
->addStyleSheetModule($theme);
echo $this->dojo();
}
//endif;

echo $this->headScript()->setIndent(4); ?>

</head>


Thanks in advance,

Bourth
--
View this message in context: http://www.nabble.com/Plugin-by-name-%27Dojo%27-was-not-found-in-the-registry-when-there-is-*no*-Dojo-elements-in-view-%21-tp25711666p25711666.html
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-mvc] Conflict between ContextSwitch and AjaxContext ?

Hi there,

I'm writing an article about ContextSwitch and AjaxContext and, for demonstration purposes, I'm working on a really light example wich illustrate both ContextSwitch and AjaxContext.

I don't know exactly why, but I can't use both a "classical" and an Ajax context on a same action.

Example :
I want to display some data from an ini file, the default context is in HTML with a layout.
I have an xml view for my data, and an Ajax search, using AjaxContext.

Xml context is working fine : If I give a format parameter with XML as a value, my Xml view is displayed. Great.
But Ajax context doesn't work : If I don't give a format parameter, it display the entire page with the layout. Logical behavior. If I give an "html" format, ContextSwitch throws an exception "html context does not exists"... It exists, but not for ContextSwitcher.

I manage to make it works, by forcing an html context for AjaxContext, without giving a format parameter with my Ajax call.

Here is my controller code :

    public function init()
    {           
        $this->_helper->ajaxContext
            ->addActionContext('index', 'html');
           
        $this->_helper->contextSwitch
            ->addActionContext('index', 'xml')
            ->initContext();
    }

    public function indexAction()
    {
    $this->_helper->ajaxContext->initContext('html');

        $dataIni = new Zend_Config_Ini(APPLICATION_PATH . '/../data/data.ini');
        $data = $dataIni->toArray();
        $data = $data['sites'];
        $search = $this->_getParam('search');
       
        if (! empty($search)) {
            $filteredData = array();
           
            foreach ($data as $row) {
                if (stripos($row['name'], $search) === 0) {
                    $filteredData[] = $row;
                }
            }
           
            $data = $filteredData;
        }
      
        $this->view->data = $data;
    }

I can deal with this restriction (or issue ?) but I must explain it, as I'm writing an article. Why ContextSwitcher throws an exception when an html AjaxContext format is given on the same action ?

Thanks for Help,
Lucas

2009年10月1日星期四

Re: [fw-mvc] Resetting a Placeholder?

-- Tim Stiles <monkeyt@mac.com> wrote
(on Thursday, 01 October 2009, 10:20 PM -0500):
> I have a widget on each page rendered into a View's placeholder by a
> pre-dispatch plugin. There are a very few pages where I don't want to see it.
>
> Is there a way to actively wipe out that placeholder in the controller rather
> than test for those pages all the time? Placeholder method set() doesn't seem
> to do it, though append() and prepend() work as I expect.
>
> Creating the widget does work that would otherwise happen elsewhere, so I don't
> really care if it builds or not. But with only two or three URLs where it's
> not wanted, I don't want to overhead of a test on the other 99% of pages.

The placeholder container actually extends ArrayObject, so you can call
exchangeArray() on it to empty it out:

$this->placeholder()->exchangeArray(array());

(You can substitute in headTitle, headScript, etc. for "placeholder" in
the above.)

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

[fw-mvc] Resetting a Placeholder?

I have a widget on each page rendered into a View's placeholder by a pre-dispatch plugin.  There are a very few pages where I don't want to see it.

Is there a way to actively wipe out that placeholder in the controller rather than test for those pages all the time? Placeholder method set() doesn't seem to do it, though append() and prepend() work as I expect.

Creating the widget does work that would otherwise happen elsewhere, so I don't really care if it builds or not.  But with only two or three URLs where it's not wanted, I don't want to overhead of a test on the other 99% of pages.

Tim Stiles,
Co-Organizer of DallasPHP
monkeyt@DallasPHP.org

Re: [fw-mvc] redirect after secconds?

It sounds as if they want there to be a page visible to the user for 3
seconds before redirecting. In general, unless there is some kind of
slow server side processing going on, you would never really want to use
sleep(), during a request.

This effectively will pause the script from running, and during that
time, it will just look like the server is hung. The more ideal
solution is, as they noted, the HttpEquiv. That is a good solution and
very x-browser compatible. Personally, given the environments I target
with my applications, the browsers, and the general availability of
javascript.. this kind of thing would typically be done with a
javascript redirect.

-ralph

Dolf Schimmel wrote:
> sleep(3);
> $this->view->_redirect()
>
> On Tue, Sep 29, 2009 at 7:13 AM, sina miandashti <miandashti@gmail.com> wrote:
>> thanks all...:X
>>
>>
>> --
>> ________________
>> Sincerely
>> Sina Miandashti
>> MuSicBasE.ir & InvisionPower.ir Admin
>>
>
>

Re: [fw-mvc] creating a cli interface to mvc web app

Great thanks again. I have been thinking bypassing Zend's MVC and just having a class that calls a service that writes out the static pages.

The service would essentially have to manage the Zend_Layout and Zend_View pieces. something like this:

class Generator{

    public function generatePage(){
        $file='/data/sites/site.com/www/docs/test_jt.html';
        $layout=new Zend_Layout();
        $layout->setLayoutPath('/data/sites/site.com/www/zf/app/layouts');
        $layout->setLayout('test');

   
        $content_view=new Zend_View();
        $content_view->setScriptPath('/data/sites/site.com/www/zf/app/views/scripts');
        $site_view=$content_view->render('partials/jt.phtml');
        $layout->content=$site_view;
        $data=$layout->render();
        file_put_contents($file, $data);
    }
}

But obviously, the MVC magic is gone for things like the layout helper allowing things like echo'ing partials within layouts. Is there a way to allow within my layout:
<?php
echo $this->parital('partials/a_sample_partial.phtml');
?>

thanks for any help.

-j

From: Pádraic Brady <padraic.brady@yahoo.com>
To: water <zflist@yahoo.com>
Cc: Zend Framework MVC <fw-mvc@lists.zend.com>
Sent: Wednesday, September 30, 2009 3:59:56 PM
Subject: Re: [fw-mvc] creating a cli interface to mvc web app

I posted a blog article about this just yesterday. The problem is that routing is a built in requirement of the FrontController dispatch cycle and there's no way to disable it, and yes, by default it insists on complaining about CLI requests.

You can wrok around it by supplying the FrontController with a custom Router which basically stubs all the right methods a Router needs, but which are all empty. So the FC can do routing, but the Router is just a dummy class that does nothing. Messy, but works ;). Here's the class I'm using:

<?php

class ZFExt_Controller_Router_Cli implements Zend_Controller_Router_Interface
{

    public function route(Zend_Controller_Request_Abstract $dispatcher){}
    public function assemble($userParams, $name = null, $reset = false, $encode = true){}
    public function getFrontController(){}
    public function setFrontController(Zend_Controller_Front $controller){}
    public function setParam($name, $value){}
    public function setParams(array $params){}
    public function getParam($name){}
    public function getParams(){}
    public function clearParams($name = null){}

}
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: water <zflist@yahoo.com>
To: fw-mvc@lists.zend.com
Sent: Wed, September 30, 2009 9:35:55 PM
Subject: [fw-mvc] creating a cli interface to mvc web app

I wanted to create a scriptable cli to a web app that we have have. One of the things that it does is that it kicks off a set of writing thousands of static html files.

I have something like the following:
$fc=Zend_Controller_Front::getInstance();
$fc->setControllerDirectory(array(
                     'default'=>$app.'/controllers/'));

Zend_Layout::startMvc(array('layoutPath' => $app.'/layouts/'));

$request=new Zend_Controller_Request_Simple('jt','generator');
$response=new Zend_Controller_Response_Cli();

$fc->setRequest($request);
$fc->setResponse($response);
$fc->throwExceptions(true);
Zend_Debug::dump($request);
$fc->dispatch();

but it gives me the following error: 
PHP Fatal error:  Uncaught exception 'Zend_Controller_Router_Exception' with message 'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object' in /data/sites/site/www/zf_source/library/Zend/Controller/Router/Rewrite.php:359

Do I need to call this upon the index.php that I have in my doc_root? 

I'm sure somebody has crossed this bridge so I greatly appreciate the help.

-jonathan



Re: [fw-mvc] Zend_Form Validator doesn't work with a custom decorator

 $this->addElement('select', 'regions', array(            'multiOptions' =>$this->data['regions'],            'required'    => true,            'decorators' =>  array('Errors',array('ViewHelper',array('helper' => 'formSelect'))),            'validators'  => array(                 array('Digits',true),                     array('Db_RecordExists', false, array('table' => 'regions',                                                              'field' => 'rcode'))                 )         )); 

View this message in context: Re: Zend_Form Validator doesn't work with a custom decorator
Sent from the Zend MVC mailing list archive at Nabble.com.