Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
forena
Commits
1f111deb
Commit
1f111deb
authored
Jul 07, 2012
by
metzlerd
Browse files
Added ability to render themed drupal nodes based on select queries.
parent
8b8640ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
forena.module
View file @
1f111deb
...
...
@@ -570,6 +570,11 @@ function forena_forena_controls() {
'file'
=>
'plugins/FrxControls.inc'
,
'class'
=>
'FrxControls'
,
);
$controls
[]
=
array
(
'file'
=>
'plugins/FrxDrupalControls.inc'
,
'class'
=>
'FrxDrupalControls'
,
);
$controls
[]
=
array
(
'file'
=>
'plugins/FrxSource.inc'
,
'class'
=>
'FrxSource'
,
...
...
plugins/FrxDrupal.inc
View file @
1f111deb
...
...
@@ -101,37 +101,6 @@ class FrxDrupal extends FrxDataProvider {
return
$value
;
}
/**
* @section
* Formatters
* Below here are formatting types
*/
public
function
formats
()
{
$formats
=
array
(
'drupal_filter'
=>
'Drupal Input Filter'
);
return
$formats
;
}
public
function
drupal_filter
(
$nid
,
$format
)
{
$node
=
node_load
(
$nid
,
NULL
,
TRUE
);
if
(
!
$node
)
{
return
'N/A'
;
}
if
((
strcasecmp
(
$format
,
'teaser'
)
==
0
)
||
(
!
$format
))
{
$bool
=
TRUE
;
}
else
{
$bool
=
FALSE
;
}
//If true, render the teaser
//else render the body
$node
=
node_prepare
(
$node
,
$bool
);
if
(
$bool
)
{
return
$node
->
teaser
;
}
return
$node
->
body
;
}
}
...
...
plugins/FrxDrupalControls.inc
0 → 100644
View file @
1f111deb
<?php
// $Id$
/**
* @file
* Provides data blocks for native drupal connections using the default
* drupal connections.
*
*/
class
FrxDrupalControls
{
/**
* Implement custom SQL formatter to make sure that strings are properly escaped.
* Ideally we'd replace this with something that handles prepared statements, but it
* wouldn't work for
*
* @param unknown_type $value
* @param unknown_type $key
* @param unknown_type $data
*/
public
function
format
(
$value
,
$key
,
$data
)
{
$db
=
Database
::
getConnection
(
'default'
);
if
(
$db
)
{
if
(
$value
==
''
)
$value
=
'NULL'
;
else
{
if
(
is_array
(
$value
))
{
if
(
$value
==
array
())
{
$value
=
'NULL'
;
}
else
{
// Build a array of values string
$i
=
0
;
$val
=
''
;
foreach
(
$value
as
$v
)
{
$i
++
;
if
(
$i
>
1
)
{
$val
.
=
','
;
}
$val
.
=
$db
->
quote
(
$v
);
}
$value
=
$val
;
}
}
else
{
$value
=
trim
(
$value
);
$value
=
$db
->
quote
(
$value
)
;
}
}
}
return
$value
;
}
/**
* @section
* Formatters
* Below here are formatting types
*/
public
function
formats
()
{
$formats
=
array
(
'drupal_node_content'
=>
'Content from node id'
);
return
$formats
;
}
public
function
drupal_node_content
(
$nid
,
$format
)
{
$nid
=
@
(
int
)
$nid
;
$node
=
@
node_load
(
$nid
,
NULL
,
TRUE
);
if
(
!
$node
)
{
return
''
;
}
if
((
strcasecmp
(
$format
,
'teaser'
)
===
0
)
||
(
!
$format
))
{
$format
=
'teaser'
;
}
else
{
$format
=
'full'
;
}
//If true, render the teaser
//else render the body
$output
=
theme
(
'node'
,
node_view
(
$node
,
$format
));
return
print_r
(
$output
,
1
)
;
}
}
repos/drupal/published_content_by_type.sql
0 → 100644
View file @
1f111deb
--ACCESS=access content
SELECT
nid
,
type
,
title
,
uid
,
sticky
,
promote
from
node
WHERE
type
=
:
content_type
and
status
=
1
ORDER
BY
title
LIMIT
COALESCE
(
CAST
(:
limit
AS
integer
),
10
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment