Ejemplo n.º 1
0
<?php

include 'Specific.php';
header('Content-Type: application/json');
$functionName = $_GET['f'];
$data = "";
if (isset($_POST)) {
    //$data = $_POST['data'];
    $data = file_get_contents("php://input");
    //pass the data in as rawe in this form: {"thing":"its value"}
}
$c = new Chooser($functionName, $data);
$c->runFunction();
class Chooser
{
    private $functionName, $data;
    public function __construct($functionName, $data)
    {
        $this->data = $data;
        $this->functionName = $functionName;
    }
    function runFunction()
    {
        //$names = $GLOBALS['functionNames'];
        $names = Specific::$functionNames;
        $len = count($names);
        $found = false;
        $inst = new Specific($this->data);
        if (!$this->functionName) {
            $inst->defaultFunction();
        } else {
Ejemplo n.º 2
0
 /**
  * 根据类型获得chooser
  */
 public function getByType($appKey, $type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'app_key=:appKey and type=:type';
     $criteria->params = array(':appKey' => $appKey, ':type' => $type);
     $item = Chooser::model()->find($criteria);
     return $this->db2Item($item);
 }