PageRenderTime 27ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php

https://github.com/decaoz/zf1
PHP | 58 lines | 35 code | 21 blank | 2 comment | 2 complexity | e69f69e78238893a9184b7ec3c2f4a1e MD5 | raw file
 1<?php
 2
 3require_once dirname(__FILE__) . '/../../common.php';
 4
 5
 6system('clear');
 7
 8$cacheId = md5(__FILE__);
 9
10$cacheFrontendOptions = array(
11    'lifetime' => 2592000, // 30 days
12    'automatic_serialization' => true
13);
14
15$cacheBackendOptions = array(
16    'cache_dir' => dirname(__FILE__) . '/cache'
17);
18
19$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
20
21if (! $fonts = $cache->load($cacheId)) {
22    
23    // Cache miss. Connect to backend service (expensive).
24    
25    $mailMerge = new Zend_Service_LiveDocx_MailMerge();
26    
27    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
28              ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
29    
30    $fonts = $mailMerge->getFontNames();
31    
32    $cache->save($fonts, $cacheId);
33    
34    unset($mailMerge);
35    
36} else {
37    
38    // Cache hit. Continue.
39    
40}
41
42unset($cache);
43
44print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
45    PHP_EOL . 'Supported Fonts' .
46    PHP_EOL . 
47    PHP_EOL . 'The following fonts are installed on the backend server and may be used in templates. Fonts used in templates, which are NOT listed below, will be substituted. If you would like to use a font, which is not installed on the backend server, please contact your LiveDocx provider.' .
48    PHP_EOL . 
49    PHP_EOL . '(Note this method call is cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' .
50    PHP_EOL . 
51    PHP_EOL . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($fonts) . 
52    PHP_EOL . 
53    PHP_EOL)
54);
55
56print(PHP_EOL);
57
58unset($mailMerge);