diff options
Diffstat (limited to 'mod/ecml/views/default/embed')
-rw-r--r-- | mod/ecml/views/default/embed/web_services/content.php | 220 |
1 files changed, 0 insertions, 220 deletions
diff --git a/mod/ecml/views/default/embed/web_services/content.php b/mod/ecml/views/default/embed/web_services/content.php deleted file mode 100644 index 9e7ffbbb4..000000000 --- a/mod/ecml/views/default/embed/web_services/content.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php -/** - * URL -> ECML converter for supported 3rd party services. - * - * Tries to automatically detect which site/ecml to use. - * Will highlight the correct one. - * If can find none, will show an error. - * Lets users click to force an ECML keyword, but will display a warning. - * - */ - -$internal_name = elgg_get_array_value('internal_name', $vars); - -$keywords = ecml_get_keywords(); -elgg_sort_3d_array_by_value($keywords, 'name'); - -$keyword_js_array = array(); -$keywords_html = "<ul class='ecml_web_service_list clearfix'>"; -// include support for standard ECML so you can get previews and validation. -//$keyword_html = '<li class="ecml_web_service"><a class="ecml">Generic ECML</a></li>'; - -foreach ($keywords as $i => $v) { - if (!isset($v['type']) || $v['type'] != 'web_service') { - unset ($keywords[$i]); - continue; - } - - // make sure the classname doens't have invalid chars. - $class = str_replace(array('.', ','), '_', $i); - $keyword_js_array[] = $class; - - $keywords_html .= "<li class='ecml_web_service'><a class=\"$class link\">{$v['name']}</a></li>"; -} - -$keywords_html .= "</ul>"; - -$keywords_js = json_encode($keyword_js_array); - -$input = elgg_view('input/text', array( - 'internalid' => 'web_services_resource' -)); - -$embed = elgg_view('input/submit', array( - 'name' => 'buggy', - 'internalid' => 'embed_submit', - 'type' => 'button', - 'value' => elgg_echo('embed:embed'), - 'class' => 'elgg-submit-button disabled', - 'disabled' => TRUE -)); - -echo '<p>' . elgg_echo('ecml:embed:instructions') . '</p>'; - -echo $keywords_html; - -echo "<div class='embed_content_section instructions hidden'><a class='ecml_embed_instructions link'>Instructions</a>"; -echo "<div id='embed_ecml_keyword_help' class='hidden'></div></div>"; - -echo "<div id='embed_service_url'><label>URL<br />".$input."<div id='url_status' class=''></div></label>"; -echo "<div class='ecml_generated_code hidden'>ECML: <span id='ecml_code'></span></div></div>"; - -echo "<div class='embed_content_section preview hidden'><a class='ecml_embed_preview link'>Preview</a>"; -echo "<div id='ecml_preview' class='hidden'></div></div>"; - -echo "<div class='divider margin-top'></div>"; -echo $embed; - -?> - -<script type="text/javascript"> - -$(document).ready(function() { - $('a.ecml_embed_instructions.link').click(function() { - elgg_slide_toggle($(this), '.embed_content_section.instructions', '#embed_ecml_keyword_help'); - $('.ecml_embed_instructions').toggleClass('open'); - }); - - $('a.ecml_embed_preview.link').click(function() { - elgg_slide_toggle($(this), '.embed_content_section.preview', '#ecml_preview'); - $('.ecml_embed_preview').toggleClass('open'); - }); -}); - -$(function() { - var keywords = <?php echo $keywords_js; ?>; - var selected_service = ''; - var manual_selected_service = false; - var embed_button = $('#embed_submit'); - var url_status = $('#url_status'); - var embed_resource_input = $('#web_services_resource'); - - // counter for paused input to try to validate/generate a preview. - var rest_timeout_id = null; - var rest_min_time = 750; - var embed_generate_ecml_url = '<?php echo elgg_get_site_url(); ?>pg/ecml_generate'; - var embed_ecml_keyword_help_url = '<?php echo elgg_get_site_url(); ?>pg/ecml/'; - var internal_name = '<?php echo addslashes($internal_name); ?>'; - - var web_services_ecml_update = function() { - if (rest_timeout_id) { - clearTimeout(rest_timeout_id); - } - - if (manual_selected_service) { - // fire off preview attempt - rest_timeout_id = setTimeout(generate_ecml, rest_min_time); - return true; - } - - var value = $(this).val(); - var value_length = value.length; - - if (value_length > 0) { - //embed_button.removeAttr('disabled').removeClass('disabled');//.addClass('embed_warning'); - url_status.removeClass('success').addClass('failure'); - } else { - embed_button.attr('disabled', 'disabled').addClass('disabled'); - url_status.removeClass('success').removeClass('failure'); - } - - if (value_length < 5) { - $('.ecml_web_service a').removeClass('selected'); - return true; - } - - // if this is ECML check that it's a valid keyword - if (value.substr(0, 1) == '[') { - var keyword = value.split(' ')[0]; - keyword = keyword.replace('[', ''); - keyword = keyword.replace(']', ''); - if ($.inArray(keyword, keywords) >= 0) { - select_service(keyword); - } - } else { - // check if any of the ECML keywords exist in the - // string and select that service. - $(keywords).each(function(index, keyword) { - if (value.indexOf(keyword) >= 0) { - select_service(keyword); - return true; - } - }); - } - - // fire off a preview attempt - if (selected_service) { - rest_timeout_id = setTimeout(generate_ecml, rest_min_time); - } - }; - - var select_service = function(service) { - if ($.inArray(service, keywords) === false) { - return false; - } - - selected_service = service; - $('.ecml_web_service a').removeClass('selected'); - $('.ecml_web_service a.' + service).addClass('selected'); - $('.embed_content_section.instructions').removeClass('hidden'); // reveal instructions link/panel - } - - // pings back core to generate the ecml. - // includes a status, ecml code, and the generated html. - var generate_ecml = function() { - if (!selected_service) { - return false; - } - - var resource = embed_resource_input.val(); - var post_data = {'service': selected_service, 'resource': resource}; - - $.post(embed_generate_ecml_url, post_data, function(data) { - if (data.status == 'success') { - // show previews and update embed code. - $('#ecml_preview').html(data.html); - $('#ecml_code').html(data.ecml); - $('body').data('elgg_embed_ecml', data.ecml); - $('.embed_content_section.preview').removeClass('hidden'); // reveal preview link/panel - $('.ecml_generated_code').removeClass('hidden'); // reveal ecml generated code - - // set status for embed button - embed_button.removeAttr('disabled').removeClass('disabled'); - url_status.removeClass('failure').addClass('success'); - } else { - // data failure - embed_button.attr('disabled', 'disabled').addClass('disabled'); - url_status.removeClass('success').removeClass('failure'); - } - }, 'json'); - } - - // auto guess the service. - embed_resource_input.keyup(web_services_ecml_update); - - // manually specify the service - $('.ecml_web_service a').click(function() { - select_service($(this).attr('class').split(' ')[0]); - manual_selected_service = true; - - // show tip - var help_url = embed_ecml_keyword_help_url + selected_service + '?ajax=true'; - $('#embed_ecml_keyword_help').load(help_url); - }); - - $('#embed_submit').click(function() { - // insert the ECML - // if the ECML input is empty, insert the resource. - if (!(content = $('body').data('elgg_embed_ecml'))) { - // @todo display an error? - content = embed_resource_input.val(); - } - - elggEmbedInsertContent(content, internal_name); - - return false; - }); -}); - - -</script>
\ No newline at end of file |