static function get_spark($data) { if (self::git_installed()) { return new GitSpark($data); } else { SparkUtils::warning('Git not found - reverting to archived copy'); return new ZipSpark($data); } }
static function get_spark($data) { if (self::hg_installed()) { return new MercurialSpark($data); } else { SparkUtils::warning('Mercurial not found - reverting to archived copy'); return new ZipSpark($data); } }
function search($term) { $json_data = @file_get_contents("http://$this->url/api/packages/search?q=" . urlencode($term)); $data = json_decode($json_data); // if the data isn't around of success is false, return a warning for this source if ($data == null || !$data->success) { $message = "Error searching source: $this->url"; if ($data != null) $message .= " ($data->message)"; SparkUtils::warning($message); return array(); } // Get sparks for each one $results = array(); foreach($data->results as $data) $results[] = $this->get_spark($data); return $results; }
function verify() { // see if this is deactivated if ($this->data->is_deactivated) { $msg = 'Woah there - it seems the spark you want has been deactivated'; if ($this->data->spark_home) $msg .= "\nLook for different versions at: " . $this->data->spark_home; throw new SparkException($msg); } // see if this is unsupported if ($this->data->is_unsupported) { SparkUtils::warning('This spark is no longer supported.'); SparkUtils::warning('You can keep using it, or look for an alternate'); } // tell the user if its already installed and throw an error $this->installation_path = SPARK_PATH . "/$this->name/$this->version"; if (is_dir($this->installation_path)) { throw new SparkException("Already installed. Try `php tools/spark remove $this->name`"); } }