Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#37 2005-06-23 06:23:45
- uHunkler
- New Member
- From: Braunschweig
- Registered: 2005-01-11
- Posts: 4
Re: I made some scripts that import/export templates, forms and css
Scott, \x27 is the hex value for the apostrophe (singelquote) '
and \x5c for the backslash. The replacement string \x5c\x27 means \'
.
> Is it a fix only for your template or for and single quote?
The line $template_data2 = str_replace("\x27", "\x5c\x27", $template_data);
replaces all apostrophes in all files.
I did some research and found the php function addslashes()
“addslashes()
(PHP 3, PHP 4, PHP 5)
addslashes—Quote string with slashes
… An example use of addslashes() is when you’re entering data into a database. For example, to insert the name O’reilly into a database, you will need to escape it. …”
So php has a build in function for the escaping. Before every line starting with “safe_update(…” and “safe_insert(…” you should add the line:
$template_data = addslashes($template_data);
I changed your script and it works as expected. The page part of the file “template-import.php” will look for example:
<pre>
<code>
/* if import==1 and database does not contain entry */
elseif($db_data!=$template_data && $import_new==“1” && $db_data==’‘) {
#import into database
$template_data = addslashes($template_data);
safe_insert(“txp_page”, “name = ‘$template_name1‘, user_html = ‘$template_data’”);
$message = ‘<span class=“notice”>inserted into database</span>’;
}
else {
# update db page table where row name is $template_name
$template_data = addslashes($template_data);
safe_update(“txp_page”, “user_html = ‘$template_data’”, “name = ‘$template_name1‘”);
$message = ‘<span class=“notice”>updated</span>’;
</code>
</pre>
Scott, I think you should update your import script ;-)
And many thanks again for your welthy scripts.
Urs
Last edited by uHunkler (2005-06-23 07:19:18)
Offline
Offline
Re: I made some scripts that import/export templates, forms and css
Looking forward to trying this when I get home from work, thanks swf.
Offline
Offline
#41 2005-08-30 09:22:17
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: I made some scripts that import/export templates, forms and css
Hey swf,
this looks like exactly what I’ve been wanting – having everything in the db is great and all, but it doesn’t play well with svn. Just a quick question before I fry my site .. er, install this puppy; is it ok for TxP v4?
peace – boblet
Offline
#42 2005-08-30 09:45:22
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: I made some scripts that import/export templates, forms and css
ok forget I spoke – this exports and imports successfully in TxP v4. Rockin’!
Offline
#43 2005-08-30 10:18:21
- davidm
- Member
- From: Paris, France
- Registered: 2004-04-27
- Posts: 719
Re: I made some scripts that import/export templates, forms and css
> boblet wrote:
> ok forget I spoke – this exports and imports successfully in TxP v4. Rockin’!
That’s very cool news I’ll try it !
Thanks for sharing :-)
.: Retired :.
Offline
Re: I made some scripts that import/export templates, forms and css
I can’t seem to get it to work, I followed the instructions exactly, and the script appears to be running, but the _template folder is empty. I tried it with both 755 and 777 (eek!) permissions on the folder, to no avail. Any ideas?
After enduring years of Art School, mild mannered Owen Waring noticed some unusual changes… the constant bombardment of criticism, it seems, had altered his DNA. Half pixel pusher, half programmer, he had become…. THE BIZARTIST
Offline
Re: I made some scripts that import/export templates, forms and css
Marvellous! Thank you so mutch!
I always have an ocean full of forms and template-pages, no problem reusing them in other installs now!
> swf wrote:
>I don’t know if I’ll be able to make this an admin plugin but I plan on making it one file with a drop down option to import or export and perhaps include a form for choosing a sub folder so it is easier to organize theme import/exports.
Other suggestions are more than welcome.
The future possibility to pick and choose WHICH of the items one wants to import or export would help me narrow things down a bit..
Offline
#46 2006-01-05 12:04:02
- alexwest
- Member
- From: Järna, Sweden
- Registered: 2004-08-04
- Posts: 53
Re: I made some scripts that import/export templates, forms and css
Just upgraded to TXP 4.0.3 and am using Link Template2File v0.3.1
I get these errors and templates are not exported:
Notice: Use of undefined constant TXP_DEBUG – assumed ‘TXP_DEBUG’ in c:\www\alexwest\textpattern\lib\txplib_db.php on line 50
Fatal error: Call to undefined function: getmicrotime() in c:\www\alexwest\textpattern\lib\txplib_db.php on line 55
Is anyone else using this plugin/hack and had the same errors with the new version of TXP?
be safe and happy
Offline
#47 2006-02-11 09:49:29
- helena
- New Member
- Registered: 2006-02-11
- Posts: 3
Re: I made some scripts that import/export templates, forms and css
I have a vanilla install of TXP 4.0.3 and LinkTemplate2File 0.3.1. I get the same error as alexwest when I load template-export.php.
I would really like to get this to work, it would be great if anyone had a solution.
Offline