'."\n";
}
function canvas_create_plugin_form($zone,$position,$block_id,$block_type) {
if($block_type == 'plugin'){
echo '';
echo '';
}
}
function canvas_database_plugin($matches, $type = 'select', $variable_value, $where_cond = '') {
global $wpdb, $canvas;
$ALLOW_TABLES = array("sitecategories");
$content = '';
if(!isset($matches[3])) $matches[3] = $matches[2];
if ($where_cond != '') {
$where_cond = str_replace('%prefix%', $wpdb->prefix, $where_cond);
$where_cond = " WHERE " . $where_cond;
}
// We need to find out whether the table name requires user prefix or global prefix
$req_table_prefix = $wpdb->prefix;
if (!$wpdb->get_var("SHOW TABLES LIKE '".$req_table_prefix.$matches[1]."'") == $req_table_prefix.$matches[1]){
if (in_array($matches[1], $ALLOW_TABLES))
$req_table_prefix = (isset($wpdb->base_prefix)?$wpdb->base_prefix:$wpdb->prefix);
}
if($wpdb->get_var("SHOW TABLES LIKE '".$req_table_prefix.$matches[1]."'") == $req_table_prefix.$matches[1]) {
//echo(" SELECT ".$matches[2].", ".$matches[3]." FROM ".$req_table_prefix.$matches[1]." TBL ".$where_cond);
if($data = $wpdb->get_results("SELECT ".$matches[2].", ".$matches[3]." FROM ".$req_table_prefix.$matches[1]." TBL ".$where_cond)) {
foreach($data as $row) {
if($type == 'select') {
$content .= '\n";
} elseif($type == 'radio') {
$content .= '';
}
}
}
}
return $content;
}
/**
*
* @param $zone_name (String) The zone name
* @param $template_name (String) The name of the template to grab. The default value is "default".
* @param $template_size (Integer) Grabs the specified version of the template. The default value is MODULE_TEMPLATE_SIZE_SMALL. The value of $template_size could be
* - MODULE_TEMPLATE_SIZE_SMALL, MODULE_TEMPLATE_SIZE_MEDIUM, MODULE_TEMPLATE_SIZE_LARGE, or MODULE_TEMPLATE_SIZE_FULL.
* - The maximum width of the module that can be placed in this canvas.
* @param $allow_other_sizes (Boolean) If you tried to put a version of a module larger the zone version, and this value is set to True, it will just give a warning. Otherwise, it will give error. The default value is true.
* @param $default_module (String) This will bring up a certain module by default.
* @param $allow_other_modules (Boolean) If set to True, then the admin can put another module in the space. Otherwise, you shouldn’t be able to move the module. The default value is true.
* @param $styles (String) A string that will be printed in the style attribute of the canvas div.
**/
function canvas_define_zone($zone_name, $template_name = "default", $template_size = MODULE_TEMPLATE_SIZE_SMALL, $allow_other_sizes = TRUE, $default_module = '', $allow_other_modules = TRUE, $styles='') {
$parent='';
global $zones, $parents, $current_zones;
$current_zones[] = $zone_name;
if($_GET["template"] != '') $theme = $_GET["template"];
else $theme = get_option('template');
$parents[] = $parent;
$zones[] = $zone_name;
echo '
'."\n";
}
function canvas_execute_function($function_name, $block_id) {
global $wpdb, $canvas;
if($var_data = $wpdb->get_results("SELECT variable_name, value, type FROM ".$canvas->variables." WHERE parent = '$block_id'")) {
$url_string = '';
$vars = array();
if (!empty($var_data)) {
foreach($var_data as $var) {
$url_string .= '&'.$var->variable_name.'='.$var->value;
//if ($function_name)
// $vars[str_replace($function_name.'_', '', $var->variable_name)] = $var->value;
//else
switch($var->type){
case 'fileupload':
$vars[$var->variable_name] = FLUTTER_URI.'files_flutter/'.$var->value;
break;
default:
$vars[$var->variable_name] = $var->value;
}
}
$url_string = str_replace($function_name.'_', '', $url_string);
$url_string .= '&block_id='.$block_id;
}
$url_string = substr($url_string, 1);
if(is_callable($function_name)) $function_name($url_string, $vars);
}
return $vars;
}
function canvas_getNodeByAttr($attr, $nodeID, $xmldoc) {
if ($xmldoc->hasChildNodes()) {
$children = $xmldoc->childNodes;
foreach($children as $node) {
if($node->hasAttributes()) {
$attributes = $node->attributes;
foreach ($attributes as $attribute) {
if(($attribute->name == $attr) && (stripos($attribute->value, $nodeID)) !== false) {
return $node;
} else {
if(canvas_getNodeByAttr($attr,$nodeID,$node))
return canvas_getNodeByAttr($attr,$nodeID,$node);
}
}
} else {
if(canvas_getNodeByAttr($attr,$nodeID,$node))
return canvas_getNodeByAttr($attr,$nodeID,$node);
}
}
} else {
return null;
}
}
function canvas_head() {
global $installed, $canvas, $wpdb;
$load_default_modules = 0;
if($_GET["resetmods"]){
$wpdb->query("UPDATE ".$canvas->main." SET zone = 'shelf', template_name='', template_size=''");
$wpdb->query("UPDATE ".$canvas->variables." SET default_value = '__RESETDEFAULT__'");
echo '';
//wp_redirect("?page=FlutterEditCanvas&resetmodsmsg=1");
die();
}
if ($wpdb->get_results("SELECT block_id FROM ".$canvas->main." WHERE theme = '".get_option('template')."' AND zone <>'shelf'")) {
$load_default_modules = 0;
}
else{
$load_default_modules = 1;
}
if(isset($_GET["defaultmods"])) $load_default_modules = 1;
if($_GET["page"] == 'FlutterEditCanvas' || $_GET["page"] == 'FlutterInk') :
?>
/canvas.css" type="text/css" media="screen" />
Theme Not Supported
The theme you are currently using ('.$theme->title.' by '.$theme->author.') doesn\'t seem to support Canvas. At this point in the game, Canvas only supports themes that are built to run with the Canvas layout and styling system. To use Canvas, you\'ll have to either select a different theme from your collection.
Although your current theme isn\'t compatible, you do have some Canvas compatible themes available. Select a theme from the listing below to edit an inactive theme.
'."\n";
foreach($canvas_themes as $theme) {
$link = 'themes.php?page=Main.php&template='.$theme['template'];
echo '
'."\n";
}
}
echo ''."\n";
}
function canvas_show_zone_options($zone, $theme) {
$content_position = canvas_zone_handler($zone);
if(true) {return; $display = ' style="display: none;"'; $toggle_style = ' style="background-color: #cfcfcf;"'; }
else { $display = ''; $toggle_style = ''; }
$content = ''."\n";
$content .= ''."\n";
$content .= ''."\n";
$content .= '';
$content .= '';
$content .= '';
$content .= ''."\n";
if($content_position != '') $content = str_replace($content_position.'_up', $content_position.'_down', $content);
$content = str_replace('value="'.$content_position.'"', 'value="'.$content_position.'" selected="selected"', $content);
echo $content;
}
function mod_var($var_name){
global $mod_vars;
//return $mod_vars[$function_name][$var_name];
return $mod_vars[$var_name];
}
/**
* Used inside any theme file in order to display a canvas whenever this page is displayed.
*
**/
function canvas_zone($zone_name) {
global $wpdb, $canvas;
if($zone_data = $wpdb->get_results("SELECT module_id, block_id, path, type, position, zone, template_name, template_size FROM ".$canvas->main." WHERE zone = '$zone_name' AND theme = '".get_option('template')."' ORDER BY position")) {
foreach($zone_data as $zone) {
// Get module name
include_once('RCCWP_CustomWriteModule.php');
$customWriteModule = RCCWP_CustomWriteModule::Get($zone->module_id);
$zone->module_name = $customWriteModule->name;
$dir = get_module_template_folder($zone->module_name, $zone->template_name, $zone->template_size);
global $mod_vars;
$mod_vars = canvas_execute_function($zone->path, $zone->block_id);
if (!file_exists($dir.'default.php')) return;
include($dir.'default.php');
}
}
}
/**
* Used inside any theme file in order to grab the specified module directly without the need to define it in the canvas.php.
*
* @param $module_name (String) The zone name
* @param $template_name (String) The name of the template to grab. The default value is "default".
* @param $template_size (Integer) Grabs the specified version of the template. The default value is "small".
**/
function get_module($module_name, $template_name = "default", $template_size = MODULE_TEMPLATE_SIZE_SMALL) {
global $wpdb, $canvas;
// Load variables
global $mod_vars;
include_once("RCCWP_CustomWriteModule.php");
$mod = RCCWP_CustomWriteModule::GetByName($module_name);
$mod_vars = canvas_execute_function('', $mod->id);
// Load template file
$dir = get_module_template_folder($module_name, $template_name, $template_size) ;
if (!file_exists($dir.'default.php')) return;
include($dir.'default.php');
}
function get_module_template_folder($module_name, $template_name, $template_size) {
switch($template_size){
case MODULE_TEMPLATE_SIZE_SMALL:
$template_size = "small";
break;
case MODULE_TEMPLATE_SIZE_MEDIUM:
$template_size = "medium";
break;
case MODULE_TEMPLATE_SIZE_LARGE:
$template_size = "large";
break;
case MODULE_TEMPLATE_SIZE_FULL:
$template_size = "full";
break;
}
if (empty($template_size))
$template_size = "small";
if (empty($template_name))
$template_name = "default";
return CANVASPATH.'/modules/'.$module_name.'/templates/'.$template_name.'/'.$template_size.'/' ;
}
function canvas_zone_handler($zone) {
global $wpdb, $canvas;
$position = $wpdb->get_var("SELECT value FROM ".$canvas->zone_options." WHERE option_name = 'zone_handler' AND zone = '$zone' AND theme = '".get_option('template')."'");
if($position != '') return $position;
else return 'before';
}
function get_canvas_draggables($zone, $theme = '') {
include_once('RCCWP_Options.php');
if (isset($_GET['t_page']))
$curr_page = $_GET['t_page'];
else
$curr_page = 'home'; // Attempt to find the main page
if(RCCWP_Options::Get('canvas_show_zone_name') && $zone != 'shelf') echo ''.$zone.'';
if($zone != 'shelf') canvas_show_zone_options($zone, $theme);
if($theme == '') $theme = get_option('template');
global $wpdb, $canvas;
if($wpdb->get_var("SHOW TABLES LIKE '".$canvas->main."'") == $canvas->main)
$results = $wpdb->get_results("SELECT * FROM ".$canvas->main." WHERE theme = '$theme' AND page='$curr_page' AND zone LIKE '$zone' ORDER BY position");
if ($results) {
foreach($results as $result) {
// Get module name
include_once('RCCWP_CustomWriteModule.php');
$customWriteModule = RCCWP_CustomWriteModule::Get($result->module_id);
$result->module_name = $customWriteModule->name;
$result->description = $customWriteModule->description;
if ($result->duplicate_id ==0 )
$result->module_title = $customWriteModule->name;
else
$result->module_title = $wpdb->get_var("SELECT duplicate_name FROM ".$canvas->duplicates." WHERE duplicate_id = ".$result->duplicate_id);
canvas_create_draggable($result->block_id, $zone, $result->position, $result->module_name, $result->module_title, '