PluginProbe
CSS & JavaScript Toolbox / 7.1
CSS & JavaScript Toolbox v7.1
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | models/package.php +33 -17 11.57.1 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // Disllow direct access.
7 7 defined('ABSPATH') or die('Access denied');
@@ -7,17 +7,17 @@
7 7 defined('ABSPATH') or die('Access denied');
8 8
9 9 // Import dependencies.
10 10 cssJSToolbox::import('framework:db:mysql:xtable.inc.php');
11 -
11 +
12 12 /**
13 -*
13 +*
14 14 */
15 15 class CJTPackageModel extends CJTHookableClass {
16 16
17 17 /**
18 18 * put your comment there...
19 - *
19 + *
20 20 * @var mixed
21 21 */
22 22 protected $params = array();
23 23
@@ -22,14 +22,14 @@
22 22 protected $params = array();
23 23
24 24 /**
25 25 * Delete single package.
26 - *
26 + *
27 27 * This method is going to delete the package
28 28 * and all the templates and blocks associated to it,
29 29 * therefor it'll unlink/break-down the relationship
30 30 * between those templates and blocks.
31 - *
31 + *
32 32 * @param Integer Package Id.
33 33 * @return CJTPackageModel Return $this.
34 34 */
35 35 public function delete($id) {
@@ -35,10 +35,10 @@
35 35 public function delete($id) {
36 36 // Initialize.
37 37 $modelTemplates = CJTModel::getInstance('templates-manager');
38 38 $dbd = cssJSToolbox::getInstance()->getDBDriver();
39 - $assoObjectsQueryTmp = 'SELECT objectId
40 - FROM #__cjtoolbox_package_objects
39 + $assoObjectsQueryTmp = 'SELECT objectId
40 + FROM #__cjtoolbox_package_objects
41 41 WHERE packageId = %d AND objectType = "%s" AND relType = "%s";';
42 42 // Delete the package.
43 43 CJTxTable::getInstance('package')
44 44 ->set('id', $id)
@@ -64,9 +64,9 @@
64 64 }
65 65
66 66 /**
67 67 * put your comment there...
68 - *
68 + *
69 69 * @param mixed $packageName
70 70 */
71 71 public function exists($packageName) {
72 72 // Load by name.
@@ -78,9 +78,9 @@
78 78 }
79 79
80 80 /**
81 81 * put your comment there...
82 - *
82 + *
83 83 */
84 84 public function getFileContent() {
85 85 // Get package ID.
86 86 $packageId = $_REQUEST['packageId'];
@@ -96,9 +96,9 @@
96 96 }
97 97
98 98 /**
99 99 * put your comment there...
100 - *
100 + *
101 101 * @param mixed $name
102 102 */
103 103 public function getParam($name) {
104 104 return isset($this->params[$name]) ? $this->params[$name] : null;
@@ -105,21 +105,37 @@
105 105 }
106 106
107 107 /**
108 108 * put your comment there...
109 - *
109 + *
110 110 * @param mixed $package
111 + * @param mixed $objects
112 + * @return CJTxTable
111 113 */
112 - public function save($package) {
114 + public function save($package, $types) {
113 115 // Add package.
114 - return CJTxTable::getInstance('package')
116 + $tablePackage = CJTxTable::getInstance('package')
115 117 ->setData($package)
116 - ->save()->get('id');
118 + ->save();
119 + // Add package objects map.
120 + $tablePackageObjects = CJTxTable::getInstance('package-objects');
121 + // Fetch objects under each type (block ,template).
122 + foreach ($types as $type => $objects) {
123 + // For each types get all object IDs!
124 + foreach ($objects as $object) {
125 + $tablePackageObjects->setItem() // Reset is needed as the object used accross multiple records
126 + // and might cause interfering between records!
127 + ->setData($object)
128 + ->set('packageId', $tablePackage->get('id'))
129 + ->set('objectType', $type)
130 + ->save();
131 + }
132 + }
117 133 }
118 -
134 +
119 135 /**
120 136 * put your comment there...
121 - *
137 + *
122 138 * @param mixed $name
123 139 * @param mixed $value
124 140 */
125 141 public function setParam($name, $value) {