CMS  Version 3.9
component.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 require_once realpath(dirname(__FILE__)."/../../../../framework/data_item.inc");
40 
41 class Component extends DataItem
42 {
43  var $table = "component";
44  var $primary_key = "component_id";
45  var $default_format = "{getPrettyName()}";
46 
47  // Fields
48  var $fields = array("component_id" => Number,
49  "name" => String,
50  "version" => String,
51  "author" => String,
52  "description" => Text,
53  "priority" => Number,
54  "enabled" => Boolean,
55  "component_path" => String,
56  "last_modified" => Timestamp);
57 
58  // Relations
59  var $relations = array("ComponentPages" => ComponentPage);
60 
61  function ComponentPages()
62  {
63  $pages = Query::create(ComponentPage, "WHERE component=:i ORDER BY identifier")
64  ->bind(":i", $this->name)
65  ->execute();
66 
67  return $pages;
68  }
69 
70  function getPrettyName()
71  {
72  return prettify($this->name);
73  }
74 
75  static function formatOptions()
76  {
77  $options = array();
78 
79  $components = removeDuplicates(Query::create(Component, "ORDER BY name")->execute(), "name");
80  if(count($components) > 0)
81  {
82  foreach($components as $component)
83  {
84  $options[$component->name] = $component->name;
85  }
86  }
87 
88  return $options;
89  }
90 
91  static function getComponent($name)
92  {
93  return Query::create(Component, "WHERE name=:n")->bind(":n", $name)->executeSingle();
94  }
95 
96  function loadManifest()
97  {
98  Fakoli::using($this->name);
99  $cl = Fakoli::getComponentClassRoot($this->name)."Manifest";
100  if (class_exists($cl))
101  {
102  return new $cl;
103  }
104  else
105  {
106  return null;
107  }
108  }
109 }
110 ?>
$component
Definition: help.inc:38
$components
Definition: tree.inc:41
$name
Definition: upload.inc:54
static formatOptions()
Definition: component.inc:75
loadManifest()
Definition: component.inc:96
getPrettyName()
Definition: component.inc:70
ComponentPages()
Definition: component.inc:61
static getComponent($name)
Definition: component.inc:91
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static getComponentClassRoot($name)
Retrieves the capitalized camlCase name for the specified component.
Definition: core.inc:752
$pages
Definition: export.inc:38