Ejemplo n.º 1
0
/**
 * retorna a url absoluta da miniatura de uma imagem ou vídeo gravado pelo usuário
 * @param int $id
 * @return string
 */
function getThumbUrlById($id)
{
    $ci =& get_instance();
    if (!$id) {
        return;
    }
    $product = getProductById($id);
    $thumb = imgToThumb($product['image']);
    return uploadUrl() . "image/" . $thumb;
}
Ejemplo n.º 2
0
/**
* Install a template from an HTTP URL
* @param string The URL option
*/
function installFromUrl($installerClass, $option, $element, $client)
{
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        $message = new mosError(T_('The installer can\'t continue before zlib is installed'), _MOS_ERROR_FATAL);
        HTML_installer::showInstallMessage($message, 'Installer - Error', returnTo($option, $element, $client));
        exit;
    }
    $userurl = mosGetParam($_REQUEST, 'userurl', '');
    if (!$userurl || $userurl[0] == 'http://') {
        $message = new mosError(T_('Please select an HTTP URL'), _MOS_ERROR_FATAL);
        HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo($option, $element, $client));
        exit;
    }
    foreach ($userurl as $value) {
        $url_data = parse_url($value);
        if (isset($url_data['path'])) {
            $userfilename = basename($url_data['path']);
        } else {
            $userfilename = '';
        }
        if (!$userfilename) {
            $message = new mosError(T_('The URL did not define a file name'), _MOS_ERROR_FATAL);
            HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo($option, $element, $client));
        }
        if (uploadUrl($value, $userfilename, $message)) {
            $installer = new $installerClass();
            if (!$installer->extractArchive($userfilename)) {
                $installer->cleanUpInstall();
                HTML_installer::showInstallMessage($installer->getErrors(), T_('Upload ') . $element . ' - ' . T_('Failed'), returnTo($option, $element, $client));
            }
            $ret = $installer->install();
            $installer->cleanUpInstall();
            HTML_installer::showInstallMessage($installer->getErrors(), T_('Upload ') . $element . ' - ' . ($ret ? T_('Success') : T_('Failed')), returnTo($option, $element, $client));
        } else {
            HTML_installer::showInstallMessage($message, T_('Upload ') . $element . ' - ' . T_('Error'), returnTo($option, $element, $client));
        }
    }
}