-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin.php
84 lines (75 loc) · 1.85 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
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* This is a sample module for PyroCMS
*
* @author Jerel Unruh - PyroCMS Dev Team
* @website http://unruhdesigns.com
* @package PyroCMS
* @subpackage Sample Module
*/
class Plugin_Download extends Plugin
{
/**
* download link
* Usage:
*
* {{ download:link slug="slug" class="your_class" }}
*
* @return anchor tag
*/
function link()
{
$slug = $this->attribute('slug');
$class = $this->attribute('class');
$id = $this->attribute('id');
$target = $this->attribute('target');
$data = $this->db->where('slug', $slug)
->get('download')
->row_array();
if($data)
if($data['memberonly'] == 0 || is_logged_in())
return '<a href="'.site_url('download/file/'.$slug.'/'.$data['encrypted']).'" '. (($class)? 'class="'.$class.'"' : '') . (($id)? 'id="'.$id.'"' : '') . (($target)? 'target="'.$target.'"' : '') .'>'.$data['title'].'</a>';
return false;
}
/**
* download advance link
* Usage: for mor customize download link
*
* {{ download:link slug="slug" class="your_class" }}
*
* @return anchor tag
*/
function advance_link()
{
$slug = $this->attribute('slug');
$data = $this->db->where('slug', $slug)
->get('download')
->row_array();
if($data){
if($data['memberonly'] == 0 || is_logged_in()){
$data['href'] = site_url('download/file/'.$slug.'/'.$data['encrypted']);
return array($data);
}
}
return false;
}
/**
* download count
* Usage:
*
* {{ download:count slug="slug" class="your_class" }}
*
* @return integer download count result
*/
function count()
{
$slug = $this->attribute('slug');
$data = $this->db->where('slug', $slug)
->get('download')
->row_array();
if($data)
return $data['count'];
return "0";
}
}
/* End of file plugin.php */