function __construct() { /** * authentication **/ $auth = new WaxAuthDb(array("encrypt" => false, "db_table" => $this->auth_database_table, "session_key" => "wildfire_user_cookie")); $this->current_user = $auth->get_user(); if ($this->current_user->usergroup == 30) { $this->is_admin = true; } /** * module setup **/ $this->before_filter("all", "check_authorised", array("login")); $this->configure_modules(); $this->all_modules = CMSApplication::get_modules(true); if (!array_key_exists($this->module_name, CMSApplication::get_modules())) { Session::add_message('This component is not registered with the application.'); $this->redirect_to('/admin/home/index'); } /** * model instanciation **/ $this->cm_conf = CmsConfiguration::get("general"); if ($this->model_class) { $this->model = new $this->model_class($this->cm_conf['campaign_monitor_ClientID']); $this->model_name = WXInflections::underscore($this->model_class); } $this->sub_links["create"] = "Create New " . $this->display_name; $this->sub_links["view_subscriber"] = "View Subscribers"; $this->sub_links["view_segments"] = "View Segments"; if (!($this->this_page = WaxUrl::get("page"))) { $this->this_page = 1; } }
/** * MAIN FUNCTION - CALL IN YOUR controller_global * This chappy uses the url to find the section & content thats appropriate by calling a bunch of others * * If the url your requesting sets an action (ie the first part of the url after the controller) and that * action is a function within the controller then this will return false! */ protected function cms() { //check if this is paginated if ($page = Request::get('page')) { $this->this_page = $page; } //add preview bar to output if (Request::get("preview")) { WaxTemplate::add_response_filter("layout", "cms-preview-bar", array("model" => "CMSApplicationController", "method" => "add_preview_bar")); } //method exists check if ($this->is_public_method($this, WXInflections::underscore($this->action))) { return false; } if (!$this->use_format) { $this->use_format = "html"; } //get the content! $this->find_contents_by_path(); //set the view $this->pick_view(); //set the action if ($this->cms_content) { $this->action = "cms_content"; $this->build_crumb(); } //incremeant the page views counter if ($this->is_page()) { $this->cms_content->add_pageview(); } //you've found a page, but no section (this happens for pages within the home section as technically there is no 'home' in the url stack) if ($this->is_page() && $this->cms_content->id && !$this->cms_section) { $this->cms_section = $this->cms_content->section; } }
public function test_underscore() { $input = "CamelCaseWord"; $input2 = "a-dashed-word"; $input3 = "A Spaced Word"; $this->assertEqual(WXInflections::underscore($input), "camel_case_word"); $this->assertEqual(WXInflections::underscore($input2), "a_dashed_word"); $this->assertEqual(WXInflections::underscore($input3), "a_spaced_word"); }
public function __construct($persist = false) { if ($persist) { $this->persist = true; } $this->form_name = "wx_form_" . WXInflections::underscore(get_class($this)); $this->table = WXInflections::underscore(get_class($this)); if ($vals = Session::get($this->form_name)) { $this->row = $vals; } }
public function new_migration($name, $table = null) { if (is_array($name)) { $name = $name[0]; } $migrate = new WXMigrate(); $migrate->increase_version_latest(); $version = $migrate->get_version_latest(); $class = WXInflections::camelize($name, true); $this->final_output .= $this->start_php_file($class, "WXMigrate"); if ($table) { $this->final_output .= $this->add_function("up", sprintf(' \\$this->create_table(\\"%s\\");', $table) . "\n"); $this->final_output .= $this->add_function("down", sprintf(' \\$this->drop_table(\\"%s\\");', $table) . "\n"); } else { $this->final_output .= $this->add_function("up"); $this->final_output .= $this->add_function("down"); } $file = str_pad($version, 3, "0", STR_PAD_LEFT) . "_" . WXInflections::underscore($class); $res = $this->write_to_file(APP_DIR . "db/migrate/" . $file . ".php"); if (!$res) { $this->add_perm_error("app/db/migrate/" . $file . ".php"); return false; } $this->add_stdout("Created migration file at app/db/migrate/" . $file . ".php"); }
public function get_templates($action) { $view = WXInflections::underscore(get_class($this)) . "/" . $action; $html = VIEW_DIR . $view . ".html"; $txt = VIEW_DIR . $view . ".txt"; if (is_readable($html && is_readable($txt))) { $this->is_html(true); $this->body = WXControllerBase::view_to_string($view, $this); $this->alt_body = WXControllerBase::view_to_string($view, $this, "txt"); } elseif (is_readable($html)) { $this->is_html(true); $this->body = WXControllerBase::view_to_string($view, $this); } elseif (!is_readable($html) && is_readable($txt)) { $this->body = WXControllerBase::view_to_string($view, $this, "txt"); } }
public function dynamic_finders($func, $args) { $func = WXInflections::underscore($func); $finder = explode("by", $func); $what = explode("and", $finder[1]); foreach ($what as $key => $val) { $what[$key] = rtrim(ltrim($val, "_"), "_"); } if ($args) { if (count($what) == 2) { $conds = $what[0] . '=' . $this->pdo->quote($args[0]) . ' AND ' . $what[1] . '=' . $this->pdo->quote($args[1]); } else { $conds = $what[0] . '=' . $this->pdo->quote($args[0]); } if (is_array($args[1])) { if (isset($args[1]["conditions"])) { $conds .= " AND " . $args[1]["conditions"]; } $params = array_merge($args[1], array("conditions" => $conds)); } elseif (is_array($args[2])) { if (isset($args[2]["conditions"])) { $conds .= " AND " . $args[2]["conditions"]; } $params = array_merge($args[2], array("conditions" => $conds)); } else { $params = array("conditions" => $conds); } if ($finder[0] == "find_all_") { return $this->find_all($params); } else { return $this->find_first($params); } } }
public function dynamic_finders($func, $args) { $func = WXInflections::underscore($func); $finder = explode("by", $func); $what = explode("and", $finder[1]); foreach ($what as $key => $val) { $what[$key] = rtrim(ltrim($val, "_"), "_"); } if ($args) { if (count($what) == 2) { $this->filter(array($what[0] => $args[0], $what[1], $args[1])); } else { $this->filter(array($what[0] => $args[0])); } if (is_array($args[1])) { $params = $args[1]; } elseif (is_array($args[2])) { $params = $args[2]; } if ($finder[0] == "find_all_") { return $this->find_all($params); } else { return $this->find($params); } } }
/** * Construct method, initialises authentication, default model and menu items **/ function __construct() { /** * authentication **/ $auth = new WaxAuthDb(array("encrypt" => false, "db_table" => $this->auth_database_table, "session_key" => "wildfire_user_cookie")); $this->current_user = $auth->get_user(); if ($this->current_user->usergroup == 30) { $this->is_admin = true; } /** * module setup **/ $this->before_filter("all", "check_authorised", array("login")); $this->configure_modules(); $this->all_modules = CMSApplication::get_modules(true, $this->current_user->usergroup); if (!array_key_exists($this->module_name, CMSApplication::get_modules())) { Session::add_message('This component is not registered with the application.'); $this->redirect_to('/admin/home/index'); } /** * model instanciation **/ if ($this->model_class) { $this->model = new $this->model_class(); $this->model_name = WXInflections::underscore($this->model_class); if (!$this->scaffold_columns && is_array($this->model->column_info())) { $this->scaffold_columns = array_keys($this->model->column_info()); } } $this->sub_links["create"] = "Create New " . $this->display_name; if (!($this->this_page = WaxUrl::get("page"))) { $this->this_page = 1; } }