Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
import_tools_manager.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset.inc';
18 
30 {
31 
32 
39  function Import_Tools_Manager($assetid=0)
40  {
41  $this->_ser_attrs = TRUE;
42  $this->Asset($assetid);
43 
44  }//end constructor
45 
46 
56  function create(&$link)
57  {
58  require_once SQ_CORE_PACKAGE_PATH.'/system/system_asset_fns.inc';
59  if (!system_asset_fns_create_pre_check($this)) {
60  return FALSE;
61  }
62  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
63 
64  if ($linkid = parent::create($link)) {
65  if (!system_asset_fns_create_cleanup($this)) {
66  $linkid = FALSE;
67  }
68  }
69 
70  if ($linkid) {
71  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
72  $this->installConverters();
73  } else {
74  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
75  }
76 
77  return $linkid;
78 
79  }//end create()
80 
81 
91  function _getName($short_name=FALSE)
92  {
93  return $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name');
94 
95  }//end _getName()
96 
97 
104  function canDelete()
105  {
106  return FALSE;
107 
108  }//end canDelete()
109 
110 
117  function canClone()
118  {
119  return FALSE;
120 
121  }//end canClone()
122 
123 
131  function _getAllowedLinks()
132  {
133  $itm_links = parent::_getAllowedLinks();
134  $itm_links[SQ_LINK_TYPE_1]['import_tool_converter'] = Array('card' => 'M', 'exclusive' => TRUE);
135 
136  return $itm_links;
137 
138  }//end _getAllowedLinks()
139 
140 
147  function installConverters()
148  {
149  $am = $GLOBALS['SQ_SYSTEM']->am;
150 
151  $converter_types = $am->getTypeDescendants('import_tool_converter');
152  $current_converters = $am->getLinks($this->id, SQ_LINK_TYPE_1, 'import_tool_converter', FALSE);
153 
154  $converter_types = array_flip($converter_types);
155 
156  foreach ($current_converters as $data) {
157  $installed_type_code = $data['minor_type_code'];
158  if (isset($converter_types[$installed_type_code])) {
159  unset($converter_types[$installed_type_code]);
160  }
161  }
162 
163  foreach ($converter_types as $type_code => $id) {
164  $this->installConverter($type_code);
165  }
166 
167  }//end installConverters()
168 
169 
178  function installConverter($type_code)
179  {
180  $am = $GLOBALS['SQ_SYSTEM']->am;
181  $am->includeAsset($type_code);
182 
183  $import_link = Array('asset' => &$this, 'link_type' => SQ_LINK_TYPE_1, 'is_exclusive' => 1);
184 
185  $new_converter = new $type_code;
186 
187  // Child Classes should have a default name set, so there is no need to set it here
188  $new_converter->create($import_link);
189 
190  }//end installConverter()
191 
192 
193 }//end class
194 
195 ?>