示例#1
0
 private function _startThemeManager()
 {
     $themeManager = new TThemeManager();
     $themeManager->BasePath = "System.Wsat.themes";
     $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat'));
     $themeManager->BaseUrl = "{$url}/themes";
     $themeManager->init(null);
     $this->setThemeManager($themeManager);
 }
示例#2
0
 public function setOpFile($op_file_namespace)
 {
     $op_file = Prado::getPathOfNamespace($op_file_namespace);
     if (empty($op_file)) {
         throw new Exception("You need to fix your output folder namespace.");
     }
     if (!is_dir($op_file)) {
         mkdir($op_file, 0777, true);
     }
     $this->_opFile = $op_file;
 }
示例#3
0
 /**
  * @param string the parameter file path. It must be in namespace format
  * and the file extension is '.xml'.
  * @throws TInvalidOperationException if the module is initialized
  * @throws TConfigurationException if the file is invalid
  */
 public function setParameterFile($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable');
     } else {
         if (($this->_paramFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null || !is_file($this->_paramFile)) {
             throw new TConfigurationException('parametermodule_parameterfile_invalid', $value);
         }
     }
 }
示例#4
0
 /**
  * @param string external configuration file in namespace format. The file
  * must be suffixed with '.xml'.
  * @throws TInvalidDataValueException if the file is invalid.
  */
 public function setConfigFile($value)
 {
     if (($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null) {
         throw new TConfigurationException('soapservice_configfile_invalid', $value);
     }
 }
示例#5
0
 /**
  * @param string external configuration file in namespace format. The file
  * extension must be '.xml'.
  * @throws TConfigurationException if the file is invalid.
  */
 public function setConfigFile($value)
 {
     if (is_file($value)) {
         $this->_configFile = $value;
     } else {
         $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT);
         if ($file === null || !is_file($file)) {
             throw new TConfigurationException('sqlmap_configfile_invalid', $value);
         } else {
             $this->_configFile = $file;
         }
     }
 }
示例#6
0
 /**
  * @param string Namespace or path to XML document
  * @throws TInvalidDataValueException
  */
 public function setDocumentPath($value)
 {
     if (!is_file($value)) {
         $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE);
         if ($value === null) {
             throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value);
         }
     }
     $this->setViewState('DocumentPath', $value, '');
 }
示例#7
0
 /**
  * Registers the stylesheet for presentation.
  */
 protected function registerStyleSheet()
 {
     $cs = $this->getPage()->getClientScript();
     $cssFile = Prado::getPathOfNamespace('Prado\\Vendor\\TextHighlighter\\highlight', '.css');
     $cssKey = 'prado:TTextHighlighter:' . $cssFile;
     if (!$cs->isStyleSheetFileRegistered($cssKey)) {
         $cs->registerStyleSheetFile($cssKey, $this->publishFilePath($cssFile));
     }
 }
示例#8
0
 /**
  * @param string root directory (in namespace form) storing pages
  * @throws TInvalidOperationException if the service is initialized already or basepath is invalid
  */
 public function setBasePath($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('pageservice_basepath_unchangeable');
     } else {
         if (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) {
             throw new TConfigurationException('pageservice_basepath_invalid', $value);
         }
     }
     $this->_basePath = realpath($path);
 }
示例#9
0
 /**
  * Sets the translation configuration. Example configuration:
  * <code>
  * $config['type'] = 'XLIFF'; //XLIFF, gettext, Database or MySQL (deprecated)
  * $config['source'] = 'Path.to.directory'; // for types XLIFF and gettext
  * $config['source'] = 'connectionId'; // for type Database
  * $config['source'] = 'mysql://*****:*****@host/db'; // for type MySQL (deprecated)
  * $config['catalogue'] = 'messages'; //default catalog
  * $config['autosave'] = 'true'; //save untranslated message
  * $config['cache'] = 'true'; //cache translated message
  * $config['marker'] = '@@'; // surround untranslated text with '@@'
  * </code>
  * Throws exception is source is not found.
  * @param TMap|array configuration options
  */
 protected function setTranslationConfiguration($config)
 {
     if ($config['type'] == 'XLIFF' || $config['type'] == 'gettext') {
         if ($config['source']) {
             $config['source'] = Prado::getPathOfNamespace($config['source']);
             if (!is_dir($config['source'])) {
                 if (@mkdir($config['source']) === false) {
                     throw new TConfigurationException('globalization_source_path_failed', $config['source']);
                 }
                 chmod($config['source'], PRADO_CHMOD);
                 //make it deletable
             }
         } else {
             throw new TConfigurationException("invalid source dir '{$config['source']}'");
         }
     }
     if (isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) {
         $config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n';
         if (!is_dir($config['cache'])) {
             if (@mkdir($config['cache']) === false) {
                 throw new TConfigurationException('globalization_cache_path_failed', $config['cache']);
             }
             chmod($config['cache'], PRADO_CHMOD);
             //make it deletable
         }
     } else {
         unset($config['cache']);
     }
     $this->_translation = $config;
 }
示例#10
0
 /**
  * Preprocesses the template string by including external templates
  * @param string template string
  * @return string expanded template string
  */
 protected function preprocess($input)
 {
     if ($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
         for ($i = 0; $i < $n; ++$i) {
             $filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT);
             if ($filePath !== null && is_file($filePath)) {
                 $this->_includedFiles[] = $filePath;
             } else {
                 $errorLine = count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1)));
                 $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input);
             }
         }
         $base = 0;
         for ($i = 0; $i < $n; ++$i) {
             $ext = file_get_contents($this->_includedFiles[$i]);
             $length = strlen($matches[$i][0][0]);
             $offset = $base + $matches[$i][0][1];
             $this->_includeAtLine[$i] = count(explode("\n", substr($input, 0, $offset)));
             $this->_includeLines[$i] = count(explode("\n", $ext));
             $input = substr_replace($input, $ext, $offset, $length);
             $base += strlen($ext) - $length;
         }
     }
     return $input;
 }
示例#11
0
 /**
  * @param string directory (in namespace format) storing log files.
  * @throws TConfigurationException if log path is invalid
  */
 public function setLogPath($value)
 {
     if (($this->_logPath = Prado::getPathOfNamespace($value)) === null || !is_dir($this->_logPath) || !is_writable($this->_logPath)) {
         throw new TConfigurationException('filelogroute_logpath_invalid', $value);
     }
 }
示例#12
0
 /**
  * @param string database file path (in namespace form)
  * @throws TInvalidOperationException if the module is already initialized
  * @throws TConfigurationException if the file is not in proper namespace format
  */
 public function setDbFile($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('sqlitecache_dbfile_unchangeable');
     } else {
         if (($this->_file = Prado::getPathOfNamespace($value, self::DB_FILE_EXT)) === null) {
             throw new TConfigurationException('sqlitecache_dbfile_invalid', $value);
         }
     }
 }
示例#13
0
    /**
     * Publish the javascript
     */
    public function onPreRender($param)
    {
        parent::onPreRender($param);
        if (!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId'] == $this->getClientID()) {
            // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead
            $this->_errorCode = UPLOAD_ERR_FORM_SIZE;
            $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), ''));
            $fileName = addslashes($this->getFileName());
            $params = new TActiveFileUploadCallbackParams();
            $params->localName = $localName;
            $params->fileName = $fileName;
            $params->fileSize = $this->getFileSize();
            $params->fileType = $this->getFileType();
            $params->errorCode = $this->getErrorCode();
            echo <<<EOS
<script language="Javascript">
\tOptions = new Object();
\tOptions.clientID = '{$_GET['TActiveFileUpload_InputId']}';
\tOptions.targetID = '{$_GET['TActiveFileUpload_TargetId']}';
\tOptions.fileName = '{$params->fileName}';
\tOptions.fileSize = '{$params->fileSize}';
\tOptions.fileType = '{$params->fileType}';
\tOptions.errorCode = '{$params->errorCode}';
\tOptions.callbackToken = '{$this->pushParamsAndGetToken($params)}';
\tparent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options);
</script>
EOS;
        }
    }
示例#14
0
 /**
  * Gets the editor script base URL by publishing the tarred source via TTarAssetManager.
  * @return string URL base path to the published editor script
  */
 protected function getScriptDeploymentPath()
 {
     $tarfile = Prado::getPathOfNamespace('Vendor.pradosoft.prado-tinymce3.tiny_mce', '.tar');
     $md5sum = Prado::getPathOfNamespace('Vendor.pradosoft.prado-tinymce3.tiny_mce', '.md5');
     if ($tarfile === null || $md5sum === null) {
         throw new TConfigurationException('htmlarea_tarfile_invalid');
     }
     $url = $this->getApplication()->getAssetManager()->publishTarFile($tarfile, $md5sum);
     $this->copyCustomPlugins($url);
     return $url;
 }
示例#15
0
 /**
  * @param string user/role data file path (in namespace form). The file format is XML
  * whose content is similar to that user/role block in application configuration.
  * @throws TInvalidOperationException if the module is already initialized
  * @throws TConfigurationException if the file is not in proper namespace format
  */
 public function setUserFile($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('usermanager_userfile_unchangeable');
     } else {
         if (($this->_userFile = Prado::getPathOfNamespace($value, self::USER_FILE_EXT)) === null || !is_file($this->_userFile)) {
             throw new TConfigurationException('usermanager_userfile_invalid', $value);
         }
     }
 }
示例#16
0
 /**
  * @param string the base path for all themes. It must be in the format of a namespace.
  * @throws TInvalidDataValueException if the base path is not a proper namespace.
  */
 public function setBasePath($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('thememanager_basepath_unchangeable');
     } else {
         $this->_basePath = Prado::getPathOfNamespace($value);
         if ($this->_basePath === null || !is_dir($this->_basePath)) {
             throw new TInvalidDataValueException('thememanager_basepath_invalid', $value);
         }
     }
 }
示例#17
0
 /**
  * Sets the path storing all error and exception template files.
  * The path must be in namespace format, such as System.Exceptions (which is the default).
  * @param string template path in namespace format
  * @throws TConfigurationException if the template path is invalid
  */
 public function setErrorTemplatePath($value)
 {
     if (($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath)) {
         $this->_templatePath = $templatePath;
     } else {
         throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
     }
 }
示例#18
0
 /**
  * Saves the current UrlManager instance to cache.
  * @return boolean true if UrlManager instance was cached, false otherwise.
  */
 protected function cacheUrlManager($manager)
 {
     if ($this->getEnableCache()) {
         $cache = $this->getApplication()->getCache();
         if ($cache !== null) {
             $dependencies = null;
             if ($this->getApplication()->getMode() !== TApplicationMode::Performance) {
                 if ($manager instanceof TUrlMapping && ($fn = $manager->getConfigFile())) {
                     $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt());
                     $dependencies = new TFileCacheDependency($fn);
                 }
             }
             return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
         }
     }
     return false;
 }