function cashmusic_shortcode($attributes) { extract(shortcode_atts(array('element' => false, 'name' => false), $attributes)); if ($element) { CASHSystem::embedElement($element); } else { echo '<!-- CASH Music error: no such element found -->'; } }
<body> <div id="mainspc"> <img src="assets/images/funzone.png" width="160" height="77" id="titleimg" /> <span id="navtitle"> MGMT<b>FUNZONE</b></span> <div id="navmenu"> <a href="#">NEWS</a><a href="#">EVENTS</a><a href="#" class="selected">TICKETS</a><a href="#">MERCH</a><a href="#">PHOTOS</a><a href="#">MUSIC+VIDEO</a><a href="#">SHOW ARCHIVE</a> </div> <?php CASHSystem::embedElement(106); // CASH element (Dandy's e-card test / ecard) ?> It's working. Here's a sample element:<br /> <?php CASHSystem::embedElement(107); // CASH element (Front page news box) ?> <?php CASHSystem::embedElement(106); // CASH element (Dandy's e-card test / ecard) ?> </div> <?php include '../../../../framework/php/settings/debug/cashmusic_debug.php'; // Debug ?> </body> </html>
$embed_location = $requests[3]; $embed_location = str_replace('!slash!', '/', $embed_location); // dumb. supporting old versions. } if (isset($_GET['location'])) { $embed_location = $_GET['location']; } if (isset($_GET['geo'])) { $embed_geo = $_GET['geo']; } $template_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getelementtemplate', 'element_id' => $requests[1], 'return_template' => 1)); $template = $template_request->response['payload']; $embed_data = array(); $element_markup = false; ob_start(); CASHSystem::embedElement($requests[1], 'embed', $embed_location, $embed_geo); $embed_data['element_markup'] = ob_get_contents(); $embed_data['cdn_url'] = defined('CDN_URL') ? CDN_URL : CASH_ADMIN_URL; ob_end_clean(); header('Content-Type: text/html; charset=utf-8'); $template = str_replace('</head>', '<script type="text/javascript" src="' . CASH_PUBLIC_URL . '/cashmusic.js"></script></head>', $template); $encoded_html = $freddiemercury->render($template, $embed_data); echo $encoded_html; } else { if ($initial_page_request) { if (in_array('payload', $requests)) { $output = $initial_page_request['response']['payload']; } else { $output = array('response' => $initial_page_request['response']); } } else {
$template_id = false; } $template = false; if ($template_id) { $template_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'gettemplate', 'template_id' => $template_id, 'user_id' => $user_id)); $template = $template_request->response['payload']; } // with a real user but no template we redirect to the admin if ($template) { $element_embeds = false; // i know we don't technically need this, but the immaculate variable in preg_match_all freaks me out $found_elements = preg_match_all('/{{{element_(.*?)}}}/', $template, $element_embeds, PREG_PATTERN_ORDER); if ($found_elements) { foreach ($element_embeds[1] as $element_id) { ob_start(); CASHSystem::embedElement($element_id); $page_vars['element_' . $element_id] = ob_get_contents(); ob_end_clean(); } } // render out the page itself echo CASHSystem::renderMustache($template, $page_vars); exit; } else { // redirect to the admin header('Location: ./admin/'); } } /*************************************** * * ADD PUBLIC PAGE BELOW CLOSING "?>"
function test_embedElement() { $element_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addelement', 'name' => 'test', 'type' => 'staticcontent', 'options_data' => array('storedcotent' => 'basic text'), 'user_id' => 1)); // should have failed with just a title: $element_id = $element_request->response['payload']; $this->assertTrue(is_numeric($element_id)); if ($element_id) { ob_start(); CASHSystem::embedElement($element_id); $output = ob_get_clean(); $this->assertPattern('/basic text/', $output); } }
<?php include '../../../../framework/php/cashmusic.php'; // Initialize CASH Music ?> <!DOCTYPE html> <head> <title>Sandbox / CASH Music</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="assets/css/demo.css" rel="stylesheet" type="text/css" /> <link rel="icon" type="image/png" href="http://cashmusic.org/images/icons/cash.png" /> </head> <body> <div id="mainspc"> <?php CASHSystem::embedElement(112); ?> </div> <?php include '../../../../framework/php/settings/debug/cashmusic_debug.php'; // Debug ?> </body> </html>