Skip to content

Commit 8c400bb

Browse files
tdutrionconst-cloudinary
authored andcommitted
PSR-2 compliance + PSR-4 autoload + documentation update
1 parent e87709c commit 8c400bb

20 files changed

Lines changed: 641 additions & 441 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ samples/PhotoAlbumCake/Config/CloudinaryPrivate.php
33
vendor/
44
coverage/
55
phpdocs/
6+
.idea
7+
dbfile.db
68
*.bak

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 cloudinary
3+
Copyright (c) 2015 Cloudinary
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@
2727
"autoload": {
2828
"classmap": ["src"],
2929
"files": ["src/Helpers.php"]
30+
},
31+
"autoload-dev": {
32+
"psr-4": { "Cloudinary\\Test\\": "tests/" },
33+
"files": ["tests/TestHelper.php"]
3034
}
3135
}

phpcs.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="cloudinary_php coding standard">
3+
<description>cloudinary_php coding standard</description>
4+
5+
<!-- display progress -->
6+
<arg value="p"/>
7+
<arg name="colors"/>
8+
9+
<!-- inherit rules from: -->
10+
<rule ref="PSR2">
11+
<exclude name="PSR1.Methods.CamelCapsMethodName"/>
12+
</rule>
13+
14+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
15+
<properties>
16+
<property name="ignoreBlankLines" value="false"/>
17+
</properties>
18+
</rule>
19+
20+
<!-- Paths to check -->
21+
<file>src</file>
22+
<file>tests</file>
23+
</ruleset>

phpunit.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
if (!is_file(__DIR__.'/vendor/autoload.php') || !is_readable(__DIR__.'/vendor/autoload.php')) {
4+
echo 'Unable to load classes. Please run composer first.';
5+
exit;
6+
}
7+
8+
include __DIR__.'/vendor/autoload.php';

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
processIsolation = "false"
1212
stopOnFailure = "false"
1313
syntaxCheck = "false"
14+
bootstrap = "phpunit.php"
1415
>
1516

1617
<testsuites>

samples/PhotoAlbum/autoloader.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
if (!is_file(__DIR__ . '/../../vendor/autoload.php') || !is_readable(__DIR__ . '/../../vendor/autoload.php')) {
4+
throw new Exception('Unable to load classes. Please run "php composer.phar dump-autoload --optimize" first.');
5+
}
6+
7+
include __DIR__.'/../../vendor/autoload.php';

samples/PhotoAlbum/list.php

Lines changed: 122 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,144 @@
11
<?php require 'main.php' ?>
22
<html>
3-
<head>
3+
<head>
44
<meta charset="utf-8">
55
<title>PhotoAlbum - Main page</title>
66

7-
<link href="style.css" media="all" rel="stylesheet" />
7+
<link href="style.css" media="all" rel="stylesheet"/>
88

99
<link rel="shortcut icon"
10-
href="<?php echo cloudinary_url("http://cloudinary.com/favicon.png",
11-
array("type" => "fetch")); ?>" />
12-
10+
href="<?php echo cloudinary_url("http://cloudinary.com/favicon.png", array("type" => "fetch")); ?>"/>
11+
1312
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
1413

1514
<script type='text/javascript'>
16-
$(function () {
17-
$('.toggle_info').click(function () {
18-
$(this).closest('.photo').toggleClass('show_more_info');
19-
return false;
15+
$(function () {
16+
$('.toggle_info').click(function () {
17+
$(this).closest('.photo').toggleClass('show_more_info');
18+
return false;
19+
});
2020
});
21-
});
2221
</script>
23-
</head>
24-
<body>
25-
26-
<div id="logo">
27-
<!-- This will render the image fetched from a remote HTTP URL using Cloudinary -->
28-
<?php echo fetch_image_tag("http://cloudinary.com/images/logo.png") ?>
29-
</div>
30-
31-
<div id="posterframe">
32-
<!-- This will render the fetched Facebook profile picture using Cloudinary according to the
33-
requested transformations -->
34-
<?php echo facebook_profile_image_tag("officialchucknorrispage", array(
35-
"format" => "png",
36-
"transformation" => array(
37-
array("height" => 95, "width" => 95, "crop" => "thumb", "gravity" => "face",
38-
"effect" => "sepia", "radius" => 20
39-
), array("angle" => 10)
40-
)));
41-
?>
42-
</div>
43-
44-
<h1>Welcome!</h1>
45-
46-
<p>
47-
This is the main demo page of the PhotoAlbum sample PHP application of Cloudinary.<br />
48-
Here you can see all images you have uploaded to this PHP application and find some information on how
49-
to implement your own PHP application storing, manipulating and serving your photos using Cloudinary!
50-
</p>
22+
</head>
23+
<body>
24+
25+
<div id="logo">
26+
<!-- This will render the image fetched from a remote HTTP URL using Cloudinary -->
27+
<?php echo fetch_image_tag("http://cloudinary.com/images/logo.png") ?>
28+
</div>
29+
30+
<div id="posterframe">
31+
<!-- This will render the fetched Facebook profile picture using Cloudinary according to the
32+
requested transformations -->
33+
<?php echo facebook_profile_image_tag("officialchucknorrispage", array(
34+
"format" => "png",
35+
"transformation" => array(
36+
array(
37+
"height" => 95,
38+
"width" => 95,
39+
"crop" => "thumb",
40+
"gravity" => "face",
41+
"effect" => "sepia",
42+
"radius" => 20,
43+
),
44+
array("angle" => 10),
45+
),
46+
));
47+
?>
48+
</div>
49+
50+
<h1>Welcome!</h1>
51+
52+
<p>
53+
This is the main demo page of the PhotoAlbum sample PHP application of Cloudinary.<br/>
54+
Here you can see all images you have uploaded to this PHP application and find some information on how
55+
to implement your own PHP application storing, manipulating and serving your photos using Cloudinary!
56+
</p>
5157

58+
<p>
59+
All of the images you see here are transformed and served by Cloudinary.
60+
For instance, the logo and the poster frame.
61+
They are both generated in the cloud using the Cloudinary shortcut functions: fetch_image_tag and
62+
facebook_profile_image_tag.
63+
These two pictures weren't even have to be uploaded to Cloudinary, they are retrieved by the service, transformed,
64+
cached and distributed through a CDN.
65+
</p>
66+
67+
<h1>Your Images</h1>
68+
<div class="photos">
5269
<p>
53-
All of the images you see here are transformed and served by Cloudinary.
54-
For instance, the logo and the poster frame.
55-
They are both generated in the cloud using the Cloudinary shortcut functions: fetch_image_tag and facebook_profile_image_tag.
56-
These two pictures weren't even have to be uploaded to Cloudinary, they are retrieved by the service, transformed, cached and distributed through a CDN.
57-
</p>
70+
Following are the images uploaded by you. You can also upload more pictures.
5871

59-
<h1>Your Images</h1>
60-
<div class="photos">
61-
<p>
62-
Following are the images uploaded by you. You can also upload more pictures.
63-
64-
You can click on each picture to view its original size, and see more info about and additional transformations.
65-
<a class="upload_link" href="upload.php">Upload Images...</a>
66-
</p>
67-
<?php if (R::count('photo') == 0) { ?>
72+
You can click on each picture to view its original size, and see more info about and additional transformations.
73+
<a class="upload_link" href="upload.php">Upload Images...</a>
74+
</p>
75+
<?php if (R::count('photo') == 0) { ?>
6876
<p>No images were uploaded yet.</p>
69-
<?php
70-
}
71-
$index = 0;
72-
foreach (R::findAll('photo') as $photo) {
73-
?>
77+
<?php
78+
}
79+
$index = 0;
80+
foreach (R::findAll('photo') as $photo) {
81+
?>
7482
<div class="photo">
75-
<a href="<?php echo cloudinary_url($photo["public_id"],
83+
<a href="<?php echo cloudinary_url($photo["public_id"],
7684
array("format" => $photo["format"])) ?>" target="_blank" class="public_id_link">
77-
<?php
78-
echo "<div class='public_id'>" . $photo["public_id"] . "</div>";
79-
echo cl_image_tag($photo["public_id"], array_merge($thumbs_params, array("crop" => "fill")));
85+
<?php
86+
echo "<div class='public_id'>" . $photo["public_id"] . "</div>";
87+
echo cl_image_tag($photo["public_id"], array_merge($thumbs_params, array("crop" => "fill")));
8088
?>
8189
</a>
82-
83-
<div class="less_info">
84-
<a href="#" class="toggle_info">More transformations...</a>
85-
</div>
86-
87-
<div class="more_info">
88-
<a href="#" class="toggle_info">Hide transformations...</a>
89-
<table class="thumbnails">
90-
<?php
91-
$thumbs = array(
92-
array("crop" => "fill", "radius" => 10),
93-
array("crop" => "scale"),
94-
array("crop" => "fit", "format" => "png"),
95-
array("crop" => "thumb", "gravity" => "face"),
96-
array("override" => true, "format" => "png", "angle" => 20, "transformation" =>
97-
array("crop" => "fill", "gravity" => "north", "width" => 150, "height" => 150, "effect" => "sepia")
98-
),
99-
);
100-
foreach($thumbs as $params) {
101-
$merged_params = array_merge((\Cloudinary::option_consume($params, "override")) ? array() : $thumbs_params, $params);
102-
echo "<td>";
103-
echo "<div class='thumbnail_holder'>";
104-
echo "<a target='_blank' href='" . cloudinary_url($photo["public_id"], $merged_params) . "'>" .
105-
cl_image_tag($photo["public_id"], $merged_params) . "</a>";
106-
echo "</div>";
107-
echo "<br/>";
108-
\PhotoAlbum\array_to_table($merged_params);
109-
echo "</td>";
110-
}
111-
?>
112-
113-
</table>
114-
115-
<div class="note">
116-
Take a look at our documentation of <a href="http://cloudinary.com/documentation/image_transformations" target="_blank">Image Transformations</a> for a full list of supported transformations.
117-
</div>
118-
</div>
90+
91+
<div class="less_info">
92+
<a href="#" class="toggle_info">More transformations...</a>
93+
</div>
94+
95+
<div class="more_info">
96+
<a href="#" class="toggle_info">Hide transformations...</a>
97+
<table class="thumbnails">
98+
<?php
99+
$thumbs = array(
100+
array("crop" => "fill", "radius" => 10),
101+
array("crop" => "scale"),
102+
array("crop" => "fit", "format" => "png"),
103+
array("crop" => "thumb", "gravity" => "face"),
104+
array(
105+
"override" => true,
106+
"format" => "png",
107+
"angle" => 20,
108+
"transformation" =>
109+
array("crop" => "fill",
110+
"gravity" => "north",
111+
"width" => 150,
112+
"height" => 150,
113+
"effect" => "sepia",
114+
),
115+
),
116+
);
117+
foreach ($thumbs as $params) {
118+
$merged_params = array_merge((\Cloudinary::option_consume($params, "override"))
119+
? array() : $thumbs_params, $params);
120+
echo "<td>";
121+
echo "<div class='thumbnail_holder'>";
122+
echo "<a target='_blank' href='" . cloudinary_url($photo["public_id"], $merged_params) . "'>" .
123+
cl_image_tag($photo["public_id"], $merged_params) . "</a>";
124+
echo "</div>";
125+
echo "<br/>";
126+
\PhotoAlbum\array_to_table($merged_params);
127+
echo "</td>";
128+
}
129+
?>
130+
131+
</table>
132+
133+
<div class="note">
134+
Take a look at our documentation of <a
135+
href="http://cloudinary.com/documentation/image_transformations" target="_blank">Image
136+
Transformations</a> for a full list of supported transformations.
137+
</div>
138+
</div>
119139
</div>
120-
<?php $index++; } ?>
121-
</div>
122-
</body>
140+
<?php $index++;
141+
} ?>
142+
</div>
143+
</body>
123144
</html>

0 commit comments

Comments
 (0)