PluginProbe
CSS & JavaScript Toolbox / 11
CSS & JavaScript Toolbox v11
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
css-javascript-toolbox / models / package-file.php

package-file.php in CSS & JavaScript Toolbox 11, at models/package-file.php

90 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disllow direct access.
7 defined('ABSPATH') or die('Access denied');
8
9 /**
10 *
11 */
12 class CJTPackageFileModel extends CJTHookableClass {
13
14 /**
15 * put your comment there...
16 *
17 * @var mixed
18 */
19 protected $state = array();
20
21 /**
22 * put your comment there...
23 *
24 * @param mixed $property
25 */
26 public function getState($property) {
27 return isset($this->state[$property]) ? $this->state[$property] : null;
28 }
29
30 /**
31 * put your comment there...
32 *
33 * @param CJTPackageFile
34 */
35 public function install($package) {
36 // Get packages definition xml factory.
37 $factory = new CJT_Models_Package_Xml_Factory('models/package/xml/definition/package');
38 // Process the full document starting by the ROOT package tag down to the latest descendant.
39 $packageObject = $factory->create(null, 'package', $package->document()); // OBJECT CONSTR&UCTED HERE!
40 // Share vars to nodes.
41 $register = $packageObject->register();
42 $register->offsetSet('packageParser', $package);
43 // Process package object.
44 $packageObject->transit()
45 // Go down the tree.
46 ->processInners();
47 // Return package Id
48 return $register['packageId'];
49 }
50
51 /**
52 * put your comment there...
53 *
54 * @param mixed $packageFile
55 */
56 public function parse($name, $file) {
57 // Initialize.
58 $package = FALSE;
59 // Use a tmp dir with the same name as package without the extension.
60 $packageFileComponent = explode('.', $name);
61 $destinationDir = get_temp_dir() . $packageFileComponent[0];
62 // Import WP_FileSystem and unzip_file functions required to unzip the file.
63 require_once ABSPATH . 'wp-admin/includes/file.php';
64 // Initialize Wordpress file systems.
65 WP_Filesystem();
66 // Extract package archive in temporary location.
67 if (($result = unzip_file($file, $destinationDir)) === true) {
68 // Import package definition class.
69 cssJSToolbox::import('framework:packages:package.class.php');
70 $package = new CJTPackageFile($destinationDir);
71 }
72 return $package;
73 }
74
75 /**
76 * put your comment there...
77 *
78 * @param mixed $property
79 * @param mixed $state
80 */
81 public function setState($property, $state) {
82 // Set State!
83 $this->state[$property] = $state;
84 // Chaining.
85 return $this;
86 }
87 } // End class.
88
89 // Hookable!
90 CJTPackageFileModel::define('CJTPackageFileModel', array('hookType' => CJTWordpressEvents::HOOK_FILTER));