示例#1
0
 /**
  *
  * @return type 
  */
 public function getConfig()
 {
     if (FALSE == ($config = App_Cache::load($this->_idCache))) {
         $config = $this->getCurrentConfig();
         App_Cache::save($config, $this->_idCache);
     }
     return $config;
 }
示例#2
0
 /**
  * 
  */
 private static function initCache()
 {
     if (null == self::$_cache) {
         $frontendOptions = array('lifetime' => 86400, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_PATH . '/cache');
         self::$_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     }
 }
示例#3
0
 /**
  *
  * @return boolean 
  */
 public function fixPhones()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $tables = array('PerData' => array('client_fone'));
         $now = App_Cache::load('current_fix_phone');
         if (empty($now)) {
             $now = 0;
         }
         $fixed = 0;
         $step = 2000;
         echo 'Step: ' . $step . ' - now: ' . $now . "\n\r";
         foreach ($tables as $table => $fields) {
             $db = App_Model_DbTable_Factory::get($table);
             $rows = $db->fetchAll(array(), array(), $step, $now);
             foreach ($rows as $row) {
                 $altered = false;
                 foreach ($fields as $field) {
                     $newPhone = App_General_String::cleanFone($row[$field]);
                     if (!empty($newPhone)) {
                         $row[$field] = $newPhone;
                         $altered = true;
                     }
                 }
                 if ($altered) {
                     $row->save();
                     $fixed++;
                 }
             }
         }
         $now += $step;
         App_Cache::save($now, 'current_fix_phone');
         $dbAdapter->commit();
         echo number_format($fixed, 0, '', '.') . ' Phones fixed' . "\n\r";
         echo str_repeat('-', 30) . "\n\r";
         return true;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         echo 'Error fixing phones: ' . $e->getMessage() . "\n\r";
         return false;
     }
 }
示例#4
0
 /**
  * 
  */
 public function imageAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $id = $this->_getParam('id');
     $dataReport = $this->_session->dataReport;
     if (!empty($dataReport)) {
         $imageData = $dataReport['graph'][$id];
         App_Cache::save($imageData, $id);
     } else {
         $imageData = App_Cache::load($id);
     }
     $resource = imagecreatefromstring($imageData);
     header('Content-type: image/png');
     imagepng($resource);
 }
示例#5
0
文件: Docx.php 项目: fredcido/simuweb
 /**
  *
  * @return boolean 
  */
 protected function _addGraphs()
 {
     $xpath = new DOMXPath($this->_dom);
     $graphs = $xpath->query('//div[@class="graphs"]', $this->_content);
     if (empty($graphs->length)) {
         return false;
     }
     $images = $graphs->item(0)->getElementsByTagName('img');
     foreach ($images as $img) {
         $src = $img->getAttribute('src');
         $src = preg_replace('/^.+image\\/id\\//i', '', $src);
         $src = preg_replace('/\\/image.png$/i', '', $src);
         $contents = App_Cache::load($src);
         $randomName = App_General_String::randomHash();
         $fileName = $this->_tempDir . DIRECTORY_SEPARATOR . $randomName . '.png';
         file_put_contents($fileName, $contents);
         $size = getimagesize($fileName);
         $this->_mainSection->addImage($fileName, array('align' => 'center', 'width' => 675, 'height' => $size[1]));
     }
     return true;
 }
示例#6
0
 /**
  *
  * @return boolean 
  */
 protected function _addGraphs()
 {
     $xpath = new DOMXPath($this->_dom);
     $graphs = $xpath->query('//div[@class="graphs"]', $this->_content);
     if (empty($graphs->length)) {
         return false;
     }
     $images = $graphs->item(0)->getElementsByTagName('img');
     foreach ($images as $img) {
         $src = $img->getAttribute('src');
         $src = preg_replace('/^.+image\\/id\\//i', '', $src);
         $src = preg_replace('/\\/image.png$/i', '', $src);
         $contents = App_Cache::load($src);
         $randomName = App_General_String::randomHash();
         $fileName = $this->_tempDir . DIRECTORY_SEPARATOR . $randomName . '.png';
         file_put_contents($fileName, $contents);
         $size = getimagesize($fileName);
         $position = PHPExcel_Cell::stringFromColumnIndex($this->_startCol) . ($this->_currentRow += 2);
         $objDrawing = new PHPExcel_Worksheet_Drawing();
         $objDrawing->setPath($fileName)->setResizeProportional(true)->setCoordinates($position)->setWorksheet($this->_mainSheet);
         $this->_currentRow += ceil($size[1] / 25) + 4;
     }
     return true;
 }
示例#7
0
 /**
  * (non-PHPdoc)
  * @see Zend_Db_Table_Abstract::delete()
  */
 public function delete($where)
 {
     $return = parent::delete($where);
     App_Cache::remove($this->getTableName());
     return $return;
 }