public function __construct($filePath = null) { if ($filePath != null) { $this->html = file_to_string($filePath); } }
function upgrade_import_tool_configs() { $root_user =& $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user'); $GLOBALS['SQ_SYSTEM']->setCurrentUser($root_user); $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED); // update cms export path $import_manager = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('import_tools_manager'); $cms_export_dir = $import_manager->attr('cms_file_export_dir'); if (!empty($cms_export_dir) && strpos($cms_export_dir, '/') === 0) { $cms_export_dir_new = str_replace(SQ_SYSTEM_ROOT . '/', '', $cms_export_dir); if ($cms_export_dir_new !== $cms_export_dir) { $import_manager->setAttrValue('cms_file_export_dir', $cms_export_dir_new); $import_manager->saveAttributes(); echo "Updated Import Tools Manager CMS Export Path\n"; } else { echo "Absolute path found in form Import Tools Manager CMS FIle Export Dir. It can not be automatically converted to relative path. Location: {$cms_export_dir}\n"; } } // update STRUCTURED_FILE_IMPORT_DIR and BULK_FILE_IMPORT_DIR require_once SQ_FUDGE_PATH . '/general/file_system.inc'; $config_file = file_to_string(SQ_DATA_PATH . '/private/conf/import_tools_manager.inc'); if (strpos($config_file, SQ_SYSTEM_ROOT . '/') !== FALSE) { $config_file = str_replace(SQ_SYSTEM_ROOT . '/', '', $config_file); string_to_file($config_file, SQ_DATA_PATH . '/private/conf/import_tools_manager.inc'); echo "Updated Import Tools Manager Structed FIle Import and Bulk FIle Import Path\n"; } // update word import tool converter $converters = $GLOBALS['SQ_SYSTEM']->am->getChildren('1', 'import_tool_converter_word'); $converter = $GLOBALS['SQ_SYSTEM']->am->getAsset(array_pop(array_keys($converters))); $upload_directory = $converter->attr('upload_directory'); if (!empty($upload_directory) && strpos($upload_directory, '/') === 0) { $upload_directory_new = str_replace(SQ_SYSTEM_ROOT . '/', '', $upload_directory); if ($upload_directory_new !== $upload_directory) { $converter->setAttrValue('upload_directory', $upload_directory_new); $converter->saveAttributes(); echo "Updated Import Tools Manager Word Converter Path\n"; } else { echo "Absolute path found in form Import Tools Manager Word Converter. It can not be automatically converted to relative path. Location: {$upload_directory}\n"; } } // update file bridge config $config_file = file_to_string(SQ_DATA_PATH . '/private/conf/file_bridge.inc'); if (strpos($config_file, SQ_SYSTEM_ROOT . '/') !== FALSE) { $config_file = str_replace(SQ_SYSTEM_ROOT . '/', '', $config_file); string_to_file($config_file, SQ_DATA_PATH . '/private/conf/file_bridge.inc'); echo "Updated File Bridge Path\n"; } $GLOBALS['SQ_SYSTEM']->restoreRunLevel(); $GLOBALS['SQ_SYSTEM']->restoreCurrentUser(); }
$count = 0; $done_asset = 1; $bad_assetids = array(); // get all the assets in the system who are in safe edit status and have a thumbnail attached to it $sql = "SELECT assetid from sq_ast where status = '64' and assetid IN (select majorid from sq_ast_lnk where value = 'thumbnail')"; $results = MatrixDAL::executeSqlAssoc($sql); echo "Found " . count($results) . " assets that are in 'Safe Editing' status and has thumbnail applied.\n"; foreach ($results as $result) { $content = array(); echo "Updating {$done_asset} of " . count($results) . " Assets\r"; $assetid = $result['assetid']; $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid); $notice_link = $GLOBALS['SQ_SYSTEM']->am->getLink($assetid, SQ_LINK_NOTICE, '', TRUE, 'thumbnail'); // if file exists, write to it else create new one if (file_exists($asset->data_path . '/.sq_system/.sq_notice_links')) { $content = unserialize(file_to_string($asset->data_path . '/.sq_system/.sq_notice_links')); $thumbnail_exists = FALSE; foreach ($content as $link) { if ($link['value'] == 'thumbnail') { $thumbnail_exists = TRUE; break; } } $content[] = $notice_link; if (!$thumbnail_exists && !string_to_file(serialize($content), $asset->data_path . '/.sq_system/.sq_notice_links')) { print_r('Still writing :('); $count++; $bad_assetids[] = $assetid; } } else { $content[] = $notice_link;