本文整理汇总了PHP中utils::o2a方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::o2a方法的具体用法?PHP utils::o2a怎么用?PHP utils::o2a使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::o2a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stackData
public function stackData($params)
{
if (is_object($params)) {
$paramsArray = utils::o2a($params);
}
nodejs::pushUpdate('influxdb::stackDataEqLogic', $paramsArray);
}
示例2: execute
public function execute($_options = array())
{
$array = utils::o2a($this);
if (isset($_options['utid'])) {
$array['utid'] = $_options['utid'];
}
if ($this->getLogicalId() == 'close') {
event::add('clink::close', $array);
} else {
event::add('clink::open', $array);
}
}
示例3: toAjax
public function toAjax()
{
$return = utils::o2a($this);
$return['viewZone'] = array();
foreach ($this->getViewZone() as $viewZone) {
$viewZone_info = utils::o2a($viewZone);
$viewZone_info['viewData'] = array();
foreach ($viewZone->getViewData() as $viewData) {
$viewData_info = utils::o2a($viewData);
$viewData_info['name'] = '';
switch ($viewData->getType()) {
case 'cmd':
$cmd = $viewData->getLinkObject();
if (is_object($cmd)) {
$viewData_info['type'] = 'cmd';
$viewData_info['name'] = $cmd->getHumanName();
$viewData_info['id'] = $cmd->getId();
$viewData_info['html'] = $cmd->toHtml(init('version', 'dashboard'));
}
break;
case 'eqLogic':
$eqLogic = $viewData->getLinkObject();
if (is_object($eqLogic)) {
$viewData_info['type'] = 'eqLogic';
$viewData_info['name'] = $eqLogic->getHumanName();
$viewData_info['id'] = $eqLogic->getId();
$viewData_info['html'] = $eqLogic->toHtml(init('version', 'dashboard'));
}
break;
case 'scenario':
$scenario = $viewData->getLinkObject();
if (is_object($scenario)) {
$viewData_info['type'] = 'scenario';
$viewData_info['name'] = $scenario->getHumanName();
$viewData_info['id'] = $scenario->getId();
$viewData_info['html'] = $scenario->toHtml(init('version', 'dashboard'));
}
break;
}
$viewZone_info['viewData'][] = $viewData_info;
}
$return['viewZone'][] = $viewZone_info;
}
return $return;
}
示例4: foreach
}
}
foreach ($eqReal_db->getEqLogic() as $eqLogic_db) {
if (!isset($enable_eqLogic[$eqLogic_db->getId()])) {
$eqLogic_db->remove();
}
}
break;
}
}
ajax::success();
}
if (init('action') == 'getJeenodeConf') {
$jeenodeReal = jeenodeReal::byId(init('jeenodeRealId'));
if (!is_object($jeenodeReal)) {
throw new Exception('JeenodeReal inconnu verifié l\'id');
}
$return = utils::o2a($jeenodeReal);
$return['port'] = array();
foreach ($jeenodeReal->getEqLogic() as $eqLogic) {
$portConfiguration = utils::o2a($eqLogic);
$portConfiguration['cmd'] = utils::o2a($eqLogic->getCmd());
$return['port'][] = $portConfiguration;
}
ajax::success($return);
}
throw new Exception('Aucune methode correspondante');
/* * *********Catch exeption*************** */
} catch (Exception $e) {
ajax::error(displayExeption($e), $e->getCode());
}
示例5: dirname
try {
require_once dirname(__FILE__) . '/../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (init('action') == 'getInfoApplication') {
if (!isConnect()) {
throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234);
}
$_SESSION['user']->refresh();
$return = array();
$return['user_id'] = $_SESSION['user']->getId();
$return['nodeJsKey'] = config::byKey('nodeJsKey');
$return['userProfils'] = $_SESSION['user']->getOptions();
$return['plugins'] = array();
foreach (plugin::listPlugin(true) as $plugin) {
if ($plugin->getMobile() != '') {
$return['plugins'][] = utils::o2a($plugin);
}
}
$return['custom'] = array();
$return['custom']['js'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.js');
$return['custom']['css'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.css');
ajax::success($return);
}
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234);
}
if (init('action') == 'ssh') {
ajax::success(shell_exec(init('command')));
}
if (init('action') == 'update') {
jeedom::update();
示例6: export
public function export()
{
$cmd = clone $this;
$cmd->setId('');
$cmd->setOrder('');
$cmd->setEqLogic_id('');
$cmd->cache = '';
$cmd->setDisplay('graphType', '');
$cmdValue = $cmd->getCmdValue();
if (is_object($cmdValue)) {
$cmd->setValue($cmdValue->getName());
} else {
$cmd->setValue('');
}
$return = utils::o2a($cmd);
foreach ($return as $key => $value) {
if (is_array($value)) {
foreach ($value as $key2 => $value2) {
if ($value2 == '') {
unset($return[$key][$key2]);
}
}
} else {
if ($value == '') {
unset($return[$key]);
}
}
}
if (isset($return['configuration']) && count($return['configuration']) == 0) {
unset($return['configuration']);
}
if (isset($return['display']) && count($return['display']) == 0) {
unset($return['display']);
}
return $return;
}
示例7: getAjaxElement
public function getAjaxElement($_mode = 'ajax')
{
$return = utils::o2a($this);
if ($_mode == 'array') {
if (isset($return['id'])) {
unset($return['id']);
}
if (isset($return['scenarioElement_id'])) {
unset($return['scenarioElement_id']);
}
if (isset($return['log'])) {
unset($return['log']);
}
if (isset($return['_expression'])) {
unset($return['_expression']);
}
}
$return['subElements'] = array();
foreach ($this->getSubElement() as $subElement) {
$subElement_ajax = utils::o2a($subElement);
if ($_mode == 'array') {
if (isset($subElement_ajax['id'])) {
unset($subElement_ajax['id']);
}
if (isset($subElement_ajax['scenarioElement_id'])) {
unset($subElement_ajax['scenarioElement_id']);
}
if (isset($subElement_ajax['log'])) {
unset($subElement_ajax['log']);
}
if (isset($subElement_ajax['_expression'])) {
unset($subElement_ajax['_expression']);
}
}
$subElement_ajax['expressions'] = array();
foreach ($subElement->getExpression() as $expression) {
$expression_ajax = utils::o2a($expression);
if ($_mode == 'array') {
if (isset($expression_ajax['id'])) {
unset($expression_ajax['id']);
}
if (isset($expression_ajax['scenarioSubElement_id'])) {
unset($expression_ajax['scenarioSubElement_id']);
}
if (isset($expression_ajax['log'])) {
unset($expression_ajax['log']);
}
if (isset($expression_ajax['_expression'])) {
unset($expression_ajax['_expression']);
}
}
if ($expression->getType() == 'element') {
$element = self::byId($expression->getExpression());
if (is_object($element)) {
$expression_ajax['element'] = $element->getAjaxElement($_mode);
if ($_mode == 'array') {
if (isset($expression_ajax['element']['id'])) {
unset($expression_ajax['element']['id']);
}
if (isset($expression_ajax['element']['scenarioElement_id'])) {
unset($expression_ajax['element']['scenarioElement_id']);
}
if (isset($expression_ajax['element']['log'])) {
unset($expression_ajax['element']['log']);
}
if (isset($expression_ajax['element']['_expression'])) {
unset($expression_ajax['element']['_expression']);
}
}
}
}
$expression_ajax = jeedom::toHumanReadable($expression_ajax);
$subElement_ajax['expressions'][] = $expression_ajax;
}
$return['subElements'][] = $subElement_ajax;
}
return $return;
}
示例8: sendVarToJS
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{{Changement}}</label>
<div class="col-sm-9">
<textarea class="form-control" id="ta_marketSendChange" placeholder="{{Changement}}" style="height: 150px;"></textarea>
</div>
</div>
<a class="btn btn-success pull-right" id="bt_marketSendValideChange"><i class="fa fa-check"></i> {{Valider}}</a>
<a class="btn btn-default pull-right" id="bt_marketSendCancelChange"><i class="fa fa-times"></i> {{Annuler}}</a>
</form>
</div>
<?php
if (is_object($market)) {
sendVarToJS('market_display_info', utils::o2a($market));
}
?>
<script>
$("#md_marketSendChangeChange").dialog({
autoOpen: false,
modal: true,
height: 400,
width:700,
position: {my: 'center', at: 'center', of: window},
open: function () {
$("body").css({overflow: 'hidden'});
},
beforeClose: function (event, ui) {
$("body").css({overflow: 'inherit'});
}
示例9: Exception
}
if (is_numeric(init('id'))) {
$cmd = cmd::byId(init('id'));
if (!is_object($cmd)) {
throw new Exception(__('Cmd ID inconnu : ', __FILE__) . init('id'));
}
$eqLogic = $cmd->getEqLogic();
if (!$eqLogic->hasRight('r')) {
throw new Exception(__('Vous n\'êtes pas autorisé à faire cette action', __FILE__));
}
$histories = $cmd->getHistory($dateStart, $dateEnd);
$return['cmd_name'] = $cmd->getName();
$return['history_name'] = $cmd->getHumanName();
$return['unite'] = $cmd->getUnite();
$return['cmd'] = utils::o2a($cmd);
$return['eqLogic'] = utils::o2a($cmd->getEqLogic());
$previsousValue = null;
$derive = init('derive', $cmd->getDisplay('graphDerive'));
if (trim($derive) == '') {
$derive = $cmd->getDisplay('graphDerive');
}
foreach ($histories as $history) {
$info_history = array();
$info_history[] = floatval(strtotime($history->getDatetime() . " UTC")) * 1000;
$value = $history->getValue() === null ? null : floatval($history->getValue());
if ($derive == 1 || $derive == '1') {
if ($value !== null && $previsousValue != null) {
$value = $value - $previsousValue;
} else {
$value = null;
}
示例10: save
public function save()
{
$cache = cache::byKey('market::info::' . $this->getLogicalId());
if (is_object($cache)) {
$cache->remove();
}
$market = self::getJsonRpc();
$params = utils::o2a($this);
if (isset($params['changelog'])) {
unset($params['changelog']);
}
switch ($this->getType()) {
case 'plugin':
$cibDir = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId();
if (file_exists($cibDir)) {
rrmdir($cibDir);
}
mkdir($cibDir);
$exclude = array('tmp');
rcopy(realpath(dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId()), $cibDir, true, $exclude, true);
$tmp = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId() . '.zip';
if (file_exists($tmp)) {
if (!unlink($tmp)) {
throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__));
}
}
if (!create_zip($cibDir, $tmp)) {
throw new Exception(__('Echec de création de l\'archive zip', __FILE__));
}
break;
default:
$type = $this->getType();
if (!class_exists($type) || !method_exists($type, 'shareOnMarket')) {
throw new Exception(__('Aucune fonction correspondante à : ', __FILE__) . $type . '::shareOnMarket');
}
$tmp = $type::shareOnMarket($this);
break;
}
if (!file_exists($tmp)) {
throw new Exception(__('Impossible de trouver le fichier à envoyer : ', __FILE__) . $tmp);
}
$file = array('file' => '@' . realpath($tmp));
if (!$market->sendRequest('market::save', $params, 30, $file)) {
throw new Exception($market->getError());
}
$update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId());
if (!is_object($update)) {
$update = new update();
$update->setLogicalId($this->getLogicalId());
$update->setType($this->getType());
}
$update->setConfiguration('version', 'beta');
$update->setLocalVersion(date('Y-m-d H:i:s', strtotime('+10 minute' . date('Y-m-d H:i:s'))));
$update->save();
$update->checkUpdate();
}
示例11: Exception
<?php
if (!isConnect('admin')) {
throw new Exception('{{401 - Accès non autorisé}}');
}
$cmd = cmd::byId(init('cmd_id'));
if (!is_object($cmd)) {
throw new Exception('Commande non trouvé : ' . init('cmd_id'));
}
sendVarToJS('cmdInfo', jeedom::toHumanReadable(utils::o2a($cmd)));
$cmd_widgetDashboard = cmd::availableWidget('dashboard');
$cmd_widgetMobile = cmd::availableWidget('mobile');
?>
<div style="display: none;" id="md_displayCmdConfigure"></div>
<a class="btn btn-success btn-sm pull-right" id="bt_cmdConfigureSave"><i class="fa fa-check-circle"></i> {{Enregistrer}}</a>
<a class="btn btn-default pull-right btn-sm" id="bt_cmdConfigureSaveOn"><i class="fa fa-plus-circle"></i> {{Appliquer à}}</a>
<div role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#information" aria-controls="home" role="tab" data-toggle="tab"><i class="fa fa-info-circle"></i> {{Informations}}</a></li>
<li role="presentation"><a href="#configuration" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-wrench"></i> {{Configuration avancée}}</a></li>
<li role="presentation"><a href="#display" aria-controls="messages" role="tab" data-toggle="tab"><i class="fa fa-desktop"></i> {{Affichage avancé}}</a></li>
</ul>
<div class="tab-content" id="div_displayCmdConfigure">
<div role="tabpanel" class="tab-pane active" id="information">
<br/>
示例12: init
utils::a2o($market, $market_ajax);
$market->save();
ajax::success();
}
if (init('action') == 'getInfo') {
ajax::success(market::getInfo(init('logicalId')));
}
if (init('action') == 'byLogicalId') {
if (init('noExecption', 0) == 1) {
try {
ajax::success(utils::o2a(market::byLogicalIdAndType(init('logicalId'), init('type'))));
} catch (Exception $e) {
ajax::success();
}
} else {
ajax::success(utils::o2a(market::byLogicalIdAndType(init('logicalId'), init('type'))));
}
}
if (init('action') == 'test') {
ajax::success(market::test());
}
if (init('action') == 'setRating') {
$market = market::byId(init('id'));
if (!is_object($market)) {
throw new Exception(__('Impossible de trouver l\'objet associé : ', __FILE__) . init('id'));
}
$market->setRating(init('rating'));
ajax::success();
}
if (init('action') == 'setComment') {
$market = market::byId(init('id'));
示例13: json_decode
if (init('action') == 'savePlanHeader') {
$planHeader_ajax = json_decode(init('planHeader'), true);
$planHeader = planHeader::byId($planHeader_ajax['id']);
if (!is_object($planHeader)) {
$planHeader = new planHeader();
}
utils::a2o($planHeader, $planHeader_ajax);
$planHeader->save();
ajax::success(utils::o2a($planHeader));
}
if (init('action') == 'copyPlanHeader') {
$planHeader = planHeader::byId(init('id'));
if (!is_object($planHeader)) {
throw new Exception(__('Plan header inconnu verifié l\'id : ', __FILE__) . init('id'));
}
ajax::success(utils::o2a($planHeader->copy(init('name'))));
}
if (init('action') == 'uploadImage') {
$planHeader = planHeader::byId(init('id'));
if (!is_object($planHeader)) {
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);
}
if (filesize($_FILES['file']['tmp_name']) > 5000000) {
throw new Exception(__('Le fichier est trop gros (maximum 5mo)', __FILE__));
示例14: export
public function export($_withCmd = true)
{
$eqLogic = clone $this;
$eqLogic->setId('');
$eqLogic->setLogicalId('');
$eqLogic->setObject_id('');
$eqLogic->setIsEnable('');
$eqLogic->setIsVisible('');
$eqLogic->setTimeout('');
$eqLogic->setOrder('');
$eqLogic->setConfiguration('nerverFail', '');
$eqLogic->setConfiguration('noBatterieCheck', '');
$return = utils::o2a($eqLogic);
foreach ($return as $key => $value) {
if (is_array($value)) {
foreach ($value as $key2 => $value2) {
if ($value2 == '') {
unset($return[$key][$key2]);
}
}
} else {
if ($value == '') {
unset($return[$key]);
}
}
}
if (isset($return['configuration']) && count($return['configuration']) == 0) {
unset($return['configuration']);
}
if (isset($return['display']) && count($return['display']) == 0) {
unset($return['display']);
}
if ($_withCmd) {
$return['cmd'] = array();
foreach ($this->getCmd() as $cmd) {
$return['cmd'][] = $cmd->export();
}
}
return $return;
}
示例15: Exception
}
if (filesize($_FILES['file']['tmp_name']) > 5000000) {
throw new Exception(__('Le fichier est trop gros (miximum 5mo)', __FILE__));
}
$object->setImage('type', str_replace('.', '', $extension));
$object->setImage('size', getimagesize($_FILES['file']['tmp_name']));
$object->setImage('data', base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$object->save();
ajax::success();
}
if (init('action') == 'getChild') {
$object = object::byId(init('id'));
if (!is_object($object)) {
throw new Exception(__('Objet inconnu verifié l\'id', __FILE__));
}
$return = utils::o2a($object->getChild());
ajax::success($return);
}
if (init('action') == 'toHtml') {
if (init('id') == 'all' || is_json(init('id'))) {
if (is_json(init('id'))) {
$object_ajax = json_decode(init('id'), true);
$objects = array();
foreach ($object_ajax as $id) {
$objects[] = object::byId($id);
}
} else {
$objects = object::all();
}
$return = array();
foreach ($objects as $object) {