本文整理汇总了PHP中Options::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::parse方法的具体用法?PHP Options::parse怎么用?PHP Options::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
function build($resultSet)
{
$class_name = $this->__class__;
$temp_result = array();
$old_ids = array();
$collid = 0;
if ($resultSet) {
$resultSet->beforeFirst();
while ($resultSet->next()) {
$collection_id = $resultSet->getData($this->__table__ . ".id");
$collection_identity = $collection_id !== false;
$collid = $collection_identity ? $collection_id : $collid;
if (array_key_exists($collid, $temp_result) === false || !$collection_identity) {
$sameNameCounter = 1;
$newInstance = new $class_name();
$newInstance->buildFromResultset($resultSet);
$old_ids[$collid] = array();
foreach ($this->__belongs_to__ as $key => $value) {
$className = is_numeric($key) ? $value : $key;
$obj_name = strToLower($className);
$resolver = "";
$options = is_numeric($key) ? array() : Options::parse($value);
$tableas = array_key_exists("as", $options) ? $options["as"] : false;
$field = array_key_exists("field", $options) ? $options["field"] : strToLower($className);
if ($obj_name == strToLower($this->__class__)) {
$resolver = $sameNameCounter;
$sameNameCounter++;
}
if ($tableas) {
$newInstance->{$field} = new $className();
$newInstance->{$field}->buildFromResultset($resultSet, $tableas);
} else {
if (class_exists($className)) {
$newInstance->{$obj_name} = new $className();
$newInstance->{$obj_name}->buildFromResultset($resultSet, $newInstance->{$obj_name}->__table__ . $resolver);
} else {
trigger_error("Can't load Class [{$className}]", E_USER_WARNING);
}
}
}
foreach ($this->__has_one__ as $key => $value) {
$className = is_numeric($key) ? $value : $key;
$obj_name = strToLower($className);
$resolver = "";
if ($obj_name == strToLower($this->__class__)) {
$resolver = $sameNameCounter;
$sameNameCounter++;
}
$newInstance->{$obj_name} = new $className();
$newInstance->{$obj_name}->buildFromResultset($resultSet, $resolver);
}
foreach ($this->__has_many__ as $key => $value) {
$property_name = is_numeric($key) ? strToLower($value . "s") : strToLower($key . "s");
$newInstance->{$property_name} = array();
$old_ids[$collid][$property_name] = array();
}
$temp_result[$collid] = $newInstance;
}
$new =& $temp_result[$collection_id];
foreach ($this->__has_many__ as $key => $value) {
$property_name = is_numeric($key) ? strToLower($value . "s") : strToLower($key . "s");
$class = is_numeric($key) ? $value : $key;
$temp_obj = new $class();
$table = $temp_obj->__table__;
$id = $resultSet->getData($table . ".id");
if (array_search($id, $old_ids[$collection_id][$property_name]) === FALSE || $id == NULL) {
$created = $temp_obj->buildFromResultset($resultSet);
if ($created) {
array_push($new->{$property_name}, $temp_obj);
array_push($old_ids[$collection_id][$property_name], $id);
}
}
}
if (!$collection_identity) {
$collid++;
}
}
}
$result = array();
foreach ($temp_result as $model) {
array_push($result, $model);
}
if ($this->__processFound__ && $resultSet != NULL) {
$result["founds"] = $resultSet->getTotal();
}
return $result;
}
示例2: search
function search($page = 1, $searchQuery = null, $sort = "id")
{
$m = $this->model;
$temp = new $m();
$searchQueryParsed = Options::parse($searchQuery);
$where = array();
$queryData = new stdClass();
foreach ($searchQueryParsed as $key => $value) {
if (APP_USE_LANGUAGE) {
if ($value != "" && $value != null) {
if (isset($m->{$key})) {
$where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\"";
} else {
$where[] = $temp->__table__ . ".{$key}_{$this->application->language} LIKE \"%{$value}%\"";
}
}
} else {
if ($value != "" && $value != null) {
$where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\"";
}
}
$queryData->{$key} = $value;
}
$query = array();
//if($this->order!=null) $query["order"] = $this->order;
if ($sort != null) {
$query["order"] = "{$temp->__table__}.{$sort}";
}
$query["group"] = $temp->__table__ . ".id";
$query["limit"] = ($page - 1) * $this->perPage . "," . $this->perPage;
$query["founds"] = true;
if (count($where) > 0) {
$query["where"] = implode(" AND ", $where);
}
/*
if($condition!=null){
$query["where"] = $condition;
}
*/
$this->data["objects"] = Collection::load($this->model, $query, $total);
$order = new stdClass();
foreach ($this->orderFields as $key) {
$order->{$key} = $key;
$sym = $key . "symbol";
$order->{$sym} = "[asc]";
if ($key == $sort) {
$order->{$key} .= " desc";
$order->{$sym} = "[desc]";
}
}
$this->data["order"] = $order;
import("data.Pager");
$page = max($page, 1);
unset($this->data["objects"]["founds"]);
$pager = new Pager($total, $this->perPage);
$pager->to = "{$this->controller}/search/{page}/{$searchQuery}";
$this->data["pager"] = $pager->build($page);
$this->data["querydata"] = $queryData;
$this->data["uri"] = linkForm("/{$this->controller}/search/{$page}/{$searchQuery}");
$this->setView("{$this->folder}/{$this->subView}", $this->data);
}
示例3: button
function button($content, $data, $attributes)
{
if (array_key_exists("type", $attributes)) {
$type = $attributes["type"];
} else {
if (array_key_exists("to", $attributes)) {
$type = "to";
$to = TemplateLogic::content($attributes["to"], $data);
} else {
$type = "submit";
}
}
$result = "";
$name = TemplateLogic::content($attributes["name"], $data);
$options = Options::parse($attributes["options"]);
if (array_key_exists("action", $attributes)) {
$options["action"] = $attributes["action"];
}
switch (strToLower($type)) {
case "back":
$result = buttonBack($name, $options);
break;
case "action":
$result = buttonAction($name, $options);
break;
case "to":
$result = buttonTo($name, $to, $options);
break;
case "reset":
$result = buttonReset($name);
break;
case "submit":
default:
$result = submit_tag($name, $options);
break;
}
return $result;
}
示例4: ulist
function ulist($content, $attributes)
{
//global $app;
$defaultValues = trim($content) == "";
$name = $attributes["name"];
$field = array_key_exists("label", $attributes) ? $this->process($attributes["label"]) : "name";
$selected = array_key_exists("selected", $attributes) ? $this->process($attributes["selected"]) : NULL;
$result = "";
$options = Options::parse($attributes["options"]);
if (array_key_exists("values", $attributes)) {
$values = explode(";", $attributes["values"]);
foreach ($values as $value) {
$data = explode(":", $value);
$liData = array("id" => $data[0]);
if ($item->id == $selected) {
$liData["class"] = "active";
}
$liContent = strtolower($options["addlinks"]) == "true" ? link_tag($data[1], "#") : $data[1];
$result .= simple_tag("li", $liContent, $liData);
}
}
if (array_key_exists("collection", $attributes)) {
if ($defaultValues) {
$collection = $this->data->get($attributes["collection"]);
if (is_array($collection)) {
foreach ($collection as $item) {
//$field = (isset($item->name)) ? "name" : "name_".$app->language;
//echo $item->name_sp;
if (!property_exists($item, $field) && $item->__use_language__) {
$field .= "_" . $this->data->get("language")->id;
}
$label = $item->{$field};
//$result .= option_tag($item->$field,$item->id,($item->id==$selected));
$liData = array("id" => $item->id);
if ($item->id == $selected) {
$liData["class"] = "active";
}
$liContent = strtolower($options["addlinks"]) == "true" ? link_tag($item->{$field}, "#") : $item->{$field};
$result .= simple_tag("li", $liContent, $liData);
}
}
} else {
$this->data->setTemporal("selected", $selected);
$result .= $this->loop($content, $attributes);
$this->data->clear("selected");
}
}
$select = simple_tag("ul", $result, $options);
return $select;
}