<?php if ($items->data) { foreach ($items->data as $item) { ?> <tr id="product-<?php echo $item->id; ?> "> <td class="id"><?php echo number_format($item->id); ?> </td> <td class="image"> <?php if (!empty($item->gallery[0])) { echo anchor(cdn_serve($item->gallery[0]), img(cdn_scale($item->gallery[0], 75, 75)), 'class="fancybox"'); } else { echo img(NAILS_ASSETS_URL . 'img/admin/modules/shop/image-icon.png'); } ?> </td> <?php if ($item->is_active) { echo '<td class="status success">'; echo '<span class="ion-checkmark-circled"></span>'; echo '</td>'; } else { echo '<td class="status error">'; echo '<span class="ion-close-circled"></span>'; echo '</td>';
$_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 = ''; $_link_target = ''; } // -------------------------------------------------------------------------- // Render $_out = ''; $_out .= $_link_url ? '<a href="' . $_link_url . '" ' . $_link_attr . '>' : ''; $_out .= '<img src="' . $_img_url . '" ' . $_img_attr . '/>'; $_out .= $_link_url ? '</a>' : ''; echo $_out; }
} echo '</td>'; echo '<td class="bucket">' . $object->bucket->label . '</td>'; echo '<td class="mime">' . $object->mime . '</td>'; echo '<td class="filename">' . $object->filename_display . '</td>'; $this->load->view('admin/_utilities/table-cell-user', $object->creator); $this->load->view('admin/_utilities/table-cell-datetime', array('datetime' => $object->created)); $this->load->view('admin/_utilities/table-cell-datetime', array('datetime' => $object->modified)); echo '<td class="filesize">' . format_bytes($object->filesize) . '</td>'; echo '<td class="actions">'; echo anchor('admin/cdnadmin/edit/' . $object->id . $_return, 'Edit', 'class="awesome small"'); echo anchor('admin/cdnadmin/delete/' . $object->id . $_return, 'Delete', 'data-title="Are you sure?" data-body="Deleting an item will attempt to disconnect it from resources which depend on it. The object wil be recoverable but dependencies won\'t." class="confirm awesome small red"'); if ($object->is_img) { echo anchor(cdn_serve($object->id), 'View', 'class="awesome small fancybox"'); } else { echo anchor(cdn_serve($object->id), 'View', 'class="awesome small fancybox" data-fancybox-type="iframe"'); } echo '</td>'; echo '</tr>'; } } else { echo '<tr>'; echo '<td colspan="10" class="no-data">'; echo 'No Items found'; echo '</td>'; echo '</tr>'; } ?> </tbody> </table> </div>
$_layout = ''; $_single_title = app_setting('social_layout_single_text', 'blog') ? app_setting('social_layout_single_text', 'blog') : 'Share'; $_counters = app_setting('social_counters', 'blog') ? 'data-zeroes="yes"' : 'data-counters="no"'; $_twitter_via = app_setting('social_twitter_via', 'blog') ? app_setting('social_twitter_via', 'blog') : ''; // -------------------------------------------------------------------------- // Layout switch (app_setting('social_layout', 'blog')) { case 'HORIZONTAL': $_layout = ''; break; case 'VERTICAL': $_layout = 'social-likes_vertical'; break; case 'SINGLE': $_layout = 'social-likes_single'; break; } $_enabled = array(); $_enabled[] = app_setting('social_facebook_enabled', 'blog') ? '<div class="facebook" title="Share link on Facebook">Facebook</div>' : ''; $_enabled[] = app_setting('social_twitter_enabled', 'blog') ? '<div class="twitter" data-via="' . $_twitter_via . '" title="Share link on Twitter">Twitter</div>' : ''; $_enabled[] = app_setting('social_googleplus_enabled', 'blog') ? '<div class="plusone" title="Share link on Google+">Google+</div>' : ''; $_enabled[] = app_setting('social_pinterest_enabled', 'blog') && $post->image_id ? '<div class="pinterest" data-media="' . cdn_serve($post->image_id) . '" title="Share image on Pinterest">Pinterest</div>' : ''; $_enabled = array_filter($_enabled); if ($_enabled) { echo '<hr />'; echo '<div class="social-likes ' . $_layout . '" ' . $_counters . ' data-url="' . $post->url . '" data-single-title="' . $_single_title . '" data-title="' . $post->title . '">'; foreach ($_enabled as $enabled) { echo $enabled; } echo '</div>'; }
function form_field_mm($field, $help = '') { // Set var defaults $_field = array(); $_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; $_field['data'] = isset($field['data']) ? $field['data'] : array(); $_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']; $_field_error_cls = form_error($_field['key']) || $_field['error'] ? 'error' : ''; $_readonly = $_field['readonly'] ? 'readonly="readonly"' : ''; $_readonly_cls = $_field['readonly'] ? 'readonly' : ''; // -------------------------------------------------------------------------- // Generate a unique ID for this field $_id = 'field_mm_' . md5(microtime()); // -------------------------------------------------------------------------- // Container data $_field_oddeven = $_field['oddeven']; $_field_type = $_field['type']; // -------------------------------------------------------------------------- // Label $_field_label = $_field['label']; $_field_label .= $_field['required'] ? '*' : ''; $_field_label .= $_field['sub_label'] ? '<small>' . $_field['sub_label'] . '</small>' : ''; // -------------------------------------------------------------------------- // Choose image button $_force_secure = page_is_secure(); if ($_field['bucket']) { $_nonce = time(); $_bucket = urlencode(get_instance()->encrypt->encode($_field['bucket'] . '|' . $_nonce, APP_PRIVATE_KEY)); $_hash = md5($_field['bucket'] . '|' . $_nonce . '|' . APP_PRIVATE_KEY); $_url = site_url('cdn/manager/browse', $_force_secure) . '?callback=_callback_form_field_mm&bucket=' . $_bucket . '&hash=' . $_hash . '&fieldid=' . $_id; } else { $_url = site_url('cdn/manager/browse', $_force_secure); } // Is the site running on SSL? If so then change the protocol so as to avoid 'protocols don't match' errors if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) == 'ON') { $_url = str_replace('http://', 'https://', $_url); } // -------------------------------------------------------------------------- // Tip $_field_tip = $_help['title'] ? img($_help) : ''; // -------------------------------------------------------------------------- // If there's post data, use that value instead $_field['default'] = set_value($_field['key'], $_field['default']); // The actual field which is submitted $_field_field = '<input type="hidden" name="' . $_field['key'] . '" class="mm-file-value" value="' . $_field['default'] . '" />'; // -------------------------------------------------------------------------- // Remove button $_remove_display = $_field['default'] ? 'inline-block' : 'none'; // -------------------------------------------------------------------------- // If a default has been specified then show a download link $_field_download = $_field['default'] ? anchor(cdn_serve($_field['default'], TRUE), 'Download File') : ''; // -------------------------------------------------------------------------- // Error if ($_field_error_cls && $_field['error']) { $_field_error = '<span class="error">' . $_field['error'] . '</span>'; } elseif ($_field_error_cls) { $_field_error = form_error($_field['key'], '<span class="error">', '</span>'); } else { $_field_error = ''; } // -------------------------------------------------------------------------- // Quick script to instantiate the field, not indented due to heredoc syntax get_instance()->load->library('cdn'); $_scheme = get_instance()->cdn->url_serve_scheme(TRUE); $_scheme = str_replace('{{bucket}}', $_field['bucket'], $_scheme); // Replace the Mustache style syntax; this could/does get used in mustache templates // so these fields get stripped out $_scheme = str_replace('{{filename}}', '{[filename]}', $_scheme); $_scheme = str_replace('{{extension}}', '{[extension]}', $_scheme); $_out = '<div class="field mm-file ' . $_field_error_cls . ' ' . $_field_oddeven . ' ' . $_readonly_cls . ' ' . $_field_type . '" id="' . $_id . '" data-scheme="' . $_scheme . '">'; $_out .= '<label>'; $_out .= ' <span class="label">'; $_out .= ' ' . $_field_label; $_out .= ' </span>'; $_out .= ' <span class="mm-file-container">'; $_out .= ' <a href="' . $_url . '" data-fancybox-type="iframe" data-width="80%" data-height="80%" class="awesome mm-file-choose">'; $_out .= ' Choose'; $_out .= ' </a>'; $_out .= ' ' . $_field_tip; $_out .= ' <br />'; $_out .= ' <a href="#" class="awesome small red mm-file-remove" style="display:' . $_remove_display . '">'; $_out .= ' Remove'; $_out .= ' </a>'; $_out .= ' <span class="mm-file-preview">'; $_out .= ' ' . $_field_download; $_out .= ' </span>'; $_out .= ' ' . $_field_error; $_out .= ' </span>'; $_out .= '</label>'; $_out .= '<br /><br />'; $_out .= $_field_field; $_out .= '</div>'; // -------------------------------------------------------------------------- return $_out; }
<th class="status">Published</th> <th class="user">Author</th> <th class="datetime">Modified</th> <th class="actions">Actions</th> </tr> </thead> <tbody> <?php if ($posts) { $_date_format = active_user('pref_date_format'); $_time_format = active_user('pref_time_format'); foreach ($posts as $post) { echo '<tr class="post" data-title="' . $post->title . '">'; echo '<td class="image">'; if ($post->image_id) { echo anchor(cdn_serve($post->image_id), img(cdn_scale($post->image_id, 75, 75)), 'class="fancybox"'); } else { echo img(NAILS_ASSETS_URL . 'img/admin/modules/blog/image-icon.png'); } echo '</td>'; echo '<td class="title">'; // Title echo $post->title; // URL echo '<small>' . anchor($post->url, $post->url, 'target="_blank"') . '</small>'; // Exceprt if (app_setting('use_excerpt', 'blog')) { echo '<small>' . $post->excerpt . '</small>'; } echo '</td>'; if ($post->is_published) {
<?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>'; // --------------------------------------------------------------------------
<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'))) : '';
<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>
<?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 />';
<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>'; ?>
// MP3 echo '<span class="ion-music-note" style="font-size:14em"></span>'; $_fancybox_class = 'cdn-fancybox'; $_fancybox_type = 'iframe'; $_url = cdn_serve($object->id); $_action = 'Play'; } elseif ($object->mime == 'application/pdf') { // PDF echo '<span class="ion-document" style="font-size:14em"></span>'; $_fancybox_class = 'cdn-fancybox'; $_fancybox_type = 'iframe'; $_url = cdn_serve($object->id); $_action = 'View'; } else { // Generic file, force download echo '<span class="ion-document" style="font-size:14em"></span>'; $_fancybox_class = ''; $_fancybox_type = ''; $_url = cdn_serve($object->id, TRUE); $_action = 'Download'; } // Actions echo '<div class="actions">'; echo '<a href="#" data-fieldid="' . $this->input->get('fieldid') . '" data-id="' . $object->id . '" data-bucket="' . $bucket->slug . '" data-file="' . $object->filename . '" class="awesome green small insert">Insert</a>'; echo anchor(site_url('cdn/manager/delete/' . $object->id . $_query_string, page_is_secure()), 'Delete', 'class="awesome red small delete"'); echo anchor($_url, $_action, 'data-fancybox-title="' . $object->filename_display . '" data-fancybox-type="' . $_fancybox_type . '" class="' . $_fancybox_class . ' awesome small"'); echo '</div>'; echo '</div>'; // Filename echo '<p class="filename">' . $object->filename_display . '</p>'; echo '</li>';
<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">';
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>'; } echo '</ul>'; ?> </p> </fieldset> <?php }
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); }