Exemple #1
1
 public function apply()
 {
     if (TinifyReport::isRunning()) {
         return $this->displayError($this->l('Tinify already running.'));
     }
     $output = '';
     $report = new TinifyReport();
     // Tinify
     try {
         \Tinify\setKey(Configuration::get('TINIFY_API_KEY'));
         \Tinify\validate();
         $report->beginTinify();
         foreach (DirList::getDirList() as $dir) {
             if ($dir->enabled) {
                 $this->tinifyDirectory($dir->path, $dir->recursive, $report);
             }
         }
         $output .= $this->displayConfirmation($this->l('Tinify finished successfully.'));
     } catch (\Tinify\AccountException $e) {
         $output .= $this->logError('Verify your account limit: ' . $e->getMessage(), $report);
     } catch (\Tinify\ClientException $e) {
         $output .= $this->logError('Check your source image and request options: ' . $e->getMessage(), $report);
     } catch (\Tinify\ServerException $e) {
         $output .= $this->logError('Temporary issue with the Tinify API: ' . $e->getMessage(), $report);
     } catch (\Tinify\ConnectionException $e) {
         $output .= $this->logError('A network connection error occurred: ' . $e->getMessage(), $report);
     } catch (Exception $e) {
         $output .= $this->logError('Unrelated exception: ' . $e->getMessage(), $report);
     }
     $report->endTinify();
     if (isset($this->logger)) {
         $this->logger->logInfo('Report ' . TinifyReport::getLast(true));
     }
     return $output;
 }
Exemple #2
0
<?php

/* You probably want to use this file literally, but as a guidance for your own template.php file.
 * Just take what you need. */
require_once 'inc/common.inc.php';
require_once 'inc/Statics.php';
require_once 'inc/Cache.php';
require_once 'inc/DirList.class.php';
$SLIDESHOWSIZE = 1280;
Statics::config(array('STATICPATH' => '/static1234/', 'REWRITE' => false));
Cache::config(array('CACHEPATH' => '/_cache/', 'CACHEURL' => '/cache/', 'BROKENPATH' => '/static1234/icon/broken.png'));
$d = new DirList(array('ICONPATH' => '/static1234/icon/', 'ICONURL' => '/static/icon/'));
$bodyClasses = array('body');
// helpful for a body.mobile class to allow mobile-specific styling
if (isMobile()) {
    $bodyClasses[] = 'mobile';
}
// catch and deal with any download requests. call this before any ensure-Functions
$d->checkDownload();
// lazy 'ensure' Functions ==> call before any output (i.e. header), to allow for redirect (in ensureThumbs)
$d->ensureThumbs(array(32, 128, $SLIDESHOWSIZE));
$d->ensureMetadata();
?>
<!DOCTYPE HTML>
<html lang="de-DE">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><?php 
echo implode(' | ', $d->path);
?>
</title>