Example #1
0
//	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 = '';
        $_link_target = '';
    }
<p>
	You have received this email because you asked us to inform you
	when <strong><?php 
echo $product->label;
?>
</strong> was back in stock.
</p>
<p class="text-center">
	<?php 
echo anchor($product->url, 'Click here to view this item at ' . APP_NAME, 'class="button"');
?>
</p>
<hr />
<?php 
if ($product->featured_img) {
    echo '<p class="text-center">';
    echo img(array('src' => cdn_scale($product->featured_img, 250, 250), 'class' => 'thumbnail '));
    echo '</p>';
}
echo '<p class="text-center">';
echo '<strong>' . $product->label . '</strong>';
echo '</p>';
echo $product->description;
Example #3
0
				<th class="filesize">Filesize</th>
				<th class="actions">Actions</th>
			</tr>
		</thead>
		<tbody>
		<?php 
if ($objects) {
    foreach ($objects as $object) {
        echo '<tr>';
        echo '<td class="id">' . number_format($object->id) . '</td>';
        echo '<td class="thumbnail">';
        switch ($object->mime) {
            case 'image/png':
            case 'image/jpeg':
            case 'image/gif':
                echo anchor(cdn_serve($object->id), img(cdn_scale($object->id, 64, 64)), 'class="fancybox"');
                break;
            case 'audio/mpeg':
                echo '<span class="ion-music-note"></span>';
                break;
            default:
                echo '<span class="ion-document"></span>';
                break;
        }
        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));
Example #4
0
			<?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>';
Example #5
0
				<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) {
Example #6
0
 function form_field_mm_image($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 = 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_image_' . 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_image&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-image-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_preview = $_field['default'] ? img(cdn_scale($_field['default'], 100, 100)) : '';
     // --------------------------------------------------------------------------
     //	Error
     if ($_field_error && $_field['error']) {
         $_field_error = '<span class="error">' . $_field['error'] . '</span>';
     } elseif ($_field_error) {
         $_field_error = form_error($_field['key'], '<span class="error">', '</span>');
     }
     // --------------------------------------------------------------------------
     //	Quick script to instantiate the field, not indented due to heredoc syntax
     get_instance()->load->library('cdn');
     $_scheme = get_instance()->cdn->url_scale_scheme();
     $_scheme = str_replace('{{width}}', 100, $_scheme);
     $_scheme = str_replace('{{height}}', 100, $_scheme);
     $_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-image ' . $_field_error . ' ' . $_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-image-preview">';
     $_out .= '		' . $_field_preview;
     $_out .= '	</span>';
     $_out .= '	<span class="mm-image-container">';
     $_out .= '		<a href="' . $_url . '" data-fancybox-type="iframe" data-width="80%" data-height="80%" class="awesome mm-image-choose">';
     $_out .= '			Choose';
     $_out .= '		</a>';
     $_out .= '		' . $_field_tip;
     $_out .= '		<br />';
     $_out .= '		<a href="#" class="awesome small red mm-image-remove" style="display:' . $_remove_display . '">';
     $_out .= '			Remove';
     $_out .= '		</a>';
     $_out .= '		' . $_field_error;
     $_out .= '	</span>';
     $_out .= '</label>';
     $_out .= '<br /><br />';
     $_out .= $_field_field;
     $_out .= '</div>';
     // --------------------------------------------------------------------------
     return $_out;
 }
Example #7
0
<?php

echo '<li class="file thumb" data-title="' . $object->filename_display . '" data-id="' . $object->id . '">';
echo '<div class="image">';
if ($object->is_img) {
    //	Thumbnail
    echo img(cdn_scale($object->id, 150, 175));
    $_fancybox_class = 'cdn-fancybox';
    $_fancybox_type = '';
    $_url = cdn_serve($object->id);
    $_action = 'View';
} elseif ($object->mime == 'audio/mpeg') {
    //	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);
<?php

echo anchor($post->url, img(array('src' => cdn_scale($post->image_id, 300, 300), 'class' => 'thumbnail img-responsive center-block')));
Example #9
0
 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);
 }