-
Notifications
You must be signed in to change notification settings - Fork 24
/
plugin.php
121 lines (107 loc) · 2.5 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Galleries Plugin
*
* Create a list of images
*
* @package PyroCMS
* @author Jerel Unruh - PyroCMS Dev Team
* @copyright Copyright (c) 2008 - 2010, PyroCMS
*
*/
class Plugin_Galleries extends Plugin
{
/**
* Image List
*
* Creates a list of gallery images
*
* Usage:
*
* {{ galleries:images slug="nature" limit="5" }}
* <a href="{{ url:base }}galleries/{{ gallery_slug }}/{{ id }}" title="{{ name }}">
* <img src="{{ url:site }}files/thumb/{{ file_id }}/75/75" alt="{{ description }}"/>
* </a>
* {{ /galleries:images }}
*
* The following is a list of tags that are available to use from this method
*
* {{ file_id }}
* {{ folder_id }}
* {{ gallery_id }}
* {{ gallery_slug }}
* {{ title }}
* {{ order }}
* {{ name }}
* {{ filename }}
* {{ description }}
* {{ extension }}
*
* @return array
*/
function images()
{
$limit = $this->attribute('limit');
$slug = $this->attribute('slug');
$offset = $this->attribute('offset');
$this->load->model(array(
'gallery_m',
'gallery_image_m'
));
$gallery = $this->gallery_m->get_by('slug', $slug);
return $gallery ? $this->gallery_image_m->get_images_by_gallery($gallery->id, array(
'limit' => $limit,
'offset' => $offset
)) : array();
}
/**
* Gallery exists
*
* Check if a gallery exists
*
* @return int 0 or 1
*/
function exists()
{
$slug = $this->attribute('slug');
$this->load->model('gallery_m');
return (int) ($slug ? $this->gallery_m->count_by('slug', $slug) > 0 : FALSE);
}
/**
* Gallery List
*
* Creates a list of galleries
*
* Usage:
*
* {{ galleries:listing limit="5" }}
* <a href="{{ url:base }}galleries/{{ slug }}/{{ id }}" title="{{ name }}">
* <img src="{{ url:site }}files/thumb/{{ file_id }}/75/75" alt="{{ description }}"/>
* </a>
* {{ /galleries:listing }}
*
* The following is a list of tags that are available to use from this method
*
* {{ id }}
* {{ title }}
* {{ slug }}
* {{ folder_id }}
* {{ thumbnail_id }}
* {{ description }}
* {{ filename }}
* {{ extension }}
*
* @return array
*/
function listing()
{
$limit = $this->attribute('limit');
$offset = $this->attribute('offset');
$this->load->model(array(
'gallery_m'
));
$galleries = $this->gallery_m->get_all_with_filename(NULL,NULL,$limit);
return $galleries ? $galleries : array();
}
}
/* End of file plugin.php */