July 3, 2008

admin emails

Filed under: ZenMagick — DerManoMann @ 2:45 am

I recently did some investigation into the generation of email content for emails intiated via the admin interface.

The code that gets executed is in zen-cart’s admin files for each admin function (for example, admin/gv_mail.php).

The only email that gets currently handled by ZenMagick is the order status update mail All others still use the zen-cart email templates under ../email (for HTML), or the hardcoded text for text based emails.

While it might be possible to improve the situation here (which I should and will do) there are some issues.

  • Guest checkout may result in duplicate email addresses
    While this is not very likely it does complicate matters. This would mean to rewrite most of the customer selection code that is based on email address.
  • Without a lot of patching the only information available will be the predefined HTML blocks.
    That means some more regular expressions in email templates to extract the information wanted. Alternatively, this could/should be moved into zen_fixes.php or the ZMEventFixes class.

In any case, if you have been wondering about the format of your stores emails, at least now you know why:)

Expect some gradual improvements over the next few releases…

June 18, 2008

Events and why using references is so nice

Filed under: PHP, ZenMagick — DerManoMann @ 1:58 am

I just checked in a couple changes that fire new events in case of a new account being created. The really nice things is now that event listener have a chance of modifying the account directly without having to change a single line of core code (or globals!).

For example, the following code would change the default authentication status for all new accounts:

class Blocker {
public function onZMCreateAccount($args) {
$account = $args['account'];
$account->setAuthorization(ZM_ACCOUNT_AUTHORIZATION_BLOCKED);
}
}

ZMEvents::instance()->attach(new Blocker());

I guess it couldn’t be any easier than that (other than re-defining the default authentication value ;)

June 16, 2008

0.9.1 - small bugs

Filed under: ZenMagick — DerManoMann @ 11:30 am

So, as usual, upgrading the demo site pciked up two minor issues with the new release.

  • The quick edit admin plugin contains a custom field config file that will break the site.
    This is a test file I created and that was not intended to be included in the release. Deleting the file fixes the problem (even though it’s a nice example of how to customize the fields ;)
  • The product info view in the demo theme does not display attributes.
    This is a regression caused by the theme changes in this release and all that is missing is to actually echo the attribute HTML.
    Line $53 should look like this: <p><?php echo $option ?></p>

I’ll update this post if I find anything else.

OpenID

Filed under: ZenMagick — DerManoMann @ 12:23 am

Astute readers might have already found the hint about OpenID in my tasklist. I have been pondering support for OpenID for quite some time, but decided to wait until 0.9.1. is out before diving into it.

Actually, that is not exactly true, as I did spend some time preparing for it. In particular, the code changes to extract the PHP compressor and the new PHP packer were already done with this in mind.

So, I manager to compress and pack the excellent PHP OpenID library by JanRain into a single file. Add some inspiration and code bits from Saeven OpenID and you are almost there :)

Unfortunately, the plugin will require code changes to ZMAccounts (well, not really changes, but upgrade to using the new ZMDatabase layer). But hopeully the next release will not take as long as the last one.

Note to self: Upgrade website with new API docs for 0.9.1 and also the demo store!

June 11, 2008

The Release!

Filed under: ZenMagick — DerManoMann @ 11:05 pm

Yes, I finally did it. Quite possible the biggest ZenMagick release ever (and not just the file size!).

In time I will have to update the wiki to reflect the new way to access services and also the template examples.

For now I am just happy that the code is now in the wild so people can start playing around with it and hopefully let me know what they do like and dislike.

Meanwhile, I will try aiming for a 1.0.0 release. There are going to be a few more 0.9.x releases, to be sure, but getting the template changes (well, most) out of the way feels very good.

As always, feedback is very welcome.

compressing PHP packages

Filed under: PHP, ZenMagick — DerManoMann @ 2:03 am

I have written before about how I managed to compress Creole into a single file. Now, I have extracted the more generic bits of code into a single utility class. The class has a couple callback methods to cope with custom handling. Actually, I implemented those callbacks exactly the way I needed them to implement the creole specific code, but it should the typical exceptions.

To use this, I added the first CLI script to ZenMagick. I do not expect a lot of user to require to run it, but it makes for a nice example of how to use the class.

For those interested in all the gory details, here is the source of the script:


// load ZenMagick core
$coreDir = dirname(dirname(__FILE__)) . '/core/';
require $coreDir.'ZMLoader.php';
ZMLoader::instance()->addPath($coreDir);
ZMLoader::resolve('ZMObject');
ZMLoader::resolve('ZMPhpPackagePacker');

/**
* Custom class for Creole specific dependency handling.
*/
class CreolePacker extends ZMPhpPackagePacker {
/**
* {@inheritDoc}
*/
public function isResolved($class, $level, $files) {
// Record does have circular references
return (’Record’ == $class && 1 == $level);
}

/**
* {@inheritDoc}
*/
public function finalizeDependencies($dependencies, $files) {
// there is no explicit include/require for this
$dependencies[’DebugConnection’][] = ‘Connection’;
return $dependencies;
}
}

// pack; ideally path/version should be CLI args…
$creoleVersion = ‘creole-1.1.0′;
$packer = new CreolePacker(’c:/temp/’.$creoleVersion.’/classes/’, ‘c:/temp/’.$creoleVersion.’.packed.php’);
$packer->setDebug(false);
$packer->packFiles();

The script extends the generic package packer class to implement custom callbacks. Creole is actually a quite easy to analyze, as almost all (except for one Connection) dependencies are covered by include and require statements.

So, executing the scirpt will result in the new file creole-1.1.0.pack.php which is about 187kb large and, at least for the default drivers, makes the custom class loading in Creole obsolete.

long term I hope to be able to extract the generic MVC code out of ZenMagick and compress is using the some similar code. This will require some more work, though, as the current class does not look at extends and implements of classes. Since all code depends on the loader, rather than import/require, analyzing those will be required in order to build a proper dependency map.

Should anyone use this for their own project, then it would be great to let me know.

May 26, 2008

tasklist for 1.0.0

Filed under: ZenMagick — DerManoMann @ 12:21 am

In my last post I started a list of things to do before the magic 1.0.0 release. I’d like to keep this post as a reference for things to do. Hopefully, I’ll be adding (and removing!) things often as I go.

Of course, suggestions are highly welcome…

  • admin - maintenance
  • facets
  • other plugins
  • make ZMPluginView more useful and start using it (this will require changes to a few plugins that do funny this loading files and eval’ing them…)
  • review email templates and integration (plus perhaps a new email service?)
  • review the remaining template functions (l10n, i18n)
  • alternative shipping/payment/order total modules
    NOTE: This is actually not to replace or reimplement any existing code. However, should plugins wish to implement new modules, that should be possible without relying on globals (in particular as those might not be available using ZenMagick in the first place)
  • review the security code - for one thing it’s not possible to have multiple authentication sources (one alternative could probably be OpenID)
  • Review and perhaps improve the price/attribute lookup code (reduce database queries)

Also, there are some things that are beyond 1.0.0, but nevertheless worth writing done:

  • Start using the alternative bootstrap code (alpha at most at the moment) for all non checkout pages to further reduce the init code
  • Redo session handling to start sessions only when really needed (any form of login, cart action, language change)
  • Complete template review - refactor some of the view classes, access views and (side-)boxes (and others) via the same view access code. That should allow more fine grained caching. A possible implementation could have a PageView to access the full page and FragmentViews to access smaller bits like boxes, views, etc. However, rather than re-inventing even more wheels it might be more effective to improve the Smarty plugin and probably complete the smarty default theme.
  • Have some more themes

May 16, 2008

regressions

Filed under: ZenMagick — DerManoMann @ 3:06 am

Right!
After spending quite some time on fixing regressions from my refactoring madness its finally time to get ready for the next release.

Rather than reiterating the things that have been changed/added/fixed/improved I’d like to talk a bit about what is coming next. I am aware that I never much of a roadmap for ZenMagick. One of the reasons being that there was just too much to do and I never had real priorities. With the changes coming in 0.9.1 there isn’t a lot left to be done for the templating side of things until we’ll eventually hit ZenMagick 1.0. The API, on the other hand, still requires some work.

While the API is pretty much complete as far as the storefront functionallity is concered, it lacks quite a bit when it comes to the admin side. What I mean is the ability to create and update data. While there has been some work in that area, there is still a lot left. As a general rule, create/update functionallity is available where it was needed.

With the introduction of the new database code I hope to finally get this big gap filled and make ZenMagick even more attractive for integrators and people interested in extending zen-cart.

There is also going to be some more work in refactoring the core code. While this is not strictly necessary, I have the urge to do that just to make myself happy (I hope that is reason enough ;)

Parallel to all that there are plans for a lot more work around plugins:

  • admin - maintenance
    There are a few plugins that I started, but never finished. Those would make the Catalog Manager a lot more useful. However, those will most likely depend on the missing data access features of the API (namely, creating and updating date like products, categories and other)
  • facets
    This is something I started as a reaction to some discussion about alternative ways to navigate the catalog. Eventually, I hope this will be good enough to replace and improve the current result list/filter code (not sure about the sorter, though). It should be more performant (using some form of caching) and generally smarter.
  • other
    There are a couple other plugins I can feel coming. This might include some more support plugins for zen-cart mods, but also some new features for the storefront side of things.

Finally, there is more need to trim the code and make it perform better. I plan to have a look at what other PHP based apps do for that and see what seems useful. Suggestions welcome.

So, again, not much of a real roadmap, but I think that a version 1.0 is finally (far, far) far away becoming visible. If you feel I have missed anything important, please, please comment or write me an email.

Happy weekend, everyone

May 8, 2008

Compressing Creole into a single file

Filed under: PHP, ZenMagick — DerManoMann @ 5:28 am

Right, I am just about to check in some new code that makes will make it very easy to import/prepare Creole for the ZenMagick loader architecture. The new (mostly unused) class ZMPhpCompressor also allows to squezze a full Creole release (everything under classes) into a single 188kb file.

I am actually not sure if I should include that already with the next release, as right now there are probably about 3 or four queries per request done by the new API and I might as well stick with the existing code a bit longer - we’ll see.

The code depends on two other ZenMagick classes, so it’s not very portable (if anyone is interested), but apart from that it works fine ;)

The actual code to do the magic looks like this on my XP box:

$creole = 'creole-1.1.0';
zm_creole_import('C:/TEMP/'.$creole);

$comp = new ZMPhpCompressor();
$comp->setRoot(’C:\Program Files\Apache Group\Apache2\htdocs\zen-cart\zenmagick\core\ext/’.$creole);
$comp->setOut(’C:\Program Files\Apache Group\Apache2\htdocs\zen-cart\zenmagick\core\ext/’.$creole.’.php’);
$comp->setTemp(’C:\Program Files\Apache Group\Apache2\htdocs\zen-cart\tmp’);
$comp->compress();

Not sure how often I’ll be using this, but it’s nice not having to try to remember these things once they are needed again!

The only caveeat is that compressing into a single file breaks the Creole ‘dot-path notation’, so in order to use the MySQL driver you’ll need to do something like:

Creole::registerDriver('mysql', 'MySQLConnection');

to avoid errors about missing drivers. Since all database access in ZenMagick is handled by a single database provider class that’s not really an issue, though.

That means the last open issue is to write some proper release notes - oh, well, babysteps ;)

May 3, 2008

release candiates - anyone?

Filed under: ZenMagick — DerManoMann @ 4:01 am

I’ve been trying to get a release together for quite some time now, but as laid out before, I was unable to resist to add this ‘last new feature’ before releasing.

Due to the massive amount of changes (even though old themes will be good with a handful of small changes) I think I’ll actually have a release candidate before doing a proper one.

There are currently three remaining issues, though:

  • Creole
    The script to “import” the Creole code (read: fiddle around to make it work with ZMLoader) is still custom and ideally I’d prefer to have a single compressed creole.php file rather than the single files. This will require splitting the core compressor code into a generic bit and the ZenMagick specific parts. Once that is done I’ll be able to compress individual folder and subtrees just as needed.
  • Release notes
    My old nemesis. With the growing number of changes it’s becoming imperative to have some good release notes so people can make an informed decision about whether they want to upgrade or not.
    Also, it should contain enough details to make theme migration an easy task
  • Time
    As some of you might have noticed I am not online a lot at the moment. There are some good, personal reasons for that so expect this continue for a while.

If anyone is interested to give the current code a try let me know and I’d be happy to put a custom build together for you (there is also the option of accessing the trunk code directly at sourceforge.)

Next Page »