[pLog-svn] r5939 - in plog/trunk: js/ui/pages locale/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Sep 15 14:10:22 EDT 2007
Author: oscar
Date: 2007-09-15 14:10:22 -0400 (Sat, 15 Sep 2007)
New Revision: 5939
Modified:
plog/trunk/js/ui/pages/templateeditor.js
plog/trunk/locale/admin/locale_en_UK.php
plog/trunk/templates/admin/edittemplatefile_form.template
Log:
Added some snippets of smarty code to the template editor so that users can easily add some of the most common bits of code to their templates if needed
Modified: plog/trunk/js/ui/pages/templateeditor.js
===================================================================
--- plog/trunk/js/ui/pages/templateeditor.js 2007-09-15 14:48:03 UTC (rev 5938)
+++ plog/trunk/js/ui/pages/templateeditor.js 2007-09-15 18:10:22 UTC (rev 5939)
@@ -197,6 +197,67 @@
}
}
+/**
+ * Inserts the relevant Smarty snippet in the editor
+ */
+Lifetype.UI.Pages.TemplateEditor.insertSnippet = function( editor )
+{
+ var selBox = Lifetype.Dom.$( 'smartySnippets' );
+ var snippetName = selBox.options[selBox.selectedIndex].value;
+
+ snippets = {
+ posts_loop:""+
+ "{foreach from=$posts item=post}\n"+
+ " <a href=\"{$url->postPermalink($post)}\">{$post->getTopic()}</a>\n"+
+ "{/foreach}\n",
+ categories_loop: ""+
+ "{foreach from=$categories item=$category}\n"+
+ " <a href=\"{$url->categoryLink($category)}\">{$category->getName}</a>\n"+
+ "{/foreach}\n",
+ archives_loop: ""+
+ "{foreach from=$archives item=archivelink}\n"+
+ " <a href=\"{$archivelink->getUrl()}\">{$archivelink->getName()}</a>\n"+
+ "{/foreach}\n",
+ links_loop: ""+
+ "{foreach name=linkcategories from=$mylinkscategories item=linkcategory}\n"+
+ " {if $linkcategory->getNumLinks() > 0}\n"+
+ " {if $smarty.foreach.linkcategories.first}<ul>{/if}\n"+
+ " <li>\n"+
+ " <b>{$linkcategory->getName()}</b>\n"+
+ " {foreach name=linkcategorylinks from=$linkcategory->getLinks() item=link}\n"+
+ " {if $smarty.foreach.linkcategorylinks.first}<ul>{/if}\n"+
+ " <li><a href=\"{$link->getUrl()}\" title=\"{$link->getDescription()}\">{$link->getName()}</a></li>\n"+
+ " {if $smarty.foreach.linkcategorylinks.last}</ul>{/if}\n"+
+ " {/foreach}\n"+
+ " </li>\n"+
+ " {if $smarty.foreach.linkcategories.last}</ul>{/if}\n"+
+ " {/if}\n"+
+ "{/foreach}",
+ get_blog_link: ""+
+ "<a href=\"{$url->blogLink()}\">{$blog->getBlog()}</a>\n",
+ get_blog_users: ""+
+ "{assign var=blogUsers value=$blog->getUsersInfo()}\n"+
+ "{foreach from=$blogUsers item=blogUser}\n"+
+ " {$blogUser->getUsername()}<br/>\n"+
+ "{/foreach}",
+ get_user_picture: ""+
+ "{assign var=blogOwner value=$blog->getOwnerInfo()}\n"+
+ "{if $blogOwner->hasPicture()}\n"+
+ " {assign var=picture value=$blogOwner->getPicture()}\n"+
+ " <img id=\"UserPicture\" src=\"{$picture->getPreviewLink()}\" alt=\"{$blogOwner->getUsername()}\" /><br/>\n"+
+ " {$blogOwner->getAboutMyself()}\n"+
+ "{/if}"
+ };
+
+ for( snippet in snippets ) {
+ if( snippetName == snippet ) {
+ // insert the snippet in the current position of the cursor
+ editor.insertText( snippets[snippet] );
+ break;
+ }
+ }
+}
+
YAHOO.util.Event.addListener( window, "load", function() {
var t = new Lifetype.Effects.Table( "templateFiles" );
t.stripe();
Modified: plog/trunk/locale/admin/locale_en_UK.php
===================================================================
--- plog/trunk/locale/admin/locale_en_UK.php 2007-09-15 14:48:03 UTC (rev 5938)
+++ plog/trunk/locale/admin/locale_en_UK.php 2007-09-15 18:10:22 UTC (rev 5939)
@@ -1340,6 +1340,15 @@
$messages['hide_global_templates'] = 'Hide global templates';
$messages['show_global_templates'] = 'Show global templates';
+$messages['snippet_posts_loop'] = 'Posts loop';
+$messages['snippet_categories_loop'] = 'Categories loop';
+$messages['snippet_archives_loop'] = 'Archives loop';
+$messages['snippet_links_loop'] = 'Links loop';
+$messages['snippet_get_blog_link'] = 'Blog link';
+$messages['snippet_get_blog_users'] = 'Blog user list';
+$messages['snippet_get_user_picture'] = 'User picture';
+
+
$messages['ok'] = 'Ok';
$messages['cancel'] = 'Cancel';
?>
\ No newline at end of file
Modified: plog/trunk/templates/admin/edittemplatefile_form.template
===================================================================
--- plog/trunk/templates/admin/edittemplatefile_form.template 2007-09-15 14:48:03 UTC (rev 5938)
+++ plog/trunk/templates/admin/edittemplatefile_form.template 2007-09-15 18:10:22 UTC (rev 5939)
@@ -23,11 +23,15 @@
</div>
<select id="smartySnippets">
- <option value="">Posts loop</option>
- <option value="">Archives loop</option>
- <option value="">Links look</option>
+ <option value="posts_loop">{$locale->tr("snippet_posts_loop")}</option>
+ <option value="categories_loop">{$locale->tr("snippet_categories_loop")}</option>
+ <option value="archives_loop">{$locale->tr("snippet_archives_loop")}</option>
+ <option value="links_loop">{$locale->tr("snippet_links_loop")}</option>
+ <option value="get_blog_link">{$locale->tr("snippet_get_blog_link")}</option>
+ <option value="get_blog_users">{$locale->tr("snippet_get_blog_users")}</option>
+ <option value="get_user_picture">{$locale->tr("snippet_get_user_picture")}</option>
</select>
- <a href="#" onClick="return(false);">{$locale->tr("insert")}</a>
+ <a href="#" onClick="Lifetype.UI.Pages.TemplateEditor.insertSnippet(ed1);return(false);">{$locale->tr("insert")}</a>
</fieldset>
<div class="buttons">
More information about the pLog-svn
mailing list