private function save_user_page($user) { $path = NeechyPath::join($this->html_path(), 'new-page.md.php'); $page = Page::find_by_title($user->field('name')); $page->set('body', $this->t->render_partial_by_path($path)); $page->set('editor', 'NeechySystem'); $page->save(); return $page; }
private function load_handler() { $handler_app_path = NeechyPath::join(NEECHY_HANDLER_APP_PATH, $this->request->handler, 'handler.php'); $handler_core_path = NeechyPath::join(NEECHY_HANDLER_CORE_PATH, $this->request->handler, 'handler.php'); $HandlerClass = sprintf('%sHandler', ucwords($this->request->handler)); if (file_exists($handler_app_path)) { require_once $handler_app_path; } elseif (file_exists($handler_core_path)) { require_once $handler_core_path; } else { throw new NeechyWebServiceError(sprintf('handler %s not found', $this->request->handler), 404); } $handler = new $HandlerClass($this->request); return $handler; }
public static function create_on_install() { $pages_created = array(); $pages_dir = NeechyPath::join(NEECHY_APP_PATH, 'templates/core_pages'); $templater = NeechyTemplater::load(); foreach (self::$core_pages as $name) { $basename = sprintf('%s.md.php', $name); $path = NeechyPath::join($pages_dir, $basename); $page_body = $templater->render_partial_by_path($path); $page = Page::find_by_title($name); $page->set('body', $page_body); $page->set('editor', NEECHY_USER); $page->save(); $pages_created[] = $page; } return $pages_created; }
private function load_layout() { # First look in theme directory $layout_path = NeechyPath::join($this->theme_path, self::THEME_LAYOUT_PATH); if (file_exists($layout_path)) { return $this->buffer($layout_path); } # If not found there, default to core layout $layout_path = NeechyPath::join(NEECHY_ROOT, self::CORE_LAYOUT_PATH); return $this->buffer($layout_path); }
# # Version # define('NEECHY_VERSION', '0.1'); define('NEECHY_URL', 'https://github.com/klenwell/neechy'); # # Path Constants # define('NEECHY_ROOT', dirname(dirname(dirname(__FILE__)))); define('NEECHY_APP_PATH', NeechyPath::join(NEECHY_ROOT, 'app')); define('NEECHY_CONFIG_PATH', NeechyPath::join(NEECHY_ROOT, 'config')); define('NEECHY_CORE_PATH', NeechyPath::join(NEECHY_ROOT, 'core')); define('NEECHY_PUBLIC_PATH', NeechyPath::join(NEECHY_ROOT, 'public')); define('NEECHY_CONSOLE_PATH', NeechyPath::join(NEECHY_ROOT, 'console')); define('NEECHY_HANDLER_CORE_PATH', NeechyPath::join(NEECHY_CORE_PATH, 'handlers')); define('NEECHY_HANDLER_APP_PATH', NeechyPath::join(NEECHY_APP_PATH, 'handlers')); define('NEECHY_TASK_CONSOLE_PATH', NeechyPath::join(NEECHY_CONSOLE_PATH, 'tasks')); define('NEECHY_TASK_APP_PATH', NeechyPath::join(NEECHY_APP_PATH, 'tasks')); # # MySQL / Database Constants # define('MYSQL_ENGINE', 'MyISAM'); # # Regular Expression Patterns # define('RE_BRACKET_TOKENS', '/\\{\\{\\s*[^\\}]+\\}\\}/'); define('RE_EXTRACT_BRACKET_TOKEN_ID', '/[\\{\\}\\s]/'); # # Miscellaneous # define('NEECHY_USER', 'NeechySystem');
protected function register_admin_user($name, $email, $password) { $level = 'ADMIN'; # Create user and default page $user = User::register($name, $email, $password, $level); # Create default page $path = NeechyPath::join($this->html_path(), 'owner-page.md.php'); $page = Page::find_by_title($user->field('name')); $page->set('body', $this->read_page_body_from_template($path)); $page->set('editor', 'NeechySystem'); $page->save(); return $page; }
private function handler_path() { $handler_name = $this->action; $handler_app_path = NeechyPath::join(NEECHY_HANDLER_APP_PATH, $handler_name, 'handler.php'); $handler_core_path = NeechyPath::join(NEECHY_HANDLER_CORE_PATH, $handler_name, 'handler.php'); if (file_exists($handler_app_path)) { return $handler_app_path; } elseif (file_exists($handler_core_path)) { return $handler_core_path; } else { return NULL; } }
public static function root($sub_path = '') { $root = NeechyPath::abspath(NeechyPath::join(__DIR__, '../..')); return NeechyPath::join($root, $sub_path); }
private function assert_core_config_present() { $core_config_path = NeechyPath::join(NEECHY_ROOT, self::CORE_PATH); if (!file_exists($core_config_path)) { throw new NeechyConfigError(sprintf('Core config file [%s] missing', $core_config_path)); } return $core_config_path; }
protected function html_path() { return NeechyPath::join(NEECHY_HANDLER_CORE_PATH, $this->folder_name(), 'html'); }