Пример #1
0
 public function api_load_extensions()
 {
     $times = Time::all();
     $counter = 0;
     foreach ($times as $time) {
         $extension_test_project = Extension::find(array('conditions' => array('value = ?', $time->project_name)));
         $extension_test_service = Extension::find(array('conditions' => array('value = ?', $time->service_name)));
         if ($extension_test_project == null && $time->project_name != null) {
             $create = Extension::create(array('parent' => NULL, 'value' => $time->project_name));
             $counter++;
         }
         if ($extension_test_service == null && $time->service_name != null) {
             if ($extension_test_project == null && $time->project_name != null) {
                 $extension_test_project = Extension::find(array('conditions' => array('value = ?', $time->project_name)));
             }
             $create = Extension::create(array('parent' => $extension_test_project->id, 'value' => $time->service_name));
             $counter++;
         }
     }
     echo $counter;
 }
Пример #2
0
 public function search()
 {
     if (empty($_GET['query'])) {
         exit;
     }
     # TODO
     $config = Config::current();
     if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) {
         # Searches with / and clean URLs = server 404
         redirect("search/" . urlencode($_GET['query']) . "/");
     }
     if (empty($_GET['query'])) {
         return Flash::warning(__("Please enter a search term."));
     }
     list($where, $params) = keywords($_GET['query'], "name LIKE :query OR url LIKE :query", "extensions");
     $extensions = Extension::find(array("placeholders" => true, "where" => $where, "params" => $params));
     list($where, $params) = keywords($_GET['query'], "description LIKE :query OR tags LIKE :query", "versions");
     $versions = Version::find(array("placeholders" => true, "where" => $where, "params" => $params));
     list($where, $params) = keywords($_GET['query'], "body LIKE :query", "notes");
     $notes = Note::find(array("placeholders" => true, "where" => $where, "params" => $params));
     $this->display("extend/search", array("extensions" => new Paginator($extensions, 25, "extensions_page"), "versions" => new Paginator($versions, 25, "versions_page"), "notes" => new Paginator($notes, 25, "notes_page"), "search" => $_GET['query']), fix(_f("Search results for \"%s\"", $_GET['query'])));
 }