当前位置: 首页>>代码示例>>PHP>>正文


PHP AppConfig::GetTemplateFiles方法代码示例

本文整理汇总了PHP中AppConfig::GetTemplateFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP AppConfig::GetTemplateFiles方法的具体用法?PHP AppConfig::GetTemplateFiles怎么用?PHP AppConfig::GetTemplateFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppConfig的用法示例。


在下文中一共展示了AppConfig::GetTemplateFiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Generate

 /**
  * Generate the application based on the selected tables and options
  */
 public function Generate()
 {
     // check for all required fields
     if (empty($_REQUEST["table_name"])) {
         throw new Exception("Please select at least one table to generate");
     }
     $cstring = $this->GetConnectionString();
     // initialize the database connection
     $handler = new DBEventHandler();
     $connection = new DBConnection($cstring, $handler);
     $server = new DBServer($connection);
     $dbSchema = new DBSchema($server);
     $debug = isset($_REQUEST["debug"]) && $_REQUEST["debug"] == "1";
     $parameters = array();
     $tableNames = $_REQUEST["table_name"];
     $packageName = $_REQUEST["package"];
     $debug_output = "";
     $selectedTables = array();
     foreach ($tableNames as $tableName) {
         $selectedTables[] = $dbSchema->Tables[$tableName];
     }
     // see if arbitrary parameters were passed in - in which case they will be passed through to the templates
     $tmp = RequestUtil::Get('parameters');
     if ($tmp) {
         $pairs = explode("\n", str_replace("\r", "", $tmp));
         foreach ($pairs as $pair) {
             list($key, $val) = explode("=", $pair, 2);
             $parameters[$key] = $val;
         }
     }
     // check for required parameters
     if (!array_key_exists('max_items_in_topnav', $parameters)) {
         $parameters['max_items_in_topnav'] = self::$DEFAULT_MAX_ITEMS_IN_TOPNAV;
     }
     $zipFile = new zipfile();
     $codeRoot = GlobalConfig::$APP_ROOT . '/code/';
     $tempRoot = GlobalConfig::$APP_ROOT . '/temp/';
     // initialize smarty
     $smarty = new Smarty();
     $smarty->template_dir = $codeRoot;
     $smarty->compile_dir = $tempRoot;
     $smarty->config_dir = $tempRoot;
     $smarty->cache_dir = $tempRoot;
     $smarty->caching = false;
     $appname = RequestUtil::Get("appname");
     $appRoot = RequestUtil::Get("appRoot");
     $includePath = RequestUtil::Get("includePath");
     $includePhar = RequestUtil::Get("includePhar");
     $enableLongPolling = RequestUtil::Get("enableLongPolling");
     $config = new AppConfig($codeRoot . $packageName);
     foreach ($config->GetTemplateFiles() as $templateFile) {
         if ($templateFile->generate_mode == 3) {
             if ($includePhar == '1') {
                 // proceed, copy the phar file
                 $templateFile->generate_mode = 2;
             } else {
                 // skip the phar file
                 continue;
             }
         }
         if ($templateFile->generate_mode == 2) {
             // this is a template that is copied without parsing to the project (ie images, static files, etc)
             $templateFilename = str_replace(array('{$appname}', '{$appname|lower}', '{$appname|upper}'), array($appname, strtolower($appname), strtoupper($appname)), $templateFile->destination);
             $contents = file_get_contents($codeRoot . $templateFile->source);
             // this is a direct copy
             if ($debug) {
                 $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . "(contents of " . $codeRoot . $templateFile->source . ")\r\n";
             } else {
                 $zipFile->addFile($contents, $templateFilename);
             }
         } elseif ($templateFile->generate_mode == 1) {
             // single template where one is generated for the entire project instead of one for each selected table
             $templateFilename = str_replace(array('{$appRoot}', '{$appRoot|lower}', '{$appRoot|upper}'), array($appRoot, strtolower($appRoot), strtoupper($appRoot)), $templateFile->destination);
             $smarty->clearAllAssign();
             foreach ($parameters as $key => $val) {
                 $smarty->assign($key, $val);
             }
             $smarty->assign("tableNames", $tableNames);
             $smarty->assign("templateFilename", $templateFilename);
             $smarty->assign("schema", $dbSchema);
             $smarty->assign("tables", $dbSchema->Tables);
             $smarty->assign("connection", $cstring);
             $smarty->assign("appname", $appname);
             $smarty->assign("appRoot", $appRoot);
             $smarty->assign("includePath", $includePath);
             $smarty->assign("includePhar", $includePhar);
             $smarty->assign("enableLongPolling", $enableLongPolling);
             $smarty->assign("PHREEZE_VERSION", Phreezer::$Version);
             $tableInfos = array();
             // add all tables to a tableInfos array that can be used for cross-referencing by table name
             foreach ($dbSchema->Tables as $table) {
                 if ($table->GetPrimaryKeyName()) {
                     $tableName = $table->Name;
                     $tableInfos[$tableName] = array();
                     $tableInfos[$tableName]['table'] = $dbSchema->Tables[$tableName];
                     $tableInfos[$tableName]['singular'] = $_REQUEST[$tableName . "_singular"];
                     $tableInfos[$tableName]['plural'] = $_REQUEST[$tableName . "_plural"];
//.........这里部分代码省略.........
开发者ID:joaoricardorm,项目名称:phreeze,代码行数:101,代码来源:GeneratorController.php


注:本文中的AppConfig::GetTemplateFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。