[fw-general] Zend_Service_Amazon::itemSearch() not holding results

2011-05-08 Thread Drew Bertola
Hi All,

I'm trying to use Zend_Service_Amazon's itemSearch method (or the Z_S_A_Query 
wrapper - both act the same) to query Amazon for items.  I get an empty 
Zend_Service_Amazon_ResultSet Object, though if I look at the response from the 
REST client's ->getBody() there is product data returned.

I believe the issue is with loading the response into DOMDocument (haven't yet 
spent time to look around in that code yet).  Has anyone found the same issue 
or a fix?

I'm running ZF 1.11.4.

BTW, I noticed that many Amazon search demo sites out on the web are not 
returning results these days.  I wonder if it's a dom issue.

Thanks,
--
Drew Bertola


--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Simple question About Error Controller

2009-08-28 Thread Drew Bertola

On 08/27/2009 01:59 PM, Sergio Rinaudo wrote:

Hi,
in my application I use an ErrorController like the one explained here

http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler

and I have a Layout composed by different parts ( header, footer ecc.. )
loaded by the render() method.

I noticed that if the url calls an existing controller and a non
existing action, I get my layout with all is parts and the
ErrorController:error.

Instead, if the controller is non existing ( whatever action ), all the
parts in my layout are missing ( except ErrorController:error ), like
$this->getResponse()->clearBody(); is automatically called.

It is a problem only for my application ( maybe I have some code that
cause this... ) or is a normal behaviour?



In the ErrorController, do you specify a layout?

$this->view->layout()->setLayout("default_layout");

I think you have to do this for each action in that controller or in an 
init() method if you want the same layout for all error types.


--
Drew Bertola

---
*   PHP/LAMP Consultant, ZCE-1000 *
* *
*   Tel: 408-966-6671 *
* *
*   current resume:   *
*   http://drewb.com/media/drew_bertola_resume.pdf*
---


Re: [fw-general] Survey: Development environment for PHP/ZFW

2009-05-05 Thread Drew Bertola

howard chen wrote:

Please feel free to answer:

1. What OS you are using during development? Windows? Mac? Linux?


Linux (Fedora 10)


2. Do you edit source code on localhost or remote? i.e. is your


localhost


testing environment reside on localhost or remote?


both - depends on the project and whether its just me or a team.


3. What tool or IDE you are using? Ultraedit? Apanta? Eclipse PDT?


Zend Studio, fall back to emacs.


4. Which versioning system your are using? svn? git?


SVN - looking forward to trying git when I have a chance.


5. Do you use PHPUnit or other testing tools?


For library code, PHPUnit.  For front end and interactivity, selenium.


--
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/blog/about/resume/ *
-


[fw-general] Dojo shipped w/ ZF1.8.0 not dojo-1.3.0?

2009-05-04 Thread Drew Bertola

Hi everyone,

From the release announcement for ZF 1.8.0, I was expecting dojo 
version 1.3.0 to be incorporated in the full download package.  I see, 
though, that dojo.version.toString() reports 1.1.0dev.  Am I mistaken, 
or is this an oversight w/ the ZF release?


I've just filed an issue regarding this:

http://framework.zend.com/issues/browse/ZF-6523

--
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/blog/about/resume/ *
-


[fw-general] ZF based Bulletin Board software?

2008-09-25 Thread Drew Bertola
Anyone know of a good bulletin board built on ZF (best if it could be a 
single module).


Thanks,

--
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/blog/about/resume/ *
-



[fw-general] Zend Lucene Search - Query help needed...

2008-02-20 Thread Drew Bertola
Hi,

I've created an index from three data sources: faq articles, forum
posts, and customer orders (sound strange?).

I've tagged each item with an "item_type" field (Keyword - either "faq",
"forums", or "orders"), as well as the item_id as a Keyword, the title
as Text, and the content as Unstored).  Additionally, all orders have an
extra Keyword field that carries the customer_id related to that order.

I'd like to have our customers be able to do text queries against all
sets of data, but limit the orders data returned to those carrying their
customer_id (hence the customer_id Keyword field for all orders).

Two questions come up.

First, how do I construct the query.  It seems to me I need to have
nested subqueries like:

words + (item_type:faq item_type:forums (item_type:orders +
customer_id:$customer_id) )

Is that the correct approach?  I don't even know if it's possible.

The second relates to having tracking numbers in the orders such as
"1Z3240230408".  For this, I've changed the default Analyzer to
TextNum_CaseInsensitive for both indexing and querying.  Is that correct?

Thanks,
-- 
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/blog/about/resume/ *
-


Re: [fw-general] Validate input data from POST variable

2007-09-21 Thread Drew Bertola
Kexiao Liao wrote:
> Where is the best place to do the input data(from POST variables) validation
> in the Zend Framework?
> 
> We can do the validation in following places:
> 1. Controller Class file
> 2. Use Defined Models Class file
> 
> Which one is the better choice?

Good question.  I've been creating a form processing utility class for
every form, then calling it from the action controller.  But
intuitively, I would have put it in the model.

The reason I didn't is that if I say:

  class book extends Zend_Db_Table_Abstract {}

  $table = new book();
  $book = $table->find(1);

  $errors = $table->validateInput($_POST); // or whatever...

This feels awkward and hard to understand.  Also, you tend to lose the
extra value that the validator object holds.

I suppose you could cobble together a composite model using a table
model together with validation, filtering, error message preparation,
etc (the stuff I now do in my form utility classes).

-- 
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/resume.pdf *
-


Re: [fw-general] how is the "html header" part of a view stored inside the response object ?

2007-08-29 Thread Drew Bertola
Truppe Steven wrote:
> Hi again,
> 
> i try to understand how a rendered Zend_View (.phtml) is stored inside
> the response object. is the external css from the .pthml file also saved
> in the response object ?

If it's external, no.  When the browser sees the"

http://drewb.com/resume.pdf *
-


Re: [fw-general] Zend_Filter_Input custom messages walked on...

2007-08-27 Thread Drew Bertola
Mmm.  I figured out the problem was just confusion between the meaning
of "missingMessage" and "notEmptyMessage".

--
Drew

Drew Bertola wrote:
> Hi,
> 
> I'm trying to figure out why I can't set custom messages in
> Zend_Filter_Input.  Is this a known bug?  I've searched around by
> haven't found anything.
> 
> Then again, it could be me.  It's happened once or twice before ;^)
> 
> If I do something like this:
> 
>  
> ...
> 
> $filters= array("name" => array("StringTrim", "StripTags"));
> $validators = array("name" => array("presence" => "required"));
> $options = array("missingMessage" => "%field% is required.");
> 
> $input = new Zend_Filter_Input($filters,
>$validators,
>$data,
>$options);
> 
> if ( $input->hasInvalid() )
> {
>   $messages = $input->getMessages();
> }
> 
> Zend_Debug::dump($messages);
> 
> ...
> 
> When I have an empty name in $data, I see the default missingMessage,
> rather than my custom message passed in $options.  I think the problem
> is actually in Zend_Validate, but I haven't tracked it down that far.
> Any ideas?
> 

-- 
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/resume.pdf *
-


[fw-general] Zend_Filter_Input custom messages walked on...

2007-08-26 Thread Drew Bertola
Hi,

I'm trying to figure out why I can't set custom messages in
Zend_Filter_Input.  Is this a known bug?  I've searched around by
haven't found anything.

Then again, it could be me.  It's happened once or twice before ;^)

If I do something like this:

 array("StringTrim", "StripTags"));
$validators = array("name" => array("presence" => "required"));
$options = array("missingMessage" => "%field% is required.");

$input = new Zend_Filter_Input($filters,
   $validators,
   $data,
   $options);

if ( $input->hasInvalid() )
{
  $messages = $input->getMessages();
}

Zend_Debug::dump($messages);

...

When I have an empty name in $data, I see the default missingMessage,
rather than my custom message passed in $options.  I think the problem
is actually in Zend_Validate, but I haven't tracked it down that far.
Any ideas?

-- 
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/resume.pdf *
-


[fw-general] Damn wiki is down!

2007-08-25 Thread Drew Bertola
About half the time I need to check out the wiki, it's down.  Any more
permanent solutions on the way?

-- 
Drew Bertola

-
*   PHP/LAMP Consultant, ZCE-1000   *
*   *
*   Tel: 408-966-6671   *
*   *
*   current resume: *
*   http://drewb.com/resume.pdf *
-


Re: [fw-general] Deploy Zend Framework application on the production server

2007-08-10 Thread Drew Bertola
There's a strong case not to use .htaccess on busy production boxes,
since it requires unnecessary file I/O for every request made within
that directory heirarchy (not only the index.php, but every favicon.ico,
*.jpg, *.js, *.css, etc).

It's best to put your rewrite rules directly inside a virtualhost
stanza.  The only justifiable case for htaccess files is when you don't
have access to httpd.conf, which is typical in shared hosting environments.

--
Drew

Kexiao Liao wrote:
> My key point is, if we already enable mod_rewrite in the apache server, Can
> we deploy Zend Framework Application without modifying httpd.conf file to
> add alias name for the document_root directory?
> 
> Kevin
> 
> 
> Jack Sleight wrote:
>> See the Graceful Restart section on this page:
>> http://httpd.apache.org/docs/2.0/stopping.html
>> Allows you to reconfigure Apache without completely restarting it.
>>
>> Kexiao Liao wrote:
>>> When we finish Zend Framework application, and put it on the production
>>> server. We need to modify the web server configuration file, in case of
>>> Apache Server, we need to modify httpd.conf and add an alias name and the
>>> associated  tag contents like following:
>>>
>>> 
>>> Options all
>>> AllowOverride all
>>> Order allow,deny
>>> Allow from all
>>> 
>>>
>>> After modify the httpd.conf configuration file, we need restart Apache
>>> server. For production site, this is not a good solution.
>>> Is there another approach which we can avoid modification of httpd.conf
>>> file
>>> and restarting the server?
>>>  
>>>   
>> -- 
>> Jack
>>
>>
> 


Re: [fw-general] Installation

2007-07-24 Thread Drew Bertola

>>> You copy the library to a directory of your choice, eg 
>>> //path/to/htdocs/library/ (has to be readable). Then you set your 
>>> include-path to //path/to/htdocs/library/. 

Not sure if this is what you meant by ".../htdocs/..." but it is worth
noting that the library should be outside any document root accessible
to the web server (e.g. apache's DocumentRoot, commonly set to
/some/path/to/htdocs/).

Anything within the document root that doesn't absolutely need to be
there should be somewhere else.  Even a bootstrap.php can be outside the
docroot.  Then your only line in index.php would be a single
require_once pulling in that file).

--
Drew


[fw-general] Zend_Layout demo app...

2007-07-24 Thread Drew Bertola
Hi,

Does anyone have a recent demo app utilizing Ralph's Zend_Layout?

Thanks,
--
Drew


Re: [fw-general] Per module header and footer...any guidance?

2007-07-23 Thread Drew Bertola
mikespook wrote:
> Place the footer.phtml and header.phtml in the dir :
> root/app/usr/{module}/{views}/{scripts}/
> And usingrender('footer.phtml');?> in your view
> scripts.
>
> Then every module has its own footer and header.

Thanks, Xing.  I was hoping for something a little less clunky, but that
is straight forward.

Previous to all the convenience functionality being added to the MVC
bits in 0.9-something, I had subclassed the action controller for each
module and added in my own convenience methods such as renderXhtml(),
renderPdf(), and renderPopup().  That allowed me to do away with the top
and bottom includes or calls to render() outside the action controllers
(which is a big plus).

I'm looking at the proposal for Zend_Layout, but it doesn't look like
it's available in the incubator yet.

--
Drew



[fw-general] Per module header and footer...any guidance?

2007-07-23 Thread Drew Bertola
Hi,

I'm looking for a way to have different header and footer templates
depending on the module.  I'd like to do this without losing any of the
convenience functionality built in to viewRenderer, etc.

Anyone have a suggestion?

Thanks,
--
Drew


Re: [fw-general] No output...

2007-07-17 Thread Drew Bertola
Matthew Weier O'Phinney wrote:
> To follow the conventional modular format, you should have the following
> directory structure:
> 
> APP_DIR/
> default/
> controllers/
> admin/
> controllers/
> (all controllers in this module should be prefixed with
> 'Admin_')

Just want to say that I followed this, and now have things working
again.  One note, though about the last bit above:

"all controllers in this module should be prefixed..." is referring to
the class names, not the file names.  That got me scratching my head for
a while.  I had "admin/controller/Admin_IndexController.php" and should
have used "admin/controller/IndexController.php" containing:

 class Admin_IndexController extends...

So, this bit is the same as the convention used around 0.6+, except for
the switch from ./application/controllers/module/... to
./application/module/controllers/...

I see the reasoning here.  Pop in a nice self contained, say, blog
module and add a simple addControllerDirectory() line to your bootstrap,
and you're all set with a new ZF blog.  Great.

What's a bit strange is that in the manual, the example layout is given as:

( http://framework.zend.com/manual/en/zend.controller.modular.html )

docroot/
index.php
application/
default/
controllers/
IndexController.php
FooController.php
blog/
controllers/
IndexController.php
models/
views/
news/
controllers/
IndexController.php
ListController.php
models/
views/

Where are the models and views for the default module?  Do they go
directly beneath application/ or are they just missing?

Thanks,
--
Drew


Re: [fw-general] No output...

2007-07-16 Thread Drew Bertola
Matthew Weier O'Phinney wrote:
> To follow the conventional modular format, you should have the following
> directory structure:
> 
> APP_DIR/
> default/
> controllers/
> admin/
> controllers/
> (all controllers in this module should be prefixed with
> 'Admin_')

I've seen so many descriptions of the "right" way to set up the
directories that I'm not sure which is authoritative.  Even the manual
has different variants.  It takes some time to figure out what is what.

>> What do I need to do now to see exceptions?
> 
> $controller->throwExceptions(true);

Missed that.  I guess I was stuck in the habit of doing
$response->renderExceptions(true);

> will turn off exception handling and throw them. However, the better way
> is the error handler... more below.

Caught that.  There's so many changes that I'm quite confused.  I was at
the point where I pulled $controller->dispatch() in favor of ::run() (as
a test).  When I went back, I must have left out ->dispatch().

>> How do I map the default views to my setup of the controller?
> 
> Please read the section on the conventional modular directory structure:
> 
> http://framework.zend.com/manual/en/zend.controller.modular.html
> 
> as well as the MVC quick start and the ViewRenderer documentation:
> 
> 
> http://framework.zend.com/manual/en/zend.controller.html#zend.controller.quickstart.go
> 
> http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer

Again, so many variations - I'm all for that, but it takes a lot of
effort to find out what the most standard (and convenient) approach is.

> Use the directory structure as shown above, and add a views subdirectory
> at the same level as 'controllers', with a subdirectory for view
> scripts. Each controller then has a subdirectory itself:
> 
> APP_DIR/
> default/
> controllers/
> IndexController.php
> ErrorController.php
> views/
> scripts/
> index/
> *.phtml
> error/
> error.phtml
> helpers/
> filters/

Great.

I'd imagine a common (to all modules) filters/ and helpers/ directory
would be useful as well, at least to help reduce duplication.  I suppose
 I can add a path for generic helpers and filters.  Of course, w/
helpers, that's how it was done from early on.

It might be that I choose to not use the convenience methods provided by
viewRenderer (or subclass it for different response types).  My thoughts
are that I would like to have:

renderXhtml() (standard http headers, page header, body, page footer),
renderPopup() (standard http headers, brief header, body, footer),
renderPdf()   (pdf headers, content),
renderJpg()   ...

What are people doing to facilitate this kind of strategy?

Thanks,
--
Drew

Thanks,
--
Drew


[fw-general] No output...

2007-07-15 Thread Drew Bertola
Hi,

I've already done a few projects with ZF in the range of 0.2 through 0.9
or so, but this is the first time I've tried to run 1.0.

My problem is that I'm not getting any output, either good or bad.

I've spent a few hours going through the manual, but it doesn't seem to
address the points I need in order to move further on.

What I'm trying to do is use something like this:


$controller = Zend_Controller_Front::getInstance();

$controller->setControllerDirectory(
  array("default"  => APP_DIR . "controllers/default",
"admin"=> APP_DIR . "controllers/admin")
  );


What do I need to do now to see exceptions?

How do I map the default views to my setup of the controller?

Where does ErrorController live (in
./controllers/default/ErrorController.php was my guess)?

Thanks,
--
Drew


Re: [fw-general] Text formatting in PDFs

2007-05-01 Thread Drew Bertola
Drew Bertola wrote:
> Drew Bertola wrote:
>> For certain fonts with guaranteed character widths, this is possible
>> using a hash of all the characters widths.  For example, here's the
>> widths of helvetica and helvetica-bold:
> 
> 
> BTW, these widths are extracted from the WX values shown within Adobe
> Font Metrics files (.afm).  They are ascii text files with font
> rendering data.  On my system, I can find a couple dozen of them in
> 
> /usr/share/fonts/default/[ghostscript]|[Type1]/
> 
> This doesn't mean they are fixed width, but it does mean that they are
> known width characters, and they should be consistent across platforms.
>  This is what you need unless you are willing to embed fonts within your
> pdfs (really, why bother?).

Rats, forgot to mention one other important thing, the "why bother?"
question above is actually not as rhetorical as I planned :)

The reason I selected helvetica and helvetica-bold is that you want to
have the highest degree of certainty that the font will be available on
the pdf reader's platform.  There are few choices that are as ubiquitous
as helvetica.

If you must use a less widely available font, you WOULD need to embed
the font to make sure that it is available on the reader's system.  You
would need to find font metrics to do all the alignment calculations, as
well, and I believe that is what would end up being be embedded.  It
adds a lot of size to the pdf, and probably a lot of hassle to the
developer.

--
Drew


Re: [fw-general] Text formatting in PDFs

2007-05-01 Thread Drew Bertola
Drew Bertola wrote:
> For certain fonts with guaranteed character widths, this is possible
> using a hash of all the characters widths.  For example, here's the
> widths of helvetica and helvetica-bold:


BTW, these widths are extracted from the WX values shown within Adobe
Font Metrics files (.afm).  They are ascii text files with font
rendering data.  On my system, I can find a couple dozen of them in

/usr/share/fonts/default/[ghostscript]|[Type1]/

This doesn't mean they are fixed width, but it does mean that they are
known width characters, and they should be consistent across platforms.
 This is what you need unless you are willing to embed fonts within your
pdfs (really, why bother?).

The relevant parts of one of those .afm files looks like this:

StartFontMetrics 2.0
Comment Generated by pfaedit
Comment Creation Date: Sat Jul 17 16:58:06 2004
FontName URWPalladioL-BoldItal
FullName URW Palladio L Bold Italic
FamilyName URW Palladio L
Weight Bold
Notice (Copyright (URW)++,Copyright 1999 by (URW)++ Design &
Development; Cyrillic glyphs added by Valek Filippov (C) 2001)
ItalicAngle -9.9
IsFixedPitch false

[snip tons of lines]

C -1 ; WX 333 ; N iacute ; B 26 -17 392 699 ;
C -1 ; WX 333 ; N igrave ; B 26 -17 322 699 ;
C -1 ; WX 333 ; N icircumflex ; B 26 -17 403 684 ;
C -1 ; WX 333 ; N lacute ; B 64 -17 432 911 ;

[snip tons more]

--
Drew


Re: [fw-general] Text formatting in PDFs

2007-05-01 Thread Drew Bertola
Andrew Yager wrote:
> Hi,
> 
> Is there a simple way to format a text string when writing? In
> particular I am interested in right aligning a variable width string.

For certain fonts with guaranteed character widths, this is possible
using a hash of all the characters widths.  For example, here's the
widths of helvetica and helvetica-bold:


  /*
   * This is an array of character widths for a few standard fonts.
   *
   * Included is "h" (helvetica) and "hb" (helvetica-bold).
   *
   * Each element is identified by the ascii decimal value of a
   * character as the key, and the width (wx) of the character as the
   * value.
   *
   * The widths are in thousandths of a point, so you can calculate a
   * characters width as follows:
   *
   * pt_size_of_font * wx_value / 1000
   */
  public static $char_wx = array("h"  => array("32"  => "278",
   "33"  => "278",
   "34"  => "355",
   "35"  => "556",
   "36"  => "556",
   "37"  => "889",
   "38"  => "667",
   "39"  => "222",
   "40"  => "333",
   "41"  => "333",
   "42"  => "389",
   "43"  => "584",
   "44"  => "278",
   "45"  => "333",
   "46"  => "278",
   "47"  => "278",
   "48"  => "556",
   "49"  => "556",
   "50"  => "556",
   "51"  => "556",
   "52"  => "556",
   "53"  => "556",
   "54"  => "556",
   "55"  => "556",
   "56"  => "556",
   "57"  => "556",
   "58"  => "278",
   "59"  => "278",
   "60"  => "584",
   "61"  => "584",
   "62"  => "584",
   "63"  => "556",
   "64"  => "1015",
   "65"  => "667",
   "66"  => "667",
   "67"  => "722",
   "68"  => "722",
   "69"  => "667",
   "70"  => "611",
   "71"  => "778",
   "72"  => "722",
   "73"  => "278",
   "74"  => "500",
   "75"  => "667",
   "76"  => "556",
   "77"  => "833",
   "78"  => "722",
   "79"  => "778",
   "80"  => "667",
   "81"  => "778",
   "82"  => "722",
   "83"  => "667",
   "84"  => "611",
   "85"  => "722",
   "86"  => "667",
   "87"  => "944",
   "88"  => "667",
   "89"  => "667",
   "90"  => "611",
   "91"  => "278",
   "92"  => "278",
   "93"  => "278",
   "94"  => "469",
   "95"  => "556",
   "96"  => "222",
   "97"  => "556",
  

Re: [fw-general] improvement in Filters with external input.

2007-03-20 Thread Drew Bertola
Doctorrock wrote:
> Now consider this use :
> GET /mypage.php?my_message[]='Hi' HTTP 1.1
> (...)
> 
> Zend_Filter_StringToLower::filter($_GET['my_message']);
> 
> Note that my_message is passed as an array, anyone can modify the type
> of params in the URL for a GET request, thus generating in that case a
> *Notice *: Array to string conversion in *my\file\dot\php* on line my_line.
> 
> Some of you would say that it's the programmer's job to cast the GET
> variable manually type before passing it to the filter, by I personally
> think that the filter function should do it by itself, as it expects a
> string in all cases, and nothing else...

I'd rather have it so that an exception is thrown (the way it is now, no?).

My reasoning is that if I make a coding blunder and pass an array (it
happens!), it will be caught rather than converted to a string and,
potentially passed to a validation chain, accepted, and entered into
storage.  All sorts of things could go wrong.

--
Drew


Re: [fw-general] MVC components now in core

2006-11-30 Thread Drew Bertola

Matthew Weier O'Phinney wrote:

So, go update your SVN tree and start coding!


Does this break any of the APIs with 0.2 (or older svn versions)?

What do I need to look out for if I update svn?
--
Drew


Re: [fw-general] Zend PDF - align right

2006-11-14 Thread Drew Bertola
Brent Robinson wrote:
> Hi There,
>
> I am having some issues with generating a script to align characters
> to the right on the framework pdf component.
This is what I did.

First, I used helvetica and helvetica bold, because they have easily
known widths.  I set up a hash to look up the widths and calculate total
string width using a quick custom function.  Then, I just subtract the
width from my right hand aligned position.  Cheap and dirty, but works
like a champ.  It's all below.

--
Drew

  /*
   * this function returns the typographic width of a string.
   */
  public function width_of($str, $font_key, $pt_size)
  {
/*
 * get the width of a numeric - used for right justification.
 */
$wx = 0;
   
for ( $i = 0; $i < strlen($str); $i++ )
  {
$ch = ord(substr($str, $i, 1));
$wx += self::$char_wx[$font_key][$ch];
  }

$width = ( $wx / 1000 ) * $pt_size;

return($width);
  }

  /*
   * This is an array of character widths for a few standard fonts.
   *
   * Included is "h" (helvetica) and "hb" (helvetica-bold).
   *
   * Each element is identified by the ascii decimal value of a
   * character as the key, and the width (wx) of the character as the
   * value.
   *
   * The widths are in thousandths of a point, so you can calculate a
   * characters width as follows:
   *
   * pt_size_of_font * wx_value / 1000
   */
  public static $char_wx = array("h"  => array("32"  => "278",
   "33"  => "278",
   "34"  => "355",
   "35"  => "556",
   "36"  => "556",
   "37"  => "889",
   "38"  => "667",
   "39"  => "222",
   "40"  => "333",
   "41"  => "333",
   "42"  => "389",
   "43"  => "584",
   "44"  => "278",
   "45"  => "333",
   "46"  => "278",
   "47"  => "278",
   "48"  => "556",
   "49"  => "556",
   "50"  => "556",
   "51"  => "556",
   "52"  => "556",
   "53"  => "556",
   "54"  => "556",
   "55"  => "556",
   "56"  => "556",
   "57"  => "556",
   "58"  => "278",
   "59"  => "278",
   "60"  => "584",
   "61"  => "584",
   "62"  => "584",
   "63"  => "556",
   "64"  => "1015",
   "65"  => "667",
   "66"  => "667",
   "67"  => "722",
   "68"  => "722",
   "69"  => "667",
   "70"  => "611",
   "71"  => "778",
   "72"  => "722",
   "73"  => "278",
   "74"  => "500",
   "75"  => "667",
   "76"  => "556",
   "77"  => "833",
   "78"  => "722",
   "79"  => "778",
   "80"  => "667",
   "81"  => "778",
   "82"  => "722",
   "83"  => "667",
   "84"  => "611",
   "85"  => "722",
   "86"  => "667",
   "87"  => "944",
   "88"  => "667",
   "89"  => "667",
   "90"  => "611",
   "91"  => "278",
   "92"  => "278",
   "93"  => "278",
   "94"  => "469",
   "95"  => "556",
   "96"  => "222",
   "97"  => "556",
   "98"  => "556",
   "99"  => "500",
   "100" => "556",
   "101" => "556",
   "102" => "278",
   "103" => "556",
   "104" => "556",
   "105" => "222",
   "106" => "222",
   "107" => "500",
   "108" => "222",
   "109" => "833",
   "110" => "556",
   "111" => "556",
   "112" => "556",
   "113" => "556",
   "114" => "333",
  

[fw-general] SVN 1499 - view bug...

2006-11-08 Thread Drew Bertola
I just filed zf-514 which reports on a view bug.  The problem is when 
validating that the view script file exists and is readable, the method 
is passed $name which _sometimes_ includes the full path, and sometimes 
is just the script name.  When it's passed the full path, it throws an 
exception because the file cannot be found.


I'll look deeper.

--
Drew


Re: [fw-general] Zend_Db_Table

2006-10-11 Thread Drew Bertola
Bruno Viana wrote:
> Lewt me explain better what i asked. I have a field called "NAME" (in
> upper case), but the Zend mapping don't see it when i use
> Zend_Db_Table. So, when i write in lower case( "name" ), thats works.

You can modify Zend/Db/Table.php to rid yourself of this behavior by
editing just a few lines.


around line 121 comment out:
 //self::$_inflector = new Zend_Db_Inflector();

around line 177 comment out original, and add simple replacement:
//$this->_name = self::$_inflector->underscore(get_class($this));
$this->_name = get_class($this);

around line 184:
//$this->_cols[$native] = self::$_inflector->camelize($native);
$this->_cols[$native] = $native;


I think that should do it.  I've been running like that for years now :)

--
Drew


Re: [fw-general] Best way to get action name and controller name within view...

2006-10-03 Thread Drew Bertola
Simon Mundy wrote:
> Hi Drew
>
> The new 0.2 release looks like it'll have the request object available
> to put into your view, which will make retrieval of your GET/POST/PATH
> fields much easier (and safer if you've applied a filter to it as well).
>
> In the meantime you may need to store the dispatcher token in your
> view if you wish to retrieve them from there. It will mean you'll have
> to use $token->getControllerName(), $token->getActionName() and
> $token->getParam('xxx') in your view, rather then $request->action,
> $request->controller, etc...

So, how do I access the dispatcher token from the controller script? 
I've poured over the documentation and didn't find a suggestion there. 
I guess I'll have to look through the code.  Any shortcuts?

>
>> Hi all,
>>
>> Is there a solution for determining the controller and action names
>> within a view?  I imagine it's there somewhere but I can't find it.  The
>> only solution I've found is to assign it every time from within the
>> actionAction() method in the controller script.



[fw-general] Best way to get action name and controller name within view...

2006-10-03 Thread Drew Bertola
Hi all,

Is there a solution for determining the controller and action names
within a view?  I imagine it's there somewhere but I can't find it.  The
only solution I've found is to assign it every time from within the
actionAction() method in the controller script.

--
Drew