本文整理汇总了PHP中utils::a2o方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::a2o方法的具体用法?PHP utils::a2o怎么用?PHP utils::a2o使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::a2o方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_decode
$return = utils::o2a($widget);
$return['logicalId'] = $widget->getLogicalId();
$return['status'] = market::getInfo($widget->getLogicalId());
ajax::success($return);
}
if (init('action') == 'save') {
$widget_ajax = json_decode(init('widget'), true);
if (file_exists($widget['path'])) {
$widget_db = widget::byPath($widget['path']);
if (!is_object($widget_db)) {
$widget_db = new widget();
}
} else {
$widget_db = new widget();
}
utils::a2o($widget_db, $widget_ajax);
$widget_db->save();
ajax::success(utils::o2a($widget_db));
}
if (init('action') == 'add') {
$widget = new widget();
$widget->setName(init('name'));
$widget->save();
ajax::success(utils::o2a($widget));
}
if (init('action') == 'remove') {
$widget = widget::byPath(init('path'));
if (!is_object($widget)) {
throw new Exception('Widget non trouvé : ' . init('path'));
}
$widget->remove();
示例2: trim
$link_id .= cmd::cmdToHumanReadable('#' . $cmd->getId() . '# && ');
}
}
$result['link_id'] = trim(trim($link_id), '&&');
}
ajax::success(jeedom::toHumanReadable($result));
}
if (init('action') == 'save') {
$interact_json = jeedom::fromHumanReadable(json_decode(init('interact'), true));
if (isset($interact_json['id'])) {
$interact = interactDef::byId($interact_json['id']);
}
if (!isset($interact) || !is_object($interact)) {
$interact = new interactDef();
}
utils::a2o($interact, $interact_json);
$interact->save();
ajax::success(utils::o2a($interact));
}
if (init('action') == 'regenerateInteract') {
interactDef::regenerateInteract();
ajax::success();
}
if (init('action') == 'remove') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$interact = interactDef::byId(init('id'));
if (!is_object($interact)) {
throw new Exception(__('Interaction inconnu verifié l\'id', __FILE__));
}
示例3: Exception
$return['plugin'] = $eqLogic->getEqType_Name();
if ($eqLogic->getObject_id() > 0) {
$return['object_name'] = $eqLogic->getObject()->getName();
}
ajax::success($return);
}
if (init('action') == 'save') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$cmd_ajax = jeedom::fromHumanReadable(json_decode(init('cmd'), true));
$cmd = cmd::byId($cmd_ajax['id']);
if (!is_object($cmd)) {
$cmd = new cmd();
}
utils::a2o($cmd, $cmd_ajax);
$cmd->save();
ajax::success();
}
if (init('action') == 'changeHistoryPoint') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$history = history::byCmdIdDatetime(init('cmd_id'), init('datetime'));
if (!is_object($history)) {
throw new Exception(__('Aucun point ne correspond pour l\'historique : ', __FILE__) . init('cmd_id') . ' - ' . init('datetime'));
}
$history->setValue(init('value', null));
$history->save(null, true);
ajax::success();
}
示例4: applyModuleConfiguration
public function applyModuleConfiguration()
{
if ($this->getConfiguration('device') == '') {
return true;
}
$device = self::devicesParameters($this->getConfiguration('device'));
if (!is_array($device) || !isset($device['commands'])) {
return true;
}
if (isset($device['configuration'])) {
foreach ($device['configuration'] as $key => $value) {
$this->setConfiguration($key, $value);
}
}
$this->setConfiguration('applyDevice', $this->getConfiguration('device'));
$cmd_order = 0;
$link_cmds = array();
foreach ($device['commands'] as $command) {
if (!isset($command['configuration']['instanceId'])) {
$command['configuration']['instanceId'] = 0;
}
$cmd = null;
foreach ($this->getCmd() as $liste_cmd) {
if ($liste_cmd->getConfiguration('instanceId', 0) == $command['configuration']['instanceId'] && $liste_cmd->getConfiguration('class') == $command['configuration']['class'] && $liste_cmd->getConfiguration('value') == $command['configuration']['value']) {
$cmd = $liste_cmd;
break;
}
}
try {
if ($cmd == null || !is_object($cmd)) {
$cmd = new zwaveCmd();
$cmd->setOrder($cmd_order);
$cmd->setEqLogic_id($this->getId());
} else {
$command['name'] = $cmd->getName();
}
utils::a2o($cmd, $command);
if (isset($command['value'])) {
$cmd->setValue(null);
}
$cmd->save();
if (isset($command['value'])) {
$link_cmds[$cmd->getId()] = $command['value'];
}
$cmd_order++;
} catch (Exception $exc) {
error_log($exc->getMessage());
}
}
if (count($link_cmds) > 0) {
foreach ($this->getCmd() as $eqLogic_cmd) {
foreach ($link_cmds as $cmd_id => $link_cmd) {
if ($link_cmd == $eqLogic_cmd->getName()) {
$cmd = cmd::byId($cmd_id);
if (is_object($cmd)) {
$cmd->setValue($eqLogic_cmd->getId());
$cmd->save();
}
}
}
}
}
$this->save();
}
示例5: Exception
if (count(user::searchByRight('admin')) == 1 && $user->getRights('admin') == 1) {
throw new Exception(__('Vous ne pouvez supprimer le dernière administrateur', __FILE__));
}
$user->remove();
ajax::success();
}
if (init('action') == 'saveProfils') {
$user_json = json_decode(init('profils'), true);
if (isset($user_json['id']) && $user_json['id'] != $_SESSION['user']->getId()) {
throw new Exception('401 unautorized');
}
$login = $_SESSION['user']->getLogin();
$rights = $_SESSION['user']->getRights();
$password = $_SESSION['user']->getPassword();
@session_start();
utils::a2o($_SESSION['user'], $user_json);
foreach ($rights as $right => $value) {
$_SESSION['user']->setRights($right, $value);
}
$_SESSION['user']->setLogin($login);
if ($password != $_SESSION['user']->getPassword()) {
$_SESSION['user']->setPassword(sha1($_SESSION['user']->getPassword()));
}
$_SESSION['user']->save();
@session_write_close();
ajax::success();
}
if (init('action') == 'get') {
ajax::success(utils::o2a($_SESSION['user']));
}
if (init('action') == 'testLdapConnection') {
示例6: json_decode
}
}
$scenario_ajax = json_decode(init('scenario'), true);
if (isset($scenario_ajax['id'])) {
$scenario_db = scenario::byId($scenario_ajax['id']);
}
if (!isset($scenario_db) || !is_object($scenario_db)) {
$scenario_db = new scenario();
} else {
if (!$scenario_db->hasRight('w')) {
throw new Exception(__('Vous n\'etês pas autorisé à faire cette action', __FILE__));
}
}
$scenario_db->setTrigger(array());
$scenario_db->setSchedule(array());
utils::a2o($scenario_db, $scenario_ajax);
$scenario_db->setConfiguration('timeDependency', $time_dependance);
$scenario_db->save();
$scenario_element_list = array();
if (isset($scenario_ajax['elements'])) {
foreach ($scenario_ajax['elements'] as $element_ajax) {
$scenario_element_list[] = scenarioElement::saveAjaxElement($element_ajax);
}
$scenario_db->setScenarioElement($scenario_element_list);
}
$scenario_db->save();
ajax::success(utils::o2a($scenario_db));
}
if (init('action') == 'actionToHtml') {
ajax::success(scenarioExpression::getExpressionOptions(init('expression'), init('option')));
}
示例7: applyModuleConfiguration
public function applyModuleConfiguration($_light = false)
{
$this->setConfiguration('applyDevice', $this->getConfiguration('device'));
if ($this->getConfiguration('device') == '') {
$this->save();
return true;
}
$device = self::devicesParameters($this->getConfiguration('device'));
if (!is_array($device) || !isset($device['commands'])) {
return true;
}
if (isset($device['configuration'])) {
foreach ($device['configuration'] as $key => $value) {
try {
$this->setConfiguration($key, $value);
} catch (Exception $e) {
}
}
}
$cmd_order = 0;
$link_cmds = array();
$razberry_id = zwave::getZwaveInfo('controller::data::nodeId::value', $this->getConfiguration('serverID', 1));
nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Mise en place des groupes par défaut', __FILE__)));
if (isset($device['groups']) && isset($device['groups']['associate'])) {
foreach ($this->getAssociation() as $group_id => $associate) {
foreach ($associate['nodes']['value'] as $node) {
if ($node['id'] == $razberry_id && !isset($device['groups']['associate'][$group_id])) {
$this->changeAssociation('remove', $group_id, $razberry_id);
}
}
}
foreach ($device['groups']['associate'] as $group) {
try {
$this->changeAssociation('add', $group, $razberry_id);
} catch (Exception $e) {
}
}
}
nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Création des commandes', __FILE__)));
if (self::$_listZwaveServer == null) {
self::listServerZway();
}
if (isset($device['commands_openzwave']) && self::$_listZwaveServer[$this->getConfiguration('serverID', 1)]['isOpenZwave'] == 1) {
$commands = $device['commands_openzwave'];
} else {
$commands = $device['commands'];
}
foreach ($commands as &$command) {
if (!isset($command['configuration']['instanceId'])) {
$command['configuration']['instanceId'] = 0;
}
if (!isset($command['configuration']['class'])) {
$command['configuration']['class'] = '';
}
$cmd = null;
foreach ($this->getCmd() as $liste_cmd) {
if ($liste_cmd->getConfiguration('instanceId', 0) == $command['configuration']['instanceId'] && $liste_cmd->getConfiguration('class') == $command['configuration']['class'] && $liste_cmd->getConfiguration('value') == $command['configuration']['value']) {
$cmd = $liste_cmd;
break;
}
}
try {
if ($cmd == null || !is_object($cmd)) {
$cmd = new zwaveCmd();
$cmd->setOrder($cmd_order);
$cmd->setEqLogic_id($this->getId());
} else {
$command['name'] = $cmd->getName();
if (isset($command['display'])) {
unset($command['display']);
}
}
utils::a2o($cmd, $command);
if (isset($command['value'])) {
$cmd->setValue(null);
}
$cmd->save();
if (isset($command['value'])) {
$link_cmds[$cmd->getId()] = $command['value'];
}
$cmd_order++;
} catch (Exception $exc) {
}
}
if (count($link_cmds) > 0) {
foreach ($this->getCmd() as $eqLogic_cmd) {
foreach ($link_cmds as $cmd_id => $link_cmd) {
if ($link_cmd == $eqLogic_cmd->getName()) {
$cmd = cmd::byId($cmd_id);
if (is_object($cmd)) {
$cmd->setValue($eqLogic_cmd->getId());
$cmd->save();
}
}
}
}
}
if (isset($device['wakeup']) && is_numeric($device['wakeup']) && $device['wakeup'] > 1) {
try {
$this->setWakeUp($device['wakeup']);
//.........这里部分代码省略.........
示例8: foreach
foreach ($eqLogics_ajax as $eqLogic_ajax) {
foreach ($eqLogic_ajax['configuration'] as $key => $value) {
if ($key == 'portType') {
$eqLogic_ajaxType = $value;
}
}
if ($eqLogic_ajaxType != 0) {
$eqLogic_db = new jeenode();
utils::a2o($eqLogic_db, $eqLogic_ajax);
$eqLogic_db->save();
$enable_eqLogic[$eqLogic_db->getId()] = true;
$enable_cmd = array();
foreach ($eqLogic_ajax['cmd'] as $cmd_ajax) {
$cmd_db = new jeenodeCmd();
$cmd_db->setEqLogic_id($eqLogic_db->getId());
utils::a2o($cmd_db, $cmd_ajax);
$cmd_db->save();
$enable_cmd[$cmd_db->getId()] = true;
}
//suppression des entrées non modifiées.
foreach ($eqLogic_db->getCmd() as $cmd_db) {
if (!isset($enable_cmd[$cmd_db->getId()])) {
$cmd_db->remove();
}
}
} else {
$eqLogic_db = jeenode::byId($eqLogic_ajax['id']);
$eqLogic_db->remove();
}
}
foreach ($eqReal_db->getEqLogic() as $eqLogic_db) {
示例9: Exception
}
if (init('action') == 'all') {
ajax::success(utils::o2a(object::buildTree()));
}
if (init('action') == 'save') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$object_json = json_decode(init('object'), true);
if (isset($object_json['id'])) {
$object = object::byId($object_json['id']);
}
if (!isset($object) || !is_object($object)) {
$object = new object();
}
utils::a2o($object, $object_json);
$object->save();
ajax::success(utils::o2a($object));
}
if (init('action') == 'uploadImage') {
$object = object::byId(init('id'));
if (!is_object($object)) {
throw new Exception(__('Objet inconnu verifié l\'id', __FILE__));
}
if (!isset($_FILES['file'])) {
throw new Exception(__('Aucun fichier trouvé. Vérifié parametre PHP (post size limit)', __FILE__));
}
$extension = strtolower(strrchr($_FILES['file']['name'], '.'));
if (!in_array($extension, array('.jpg', '.png'))) {
throw new Exception('Extension du fichier non valide (autorisé .jpg .png) : ' . $extension);
}
示例10: Exception
ajax::success($jeeNetwork->backup());
}
if (init('action') == 'save') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$update = true;
$jeeNetwork_json = json_decode(init('jeeNetwork'), true);
if (isset($jeeNetwork_json['id'])) {
$jeeNetwork = jeeNetwork::byId($jeeNetwork_json['id']);
}
if (!isset($jeeNetwork) || !is_object($jeeNetwork)) {
$update = false;
$jeeNetwork = new jeeNetwork();
}
utils::a2o($jeeNetwork, $jeeNetwork_json);
$jeeNetwork->save();
if ($update) {
$jeeNetwork->reload();
}
ajax::success(utils::o2a($jeeNetwork));
}
if (init('action') == 'changeMode') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
ajax::success(jeeNetwork::changeMode(init('mode')));
}
if (init('action') == 'restartNgrok') {
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
示例11: array
$dbList = $typeCmd::byEqLogicId($eqLogic->getId());
$eqLogic->save();
$enableList = array();
if (isset($params['cmd'])) {
$cmd_order = 0;
foreach ($params['cmd'] as $cmd_info) {
$cmd = null;
if (isset($cmd_info['id'])) {
$cmd = $typeCmd::byId($cmd_info['id']);
}
if (!is_object($cmd)) {
$cmd = new $typeCmd();
}
$cmd->setEqLogic_id($eqLogic->getId());
$cmd->setOrder($cmd_order);
utils::a2o($cmd, jeedom::fromHumanReadable($cmd_info));
$cmd->save();
$cmd_order++;
$enableList[$cmd->getId()] = true;
}
//suppression des entrées inexistante.
foreach ($dbList as $dbObject) {
if (!isset($enableList[$dbObject->getId()]) && !$dbObject->dontRemoveCmd()) {
$dbObject->remove();
}
}
}
$jsonrpc->makeSuccess(utils::o2a($eqLogic));
}
if ($jsonrpc->getMethod() == 'eqLogic::byTypeAndId') {
$return = array();
示例12: array
$dbList = $typeCmd::byEqLogicId($eqLogic->getId());
$eqLogic->save();
$enableList = array();
if (isset($eqLogicSave['cmd'])) {
$cmd_order = 0;
foreach ($eqLogicSave['cmd'] as $cmd_info) {
$cmd = null;
if (isset($cmd_info['id'])) {
$cmd = $typeCmd::byId($cmd_info['id']);
}
if (!is_object($cmd)) {
$cmd = new $typeCmd();
}
$cmd->setEqLogic_id($eqLogic->getId());
$cmd->setOrder($cmd_order);
utils::a2o($cmd, $cmd_info);
$cmd->save();
$cmd_order++;
$enableList[$cmd->getId()] = true;
}
//suppression des entrées non innexistante.
foreach ($dbList as $dbObject) {
if (!isset($enableList[$dbObject->getId()]) && !$dbObject->dontRemoveCmd()) {
$dbObject->remove();
}
}
}
if (method_exists($eqLogic, 'postAjax')) {
$eqLogic->postAjax();
}
}
示例13: dirname
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
*/
try {
require_once dirname(__FILE__) . '/../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
if (init('action') == 'byUserId') {
ajax::success(utils::o2a(rights::byUserId(init('user_id'))));
}
if (init('action') == 'save') {
$rights_json = json_decode(init('rights'), true);
foreach ($rights_json as $right_json) {
$rights = rights::byId($right_json['id']);
if (!is_object($rights)) {
$rights = new rights();
}
utils::a2o($rights, $right_json);
$rights->save();
}
ajax::success();
}
throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
/* * *********Catch exeption*************** */
} catch (Exception $e) {
ajax::error(displayExeption($e), $e->getCode());
}
示例14: json_decode
$view_ajax = json_decode(init('view'), true);
utils::a2o($view, $view_ajax);
$view->save();
if (count($view_ajax['zones']) > 0) {
foreach ($view_ajax['zones'] as $viewZone_info) {
$viewZone = new viewZone();
$viewZone->setView_id($view->getId());
utils::a2o($viewZone, $viewZone_info);
$viewZone->save();
if (isset($viewZone_info['viewData'])) {
$order = 0;
foreach ($viewZone_info['viewData'] as $viewData_info) {
$viewData = new viewData();
$viewData->setviewZone_id($viewZone->getId());
$viewData->setOrder($order);
utils::a2o($viewData, $viewData_info);
$viewData->save();
$order++;
}
}
}
}
ajax::success();
}
if (init('action') == 'getEqLogicviewZone') {
$viewZone = viewZone::byId(init('viewZone_id'));
if (!is_object($viewZone)) {
throw new Exception(__('Vue non trouvé. Vérifier l\'id', __FILE__));
}
$return = utils::o2a($viewZone);
$return['eqLogic'] = array();
示例15: applyModuleConfiguration
public function applyModuleConfiguration()
{
if ($this->getConfiguration('device') == '') {
return true;
}
$this->setConfiguration('applyDevice', $this->getConfiguration('device'));
$this->save();
$device_type = explode('::', $this->getConfiguration('device'));
$packettype = $device_type[0];
$subtype = $device_type[1];
$device = self::devicesParameters($packettype);
if (!is_array($device) || !isset($device['subtype'][$subtype])) {
return true;
} else {
$device = $device['subtype'][$subtype];
}
if (isset($device['configuration'])) {
foreach ($device['configuration'] as $key => $value) {
$this->setConfiguration($key, $value);
}
}
$cmd_order = 0;
foreach ($device['commands'] as $command) {
$cmd = null;
foreach ($this->getCmd() as $liste_cmd) {
if ($liste_cmd->getConfiguration('logicalId', '') == $command['configuration']['logicalId']) {
$cmd = $liste_cmd;
break;
}
}
try {
if ($cmd == null || !is_object($cmd)) {
$cmd = new rfxcomCmd();
$cmd->setOrder($cmd_order);
$cmd->setEqLogic_id($this->getId());
} else {
$command['name'] = $cmd->getName();
}
utils::a2o($cmd, $command);
$cmd->save();
$cmd_order++;
} catch (Exception $exc) {
}
}
$this->save();
}