Exemple #1
0
 /** Get referenced row
  * @param string
  * @return NotORM_Row or null if the row does not exist
  */
 function __get($name)
 {
     $this->result->notORM->__updateRowClass($name);
     $column = $this->result->notORM->structure->getReferencedColumn($name, $this->result->table);
     $referenced =& $this->result->referenced[$name];
     if (!isset($referenced)) {
         $keys = array();
         foreach ($this->result->rows as $row) {
             if ($row[$column] !== null) {
                 $keys[$row[$column]] = null;
             }
         }
         if ($keys) {
             $table = $this->result->notORM->structure->getReferencedTable($name, $this->result->table);
             $referenced = new Result($table, $this->result->notORM);
             $referenced->where("{$table}." . $this->result->notORM->structure->getPrimary($table), array_keys($keys));
         } else {
             $referenced = array();
         }
     }
     if (!isset($referenced[$this[$column]])) {
         // referenced row may not exist
         return null;
     }
     return $referenced[$this[$column]];
 }
 public function get_calendar()
 {
     $date_start = date('Y-m-d', $_GET['start']);
     $date_end = date('Y-m-d', $_GET['end']);
     $variable = new Result();
     $variable->get();
     $day = 24 * 60 * 60 * 1000;
     foreach ($variable as $key => $value) {
         $title = null;
         $color = null;
         switch ($value->result_type_id) {
             case 1:
                 $title = "รายสัปดาห์";
                 $color = "#337AB7";
                 break;
             case 2:
                 $title = "รายเดือน";
                 $color = "#f0AD4E";
                 break;
             default:
                 $title = "รายวัน";
                 $color = "#5cb85c";
                 break;
         }
         $data_[] = array("title" => $value->title, "start" => date("Y-m-d", strtotime($value->import_time)), "url" => "reports/views/" . $value->id, "color" => $color);
     }
     echo json_encode(@$data_);
 }
Exemple #3
0
 /**
  * Constructor
  * Use $db->createResult( $parent, $name ) instead
  *
  * @param Database|Result|Row $parent
  * @param string $name
  */
 function __construct($parent, $name)
 {
     if ($parent instanceof Database) {
         // basic result
         $this->db = $parent;
         $this->table = $this->db->getAlias($name);
     } else {
         // Row or Result
         // result referenced to parent
         $this->parent_ = $parent;
         $this->db = $parent->getDatabase();
         // determine type of reference based on conventions and user hints
         $fullName = $name;
         $name = preg_replace('/List$/', '', $fullName);
         $this->table = $this->db->getAlias($name);
         $this->single = $name === $fullName;
         if ($this->single) {
             $this->key = $this->db->getPrimary($this->getTable());
             $this->parentKey = $this->db->getReference($parent->getTable(), $name);
         } else {
             $this->key = $this->db->getBackReference($parent->getTable(), $name);
             $this->parentKey = $this->db->getPrimary($parent->getTable());
         }
     }
 }
function app_choice()
{
    // Accessing the result object
    $result = new Result();
    $choice = $result->getValue();
    // Create a new instance of the Tropo object.
    $tropo = new Tropo();
    // Provide a prompt based on the value
    if ($choice == "1") {
        $tropo->say("You picked Lord of the Rings.  Did you know Gandalf is also Mag knee toe?  Weird.");
    }
    if ($choice == "2") {
        $tropo->say("You picked the original Star Wars.  I hear Leonard Nimoy was awe some in those.");
    }
    if ($choice == "3") {
        $tropo->say("You picked the Star Wars prequels.  Stop calling this number, Mr. Lucas, we know it's you.");
    }
    if ($choice == "4") {
        $tropo->say("You picked the Matrix. Dude, woe.");
    }
    // Tell Tropo what to do next. This redirects to the instructions under dispatch_post('/hangup', 'app_hangup').
    $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=hangup"));
    // Tell Tropo what to do if there's an problem, like a timeout. This redirects to the instructions under dispatch_post('/incomplete', 'app_incomplete').
    $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete"));
    // Render the JSON for the Tropo WebAPI to consume.
    return $tropo->RenderJson();
}
 /**
  * @param string $status
  * @param string $message
  * @return Result
  */
 public function createResult($status = Result::STATUS_OK, $message = '')
 {
     $result = new Result($status, $message);
     $result->setResultGroup($this->_resultGroup);
     $this->addResult($result);
     return $result;
 }
Exemple #6
0
 public function run(Result $result, $offset)
 {
     $result->addError($offset);
     $result->addSuccesses(15);
     $result->addFailures(10);
     return $result;
 }
function app_continue()
{
    $tropo = new Tropo();
    @($result = new Result());
    $userType = $result->getUserType();
    $tropo->say("You are a {$userType}");
    $tropo->RenderJson();
}
Exemple #8
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!($value === $this->compare && !$value instanceof \DateTime) && !($value instanceof \DateTime && $this->compare instanceof \DateTime && $value == $this->compare)) {
         $result->setValue(false);
         $result->addMessage('equal');
     }
     return $result;
 }
Exemple #9
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!is_numeric($value)) {
         $result->setValue(false);
         $result->addMessage('float');
     }
     return $result;
 }
Exemple #10
0
 public function voice_continue()
 {
     $this->set_output_mode(MY_Controller::OUTPUT_NORMAL);
     $tropo = new Tropo();
     @($result = new Result());
     $answer = $result->getValue();
     $tropo->say("You said " . $answer);
     $tropo->RenderJson();
 }
Exemple #11
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if ($value !== true && $value !== false) {
         $result->setValue(false);
         $result->addMessage('boolean');
     }
     return $result;
 }
Exemple #12
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!is_string($value)) {
         $result->setValue(false);
         $result->addMessage('string');
     }
     return $result;
 }
Exemple #13
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!preg_match('/' . $this->regex . '/', $value)) {
         $result->setValue(false);
         $result->addMessage(['regex', $this->regex]);
     }
     return $result;
 }
Exemple #14
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!preg_match($this->regex, $value)) {
         $result->setValue(false);
         $result->addMessage('alpha');
     }
     return $result;
 }
Exemple #15
0
 function validate_cancel_input()
 {
     $result = new Result();
     if (!isset($_POST['leave_to_cancel']) || empty($_POST['leave_to_cancel'])) {
         $result->setResult(FALSE);
         $result->addError("Please select leave to cancel");
     }
     return $result;
 }
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!($value < $this->compare)) {
         $result->setValue(false);
         $result->addMessage('lessThan');
     }
     return $result;
 }
Exemple #17
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!$value instanceof \DateTime) {
         $result->setValue(false);
         $result->addMessage('date');
     }
     return $result;
 }
Exemple #18
0
 public function testContentIsGenerator()
 {
     $data = $this->mock_gen();
     $r = new Result($data, 'json', ['header_func' => function ($h) use(&$header) {
         $header = $h;
     }]);
     $expected = json_encode([["id" => 0], ["id" => 1], ["id" => 2]]);
     $result = $r->render();
     $this->assertEquals($expected, $result);
 }
 /**
  * 查看一条记录是否在结果集中存在
  * @param Result $record
  * @return boolean
  */
 public function isRecordExists($record)
 {
     foreach ($this->resArr as $value) {
         $value_record = $value->getRecord();
         if ($value_record == $record->getRecord()) {
             return true;
         }
     }
     return false;
 }
Exemple #20
0
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     $length = strlen($value);
     if ($length < $this->min || $length > $this->max) {
         $result->setValue(false);
         $result->addMessage(['length', $this->min, $this->max]);
     }
     return $result;
 }
 /**
  * @return \Cpeople\Classes\Geolocation\Result $result
  */
 public function locate()
 {
     $url = "http://ipgeobase.ru:7020/geo/?ip={$this->ip}";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, 'Content-Type:application/x-www-form-urlencoded');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $curlResult = curl_exec($ch);
     $result = new Result();
     try {
         if (curl_error($ch)) {
             throw new \Exception('Error in request, ' . __METHOD__);
         }
         if (!($xml = simplexml_load_string($curlResult))) {
             throw new \Exception('Bad response, ' . __METHOD__);
         }
         if ((string) $xml->ip->city == '') {
             throw new \Exception('Bad XML, ' . __METHOD__);
         }
         $result->setCity((string) $xml->ip->city);
         $result->setCountry((string) $xml->ip->country);
         $result->setRegion((string) $xml->ip->region);
         $result->setDestrict((string) $xml->ip->district);
         $result->setLatitude((string) $xml->ip->lat);
         $result->setLongtitude((string) $xml->ip->lng);
     } catch (\Exception $e) {
         $result->setError($e->getMessage());
     }
     return $result;
 }
Exemple #22
0
 /**
  * Tests not applicable results.
  */
 public function testNotApplicable()
 {
     // No label
     $result = new Result(Result::NOT_APPLICABLE);
     $this->assertTrue($result->isSuccess());
     $this->assertEquals(Result::NOT_APPLICABLE, $result->getStatus());
     $this->assertEquals($result->getStatusMessage(), $result->getDescription());
     // With label
     $result = new Result(Result::NOT_APPLICABLE, 'Desc');
     $this->assertEquals('Desc', $result->getDescription());
 }
 /**
  * Calculates Maintainability Index
  *
  * @param \Hal\Metrics\Complexity\Text\Halstead\Result $rHalstead
  * @param \Hal\Metrics\Complexity\Text\Length\Result $rLoc
  * @param \Hal\Metrics\Complexity\Component\McCabe\Result $rMcCabe
  * @return Result
  */
 public function calculate(\Hal\Metrics\Complexity\Text\Halstead\Result $rHalstead, \Hal\Metrics\Complexity\Text\Length\Result $rLoc, \Hal\Metrics\Complexity\Component\McCabe\Result $rMcCabe)
 {
     $result = new Result();
     $result->setMaintainabilityIndexWithoutComment(max((171 - 5.2 * \log($rHalstead->getVolume()) - 0.23 * $rMcCabe->getCyclomaticComplexityNumber() - 16.2 * \log($rLoc->getLogicalLoc())) * 100 / 171, 0));
     // comment weight
     if ($rLoc->getLoc() > 0) {
         $CM = $rLoc->getCommentLoc() / $rLoc->getLoc();
         $result->setCommentWeight(50 * sin(sqrt(2.4 * $CM)));
     }
     return $result;
 }
Exemple #24
0
 public function find(Query $query, Result $result)
 {
     while ($nextLine = $this->parser->nextLine()) {
         if ($query->matches($nextLine)) {
             $result->addLogLine($nextLine);
         }
         if ($result->hasEnoughLogsInPage()) {
             break;
         }
     }
     return $result;
 }
function zip_end()
{
    // Create a new instance of the result object and get the value of the user input.
    $result = new Result();
    $zip = $result->getValue();
    // Create a new instance of the Tropo object.
    $tropo = new Tropo();
    // Get the weather information for the entered zip code.
    formatWeatherResponse($tropo, $zip);
    // Render the JSON for the Tropo WebAPI to consume.
    return $tropo->RenderJson();
}
Exemple #26
0
 /**
  * Checks the result of the event for errors, fills the Result object.
  * Returns true on errors, false on no errors.
  *
  * @param Result $result
  * @return bool
  */
 public function getErrors(Result $result)
 {
     $hasErrors = false;
     /** @var $evenResult EventResult */
     foreach ($this->getResults() as $evenResult) {
         if ($evenResult->getType() === EventResult::ERROR) {
             $hasErrors = true;
             $result->addErrors($evenResult->getErrors());
         }
     }
     return $hasErrors;
 }
 /**
  * Checks the result of the event for errors, fills the Result object.
  * Returns true on errors, false on no errors.
  *
  * @param Result $result
  * @return bool
  */
 public function getErrors(Result $result)
 {
     $hasErrors = false;
     if ($this->getResults() != null) {
         foreach ($this->getResults() as $evenResult) {
             if ($evenResult->getResultType() === \Bitrix\Main\EventResult::ERROR) {
                 $hasErrors = true;
                 $result->addErrors($evenResult->getParameters());
             }
         }
     }
     return $hasErrors;
 }
Exemple #28
0
 /**
  * Convert the raw XML into an object
  *
  * @param \SimpleXMLElement $xml
  * @return Result
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $result = new Result();
     if (isset($xml->nofrecords)) {
         $result->setNumResults((int) $xml->nofrecords);
     }
     if (isset($xml->event)) {
         foreach ($xml->event as $event) {
             $result->addEvent(\CultureFeed_Cdb_Item_Event::parseFromCdbXml($event));
         }
     }
     return $result;
 }
 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     $value = preg_replace('/[- ]/', '', $value);
     foreach ($this->cardInfo as $regex) {
         if (preg_match('/^' . $regex . '$/', $value)) {
             return $result;
         }
     }
     $result->setValue(false);
     $result->addMessage('creditCard');
     return $result;
 }
function conference()
{
    global $voice;
    $tropo = new Tropo();
    $tropo->setVoice($voice);
    $result = new Result();
    $conference = $result->getValue();
    $tropo->say('<speak>Conference ID <say-as interpret-as=\'vxml:digits\'>' . $conference . '</say-as> accepted.</speak>');
    $tropo->say('You will now be placed into the conference. Please announce yourself. To exit the conference without disconnecting, press pound.');
    $tropo->conference($conference, array('id' => $conference, 'terminator' => '#'));
    $tropo->say('You have left the conference.');
    $tropo->on(array("event" => "continue", "next" => "restart"));
    $tropo->RenderJson();
}