Example #1
0
 /**
  * get a image by it's size
  * if url is entire url we will use it. if not we will use view baseUrl
  * 
  * @return String
  */
 public static function GetImageUrlBySize($surl, $width = null, $height = null)
 {
     $isExternal = self::_IsExternalUrl($surl);
     if ($isExternal) {
         $s3 = Zend_Registry::get('magzine-s3');
         $bucket = WeFlex_Application::GetInstance()->config->api->amazon->s3->bucket->issue;
         $lifetime = WeFlex_Application::GetInstance()->config->api->amazon->s3->lifetime;
         if ($width) {
             $durl = substr($surl, 0, strrpos($surl, '.')) . '_' . $width . 'x' . $height . substr($surl, strrpos($surl, '.'));
         } else {
             $durl = $surl;
         }
         //$durl = $s3->getAuthenticatedURL( $bucket, $durl, $lifetime , false , true );
         $durl = "http://" . $bucket . ".s3.amazonaws.com/" . $durl;
     } else {
         $view = Zend_Registry::get('view');
         if ($width) {
             $durl = substr($surl, 0, strrpos($surl, '.')) . '_' . $width . 'x' . $height . substr($surl, strrpos($surl, '.'));
         } else {
             $durl = $surl;
         }
         $durl = $view->baseUrl() . $durl;
     }
     return $durl;
 }
Example #2
0
 /**
  * @return WeFlex_Application
  */
 public static function GetInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 private static function _createAdapter()
 {
     $adapter = self::_getZendAdapterName(WeFlex_Application::GetInstance()->config->db->adapter);
     /**
      * $TODO check the following validate
      */
     $database = WeFlex_Application::GetInstance()->config->db->database;
     $username = WeFlex_Application::GetInstance()->config->db->user;
     $password = WeFlex_Application::GetInstance()->config->db->pwd;
     $host = WeFlex_Application::GetInstance()->config->db->host;
     /**
      * @todo if the adapter is exsit , we could not create it , and get it from registry
      */
     $zendAdapter = Zend_Db::factory($adapter, array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $database));
     /**
      * hack for debugger;
      */
     if (WeFlex_Application::GetInstance()->config->db->usefirephp) {
         $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
         $profiler->setEnabled(true);
         $zendAdapter->setProfiler($profiler);
     }
     $zendAdapter->getConnection();
     $zendAdapter->query("SET NAMES 'utf8'");
     return $zendAdapter;
 }
Example #4
0
 /**
  * Create a Zend_Db_Adapter_Abstract
  *
  * @param array $options
  * @return Zend_Db_Adapter_Abstract
  */
 public static function factory($options)
 {
     $adapter = self::_getZendAdapterName($options[WeFlex_Db::ADAPTER]);
     /**
      * $TODO check the following validate
      */
     $database = $options[WeFlex_Db::DATABASE];
     $username = $options[WeFlex_Db::USER];
     $password = $options[WeFlex_Db::PWD];
     $host = $options[WeFlex_Db::HOST];
     /**
      * @todo if the adapter is exsit , we could not create it , and get it from registry
      */
     $zendAdapter = Zend_Db::factory($adapter, array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $database));
     /**
      * hack for debugger;
      */
     if (WeFlex_Application::GetInstance()->config->db->usefirephp) {
         $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
         $profiler->setEnabled(true);
         $zendAdapter->setProfiler($profiler);
     }
     $zendAdapter->query("SET NAMES 'utf8'");
     return $zendAdapter;
 }
Example #5
0
 /**
  * add js file
  */
 public function appendJs($file)
 {
     $usingMergeJs = false;
     if (WeFlex_Application::GetInstance()->config->js && WeFlex_Application::GetInstance()->config->js->compress) {
         $usingMergeJs = WeFlex_Application::GetInstance()->config->js->compress;
     }
     if (!$usingMergeJs) {
         $this->view->headScript()->appendFile($this->view->baseUrl() . '/' . $file, 'text/javascript');
     }
 }
Example #6
0
 public static function GetLangFieldLang($filedName)
 {
     $langs = array_keys(WeFlex_Application::GetInstance()->getLangs());
     foreach ($langs as $lang) {
         $isInLang = strstr($filedName, $lang);
         if ($isInLang) {
             return $lang;
         }
     }
     return false;
 }
Example #7
0
 public function formal($index, $tempUrl)
 {
     $imageFileName = $this->_getImageFileName($tempUrl);
     $tempImagePath = WeFlex_Application::GetInstance()->getPublicPath() . $tempUrl;
     $regularDir = $this->_getRegularPath() . '/' . $index . '/';
     $regularImagePath = $regularDir . $imageFileName;
     $regularImageUrl = $this->_getRegularUrl() . '/' . $index . '/' . $imageFileName;
     $this->_mkDir($regularDir);
     $this->_copy($tempImagePath, $regularImagePath);
     $this->_generStandard($regularImagePath);
     return $regularImageUrl;
 }
Example #8
0
 private function _configSystemIni()
 {
     $this->config = WeFlex_Application::GetInstance()->configAll->stack;
 }
Example #9
0
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
define('APPLICATION_PUBLIC_PATH', realpath(dirname(__FILE__)));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), realpath(APPLICATION_PATH . '/library'), get_include_path())));
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('WeFlex');
$autoloader->registerNamespace('TCVM');
$autoloader->registerNamespace('Zend');
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
/**
 * application bootstrap;
 */
$application->bootstrap();
/**
 * WeFlex Start
 */
WeFlex_Application::GetInstance()->start(APPLICATION_ENV, APPLICATION_PATH . '/configs/tcvm.ini');
/**
 * Eccky Init
 */
TCVM::GetInstance()->init();
/**
 * application run
 */
$application->run();
Example #10
0
 private function _isFileNameInLangs($filedName)
 {
     $langs = array_keys(WeFlex_Application::GetInstance()->getLangs());
     foreach ($langs as $lang) {
         $isInLang = strstr($filedName, $lang);
         if ($isInLang) {
             return true;
         }
     }
     return false;
 }
Example #11
0
 /**
  * @param string $table
  * @return WeFlex_Db_Model
  */
 private function _initModel($table)
 {
     $options = array(WeFlex_Db::ADAPTER => WeFlex_Application::GetInstance()->config->db->adapter, WeFlex_Db::DATABASE => WeFlex_Application::GetInstance()->config->db->database, WeFlex_Db::HOST => WeFlex_Application::GetInstance()->config->db->host, WeFlex_Db::USER => WeFlex_Application::GetInstance()->config->db->user, WeFlex_Db::PWD => WeFlex_Application::GetInstance()->config->db->pwd, WeFlex_Db::TABLE => $table);
     $this->_dbModel = new WeFlex_Db_Model($options);
 }
Example #12
0
 private static function _getCountByConditions($table, $langFields, $conditions = null)
 {
     $baseModel = self::_generModel($table);
     $langs = array_keys(WeFlex_Application::GetInstance()->getLangs());
     $columns = array();
     foreach ($langs as $lang) {
         $table_lang = $table . '_lang' . $lang;
         $baseModel->joinLeft(array($table_lang => $table . '_lang'), $table_lang . '.parent = ' . $table . '.id');
         $baseModel->where(array($table_lang . '.lang' => $lang));
         foreach ($langFields as $langField) {
             $columns[] = array($langField . '_' . $lang => $table_lang . '.' . $langField);
         }
     }
     $columns[] = $table . '.*';
     $baseModel->columns($columns);
     if ($conditions) {
         $baseModel->where($conditions);
     }
     return $baseModel->count();
 }
Example #13
0
 protected function _getRegularPath()
 {
     $regularPath = WeFlex_Application::GetInstance()->config->public_path . $this->_uploadUrl;
     return $regularPath;
 }