<?php // Set defaults $_image_id = !empty($image_id) ? $image_id : ''; $_scaling = !empty($scaling) ? $scaling : ''; $_width = !empty($width) ? $width : ''; $_height = !empty($height) ? $height : ''; $_linking = !empty($linking) ? $linking : ''; $_url = !empty($url) ? $url : ''; $_target = !empty($target) ? $target : ''; $_link_attr = !empty($link_attr) ? $link_attr : ''; $_img_attr = !empty($img_attr) ? $img_attr : ''; if ($_image_id) { // Determine image URL if ($_scaling == 'CROP' && $_width && $_height) { $_img_url = cdn_thumb($_image_id, $_width, $_height); } elseif ($_scaling == 'SCLAE' && $_width && $_height) { $_img_url = cdn_scale($_image_id, $_width, $_height); } else { $_img_url = cdn_serve($_image_id); } // -------------------------------------------------------------------------- // Determine linking if ($_linking == 'CUSTOM' && $_url) { $_link_url = $_url; $_link_target = $_target ? 'target="' . $_target . '"' : ''; } elseif ($_linking == 'FULLSIZE') { $_link_url = cdn_serve($_image_id); $_link_target = $_target ? 'target="' . $_target . '"' : ''; } else { $_link_url = '';
</li> </ul> <ul class="right shaded"> <li> <?php echo anchor('', lang('admin_switch_frontend')); ?> </li> <li style="color:#999;"> <?php // Logged in as $_link = anchor('admin/accounts/edit/' . active_user('id'), active_user('first_name'), 'class="fancybox" data-fancybox-type="iframe"'); echo lang('admin_loggedin_as', $_link); if (active_user('profile_img')) { echo img(array('src' => cdn_thumb(active_user('profile_img'), 16, 16), 'class' => 'avatar')); } // -------------------------------------------------------------------------- $_admin_recovery = $this->session->userdata('admin_recovery'); if ($this->session->userdata('admin_recovery')) { echo lang('admin_admin_recover', array(site_url('auth/override/login_as/' . $_admin_recovery->id . '/' . $_admin_recovery->hash), $_admin_recovery->name)); } ?> </li> <li class="logout"> <?php echo anchor('auth/logout', lang('action_logout')); ?> </li> </ul>
<?php if (isset($object_id)) { echo '<li class="gallery-item">'; echo img(cdn_thumb($object_id, 100, 100)); echo '<a href="#" class="delete" data-object_id="' . $object_id . '"></a>'; echo form_hidden('gallery[]', $object_id); echo '</li>'; } else { echo '<li class="gallery-item crunching">'; echo '<div class="crunching"></div>'; echo form_hidden('gallery[]'); echo '</li>'; }
<tr> <td class="id"><?php echo number_format($member->id); ?> </td> <td class="details"> <?php if ($member->profile_img) { echo anchor(cdn_serve($member->profile_img), img(array('src' => cdn_thumb($member->profile_img, 65, 65), 'class' => 'profile-img')), 'class="fancybox"'); } else { switch ($member->gender) { case 'female': echo img(array('src' => cdn_blank_avatar(65, 65, 'female'), 'class' => 'profile-img')); break; default: echo img(array('src' => cdn_blank_avatar(65, 65, 'male'), 'class' => 'profile-img')); break; } } echo '<div>'; switch ($this->input->get('sort')) { case 'u.last_name': echo '<strong>' . $member->last_name . ', ' . $member->first_name . '</strong>'; break; default: echo '<strong>' . $member->first_name . ' ' . $member->last_name . '</strong>'; break; } echo '<small>'; echo $member->email; echo $member->email_is_verified ? img(array('src' => NAILS_ASSETS_URL . '/img/admin/icons/verified-email.png', 'class' => 'verified', 'rel' => 'tooltip', 'title' => lang('accounts_index_verified'))) : '';
function form_field_multiimage($field, $help = '') { // Set var defaults $_field_id = isset($field['id']) ? $field['id'] : NULL; $_field_type = isset($field['type']) ? $field['type'] : 'text'; $_field_oddeven = isset($field['oddeven']) ? $field['oddeven'] : NULL; $_field_key = isset($field['key']) ? $field['key'] : NULL; $_field_label = isset($field['label']) ? $field['label'] : NULL; $_field_default = isset($field['default']) ? $field['default'] : NULL; $_field_sub_label = isset($field['sub_label']) ? $field['sub_label'] : NULL; $_field_required = isset($field['required']) ? $field['required'] : FALSE; $_field_placeholder = isset($field['placeholder']) ? $field['placeholder'] : NULL; $_field_readonly = isset($field['readonly']) ? $field['readonly'] : FALSE; $_field_error = isset($field['error']) ? $field['error'] : FALSE; $_field_bucket = isset($field['bucket']) ? $field['bucket'] : FALSE; $_field_class = isset($field['class']) ? $field['class'] : FALSE; $_help = array(); $_help['src'] = is_array($help) && isset($help['src']) ? $help['src'] : NAILS_ASSETS_URL . 'img/form/help.png'; $_help['class'] = is_array($help) && isset($help['class']) ? $help['class'] : 'help'; $_help['rel'] = is_array($help) && isset($help['rel']) ? $help['rel'] : 'tipsy-left'; $_help['title'] = is_array($help) && isset($help['title']) ? $help['title'] : NULL; $_help['title'] = is_string($help) ? $help : $_help['title']; $_error = form_error($_field_key) || $_field_error ? 'error' : ''; $_error_class = $_error ? 'error' : ''; $_readonly = $_field_readonly ? 'readonly="readonly"' : ''; $_readonly_cls = $_field_readonly ? 'readonly' : ''; // -------------------------------------------------------------------------- // Generate a unique ID for this field $_id = 'field_multiimage_' . md5(microtime()); // -------------------------------------------------------------------------- // Sanitize the key $_field_key .= substr($_field_key, -2) != '[]' ? '[]' : ''; // -------------------------------------------------------------------------- // Is the label required? $_field_label .= $_field_required ? '*' : ''; // Prep sublabel $_field_sub_label = $_field_sub_label ? '<small>' . $_field_sub_label . '</small>' : ''; // -------------------------------------------------------------------------- // Set the defaults $_field_default = set_value($_field_key, $_field_default); $_default_html = ''; // Render any defaults if (is_array($_field_default)) { foreach ($_field_default as $file) { $_default_html .= '<li class="item">'; $_default_html .= '<a href="#" class="delete" data-object_id="' . $file . '"></a>'; $_default_html .= img(cdn_thumb($file, 92, 92)); $_default_html .= form_hidden($_field_key, $file); $_default_html .= '</li>'; } } // -------------------------------------------------------------------------- // Error if ($_error && $_field_error) { $_error = '<span class="error">' . $_field_error . '</span>'; } elseif ($_error) { $_error = form_error($_field_key, '<span class="error">', '</span>'); } // -------------------------------------------------------------------------- // Tip $_tip = $_help['title'] ? img($_help) : ''; $_filelist_class = $_help['title'] ? 'has-tip ' : ''; // -------------------------------------------------------------------------- // Quick script to instantiate the field, not indented due to heredoc syntax get_instance()->load->library('cdn'); $_movie_url = NAILS_ASSETS_URL . 'swf/jquery.uploadify/uploadify.swf'; $_upload_url = site_url('api/cdnapi/object_create/script.php', page_is_secure()); $_upload_token = get_instance()->cdn->generate_api_upload_token(); $_bucket = $_field_bucket; $_out = <<<EOT \t<div class="field multiimage {$_error_class} {$_field_oddeven} {$_readonly_cls} {$_field_type}" id="{$_id}"> \t\t<label> \t\t\t<span class="label"> \t\t\t\t{$_field_label} \t\t\t\t{$_field_sub_label} \t\t\t</span> \t\t\t<span class="input"> \t\t\t\t<p class="system-alert error" id="{$_id}-uploadify-not-available"> \t\t\t\t\t<strong>Configuration Error.</strong> Uploadify is not available. \t\t\t\t</p> \t\t\t\t<span id="{$_id}-uploadify-available" style="display:none;"> \t\t\t\t\t<ul id="{$_id}-filelist" class="filelist empty"> \t\t\t\t\t\t{$_default_html} \t\t\t\t\t\t<li class="empty">No Images, add some now.</li> \t\t\t\t\t</ul> \t\t\t\t\t<button id="{$_id}-uploadify">Choose Images</button> \t\t\t\t</span> \t\t\t\t{$_error} \t\t\t<span> \t\t</label> \t</div> \t<script type="text/template" id="{$_id}-template-uploadify"> \t\t<li class="item uploadify-queue-item" id="{$_id}-\${fileID}" data-instance_id="\${instanceID}" data-file_id="\${fileID}"> \t\t\t<a href="#" data-instance_id="\${instanceID}" data-file_id="\${fileID}" class="remove"></a> \t\t\t<div class="progress" style="height:0%"></div> \t\t\t<div class="data data-cancel">CANCELLED</div> \t\t</li> \t</script> \t<script type="text/template" id="{$_id}-template-item"> \t\t<li class="item crunching"> \t\t\t<div class="crunching"></div> \t\t\t<input type="hidden" name="{$_field_key}" /> \t\t</li> \t</script> \t<div id="{$_id}-dialog-confirm-delete" title="Confirm Delete" style="display:none;"> \t\t<p> \t\t\t<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 0 0;"></span> \t\t\tThis item will be removed from the interface and cannot be recovered. \t\t\t<strong>Are you sure?</strong> \t\t</p> \t</div> \t<script type="text/javascript"> \tif ( typeof( \$.fn.uploadify ) === 'function' ) \t{ \t\t\$( '#{$_id}-uploadify-not-available' ).hide(); \t\t\$( '#{$_id}-uploadify-available' ).show(); \t\t// -------------------------------------------------------------------------- \t\t\$( '#{$_id}-uploadify' ).uploadify( \t\t{ \t\t\t'debug': false, \t\t\t'auto': true, \t\t\t'swf': '{$_movie_url}', \t\t\t'buttonText':'Add Images', \t\t\t'uploader': '{$_upload_url}', \t\t\t'fileObjName': 'upload', \t\t\t'fileTypeExts': '*.gif; *.jpg; *.jpeg; *.png', \t\t\t'queueID': '{$_id}-filelist', \t\t\t'formData': \t\t\t{ \t\t\t\t'token': '{$_upload_token}', \t\t\t\t'bucket': '{$_bucket}', \t\t\t\t'return': 'URL|THUMB|92x92' \t\t\t}, \t\t\t'itemTemplate': \$('#{$_id}-template-uploadify').html(), \t\t\t'onSelect': function() \t\t\t{ \t\t\t\tif ( \$( '#{$_id}-filelist li' ).length ) \t\t\t\t{ \t\t\t\t\t\$('#{$_id}-filelist').removeClass( 'empty' ); \t\t\t\t} \t\t\t}, \t\t\t'onUploadStart': function() \t\t\t{ \t\t\t\twindow.onbeforeunload = function() \t\t\t\t{ \t\t\t\t\treturn 'Uploads are in progress. Leaving this page will cause them to stop.'; \t\t\t\t}; \t\t\t\t//\tDisable tabs - SWFUpload aborts uploads if it is hidden. \t\t\t\t\$('ul.tabs li a').addClass('disabled'); \t\t\t}, \t\t\t'onQueueComplete': function() \t\t\t{ \t\t\t\twindow.onbeforeunload = null; \t\t\t\t\$('ul.tabs li a').removeClass('disabled'); \t\t\t}, \t\t\t'onUploadProgress': function(file, bytesUploaded, bytesTotal) \t\t\t{ \t\t\t\tvar _percent = bytesUploaded / bytesTotal * 100; \t\t\t\t\$('#{$_id}-' + file.id + ' .progress').css('height', _percent + '%'); \t\t\t}, \t\t\t'onUploadSuccess': function(file, data) \t\t\t{ \t\t\t\tvar _data = JSON.parse(data); \t\t\t\t// -------------------------------------------------------------------------- \t\t\t\tvar _html = \$.trim(\$('#{$_id}-template-item').html()); \t\t\t\tvar _item = \$(\$.parseHTML(_html)); \t\t\t\t_item.attr('id', '{$_id}-' + file.id + '-complete'); \t\t\t\t\$('#{$_id}-' + file.id).replaceWith(_item); \t\t\t\t// -------------------------------------------------------------------------- \t\t\t\tvar _target = \$('#{$_id}-' + file.id + '-complete'); \t\t\t\tif (!_target.length) \t\t\t\t{ \t\t\t\t\t_html = \$.trim(\$('#{$_id}-template-item').html()); \t\t\t\t\t_item = \$(\$.parseHTML(_html)); \t\t\t\t\t_item.attr('id', '{$_id}-' + file.id + '-complete'); \t\t\t\t\t\$('#' + file.id).replaceWith(_item); \t\t\t\t\t_target = \$('#{$_id}-' + file.id + '-complete'); \t\t\t\t} \t\t\t\t// -------------------------------------------------------------------------- \t\t\t\t//\tSwitch the response code \t\t\t\tif (_data.status === 200) \t\t\t\t{ \t\t\t\t\t//\tInsert the image \t\t\t\t\tvar _img = \$('<img>').attr('src', _data.object_url[0]).on('load', function() { \t\t\t\t\t\t_target.removeClass('crunching'); \t\t\t\t\t}); \t\t\t\t\tvar _del = \$('<a>').attr({ \t\t\t\t\t\t'href': '#', \t\t\t\t\t\t'class': 'delete', \t\t\t\t\t\t'data-object_id': _data.object_id \t\t\t\t\t}); \t\t\t\t\t_target.append(_img).append(_del).find('input').val(_data.object_id); \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\t//\tAn error occurred \t\t\t\t\tvar _filename = \$('<p>').addClass('filename').text(file.name); \t\t\t\t\tvar _message = \$('<p>').addClass('message').text(_data.error); \t\t\t\t\t_target.addClass('error').append(_filename).append(_message).removeClass('crunching'); \t\t\t\t} \t\t\t}, \t\t\t'onUploadError': function(file, errorCode, errorMsg, errorString) \t\t\t{ \t\t\t\tvar _target = \$('#{$_id}-' + file.id + '-complete'); \t\t\t\tif (!_target.length) \t\t\t\t{ \t\t\t\t\tvar _html = \$.trim(\$('#{$_id}-template-item').html()); \t\t\t\t\tvar _item = \$(\$.parseHTML(_html)); \t\t\t\t\t_item.attr('id', '{$_id}-' + file.id + '-complete'); \t\t\t\t\t\$('#{$_id}-' + file.id).replaceWith(_item); \t\t\t\t\t_target = \$('#{$_id}-' + file.id + '-complete'); \t\t\t\t} \t\t\t\tvar _filename = \$('<p>').addClass('filename').text(file.name); \t\t\t\tvar _message = \$('<p>').addClass('message').text(errorString); \t\t\t\t_target.addClass('error').append(_filename).append(_message).removeClass('crunching'); \t\t\t} \t\t}); \t\tif ( typeof( \$.fn.sortable ) === 'function' ) \t\t{ \t\t\t\$('#{$_id}-filelist').disableSelection().sortable({ \t\t\t\tplaceholder: 'item placeholder', \t\t\t\titems: "li.item" \t\t\t}); \t\t} \t\t//\tRemove an item from the queue \t\t\$(document).on('click', '#{$_id}-filelist .item .remove', function() \t\t{ \t\t\tvar _instance_id = \$(this).data('instance_id'); \t\t\tvar _file_id = \$(this).data('file_id'); \t\t\t\$('#{$_id}-' + _instance_id).uploadify('cancel', _file_id); \t\t\t\$('#{$_id}-' + _file_id + ' .data-cancel').text('Cancelled').show(); \t\t\t\$('#{$_id}-' + _file_id).addClass('cancelled'); \t\t\tif (\$('#{$_id}-filelist li.item:not(.cancelled)').length === 0) \t\t\t{ \t\t\t\t\$('#{$_id}-filelist').addClass('empty'); \t\t\t\t\$('#{$_id}-filelist li.empty').css('opacity', 0).delay(1000).animate({ \t\t\t\t\topacity: 1 \t\t\t\t}, 250); \t\t\t} \t\t\treturn false; \t\t}); \t\t//\tDeletes an uploaded image \t\t\$(document).on('click', '#{$_id}-filelist .item .delete', function() \t\t{ \t\t\tvar _object = this; \t\t\t\$('#{$_id}-dialog-confirm-delete').dialog( \t\t\t{ \t\t\t\tresizable: false, \t\t\t\tdraggable: false, \t\t\t\tmodal: true, \t\t\t\tdialogClass: "no-close", \t\t\t\tbuttons: \t\t\t\t{ \t\t\t\t\t"Delete Image": function() \t\t\t\t\t{ \t\t\t\t\t\tvar _object_id = \$(_object).data('object_id'); \t\t\t\t\t\t//\tSend off the delete request \t\t\t\t\t\tvar _call = { \t\t\t\t\t\t\t'controller'\t: 'cdnapi', \t\t\t\t\t\t\t'method'\t\t: 'object_delete', \t\t\t\t\t\t\t'action'\t\t: 'POST', \t\t\t\t\t\t\t'data'\t\t\t: \t\t\t\t\t\t\t{ \t\t\t\t\t\t\t\t'object_id': _object_id \t\t\t\t\t\t\t} \t\t\t\t\t\t}; \t\t\t\t\t\tvar _api = new window.NAILS_API(); \t\t\t\t\t\t_api.call( _call ); \t\t\t\t\t\t// -------------------------------------------------------------------------- \t\t\t\t\t\t\$(_object).closest('li.item').addClass('deleted').fadeOut('slow', function() \t\t\t\t\t\t{ \t\t\t\t\t\t\t\$(_object).remove(); \t\t\t\t\t\t}); \t\t\t\t\t\t// -------------------------------------------------------------------------- \t\t\t\t\t\t//\tShow the empty screens \t\t\t\t\t\tif (\$('#{$_id}-filelist li.item:not(.deleted)').length === 0) \t\t\t\t\t\t{ \t\t\t\t\t\t\t\$('#{$_id}-filelist').addClass('empty'); \t\t\t\t\t\t} \t\t\t\t\t\t// -------------------------------------------------------------------------- \t\t\t\t\t\t//\tClose dialog \t\t\t\t\t\t\$(this).dialog("close"); \t\t\t\t\t}, \t\t\t\t\tCancel: function() \t\t\t\t\t{ \t\t\t\t\t\t\$(this).dialog("close"); \t\t\t\t\t} \t\t\t\t} \t\t\t}); \t\t\treturn false; \t\t}); \t} \t</script> EOT; // -------------------------------------------------------------------------- return $_out; }
<?php // This is a simple list of thumbnails with a fancybox gallery echo '<hr />'; echo '<div class="gallery row">'; foreach ($post->gallery as $slide) { echo '<div class="' . BS_COL_SM_3 . ' ' . BS_COL_XS_4 . '" style="margin-bottom:1.25em;">'; echo '<a href="' . cdn_serve($slide->image_id) . '" target="_blank" class="fancybox" data-fancybox-group="blog-post-gallery">'; echo img(array('src' => cdn_thumb($slide->image_id, 500, 500), 'class' => 'img-responsive center-block thumbnail', 'width' => 500, 'height' => 500)); echo '</a>'; echo '</div>'; } echo '</div>'; echo '<hr />';
<?php $_known_user = isset($id) && $id ? '' : 'no-data'; echo '<td class="' . $_known_user . ' user-cell">'; // -------------------------------------------------------------------------- // Profile image if (isset($profile_img) && $profile_img) { echo anchor(cdn_serve($profile_img), img(cdn_thumb($profile_img, 36, 36)), 'class="fancybox"'); } else { $_gender = isset($gender) ? $gender : 'undisclosed'; echo img(cdn_blank_avatar(36, 36, $_gender)); } // -------------------------------------------------------------------------- // User details echo '<span class="user-data">'; $_name = ''; $_name .= isset($first_name) && $first_name ? $first_name . ' ' : ''; $_name .= isset($last_name) && $last_name ? $last_name . ' ' : ''; $_name = $_name ? $_name : 'Unknown User'; if (isset($id) && $id) { echo anchor('admin/accounts/edit/' . $id, $_name, 'class="fancybox" data-fancybox-type="iframe"'); } else { echo $_name; } if (isset($email) && $email) { echo '<small>' . mailto($email) . '</small>'; } else { echo '<small>No email address</small>'; } echo '</span>'; // --------------------------------------------------------------------------
<fieldset id="edit-user-profile-img"> <legend><?php echo lang('accounts_edit_img_legend'); ?> </legend> <?php $_error = isset($upload_error) ? 'error' : NULL; echo '<div class="field ' . $_error . '">'; if (empty($user_edit->profile_img)) { echo img(array('src' => cdn_blank_avatar(100, 125), 'id' => 'preview_image', 'class' => 'left', 'style' => 'margin-right:10px;')); echo form_upload('profile_img'); } else { $_img = array('src' => cdn_thumb($user_edit->profile_img, 100, 125), 'id' => 'preview_image', 'style' => 'border:1px solid #CCC;padding:0;margin-right:10px;'); echo anchor(cdn_serve($user_edit->profile_img), img($_img), 'class="fancybox left"'); echo '<p>'; echo form_upload('profile_img', NULL, 'style="float:none;"') . '<br />'; $_return = '?return_to=' . urlencode(uri_string() . '?' . $_SERVER['QUERY_STRING']); echo anchor('admin/accounts/delete_profile_img/' . $user_edit->id . $_return, lang('action_delete'), 'class="awesome small red" style="margin-top:10px;"'); echo '</p>'; } if ($_error) { echo '<span class="error">'; foreach ($upload_error as $err) { echo $err . '<br />'; } echo '</span>'; } echo '<div class="clear"></div>'; echo '</div>'; ?>
<div class="row"> <div class="<?php echo BS_COL_MD_12; ?> "> <?php echo '<a href="' . cdn_serve($post->image_id) . '" class="fancybox" target="_blank">'; echo img(array('src' => cdn_thumb($post->image_id, 1100, 500), 'class' => 'img-responsive center-block thumbnail')); echo '</a>'; ?> </div> </div>
$_selected = array(); } ?> <ul class="gallery-associations <?php echo !empty($_gallery) ? '' : 'empty'; ?> "> <li class="empty">No images have been uploaded; upload some using the <a href="#">Gallery tab</a></li> <?php if (!empty($_gallery)) { foreach ($_gallery as $image) { // Is this item selected for this variation? $_checked = array_search($image, $_selected) !== FALSE ? 'selected' : FALSE; echo '<li class="image object-id-' . $image . ' ' . $_checked . '">'; echo form_checkbox('variation[' . $_counter . '][gallery][]', $image, (bool) $_checked); echo img(cdn_thumb($image, 34, 34)); echo '</li>'; } } ?> <li class="actions"> <a href="#" data-function="all" class="action awesome small orange">Select All</a> <a href="#" data-function="none" class="action awesome small orange">Select None</a> <a href="#" data-function="toggle" class="action awesome small orange">Toggle</a> </li> </ul> </div> <div class="tab page fieldset" id="tab-variation-<?php echo $_counter; ?>
<th class="label">Label & Description</th> <th class="count">Products</th> <th class="modified">Modified</th> <th class="active">Active</th> <th class="actions">Actions</th> </tr> </thead> <tbody> <?php if ($brands) { foreach ($brands as $brand) { echo '<tr>'; echo '<td class="label">'; echo '<div class="thumbnail">'; if ($brand->logo_id) { echo anchor(cdn_serve($brand->logo_id), img(cdn_thumb($brand->logo_id, 32, 32)), 'class="fancybox"'); } else { echo img(NAILS_ASSETS_URL . 'img/admin/modules/shop/manager/no-image.jpg'); } echo '</div>'; echo '<div class="content">'; echo $brand->label; echo $brand->description ? '<small>' . character_limiter(strip_tags($brand->description), 225) . '</small>' : '<small>No Description</small>'; echo '</div>'; echo '</td>'; echo '<td class="count">'; echo !isset($brand->product_count) ? 'Unknown' : $brand->product_count; echo '</td>'; echo $this->load->view('_utilities/table-cell-datetime', array('datetime' => $brand->modified), TRUE); if ($brand->is_active) { echo '<td class="active success">';
echo lang('accounts_edit_upload_legend'); ?> </legend> <p> <?php echo '<ul>'; if ($user_uploads) { foreach ($user_uploads as $file) { echo '<li class="file">'; switch ($file->mime) { case 'image/jpg': case 'image/jpeg': case 'image/gif': case 'image/png': echo '<a href="' . cdn_serve($file->id) . '" class="fancybox image">'; echo img(cdn_thumb($file->id, 35, 35)); echo $file->filename_display; echo '<small>Bucket: ' . $file->bucket->slug . '</small>'; echo '</a>'; break; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- default: echo anchor(cdn_serve($file->id) . '?dl=1', $file->filename_display . '<small>Bucket: ' . $file->bucket->slug . '</small>'); break; } echo '</li>'; } } else { echo '<li class="no-data">' . lang('accounts_edit_upload_nofile') . '</li>'; }
public function object_create() { // Define $_out array $_out = array(); // -------------------------------------------------------------------------- if (!$this->user_model->is_logged_in()) { // User is not logged in must supply a valid upload token $_token = $this->input->get_post('token'); if (!$_token) { // Sent as a header? $_token = $this->input->get_request_header('X-cdn-token'); } $_user = $this->cdn->validate_api_upload_token($_token); if (!$_user) { $_out['status'] = 400; $_out['error'] = $this->cdn->last_error(); $this->_out($_out); return; } else { $this->user_model->set_active_user($_user); } } // -------------------------------------------------------------------------- // Uploader verified, bucket defined and valid? $_bucket = $this->input->get_post('bucket'); if (!$_bucket) { // Sent as a header? $_bucket = $this->input->get_request_header('X-cdn-bucket'); } if (!$_bucket) { $_out['status'] = 400; $_out['error'] = 'Bucket not defined.'; $this->_out($_out); return; } // -------------------------------------------------------------------------- // Attempt upload $_upload = $this->cdn->object_create('upload', $_bucket); if ($_upload) { // Success! Return as per the user's preference $_return = $this->input->post('return'); if (!$_return) { // Sent as a header? $_return = $this->input->get_request_header('X-cdn-return'); } if ($_return) { $_format = explode('|', $_return); switch (strtoupper($_format[0])) { // URL case 'URL': if (isset($_format[1])) { switch (strtoupper($_format[1])) { case 'THUMB': // Generate a url for each request $_out['object_url'] = array(); $_sizes = explode(',', $_format[2]); foreach ($_sizes as $sizes) { $_size = explode('x', $sizes); $_w = isset($_size[0]) ? $_size[0] : ''; $_h = isset($_size[1]) ? $_size[1] : ''; $_out['object_url'][] = cdn_thumb($_upload->id, $_w, $_h); } $_out['object_id'] = $_upload->id; break; case 'SCALE': // Generate a url for each request $_out['object_url'] = array(); $_sizes = explode(',', $_format[2]); foreach ($_sizes as $sizes) { $_size = explode('x', $sizes); $_w = isset($_size[0]) ? $_size[0] : ''; $_h = isset($_size[1]) ? $_size[1] : ''; $_out['object_url'][] = cdn_scale($_upload->id, $_w, $_h); } $_out['object_id'] = $_upload->id; break; case 'SERVE_DL': case 'DOWNLOAD': case 'SERVE_DOWNLOAD': $_out['object_url'] = cdn_serve($_upload->id, TRUE); $_out['object_id'] = $_upload->id; break; case 'SERVE': default: $_out['object_url'] = cdn_serve($_upload->id); $_out['object_id'] = $_upload->id; break; } } else { // Unknow, return the serve URL & ID $_out['object_url'] = cdn_serve($_upload->id); $_out['object_id'] = $_upload->id; } break; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- default: // just return the object $_out['object'] = $_upload; break; } } else { // just return the object $_out['object'] = $_upload; } } else { $_out['status'] = 400; $_out['error'] = $this->cdn->last_error(); } // -------------------------------------------------------------------------- // Make sure the _out() method doesn't send a header, annoyingly SWFupload does // not return the server response to the script when a non-200 status code is detected $this->_out($_out); }
<?php echo '<tr class="file list" data-title="' . $object->filename_display . '" data-id="' . $object->id . '">'; echo '<td class="filename">'; if ($object->is_img) { // Thumbnail echo img(array('src' => cdn_thumb($object->id, 30, 30), 'class' => 'icon')); $_fancybox_class = 'cdn-fancybox'; $_fancybox_type = ''; $_url = cdn_serve($object->id); $_action = 'View'; } elseif ($object->mime == 'audio/mpeg') { // PDF echo '<div class="icon"><span class="ion-music-note" style="font-size:2.2em"></span></div>'; $_fancybox_class = 'cdn-fancybox'; $_fancybox_type = 'iframe'; $_url = cdn_serve($object->id); $_action = 'Play'; } elseif ($object->mime == 'application/pdf') { // PDF echo '<div class="icon"><span class="ion-document" style="font-size:2.2em"></span></div>'; $_fancybox_class = 'cdn-fancybox'; $_fancybox_type = 'iframe'; $_url = cdn_serve($object->id); $_action = 'View'; } else { // Generic file, force download echo '<div class="icon"><span class="ion-document" style="font-size:2.2em"></span></div>'; $_fancybox_class = ''; $_fancybox_type = ''; $_url = cdn_serve($object->id, TRUE);