Пример #1
0
 function do_upload()
 {
     $config['upload_path'] = $this->photos_path;
     $config['allowed_types'] = 'gif|jpg|png|jpeg';
     $fileNameParsed = explode('.', $_FILES['userfile']['name']);
     $ext = array_pop($fileNameParsed);
     $config['file_name'] = implode('.', [slug(implode('.', $fileNameParsed)), $ext]);
     $this->load->library('upload', $config);
     if ($this->upload->do_upload()) {
         //Get DATA
         $file_data = $this->upload->data();
         if ($file_data["image_width"] > 900) {
             //RESIZE
             $config = array('source_image' => $file_data['full_path'], 'maintain_ratio' => true, 'width' => 900, 'height' => 600);
             $this->image_lib->initialize($config);
             if (!$this->image_lib->resize()) {
                 return false;
             }
         }
         // GET COLOR
         $color = get_main_color($file_data);
         //SAVE IN DB
         $data = array('title' => humanize($file_data['raw_name']), 'filename' => $file_data['file_name'], 'origin_width' => $file_data['image_width'], 'origin_height' => $file_data['image_height'], 'created' => $this->now, 'updated' => $this->now, 'type' => $file_data['image_type'], 'r' => $color['r'], 'g' => $color['g'], 'b' => $color['b']);
         //CREATE Header
         create_header($data);
         //CREATE THUMB
         create_thumbnail($data);
         if ($this->db->insert('photos', $data)) {
             return true;
         } else {
             $this->session->set_flashdata('message', array('title' => 'Error', 'content' => 'Unexpected Error', 'type' => 'error'));
             return false;
         }
     } else {
         //ERROR
         $this->session->set_flashdata('message', array('title' => 'Error', 'content' => $this->upload->display_errors(), 'type' => 'error'));
         return false;
         // $this->upload->display_errors();
     }
 }
Пример #2
0
 function edit($id)
 {
     //GET Thumbnails
     $thumbnail = $this->get_thumbnail($_POST['url']);
     if ($thumbnail) {
         $header = isset($_POST['header']) ? true : false;
         $data['full_path'] = $this->photos_path . 'thumbs/' . $thumbnail;
         $published = isset($_POST['published']) ? true : false;
         $color = get_main_color($data);
         $data = array('published' => $published, 'updated' => $this->now, 'title' => $_POST['title'], 'url' => $_POST['url'], 'header' => $header, 'language' => $_POST['language'], 'description' => $_POST['description'], 'thumbnail' => $thumbnail, 'r' => $color['r'], 'g' => $color['g'], 'b' => $color['b']);
         if (isset($_POST['photo_id']) && !empty($_POST['photo_id'])) {
             $data['photo_id'] = $_POST['photo_id'];
         } else {
             $data['photo_id'] = null;
         }
         $this->db->where('id', $id);
         return $this->db->update('videos', $data);
     }
 }
Пример #3
0
function customize_css()
{
    ?>
	<style>
	.main-color-background,
	.content h2{background-color: <?php 
    echo get_main_color();
    ?>
;}
	.main-color-font{color: <?php 
    echo get_main_color();
    ?>
;}
	.site-title, .site-title a, .site-desc, .content h2, .more-link, .min-more-link, .go-comment-arrow{color: <?php 
    echo get_title_color();
    ?>
;}
	.content h3{border-bottom: 3px solid <?php 
    echo get_main_color();
    ?>
;}
	.content h4{border-left: 8px solid <?php 
    echo get_main_color();
    ?>
;}
	.content h5{border-left: 3px solid <?php 
    echo get_main_color();
    ?>
}
	.share, .comments-header{border-bottom: 2px solid <?php 
    echo get_main_color();
    ?>
;}
	.sub-color-background{background-color: <?php 
    echo get_sub_color();
    ?>
;}

	.no-thumbnail p:hover,
	.post-title a:hover,
	.bread ul li a:hover,
	.site-title a:hover,
	.kanren-post-name a:hover,
	.same-tag a:hover,
	.same-category a:hover,
	.side .box a:hover,
	.footer a:hover{color: <?php 
    echo get_link_hover_color();
    ?>
;}

	.nav-inner ul li a:hover,
	.cat-link a:hover,
	.more-link:hover,
	.min-more-link:hover,
	.pagenavi .current,
	.pagenavi a:hover,
	.com-nav a:hover,
	.go-comment-arrow:hover,
	.search-submit:hover,
	.move-button:hover{background-color: <?php 
    echo get_link_hover_color();
    ?>
;}
	.no-thumbnail{height: <?php 
    echo get_thumbnail_height();
    ?>
;}
	.thumb-box{max-height: <?php 
    echo get_thumbnail_height();
    ?>
;}
	<?php 
    if (get_option("is_shadow")) {
        echo ".main-color-font, .content h2{text-shadow: 1px 1px 1px #333;}";
    }
    $count_followButtons = 1;
    if (is_twitter_follow()) {
        $count_followButtons += 1;
    }
    if (is_fb_follow()) {
        $count_followButtons += 1;
    }
    if (is_g_follow()) {
        $count_followButtons += 1;
    }
    if (is_line_follow()) {
        $count_followButtons += 1;
    }
    $width_followButton = floor(100 / $count_followButtons);
    ?>
	.follow-icon{width: <?php 
    echo $width_followButton;
    ?>
%;}
	</style>
<?php 
}