Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
tool_export_files.inc
1 <?php
17 require_once SQ_SYSTEM_ROOT.'/core/assets/system/tool/tool.inc';
18 
32 class Tool_Export_Files extends Tool
33 {
34 
35 
42  function __construct($assetid=0)
43  {
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
58  static function paintTool(&$o, $type_code)
59  {
60  $filetypes = Array(
61  'folder' => 'D',
62  );
63 
64  $tool_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code);
65 
66  $am = $GLOBALS['SQ_SYSTEM']->am;
67  $itm = $am->getSystemAsset('import_tools_manager');
68 
69  $save_name = $itm->attr('cms_file_export_name');
70  $save_location = $itm->attr('cms_file_export_dir');
71 
72  $o->openSection($tool_info['name']);
73 
74  $o->openField(translate('cms_tool_export_files_root_node'));
75  multiple_asset_finder($type_code.'_root_node', Array(), $filetypes);
76  $o->note(translate('cms_tool_export_files_root_node_note'));
77  $o->closeField();
78 
79  $o->openField(translate('cms_tool_export_files_save_name'));
80  text_box($type_code.'_save_name', $save_name, 30);
81  $o->note(translate('cms_tool_export_files_save_name_note'));
82  $o->closeField();
83 
84  $o->openField(translate('cms_tool_export_files_save_location'));
85  text_box($type_code.'_save_location', $save_location, 30);
86  $o->note(translate('cms_tool_export_files_save_location_note'));
87  $o->closeField();
88 
89  $o->openField(translate('cms_tool_export_files_keep_structure'));
90  check_box($type_code.'_keep', 1, TRUE);
91  $o->note(translate('cms_tool_export_files_keep_structure_note'));
92  $o->closeField();
93 
94  $o->closeSection();
95 
96  }//end paintTool()
97 
98 
108  static function processTool(&$o, $type_code)
109  {
110  // error: root node not specified
111  if (!isset($_REQUEST[$type_code.'_root_node']) || empty($_REQUEST[$type_code.'_root_node'])) {
112  trigger_localised_error('CMS0100', E_USER_NOTICE);
113  return FALSE;
114  }//end if
115 
116  // error: save name not specified
117  if (!isset($_REQUEST[$type_code.'_save_name']) || empty($_REQUEST[$type_code.'_save_name'])) {
118  trigger_localised_error('CMS0101', E_USER_NOTICE);
119  return FALSE;
120  }//end if
121 
122  // error: save location not specified
123  if (!isset($_REQUEST[$type_code.'_save_location']) || empty($_REQUEST[$type_code.'_save_location'])) {
124  trigger_localised_error('CMS0102', E_USER_NOTICE);
125  return FALSE;
126  }//end if
127 
128  // error: save location not directory and not writable
129  if (!is_dir($_REQUEST[$type_code.'_save_location']) || !is_writable($_REQUEST[$type_code.'_save_location'])) {
130  trigger_localised_error('CMS0103', E_USER_NOTICE);
131  return FALSE;
132  }//end if
133 
134  // set HIPO running_vars
135  $vars['root_node'] = $_REQUEST[$type_code.'_root_node'];
136  $vars['save_name'] = $_REQUEST[$type_code.'_save_name'];
137  $vars['save_location'] = $_REQUEST[$type_code.'_save_location'];
138  $vars['keep_structure'] = (isset($_REQUEST[$type_code.'_keep']) && $_REQUEST[$type_code.'_keep']) ? TRUE : FALSE;
139 
140  // run HIPO job
141  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
142  $hh->queueHipo('hipo_job_tool_export_files', $vars, '', SQ_PACKAGES_PATH.'/cms/hipo_jobs');
143  $url = $hh->runQueuedJobs();
144  if (!empty($url)) $o->setRedirect($url);
145 
146  }//end processTool()
147 
148 
149 }//end class
150 
151 
152 ?>