예제 #1
0
 /**
  * Overload saving to set the created time and to create a new token
  * when the object is saved.
  */
 public function save()
 {
     if ($this->loaded === FALSE) {
         $this->created = time();
         $this->apikey = text::random('alnum', 8);
         $this->token = $this->create_token();
         parent::save();
         # auto create a new tconfig.
         $new_tconfig = ORM::factory('tconfig');
         $new_tconfig->owner_id = $this->id;
         $new_tconfig->save();
         # add 3 sample testimonials to get the party started.
         $testimonial = ORM::factory('testimonial');
         $testimonial->owner_id = $this->id;
         $testimonial->name = 'Stephanie Lo';
         $testimonial->company = 'World United';
         $testimonial->c_position = 'Founder';
         $testimonial->url = 'worldunited.com';
         $testimonial->location = 'Berkeley, CA';
         $testimonial->rating = 5;
         $testimonial->body = 'The interface is simple and directed. I have a super busy schedule and did not want to waste any time learning yet another website. Pluspanda values my time. Thanks!';
         $testimonial->publish = 1;
         $testimonial->save();
         $testimonial->clear();
         $testimonial->owner_id = $this->id;
         $testimonial->name = 'John Doe';
         $testimonial->company = 'Super Company!';
         $testimonial->c_position = 'President';
         $testimonial->url = 'supercompany.com';
         $testimonial->location = 'Atlanta, Georgia';
         $testimonial->rating = 5;
         $testimonial->body = 'This is a sample testimonial for all to see.';
         $testimonial->publish = 1;
         $testimonial->save();
         $testimonial->clear();
         $testimonial->owner_id = $this->id;
         $testimonial->name = 'Jane Smith';
         $testimonial->company = 'Widgets R Us';
         $testimonial->c_position = 'Sales Manager';
         $testimonial->url = 'widgetsrus.com';
         $testimonial->location = 'Los Angeles, CA';
         $testimonial->rating = 5;
         $testimonial->body = 'Pluspanda makes our testimonials look great! Our widget sales our up 200% Thanks Pluspanda!';
         $testimonial->publish = 1;
         $testimonial->save();
         # copy stock testimonial css to user data folder
         $src = DOCROOT . 'static/css/testimonials/stock';
         $dest = t_paths::css($this->apikey);
         dir::copy($src, $dest);
         return;
     }
     return parent::save();
 }
예제 #2
0
 /**
  * 创建项目运行目录
  * @access private
  * @return void
  */
 public static function mkDirs()
 {
     if (is_dir(APP_COMMON_PATH)) {
         return;
     }
     //目录
     $dirs = array(APP_PATH, TEMP_PATH, APP_COMMON_PATH, APP_CONFIG_PATH, APP_ADDON_PATH, APP_MODEL_PATH, APP_CONTROLLER_PATH, APP_LANGUAGE_PATH, APP_HOOK_PATH, APP_TAG_PATH, APP_LIB_PATH, APP_COMPILE_PATH, APP_CACHE_PATH, APP_TABLE_PATH, APP_LOG_PATH, MODULE_CONTROLLER_PATH, MODULE_CONFIG_PATH, MODULE_LANGUAGE_PATH, MODULE_MODEL_PATH, MODULE_HOOK_PATH, MODULE_TAG_PATH, MODULE_LIB_PATH, MODULE_VIEW_PATH, CONTROLLER_VIEW_PATH, MODULE_PUBLIC_PATH, STATIC_PATH);
     foreach ($dirs as $d) {
         if (!dir_create($d, 0755)) {
             header("Content-type:text/html;charset=utf-8");
             exit("目录{$d}创建失败,请检查权限");
         }
     }
     //复制视图
     is_file(CONTROLLER_VIEW_PATH . "index.html") or copy(HDPHP_PATH . 'Lib/Tpl/view.html', CONTROLLER_VIEW_PATH . "index.html");
     //复制公共模板文件
     is_file(MODULE_PUBLIC_PATH . "success.html") or copy(HDPHP_PATH . 'Lib/Tpl/success.html', MODULE_PUBLIC_PATH . "success.html");
     is_file(MODULE_PUBLIC_PATH . "error.html") or copy(HDPHP_PATH . 'Lib/Tpl/error.html', MODULE_PUBLIC_PATH . "error.html");
     //复制模块配置文件
     is_file(MODULE_CONFIG_PATH . "config.php") or copy(HDPHP_PATH . 'Lib/Tpl/configModule.php', MODULE_CONFIG_PATH . "config.php");
     is_file(APP_CONFIG_PATH . "config.php") or copy(HDPHP_PATH . 'Lib/Tpl/configApp.php', APP_CONFIG_PATH . "config.php");
     //创建测试控制器
     is_file(MODULE_CONTROLLER_PATH . 'IndexController.class.php') or file_put_contents(MODULE_CONTROLLER_PATH . 'IndexController.class.php', file_get_contents(HDPHP_PATH . 'Lib/Tpl/controller.php'));
     //创建安全文件
     self::safeFile();
     //批量创建模块
     if (defined('MODULE_LIST')) {
         $module = explode(',', MODULE_LIST);
         if (!empty($module)) {
             foreach ($module as $m) {
                 dir::create(APP_PATH . $m);
                 dir::copy(MODULE_PATH, APP_PATH . $m);
             }
         }
     }
 }
예제 #3
0
파일: statify.php 프로젝트: nsteiner/kdoc
 * 5. Test your site
 */
// Setup the base url for your site here
$url = 'http://nsteiner.github.io/kdoc';
// Don't touch below here
define('DS', DIRECTORY_SEPARATOR);
// load the cms bootstrapper
include __DIR__ . DS . 'kirby' . DS . 'bootstrap.php';
$kirby = kirby();
$kirby->urls->index = $url;
$site = $kirby->site();
if ($site->multilang()) {
    die('Multilanguage sites are not supported');
}
dir::copy(__DIR__ . DS . 'assets', __DIR__ . DS . 'static' . DS . 'assets');
dir::copy(__DIR__ . DS . 'content', __DIR__ . DS . 'static' . DS . 'content');
// set the timezone for all date functions
date_default_timezone_set($kirby->options['timezone']);
// load all extensions
$kirby->extensions();
// load all plugins
$kirby->plugins();
// load all models
$kirby->models();
// load all language variables
$kirby->localize();
foreach ($site->index() as $page) {
    $site->visit($page->uri());
    $html = $kirby->render($page);
    if ($page->isHomePage()) {
        $root = __DIR__ . DS . 'static' . DS . 'index.html';