2010年11月29日星期一

[fw-gdata] It's possible to get Books images from Google Books

Hi every:

I'm newbie using Zend Framework and also Zend GData. I'm just answering if
it's possible to get Google Books images based on ISBN or some others
parameters. If yes how?

Cheers and thx in advance

[fw-webservices] ZendAMF ByteArray

I'm passing an AS3 Image class over to PHP.

The image class contains the following information
byteArray
description

in my save method I'm pulling the bytearray out and saving that into my DB
in a blob like so:
public function SaveImage (Image $im)
{
$ba = new Zend_Amf_Value_ByteArray ( $im->bArray );
$data = mysql_real_escape_string ( $ba->getData () );

$query = "INSERT INTO image ( byteArray ) VALUES ( '".$data."' );";
$result = mysql_query($query);
$error = mysql_error();

if($error)
return "Error: " . $error;
else
return true;

}

This seems to be working as I'm getting the image into the DB, now later I'm
trying to pull the image out with the following code in PHP:

public function GetImages ()
{
$result = mysql_query ( 'SELECT * FROM image');
$array = array();

while ( $row = mysql_fetch_assoc ( $result ) )
{
$ba = new Zend_Amf_Value_ByteArray ( base64_decode ( $row['byteArray'] )
);

$image = new Image ();
$image->id = $row['id'];
$image->bArray = $ba; //$ba->getData();

array_push ( $array, $image );
}

return ( $array );
}

This seems to be return an empty byte array.
Can anyone point me in the right direction on this?
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZendAMF-ByteArray-tp3064702p3064702.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

[fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Rishi Daryanani wrote:
>
> Currently I do use controllers, big controllers with several of its own
> functions within the ProductlistAction() function, to do everything the
> "products list" pages do. That includes getting the products from the
> database...
>

Hi Rishi, this is exactly the type of information that can be retrieved via
a "Product" model. You would essentially retrieve a "list" of models that
fit the "criteria" selected.


Rishi Daryanani wrote:
>
> ...and generating each filter as a side menu on the page.
>

So, each item on the side-menu is a selection criteria/condition. These are
often referred to as search/filter facets.


Rishi Daryanani wrote:
>
> Each "filter" comes from its own two tables, e.g. colour has a "colour"
> table and a "colour_language" linked table for a description per language.
> "Length" has a "length" table with a "length_language" table for a
> description per language. (Multi lingual site).
>

In this case, it does sound like you could defer to building a "Facet"
model. This would really pull a TON of logic away from your controllers and
allow you some testability. Something I am sure you would be hard pressed to
achieve today (you can always re-factor a piece at a time to achieve better
testability).


Rishi Daryanani wrote:
>
> I have no problem in sorting it all out via controllers, as that is what
> we've been doing all along. I'm just trying to understand if there is a
> better way to separate code or classes
>

I would honestly recommend that you clean up your controllers by moving the
logic out to models. You'll find that this will significantly help your
maintenance efforts. The other stuff can be refactored later.

BTW, David made a good point about not necessarily moving to modules. To add
to that point, I would say that I can't tell you whether it is a good idea
or not because I really only know about one part of your application at this
point. To tell you one way or the other would be a guess at this point. I
_can_ tell you that it is probably the last thing you should be focusing on
at this point as it is mostly an organizational tool.


Rishi Daryanani wrote:
>
> ...if they needed to edit a site which uses controllers the way I
> described (without models), what would THEY do to improvise the code,
> let's say, as a quick start for the filters / situation I described in my
> previous mail?
>

As noted above, I would start by moving the logic out of the controller and
go for better testability.


-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3064293.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

If in doubt, use a model ;)

On 29 November 2010 16:53, Rishi Daryanani <rishijd@yahoo.com> wrote:

> Hi David,
>
> Thanks for your reply, but I'm afraid I'm back to square one on confusion
> :(
> Currently I do use controllers, big controllers with several of its own
> functions within the ProductlistAction() function, to do everything the
> "products list" pages do. That includes getting the products from the
> database,
> and generating each filter as a side menu on the page. Each "filter" comes
> from
> its own two tables, e.g. colour has a "colour" table and a
> "colour_language"
> linked table for a description per language. "Length" has a "length" table
> with
> a "length_language" table for a description per language. (Multi lingual
> site).
> There are on any given products list page, more than 5 filters per page.
>
>
> I have no problem in sorting it all out via controllers, as that is what
> we've
> been doing all along. I'm just trying to understand if there is a better
> way to
> separate code or classes, or if using a plain old PHP class will simply
> solve my
> problem. I know it will actually, but I just want to hear from all the
> experienced people here on how THEY would do it, or if they needed to edit
> a
> site which uses controllers the way I described (without models), what
> would
> THEY do to improvise the code, let's say, as a quick start for the filters
> /
> situation I described in my previous mail?
>
> Many thanks,
> Rishi
>
>
>
>
>
> ________________________________
> From: David Muir <davidkmuir+zend@gmail.com <davidkmuir%2Bzend@gmail.com>>
> To: fw-mvc@lists.zend.com
> Sent: Mon, November 29, 2010 6:19:36 PM
> Subject: [fw-mvc] Re: How to instantiate a model class to use its
> functions,
> standard solution?
>
>
> I would not say that "filter" is a model. It is, as it's name implies, a
> filter. :-)
>
> Colour and length are attributes that you'd be filtering. In your case, the
> filter happens to be expressed via sql table joins. That is, unless you're
> selling air filters, in which case I think I've misunderstood your problem
> :-)
>
> Unless you've got a big system with many (relatively independent) parts,
> then modules is probably not what you need. AFAICT, other than organising
> and grouping code, they don't offer much of an advantage over just using
> controllers.
>
> David
> --
> View this message in context:
>
> http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3063519.html
>
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
>
>
>
>

Re: [fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Hi David,

Thanks for your reply, but I'm afraid I'm back to square one on confusion :(
Currently I do use controllers, big controllers with several of its own
functions within the ProductlistAction() function, to do everything the
"products list" pages do. That includes getting the products from the database,
and generating each filter as a side menu on the page. Each "filter" comes from
its own two tables, e.g. colour has a "colour" table and a "colour_language"
linked table for a description per language. "Length" has a "length" table with
a "length_language" table for a description per language. (Multi lingual site).
There are on any given products list page, more than 5 filters per page.


I have no problem in sorting it all out via controllers, as that is what we've
been doing all along. I'm just trying to understand if there is a better way to
separate code or classes, or if using a plain old PHP class will simply solve my
problem. I know it will actually, but I just want to hear from all the
experienced people here on how THEY would do it, or if they needed to edit a
site which uses controllers the way I described (without models), what would
THEY do to improvise the code, let's say, as a quick start for the filters /
situation I described in my previous mail?

Many thanks,
Rishi

________________________________
From: David Muir <davidkmuir+zend@gmail.com>
To: fw-mvc@lists.zend.com
Sent: Mon, November 29, 2010 6:19:36 PM
Subject: [fw-mvc] Re: How to instantiate a model class to use its functions,
standard solution?


I would not say that "filter" is a model. It is, as it's name implies, a
filter. :-)

Colour and length are attributes that you'd be filtering. In your case, the
filter happens to be expressed via sql table joins. That is, unless you're
selling air filters, in which case I think I've misunderstood your problem
:-)

Unless you've got a big system with many (relatively independent) parts,
then modules is probably not what you need. AFAICT, other than organising
and grouping code, they don't offer much of an advantage over just using
controllers.

David
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3063519.html

Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-webservices] Re: XmlRpc string decode into struct problem

-- ppafford <phillpafford@gmail.com> wrote
(on Tuesday, 23 November 2010, 02:00 PM -0800):
> Sorry to re-open a old thread but I wanted to know if I could use the
> MethodName as the index key for the return array?

<snip -- multicall example>

> How (If possible) can I get it to return something like this
>
> <code>
> Array
> (
> [0] => Array
> (
> [0] => system.listMethods
> [1] => system.methodHelp
> [2] => system.methodSignature
> [3] => system.multicall
> [4] => md5Value
> )
>
> [md5Value] => 0cff048a9159b57d3568e06ee6d5b454
> )
> </code>
>
> With the MethodName as the array index

It's not, as doing so would violate the XML-RPC multicall specification.

You could likely extend Zend_XmlRpc_Client to do that, but it won't be
something we do in the base library.

The approach you would take is to extend Zend_XmlRpc_Client, and modify
the call() method slightly. If I were to do it, I'd do something like
this:

public function call($method, $params = array())
{
$response = parent::call($method, $params);
if (!$method = 'system.multicall') {
return $response;
}

$newResponse = array();
foreach ($params as $index => $callParams) {
$newResponse[$callParams['methodName']] = $response[$index];
}
return $newResponse;
}

(Note: completely untested!)

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

[fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

I would not say that "filter" is a model. It is, as it's name implies, a
filter. :-)

Colour and length are attributes that you'd be filtering. In your case, the
filter happens to be expressed via sql table joins. That is, unless you're
selling air filters, in which case I think I've misunderstood your problem
:-)

Unless you've got a big system with many (relatively independent) parts,
then modules is probably not what you need. AFAICT, other than organising
and grouping code, they don't offer much of an advantage over just using
controllers.

David
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3063519.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Hi Wil / all,

Thanks again for your reply and all the details. I think I need to personally
set myself up with a fresh download of the latest ZF, and experiment with
bootstrap as a class, controllers and views, as well as models and "modules"
which are new to me. I am reading up on data mapping and need to experiment with
that too on free time. If you can please let me know, in regard to my last
question from my previous email (pasted below, my comments are below yours):

> If *you* were coding a products list page, would you :
> - simply create many controller auxiliary/helper functions to do the job
> - or set up a products list model to hold the functions
> - or set up a unique class (similar to a model, except we won't *call* it
> a
> model) and store it anywhere in a common directory, even
> models/commonclasses/
> or something like that?
>

>As you suspected, the list itself isn't usually considered a model.
>The product itself is a model. The list is considered a collection.
>Think in terms of an array/iterator of one or more products.

Understood; so the following is my scenario:
- I have a number of products in my database, for convenience we will call each
Product a Model (even though I have not coded it as a model, following my
previous emails, and all my code is in the controller).
- The Product List pages display a collection of products. There is a LOT more
going on though, several requirements in play, a simple example being "Product
filters". E.g.
Filter by Colour:
- black
- brown
- white
- blue

Filter by Length:
- Long
- Medium
- Short.

Each of the above filters comes from a couple of table JOINs in the database.
>From everything I've read online, I think I can safely call a "filter" = a
"Model", because it comes from the database and is its own entity. There is a
many-to-many relationship between filters and products. If I just want to start
upgrading the site I'm working on to use the concept of "models", should I go
ahead and prepare a model for a general filter? Then my products-list controller
will generate instances of each filter model.

If I were to further improvise our coding, to keep our "product" related
functions and classes separate from other directories, would you recommend that
I create a "module" or custom namespace to hold my "product" functions? For
example, I could have a

/application/modules/ directory (not created at the moment) and then have a
subdirectory called "products" , which will hold my "models/Product.php" for the
Product model, and "models/Filter.php" for the product Filter. Does this make
sense? Am I on the right track?
At the moment I don't want to give our website a complete turnaround in coding
due to limited time, but I just want to get the "filter" part of the pages coded
"well". I am therefore looking to
- either create a model for this, as explained above.
- create a model for this AND put it in a "modules/products/" directory for the
future, to keep all product-related coding for models there.
- or if I'm not on the right track, then I'd simply store a common functions
file for products-lists anywhere else where I prefer.

The above is quite a standard requirement in terms of developing a products
website, so I am looking to find out a fairly simple yet common way for people
who are somewhat new to the framework's concepts of models and modules.

(Wil, p.s. - thanks for the reference on Zend Paginator; I've not used it but I
don't need paging in this particular website.)

Thanks,
Rishi


________________________________
From: Wil Moore III <wil.moore@wilmoore.com>
To: fw-mvc@lists.zend.com
Sent: Sun, November 28, 2010 12:45:10 AM
Subject: [fw-mvc] Re: How to instantiate a model class to use its functions,
standard solution?


Hi Rishi,

I'll do my best to answer your questions...see below:


Rishi Daryanani wrote:
> Do you see any issues with this approach or is it easy to switch to a
> class...

While there is nothing wrong with the older approach (I've supported code
that was setup this way), there are a few benefits to the newer bootstrap
facilities and Zend_Application.

This is not exhaustive and I'm trying to be brief so off the top of my head:

1. You can simply configure "resources" in your application.ini (or .xml if
that is what you use) and they are bootstrapped and available for use
throughout the application.
2. You can re-factor your Bootstrap resource "_init*" methods into their
own classes. There are several advantages here, but I won't go deep into
that here.
3. Through conventions, it is easy to understand what resources are
available and what options are avilable on those resources.

Rishi Daryanani wrote:
>
> http://framework.zend.com/manual/en/learning.quickstart.create-model.html...I
> usually load data into a database from my own custom PHP script or via an
> admin interface (e.g. phpPgAdmin for Postgresql) if need be. Is there a
> certain advantage of doing the database updating/data upload in a similar
> way described in the above link? I suppose the advantage is that it keeps
> everything together, within the application/framework.
>

As I use Doctrine2 (ORM, DBAL) and Liquibase (Schema Migrations), I've never
needed to go through the info in the above link. All I can tell you is that
an OO Data Mapping (you may want to read more about this pattern) strategy
and and schema migrations will alleviate a lot of problems and allow you to
focus on other things.


Rishi Daryanani wrote:
>
> ...why do we have two models: Application_Model_GuestbookMapper and
> Application_Model_Guestbook?
>

One of them is a model/entity class and the other is the mapper. You will
want to read up on the Data Mapper pattern (and potentially study Doctrine2,
Hibernate, and Entity Framework) to understand this separation further. The
basic idea (and I mean basic) is that your model/entity class knowns nothing
of how it will be persisted or even if it will be persisted at all. You
should be able to unit-test your plain PHP object (model) without worrying
about persistence.


Rishi Daryanani wrote:
>
> Following the above tutorial I did try to create a
> "Application_Model_Guestbook" model, however what I did not do is execute
> the
> command line code like % zf create model Guestbook.
>

I've only used the "zf" command once. That was to start a skeleton project.
I keep that skeleton project around for starting new ZF projects. What I'm
saying is that I can't tell you much about the "zf" command as I hardly use
it. I can tell you that there is nothing in the framework that you can't do
on your own (without the "zf" command).


Rishi Daryanani wrote:
>
> ...my script kept returing the error that the php file was not found in
> /Application/Model/ - I'm not sure why it was looking in that directory;
>

Sounds like you need to setup the resource autoloader. Again, not sure as I
don't use that either. I keep all models under a library directory. I've
never really found putting resources near the controllers to be an
advantage. Using sane package/namespace conventions sort of negates any
advantage module/controller resource has (in my mind). Of course, YMMV on
this one. BTW, now that we are on PHP 5.3.x, packages/namespaces are even
cleaner.

NOTE: Zend's autoloader works well and is PSR-0 compliant -
http://groups.google.com/group/php-standards/web/psr-0-final-proposal. I've
had no need to add anything else to the equation.


Rishi Daryanani wrote:
>
> must I execute those command line codes again or can I dive straight into
> creating code like the following?
> // application/forms/Guestbook.php
> class Application_Form_Guestbook extends Zend_Form
>

You can build forms just as you build any other class. Loading them is
completely up to you as well. You can use the resource loader (again,
something I personally don't use) or you can put your forms under your
library directory and load them that way.


Rishi Daryanani wrote:
>
> If *you* were coding a products list page, would you :
> - simply create many controller auxiliary/helper functions to do the job
> - or set up a products list model to hold the functions
> - or set up a unique class (similar to a model, except we won't *call* it
> a
> model) and store it anywhere in a common directory, even
> models/commonclasses/
> or something like that?
>

As you suspected, the list itself isn't usually considered a model. The
product itself is a model.
The list is considered a collection. Think in terms of an array/iterator of
one or more products.

Zend Paginator would help you in this regard as well.


Sorry this was so quick but I hope it turns out to be at least somewhat
helpful.


--
Wil Moore III


-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3061840.html

Sent from the Zend MVC mailing list archive at Nabble.com.

2010年11月27日星期六

[fw-webservices] Zend_Uri_Http - square brackets in query string

I was looking into the behavior of http_build_query() with respect to square
brackets ("[", "]") in the query string and I came across this thread:

http://zend-framework-community.634137.n4.nabble.com/Accepting-square-brackets-in-Zend-Uri-Http-td675578.html#none

>From the first post:

On May 01, 2007; 01:12 PM, Shahar Evron wrote:
> Apache, PHP and Firefox all allow you to use unescaped '[]' in requests.
> This conforms to RFC 3986 (http://www.ietf.org/rfc/rfc3986.txt )

I'm failing to see how that conforms to RFC 3986:

query = *( pchar / "/" / "?" )

pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

pct-encoded = "%" HEXDIG HEXDIG

sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="

gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"


My reading of the RFC is that square brackets are not included in the
'query' rule. That was also suggested on Jun 02, 2007 in a reply to the
post above, but no reply was made to that.

I think it's unfortunate if square brackets can't be included un-encoded in
the query string according to the relevant spec, e.g. RFC 3986. If the
decision is made to deviate from the spec, that is what it is, but it seems
like this decision may have been made with an inaccurate understanding of
what the spec says. Or have I misunderstood something?

For what it's worth, http_build_query() encodes square brackets, and
parse_str() produces the same result with either encoded or unencoded square
brackets. See http://bugs.php.net/bug.php?id=36656

[fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Hi Rishi,

I'll do my best to answer your questions...see below:


Rishi Daryanani wrote:
> Do you see any issues with this approach or is it easy to switch to a
> class...

While there is nothing wrong with the older approach (I've supported code
that was setup this way), there are a few benefits to the newer bootstrap
facilities and Zend_Application.

This is not exhaustive and I'm trying to be brief so off the top of my head:

1. You can simply configure "resources" in your application.ini (or .xml if
that is what you use) and they are bootstrapped and available for use
throughout the application.
2. You can re-factor your Bootstrap resource "_init*" methods into their
own classes. There are several advantages here, but I won't go deep into
that here.
3. Through conventions, it is easy to understand what resources are
available and what options are avilable on those resources.

Rishi Daryanani wrote:
>
> http://framework.zend.com/manual/en/learning.quickstart.create-model.html...I
> usually load data into a database from my own custom PHP script or via an
> admin interface (e.g. phpPgAdmin for Postgresql) if need be. Is there a
> certain advantage of doing the database updating/data upload in a similar
> way described in the above link? I suppose the advantage is that it keeps
> everything together, within the application/framework.
>

As I use Doctrine2 (ORM, DBAL) and Liquibase (Schema Migrations), I've never
needed to go through the info in the above link. All I can tell you is that
an OO Data Mapping (you may want to read more about this pattern) strategy
and and schema migrations will alleviate a lot of problems and allow you to
focus on other things.


Rishi Daryanani wrote:
>
> ...why do we have two models: Application_Model_GuestbookMapper and
> Application_Model_Guestbook?
>

One of them is a model/entity class and the other is the mapper. You will
want to read up on the Data Mapper pattern (and potentially study Doctrine2,
Hibernate, and Entity Framework) to understand this separation further. The
basic idea (and I mean basic) is that your model/entity class knowns nothing
of how it will be persisted or even if it will be persisted at all. You
should be able to unit-test your plain PHP object (model) without worrying
about persistence.


Rishi Daryanani wrote:
>
> Following the above tutorial I did try to create a
> "Application_Model_Guestbook" model, however what I did not do is execute
> the
> command line code like % zf create model Guestbook.
>

I've only used the "zf" command once. That was to start a skeleton project.
I keep that skeleton project around for starting new ZF projects. What I'm
saying is that I can't tell you much about the "zf" command as I hardly use
it. I can tell you that there is nothing in the framework that you can't do
on your own (without the "zf" command).


Rishi Daryanani wrote:
>
> ...my script kept returing the error that the php file was not found in
> /Application/Model/ - I'm not sure why it was looking in that directory;
>

Sounds like you need to setup the resource autoloader. Again, not sure as I
don't use that either. I keep all models under a library directory. I've
never really found putting resources near the controllers to be an
advantage. Using sane package/namespace conventions sort of negates any
advantage module/controller resource has (in my mind). Of course, YMMV on
this one. BTW, now that we are on PHP 5.3.x, packages/namespaces are even
cleaner.

NOTE: Zend's autoloader works well and is PSR-0 compliant -
http://groups.google.com/group/php-standards/web/psr-0-final-proposal. I've
had no need to add anything else to the equation.


Rishi Daryanani wrote:
>
> must I execute those command line codes again or can I dive straight into
> creating code like the following?
> // application/forms/Guestbook.php
> class Application_Form_Guestbook extends Zend_Form
>

You can build forms just as you build any other class. Loading them is
completely up to you as well. You can use the resource loader (again,
something I personally don't use) or you can put your forms under your
library directory and load them that way.


Rishi Daryanani wrote:
>
> If *you* were coding a products list page, would you :
> - simply create many controller auxiliary/helper functions to do the job
> - or set up a products list model to hold the functions
> - or set up a unique class (similar to a model, except we won't *call* it
> a
> model) and store it anywhere in a common directory, even
> models/commonclasses/
> or something like that?
>

As you suspected, the list itself isn't usually considered a model. The
product itself is a model.
The list is considered a collection. Think in terms of an array/iterator of
one or more products.

Zend Paginator would help you in this regard as well.


Sorry this was so quick but I hope it turns out to be at least somewhat
helpful.


--
Wil Moore III


-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3061840.html
Sent from the Zend MVC mailing list archive at Nabble.com.

2010年11月26日星期五

Re: [fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Hi Wil,

Thanks for your mail. I have a few comments, hope you can help me out.

a) Bootstrap - in the quick start this mentions that Bootstrap can be a class,
but my current file is 'normal' php code, no class involved. I know its better
to have a class, but since we used Zend Framework back in 2008 (and recently
upgraded), our bootstrap.php code has not changed to use a class and our site is
working fine ok with our own custom functions as explained. Do you see any
issues with this approach or is it easy to switch to a class, or at least move
some of the common code to a class? I suppose I need to read more on this to
understand, however it isn't as pressing as my points below for now.

b) http://framework.zend.com/manual/en/learning.quickstart.create-model.html - I
read through this before posting and I re-read it again, I understand some of
the concepts but not all of them. I understand a number of items require us to
execute commands from the command line, however for my interest - I usually load
data into a database from my own custom PHP script or via an admin interface
(e.g. phpPgAdmin for Postgresql) if need be. Is there a certain advantage of
doing the database updating/data upload in a similar way described in the above
link? I suppose the advantage is that it keeps everything together, within the
application/framework.


c) One thing I don't understand about the above is, why do we have two models:
Application_Model_GuestbookMapper
and
Application_Model_Guestbook
I understand the former uses the database, and the latter doesn't, so since they
perform somewhat different tasks, it is better to separate them as two models
rather than one larger model?

d) Following the above tutorial I did try to create a
"Application_Model_Guestbook" model, however what I did not do is execute the
command line code like % zf create model Guestbook.
I suppose this was the problem, because my script kept returing the error that
the php file was not found in /Application/Model/ - I'm not sure why it was
looking in that directory; I thought the default for the above would be
/application/models/ (case sensitive / Apache). I'm sure I must have missed a
configuration step but I was just experimenting with the defaults and how to do
all this by php code / bootstrap.php alone. Finally I understood that I need to
set up a new Zend_Loader_Autoloader_Resource and that worked.

e) http://framework.zend.com/manual/en/learning.quickstart.create-form.html -
this is interesting as I have always put direct HTML form code in my view, and
processed/validated the data in the controller. This worked well for me, but I'm
curious, must I execute those command line codes again or can I dive straight
into creating code like the following?
// application/forms/Guestbook.php
class Application_Form_Guestbook extends Zend_Form

I suppose for the above, it requres an update to bootstrap.php again on the
Resource loader to point the application to the /forms/ directory? If its really
simple and I could have the code for that it'd be great :)

f) My final, big question. I have a products list page, which displays lots of
products - but the Products List isn't really a "model", it is more a list of
Products (while a Product can be classified as a model) - it is complicated by
various scenarios so I have lots of small functions that are specific to the
Product List page, such as filters, ranges, product types (filter again),
sale/non-sale mode, etc. If *you* were coding a products list page, would you :
- simply create many controller auxiliary/helper functions to do the job
- or set up a products list model to hold the functions
- or set up a unique class (similar to a model, except we won't *call* it a
model) and store it anywhere in a common directory, even models/commonclasses/
or something like that?

Any response to any of these questions would help, but my most pressing question
if question f) above.

Many thanks,
Rishi


________________________________
From: Wil Moore III <wil.moore@wilmoore.com>
To: fw-mvc@lists.zend.com
Sent: Wed, November 24, 2010 12:28:44 AM
Subject: [fw-mvc] Re: How to instantiate a model class to use its functions,
standard solution?


Rishi,

Have you tried the quick start guide?
http://framework.zend.com/manual/en/learning.quickstart.create-project.html

I suspect many of your questions will be answered after going through this.

BTW, the "My" namespace is contrived for example purposes -- not saying you
can't use it; however, there is nothing compulsory about it.

Also, anytime you get errors regarding a not found file (class), you can
start by checking that the file is within the include path (the include path
will generally be echo'd in the error/exception output). There can be more
to it if you are autoloading, but generally, you can at least start here.

Please post again after going attempting some of the concepts presented in
the quick start guide.

-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3056023.html

Sent from the Zend MVC mailing list archive at Nabble.com.

2010年11月24日星期三

RE: [fw-mvc] Drupal and Zend

With WAMP I just put separate directories in the www folder for each project
I am working on for development. When I am done the project and ready to go
live I set it up differently on the server. This allows me to keep things
separate, like multiple Zend projects with multiple library versions, etc.

Aaron LaLiberté

-----Original Message-----
From: Evan Kaufman [mailto:evan.kaufman@gmail.com]
Sent: November-24-10 11:49 AM
To: Thomas List
Cc: fw-mvc@lists.zend.com
Subject: Re: [fw-mvc] Drupal and Zend

As long as you have them logically separated through apache (different
virtual hosts with different document roots), you shouldn't have any issues.
----
Evan Kaufman // digitalflophouse.com

On Wed, Nov 24, 2010 at 9:37 AM, Thomas List <thomaslist@hotmail.com> wrote:
>
> Hello,
>
> I currently am running a local installation of XAMPP with a Zend
Framework.   I'm currently developing a project using the Zend Framework.  I
was wondering if it is possible to locally install Drupal on my Mac without
it interfering with my current projects in Zend.  I've just started
researching Drupal, but thought it would good to hear some feedback on
installing and developing with Drupal, while still being able to develop and
run my Zend projects.
>
> Thanks,
> Thomas
>

[fw-mvc] best point in cycle to change default view script

I find I am repeating myself in controllers having actions named 'update'
and 'create,' because I want the default view script for those actions to be
'form'. I've discovered a hot tip about how you can do that in a controller:


$this->_helper->viewRenderer->setRender('form');

If you are pretty confident you'd like to do that application-wide, where's
a good place to set it up, rather than repeating yourself in controller
after controller? Obviously it has to take place after routing. Writing a
whole controller plugin just to do this one thing seems heavy-handed. What
do you think?

--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/

Re: [fw-mvc] Drupal and Zend

As long as you have them logically separated through apache (different
virtual hosts with different document roots), you shouldn't have any
issues.
----
Evan Kaufman // digitalflophouse.com

On Wed, Nov 24, 2010 at 9:37 AM, Thomas List <thomaslist@hotmail.com> wrote:
>
> Hello,
>
> I currently am running a local installation of XAMPP with a Zend Framework.   I'm currently developing a project using the Zend Framework.  I was wondering if it is possible to locally install Drupal on my Mac without it interfering with my current projects in Zend.  I've just started researching Drupal, but thought it would good to hear some feedback on installing and developing with Drupal, while still being able to develop and run my Zend projects.
>
> Thanks,
> Thomas
>

Re: [fw-mvc] Drupal and Zend

hi
what is the folder where you have put your zend framework,
i have created a separate folder for zend project and separate folder in
htdocs for drupal and it works fine.

thanks

On 11/24/2010 7:37 AM, Thomas List wrote:
> Hello,
>
> I currently am running a local installation of XAMPP with a Zend Framework. I'm currently developing a project using the Zend Framework. I was wondering if it is possible to locally install Drupal on my Mac without it interfering with my current projects in Zend. I've just started researching Drupal, but thought it would good to hear some feedback on installing and developing with Drupal, while still being able to develop and run my Zend projects.
>
> Thanks,
> Thomas
>

[fw-mvc] Drupal and Zend

Hello,

I currently am running a local installation of XAMPP with a Zend Framework. I'm currently developing a project using the Zend Framework. I was wondering if it is possible to locally install Drupal on my Mac without it interfering with my current projects in Zend. I've just started researching Drupal, but thought it would good to hear some feedback on installing and developing with Drupal, while still being able to develop and run my Zend projects.

Thanks,
Thomas

2010年11月23日星期二

[fw-webservices] Re: XmlRpc string decode into struct problem

Sorry to re-open a old thread but I wanted to know if I could use the
MethodName as the index key for the return array?

<code>
$connection = new Zend_XmlRpc_Client('http://localhost/xmlrpc');
$client = $connection->getProxy();
$request = array(
array(
'methodName' => 'system.listMethods',
'params' => array()
),
array(
'methodName' => ' system.methodHelp',
'params' => array('md5Value')
),
array(
'methodName' => 'md5Value',
'params' => array(' system.listMethods')
);

$response = $client->system->multicall($request);
echo print_r($response,true);
</code>

Is returns something like this

<code>
Array
(
[0] => Array
(
[0] => system.listMethods
[1] => system.methodHelp
[2] => system.methodSignature
[3] => system.multicall
[4] => md5Value
)

[1] => 0cff048a9159b57d3568e06ee6d5b454
)
</code>

How (If possible) can I get it to return something like this

<code>
Array
(
[0] => Array
(
[0] => system.listMethods
[1] => system.methodHelp
[2] => system.methodSignature
[3] => system.multicall
[4] => md5Value
)

[md5Value] => 0cff048a9159b57d3568e06ee6d5b454
)
</code>

With the MethodName as the array index
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/XmlRpc-string-decode-into-struct-problem-tp675573p3056322.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

[fw-mvc] Re: How to instantiate a model class to use its functions, standard solution?

Rishi,

Have you tried the quick start guide?
http://framework.zend.com/manual/en/learning.quickstart.create-project.html

I suspect many of your questions will be answered after going through this.

BTW, the "My" namespace is contrived for example purposes -- not saying you
can't use it; however, there is nothing compulsory about it.

Also, anytime you get errors regarding a not found file (class), you can
start by checking that the file is within the include path (the include path
will generally be echo'd in the error/exception output). There can be more
to it if you are autoloading, but generally, you can at least start here.

Please post again after going attempting some of the concepts presented in
the quick start guide.

-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3056023.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_View directory layout

Saša,

I have used WURFL directly to detect and redirect users to the appropriate
page/view.

However ZF has a more elegant way of doing this.

http://framework.zend.com/manual/1.11/en/zend.http.user-agent.html

Combining it with what is in this thread, maybe able to produce what you are
looking for.

- Nomolos


On Tue, Nov 23, 2010 at 7:57 AM, Саша Стаменковић <umpirsky@gmail.com>wrote:

> Probably there can be applied similar solution for mobile version of the
> app. Anyone have expiriences with that?
>
> Regards,
> Saša Stamenković
>
>
>
> On Tue, Nov 23, 2010 at 1:32 PM, Nomolos Sharpe <nomolossharpe@gmail.com>wrote:
>
>> Maxim,
>>
>> I think this article maybe able to help.
>>
>> http://www.kharysharpe.com/?p=3
>>
>> Cheers,
>>
>> Nomolos
>>
>>
>>
>> On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko <maxim.savenko@gmail.com
>> >wrote:
>>
>> > I'd like to slightly change the layout of base Zend_View directory
>> layout.
>> > The current layout is as follows:
>> >
>> > view
>> > filters
>> > helpers
>> > scripts
>> >
>> > ... and I'd like to split script directory to several
>> directories(themes),
>> > depending on a theme user will choose.
>> > For example:
>> >
>> > view
>> > filters
>> > helpers
>> > scripts
>> > default
>> > modern
>> > classic
>> >
>> > What is the best way to shoot the bull?
>> >
>> > Thank you,
>> > Maxim Savenko
>> > maxim.savenko@gmail.com
>> >
>>
>>
>>
>> --
>> Regards,
>>
>> Nomolos
>>
>
>


--
Regards,

Nomolos

Re: [fw-mvc] Zend_View directory layout

Maxim,

See some additional code snippet, this was placed in MyApp_Resource_View
(extends Zend_Application_Resource_ResourceAbstract)

$module = $request->getModuleName();
$controller = $request->getControllerName();
$actionName = $request->getActionName();

$moduleDir = $frontController->getModuleDirectory($module);

$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');

$scriptPath =
realpath("$moduleDir/views/{$session->theme}/$controller/$actionName.phtml");

if (file_exists($scriptPath))
$viewRenderer->setViewBasePathSpec(':moduleDir/views/'.
$session->theme);
else

$viewRenderer->setViewBasePathSpec(':moduleDir/views/default');

$viewRenderer->setView($view);


- Nomolos

On Tue, Nov 23, 2010 at 8:10 AM, Maxim Savenko <maxim.savenko@gmail.com>wrote:

> Hi Nomolos,
>
> Thank you, but my question isn't related to public folder.
>
> Anyway thanx to all you guys. I think that setScriptPath in predispatch
> callback is the most simple way. However, extending Zend_View with the new
> base vew structure is fine too.
>
> Thank you
>
> Maxim Savenko
> maxim.savenko@gmail.com
>
>
> 2010/11/23 Nomolos Sharpe <nomolossharpe@gmail.com>
>
> Maxim,
>>
>> I think this article maybe able to help.
>>
>> http://www.kharysharpe.com/?p=3
>>
>> Cheers,
>>
>> Nomolos
>>
>>
>>
>>
>> On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko <maxim.savenko@gmail.com>wrote:
>>
>>> I'd like to slightly change the layout of base Zend_View directory
>>> layout.
>>> The current layout is as follows:
>>>
>>> view
>>> filters
>>> helpers
>>> scripts
>>>
>>> ... and I'd like to split script directory to several
>>> directories(themes),
>>> depending on a theme user will choose.
>>> For example:
>>>
>>> view
>>> filters
>>> helpers
>>> scripts
>>> default
>>> modern
>>> classic
>>>
>>> What is the best way to shoot the bull?
>>>
>>> Thank you,
>>> Maxim Savenko
>>> maxim.savenko@gmail.com
>>>
>>
>>
>>
>> --
>> Regards,
>>
>> Nomolos
>>
>
>


--
Regards,

Nomolos

Re: [fw-mvc] Zend_View directory layout

In my case when I create a mobile version of my sites, I create a new
project, shared the models, libraries, with symlinks. But is other
project. The views, and layout is not the same, the information is very
different, o minimal.


The mobile version required other stuff, we need to know if the mobile
have support for flash, maps, javascripts, etc. In the normal web
version we assumed with this stuff is on.

You can see my project

Normal Version
http://www.dondejugarpaintball.com

Mobile Version
http://m.dondejugarpaintball.com

Other layouts, others views, other domain, others validations, and tiny
information.

But I like have 2 different project, is more easy to me.


On 11/23/2010 09:57 AM, Саша Стаменковић wrote:
> Probably there can be applied similar solution for mobile version of the
> app. Anyone have expiriences with that?
>
> Regards,
> Saša Stamenković
>
>
> On Tue, Nov 23, 2010 at 1:32 PM, Nomolos Sharpe<nomolossharpe@gmail.com>wrote:
>
>> Maxim,
>>
>> I think this article maybe able to help.
>>
>> http://www.kharysharpe.com/?p=3
>>
>> Cheers,
>>
>> Nomolos
>>
>>
>>
>> On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko<maxim.savenko@gmail.com
>>> wrote:
>>> I'd like to slightly change the layout of base Zend_View directory
>> layout.
>>> The current layout is as follows:
>>>
>>> view
>>> filters
>>> helpers
>>> scripts
>>>
>>> ... and I'd like to split script directory to several
>> directories(themes),
>>> depending on a theme user will choose.
>>> For example:
>>>
>>> view
>>> filters
>>> helpers
>>> scripts
>>> default
>>> modern
>>> classic
>>>
>>> What is the best way to shoot the bull?
>>>
>>> Thank you,
>>> Maxim Savenko
>>> maxim.savenko@gmail.com
>>>
>>
>>
>> --
>> Regards,
>>
>> Nomolos
>>

Re: [fw-mvc] Zend_View directory layout

Hi Nomolos,

Thank you, but my question isn't related to public folder.

Anyway thanx to all you guys. I think that setScriptPath in predispatch
callback is the most simple way. However, extending Zend_View with the new
base vew structure is fine too.

Thank you

Maxim Savenko
maxim.savenko@gmail.com


2010/11/23 Nomolos Sharpe <nomolossharpe@gmail.com>

> Maxim,
>
> I think this article maybe able to help.
>
> http://www.kharysharpe.com/?p=3
>
> Cheers,
>
> Nomolos
>
>
>
>
> On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko <maxim.savenko@gmail.com>wrote:
>
>> I'd like to slightly change the layout of base Zend_View directory
>> layout.
>> The current layout is as follows:
>>
>> view
>> filters
>> helpers
>> scripts
>>
>> ... and I'd like to split script directory to several directories(themes),
>> depending on a theme user will choose.
>> For example:
>>
>> view
>> filters
>> helpers
>> scripts
>> default
>> modern
>> classic
>>
>> What is the best way to shoot the bull?
>>
>> Thank you,
>> Maxim Savenko
>> maxim.savenko@gmail.com
>>
>
>
>
> --
> Regards,
>
> Nomolos
>

Re: [fw-mvc] Zend_View directory layout

Probably there can be applied similar solution for mobile version of the
app. Anyone have expiriences with that?

Regards,
Saša Stamenković


On Tue, Nov 23, 2010 at 1:32 PM, Nomolos Sharpe <nomolossharpe@gmail.com>wrote:

> Maxim,
>
> I think this article maybe able to help.
>
> http://www.kharysharpe.com/?p=3
>
> Cheers,
>
> Nomolos
>
>
>
> On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko <maxim.savenko@gmail.com
> >wrote:
>
> > I'd like to slightly change the layout of base Zend_View directory
> layout.
> > The current layout is as follows:
> >
> > view
> > filters
> > helpers
> > scripts
> >
> > ... and I'd like to split script directory to several
> directories(themes),
> > depending on a theme user will choose.
> > For example:
> >
> > view
> > filters
> > helpers
> > scripts
> > default
> > modern
> > classic
> >
> > What is the best way to shoot the bull?
> >
> > Thank you,
> > Maxim Savenko
> > maxim.savenko@gmail.com
> >
>
>
>
> --
> Regards,
>
> Nomolos
>

Re: [fw-mvc] Zend_View directory layout

Maxim,

I think this article maybe able to help.

http://www.kharysharpe.com/?p=3

Cheers,

Nomolos

On Mon, Nov 22, 2010 at 10:14 AM, Maxim Savenko <maxim.savenko@gmail.com>wrote:

> I'd like to slightly change the layout of base Zend_View directory layout.
> The current layout is as follows:
>
> view
> filters
> helpers
> scripts
>
> ... and I'd like to split script directory to several directories(themes),
> depending on a theme user will choose.
> For example:
>
> view
> filters
> helpers
> scripts
> default
> modern
> classic
>
> What is the best way to shoot the bull?
>
> Thank you,
> Maxim Savenko
> maxim.savenko@gmail.com
>

--
Regards,

Nomolos

2010年11月22日星期一

Re: [fw-mvc] How to instantiate a model class to use its functions, standard solution?

Hi all,

Following the below, I managed to update the code successfully as follows.
However I do have questions below, would really appreciate a response:

---- bootstrap.php, updated as follows on the autoloader (see $resourceLoader
code below)
/* Set up autoload so we don't have to explicitely require each Zend Framework
class */

include_once('Zend/Loader/Autoloader.php');
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);

$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => '../application/',
'namespace' => 'My',
));
$resourceLoader->addResourceType('models', 'models/', 'Model');

---- new file: models/ProductTest.php -
class My_Model_ProductTest {
}

---- to call the above from the controller, I do this:
$model_productlist = new My_Model_ProductTest();

I'm relieved it is working, but I'd like to know:
a) If I want to store a few functions in a class, and eventually build up that
class as a Product List class (for the list page for product thumbnails), should
I start here, by creating a model? Or is there another recommendation to store
functions in a common place?
b) Following my mail below, should bootstrap.php be a class, or just have its
own inline code as in my script? The version of ZF I am using is 1.10.2.
c) Although documentation online explains that Autoloading is a good way to go,
I'd just like some opinions from those who have tested performance on this. Is
it 'better' to 'include_once' the class file you want to use, or use ZF's
autoloading for that class as explained above? Or does performance not matter,
and it is a preference of the developer?

d) In the above, I've used the namespace "My". How can I use ZF's default?
(since that would be more straightforward)? e.g. I tried
Application_Model_ProductTest as the class name but there was an error that ZF
could not load /Application/Model/ProductTest.php


e) Is there a way I can get and set controller variables from the controller
action/function that instantiated the class? For example can I set the variable
$this->controller->product_array = $myarray;
from within my function in the model?
I guess the recommended way is to return the variable from the function rather
than access any controller variables.

Many thanks,
Rishi

________________________________
From: Rishi Daryanani <rishijd@yahoo.com>
To: fw-mvc@lists.zend.com
Sent: Tue, November 23, 2010 10:04:41 AM
Subject: [fw-mvc] How to instantiate a model class to use its functions,
standard solution?

Hi,

I've been using Zend Framework in a somewhat 'partial' way between Zend's MVC
logic and our own coding structure (classes and shared functions). This has
been done using controllers and views, with the controller doing most of the
work (as opposed to the model). We have a new feature which required shared
functions again, and I'd like to put these in its own class which can be
instantiated when needed - ie. a model. (I'd like to do this to learn how to
code a model, for my own reference and better coding for the future).

The model needs to simply be a class with a few functions. It does not need to
extend Zend_Db or anything (as we are currently using our own functions for
database management) but it would be nice for it to set variables in
$this->controller.

My simple question - if I put the model in the 'application/models/' folder can

call it say 'ProductList.php' - how do I update bootstrap.php to set the
filepath to this model? Or do I need to include the file explicitly in the
controller? I can't seem to find a simple guide online for this.

FYI, my current bootstrap.php file contains the following, on Zend Framework
version 1.10.2 (recently upgraded from an older version):
/* Add the Zend Framework library to the include path so that we can access the
ZF classes */

set_include_path('../library' . PATH_SEPARATOR . get_include_path());

/* Set up autoload so we don't have to explicitely require each Zend Framework
class */

include_once('Zend/Loader/Autoloader.php');
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);

Online references show that the autoloader in bootstrap is more efficient than
doing an explicit include -
- I just want to know typically what/how you would name and instantiate a model?

Or do I need to go about this another way?
- I assume the solution to the above is very simple, so I'd just need to
know\understand the code to use to do this.
- Note that references like the below show bootstrap "classes", but our current
bootstrap.php file has code straightaway like the above, and not in a class.

References so far:
http://devzone.zend.com/article/4525-Developing-a-Comprehensive-Autoloader
http://framework.zend.com/manual/en/zend.loader.autoloader.html - good for
function references
http://www.youtube.com/watch?v=kuNNwpeNn4s
http://techblog.wimgodden.be/2008/12/21/autoloading-in-zend-framework-how-not-to-do-it/

Many thanks
Rishi

[fw-mvc] How to instantiate a model class to use its functions, standard solution?

Hi,

I've been using Zend Framework in a somewhat 'partial' way between Zend's MVC
logic and our own coding structure (classes and shared functions). This has
been done using controllers and views, with the controller doing most of the
work (as opposed to the model). We have a new feature which required shared
functions again, and I'd like to put these in its own class which can be
instantiated when needed - ie. a model. (I'd like to do this to learn how to
code a model, for my own reference and better coding for the future).

The model needs to simply be a class with a few functions. It does not need to
extend Zend_Db or anything (as we are currently using our own functions for
database management) but it would be nice for it to set variables in
$this->controller.

My simple question - if I put the model in the 'application/models/' folder can
call it say 'ProductList.php' - how do I update bootstrap.php to set the
filepath to this model? Or do I need to include the file explicitly in the
controller? I can't seem to find a simple guide online for this.

FYI, my current bootstrap.php file contains the following, on Zend Framework
version 1.10.2 (recently upgraded from an older version):
/* Add the Zend Framework library to the include path so that we can access the
ZF classes */

set_include_path('../library' . PATH_SEPARATOR . get_include_path());

/* Set up autoload so we don't have to explicitely require each Zend Framework
class */

include_once('Zend/Loader/Autoloader.php');
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);

Online references show that the autoloader in bootstrap is more efficient than
doing an explicit include -
- I just want to know typically what/how you would name and instantiate a model?
Or do I need to go about this another way?
- I assume the solution to the above is very simple, so I'd just need to
know\understand the code to use to do this.
- Note that references like the below show bootstrap "classes", but our current
bootstrap.php file has code straightaway like the above, and not in a class.

References so far:
http://devzone.zend.com/article/4525-Developing-a-Comprehensive-Autoloader
http://framework.zend.com/manual/en/zend.loader.autoloader.html - good for
function references
http://www.youtube.com/watch?v=kuNNwpeNn4s
http://techblog.wimgodden.be/2008/12/21/autoloading-in-zend-framework-how-not-to-do-it/

Many thanks
Rishi

[fw-mvc] Re: Zend_View directory layout

PHP is ZF's default templating language, not templating engine. Zend_View +
Zend_Layout are the closest things that ZF has to a templating engine.

I haven't messed with it much, but looking at how Drupal's templating engine
( http://drupal.org/phptemplate PHPTemplate ) works, might be helpful.

David


Abraham Block wrote:
>
> php
>
> On Mon, Nov 22, 2010 at 9:29 PM, Andrew Sledge
> <andrew.j.sledge@gmail.com>wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Well here's a question I haven't seen answered yet (though maybe I've
>> overlooked it): is there a recommended templating engine for Zend
>> Framework?
>>
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iEYEARECAAYFAkzrJxQACgkQ3XeSMIaeNkk5QgCfebHoKX7+V//iFd9Sm7+T65bc
>> 7LUAoIcZMOyjXPWgR9UhjaOQLY4PXuGA
>> =tnVB
>> -----END PGP SIGNATURE-----
>>
>>
>
>

--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-View-directory-layout-tp3053776p3054798.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_View directory layout

php

On Mon, Nov 22, 2010 at 9:29 PM, Andrew Sledge <andrew.j.sledge@gmail.com>wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Well here's a question I haven't seen answered yet (though maybe I've
> overlooked it): is there a recommended templating engine for Zend
> Framework?
>
> On 11/22/2010 10:37 AM, Hector Virgen wrote:
> > If possible I suggest using CSS to apply the themes. Otherwise you'll
> need
> > to create multiple versions of the same view and that can quickly become
> > tedious.
> >
> > But if your themes require custom markup per view script, then using
> > $view->setScriptPath() will work fine. Just be sure to set it early like
> in
> > a preDispatch hook or, at latest, within the action method's body.
> >
> > --
> > *Hector Virgen*
> > Sr. Web Developer
> > http://www.virgentech.com
> >
> >
> >
> > On Mon, Nov 22, 2010 at 7:31 AM, <aurelijus@astdev.lt> wrote:
> >
> >> It's not really hard.
> >> You can do it in your controller plugin or even bootstrap, just set
> >> view script path depending on user (or other) preferences
> >> $viewInstance->setScriptPath(THEME_PATH);
> >>
> >>
> >>
> >> On Mon, Nov 22, 2010 at 5:26 PM, Pablo Morales <pablofmorales@gmail.com
> >
> >> wrote:
> >>> This is so hard.
> >>>
> >>> If you have different themes, the best way is the theme adapt your
> views
> >> to
> >>> layout, not the inverse.
> >>>
> >>> The logic in the views, is the same, only change some divs, or other
> html
> >>> parameters. You need work with your layout, not with your views files
> >>>
> >>>
> >>>
> >>> On 11/22/2010 12:14 PM, Maxim Savenko wrote:
> >>>>
> >>>> I'd like to slightly change the layout of base Zend_View directory
> >>>> layout.
> >>>> The current layout is as follows:
> >>>>
> >>>> view
> >>>> filters
> >>>> helpers
> >>>> scripts
> >>>>
> >>>> ... and I'd like to split script directory to several
> >> directories(themes),
> >>>> depending on a theme user will choose.
> >>>> For example:
> >>>>
> >>>> view
> >>>> filters
> >>>> helpers
> >>>> scripts
> >>>> default
> >>>> modern
> >>>> classic
> >>>>
> >>>> What is the best way to shoot the bull?
> >>>>
> >>>> Thank you,
> >>>> Maxim Savenko
> >>>> maxim.savenko@gmail.com
> >>>>
> >>>
> >>>
> >>
> >>
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkzrJxQACgkQ3XeSMIaeNkk5QgCfebHoKX7+V//iFd9Sm7+T65bc
> 7LUAoIcZMOyjXPWgR9UhjaOQLY4PXuGA
> =tnVB
> -----END PGP SIGNATURE-----
>
>

Re: [fw-mvc] Zend_View directory layout

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well here's a question I haven't seen answered yet (though maybe I've
overlooked it): is there a recommended templating engine for Zend
Framework?

On 11/22/2010 10:37 AM, Hector Virgen wrote:
> If possible I suggest using CSS to apply the themes. Otherwise you'll need
> to create multiple versions of the same view and that can quickly become
> tedious.
>
> But if your themes require custom markup per view script, then using
> $view->setScriptPath() will work fine. Just be sure to set it early like in
> a preDispatch hook or, at latest, within the action method's body.
>
> --
> *Hector Virgen*
> Sr. Web Developer
> http://www.virgentech.com
>
>
>
> On Mon, Nov 22, 2010 at 7:31 AM, <aurelijus@astdev.lt> wrote:
>
>> It's not really hard.
>> You can do it in your controller plugin or even bootstrap, just set
>> view script path depending on user (or other) preferences
>> $viewInstance->setScriptPath(THEME_PATH);
>>
>>
>>
>> On Mon, Nov 22, 2010 at 5:26 PM, Pablo Morales <pablofmorales@gmail.com>
>> wrote:
>>> This is so hard.
>>>
>>> If you have different themes, the best way is the theme adapt your views
>> to
>>> layout, not the inverse.
>>>
>>> The logic in the views, is the same, only change some divs, or other html
>>> parameters. You need work with your layout, not with your views files
>>>
>>>
>>>
>>> On 11/22/2010 12:14 PM, Maxim Savenko wrote:
>>>>
>>>> I'd like to slightly change the layout of base Zend_View directory
>>>> layout.
>>>> The current layout is as follows:
>>>>
>>>> view
>>>> filters
>>>> helpers
>>>> scripts
>>>>
>>>> ... and I'd like to split script directory to several
>> directories(themes),
>>>> depending on a theme user will choose.
>>>> For example:
>>>>
>>>> view
>>>> filters
>>>> helpers
>>>> scripts
>>>> default
>>>> modern
>>>> classic
>>>>
>>>> What is the best way to shoot the bull?
>>>>
>>>> Thank you,
>>>> Maxim Savenko
>>>> maxim.savenko@gmail.com
>>>>
>>>
>>>
>>
>>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzrJxQACgkQ3XeSMIaeNkk5QgCfebHoKX7+V//iFd9Sm7+T65bc
7LUAoIcZMOyjXPWgR9UhjaOQLY4PXuGA
=tnVB
-----END PGP SIGNATURE-----

Re: [fw-mvc] Zend_View directory layout

If possible I suggest using CSS to apply the themes. Otherwise you'll need
to create multiple versions of the same view and that can quickly become
tedious.

But if your themes require custom markup per view script, then using
$view->setScriptPath() will work fine. Just be sure to set it early like in
a preDispatch hook or, at latest, within the action method's body.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Mon, Nov 22, 2010 at 7:31 AM, <aurelijus@astdev.lt> wrote:

> It's not really hard.
> You can do it in your controller plugin or even bootstrap, just set
> view script path depending on user (or other) preferences
> $viewInstance->setScriptPath(THEME_PATH);
>
>
>
> On Mon, Nov 22, 2010 at 5:26 PM, Pablo Morales <pablofmorales@gmail.com>
> wrote:
> > This is so hard.
> >
> > If you have different themes, the best way is the theme adapt your views
> to
> > layout, not the inverse.
> >
> > The logic in the views, is the same, only change some divs, or other html
> > parameters. You need work with your layout, not with your views files
> >
> >
> >
> > On 11/22/2010 12:14 PM, Maxim Savenko wrote:
> >>
> >> I'd like to slightly change the layout of base Zend_View directory
> >> layout.
> >> The current layout is as follows:
> >>
> >> view
> >> filters
> >> helpers
> >> scripts
> >>
> >> ... and I'd like to split script directory to several
> directories(themes),
> >> depending on a theme user will choose.
> >> For example:
> >>
> >> view
> >> filters
> >> helpers
> >> scripts
> >> default
> >> modern
> >> classic
> >>
> >> What is the best way to shoot the bull?
> >>
> >> Thank you,
> >> Maxim Savenko
> >> maxim.savenko@gmail.com
> >>
> >
> >
>
>

Re: [fw-mvc] Zend_View directory layout

Sorry my english :(

I mean is no so hard, this is unnecessary, this implies more maintance
files, and more code

On 11/22/2010 12:31 PM, aurelijus@astdev.lt wrote:
> It's not really hard.
> You can do it in your controller plugin or even bootstrap, just set
> view script path depending on user (or other) preferences
> $viewInstance->setScriptPath(THEME_PATH);
>
>

Re: [fw-mvc] Zend_View directory layout

It's not really hard.
You can do it in your controller plugin or even bootstrap, just set
view script path depending on user (or other) preferences
$viewInstance->setScriptPath(THEME_PATH);

On Mon, Nov 22, 2010 at 5:26 PM, Pablo Morales <pablofmorales@gmail.com> wrote:
> This is so hard.
>
> If you have different themes, the best way is the theme adapt your views to
> layout, not the inverse.
>
> The logic in the views, is the same, only change some divs, or other html
> parameters. You need work with your layout, not with your views files
>
>
>
> On 11/22/2010 12:14 PM, Maxim Savenko wrote:
>>
>> I'd like to slightly change the layout  of base Zend_View directory
>> layout.
>> The current layout is as follows:
>>
>> view
>>   filters
>>   helpers
>>   scripts
>>
>> ... and I'd like to split script directory to several directories(themes),
>> depending on a theme user will choose.
>> For example:
>>
>> view
>>   filters
>>   helpers
>>   scripts
>>      default
>>      modern
>>      classic
>>
>> What is the best way to shoot the bull?
>>
>> Thank you,
>> Maxim Savenko
>> maxim.savenko@gmail.com
>>
>
>

Re: [fw-mvc] Zend_View directory layout

This is so hard.

If you have different themes, the best way is the theme adapt your views
to layout, not the inverse.

The logic in the views, is the same, only change some divs, or other
html parameters. You need work with your layout, not with your views files

On 11/22/2010 12:14 PM, Maxim Savenko wrote:
> I'd like to slightly change the layout of base Zend_View directory layout.
> The current layout is as follows:
>
> view
> filters
> helpers
> scripts
>
> ... and I'd like to split script directory to several directories(themes),
> depending on a theme user will choose.
> For example:
>
> view
> filters
> helpers
> scripts
> default
> modern
> classic
>
> What is the best way to shoot the bull?
>
> Thank you,
> Maxim Savenko
> maxim.savenko@gmail.com
>

[fw-mvc] Zend_View directory layout

I'd like to slightly change the layout of base Zend_View directory layout.
The current layout is as follows:

view
filters
helpers
scripts

... and I'd like to split script directory to several directories(themes),
depending on a theme user will choose.
For example:

view
filters
helpers
scripts
default
modern
classic

What is the best way to shoot the bull?

Thank you,
Maxim Savenko
maxim.savenko@gmail.com

2010年11月19日星期五

[fw-auth] Re: Zend_Auth_Adapter_DbTable additional checks

I had a similar approach. In my database I have two rows with the same keys
'email' and 'password'.
One has a flag deleteDate set and so it should be excluded in the result.

My first script:

$adapter->setTableName('members');
$adapter->setIdentityColumn('email');
$adapter->setCredentialColumn('password');
$adapter->setCredentialTreatment('PASSWORD(?) AND deletionDate IS NULL AND
blockDate IS NULL');
$adapter->setIdentity($values['email']);
$adapter->setCredential($values['password']);


Logging in failed for some reason.

I switched to this script:

$adapter->setTableName('members');
$adapter->setIdentityColumn('email');
$adapter->setCredentialColumn('password');
$adapter->setCredentialTreatment('PASSWORD(?)');
$adapter->setIdentity($values['email']);
$adapter->setCredential($values['password']);

$select = $adapter->getDbSelect();
$select->where('deletionDate IS NULL');
$select->where('blockDate IS NULL');


This worked fine. But the documentation says that these methods should react
equally, or not!?
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Auth-Adapter-DbTable-additional-checks-tp676876p3050167.html
Sent from the Zend Auth mailing list archive at Nabble.com.

2010年11月18日星期四

Re: [fw-mvc] How to clear view placeholders? (headTitle, headLink, headScript, inlineScript...)

Placeholder-type view helpers extend ArrayObject, so you can do this:

$view->headTitle()->exchangeArray(array());

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Tue, Nov 16, 2010 at 6:48 AM, Rafael Hengles <rhengles@gmail.com> wrote:

> Right now i'm doing this:
>
> <?php
> $phEmpty = array('headTitle', 'headLink', 'headScript', 'inlineScript');
> foreach ( $phEmpty as $phn ) {
> $ph = $view->$phn();
> $phikeys = array();
> foreach ( $ph as $phik => $phiv ) array_push($phikeys, $phik);
> foreach ( $phikeys as $phik ) unset( $ph[$phik] );
> }
> ?>
>
> Is there a better way?
>
> Thanks
>
>

2010年11月16日星期二

Re: [fw-mvc] FlashMessenger namespace not expiring when user is logged in

I have the same problem! :(
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/FlashMessenger-namespace-not-expiring-when-user-is-logged-in-tp970072p3045622.html
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-mvc] How to clear view placeholders? (headTitle, headLink, headScript, inlineScript...)

Right now i'm doing this:

<?php
$phEmpty = array('headTitle', 'headLink', 'headScript', 'inlineScript');
foreach ( $phEmpty as $phn ) {
$ph = $view->$phn();
$phikeys = array();
foreach ( $ph as $phik => $phiv ) array_push($phikeys, $phik);
foreach ( $phikeys as $phik ) unset( $ph[$phik] );
}
?>

Is there a better way?

Thanks

2010年11月13日星期六

RE: [fw-auth] Ldap extension not loaded

You are awesome! They are definitely different! I will handle it from here. Thanks so much, Stefan!


-----Original Message-----
From: Stefan Gehrig [mailto:stefan.gehrig.hn@googlemail.com]
Sent: Saturday, November 13, 2010 6:42 PM
To: Gina-Marie Rollock
Cc: fw-auth@lists.zend.com
Subject: Re: [fw-auth] Ldap extension not loaded

If you're running the sample code from the command line for example, it may be that this is a different interpreter or that it uses a different php.ini.

You could run a phpinfo(); in both of your scripts and check if there is any evidence to ext/ldap.

Am 13.11.2010 um 15:39 schrieb Gina-Marie Rollock:

> Why would it be different? Is there a way I can check if I'm using a different interpreter?
>
>
>
> -----Original Message-----
> From: Stefan Gehrig [mailto:stefan.gehrig.hn@googlemail.com]
> Sent: Saturday, November 13, 2010 6:39 PM
> To: Gina-Marie Rollock
> Cc: fw-auth@lists.zend.com
> Subject: Re: [fw-auth] Ldap extension not loaded
>
> Actually the code to check for the LDAP extension is
>
> if (!extension_loaded('ldap')) {
> /**
> * @see Zend_Ldap_Exception
> */
> require_once 'Zend/Ldap/Exception.php';
> throw new Zend_Ldap_Exception(null, 'LDAP extension not loaded',
> Zend_Ldap_Exception::LDAP_X_EXTENSION_NOT_LOADED);
> }
>
> in the constructor... Hard to say, what the problem is - but are you sure that the PHP interpreter running your sample script is the same interpreter that's running your other Zend_Ldap code?
>
> Best regards
>
> Stefan
>
>
> Am 13.11.2010 um 15:29 schrieb rollockg:
>
>>
>> I am trying to authenticate via LDAP. I am getting the message
>> "0x7002: LDAP extension not loaded". I have checked everything and
>> compared it to other servers where I am successfully using LDAP. Everything appears the same.
>>
>> I decided to create a simple php script like below, utilizing the
>> code from
>> /Zend/Ldap.php:
>>
>> <?php
>>
>> if (!extension_loaded('ldap')) {
>> echo 'LDAP Extension not loaded!';
>> } else {
>> echo 'Good to go!';
>> }
>> ?>
>>
>> I ran this script on the other servers from which I can successfully
>> authenticate via LDAP, and then on the server that I'm getting the
>> "not loaded" message on.
>>
>> On all of them I am getting the "Good to go!" message from my script.
>>
>> So my question is, why is my little test script returning a "Good" on
>> finding the extension, but the Framework is not? What am I missing?
>> Is there something else I can check? This is Framework 1.9.6.
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/Ldap-extension-n
>> o t-loaded-tp3041379p3041379.html Sent from the Zend Auth mailing
>> list archive at Nabble.com.
>

Re: [fw-auth] Ldap extension not loaded

If you're running the sample code from the command line for example, it may be that this is a different interpreter or that it uses a different php.ini.

You could run a phpinfo(); in both of your scripts and check if there is any evidence to ext/ldap.

Am 13.11.2010 um 15:39 schrieb Gina-Marie Rollock:

> Why would it be different? Is there a way I can check if I'm using a different interpreter?
>
>
>
> -----Original Message-----
> From: Stefan Gehrig [mailto:stefan.gehrig.hn@googlemail.com]
> Sent: Saturday, November 13, 2010 6:39 PM
> To: Gina-Marie Rollock
> Cc: fw-auth@lists.zend.com
> Subject: Re: [fw-auth] Ldap extension not loaded
>
> Actually the code to check for the LDAP extension is
>
> if (!extension_loaded('ldap')) {
> /**
> * @see Zend_Ldap_Exception
> */
> require_once 'Zend/Ldap/Exception.php';
> throw new Zend_Ldap_Exception(null, 'LDAP extension not loaded',
> Zend_Ldap_Exception::LDAP_X_EXTENSION_NOT_LOADED);
> }
>
> in the constructor... Hard to say, what the problem is - but are you sure that the PHP interpreter running your sample script is the same interpreter that's running your other Zend_Ldap code?
>
> Best regards
>
> Stefan
>
>
> Am 13.11.2010 um 15:29 schrieb rollockg:
>
>>
>> I am trying to authenticate via LDAP. I am getting the message
>> "0x7002: LDAP extension not loaded". I have checked everything and
>> compared it to other servers where I am successfully using LDAP. Everything appears the same.
>>
>> I decided to create a simple php script like below, utilizing the code
>> from
>> /Zend/Ldap.php:
>>
>> <?php
>>
>> if (!extension_loaded('ldap')) {
>> echo 'LDAP Extension not loaded!';
>> } else {
>> echo 'Good to go!';
>> }
>> ?>
>>
>> I ran this script on the other servers from which I can successfully
>> authenticate via LDAP, and then on the server that I'm getting the
>> "not loaded" message on.
>>
>> On all of them I am getting the "Good to go!" message from my script.
>>
>> So my question is, why is my little test script returning a "Good" on
>> finding the extension, but the Framework is not? What am I missing? Is
>> there something else I can check? This is Framework 1.9.6.
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/Ldap-extension-no
>> t-loaded-tp3041379p3041379.html Sent from the Zend Auth mailing list
>> archive at Nabble.com.
>

RE: [fw-auth] Ldap extension not loaded

Why would it be different? Is there a way I can check if I'm using a different interpreter?

-----Original Message-----
From: Stefan Gehrig [mailto:stefan.gehrig.hn@googlemail.com]
Sent: Saturday, November 13, 2010 6:39 PM
To: Gina-Marie Rollock
Cc: fw-auth@lists.zend.com
Subject: Re: [fw-auth] Ldap extension not loaded

Actually the code to check for the LDAP extension is

if (!extension_loaded('ldap')) {
/**
* @see Zend_Ldap_Exception
*/
require_once 'Zend/Ldap/Exception.php';
throw new Zend_Ldap_Exception(null, 'LDAP extension not loaded',
Zend_Ldap_Exception::LDAP_X_EXTENSION_NOT_LOADED);
}

in the constructor... Hard to say, what the problem is - but are you sure that the PHP interpreter running your sample script is the same interpreter that's running your other Zend_Ldap code?

Best regards

Stefan


Am 13.11.2010 um 15:29 schrieb rollockg:

>
> I am trying to authenticate via LDAP. I am getting the message
> "0x7002: LDAP extension not loaded". I have checked everything and
> compared it to other servers where I am successfully using LDAP. Everything appears the same.
>
> I decided to create a simple php script like below, utilizing the code
> from
> /Zend/Ldap.php:
>
> <?php
>
> if (!extension_loaded('ldap')) {
> echo 'LDAP Extension not loaded!';
> } else {
> echo 'Good to go!';
> }
> ?>
>
> I ran this script on the other servers from which I can successfully
> authenticate via LDAP, and then on the server that I'm getting the
> "not loaded" message on.
>
> On all of them I am getting the "Good to go!" message from my script.
>
> So my question is, why is my little test script returning a "Good" on
> finding the extension, but the Framework is not? What am I missing? Is
> there something else I can check? This is Framework 1.9.6.
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Ldap-extension-no
> t-loaded-tp3041379p3041379.html Sent from the Zend Auth mailing list
> archive at Nabble.com.

Re: [fw-auth] Ldap extension not loaded

Actually the code to check for the LDAP extension is

if (!extension_loaded('ldap')) {
/**
* @see Zend_Ldap_Exception
*/
require_once 'Zend/Ldap/Exception.php';
throw new Zend_Ldap_Exception(null, 'LDAP extension not loaded',
Zend_Ldap_Exception::LDAP_X_EXTENSION_NOT_LOADED);
}

in the constructor... Hard to say, what the problem is - but are you sure that the PHP interpreter running your sample script is the same interpreter that's running your other Zend_Ldap code?

Best regards

Stefan


Am 13.11.2010 um 15:29 schrieb rollockg:

>
> I am trying to authenticate via LDAP. I am getting the message "0x7002: LDAP
> extension not loaded". I have checked everything and compared it to other
> servers where I am successfully using LDAP. Everything appears the same.
>
> I decided to create a simple php script like below, utilizing the code from
> /Zend/Ldap.php:
>
> <?php
>
> if (!extension_loaded('ldap')) {
> echo 'LDAP Extension not loaded!';
> } else {
> echo 'Good to go!';
> }
> ?>
>
> I ran this script on the other servers from which I can successfully
> authenticate via LDAP, and then on the server that I'm getting the "not
> loaded" message on.
>
> On all of them I am getting the "Good to go!" message from my script.
>
> So my question is, why is my little test script returning a "Good" on
> finding the extension, but the Framework is not? What am I missing? Is there
> something else I can check? This is Framework 1.9.6.
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/Ldap-extension-not-loaded-tp3041379p3041379.html
> Sent from the Zend Auth mailing list archive at Nabble.com.