Example #1
0
    /**
	 * Construct by passing in the primary key to access the article in
	 * the database.
	 *
	 * @param int $p_languageId
	 * @param int $p_articleNumber
	 *		Not required when creating an article.
	 */
    function Blog($p_blog_id = null)
    {
        parent::DatabaseObject($this->m_columnNames);
        $this->m_data['blog_id'] = $p_blog_id;
        if ($this->keyValuesExist()) {
            $this->fetch();
            $this->m_data['images'] = BlogImageHelper::GetImagePaths('blog', $p_blog_id, true, true);
        }
    } // constructor
Example #2
0
    public static function StoreImageDerivates($p_object_type, $p_object_id, $p_image)
    {
        if ($p_image['error'] !== 0 || self::TestImage($p_image) !== 0) {
            return false;   
        }

        foreach (BlogImageHelper::GetImagePaths($p_object_type, $p_object_id) as $dim => $path) {
            list ($width, $height) = explode('x', $dim);
            
            $d_width = $width * 2;
            $d_height = $height * 2;

            if (!file_exists(dirname($path))) {
                $mkdir = '';
                foreach (explode('/', dirname($path)) as $k => $dir) {
                    $mkdir .= '/'.$dir;
                    @mkdir($mkdir, 0775);
                }
            }

            $cmd = "convert -resize {$d_width}x -resize 'x{$d_height}<' -resize 50% -gravity center  -crop {$width}x{$height}+0+0 +repage {$p_image['tmp_name']} $path";
            system($cmd, $return_value);
            
            $all_right = $return_value || $all_right;
            
            if ($return_value ==  0) {
                $success[] = $width.'x'.$height;       
            } else {
                $failed[] = $width.'x'.$height;   
            }
        }
        
        if (function_exists('camp_html_add_msg')) {
            if (is_array($success)) {
                camp_html_add_msg(getGS('Created image derivate(s): $1', implode(', ', $success)), 'ok');
            }
            if (is_array($failed)) {
                camp_html_add_msg(getGS('Failed to create image derivate(s): $1', implode(', ', $failed)), 'error');    
            }
        }

        return $all_right;
    }