Skip to content

Commit d4b5515

Browse files
author
skrol29
committed
Drupal plugin version 1.5.0
1 parent a1a8314 commit d4b5515

File tree

5 files changed

+96
-172
lines changed

5 files changed

+96
-172
lines changed

cms_drupal/tbs/changes.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Changes from the previous versions of TBS Dynamic Articles (any CMS)
2+
3+
[ok] delete the "Embedded scripts" feature
4+
5+
Specific to Drupal ?
6+
[ok] delete the "AllowedIds" option
7+
[ok] delete the "Full rights articles" option
8+
9+
[ ] default value for "script location" should be "site\all\tbs_scripts"
10+
[ ] allows only Direct MergeBlock with "SELECT" queries
11+
[ ] option for TBS delimiters should be only for Direct MergeBlock, not script + add a wrapper to set de delimiters from de PHP script
12+
[ ] option for TBS variables should be only for Direct MergeBlock, not script
13+
[ ] provide a wrapper that provide a TbsSQL instance
14+
15+
CMS info
16+
[ ] provide an PHP wrapper that provide current user info : id+name+role+...
17+
[ ] provide an PHP wrapper that tells if a user U is in the role R
18+
[ ] provide an TBS special field that return the current URL + current URL havin '&' or '?' for GET parameters
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+

cms_drupal/tbs/tbs.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
name = TinyButStrong
33
description = Dynamic Content
44
package = TinyButStrong
5-
version = 1.0-beta-20110105
5+
version = 1.5.0-beta-20110301
66
core = 6.x

cms_drupal/tbs/tbs.module

Lines changed: 46 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/*
55
1) Home�Administer�Site building�Modules => enable "Dynamic pages with TinyButStrong"
66
2) Home�Administer�Site configuration�Input Formats => Add
7-
87
*/
98

109
function tbs_help($path, $arg) {
@@ -22,53 +21,53 @@ function tbs_help($path, $arg) {
2221
http://api.drupal.org/api/function/hook_filter
2322
*/
2423
function tbs_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
25-
switch ($op) {
26-
case 'list':
27-
return array(0=> t('Dynamic content with TinyButStrong')); // Title displayed in the "Add input format" screen
28-
case 'no cache':
29-
return true; // avoid cache for this filter => the node must be dynamic, this is the main goal
30-
case 'description':
31-
return "Activate TBS tags that produce dynamic content automatically or trought a custom script."; // displayed in "Home�Administer�Site configuration�Input Formats"
32-
case 'prepare':
33-
return $text;
34-
case 'process':
35-
tbs_merge_node($text);
36-
return $text;
37-
case 'settings':
38-
// displayed in "Home�Administer�Site configuration�Input formats�TBS�Configure"
39-
$form['tbs_filter'] = array('#type' => 'fieldset', '#title' => t('Dynamic content with TinyButStrong'), '#value' => t('You can define a global list of smileys on the !page.', array('!page' => l(t('smileys settings page'), 'admin/settings/tbs'))));
40-
return $form;
41-
}
24+
switch ($op) {
25+
case 'list':
26+
return array(0=> t('Dynamic content with TinyButStrong')); // Title displayed in the "Add input format" screen
27+
case 'no cache':
28+
return true; // avoid cache for this filter => the node must be dynamic, this is the main goal
29+
case 'description':
30+
return "Activate TBS tags that produce dynamic content automatically or trought a custom script."; // displayed in "Home�Administer�Site configuration�Input Formats"
31+
case 'prepare':
32+
return $text;
33+
case 'process':
34+
tbs_merge_node($text);
35+
return $text;
36+
case 'settings':
37+
// displayed in "Home�Administer�Site configuration�Input formats�TBS�Configure"
38+
$form['tbs_filter'] = array('#type' => 'fieldset', '#title' => t('Dynamic content with TinyButStrong'), '#value' => t('You can define a global list of smileys on the !page.', array('!page' => l(t('smileys settings page'), 'admin/settings/tbs'))));
39+
return $form;
40+
}
4241
}
4342

4443
function tbs_merge_node(&$text) {
4544

46-
// Search for plugin tags inside the article. There is a loop because the article can support several mergings.
47-
$tag_beg = '{tbs}';
48-
$tag_end = '{/tbs}';
49-
$p1 = strpos($text, $tag_beg);
50-
if ($p1===false) return; // If no TBS tag, then the node doesn't need the plugin.
45+
// Search for plugin tags inside the article. There is a loop because the article can support several mergings.
46+
$tag_beg = '{tbs}';
47+
$tag_end = '{/tbs}';
48+
$p1 = strpos($text, $tag_beg);
49+
if ($p1===false) return; // If no TBS tag, then the node doesn't need the plugin.
5150

52-
include_once('tinybutstrong_comm.php');
53-
include_once('tinybutstrong_spec.php');
51+
include_once('tinybutstrong_comm.php');
52+
include_once('tinybutstrong_spec.php');
5453

55-
$TBS = false;
54+
$TBS = false;
5655

57-
// Drupal: The node Id cannot be retreive in the context of a filter process because the filter can be applied on a combination of nodes.
58-
//if (!tbs_plugin_CheckArticle($NodeId)) return ''; // Exit the plug if the node is not allowed
59-
60-
tbs_plugin_InitTBS($TBS, $text);
61-
tbs_plugin_SqlDbInit($TBS); // retrieve SQL information and set them as custom property of $TBS
56+
// Drupal: The node Id cannot be retreive in the context of a filter process because the filter can be applied on a combination of nodes.
57+
//if (!tbs_plugin_CheckArticle($NodeId)) return ''; // Exit the plug if the node is not allowed
58+
59+
tbs_plugin_InitTBS($TBS, $text);
60+
tbs_plugin_SqlDbInit($TBS); // retrieve SQL information and set them as custom property of $TBS
6261

63-
// Wrappers for developpers
64-
// $TBS->DrupalDb = $TBS->_CmsDbSrc;
62+
// Wrappers for developpers
63+
// $TBS->DrupalDb = $TBS->_CmsDbSrc;
6564

66-
$tag_lst = tbs_plugin_Loop($TBS, $p1, $tag_beg, $tag_end); // Search for all TBS tags and process them.
65+
$tag_lst = tbs_plugin_Loop($TBS, $p1, $tag_beg, $tag_end); // Search for all TBS tags and process them.
6766

68-
$text = tbs_plugin_EndTBS($TBS); // ends the merge.
67+
$text = tbs_plugin_EndTBS($TBS); // ends the merge.
6968

70-
unset($TBS);
71-
return true;
69+
unset($TBS);
70+
return true;
7271

7372
}
7473

@@ -77,16 +76,16 @@ function tbs_merge_node(&$text) {
7776
// Implements hook_menu() http://api.drupal.org/api/function/hook_menu
7877
// The menu is added in both "Home�Administer�Site configuration" and "Home�Administer�Site building�Administration by module"
7978
function tbs_menu() {
80-
$items = array();
81-
$items['admin/settings/tbs'] = array(
82-
'title' => 'TinyButStrong',
83-
'description' => 'Settings for the module: Dynamic Content with TinyButStrong Template Engine',
84-
'page callback' => 'drupal_get_form',
85-
'page arguments' => array('tbs_settings'),
86-
'access arguments' => array('access administration pages'),
87-
'type' => MENU_NORMAL_ITEM,
88-
);
89-
return $items;
79+
$items = array();
80+
$items['admin/settings/tbs'] = array(
81+
'title' => 'TinyButStrong',
82+
'description' => 'Settings for the module: Dynamic Content with TinyButStrong Template Engine',
83+
'page callback' => 'drupal_get_form',
84+
'page arguments' => array('tbs_settings'),
85+
'access arguments' => array('access administration pages'),
86+
'type' => MENU_NORMAL_ITEM,
87+
);
88+
return $items;
9089
}
9190

9291
// called defined by the hook onthisdate_menu().
@@ -124,16 +123,6 @@ function tbs_settings() {
124123
'#size' => 10,
125124
'#required' => false,
126125
);
127-
/*
128-
$form['tbs_option_AllowedIds'] = array(
129-
'#title' => t('Allowed nodes'),
130-
'#description' => t("Default value is empty ('') which mean none. Enter one or several id of nodes allowed to use plugin tags, separated them with comas (,). An error is prompted if a non-allowed article contains a plugin tag such as {tbs}. Set this parameter to limit the articles that Drupal authors can use plugin tags with. You can use '*' to allow all articles, but use this value carefully because if option Direct MergeBlock is also allowed then any Drupal author will be able to display the Drupal database."),
131-
'#default_value' => '',
132-
'#type' => 'textfield',
133-
'#size' => 30,
134-
'#required' => false,
135-
);
136-
*/
137126
$form['tbs_option_MergeBlock'] = array(
138127
'#title' => t('Direct MergeBlock'),
139128
'#description' => t("Allow plugin tags such as {tbs}mergeblock=...,sql=...,db=...{/tbs}."),
@@ -158,24 +147,6 @@ function tbs_settings() {
158147
'#size' => 60,
159148
'#required' => false,
160149
);
161-
$form['tbs_option_Embedded'] = array(
162-
'#title' => t('Embedded scripts'),
163-
'#description' => t("Allow plugin tags such as {tbs}embedded{/tbs}. Please note that those tags allow to run PHP scripts which is embedded inside an article."),
164-
'#default_value' => 'no',
165-
'#type' => 'select',
166-
'#options' => array('no'=>t('Forbidden'), 'all'=>t('Allowed')),
167-
'#required' => true,
168-
);
169-
/*
170-
$form['tbs_option_FullRightsIds'] = array(
171-
'#title' => t('Full rights nodes'),
172-
'#description' => t("Default value is empty. Ids of nodes which are allowed to use all plugin tags with all permissions. You can seperate Ids with a coma (,). You can use '*' to allow all nodes. You can use this parameter to let Admin users to use plugin tags for their own nodes."),
173-
'#default_value' => '',
174-
'#type' => 'textfield',
175-
'#size' => 30,
176-
'#required' => false,
177-
);
178-
*/
179150
// retrieve saved values for the HTML form
180151
$opt_lst = array_keys($form);
181152
foreach ($opt_lst as $opt) {

cms_drupal/tbs/tinybutstrong_comm.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/* Common functions for the TinyButStrong plugin, can feet to any CMS.
4-
Version 2009-12-14
4+
Version 2011-03-01
55
*/
66

77
function tbs_plugin_Loop(&$TBS, $p1, $tag_beg, $tag_end) {
@@ -12,7 +12,7 @@ function tbs_plugin_Loop(&$TBS, $p1, $tag_beg, $tag_end) {
1212
$p1 = strpos($TBS->Source, $tag_beg); // if the first position is not yet set, we found it
1313
if ($p1===false) return $tag_lst;
1414
}
15-
15+
1616
do {
1717

1818
$p2 = strpos($TBS->Source,$tag_end,$p1);
@@ -99,35 +99,6 @@ function tbs_plugin_Loop(&$TBS, $p1, $tag_beg, $tag_end) {
9999
}
100100
}
101101

102-
// Embedded script
103-
if (isset($prm['embedded'])) {
104-
// Check if this parameter is allowed
105-
if (!isset($Opt_Embedded)) $Opt_Embedded = tbs_plugin_GetOption('Embedded', 'no');
106-
if ($Opt_Embedded=='all') {
107-
$t1 = '<!--TBS';
108-
$t2 = '-->';
109-
$tp1 = -1;
110-
do {
111-
$tp1 = strpos($TBS->Source,$t1,$tp1+1);
112-
if ($tp1!==false) {
113-
$tp2 = strpos($TBS->Source,$t2,$tp1);
114-
if ($tp2===false) {
115-
tbs_plugin_AddError($TBS, "one tag '-->' is missing after '<!--TBS'.");
116-
$tp1 = false;
117-
} else {
118-
$script = substr($TBS->Source,$tp1+strlen($t1),$tp2-$tp1-strlen($t1));
119-
$script = trim($script);
120-
$TBS->Source = substr_replace($TBS->Source,'',$tp1,$tp2-$tp1+strlen($t2));
121-
tbs_plugin_LoadTemplate($TBS);
122-
eval($script);
123-
}
124-
}
125-
} while ($tp1!==false);
126-
} else {
127-
tbs_plugin_AddError($TBS, "parameter 'embedded' is not allowed. See plugin configuration.");
128-
}
129-
}
130-
131102
$p1 = strpos($TBS->Source,$tag_beg);
132103

133104
}

0 commit comments

Comments
 (0)