foreach ($tags as $tag) { /* Yura: I have added "utf8_strtolower()" below in condition in order to: * When we enter new tag 'testA' and the tag 'testa' already exists * then we suggest only 'testa' instead of 'testA'. */ if (utf8_strtolower($tag['title']) == utf8_strtolower($term)) { // Current term is an existing tag $term_is_new_tag = false; } } } if ($term_is_new_tag && !empty($term)) { // Add current term in the beginning of the tags list array_unshift($tags, array('id' => $term, 'title' => $term)); } echo evo_json_encode($tags); exit(0); case 'crop': // Get form to crop profile picture if (!is_logged_in()) { // Only the logged in user can crop pictures break; } $file_ID = param('file_ID', 'integer'); $cropped_File =& $current_User->get_File_by_ID($file_ID, $error_code); if (!$cropped_File) { // Wrong file for cropping break; } $BlogCache =& get_BlogCache(); $Blog =& $BlogCache->get_by_ID($blog_ID, true);
function out_echo($message, $specialchars) { $message['text'] = base64_encode($message['text']); if ($specialchars == 1) { $message['specialchars'] = 1; echo htmlspecialchars(evo_json_encode(array('success' => $message))); } else { $message['specialchars'] = 0; echo evo_json_encode(array('success' => $message)); } }
// User link with full path to file $FileCache =& get_FileCache(); $new_File =& $FileCache->get_by_root_and_path($fileroot_type, $fileroot_type_ID, trailing_slash($path) . $newfile, true); $old_File =& $FileCache->get_by_root_and_path($fileroot_type, $fileroot_type_ID, trailing_slash($path) . $oldfile, true); $data['new'] = $new_File->get_view_link(); $data['old'] = $old_File->get_view_link(); } else { // Simple text format $data['new'] = $newfile; $data['old'] = $oldfile; } if ($result !== true) { // Send an error if it was created during the replacing $data['error'] = $result; } echo evo_json_encode($data); exit(0); case 'link_attachment': // The content for popup window to link the files to the items/comments // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('link'); // Check permission: $current_User->check_perm('files', 'view'); param('iframe_name', 'string', ''); param('link_owner_type', 'string', true); param('link_owner_ID', 'integer', true); // Additional params, Used to highlight file/folder param('root', 'string', ''); param('path', 'string', ''); param('fm_highlight', 'string', ''); $additional_params = empty($root) ? '' : '&root=' . $root;
/** * Display a form (like comment or contact form) through an ajax call * * @param array params */ function display_ajax_form($params) { global $rsc_uri, $samedomain_htsrv_url, $ajax_form_number; if (is_recursive($params)) { // The params array contains recursion, don't try to encode, display error message instead // We don't use translation because this situation should not really happen ( Probably it happesn with some wrong skin ) echo '<p style="color:red;font-weight:bold">' . T_('This section can\'t be displayed because wrong params were created by the skin.') . '</p>'; return; } if (empty($ajax_form_number)) { // Set number for ajax form to use unique ID for each new form $ajax_form_number = 0; } $ajax_form_number++; echo '<div id="ajax_form_number_' . $ajax_form_number . '" class="section_requires_javascript">'; // Needs json_encode function to create json type params $json_params = evo_json_encode($params); $ajax_loader = "<p class='ajax-loader'><img src='" . $rsc_uri . "img/ajax-loader2.gif' /><br />" . T_('Form is loading...') . "</p>"; ?> <script type="text/javascript"> // display loader gif until the ajax call returns document.write( <?php echo '"' . $ajax_loader . '"'; ?> ); var ajax_form_offset_<?php echo $ajax_form_number; ?> = jQuery('#ajax_form_number_<?php echo $ajax_form_number; ?> ').offset().top; var request_sent_<?php echo $ajax_form_number; ?> = false; function get_form_<?php echo $ajax_form_number; ?> () { jQuery.ajax({ url: '<?php echo $samedomain_htsrv_url; ?> anon_async.php', type: 'POST', data: <?php echo $json_params; ?> , success: function(result) { jQuery('#ajax_form_number_<?php echo $ajax_form_number; ?> ').html( ajax_debug_clear( result ) ); } }); } function check_and_show_<?php echo $ajax_form_number; ?> () { var window_scrollTop = jQuery(window).scrollTop(); var window_height = jQuery(window).height(); // check if the ajax form is visible, or if it will be visible soon ( 20 pixel ) if( window_scrollTop >= ajax_form_offset_<?php echo $ajax_form_number; ?> - window_height - 20 ) { if( !request_sent_<?php echo $ajax_form_number; ?> ) { request_sent_<?php echo $ajax_form_number; ?> = true; // get the form get_form_<?php echo $ajax_form_number; ?> (); } } } jQuery(window).scroll(function() { check_and_show_<?php echo $ajax_form_number; ?> (); }); jQuery(document).ready( function() { check_and_show_<?php echo $ajax_form_number; ?> (); }); jQuery(window).resize( function() { check_and_show_<?php echo $ajax_form_number; ?> (); }); </script> <noscript> <?php echo '<p>' . T_('This section can only be displayed by javascript enabled browsers.') . '</p>'; ?> </noscript> <?php echo '</div>'; }
/** * Output Javascript for tags autocompletion. * @todo dh> a more facebook like widget would be: http://plugins.jquery.com/project/facelist * "ListBuilder" is being planned for jQuery UI: http://wiki.jqueryui.com/ListBuilder * * @param array Tags */ function echo_autocomplete_tags($tags = array()) { global $htsrv_url; // Initialize an array to pre-fill the tags input $prefilled_tags = array(); if (!empty($tags)) { foreach ($tags as $tag_name) { $prefilled_tags[] = array('id' => $tag_name, 'title' => $tag_name); } } //echo <<<EOD ?> <script type="text/javascript"> (function($){ jQuery(function() { jQuery( '#item_tags' ).tokenInput( '<?php echo $htsrv_url . 'async.php?action=get_tags'; ?> ', { theme: 'facebook', queryParam: 'term', propertyToSearch: 'title', tokenValue: 'title', preventDuplicates: true, prePopulate: <?php echo evo_json_encode($prefilled_tags); ?> , hintText: '<?php echo TS_('Type in a tag'); ?> ', noResultsText: '<?php echo TS_('No results'); ?> ', searchingText: '<?php echo TS_('Searching...'); ?> ' } ); }); })(jQuery); </script> <?php //EOD; }
param('term', 'string'); // Clear users cache and load only possible recipients who need right now, but keep shadow $where_condition = '( user_login LIKE ' . $DB->quote('%' . $term . '%') . ' ) AND ( user_ID != ' . $DB->quote($current_User->ID) . ' )'; $UserCache =& get_UserCache(); $UserCache->clear(true); $UserCache->load_where($where_condition); $result_users = array(); while (($iterator_User =& $UserCache->get_next()) != NULL) { // Iterate through UserCache if (!$iterator_User->check_status('can_receive_pm')) { // this user is probably closed so don't show it continue; } $result_users[] = array('id' => $iterator_User->ID, 'title' => $iterator_User->get('login'), 'fullname' => $iterator_User->get('fullname'), 'picture' => $iterator_User->get_avatar_imgtag('crop-top-32x32')); } echo evo_json_encode($result_users); exit(0); case 'moderate_comment': // Used for quick moderation of comments in front-office // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('comment'); if (!is_logged_in()) { // Only logged in users can moderate comments break; } // Check comment moderate permission below after we have the $edited_Comment object $blog = param('blogid', 'integer'); $status = param('status', 'string'); $edited_Comment =& Comment_get_by_ID(param('commentid', 'integer'), false); if ($edited_Comment !== false) { // The comment still exists
{ check_multiple_recipients(); } ); jQuery( '#thrd_recipients' ).tokenInput( '<?php echo get_samedomain_htsrv_url(); ?> anon_async.php?action=get_recipients', { theme: 'facebook', queryParam: 'term', propertyToSearch: 'title', preventDuplicates: true, prePopulate: <?php echo evo_json_encode($recipients_selected); ?> , hintText: '<?php echo TS_('Type in a username'); ?> ', noResultsText: '<?php echo TS_('No results'); ?> ', searchingText: '<?php echo TS_('Searching...'); ?> ', tokenFormatter: function( item )
echo '<a href="' . $lost_password_url . '">' . $Widget->get_param('password_link') . '</a>'; } $Form->end_fieldset(); $Form->end_form(); // Display only button to login if JS scripts or AJAX forms are disabled echo $ajax_form_enabled ? '<noscript>' : ''; echo get_user_login_link('<br /><strong>', '</strong><br /><br />', T_('Login now...'), '#', $source, $redirect_to); echo $ajax_form_enabled ? '</noscript>' : ''; if ($Widget && $Widget->get_param('register_link_show')) { // Display a link to register echo get_user_register_link('<span class="register_link">', '</span>', $Widget->get_param('register_link'), '#', true, $redirect_to, $source); } if ($ajax_form_enabled) { // create javascripts to handle login form crumb and password salt global $samedomain_htsrv_url; $json_params = evo_json_encode(array('action' => 'get_widget_login_hidden_fields')); ?> <script type="text/javascript"> // Show login form when JS scripts and AJAX forms are enabled jQuery( 'form#login_form' ).show(); var requestSent = false; var requestSucceed = false; var submitFormIfRequestSucceed = false; var sessionID = 0; // Calculate hashed password and set it in the form function setPwdHashed() { var form = document.forms['login_form']; form.pwd_hashed.value = hex_sha1( hex_md5(form.<?php echo $dummy_fields['pwd'];
/** * Event handler: Called when displaying item attachment. * * @param array Associative array of parameters. $params['File'] - attachment, $params['data'] - output * @param boolean TRUE - when render in comments * @return boolean true if plugin rendered this attachment */ function RenderItemAttachment(&$params, $in_comments = false) { $File = $params['File']; if (!$this->is_flp_video($File)) { return false; } if ($File->exists()) { /** * @var integer A number to assign each video player new id attribute */ global $html5_videojs_number; $html5_videojs_number++; if ($in_comments) { $params['data'] .= '<div style="clear: both; height: 0px; font-size: 0px"></div>'; } /** * Video options: * * controls: true // The controls option sets whether or not the player has controls that the user can interact with. * autoplay: true // If autoplay is true, the video will start playing as soon as page is loaded (without any interaction from the user). NOT SUPPORTED BY APPLE iOS DEVICES * preload: 'auto'|'metadata'|'none' // The preload attribute informs the browser whether or not the video data should begin downloading as soon as the video tag is loaded. * poster: 'myPoster.jpg' // The poster attribute sets the image that displays before the video begins playing. * loop: true // The loop attribute causes the video to start over as soon as it ends. */ $video_options = array(); $video_options['controls'] = true; $video_options['preload'] = 'auto'; $params['data'] .= '<video id="html5_videojs_' . $html5_videojs_number . '" class="video-js ' . $this->Settings->get('skin') . '" data-setup=\'' . evo_json_encode($video_options) . '\'>' . '<source src="' . $File->get_url() . '" type="' . $this->get_video_mimetype($File) . '" />' . '</video>'; if ($this->Settings->get('allow_download')) { // Allow to download the video files $params['data'] .= '<div class="small center"><a href="' . $File->get_url() . '">' . T_('Download this video') . '</a></div>'; } return true; } return false; }