Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2011-01-27 13:32:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

cXc wrote:

I just don’t understand how it works or how to use it

Hehe, no worries. I don’t understand how the classes work; I just took them from PHPClasses as they were the best — and most compact — ones I could find, then sent the authors an e-mail to say how cool they were :-)

If you’re only supporting zip you can get away with just copying the dUnzip2 class (well, ok smd_dUnzip2 as I had to rename all the functions to maintain the smd_ namespace: you’ll need to do likewise with your prefix). Essentially it’s lines 2500 – 3150ish, plus the comment header block of course.

So if you want to export some files you can do something like the following. It’s untested as I don’t do it this way — I use the other class smd_at_archive for zipping up stuff (because I fixed it to handle recursion properly), but it’s overkill for your needs here.

$zip = new smd_dZip($dest_filename); // Optional boolean 2nd arg to force overwrite if file already exists. Default: true
$zip->addDir($folder_path_of_files_to_zip); // Not sure if it's recursive. If not, just call $zip->addDir() for each one
..
..
$zip->save()

That creates the $dest_filename file. Then you can just grab that file and send it to the browser with an appropriate header(). For reference, the other class in smd_admin_themes which does everything except unzip (grrrr…) has some nice options you can set so that it’ll deliver the zipped file to the browser by itself, but it’s not much hardship to send it by hand. You can look in that other class for the download_file() function if you want to see how they do it.

And for unzipping:

$zip = new smd_dUnzip2($zipfile);
$zip->getList(); // Not sure if this is necessary. Try it with and without to see?
$zip->unzipAll($basedir_of_where_to_unpack);
$zip->close();

Job done. Hope that helps.

Last edited by Bloke (2011-01-27 13:33:23)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2011-01-27 14:33:25

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Just to get around any possible server limitations, in my “Coda” release I have included instructions for manually unzipping and uploading the theme folder into place if the plugin’s .zip upload facility is hanging or doesn’t appear or won’t let you browse. Then I’ve told the user to use the “Import Template” facility and give his/her host hell. ;)

I’ve also include an empty /tpl/ folder (or in my case /_templates/) which is for manual uploading and chmod just in case the server permissions won’t allow the plugin to create it. The way my instructions are laid out, manual uploading is done as a “matter of course” rather than waiting to see if the plugin can perform the task.

As far as the /cache/ directory is concerned I did mention to Doc (and he has said so earlier) that this was something that really only concerned my themes which all use an image-resizing script and really shouldn’t be a part of the plugin. As far as my themes are concerned though it doesn’t matter whether it is there or not as the /cache/ directory (empty) is included in the theme download and the user is instructed to upload it themselves along with the /_templates/ folder and the image-resizing script.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#15 2011-01-27 15:31:57

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Bloke wrote:

I ended up including — at great pluign size expense — custom libraries that I downloaded from PHPClasses so I could offer Zip support across the board.

Stef

A thought I had in a previous discussion with Doc

Could the zip portion of smd_admin_themes be broke out as a plugin library that smd_admin_themes, cxc_templates and other plugins could use?

Last edited by maverick (2011-01-27 15:35:55)

Offline

#16 2011-01-27 17:04:00

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

The only problem I see with that Mike is that a user would now have to manually install 2 plugins prior to doing the theme installation. No biggie for all of us veterans but I’m trying to make this a simple a process as possible for the noobs, so I would not favour such a split even though I can totally see the logic behind it.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#17 2011-01-27 17:27:38

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

That’s is a drawback that cross my mind too, Stuart. I totally appreciate your point of view.

Here’s why I came down on the side of breaking it out as a preferred route

  • We already have many plugins that need a library or second plugin. zem_contact_reborn, soo_, smd_, wet_, sed_, mem_ all have some or all of their plugins in need of a second/lib plugin

The great thing is that with the new template plugins, cxc_templates in particular, is that installing plugins is simplified. All the necessary plugins are installed and enabled.

The drawback is that it doesn’t help prior to installing the cxc_template. Still, to install and enable two plugins (a lib and cxc_template) seems pretty easy, especially if they are packaged together. If you can install and enable cxc_template, doing one more doesn’t seem like it should be a big issue, even for noobs.

Since cxc_templates and smd_admin_themes are likely to both be installed eventually, having the smaller amount of code seems preferable.

In the vein of simplicity, though, maybe there is a way to install cxc_templates and have it automatically load the needed library plugin from the new Textpattern.org?

Last edited by maverick (2011-01-27 17:28:34)

Offline

#18 2011-01-27 18:53:11

~cXc~
Plugin Author
Registered: 2010-12-27
Posts: 39

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Mike, after Stef explained how it worked (my gratitude is immense for the education) I have started working on making the required adjustments. I have had this one thought the whole time though, you and Zanza still may not be able to get it to work even with this it still requires the PHP ZLIB to function. So I’ve decided I’ll indeed include the error messages discussed earlier and if possible, Stuart, could you send me a copy of the docs for Coda (just the docs) so I can either plagiarize it or get inspiration from it

The classes Stef encouraged me to use are not as complicated as I had thought after seeing the hooks I think I can get it working :)
So far it unzips and installs properly so I’m back to working on the Zip Project feature, and adding the educational information about PHP ZLIB and how to enable it and if its not possible aggravate the host :P I like covering all the bases with error messages o.O this plugin is more or less targeting new users not the veterans that understand it all ;) they need to be educated and taught the things I’ve learned while refactoring the plugin.

Back to work and see if I can get recursive directory zipping ;)

@Stef, to maintain the namespace I only have to name my classes cxc_ right? I don’t need to bother with function names?

Last edited by ~cXc~ (2011-01-27 18:59:14)

Offline

#19 2011-01-27 19:19:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

cXc wrote:

it still requires the PHP ZLIB to function.

Yeah. A pain. But more widespread than the Extension.

to maintain the namespace I only have to name my classes cxc_ right? I don’t need to bother with function names?

Correct. Anything globally acessible to TXP needs your prefix: the internal functions are merely private methods.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#20 2011-01-27 21:53:24

~cXc~
Plugin Author
Registered: 2010-12-27
Posts: 39

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Sorry but I have to postpone this until tomorrow, I’m so sleepy, I just fell out of my chair o.O

I have most of it ready but I’ve created some permission issues, I’m having trouble deleting uploaded files after they are extracted and webroot installation seems to be completely broken :(

Last edited by ~cXc~ (2011-01-27 21:54:30)

Offline

#21 2011-01-30 22:59:51

~cXc~
Plugin Author
Registered: 2010-12-27
Posts: 39

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

New version released http://code.google.com/p/cxc-templates/downloads/list please look over and let me know if there are any errors or anything else I need to work on. If there are no new issues I want to move to v0.1.0 and call it a stable beta :D

I want to thank everyone that has been helping by testing and contributing advice and code, Stef I accidentally left you off the thanks and credits list but you will be added in the next release ;)

Sorry it took me three days to figure out how to delete the uploaded files o.O unless something new is discovered the only thing I have left on my ‘to do’ list is recursively delete ‘preimport-data’ before exporting to it during import … I found a few hundred form files from playing around in the ‘preimport-data’ of my test site lol that made me decide I should delete it each time so that it only contains the files and settings that were active at the time of install. That’s all I got or all I can remember that I have left o.O

[ edit ] v0.0.8 added to the SVN but no full release since I’m still making small changes in the help section and other areas and waiting for any issues that might be reported, v0.0.8 adds deletion of ‘preimport-data’ and acknowledgment of Stef’s contribution to my education :) [ /edit ]

Last edited by ~cXc~ (2011-01-31 11:54:12)

Offline

#22 2011-01-31 11:40:57

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Nice! Now it works on my server. I have been able to export my actual template and to load Translucence, then to revert to mine. Everything is ok (except that translucence theme have widgets and variables that doesn’t fit by default with my section naming, but that’s another problem; maybe a problem that could prevent easy theming adoption from basic users, but it’s not the right place to talk about it).

I’ll report back any issue as I use the system. Thank you for your great job so far!

Offline

#23 2011-01-31 12:28:29

~cXc~
Plugin Author
Registered: 2010-12-27
Posts: 39

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Sorry about the back to back releases v0.0.8 now available http://code.google.com/p/cxc-templates/downloads/list changes outlined in my previous post, hopefully this will be the final alpha release.

Last edited by ~cXc~ (2011-01-31 12:30:43)

Offline

#24 2011-02-11 10:18:45

~cXc~
Plugin Author
Registered: 2010-12-27
Posts: 39

Re: [plugin] [ORPHAN] cxc_templates : front-end template management

Nobody complained about the last couple releases so I went ahead and added language string support (until I can figure out textpacks) and moved the release to public beta. The cxc_templates v0.1.0 plugin is now available at Google Code and I’ve updated the first post of this thread :)

o.O I hate piggy backing my own post o.O sorry for the double … o.O

Last edited by ~cXc~ (2011-02-11 10:20:17)

Offline

Board footer

Powered by FluxBB